-void AliAnalysisHelperJetTasks::GetClosestJets(AliAODJet *genJets,const Int_t &nGenJets,
- AliAODJet *recJets,const Int_t &nRecJets,
+void AliAnalysisHelperJetTasks::GetClosestJets(AliAODJet *genJets,const Int_t &kGenJets,
+ AliAODJet *recJets,const Int_t &kRecJets,
Int_t *iGenIndex,Int_t *iRecIndex,
Int_t iDebug,Float_t maxDist){
// 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
// d c
// 3 e
// Only entries with "3" match from both sides
+
+ // In case we have more jets than kmaxjets only the
+ // first kmaxjets are searched
+ // all other are -1
+ // use kMaxJets for a test not to fragemnt the memory...
+
+ for(int i = 0;i < kGenJets;++i)iGenIndex[i] = -1;
+ for(int j = 0;j < kRecJets;++j)iRecIndex[j] = -1;
+
+
const int kMode = 3;
-
+ const Int_t nGenJets = TMath::Min(kMaxJets,kGenJets);
+ const Int_t nRecJets = TMath::Min(kMaxJets,kRecJets);
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];
+ // UShort_t *iFlag = new UShort_t[nGenJets*nRecJets];
+ UShort_t iFlag[kMaxJets*kMaxJets];
for(int i = 0;i < nGenJets;++i){
for(int j = 0;j < nRecJets;++j){
iFlag[i*nGenJets+j] = 0;
}
if(iDebug>1)printf("\n");
}
-
- delete [] iFlag;
-
}
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,
+ const Int_t &kGenJets,
AliAODJet *recJets,
- const Int_t &nRecJets,
+ const Int_t &kRecJets,
Int_t *iGenIndex,
Int_t *iRecIndex,
Int_t iDebug, Float_t maxDist = 0.5);
static void MergeOutput(char* cFiles, char* cList = "pwg4spec"); // Merges the files in the input text file needs the two histograms fh1PtHard_Trials, fh1Xsec and the name of the input list
-
+ enum {kMaxJets = 6}; // needed for array size not to fragemnt memory on the heap by many new/delete
private:
ClassDef(AliAnalysisHelperJetTasks, 1)