Hello Jeremy,

I was attempting to implement your first example with the following code:

    public void detectorChanged(Detector detector) {
        for(EcalCrystal crystal : detector.getSubdetector("Ecal").getDetectorElement().findDescendants(EcalCrystal.class)) {
            CalorimeterHit tempHit = CalorimeterHitUtilities.create(0, 0, crystal.getIdentifier().getValue());
            int ix = tempHit.getIdentifierFieldValue("ix");
            int iy = tempHit.getIdentifierFieldValue("iy");
            double[] xyz = tempHit.getPosition();
            System.out.printf("(%3d, %3d) --> (%.2f, %.2f)%n", ix, iy, xyz[0], xyz[1]);

When running this, I obtain the error:

        at org.lcsim.event.base.BaseHit.getIDDecoder(BaseHit.java:127)
        at org.lcsim.event.base.BaseHit.getSubdetector(BaseHit.java:67)
        at org.lcsim.event.base.BaseHit.getIdentifierHelper(BaseHit.java:111)
        at org.lcsim.event.base.BaseHit.getIdentifierFieldValue(BaseHit.java:159)
        at org.hps.users.kmccarty.TriggerDiagnosticDriver.detectorChanged(TriggerDiagnosticDriver.java:53)
        at org.lcsim.util.Driver.detectorChanged(Driver.java:171)
        at org.lcsim.util.DriverAdapter.detectorChanged(DriverAdapter.java:86)
        at org.lcsim.util.DriverAdapter.recordSupplied(DriverAdapter.java:72)
        at org.freehep.record.loop.DefaultRecordLoop.consumeRecord(DefaultRecordLoop.java:832)
        at org.freehep.record.loop.DefaultRecordLoop.loop(DefaultRecordLoop.java:668)
        at org.freehep.record.loop.DefaultRecordLoop.execute(DefaultRecordLoop.java:566)
        at org.lcsim.util.loop.LCSimLoop.loop(LCSimLoop.java:153)
        at org.lcsim.job.JobControlManager.run(JobControlManager.java:429)
        at org.hps.job.JobManager.run(JobManager.java:36)
        at org.lcsim.job.JobControlManager.run(JobControlManager.java:187)
        at org.hps.job.JobManager.main(JobManager.java:18)

This occurs at the line "int ix = tempHit.getIdentifierFieldValue("ix");". Note that it does print the ID value (specifically 4129037, if it is useful). Do you know what is causing this issue?



On Fri, Feb 6, 2015 at 3:58 PM, McCormick, Jeremy I. <[log in to unmask]> wrote:
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...

On Feb 6, 2015, at 9:53 AM, Kyle McCarty <[log in to unmask]> wrote:

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?



On Thu, Feb 5, 2015 at 8:53 AM, Kyle McCarty <[log in to unmask]> wrote:
Hello Jeremy,

Is there a quick way to get the "ID" field that is needed when creating a CalorimeterHit object from the x- and y- indices?

I am trying to create an extension of BaseCluster to represent the clusters reported by the SSP. These will never be persisted since they are generated automatically from the SSP bank data during a run, so there is no concern over whether they are LCIO-compatible.



Use REPLY-ALL to reply to list

To unsubscribe from the HPS-SOFTWARE list, click the following link: