]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Moved GetClosestJets() method to helper class
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 12 Jul 2009 11:04:31 +0000 (11:04 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 12 Jul 2009 11:04:31 +0000 (11:04 +0000)
PWG4/JetTasks/AliAnalysisHelperJetTasks.cxx
PWG4/JetTasks/AliAnalysisHelperJetTasks.h
PWG4/JetTasks/AliAnalysisTaskJetSpectrum.cxx
PWG4/JetTasks/AliAnalysisTaskJetSpectrum.h

index 5a33e3d4a1f08dd91923c4bbf42ffe3805c16719..b3c5fc48dbafa7dca9a5d724b7f2a91225504e7d 100644 (file)
@@ -2,6 +2,7 @@
 #include "TROOT.h"
 #include "TList.h"
 #include "AliMCEvent.h"
+#include "AliAODJet.h"
 #include "AliStack.h"
 #include "AliGenEventHeader.h"
 #include "AliGenCocktailEventHeader.h"
@@ -72,3 +73,126 @@ void AliAnalysisHelperJetTasks::PrintStack(AliMCEvent *mcEvent,Int_t iFirst,Int_
 }
 
 
+
+
+void AliAnalysisHelperJetTasks::GetClosestJets(AliAODJet *genJets,const Int_t &nGenJets,
+                                              AliAODJet *recJets,const Int_t &nRecJets,
+                                              Int_t *iGenIndex,Int_t *iRecIndex,
+                                              Int_t iDebug,Float_t maxDist){
+
+  //
+  // Relate the two input jet Arrays
+  //
+
+  //
+  // The association has to be unique
+  // So check in two directions
+  // find the closest rec to a gen
+  // and check if there is no other rec which is closer
+  // Caveat: Close low energy/split jets may disturb this correlation
+
+  // Idea: search in two directions generated e.g (a--e) and rec (1--3)
+  // Fill a matrix with Flags (1 for closest rec jet, 2 for closest rec jet
+  // in the end we have something like this
+  //    1   2   3
+  // ------------
+  // a| 3   2   0
+  // b| 0   1   0
+  // c| 0   0   3
+  // d| 0   0   1
+  // e| 0   0   1
+  // Topology
+  //   1     2
+  //     a         b        
+  //
+  //  d      c
+  //        3     e
+  // Only entries with "3" match from both sides
+  
+  const int kMode = 3;
+
+  
+
+  if(nRecJets==0||nGenJets==0)return;
+
+  for(int i = 0;i < nGenJets;++i)iGenIndex[i] = -1;
+  for(int j = 0;j < nRecJets;++j)iRecIndex[j] = -1;
+
+  UShort_t *iFlag = new UShort_t[nGenJets*nRecJets];
+  for(int i = 0;i < nGenJets;++i){
+    for(int j = 0;j < nRecJets;++j){
+      iFlag[i*nGenJets+j] = 0;
+    }
+  }
+
+
+
+  // find the closest distance to the generated
+  for(int ig = 0;ig<nGenJets;++ig){
+    Float_t dist = maxDist;
+    if(iDebug>1)Printf("Gen (%d) p_T %3.3f eta %3.3f ph %3.3f ",ig,genJets[ig].Pt(),genJets[ig].Eta(),genJets[ig].Phi());
+    for(int ir = 0;ir<nRecJets;++ir){
+      Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
+      if(iDebug>1)Printf("Rec (%d) p_T %3.3f eta %3.3f ph %3.3f ",ir,recJets[ir].Pt(),recJets[ir].Eta(),recJets[ir].Phi());
+      if(iDebug>1)Printf("Distance (%d)--(%d) %3.3f ",ig,ir,dR);
+      if(dR<dist){
+       iRecIndex[ig] = ir;
+       dist = dR;
+      }        
+    }
+    if(iRecIndex[ig]>=0)iFlag[ig*nGenJets+iRecIndex[ig]]+=1;
+    // reset...
+    iRecIndex[ig] = -1;
+  }
+  // other way around
+  for(int ir = 0;ir<nRecJets;++ir){
+    Float_t dist = maxDist;
+    for(int ig = 0;ig<nGenJets;++ig){
+      Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
+      if(dR<dist){
+       iGenIndex[ir] = ig;
+       dist = dR;
+      }        
+    }
+    if(iGenIndex[ir]>=0)iFlag[iGenIndex[ir]*nGenJets+ir]+=2;
+    // reset...
+    iGenIndex[ir] = -1;
+  }
+
+  // check for "true" correlations
+
+  if(iDebug>1)Printf(">>>>>> Matrix");
+
+  for(int ig = 0;ig<nGenJets;++ig){
+    for(int ir = 0;ir<nRecJets;++ir){
+      // Print
+      if(iDebug>1)printf("Flag[%d][%d] %d ",ig,ir,iFlag[ig*nGenJets+ir]);
+
+      if(kMode==3){
+       // we have a uniqie correlation
+       if(iFlag[ig*nGenJets+ir]==3){
+         iGenIndex[ir] = ig;
+         iRecIndex[ig] = ir;
+       }
+      }
+      else{
+       // we just take the correlation from on side
+       if((iFlag[ig*nGenJets+ir]&2)==2){
+         iGenIndex[ir] = ig;
+       }
+       if((iFlag[ig*nGenJets+ir]&1)==1){
+         iRecIndex[ig] = ir;
+       }
+      }
+    }
+    if(iDebug>1)printf("\n");
+  }
+
+  delete [] iFlag;
+
+}
+
+
+
+
+
index b8a9361b8f16fcec47a7a2258b5a1cb3be7f9c36..d0a5798d550e84214a4304fe842567e4382ca8aa 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "TObject.h"
 class AliMCEvent;
+class AliAODJet;
 class AliGenPythiaEventHeader;
 
 // Helper Class that contains a lot of usefull static functions (i.e. for Flavor selection.
@@ -15,6 +16,13 @@ class AliAnalysisHelperJetTasks : public TObject {
   
   static AliGenPythiaEventHeader*  GetPythiaEventHeader(AliMCEvent *mcEvent);
   static void PrintStack(AliMCEvent *mcEvent,Int_t iFirst = 0,Int_t iLast = 0,Int_t iMaxPrint = 10);
+  static void GetClosestJets(AliAODJet *genJets,
+                            const Int_t &nGenJets,
+                            AliAODJet *recJets,
+                            const Int_t &nRecJets,
+                            Int_t *iGenIndex,
+                            Int_t *iRecIndex,
+                            Int_t iDebug, Float_t maxDist = 0.5);
   
 
   private:
index 96924c91c6ef554824f812d5c85aa16a94f7520b..01e79dfabaf8fa13ef564b23b44b5fd12bd3f75e 100644 (file)
@@ -56,6 +56,7 @@
 #include "AliGenCocktailEventHeader.h"
 #include "AliInputEventHandler.h"
 
+
 #include "AliAnalysisHelperJetTasks.h"
 
 ClassImp(AliAnalysisTaskJetSpectrum)
@@ -67,9 +68,7 @@ AliAnalysisTaskJetSpectrum::AliAnalysisTaskJetSpectrum(): AliAnalysisTaskSE(),
   fJetHeaderGen(0x0),
   fAOD(0x0),
   fBranchRec("jets"),
-  fConfigRec("ConfigJets.C"),
   fBranchGen(""),
-  fConfigGen(""),
   fUseAODInput(kFALSE),
   fUseExternalWeightOnly(kFALSE),
   fLimitGenJetEta(kFALSE),
@@ -83,7 +82,7 @@ AliAnalysisTaskJetSpectrum::AliAnalysisTaskJetSpectrum(): AliAnalysisTaskSE(),
   fh1PtHardTrials(0x0),
   fh1NGenJets(0x0),
   fh1NRecJets(0x0),
-  fHistList(0x0) , 
+  fHistList(0x0) ,
   ////////////////
   fh1JetMultiplicity(0x0) ,     
   fh2ERecZRec(0x0) ,
@@ -110,9 +109,7 @@ AliAnalysisTaskJetSpectrum::AliAnalysisTaskJetSpectrum(const char* name):
   fJetHeaderGen(0x0),
   fAOD(0x0),
   fBranchRec("jets"),
-  fConfigRec("ConfigJets.C"),
   fBranchGen(""),
-  fConfigGen(""),
   fUseAODInput(kFALSE),
   fUseExternalWeightOnly(kFALSE),
   fLimitGenJetEta(kFALSE),
@@ -656,7 +653,7 @@ void AliAnalysisTaskJetSpectrum::UserExec(Option_t */*option*/)
   }
 
 
-  GetClosestJets(genJets,nGenJets,recJets,nRecJets,
+  AliAnalysisHelperJetTasks::GetClosestJets(genJets,nGenJets,recJets,nRecJets,
                 iGenIndex,iRecIndex,fDebug);
   if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
 
@@ -810,118 +807,3 @@ void AliAnalysisTaskJetSpectrum::Terminate(Option_t */*option*/)
 //
     if (fDebug > 1) printf("AnalysisJetSpectrum: Terminate() \n");
 }
-
-
-void AliAnalysisTaskJetSpectrum::GetClosestJets(AliAODJet *genJets,const Int_t &nGenJets,
-                                               AliAODJet *recJets,const Int_t &nRecJets,
-                                               Int_t *iGenIndex,Int_t *iRecIndex,Int_t iDebug){
-
-  //
-  // Relate the two input jet Arrays
-  //
-
-  //
-  // The association has to be unique
-  // So check in two directions
-  // find the closest rec to a gen
-  // and check if there is no other rec which is closer
-  // Caveat: Close low energy/split jets may disturb this correlation
-
-  // Idea: search in two directions generated e.g (a--e) and rec (1--3)
-  // Fill a matrix with Flags (1 for closest rec jet, 2 for closest rec jet
-  // in the end we have something like this
-  //    1   2   3
-  // ------------
-  // a| 3   2   0
-  // b| 0   1   0
-  // c| 0   0   3
-  // d| 0   0   1
-  // e| 0   0   1
-  // Topology
-  //   1     2
-  //     a         b        
-  //
-  //  d      c
-  //        3     e
-  // Only entries with "3" match from both sides
-  
-  const int kMode = 3;
-
-  Int_t iFlag[kMaxJets][kMaxJets];
-
-
-
-  for(int i = 0;i < kMaxJets;++i){
-    iRecIndex[i] = -1;
-    iGenIndex[i] = -1;
-    for(int j = 0;j < kMaxJets;++j)iFlag[i][j] = 0;
-  }
-
-  if(nRecJets==0)return;
-  if(nGenJets==0)return;
-
-  const Float_t maxDist = 0.5;
-  // find the closest distance to the generated
-  for(int ig = 0;ig<nGenJets;++ig){
-    Float_t dist = maxDist;
-    if(iDebug>1)Printf("Gen (%d) p_T %3.3f eta %3.3f ph %3.3f ",ig,genJets[ig].Pt(),genJets[ig].Eta(),genJets[ig].Phi());
-    for(int ir = 0;ir<nRecJets;++ir){
-      Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
-      if(iDebug>1)Printf("Rec (%d) p_T %3.3f eta %3.3f ph %3.3f ",ir,recJets[ir].Pt(),recJets[ir].Eta(),recJets[ir].Phi());
-      if(iDebug>1)Printf("Distance (%d)--(%d) %3.3f ",ig,ir,dR);
-      if(dR<dist){
-       iRecIndex[ig] = ir;
-       dist = dR;
-      }        
-    }
-    if(iRecIndex[ig]>=0)iFlag[ig][iRecIndex[ig]]+=1;
-    // reset...
-    iRecIndex[ig] = -1;
-  }
-  // other way around
-  for(int ir = 0;ir<nRecJets;++ir){
-    Float_t dist = maxDist;
-    for(int ig = 0;ig<nGenJets;++ig){
-      Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
-      if(dR<dist){
-       iGenIndex[ir] = ig;
-       dist = dR;
-      }        
-    }
-    if(iGenIndex[ir]>=0)iFlag[iGenIndex[ir]][ir]+=2;
-    // reset...
-    iGenIndex[ir] = -1;
-  }
-
-  // check for "true" correlations
-
-  if(iDebug>1)Printf(">>>>>> Matrix");
-
-  for(int ig = 0;ig<nGenJets;++ig){
-    for(int ir = 0;ir<nRecJets;++ir){
-      // Print
-      if(iDebug>1)printf("XFL %d ",iFlag[ig][ir]);
-
-      if(kMode==3){
-       // we have a uniqie correlation
-       if(iFlag[ig][ir]==3){
-         iGenIndex[ir] = ig;
-         iRecIndex[ig] = ir;
-       }
-      }
-      else{
-       // we just take the correlation from on side
-       if((iFlag[ig][ir]&2)==2){
-         iGenIndex[ir] = ig;
-       }
-       if((iFlag[ig][ir]&1)==1){
-         iRecIndex[ig] = ir;
-       }
-      }
-    }
-    if(iDebug>1)printf("\n");
-  }
-}
-
-
-
index c5256f31f7352976e5e59924f9467e739e53b023..3b90bcd932005a2112c7d83b041684084c187c77 100644 (file)
@@ -52,11 +52,7 @@ class AliAnalysisTaskJetSpectrum : public AliAnalysisTaskSE
     virtual void SetBranchRec(const char* c){fBranchRec = c;}
 
     // Helper
-    static void GetClosestJets(AliAODJet *genJets,const Int_t &nGenJets,
-                              AliAODJet *recJets,const Int_t &nRecJets,
-                              Int_t *iGenIndex,Int_t *iRecIndex,Int_t iDebug = 0);
-
-  //
+    //
 
     enum {kAnaMC =  0x1};
     enum {kMaxJets =  4};
@@ -75,9 +71,7 @@ class AliAnalysisTaskJetSpectrum : public AliAnalysisTaskSE
     AliAODEvent  *fAOD; // where we take the jets from can be input or output AOD
 
     TString       fBranchRec;  // AOD branch name for reconstructed
-    TString       fConfigRec;  // Name of the Config file 
     TString       fBranchGen;  // AOD brnach for genereated
-    TString       fConfigGen;  // Name of the Config file (if any)
 
     Bool_t        fUseAODInput;           // use AOD input
     Bool_t        fUseExternalWeightOnly; // use only external weight
@@ -136,7 +130,7 @@ class AliAnalysisTaskJetSpectrum : public AliAnalysisTaskSE
     ///////////////////////////////////////////////////////
 
 
-    ClassDef(AliAnalysisTaskJetSpectrum, 1) // Analysis task for standard jet analysis
+    ClassDef(AliAnalysisTaskJetSpectrum, 2) // Analysis task for standard jet analysis
 };
  
 #endif