View Javadoc

1   package org.lcsim.analysis;
2   
3   import java.util.ArrayList;
4   import java.util.HashMap;
5   import java.util.List;
6   import java.util.Map;
7   import org.lcsim.event.CalorimeterHit;
8   import org.lcsim.event.Cluster;
9   import org.lcsim.event.EventHeader;
10  import org.lcsim.event.LCRelation;
11  import org.lcsim.event.MCParticle;
12  import org.lcsim.event.ReconstructedParticle;
13  import org.lcsim.event.SimCalorimeterHit;
14  import org.lcsim.event.base.BaseLCRelation;
15  import org.lcsim.util.Driver;
16  import static org.lcsim.util.Driver.HLEVEL_FULL;
17  import static org.lcsim.util.Driver.HLEVEL_NORMAL;
18  import org.lcsim.util.aida.AIDA;
19  
20  /**
21   *
22   * @author Norman A Graf
23   *
24   * @version $Id:
25   */
26  public class ReconstructedParticleAnalysis extends Driver
27  {
28  
29      private AIDA aida = AIDA.defaultInstance();
30  
31      @Override
32      protected void process(EventHeader event)
33      {
34          // The Monte carlo Particles
35          List<MCParticle> mcparts = event.getMCParticles();
36          for (MCParticle mcp : mcparts) {
37              // only book final state particles here...
38              if (mcp.getGeneratorStatus() == MCParticle.FINAL_STATE) {
39                  aida.cloud1D("MC final state PDG ID").fill(mcp.getPDGID());
40              }
41          }
42          // need to set  up the relation between CalorimeterHit ans SimCalorimeterHit
43          List<LCRelation> caloHitSimHitRelation = event.get(LCRelation.class, "CalorimeterHitRelations");
44          Map<CalorimeterHit, SimCalorimeterHit> simhitmap = new HashMap<CalorimeterHit, SimCalorimeterHit>();
45          for (LCRelation relation : caloHitSimHitRelation) {
46              CalorimeterHit digiHit = (CalorimeterHit) relation.getFrom();
47              SimCalorimeterHit simHit = (SimCalorimeterHit) relation.getTo();
48              simhitmap.put(digiHit, simHit);
49          }
50  
51          // the ReconstructedParticles
52          List<ReconstructedParticle> rplist = event.get(ReconstructedParticle.class, "PandoraPFOCollection");
53          aida.cloud1D("Number of ReconstructedParticles found").fill(rplist.size());
54          double eventEnergy = 0.;
55          for (ReconstructedParticle rp : rplist) {
56              eventEnergy += rp.getEnergy();
57              aida.cloud1D("Energy").fill(rp.getEnergy());
58              int id = rp.getType();
59              aida.cloud1D("Cluster Energy pid= " + id).fill(rp.getEnergy());
60              List<Cluster> clusters = rp.getClusters();
61              for (Cluster clus : clusters) {
62                  List<CalorimeterHit> hits = clus.getCalorimeterHits();
63                  for (CalorimeterHit hit : hits) {
64                      //get the SimCalorimeterHit that corresponds to this hit
65                      SimCalorimeterHit simHit = simhitmap.get(hit);
66                      // TODO: flesh out the analysis here...
67                  }
68              }
69          }
70          aida.cloud1D("Event Energy").fill(eventEnergy);
71      }
72  }