Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/SteveMagill on MAIN
CALHitHistDriver.java+173added 1.1


lcsim-contrib/src/main/java/org/lcsim/contrib/SteveMagill
CALHitHistDriver.java added at 1.1
diff -N CALHitHistDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ CALHitHistDriver.java	12 Aug 2009 18:35:18 -0000	1.1
@@ -0,0 +1,173 @@
+package org.lcsim.contrib.SteveMagill;
+
+import java.util.*;
+import org.lcsim.util.aida.AIDA;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.ReconstructedParticle;
+
+public class CALHitHistDriver extends Driver
+{
+  public CALHitHistDriver() {
+  }
+
+  private String[] _scnames;
+  private String[] _chnames;
+  private String _rpname;
+  private AIDA aida = AIDA.defaultInstance();
+  
+  public void process(EventHeader event) 
+  {
+//  get energy of reco particle for this calibration
+      double parE = 0.;
+      List<ReconstructedParticle> recops = event.get(ReconstructedParticle.class,_rpname);
+      if (recops.size() == 1)
+      {
+          for (ReconstructedParticle rp : recops)
+          {
+              parE = rp.getEnergy();
+          }
+      }
+
+      //  get hit distributions with no threshold, timing cuts
+      List<CalorimeterHit> aehits = event.get(CalorimeterHit.class,"Edep_EcalBarrHits");
+      List<CalorimeterHit> ahhits = event.get(CalorimeterHit.class,"Edep_HcalBarrHits");
+      List<CalorimeterHit> behits = event.get(CalorimeterHit.class,"Ceren_EcalBarrHits");
+      List<CalorimeterHit> bhhits = event.get(CalorimeterHit.class,"Ceren_HcalBarrHits");
+      double ascESum = 0.;
+      double achESum = 0.;
+      double asceESum = 0.;
+      double aschESum = 0.;
+      double acheESum = 0.;
+      double achhESum = 0.;
+      for (CalorimeterHit aehit : aehits)
+      {
+//          aida.cloud1D("Scin EM All Hit E").fill(aehit.getCorrectedEnergy());
+          ascESum += aehit.getCorrectedEnergy();
+          asceESum += aehit.getCorrectedEnergy();
+          aida.cloud1D("Timing of EM scin hits").fill(aehit.getTime());
+      }
+      for (CalorimeterHit ahhit : ahhits)
+      {
+//          aida.cloud1D("Scin HAD All Hit E").fill(ahhit.getCorrectedEnergy());
+          ascESum += ahhit.getCorrectedEnergy();
+          aschESum += ahhit.getCorrectedEnergy();
+          aida.cloud1D("Timing of HAD scin hits").fill(ahhit.getTime());
+      }
+      for (CalorimeterHit behit : behits)
+      {
+//        aida.cloud1D("Ceren EM All Hit E").fill(behit.getCorrectedEnergy());
+          achESum += behit.getCorrectedEnergy();
+          acheESum += behit.getCorrectedEnergy();
+          aida.cloud1D("Timing of EM ceren hits").fill(behit.getTime());
+      }
+      for (CalorimeterHit bhhit : bhhits)
+      {
+//          aida.cloud1D("Ceren HAD All Hit E").fill(bhhit.getCorrectedEnergy());
+          achESum += bhhit.getCorrectedEnergy();
+          achhESum += bhhit.getCorrectedEnergy();
+          aida.cloud1D("Timing of HAD ceren hits").fill(bhhit.getTime());
+      }
+      aida.cloud1D("AllHit Scin ESum").fill(ascESum);
+      aida.cloud1D("AllHit Ceren ESum").fill(achESum);
+      aida.cloud1D("AllHit Scin EM ESum").fill(asceESum);
+      aida.cloud1D("AllHit Ceren EM ESum").fill(acheESum);
+      aida.cloud1D("AllHit Scin HAD ESum").fill(aschESum);
+      aida.cloud1D("AllHit Ceren HAD ESum").fill(achhESum);
+
+      double scETsum = 0.;
+      double scEMEsum = 0.;
+      double scHADEsum = 0.;
+      double chETsum = 0.;
+      double chEMEsum = 0.;
+      double chHADEsum = 0.;
+      double scElhadl = 0.;
+
+      //  first make scintillator plots
+      double nlhadl = 0;
+      double nhadhits = 0;
+      double nemhits = 0;
+      double nhadrat = 0.;
+      double nhademh = 0.;
+      for (int i=0; i<_scnames.length; i++)
+      {
+          List<CalorimeterHit> schits = event.get(CalorimeterHit.class,_scnames[i]);
+          for (CalorimeterHit schit : schits)
+          {
+              scETsum += schit.getCorrectedEnergy();
+              //  check individual collections
+              if (_scnames[i].equals("Edep_EcalBarrDigiHits") || _scnames[i].equals("Edep_EcalEndcapDigiHits"))
+              {
+                  scEMEsum += schit.getCorrectedEnergy();
+                  nemhits++;
+//                  int nlayer = schit.getMetaData().getIDDecoder().getLayer();
+                  aida.cloud1D("DigiSim Scin EM Hit E").fill(schit.getCorrectedEnergy());
+              }
+              if (_scnames[i].equals("Edep_HcalBarrDigiHits") || _scnames[i].equals("Edep_HcalEndcapDigiHits"))
+              {
+                  scHADEsum += schit.getCorrectedEnergy();
+                  nhadhits++;
+//                  int nlayer = schit.getMetaData().getIDDecoder().getLayer();
+                  aida.cloud1D("DigiSim Scin HAD Hit E").fill(schit.getCorrectedEnergy());
+                  {
+                      nlhadl++;
+                      scElhadl += schit.getCorrectedEnergy();
+                  }
+              }
+          }            
+      } 
+      aida.cloud1D("DigiSimHit Scin ESum").fill(scETsum);
+      double sccorf = parE/scETsum;
+      aida.cloud1D("eCalib DigiSimHit Scin").fill(sccorf);
+      aida.cloud1D("DigiSimHit Scin EM ESum").fill(scEMEsum);
+      aida.cloud1D("DigiSimHit Scin HAD ESum").fill(scHADEsum);
+
+      //  make cherenkov plots 
+      for (int i=0; i<_chnames.length; i++)
+      {
+          List<CalorimeterHit> chhits = event.get(CalorimeterHit.class,_chnames[i]);
+    //       CalorimeterIDDecoder caldecoder = (CalorimeterIDDecoder) event.getMetaData(chhits).getIDDecoder();
+          for (CalorimeterHit chhit : chhits)
+          {
+//               aida.cloud1D("Timing of Cherenkov hits").fill(chhit.getTime());
+              chETsum += chhit.getCorrectedEnergy();
+              //  check individual collections
+              if (_chnames[i].equals("Ceren_EcalBarrDigiHits") || _chnames[i].equals("Ceren_HcalEndcapDigiHits"))
+              {
+                  chEMEsum += chhit.getCorrectedEnergy();
+//                  int nlayer = chhit.getMetaData().getIDDecoder().getLayer();
+                  aida.cloud1D("DigiSim Ceren EM Hit E").fill(chhit.getCorrectedEnergy());
+              }
+              if (_chnames[i].equals("Ceren_HcalBarrDigiHits") || _chnames[i].equals("Ceren_HcalEndcapDigiHits"))
+              {
+                  chHADEsum += chhit.getCorrectedEnergy();
+//                  int nlayer = chhit.getMetaData().getIDDecoder().getLayer();
+                  aida.cloud1D("DigiSim Ceren HAD Hit E").fill(chhit.getCorrectedEnergy());
+              }
+          }            
+      } 
+      aida.cloud1D("DigiSimHit Ceren ESum").fill(chETsum);
+      double chcorf = parE/chETsum;
+      aida.cloud1D("eCalib DigiSimHit Ceren").fill(chcorf);
+      aida.cloud1D("DigiSimHit Ceren EM ESum").fill(chEMEsum);
+      aida.cloud1D("DigiSimHit Ceren HAD ESum").fill(chHADEsum);
+
+  }
+  
+  public void setScHitNames(String[] scnames)
+  {
+      _scnames = scnames;
+  }
+
+  public void setChHitNames(String[] chnames)
+  {
+      _chnames = chnames;
+  }
+
+  public void setMCRecoPName(String rpname)
+  {
+      _rpname = rpname;
+  }
+  
+}
CVSspam 0.2.8