Print

Print


Commit in lcsim/src/org/lcsim/contrib/SteveMagill on MAIN
NHCandClusterDriver.java+104added 1.1


lcsim/src/org/lcsim/contrib/SteveMagill
NHCandClusterDriver.java added at 1.1
diff -N NHCandClusterDriver.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ NHCandClusterDriver.java	18 May 2007 19:58:44 -0000	1.1
@@ -0,0 +1,104 @@
+package org.lcsim.contrib.SteveMagill;
+
+//  This driver extrapolates tracks into CAL, associating clusters to the tracks, testing E/p
+//  output : modified hit map and track cal clusters
+
+import java.util.*;
+import org.lcsim.event.CalorimeterHit;
+import org.lcsim.event.EventHeader;
+import org.lcsim.util.Driver;
+// import org.lcsim.util.swim.*;
+import org.lcsim.util.lcio.LCIOConstants;
+import org.lcsim.recon.cluster.util.*;
+import org.lcsim.util.aida.*;
+import org.lcsim.geometry.*;
+import hep.physics.vec.Hep3Vector;
+import hep.physics.vec.BasicHep3Vector;
+import hep.aida.*;
+
+public class NHCandClusterDriver extends Driver
+{
+    private AIDA aida = AIDA.defaultInstance();
+    private String _clusname;
+    private String _outclusname;
+    private int _mincells;
+    private double _Emin;
+    private double _ClCldist;
+   
+    public NHCandClusterDriver(int mincells, double Emin, double ClCldist)
+    {
+        //  add arguments if needed
+        _mincells = mincells;
+        _Emin = Emin;
+        _ClCldist = ClCldist;
+    }
+   
+    protected void process(EventHeader event)
+    {
+        super.process(event);  // executes all added drivers
+        
+        List<BasicCluster> nhclus = new ArrayList<BasicCluster>();
+        List<PerfectTrack> trks = event.get(PerfectTrack.class, "PerfectTracks");
+        List<BasicCluster> trshcls = event.get(BasicCluster.class, "TrackCALClusters");
+        //  to keep as neutral, minimum number of hits, distance from nearest track cluster, etc.
+        try
+        {
+            List<BasicCluster> ncclus = event.get(BasicCluster.class,_clusname);
+            for (BasicCluster cl : ncclus)
+            {
+                if (cl.getCalorimeterHits().size()>_mincells && cl.getEnergy()>_Emin) 
+                {
+                    //  get cluster hit positions
+                    aida.cloud1D("NHCand Clus E").fill(cl.getEnergy());
+                    double[] clpos = cl.getPosition();
+                    double cph = Math.atan2(clpos[1],clpos[0]);
+                    if (cph<0) cph+=2*Math.PI;
+                    double cshr = Math.sqrt(clpos[0]*clpos[0]+clpos[1]*clpos[1]);
+                    double cth = Math.atan(cshr/clpos[2]);
+                    if (cth<0) cth+=Math.PI;
+                    int nclmtch = 0;
+                    for (BasicCluster trshcl : trshcls)
+                    {
+                        //  get this cluster position
+                        double[] tpos = trshcl.getPosition();
+                        double tph = Math.atan2(tpos[1],tpos[0]);
+                        if (tph<0) tph+=2*Math.PI;
+                        double tshr = Math.sqrt(tpos[0]*tpos[0]+tpos[1]*tpos[1]);
+                        double tth = Math.atan(tshr/tpos[2]);
+                        if (tth<0) tth+=Math.PI;
+                        double dccth = Math.abs(tth-cth);
+                        double dccph = Math.abs(tph-cph);
+                        if (dccph>Math.PI) dccph = 2*Math.PI-dccph;
+                        double dcc = Math.sqrt(dccth*dccth+dccph*dccph);
+                        aida.cloud1D("ClusClus distance in NHCand").fill(dcc);
+                        if (dcc<_ClCldist) nclmtch++;
+                        if (nclmtch>0) continue;
+                    }
+                    if (nclmtch == 0) nhclus.add(cl);
+                }
+            }
+            if (nhclus.size()>0) event.put(_outclusname,nhclus);
+            
+            double nhclE = 0;
+            for (BasicCluster nhcl : nhclus)
+            {
+                nhclE += nhcl.getEnergy()*1.3;
+            }
+            aida.cloud1D("PFA Neutral Hadron ESum").fill(nhclE);
+        }
+        catch(java.lang.IllegalArgumentException ex)
+        {
+            System.out.println("requested object not found in event " + _clusname);      
+        }
+    }  // end of event loop
+
+    public void setInputClusterName(String name)
+    {
+        _clusname = name;
+    }
+    public void setOutputClusterName(String outname)
+    {
+        _outclusname = outname;
+    }
+}
+
CVSspam 0.2.8