Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/SteveMagill on MAIN | |||
TrMipClusDiagDriver.java | +101 | added 1.1 |
diff -N TrMipClusDiagDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TrMipClusDiagDriver.java 14 Feb 2012 19:22:17 -0000 1.1 @@ -0,0 +1,101 @@
+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.SimCalorimeterHit; +import hep.physics.vec.Hep3Vector; +import org.lcsim.event.Track; +import org.lcsim.recon.cluster.util.BasicCluster; +import org.lcsim.spacegeom.*; +import org.lcsim.event.base.*; +import org.lcsim.event.MCParticle; + +/** + * Diagnostic routine to evaluate performance of mip finder + */ + +public class TrMipClusDiagDriver extends Driver +{ + public TrMipClusDiagDriver() { + } + + private String _tmclusname; + private AIDA aida = AIDA.defaultInstance(); + private boolean perfPFAD = true; + private boolean muons = false; + + public void process(EventHeader event) + { + int NMipCl = 0; + int nhitstm = 0; // number of hits in all mip clusters + int nchhitstm = 0; // number of charged particle hits in all mip clusters + int nnhhitstm = 0; // number of neutral hadron hits in mip clusters + int nphohitstm = 0; // number of photon hits in mip clusters + + try + { + List<BasicCluster> tmclusters = event.get(BasicCluster.class,_tmclusname); + for (BasicCluster tmclus : tmclusters) + { + NMipCl++; + int numhits = tmclus.getSize(); // number of hits in this mip cluster + nhitstm += tmclus.getSize(); // sum hits from all mip clusters in event + double tmclE = tmclus.getEnergy(); // energy of this mip cluster + aida.cloud1D("Tr Mip Clus E").fill(tmclE); + aida.cloud1D("Tr Mip Clus Size").fill(numhits); + aida.cloud2D("Tr Mip NumHits vs E").fill(tmclE,numhits); + List<CalorimeterHit> tmcalhits = tmclus.getCalorimeterHits(); + int numchits = 0; + for (CalorimeterHit tmhit : tmcalhits) + { + SimCalorimeterHit hit = (SimCalorimeterHit) tmhit; + double hitch = Math.abs(hit.getMCParticle(0).getCharge()); + double hitm = hit.getMCParticle(0).getMass(); + if (hitch>0) numchits++; + if (hitch>0) nchhitstm++; + if (hitch==0 && hitm==0) nphohitstm++; + if (hitch==0 && hitm>0) nnhhitstm++; + } + if (numhits>0) + { + double dnumhits = numhits; + double dnumchits = numchits; + double hrat = dnumchits/dnumhits; + aida.cloud2D("NClus hits vs NMC hits per TrMipClus").fill(numchits,numhits); + aida.cloud1D("MC Particle Purity per TrMipClus").fill(hrat); + } + } + double dnhitstm = nhitstm; + double dnchhitstm = nchhitstm; + double mipTot = dnchhitstm/dnhitstm; + double dnphohitstm = nphohitstm; + double dnnhhitstm = nnhhitstm; + if (nhitstm>0) + { + aida.cloud1D("MC Particle Purity TrMips per event").fill(mipTot); + aida.cloud1D("Pho conf TrMips per event").fill(dnphohitstm/dnhitstm); + aida.cloud1D("NeuH conf TrMips per event").fill(dnnhhitstm/dnhitstm); + } + + } + catch(java.lang.IllegalArgumentException ex) + { + System.out.println("requested object not found in event " + _tmclusname); + } + + // for single particles + if (NMipCl == 1) + { + aida.cloud1D("Num Hits Mip Clus single cluster").fill(nhitstm); + } + } + + public void setTrMipClusName(String tmclusname) + { + _tmclusname = tmclusname; + } + +}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1