54 #include <TClonesArray.h> 69 #include <AliAnalysisTask.h> 70 #include <AliAnalysisManager.h> 72 #include <AliVEvent.h> 73 #include <AliVParticle.h> 85 fSourceJets(0),
fSourceJetsName(0),
fTargetJets(0),
fTargetJetsName(0),
fMatchedJets(0),
fMatchedJetsName(GetName()),
fSourceRho(0),
fSourceRhoName(0),
fTargetRho(0),
fTargetRhoName(0),
fUseScaledRho(0),
fSourceRadius(0.3),
fTargetRadius(0.3),
fMatchingScheme(
kGeoEtaPhi),
fUseEmcalBaseJetCuts(kFALSE),
fSourceBKG(
kNoSourceBKG),
fTargetBKG(
kNoTargetBKG),
fOutputList(0),
fHistUnsortedCorrelation(0),
fHistMatchedCorrelation(0),
fHistSourceJetPt(0),
fHistMatchedSourceJetPt(0),
fHistTargetJetPt(0),
fHistMatchedJetPt(0),
fHistSourceMatchedJetPt(0),
fHistDetectorResponseProb(0),
fHistNoConstSourceJet(0),
fHistNoConstTargetJet(0),
fHistNoConstMatchJet(0),
fProfFracPtMatched(0),
fProfFracPtJets(0),
fProfFracNoMatched(0),
fProfFracNoJets(0),
fHistDiJet(0),
fHistDiJetLeadingJet(0),
fHistDiJetDPhi(0),
fHistDiJetDPt(0),
fHistAnalysisSummary(0),
fProfQAMatched(0),
fProfQA(0),
fNoMatchedJets(200),
fMatchEta(.3),
fMatchPhi(.3),
fMatchR(.08),
fDoDetectorResponse(kFALSE),
fMatchConstituents(kTRUE),
fMinFracRecoveredConstituents(.5),
fMinFracRecoveredConstituentPt(0.5),
fGetBijection(kTRUE),
fh1Trials(0x0),
fh1AvgTrials(0x0),
fh1Xsec(0x0),
fAvgTrials(0) {
91 fSourceJets(0),
fSourceJetsName(0),
fTargetJets(0),
fTargetJetsName(0),
fMatchedJets(0),
fMatchedJetsName(GetName()),
fSourceRho(0),
fSourceRhoName(0),
fTargetRho(0),
fTargetRhoName(0),
fUseScaledRho(0),
fSourceRadius(0.3),
fTargetRadius(0.3),
fMatchingScheme(
kGeoEtaPhi),
fUseEmcalBaseJetCuts(kFALSE),
fSourceBKG(
kNoSourceBKG),
fTargetBKG(
kNoTargetBKG),
fOutputList(0),
fHistUnsortedCorrelation(0),
fHistMatchedCorrelation(0),
fHistSourceJetPt(0),
fHistMatchedSourceJetPt(0),
fHistTargetJetPt(0),
fHistMatchedJetPt(0),
fHistSourceMatchedJetPt(0),
fHistDetectorResponseProb(0),
fHistNoConstSourceJet(0),
fHistNoConstTargetJet(0),
fHistNoConstMatchJet(0),
fProfFracPtMatched(0),
fProfFracPtJets(0),
fProfFracNoMatched(0),
fProfFracNoJets(0),
fHistDiJet(0),
fHistDiJetLeadingJet(0),
fHistDiJetDPhi(0),
fHistDiJetDPt(0),
fHistAnalysisSummary(0),
fProfQAMatched(0),
fProfQA(0),
fNoMatchedJets(200),
fMatchEta(.3),
fMatchPhi(.3),
fMatchR(.08),
fDoDetectorResponse(kFALSE),
fMatchConstituents(kTRUE),
fMinFracRecoveredConstituents(0.5),
fMinFracRecoveredConstituentPt(0.5),
fGetBijection(kTRUE),
fh1Trials(0x0),
fh1AvgTrials(0x0),
fh1Xsec(0x0),
fAvgTrials(0) {
94 DefineInput(0, TChain::Class());
95 DefineOutput(1, TList::Class());
108 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
118 else AliFatal(Form(
"%s: Object with name %s already in event! Aborting", GetName(),
fMatchedJetsName.Data()));
123 if(!
fSourceRho) AliFatal(Form(
"%s: Object with name %s requested but not found! Aborting", GetName(),
fSourceRhoName.Data()));
130 if(!
fTargetRho) AliFatal(Form(
"%s: Object with name %s requested but not found! Aborting", GetName(),
fTargetRhoName.Data()));
142 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
156 fHistSourceMatchedJetPt = (
fDoDetectorResponse) ?
BookTH2F(
"fHistDetectorResponse",
"particle level jet p_{t}^{gen} [GeV/c]",
"detector level jet p_{t}^{rec} [GeV/c]", 300, -50, 250, 300, -50, 250) :
BookTH2F(
"fHistSourceMatchedJetPt",
"source jet p_{t} [GeV/c]",
"matched jet p_{t} [GeV/c]", 300, -50, 250, 300, -50, 250);
159 fh1Xsec =
new TProfile(
"fh1Xsec",
"xsec from pyxsec.root",1,0,1);
160 fh1Xsec->GetXaxis()->SetBinLabel(1,
"<#sigma>");
162 fh1Trials =
new TH1F(
"fh1Trials",
"trials root file",1,0,1);
163 fh1Trials->GetXaxis()->SetBinLabel(1,
"#sum{ntrials}");
165 fh1AvgTrials =
new TH1F(
"fh1AvgTrials",
"avg trials root file",1,0,1);
166 fh1AvgTrials->GetXaxis()->SetBinLabel(1,
"#sum{avg ntrials}");
173 fProfFracPtMatched =
new TProfile(
"fProfFracPtMatched",
"recovered target p_{T} / source p_{T}", 15, -50, 250);
175 fProfFracNoMatched =
new TProfile(
"fProfFracNoMatched",
"recovered target constituents / source constituents", 15, -50, 250);
180 fProfQAMatched =
new TProfile(
"fProfQAMatched",
"fProfQAMatched", 3, 0, 3);
185 fProfQA =
new TProfile(
"fProfQA",
"fProfQA", 3, 0, 3);
186 fProfQA->GetXaxis()->SetBinLabel(1,
"<#delta p_{t} >");
187 fProfQA->GetXaxis()->SetBinLabel(2,
"<#delta #eta>");
188 fProfQA->GetXaxis()->SetBinLabel(3,
"<#delta #varphi>");
190 fProfFracPtJets =
new TProfile(
"fProfFracPtJets",
"source p_{T} / target p_{T}", 15, -50, 250);
192 fProfFracNoJets =
new TProfile(
"fProfFracNoJets",
"source constituents / target constituents", 15, -50, 250);
196 fHistDiJet =
BookTH3F(
"fHistDiJet",
"matched di-jet #varphi",
"matched di-jet #eta",
"leading jet p_{T} (GeV/c)", 100, 0., TMath::TwoPi(), 100, -5., 5., 100, 0, 200);
197 fHistDiJetLeadingJet =
BookTH3F(
"fHistDiJetLeadingJet",
"leading jet #varphi",
"leadingd jet #eta",
"leading jet p_{T} (GeV/c)", 100, 0., TMath::TwoPi(), 100, -5., 5., 100, 0, 200);
198 fHistDiJetDPhi =
BookTH2F(
"fHistDiJetDPhi",
"leading jet #varphi - (matched jet #varphi - #pi)",
"leading jet p_{T} (GeV/c)", 100, -1.*TMath::Pi(), TMath::Pi(), 100, 0, 200);
199 fHistDiJetDPt =
BookTH2F(
"fHistDiJetDPt",
"leading jet p_{T} - sub leading jet p_{T} (GeV/c)",
"leading jet p_{T} (GeV/c)", 100, -25, 25, 100, 0, 200);
211 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
215 title += Form(
";%s;[counts]", x);
216 TH1F* histogram =
new TH1F(name, title.Data(), bins, min, max);
226 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
230 title += Form(
";%s;%s", x, y);
231 TH2F* histogram =
new TH2F(name, title.Data(), binsx, minx, maxx, binsy, miny, maxy);
237 TH3F*
AliAnalysisTaskJetMatching::BookTH3F(
const char* name,
const char* x,
const char* y,
const char* z,
Int_t binsx,
Double_t minx,
Double_t maxx,
Int_t binsy,
Double_t miny,
Double_t maxy,
Int_t binsz,
Double_t minz,
Double_t maxz,
Bool_t append)
241 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
245 title += Form(
";%s;%s;%s", x, y, z);
246 TH3F* histogram =
new TH3F(name, title.Data(), binsx, minx, maxx, binsy, miny, maxy, binsz, minz, maxz);
260 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
262 Float_t xsection(0), ftrials(1);
264 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
266 TFile *curfile = tree->GetCurrentFile();
267 if (!curfile)
return kFALSE;
269 if(
file.Contains(
"root_archive.zip#"))
file.Replace(
file.Index(
"#",1,
file.Index(
"root_archive",12,0,TString::kExact),TString::kExact)+1,
file.Index(
".root",5,TString::kExact)-
file.Index(
"root_archive",12,0,TString::kExact),
"");
271 TFile *fxsec = TFile::Open(Form(
"%s%s",
file.Data(),
"pyxsec.root"));
273 fxsec = TFile::Open(Form(
"%s%s",
file.Data(),
"pyxsec_hists.root"));
275 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
277 TList *list =
dynamic_cast<TList*
>(key->ReadObj());
279 xsection = ((TProfile*)list->FindObject(
"h1Xsec"))->GetBinContent(1);
280 ftrials = ((TH1F*)list->FindObject(
"h1Trials"))->GetBinContent(1);
286 TTree *xtree = (
TTree*)fxsec->Get(
"Xsection");
290 xtree->SetBranchAddress(
"xsection",&_xsection);
291 xtree->SetBranchAddress(
"ntrials",&_ftrials);
294 xsection = _xsection;
298 fh1Xsec->Fill(
"<#sigma>",xsection);
300 if(ftrials >= nEntries && nEntries > 0.)
fAvgTrials = ftrials/nEntries;
301 fh1Trials->Fill(
"#sum{ntrials}",ftrials);
310 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
351 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
355 for(
Int_t i(0); i < iSource; i++) {
358 for(
Int_t j(0); j < iTarget; j++) {
363 Double_t sourcePhi(sourceJet->
Phi()), targetPhi(targetJet->
Phi());
364 if(TMath::Abs(sourcePhi-targetPhi) > TMath::Abs(sourcePhi-targetPhi+TMath::TwoPi())) sourcePhi+=TMath::TwoPi();
365 if(TMath::Abs(sourcePhi-targetPhi) > TMath::Abs(sourcePhi-targetPhi-TMath::TwoPi())) sourcePhi-=TMath::TwoPi();
366 if(TMath::Abs(sourcePhi-targetPhi) <
fMatchPhi) {
367 Bool_t isBestMatch(kTRUE);
370 printf(
" > Entering first bijection test \n");
372 for(
Int_t k(i); k < iSource; k++) {
374 if(
PassesCuts(candidateSourceJet, 0))
continue;
376 printf(
"source distance %.2f \t candidate distance %.2f \n",
GetR(sourceJet, targetJet),
GetR(candidateSourceJet, targetJet));
378 if(
GetR(sourceJet, targetJet) >
GetR(candidateSourceJet, targetJet)) {
379 isBestMatch = kFALSE;
384 (isBestMatch) ? printf(
" kept source \n ") : printf(
" we can do better (rejected source) \n");
393 AliError(Form(
"%s: Found too many matched jets (> 100). Adjust matching criteria !", GetName()));
406 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
410 for(
Int_t i(0); i < iSource; i++) {
413 for(
Int_t j(0); j < iTarget; j++) {
418 Bool_t isBestMatch(kTRUE);
421 printf(
" > Entering first bijection test \n");
423 for(
Int_t k(i); k < iSource; k++) {
425 if(!
PassesCuts(candidateSourceJet, 0))
continue;
427 printf(
"source distance %.2f \t candidate distance %.2f \n",
GetR(sourceJet, targetJet),
GetR(candidateSourceJet, targetJet));
429 if(
GetR(sourceJet, targetJet) >
GetR(candidateSourceJet, targetJet)) {
430 isBestMatch = kFALSE;
435 (isBestMatch) ? printf(
" kept source \n ") : printf(
" we can do better (rejected source) \n");
444 AliError(Form(
"%s: Found too many matched jets (> 100). Adjust matching criteria !", GetName()));
459 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
462 Int_t leadingJetIndex(-1), subLeadingJetIndex(-1);
465 if(!leadingJet)
return;
468 Double_t sourcePhi(leadingJet->
Phi()), targetPhi(-1);
471 if(!subLeadingJet)
return;
473 targetPhi = subLeadingJet->
Phi() + TMath::Pi();
475 if(TMath::Abs(sourcePhi) > TMath::Abs(sourcePhi+TMath::TwoPi())) sourcePhi+=TMath::TwoPi();
476 if(TMath::Abs(sourcePhi) > TMath::Abs(sourcePhi-TMath::TwoPi())) sourcePhi-=TMath::TwoPi();
477 if(TMath::Abs(targetPhi) > TMath::Abs(targetPhi+TMath::TwoPi())) targetPhi+=TMath::TwoPi();
478 if(TMath::Abs(targetPhi) > TMath::Abs(targetPhi-TMath::TwoPi())) targetPhi-=TMath::TwoPi();
479 if(TMath::Abs(sourcePhi-targetPhi) <
fMatchPhi) {
491 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
494 AliFatal(Form(
"%s Fatal error! To do deep matching, supply jet constituents ! \n", GetName()));
500 if(sourceJet && targetJet) {
504 Int_t overlap(0), alreadyFound(0);
505 for(
Int_t j(0); j < iSJ; j++) {
508 for(
Int_t k(0); k < iTJ; k++) {
509 if(idSource == targetJet->
TrackAt(k) && alreadyFound == 0) {
512 AliVParticle* vp(static_cast<AliVParticle*>(targetJet->
TrackAt(k,
fTracks)));
513 if(vp) targetPt += vp->Pt();
520 printf(
" \n > Purging jet, recovered constituents ratio %i / %i = %.2f < or pt ratio %.2f / %.2f = %.2f < %.2f", overlap, iSJ, (
float)overlap/(
float)iSJ, targetPt, sourceJet->
Pt(), targetPt/sourceJet->
Pt(),
fMinFracRecoveredConstituentPt);
523 fMatchedJetContainer[i][1] = 0x0;
526 if(sourceJet->
Pt() > 0) {
527 Double_t sourceRho(0), targetRho(0);
531 fProfFracPtJets->Fill(sourceJet->
Pt()-sourceRho, (targetJet->
Pt()-targetRho) / (sourceJet->
Pt()-sourceRho));
537 printf(
"\n > Jet A: %i const\t", iSJ);
538 printf(
" > Jet B %i const\t", iTJ);
539 printf(
" -> OVERLAP: %i tracks <- \n", overlap);
550 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
569 printf(
" found duplicate jet, chose %.2f over %.2f \n" , (rB > rA) ? rA : rB, (rB > rA) ? rB : rA);
580 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
595 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
619 printf(
"__FILE__ = %s \n __LINE __ %i , __FUNC__ %s \n ", __FILE__, __LINE__, __func__);
623 if(!source)
continue;
625 Double_t sourceRho(0), targetRho(0);
634 fProfQA->Fill(0.5, TMath::Abs((source->
Pt()-sourceRho)-(target->
Pt()-targetRho)));
647 Double_t sourceRho(0), targetRho(0);
671 Int_t iJets(source->GetEntriesFast());
674 for(
Int_t i(0); i < iJets; i++) {
676 if(jet->
Eta() < etaMin || jet->
Eta() > etaMax)
continue;
679 pt = leadingJet->
Pt();
692 Int_t iJets(source->GetEntriesFast());
694 if(leadingJetIndex < 0)
GetLeadingJet(source, leadingJetIndex);
695 AliEmcalJet *leadingJet(0x0), *prevLeadingJet(static_cast<AliEmcalJet*>(source->At(leadingJetIndex)));
696 if(!prevLeadingJet)
return 0x0;
697 Double_t pt(0), leadingPt(prevLeadingJet->
Pt());
698 for(
Int_t i(0); i < iJets; i++) {
699 if(i == leadingJetIndex)
continue;
702 if(jet->
Pt() > pt && jet->
Pt() <= leadingPt) {
704 pt = leadingJet->
Pt();
705 subLeadingJetIndex = i;
TH1F * fHistTargetJetPt
pt of matched source jets
TH3F * fHistDiJet
no of consstituents fraction jet / jet
TH3F * fHistDiJetLeadingJet
matched dijet eta, phi
TString fSourceRhoName
source rho
Bool_t PassesCuts(const AliVTrack *track) const
TH1F * fHistMatchedJetPt
pt of target jets
void ClearMatchedJetsCache()
TH1F * fHistAnalysisSummary
dijet dpt
TH2F * fHistSourceMatchedJetPt
pt of matched jets
TString fTargetJetsName
array with target jets
TClonesArray * fTargetJets
TProfile * fProfFracNoMatched
sum pt fraction for matched jets
TString fTargetRhoName
target rho
Double_t GetLocalVal(Double_t phi, Double_t r, Double_t n) const
void DoGeometricMatchingR()
void FillAnalysisSummaryHistogram() const
TH1F * fHistNoConstMatchJet
number of constituents of target jet
virtual void UserCreateOutputObjects()
TString fMatchedJetsName
final list of matched jets which is added to event
AliLocalRhoParameter * fSourceRho
Double_t GetR(AliVParticle *a, AliVParticle *b) const
TH1F * fh1AvgTrials
sum of trails (in Notify)
void ExecOnce()
Perform steps needed to initialize the analysis.
TH3F * BookTH3F(const char *name, const char *x, const char *y, const char *z, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Int_t binsz, Double_t minz, Double_t maxz, Bool_t append=kTRUE)
Bool_t fMatchConstituents
AliEmcalJet * fMatchedJetContainer[200][2]
number of matched jets
AliLocalRhoParameter * fTargetRho
void DoGeometricMatchingEtaPhi()
TH2F * fHistDetectorResponseProb
pt or source vs matched jets
UShort_t GetNumberOfConstituents() const
Int_t TrackAt(Int_t idx) const
AliEmcalJet * GetLeadingJet(TClonesArray *source, Int_t &leadingJetIndex, Double_t etaMin=-.7, Double_t etaMax=.7)
UShort_t GetNumberOfTracks() const
TH1F * BookTH1F(const char *name, const char *x, Int_t bins, Double_t min, Double_t max, Bool_t append=kTRUE)
matchingSceme fMatchingScheme
Float_t fMatchEta
pointers to matched jets
Bool_t fUseEmcalBaseJetCuts
TH1F * fHistMatchedSourceJetPt
pt of source jets
TClonesArray * fMatchedJets
Double_t PhaseShift(Double_t x) const
TProfile * fProfFracPtMatched
number of constituents of matched jets
void FillMatchedJetHistograms()
virtual ~AliAnalysisTaskJetMatching()
TClonesArray * fSourceJets
TString fSourceJetsName
array with source jets
TProfile * fProfFracPtJets
sum pt fraction for matched tracks / jet
TH2F * fHistDiJetDPt
dijet dphi
TProfile * fh1Xsec
average sum of trials (in Run)
TProfile * fProfFracNoJets
no of constituents fraction found / jet
void DoConstituentMatching()
TH1F * fHistUnsortedCorrelation
output list
Float_t fMinFracRecoveredConstituents
Float_t fAvgTrials
pythia cross section and trials
TProfile * fProfQA
QA spreads of matched jets.
TProfile * fProfQAMatched
flags
Bool_t fDoDetectorResponse
virtual Bool_t IsEventSelected()
Performing event selection.
Float_t fMinFracRecoveredConstituentPt
virtual void Terminate(Option_t *option)
AliAnalysisTaskJetMatching()
TClonesArray * fTracks
!tracks
TH2F * fHistDiJetDPhi
leading jet (for dijet) eta, phi
virtual Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
TH2F * BookTH2F(const char *name, const char *x, const char *y, Int_t binsx, Double_t minx, Double_t maxx, Int_t binsy, Double_t miny, Double_t maxy, Bool_t append=kTRUE)
TFile * file
TList with histograms for a given trigger.
AliEmcalJet * GetSubLeadingJet(TClonesArray *source, Int_t leadingJetIndex, Int_t &subLeadingJetIndex)
Base task in the EMCAL jet framework.
Represent a jet reconstructed using the EMCal jet framework.
Int_t fNoMatchedJets
QA spreads of source and target jets.
TH1F * fHistMatchedCorrelation
dphi correlation of unsorted jets
TH1F * fHistNoConstSourceJet
det prob
virtual Bool_t AcceptJet(AliEmcalJet *jet, Int_t c=0)
TH1F * fHistNoConstTargetJet
number of constituents of source jet
TH1F * fHistSourceJetPt
dphi correlation of matched jets