Print

Print


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?

Thanks,

Kyle

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.

Thanks,

Kyle




Use REPLY-ALL to reply to list

To unsubscribe from the HPS-SOFTWARE list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=HPS-SOFTWARE&A=1