lcsim-contrib/src/main/java/org/lcsim/contrib/SteveMagill
diff -N SChJetLinkDriver.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SChJetLinkDriver.java 12 Aug 2009 18:33:40 -0000 1.1
@@ -0,0 +1,112 @@
+package org.lcsim.contrib.SteveMagill;
+
+import java.util.*;
+import org.lcsim.event.*;
+import org.lcsim.util.Driver;
+import hep.physics.vec.Hep3Vector;
+import org.lcsim.util.aida.AIDA;
+import hep.aida.ITree;
+
+public class SChJetLinkDriver extends Driver
+{
+ private AIDA aida = AIDA.defaultInstance();
+ private double _clldis;
+ private ITree _tree;
+ private boolean linkD = true;
+ private String _sjetname;
+ private String _chjetname;
+ private String _olmapname;
+
+ public SChJetLinkDriver(double clldis)
+ {
+ _clldis = clldis;
+ }
+
+ protected void process(EventHeader event)
+ {
+ super.process(event); // executes all added drivers
+
+ // loop over all Scin jets
+ Map<ReconstructedParticle, ReconstructedParticle> schmap = new HashMap<ReconstructedParticle, ReconstructedParticle>();
+ int nlink = 0;
+ try
+ {
+ List<ReconstructedParticle> Sjets = event.get(ReconstructedParticle.class,_sjetname);
+// System.out.println("Number of S Clus" + Sclusters.size());
+ for (ReconstructedParticle sjet : Sjets)
+ {
+ Hep3Vector ecp = sjet.getMomentum();
+ double ecpx = ecp.x();
+ double ecpy = ecp.y();
+ double ecpz = ecp.z();
+ double ecR = Math.sqrt(ecpx*ecpx+ecpy*ecpy);
+ double eclth = Math.atan(ecR/ecpz);
+ if (eclth<0) eclth+=Math.PI;
+ double eclph = Math.atan2(ecpy,ecpx);
+ if (eclph<0) eclph+=2*Math.PI;
+ if (linkD) aida.cloud1D("Theta of S jets").fill(eclth);
+ if (linkD) aida.cloud1D("Phi of S jets").fill(eclph);
+
+ // now check with ch jets to make links
+ try
+ {
+ List<ReconstructedParticle> CHjets = event.get(ReconstructedParticle.class,_chjetname);
+ for (Iterator<ReconstructedParticle> chj = CHjets.iterator(); chj.hasNext();)
+ {
+ ReconstructedParticle ihj = chj.next();
+ Hep3Vector hcp = ihj.getMomentum();
+ double hcpx = hcp.x();
+ double hcpy = hcp.y();
+ double hcpz = hcp.z();
+ double hcR = Math.sqrt(hcpx*hcpx+hcpy*hcpy);
+ double hclth = Math.atan(hcR/hcpz);
+ if (hclth<0) hclth+=Math.PI;
+ double hclph = Math.atan2(hcpy,hcpx);
+ if (hclph<0) hclph+=2*Math.PI;
+ if (linkD) aida.cloud1D("Theta of CH jets").fill(hclth);
+ if (linkD) aida.cloud1D("Phi of CH jets").fill(hclph);
+ // calculate distance in theta phi
+ double dccth = Math.abs(eclth-hclth);
+ double dccph = Math.abs(eclph-hclph);
+ if (dccph>Math.PI) dccph = 2*Math.PI-dccph;
+ double dist = Math.sqrt(dccth*dccth+dccph*dccph);
+ if (linkD) aida.cloud1D("Distance between S and CH jets").fill(dist);
+ // test for distance and merge if close, removing merged hadclusters from list
+ if (dist<_clldis)
+ {
+ schmap.put(sjet, ihj);
+ nlink++;
+ aida.cloud1D("Cer over Sci E ratio for matched jets").fill(ihj.getEnergy()/sjet.getEnergy());
+ }
+ } // end of cher jet loop
+ }
+ catch (java.lang.IllegalArgumentException ex)
+ {
+ System.out.println("No CH jets in link");
+ }
+ } // end of S cluster loop
+ }
+ catch (java.lang.IllegalArgumentException ex)
+ {
+ System.out.println("No S jets in link");
+ }
+ aida.cloud1D("Number of SC jet links").fill(nlink);
+ event.put(_olmapname,schmap);
+
+ } // end of event loop
+
+ public void setInputScinJetName(String sjname)
+ {
+ _sjetname = sjname;
+ }
+ public void setInputCherJetName(String chjname)
+ {
+ _chjetname = chjname;
+ }
+ public void setOutputLinkMapName(String olmapname)
+ {
+ _olmapname = olmapname;
+ }
+
+}
+