Print

Print


Hi, Kyle.

This should help…

public class EcalCrystalExample extends Driver {

    

    IDetectorElementContainer crystals;
    IIdentifierHelper helper;
    int system;
    public void detectorChanged(Detector detector) {
        Subdetector subdetector = detector.getSubdetector("Ecal");
        system = subdetector.getSystemID();
        helper = subdetector.getDetectorElement().getIdentifierHelper();
        crystals = subdetector.getDetectorElement().getChildren();
    }    

    

    public void process(EventHeader event) {
        List<CalorimeterHit> hits = event.get(CalorimeterHit.class, "EcalCalHits");
        for (CalorimeterHit hit : hits) {

            

            EcalCrystal crystal;

            

            // Find crystal from hit ID.
            crystal = (EcalCrystal) crystals.find(hit.getIdentifier());

            

            // Hit already points to crystal directly.   
            crystal = (EcalCrystal) hit.getDetectorElement();

            

            // Example of making a new ID to lookup crystal.
            IExpandedIdentifier expId = new ExpandedIdentifier();
            expId.addValue(system);
    expId.addValue(0); 
            expId.addValue(helper.getValue(hit.getIdentifier(), "ix"));
            expId.addValue(helper.getValue(hit.getIdentifier(), "iy"));
            IIdentifier crystalId = helper.pack(expId);
            crystal = (EcalCrystal) crystals.find(crystalId);            

            

            System.out.println(crystal.getName() + " @ " + crystal.getGeometry().getPosition());
        }        
    }
}

You should look at the section commented as “Example of making a new ID” where I use the hit’s X and Y values to lookup the crystal.  But these could be values coming from some other source than the hit.

You can also loop over all the crystals in the container to find what you need there but lookup by ID will be much faster.

—Jeremy


On Feb 7, 2015, at 10:09 AM, Kyle McCarty <[log in to unmask]> wrote:

Hello hps-software,

I need to know how to obtain the x/y position (in mm) from the geometry when I only know the crystal x/y-index. This is needed for calculating some of the trigger cuts for the purpose of applying them to cluster reported by the SSP bank. Since these only provide the x/y-index and do not contain actual CalorimeterHit objects, I am unsure where to look for the information. (Normally these values are calculated for regular clusters by calling cluster.getCalorimeterHits().get(0).getPosition()).

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




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