Apologies, my last reply might have been an incomplete draft.
Here’s an example of creating hits directly from the crystal objects in the geometry...
public
class IdExample extends Driver {
IIdentifierHelper
helper;
Subdetector
subdet;
public void detectorChanged(Detector
detector) {
subdet = detector.getSubdetector("Ecal");
helper = subdet.getDetectorElement().getIdentifierHelper();
}
public void process(EventHeader
event) {
for (EcalCrystal crystal :
subdet.getDetectorElement().findDescendants(EcalCrystal.class)) {
IIdentifier
id = crystal.getIdentifier();
CalorimeterHitUtilities.create(0, 0,
id.getValue());
}
}
}
You can also do something similar based on the EcalChannel conditions….
public
class EcalChannelIdExample
extends Driver {
EcalChannelCollection
channels;
int sys;
IIdentifierHelper
helper;
public void detectorChanged(Detector
detector) {
channels = DatabaseConditionsManager.getInstance().getCollection(EcalChannelCollection.class);
helper = detector.getSubdetector("Ecal").getDetectorElement().getIdentifierHelper();
sys = detector.getSubdetector("Ecal").getSystemID();
}
public void process(EventHeader
event) {
for (EcalChannel channel :
channels) {
IExpandedIdentifier
id = new ExpandedIdentifier();
int xIndex =
helper.getFieldIndex("ix");
int yIndex =
helper.getFieldIndex("iy");
int sysIndex =
helper.getFieldIndex("system");
id.setValue(xIndex,
channel.getX());
id.setValue(yIndex,
channel.getY());
id.setValue(sysIndex,
sys);
CalorimeterHitUtilities.create(0, 0,
helper.pack(id).getValue());
}
}
}
I think probably the second way is better because you can easily lookup whatever EcalChannel you want in the collection.
For instance, you can easily add some if statement to look at the X and Y of the channel as you are looping over them to determine if you want to use it or not for creating a hit.
If you have any questions about these examples let me know. Should be enough to point you in the right direction...
Hello Jeremy,
I'm not sure if this email got lost. I am trying to create a class for the SSP clusters that extends BaseCluster. I need to do this because I will need to run them through the trigger logic, and it uses BaseCluster objects as arguments. My plan was to create
a fake cluster that contains a seed hit with all of the reported energy at the correct cluster location and then populate the rest of the cluster with fake zero energy hits so that cluster.getCalorimeterHits().size() returns the correct cluster size. To do
this, I am trying to create the hits with CalorimeterHitUtilities.create(double, double, long), but I am unsure how to get the long cell ID from the ix/iy crystal indices. The conditions database gives ints for both channel and channel ID. Can you explain
how to obtain this value or suggest a better way to accomplish what I am trying to do?
Thanks,
Kyle