Commit in lcsim-contrib/src/main/java/org/lcsim/contrib/SteveMagill on MAIN | |||
TrCoreClusDiagDriver.java | +96 | added 1.1 |
diff -N TrCoreClusDiagDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TrCoreClusDiagDriver.java 14 Feb 2012 19:24:58 -0000 1.1 @@ -0,0 +1,96 @@
+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 org.lcsim.recon.cluster.util.BasicCluster; + +/** + * Diagnostic routine to evaluate performance of mip finder + */ + +public class TrCoreClusDiagDriver extends Driver +{ + public TrCoreClusDiagDriver() { + } + + private String _tcclusname; + private AIDA aida = AIDA.defaultInstance(); + private boolean tccD = true; + + public void process(EventHeader event) + { + int NCoreCl = 0; + int nhitstm = 0; // number of hits in all core clusters + int nchhitstm = 0; // number of charged particle hits in all core clusters + int nnhhitstm = 0; // number of neutral hadron hits in core clusters + int nphohitstm = 0; // number of photon hits in core clusters + + try + { + List<BasicCluster> tcclusters = event.get(BasicCluster.class,_tcclusname); + if (tccD) aida.cloud1D("Number of Core Clusters").fill(tcclusters.size()); + for (BasicCluster tcclus : tcclusters) + { + NCoreCl++; + int numhits = tcclus.getSize(); // number of hits in this mip cluster + nhitstm += tcclus.getSize(); // sum hits from all mip clusters in event + double tcclE = tcclus.getEnergy(); // energy of this mip cluster + if (tccD) aida.cloud1D("Tr Core Clus E").fill(tcclE); + if (tccD) aida.cloud1D("Tr Core Clus Size").fill(numhits); + if (tccD) aida.cloud2D("Tr Core NumHits vs E").fill(tcclE,numhits); + List<CalorimeterHit> tmcalhits = tcclus.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; + if (tccD) aida.cloud2D("NClus hits vs NMC hits per TrCoreClus").fill(numchits,numhits); + if (tccD) aida.cloud1D("MC Particle Purity per TrCoreClus").fill(hrat); + } + } + double dnhitstm = nhitstm; + double dnchhitstm = nchhitstm; + double mipTot = dnchhitstm/dnhitstm; + double dnphohitstm = nphohitstm; + double dnnhhitstm = nnhhitstm; + if (nhitstm>0 && tccD) + { + aida.cloud1D("MC Particle Purity TrCores per event").fill(mipTot); + aida.cloud1D("Pho conf TrCores per event").fill(dnphohitstm/dnhitstm); + aida.cloud1D("NeuH conf TrCores per event").fill(dnnhhitstm/dnhitstm); + } + + } + catch(java.lang.IllegalArgumentException ex) + { + System.out.println("requested object not found in event " + _tcclusname); + } + + // for single particles + if (NCoreCl == 1 && tccD) + { + aida.cloud1D("Num Hits Core Clus single cluster").fill(nhitstm); + } + } + + public void setTrCoreClusName(String tcclusname) + { + _tcclusname = tcclusname; + } + +}
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