Print

Print


Commit in lcsim/src/org/lcsim/contrib/SteveMagill on MAIN
TrShowCompDriver.java+191added 1.1


lcsim/src/org/lcsim/contrib/SteveMagill
TrShowCompDriver.java added at 1.1
diff -N TrShowCompDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ TrShowCompDriver.java	29 May 2008 21:31:50 -0000	1.1
@@ -0,0 +1,191 @@
+package org.lcsim.contrib.compile.SteveMagill;
+
+import java.util.*;
+import org.lcsim.util.aida.AIDA;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+import org.lcsim.event.Cluster;
+import org.lcsim.event.MCParticle;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.SimCalorimeterHit;
+import org.lcsim.recon.cluster.util.BasicCluster;
+import org.lcsim.geometry.util.CalorimeterIDDecoder;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
+import org.lcsim.event.Track;
+import org.lcsim.util.hitmap.HitMap;
+import org.lcsim.recon.cluster.util.BasicCluster;
+
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.base.MCReconstructedParticle;
+import org.lcsim.event.ParticleID;
+import org.lcsim.recon.cluster.cheat.CheatCluster;
+import org.lcsim.event.ParticleID;
+import org.lcsim.event.ReconstructedParticle;
+import org.lcsim.event.base.BaseParticleID;
+import org.lcsim.event.base.BaseReconstructedParticle;
+import hep.physics.particle.properties.ParticlePropertyManager;
+import hep.physics.particle.properties.ParticleType;
+
+/**
+ *  Defines perfect particle flow objects - perfect charged particles, perfect photons and perfect neutral hadrons
+ */
+
+public class TrShowCompDriver extends Driver
+{
+  public TrShowCompDriver() {
+  }
+
+  private String _tsclusname;
+  private AIDA aida = AIDA.defaultInstance();
+  private boolean perfPFAD = true;
+  
+  public void process(EventHeader event) 
+  {
+      List<CheatCluster> chclusters = event.get(CheatCluster.class,"PerfectCheatClusters");
+      
+      //  check cores
+      int nhitsc = 0;  // number of hits in core clusters
+      int nchhitsc = 0;  // number of charged particle hits in core clusters
+      try
+      {
+      List<BasicCluster> tcclusters = event.get(BasicCluster.class,"TrackCoreClusters");
+      aida.cloud1D("Number of TrCore Clusters").fill(tcclusters.size());
+      for (BasicCluster tcclus : tcclusters)
+      {
+          int ncorehits = tcclus.getSize();
+          nhitsc += tcclus.getSize();
+          List<CalorimeterHit> tccalhits = tcclus.getCalorimeterHits();          
+          int nchcorehits = 0;
+          for (CalorimeterHit tchit : tccalhits)
+          {
+              SimCalorimeterHit hit = (SimCalorimeterHit) tchit;
+              double hitch = Math.abs(hit.getMCParticle(0).getCharge());
+              if (hitch>0) nchhitsc++;
+              if (hitch>0) nchcorehits++;
+          }
+          if (ncorehits>0)
+          {
+              double dncorehits = ncorehits;
+              double dnchcorehits = nchcorehits;
+              double hrat = dnchcorehits/dncorehits;
+              aida.cloud2D("NClus hits vs NMC hits TrCoreClus").fill(nchcorehits,ncorehits);
+              aida.cloud1D("MC Particle Purity per TrCoreClus").fill(hrat);
+          }          
+      }
+      double dnhitsc = nhitsc;
+      double dnchhitsc = nchhitsc;
+      double coreTot = dnchhitsc/dnhitsc;
+      if (nhitsc>0) aida.cloud1D("Total Particle Purity for TrCores in event").fill(coreTot);
+      }     
+      catch(java.lang.IllegalArgumentException ex)
+      {
+          System.out.println("requested object not found in event " + _tsclusname);      
+      }      
+      
+      int NMipCl = 0;
+      int NTrCALClus = 0;
+      int nhitstm = 0;
+      int nchhitstm = 0;
+      double trshclusE = 0.;
+      double trshclusP = 0.;
+      double hratTot = 0.;
+
+      try
+      {
+      List<BasicCluster> tsclusters = event.get(BasicCluster.class,_tsclusname);
+      aida.cloud1D("Number of TrCAL Clusters").fill(tsclusters.size());
+      for (BasicCluster tsclus : tsclusters)
+      {
+          NMipCl++;
+          NTrCALClus++;
+          int numhits = tsclus.getSize();
+          nhitstm += tsclus.getSize();
+          double tmclE = tsclus.getEnergy();
+          trshclusE += tsclus.getEnergy();
+          aida.cloud1D("Tr CAL Clus E").fill(tmclE);
+          aida.cloud1D("Tr CAL Clus Size").fill(numhits);
+          aida.cloud2D("NumHits vs E TrCALClus").fill(tmclE,numhits);
+          List<CalorimeterHit> tmcalhits = tsclus.getCalorimeterHits();
+          int numchits = 0;
+          for (CalorimeterHit tmhit : tmcalhits)
+          {
+              SimCalorimeterHit hit = (SimCalorimeterHit) tmhit;
+              double hitch = Math.abs(hit.getMCParticle(0).getCharge());
+              if (hitch>0) numchits++;
+              if (hitch>0) nchhitstm++;
+          }
+          if (numhits>0)
+          {
+              double dnumhits = numhits;
+              double dnumchits = numchits;
+              double hrat = dnumchits/dnumhits;
+              aida.cloud2D("NClus hits vs NMC hits TrCALClus").fill(numchits,numhits);
+              aida.cloud1D("MC Particle Purity per TrCAL Clus").fill(hrat);
+          }
+      }
+      double dnhitstm = nhitstm;
+      double dnchhitstm = nchhitstm;
+      hratTot = dnchhitstm/dnhitstm;
+      aida.cloud1D("Total Particle Purity for TrCAL in event").fill(hratTot);
+      }     
+      catch(java.lang.IllegalArgumentException ex)
+      {
+          System.out.println("requested object not found in event " + _tsclusname);      
+      }
+      
+      if (NMipCl == 1)
+      {
+          aida.cloud1D("Num Hits TrShow Clus single cluster").fill(nhitstm);
+      }
+      
+      //  Check the cheated clusters also
+      double chclusE = 0;
+      int NCheatCl = 0;
+      double PerfChHClE = 0;
+      double MCChHE = 0;
+      int nhitsingcl = 0;
+      double chclchpE = 0;
+      double chclchpP = 0;
+      aida.cloud1D("Number of Cheated TrCAL Clusters").fill(chclusters.size());
+      for (CheatCluster chclus : chclusters)
+      {
+          chclusE += chclus.getEnergy();
+          aida.cloud1D("Num hits in Perfect Cheat Cluster TrCAL").fill(chclus.getSize());
+          aida.cloud2D("Num hits vs E PerfCheatCl TrCAL").fill(chclus.getEnergy(),chclus.getSize());
+          aida.cloud1D("Num hits over E PerfCheatCl TrCAL").fill(chclus.getSize()/chclus.getEnergy());
+          if (chclus.getMCParticle().getCharge() != 0)
+          {
+              NCheatCl++;
+              nhitsingcl += chclus.getSize();
+              PerfChHClE += chclus.getEnergy();
+              MCChHE += chclus.getMCParticle().getEnergy();
+              chclchpE += chclus.getEnergy();
+              chclchpP += chclus.getMCParticle().getMomentum().magnitude();
+              aida.cloud1D("Cheated Cluster Charge E over P TrCAL").fill(chclchpE/chclchpP);
+          }
+      }
+      if (NCheatCl==1)
+      {
+          aida.cloud1D("Single CheatClus E over p").fill(chclchpE/chclchpP);
+          aida.cloud1D("Single CheatClus E Eff TrCALclus").fill(trshclusE/chclchpE);
+      }
+      if (NCheatCl > 0)
+      {
+          aida.cloud1D("Cheat Cluster Charge E over P TrCAL").fill(chclchpE/chclchpP);
+          aida.cloud1D("Cheated Cluster E single cluster TrCAL").fill(chclusE);
+          aida.cloud1D("Num Hits in Cheated Cluster single cluster TrCAL").fill(nhitsingcl);
+          double dnhitstm = nhitstm;
+          double dnhitsingcl = nhitsingcl;
+          aida.cloud1D("NHits Eff TrCALClus CheatClus").fill(dnhitstm/dnhitsingcl);
+          aida.cloud1D("E Eff TrCALClus CheatClus").fill(1.176*trshclusE/chclchpE);
+          aida.cloud2D("Charged Cluster EnEff vs hitP").fill(hratTot,1.176*trshclusE/chclchpE);
+      }
+  }
+  
+  public void setTrShowClusName(String tsclusname)
+  {
+      _tsclusname = tsclusname;
+  }
+  
+}
CVSspam 0.2.8