#include "TROOT.h"
#include "TList.h"
#include "AliMCEvent.h"
+#include "AliAODJet.h"
#include "AliStack.h"
#include "AliGenEventHeader.h"
#include "AliGenCocktailEventHeader.h"
}
+
+
+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;
+
+}
+
+
+
+
+
#include "TObject.h"
class AliMCEvent;
+class AliAODJet;
class AliGenPythiaEventHeader;
// Helper Class that contains a lot of usefull static functions (i.e. for Flavor selection.
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:
#include "AliGenCocktailEventHeader.h"
#include "AliInputEventHandler.h"
+
#include "AliAnalysisHelperJetTasks.h"
ClassImp(AliAnalysisTaskJetSpectrum)
fJetHeaderGen(0x0),
fAOD(0x0),
fBranchRec("jets"),
- fConfigRec("ConfigJets.C"),
fBranchGen(""),
- fConfigGen(""),
fUseAODInput(kFALSE),
fUseExternalWeightOnly(kFALSE),
fLimitGenJetEta(kFALSE),
fh1PtHardTrials(0x0),
fh1NGenJets(0x0),
fh1NRecJets(0x0),
- fHistList(0x0) ,
+ fHistList(0x0) ,
////////////////
fh1JetMultiplicity(0x0) ,
fh2ERecZRec(0x0) ,
fJetHeaderGen(0x0),
fAOD(0x0),
fBranchRec("jets"),
- fConfigRec("ConfigJets.C"),
fBranchGen(""),
- fConfigGen(""),
fUseAODInput(kFALSE),
fUseExternalWeightOnly(kFALSE),
fLimitGenJetEta(kFALSE),
}
- GetClosestJets(genJets,nGenJets,recJets,nRecJets,
+ AliAnalysisHelperJetTasks::GetClosestJets(genJets,nGenJets,recJets,nRecJets,
iGenIndex,iRecIndex,fDebug);
if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
//
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");
- }
-}
-
-
-
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};
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
///////////////////////////////////////////////////////
- ClassDef(AliAnalysisTaskJetSpectrum, 1) // Analysis task for standard jet analysis
+ ClassDef(AliAnalysisTaskJetSpectrum, 2) // Analysis task for standard jet analysis
};
#endif