1 package org.lcsim.cal.calib;
2
3 import java.util.List;
4 import org.lcsim.event.EventHeader;
5 import org.lcsim.event.MCParticle;
6 import org.lcsim.event.SimCalorimeterHit;
7 import org.lcsim.geometry.IDDecoder;
8 import org.lcsim.util.Driver;
9 import org.lcsim.util.aida.AIDA;
10
11
12
13
14
15
16
17 public class MipSamplingFractionAnalysisDriver extends Driver
18 {
19
20 private boolean _debug = false;
21 private AIDA aida = AIDA.defaultInstance();
22
23 @Override
24 protected void process(EventHeader event)
25 {
26 List<MCParticle> mcparts = event.getMCParticles();
27
28 MCParticle mcpart = mcparts.get(mcparts.size() - 1);
29 String particleType = mcpart.getType().getName();
30 log(particleType);
31 if (particleType.equals("mu+") && mcpart.getSimulatorStatus().hasLeftDetector())
32 {
33 List<SimCalorimeterHit> ecalhits = event.get(SimCalorimeterHit.class, "EcalBarrelHits");
34 log("There are " + ecalhits.size() + " EcalBarrelHits");
35 for (SimCalorimeterHit hit : ecalhits)
36 {
37 long cellId = hit.getCellID();
38 IDDecoder d = hit.getIDDecoder();
39 d.setID(cellId);
40 int layer = d.getLayer();
41 int slice = d.getValue("slice");
42 log(layer + " " + slice);
43 aida.cloud1D("ECal layer" + layer + "_slice" + slice + " energy").fill(hit.getRawEnergy());
44 if (layer > 0 && layer < 21)
45 {
46 if (slice == 0)
47 aida.histogram1D("ECal thin layer absorber energy",100,0.,0.05).fill(hit.getRawEnergy());
48 if (slice == 2)
49 aida.histogram1D("ECal thin layer silicon energy",100,0.,0.001).fill(hit.getRawEnergy());
50 }
51 if (layer > 20)
52 {
53 if (slice == 0)
54 aida.histogram1D("ECal thick layer absorber energy",100,0.,0.05).fill(hit.getRawEnergy());
55 if (slice == 2)
56 aida.histogram1D("ECal thick layer silicon energy",100,0.,0.001).fill(hit.getRawEnergy());
57 }
58
59 }
60 List<SimCalorimeterHit> hcalhits = event.get(SimCalorimeterHit.class, "HcalBarrelHits");
61 log("There are " + hcalhits.size() + " HcalBarrelHits");
62 for (SimCalorimeterHit hit : hcalhits)
63 {
64 long cellId = hit.getCellID();
65 IDDecoder d = hit.getIDDecoder();
66 d.setID(cellId);
67 int layer = d.getLayer();
68 int slice = d.getValue("slice");
69 log(layer + " " + slice);
70 aida.cloud1D("HCal layer" + layer + "_slice" + slice + " energy").fill(hit.getRawEnergy());
71
72
73 }
74 }
75 }
76
77 @Override
78 protected void endOfData()
79 {
80
81 }
82
83 private void log(String s)
84 {
85 if (_debug)
86 System.out.println(s);
87 }
88 }