Print

Print


Commit in lcsim/src/org/lcsim/contrib/SteveMagill on MAIN
PhotonFinderDriver.java+106-191.1 -> 1.2


lcsim/src/org/lcsim/contrib/SteveMagill
PhotonFinderDriver.java 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- PhotonFinderDriver.java	23 Apr 2007 20:04:31 -0000	1.1
+++ PhotonFinderDriver.java	18 May 2007 19:58:52 -0000	1.2
@@ -48,8 +48,10 @@
    double[] _valsEC;
    private double[] BRadii = new double[100];
    private double[] ECZs = new double[100];
-   private boolean phoD = false;
-   private boolean phoRes = false;
+   private boolean phoD = true;
+   private boolean phoRes = true;
+   private String _eboclname;
+   private String _eecoclname;
       
    public PhotonFinderDriver(int mincells, double dTrcl)
    {
@@ -78,12 +80,7 @@
     protected void process(EventHeader event)
     {
         super.process(event);  // executes all added drivers
-        
-        boolean mcfltr = true;
-//        mcfltr = (Boolean)event.get("MCFilt");
-//        System.out.println("MCFilt is " +mcfltr);
-        if (mcfltr)
-        {
+
             if(!_initialized)
             {
                 CylindricalCalorimeter calsubB = (CylindricalCalorimeter)event.getDetector().getSubdetectors().get("EMBarrel");
@@ -175,7 +172,7 @@
             List<BasicCluster> phoECclusters = new ArrayList<BasicCluster>();
             try
             {
-                List<BasicCluster> EBclusters = event.get(BasicCluster.class,"EBTMHitsFCClus");                
+                List<BasicCluster> EBclusters = event.get(BasicCluster.class,_eboclname);                
 
             for (BasicCluster ebclus : EBclusters)
             {
@@ -210,6 +207,40 @@
                 }
                 //  if any matches, don't test this cluster - its not a photon
                 if (ntrclmatch>0) continue;
+                //  now check HCAL to see if significant E directly behind this cluster - also not a photon
+                double emclE = ebclus.getEnergy();
+                double hclE = 0;
+                int nclclmatch = 0;
+                try
+                {
+                    List<BasicCluster> hbclusters = event.get(BasicCluster.class,"HBTMHitsFCClus");
+                    for (BasicCluster hbclus : hbclusters)
+                    {
+                        if (phoD) aida.cloud1D("Number of hits in HB Clus").fill(hbclus.getCalorimeterHits().size());
+                        if (hbclus.getCalorimeterHits().size()<4) continue;
+                        double hbp[] = hbclus.getPosition();
+                        double hbpx = hbp[0];
+                        double hbpy = hbp[1];
+                        double hbpz = hbp[2];
+                        double hbR = Math.sqrt(hbpx*hbpx+hbpy*hbpy);
+                        double hbclth = Math.atan(hbR/hbpz);
+                        if (hbclth<0) hbclth+=Math.PI;
+                        double hbclph = Math.atan2(hbpy,hbpx);
+                        if (hbclph<0) hbclph+=2*Math.PI;
+                        double clcldelth = Math.abs(ebclth-hbclth);
+                        double clcldelph = Math.abs(ebclph-hbclph);
+                        if (clcldelph > Math.PI) clcldelph = 2*Math.PI-clcldelph;
+                        double clcldist = Math.sqrt(clcldelth*clcldelth+clcldelph*clcldelph);
+                        hclE += hbclus.getEnergy();
+                        if (phoD) aida.cloud1D("ClusClus distance in phofinder").fill(clcldist);
+                        if (clcldist<_dTrcl && emclE/(emclE+hclE)<0.9) nclclmatch++;
+                    }
+                }
+                catch (java.lang.IllegalArgumentException ex)
+                {
+                    System.out.println("No had barrel clusters in photon finder");
+                }
+                if (nclclmatch>0) continue;
                 //  Make a hitmap of cluser hits to re-cluster in NN clusterer
                 HitMap ebhitmap = new HitMap();
                 for (CalorimeterHit ebhit : ebclus.getCalorimeterHits())
@@ -242,7 +273,15 @@
                     candclus = ebclus;
                 } else if (ennclusters.size() == 1) 
                 {
-                    candclus = ennclusters.get(0);
+                    double nhebclus = ebclus.getCalorimeterHits().size();
+                    double nhennclus = ennclusters.get(0).getCalorimeterHits().size();
+                    double ratio = nhennclus/nhebclus;
+//                    System.out.println("Num Hits in ebcluster" + nhebclus);
+//                    System.out.println("Num Hits in enncluster" + nhennclus);
+                    aida.cloud1D("Ratio nhits nn to nhits ebsh").fill(ratio);
+                    // candclus = ennclusters.get(0);
+                    candclus = ebclus;
+                    if (ratio > 0.60 && nhennclus >= _mincells) candclus = ennclusters.get(0);
                 } else if (ennclusters.size()>1)
                 {
                     candclus = ebclus;
@@ -262,7 +301,7 @@
 //                if (layfirst > 7) continue;
                 if (phoD) aida.cloud1D("Layer of first photon cand interaction B").fill(layfirst);
                 //  test with H-Matrix if cluster has enough cells
-                if (candclus.getCalorimeterHits().size()>=_mincells && layfirst<9)
+                if (candclus.getCalorimeterHits().size()>=_mincells && layfirst<7)
                 {
                     for(int i=0; i<layerE.length-layfirst; ++i)
                     {
@@ -298,7 +337,7 @@
                         {
 //                            System.out.println("Pho Cand Failed H-Matrix test");
                             int clsize = ebclus.getCalorimeterHits().size();
-                            if (clsize>1 && clsize<_mincells && layfirst<5) phoBclusters.add(ebclus);
+                            if (clsize>1 && layfirst<7) phoBclusters.add(ebclus);
                         }
                     }
                 } else
@@ -306,7 +345,7 @@
 //                    System.out.println("No H-Matrix test try layfirst");
 //                    System.out.println("Num of hits " + candclus.getCalorimeterHits().size() + " First Layer " + layfirst);
                     int cansize = candclus.getCalorimeterHits().size();
-                    if (cansize>1 && cansize<_mincells && layfirst<5) phoBclusters.add(ebclus);
+                    if (cansize>4 && cansize<_mincells && layfirst<5) phoBclusters.add(ebclus);
                 }
             } // end of barrel part
             }
@@ -316,7 +355,7 @@
             }
             try
             {
-                List<BasicCluster> EECclusters = event.get(BasicCluster.class,"EECTMHitsFCClus");
+                List<BasicCluster> EECclusters = event.get(BasicCluster.class,_eecoclname);
 
             for (BasicCluster eecclus : EECclusters)
             {
@@ -349,6 +388,40 @@
                 }
                 //  if any matches, don't test this cluster - its not a photon
                 if (ntrclmatch>0) continue;
+                //  now check HCAL to see if significant E directly behind this cluster - also not a photon
+                int nclclmatch = 0;
+                double emclE = eecclus.getEnergy();
+                double hclE = 0;
+                try
+                {
+                    List<BasicCluster> hecclusters = event.get(BasicCluster.class,"HECTMHitsFCClus");
+                    for (BasicCluster hecclus : hecclusters)
+                    {
+                        if (phoD) aida.cloud1D("Number of hits in HEC Clus").fill(hecclus.getCalorimeterHits().size());
+                        if (hecclus.getCalorimeterHits().size()<4) continue;
+                        double hbp[] = hecclus.getPosition();
+                        double hbpx = hbp[0];
+                        double hbpy = hbp[1];
+                        double hbpz = hbp[2];
+                        double hbR = Math.sqrt(hbpx*hbpx+hbpy*hbpy);
+                        double hbclth = Math.atan(hbR/hbpz);
+                        if (hbclth<0) hbclth+=Math.PI;
+                        double hbclph = Math.atan2(hbpy,hbpx);
+                        if (hbclph<0) hbclph+=2*Math.PI;
+                        double clcldelth = Math.abs(ebclth-hbclth);
+                        double clcldelph = Math.abs(ebclph-hbclph);
+                        if (clcldelph > Math.PI) clcldelph = 2*Math.PI-clcldelph;
+                        double clcldist = Math.sqrt(clcldelth*clcldelth+clcldelph*clcldelph);
+                        hclE += hecclus.getEnergy();
+                        if (phoD) aida.cloud1D("ClusClus distance in phofinder").fill(clcldist);
+                        if (clcldist<_dTrcl && emclE/(emclE+hclE)<0.9) nclclmatch++;
+                    }
+                }
+                catch (java.lang.IllegalArgumentException ex)
+                {
+                    System.out.println("No had endcap clusters in photon finder");
+                }
+                if (nclclmatch>0) continue;
                 //  Make a hitmap of cluser hits to re-cluster in NN clusterer
                 HitMap eechitmap = new HitMap();
                 for (CalorimeterHit eechit : eecclus.getCalorimeterHits())
@@ -381,7 +454,12 @@
                     candclus = eecclus;
                 } else if (ennclusters.size() == 1) 
                 {
-                    candclus = ennclusters.get(0);
+                    double nheecclus = eecclus.getCalorimeterHits().size();
+                    double nhennclus = ennclusters.get(0).getCalorimeterHits().size();
+                    double ratio = nhennclus/nheecclus;
+                    // candclus = ennclusters.get(0);
+                    candclus = eecclus;
+                    if (ratio > 0.60 && nhennclus >= _mincells) candclus = ennclusters.get(0);
                 } else if (ennclusters.size()>1)
                 {
                     candclus = eecclus;
@@ -398,7 +476,7 @@
                     if (layerE[j] > 0.0) break;
                 }
                 if (phoD) aida.cloud1D("Layer of first photon cand interaction EC").fill(layfirst);
-                if (candclus.getCalorimeterHits().size()>=_mincells && layfirst<9)
+                if (candclus.getCalorimeterHits().size()>=_mincells && layfirst<7)
                 {
                     for(int i=0; i<layerE.length-layfirst; ++i)
                     {
@@ -432,13 +510,13 @@
                         } else
                         {
                             int clsize = eecclus.getCalorimeterHits().size();
-                            if (clsize>1 && clsize<_mincells && layfirst<5) phoECclusters.add(eecclus);
+                            if (clsize>1 && layfirst<7) phoECclusters.add(eecclus);
                         } 
                     }
                 } else // can't use H-Matrix, try something else
                 {
                     int cansize = candclus.getCalorimeterHits().size();
-                    if (cansize>1 && cansize<_mincells && layfirst<5) phoECclusters.add(eecclus);
+                    if (cansize>4 && cansize<_mincells && layfirst<5) phoECclusters.add(eecclus);
                 }
             }  //  end of Endcap part
             }
@@ -466,7 +544,6 @@
             if (phoRes && phoBclusters.size()+phoECclusters.size()==1) aida.cloud1D("Single Photon ESum").fill(PFAPhoE);
             if (phoRes) aida.cloud1D("Total Photon ESum").fill(PFAPhoE);
             if (phoRes) aida.cloud1D("Total Charged P + Photon E").fill(PFAPhoE+TotTrP);
-        }  // end of filter loop
     }  // end of event loop
     private double[] layerEnergiesB(BasicCluster clusB)
     {
@@ -526,5 +603,15 @@
 //        System.out.println(clusterEnergy+" "+clus.getEnergy());
         return layerEnergiesEC;
     }
+    
+    public void setBInputClusterName(String bname)
+    {
+        _eboclname = bname;
+    }
+    
+    public void setECInputClusterName(String ecname)
+    {
+        _eecoclname = ecname;
+    }
 }
 
CVSspam 0.2.8