1 // **************************************
2 // Task used for the correction of detector effects for background fluctuations in jet spectra by the HBOM method
3 // *******************************************
6 /**************************************************************************
7 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
9 * Author: The ALICE Off-line Project. *
10 * Contributors are mentioned in the code where appropriate. *
12 * Permission to use, copy, modify and distribute this software and its *
13 * documentation strictly for non-commercial purposes is hereby granted *
14 * without fee, provided that the above copyright notice appears in all *
15 * copies and that both the copyright notice and this permission notice *
16 * appear in the supporting documentation. The authors make no claims *
17 * about the suitability of this software for any purpose. It is *
18 * provided "as is" without express or implied warranty. *
19 **************************************************************************/
25 #include <TInterpreter.h>
27 #include <TRefArray.h>
36 #include <TLorentzVector.h>
37 #include <TClonesArray.h>
38 #include "TDatabasePDG.h"
40 #include "AliAnalysisTaskJetHBOM.h"
41 #include "AliAnalysisManager.h"
42 #include "AliESDEvent.h"
43 #include "AliAODEvent.h"
44 #include "AliAODHandler.h"
45 #include "AliAODExtension.h"
46 #include "AliAODTrack.h"
47 #include "AliAODJet.h"
48 #include "AliAODMCParticle.h"
49 #include "AliMCEventHandler.h"
50 #include "AliMCEvent.h"
52 #include "AliGenPythiaEventHeader.h"
53 #include "AliGenCocktailEventHeader.h"
54 #include "AliInputEventHandler.h"
55 #include "AliAODJetEventBackground.h"
62 ClassImp(AliAnalysisTaskJetHBOM)
64 AliAnalysisTaskJetHBOM::~AliAnalysisTaskJetHBOM(){
72 if(fTCARandomConesOut)fTCARandomConesOut->Delete();
73 delete fTCARandomConesOut;
75 if(fTCARandomConesOutRan)fTCARandomConesOutRan->Delete();
76 delete fTCARandomConesOutRan;
80 AliAnalysisTaskJetHBOM::AliAnalysisTaskJetHBOM():
85 fUseAODTrackInput(kFALSE),
86 fUseAODMCInput(kFALSE),
87 fEventSelection(kFALSE),
92 fTrackTypeRec(kTrackUndef),
93 fTrackTypeGen(kTrackUndef),
101 fTrackEtaWindow(0.9),
102 //fRecEtaWindow(0.5),
104 fJetOutputMinPt(0.150),
105 fMaxTrackPtInJet(100.),
111 fBackgroundBranch(""),
122 fUseTrMomentumSmearing(kFALSE),
123 fUseDiceEfficiency(kFALSE),
125 fAlgorithm(fastjet::kt_algorithm),
126 fStrategy(fastjet::Best),
127 fRecombScheme(fastjet::BIpt_scheme),
128 fAreaType(fastjet::active_area),
130 fActiveAreaRepeats(1),
133 fTCARandomConesOut(0x0),
134 fTCARandomConesOutRan(0x0),
140 fh1PtHardTrials(0x0),
142 fh1CentralityPhySel(0x0),
148 fh1efficiencyPt(0x0),
149 fh2efficiencyPhi(0x0),
157 AliAnalysisTaskJetHBOM::AliAnalysisTaskJetHBOM(const char* name):
158 AliAnalysisTaskSE(name),
162 fUseAODTrackInput(kFALSE),
163 fUseAODMCInput(kFALSE),
164 fEventSelection(kFALSE),
166 fFilterMaskBestPt(0),
169 fTrackTypeRec(kTrackUndef),
170 fTrackTypeGen(kTrackUndef),
172 fNSkipLeadingCone(0),
178 fTrackEtaWindow(0.9),
179 //fRecEtaWindow(0.5),
181 fJetOutputMinPt(0.150),
182 fMaxTrackPtInJet(100.),
188 fBackgroundBranch(""),
199 fUseTrMomentumSmearing(kFALSE),
200 fUseDiceEfficiency(kFALSE),
202 fAlgorithm(fastjet::kt_algorithm),
203 fStrategy(fastjet::Best),
204 fRecombScheme(fastjet::BIpt_scheme),
205 fAreaType(fastjet::active_area),
207 fActiveAreaRepeats(1),
210 fTCARandomConesOut(0x0),
211 fTCARandomConesOutRan(0x0),
217 fh1PtHardTrials(0x0),
219 fh1CentralityPhySel(0x0),
225 fh1efficiencyPt(0x0),
226 fh2efficiencyPhi(0x0),
231 DefineOutput(1, TList::Class());
236 Bool_t AliAnalysisTaskJetHBOM::Notify()
239 // Implemented Notify() to read the cross sections
240 // and number of trials from pyxsec.root
245 void AliAnalysisTaskJetHBOM::UserCreateOutputObjects()
249 // Create the output container
252 fRandom = new TRandom3(0);
258 if (fDebug > 1) printf("AnalysisTaskJetHBOM::UserCreateOutputObjects() \n");
262 if(fNonStdBranch.Length()!=0)
264 // only create the output branch if we have a name
265 // Create a new branch for jets...
266 // -> cleared in the UserExec....
267 // here we can also have the case that the brnaches are written to a separate file
269 // create the branch for the random cones with the same R
270 TString cName = Form("%sRandomConeSkip%02d",fNonStdBranch.Data(),fNSkipLeadingCone);
271 if(fUseDiceEfficiency || fUseTrMomentumSmearing)
272 cName = Form("%sDetector%d%d_RandomConeSkip%02d",fNonStdBranch.Data(),fUseTrMomentumSmearing,fUseDiceEfficiency,fNSkipLeadingCone);
274 //create array for the random cones; Until now only one cone per event is used
275 if(!AODEvent()->FindListObject(cName.Data())){
276 fTCARandomConesOut = new TClonesArray("AliAODJet", 0);
277 fTCARandomConesOut->SetName(cName.Data());
278 AddAODBranch("TClonesArray",&fTCARandomConesOut,fNonStdFile.Data());
280 // create the branch with the random for the random cones on the random event
281 cName = Form("%sRandomCone_random",fNonStdBranch.Data());
282 if(!AODEvent()->FindListObject(cName.Data())){
283 fTCARandomConesOutRan = new TClonesArray("AliAODJet", 0);
284 fTCARandomConesOutRan->SetName(cName.Data());
285 AddAODBranch("TClonesArray",&fTCARandomConesOutRan,fNonStdFile.Data());
288 if(fNonStdFile.Length()!=0){
290 // case that we have an AOD extension we need to fetch the jets from the extended output
291 // we identify the extension aod event by looking for the branchname
292 AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
293 // case that we have an AOD extension we need can fetch the background maybe from the extended output
294 fAODExtension = (aodH?aodH->GetExtension(fNonStdFile.Data()):0);
298 // FitMomentumResolution();
301 if(!fHistList)fHistList = new TList();
302 fHistList->SetOwner();
303 PostData(1, fHistList); // post data in any case once
305 Bool_t oldStatus = TH1::AddDirectoryStatus();
306 TH1::AddDirectory(kFALSE);
311 const Int_t nBinPt = 100;
312 Double_t binLimitsPt[nBinPt+1];
313 for(Int_t iPt = 0;iPt <= nBinPt;iPt++){
315 binLimitsPt[iPt] = 0.0;
318 binLimitsPt[iPt] = binLimitsPt[iPt-1] + 2.0;
322 const Int_t nBinPhi = 90;
323 Double_t binLimitsPhi[nBinPhi+1];
324 for(Int_t iPhi = 0;iPhi<=nBinPhi;iPhi++){
326 binLimitsPhi[iPhi] = -1.*TMath::Pi();
329 binLimitsPhi[iPhi] = binLimitsPhi[iPhi-1] + 1/(Float_t)nBinPhi * TMath::Pi()*2;
335 const Int_t nBinEta = 40;
336 Double_t binLimitsEta[nBinEta+1];
337 for(Int_t iEta = 0;iEta<=nBinEta;iEta++){
339 binLimitsEta[iEta] = -2.0;
342 binLimitsEta[iEta] = binLimitsEta[iEta-1] + 0.1;
346 const int nChMax = 5000;
348 fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root",1,0,1);
349 fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>");
351 fh1Trials = new TH1F("fh1Trials","trials root file",1,0,1);
352 fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}");
355 fh1PtHard = new TH1F("fh1PtHard","PYTHIA Pt hard;p_{T,hard}",nBinPt,binLimitsPt);
356 fh1PtHardNoW = new TH1F("fh1PtHardNoW","PYTHIA Pt hard no weight;p_{T,hard}",nBinPt,binLimitsPt);
357 fh1PtHardTrials = new TH1F("fh1PtHardTrials","PYTHIA Pt hard weight with trials;p_{T,hard}",nBinPt,binLimitsPt);
359 fh1Nch = new TH1F("fh1Nch","charged multiplicity; N_{ch}",nChMax,-0.5,nChMax-0.5);
361 fh1Centrality = new TH1F("fh1Centrality",";cent (%)",111,-0.5,110.5);
362 fh1CentralityPhySel = new TH1F("fh1CentralityPhySel",";cent (%)",111,-0.5,110.5);
364 fh1Z = new TH1F("fh1Z",";zvtx",100,-25,25);
365 fh1ZPhySel = new TH1F("fh1ZPhySel",";zvtx",100,-25,25);
367 fh1DeltapT = new TH1F("fh1DeltapT","DeltapT",100,-50,50);
368 fh1Rho = new TH1F("fh1Rho","Rho",100,0,200);
369 fh1PtRandCone = new TH1F("fh1PtRandCone","pt",100,0,200);
370 fh1Area = new TH1F("fh1Area","area",100,0,1);
372 const Int_t saveLevel = 3; // large save level more histos
374 fHistList->Add(fh1Xsec);
375 fHistList->Add(fh1Trials);
377 fHistList->Add(fh1Nch);
378 fHistList->Add(fh1Centrality);
379 fHistList->Add(fh1CentralityPhySel);
380 fHistList->Add(fh1Z);
381 fHistList->Add(fh1ZPhySel);
382 fHistList->Add(fh1DeltapT);
383 fHistList->Add(fh1Rho);
384 fHistList->Add(fh1PtRandCone);
385 fHistList->Add(fh1Area);
388 // =========== Switch on Sumw2 for all histos ===========
389 for (Int_t i=0; i<fHistList->GetEntries(); ++i) {
390 TH1 *h1 = dynamic_cast<TH1*>(fHistList->At(i));
395 THnSparse *hn = dynamic_cast<THnSparse*>(fHistList->At(i));
398 TH1::AddDirectory(oldStatus);
401 void AliAnalysisTaskJetHBOM::Init()
407 if (fDebug > 1) printf("AnalysisTaskJetHBOM::Init() \n");
409 FitMomentumResolution();
413 void AliAnalysisTaskJetHBOM::UserExec(Option_t */*option*/)
416 // handle and reset the output jet branch
418 if(fTCARandomConesOut)fTCARandomConesOut->Delete();
419 if(fTCARandomConesOutRan)fTCARandomConesOutRan->Delete();
422 // Execute analysis for current event
424 AliESDEvent *fESD = 0;
425 if(fUseAODTrackInput){
426 fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
428 Printf("%s:%d AODEvent not found in Input Manager %d",(char*)__FILE__,__LINE__,fUseAODTrackInput);
434 // assume that the AOD is in the general output...
437 Printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
441 fESD = dynamic_cast<AliESDEvent*> (InputEvent());
445 //Check if information is provided detector level effects
446 if(!fMomResH1 || !fMomResH2 || !fMomResH3) fUseTrMomentumSmearing = kFALSE;
447 if(!fhEffH1 || !fhEffH2 || !fhEffH3) fUseDiceEfficiency = kFALSE;
449 Bool_t selectEvent = false;
450 Bool_t physicsSelection = true;// handled by the framework(fInputHandler->IsEventSelected()&AliVEvent::kMB)==AliVEvent::kMB;
456 const AliAODVertex *vtxAOD = fAOD->GetPrimaryVertex();
457 TString vtxTitle(vtxAOD->GetTitle());
458 zVtx = vtxAOD->GetZ();
460 cent = fAOD->GetHeader()->GetCentrality();
461 if(physicsSelection){
462 fh1CentralityPhySel->Fill(cent);
463 fh1ZPhySel->Fill(zVtx);
465 // zVertex and centrality selection
467 if(vtxAOD->GetNContributors()>2&&!vtxTitle.Contains("TPCVertex")){
468 Float_t yvtx = vtxAOD->GetY();
469 Float_t xvtx = vtxAOD->GetX();
470 Float_t r2 = yvtx*yvtx+xvtx*xvtx;
471 if(TMath::Abs(zVtx)<fVtxZCut&&r2<fVtxR2Cut){//usual fVtxZCut=10 and fVtxR2Cut=1 // apply vertex cut later on
472 if(physicsSelection){
477 //centrality selection
479 if(cent<fCentCutLo||cent>fCentCutUp){
490 PostData(1, fHistList);
493 fh1Centrality->Fill(cent);
495 fh1Trials->Fill("#sum{ntrials}",1);
498 if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
500 // ==== General variables needed
504 // we simply fetch the tracks/mc particles as a list of AliVParticles
506 //reconstructed particles
508 Int_t nT = GetListOfTracks(&recParticles,fTrackTypeRec);
509 Float_t nCh = recParticles.GetEntries();
511 if(fDebug>2)Printf("%s:%d Selected Rec tracks: %d %d",(char*)__FILE__,__LINE__,nT,recParticles.GetEntries());
512 //nT = GetListOfTracks(&genParticles,fTrackTypeGen);
513 //if(fDebug>2)Printf("%s:%d Selected Gen tracks: %d %d",(char*)__FILE__,__LINE__,nT,genParticles.GetEntries());
516 //apply efficiency fNHBOM times
518 for(int particle=0;particle<recParticles.GetEntries();particle++){
519 // hier Effizienzen laden und überprüfen ob das Teilchen nachgewiesen wird.
520 AliVParticle *vp = (AliVParticle*)recParticles.At(particle);
522 Double_t pT = vp->Pt();
523 Double_t phi = vp->Phi();
526 Double_t efficiencyPt = fh1efficiencyPt->GetBinContent(fh1efficiencyPt->FindBin(pT));
527 Double_t efficiencyPhi = fh2efficiencyPhi->GetBinContent(fh2efficiencyPhi->FindBin(phi,pT));
529 efficiencyPt = 0.857; //this is the result for the fit with pT>10; statistic is low for pT>10
530 //if the efficiency is not from fastMCInput_LHC10h_110719a.root this should be calculated new
531 if(fh1efficiencyPt->GetBinContent(fh1efficiencyPt->FindBin(10))>0.9||fh1efficiencyPt->GetBinContent(fh1efficiencyPt->FindBin(10))<0.8){
532 efficiencyPt = fh1efficiencyPt->GetBinContent(fh1efficiencyPt->FindBin(pT));
533 Printf("%s:%d Wrong efficiency input. Check efficiency for pt>10GeV",(char*)__FILE__,__LINE__);
536 Double_t eff = efficiencyPt*efficiencyPhi; //over all efficiency
538 // if ran<eff -> particle is detected eff^fNHBOM = efficiency to detect particle fNHBOM times
539 Double_t ran = fRandom->Rndm();
540 if(ran>TMath::Power(eff,fNHBOM)){
541 recParticles.Remove(vp);
549 vector<fastjet::PseudoJet> inputParticlesRec;
550 vector<fastjet::PseudoJet> inputParticlesRecRan;
552 //randomize particles
553 AliAODJet vTmpRan(1,0,0,1);
554 for(int i = 0; i < recParticles.GetEntries(); i++){
555 AliVParticle *vp = (AliVParticle*)recParticles.At(i);
557 // Carefull energy is not well determined in real data, should not matter for p_T scheme?
558 // we take total momentum here
560 //Add particles to fastjet in case we are not running toy model
561 fastjet::PseudoJet jInp(vp->Px(),vp->Py(),vp->Pz(),vp->P());
562 jInp.set_user_index(i);
563 inputParticlesRec.push_back(jInp);
565 // the randomized input changes eta and phi, but keeps the p_T
566 Double_t pT = vp->Pt();
567 Double_t eta = 2.*fTrackEtaWindow * fRandom->Rndm() - fTrackEtaWindow;
568 Double_t phi = 2.* TMath::Pi() * fRandom->Rndm();
570 Double_t theta = 2.*TMath::ATan(TMath::Exp(-eta));
571 Double_t pZ = pT/TMath::Tan(theta);
573 Double_t pX = pT * TMath::Cos(phi);
574 Double_t pY = pT * TMath::Sin(phi);
575 Double_t p = TMath::Sqrt(pT*pT+pZ*pZ);
576 fastjet::PseudoJet jInpRan(pX,pY,pZ,p);
578 jInpRan.set_user_index(i);
579 inputParticlesRecRan.push_back(jInpRan);
580 vTmpRan.SetPxPyPzE(pX,pY,pZ,p);
584 if(inputParticlesRec.size()==0){
585 if(fDebug)Printf("%s:%d No input particles found, skipping event",(char*)__FILE__,__LINE__);
586 PostData(1, fHistList);
591 // employ setters for these...
593 fastjet::GhostedAreaSpec ghostSpec(fGhostEtamax, fActiveAreaRepeats, fGhostArea);
594 fastjet::AreaType areaType = fastjet::active_area;
595 fastjet::AreaDefinition areaDef = fastjet::AreaDefinition(areaType,ghostSpec);
596 fastjet::JetDefinition jetDef(fAlgorithm, fRparam, fRecombScheme, fStrategy);
597 fastjet::ClusterSequenceArea clustSeq(inputParticlesRec, jetDef,areaDef);
599 //range where to compute background
600 Double_t phiMin = 0, phiMax = 0, rapMin = 0, rapMax = 0;
602 phiMax = 2*TMath::Pi();
603 rapMax = fGhostEtamax - fRparam;
604 rapMin = - fGhostEtamax + fRparam;
605 fastjet::RangeDefinition range(rapMin,rapMax, phiMin, phiMax);
608 const vector <fastjet::PseudoJet> &inclusiveJets = clustSeq.inclusive_jets();
609 const vector <fastjet::PseudoJet> &sortedJets = sorted_by_pt(inclusiveJets);
612 // loop over all jets and fill information, first one is the leading jet
614 if(inclusiveJets.size()>0){
616 //background estimates:all bckg jets wo the 2 hardest
617 vector<fastjet::PseudoJet> jets2=sortedJets;
618 if(jets2.size()>2) jets2.erase(jets2.begin(),jets2.begin()+2); //removes the two jets with the highest pT; +2 is correct ro remove 2 jets
621 Double_t meanarea1=0.;
622 clustSeq.get_median_rho_and_sigma(jets2, range, true, bkg1, sigma1, meanarea1, true);
623 background = bkg1;//sets background variable of the task to the correct value
626 // generate random cones
627 if(fTCARandomConesOut){
628 // create a random jet within the acceptance
629 Double_t etaMax = fTrackEtaWindow - fRparam;//0.9 - 0.4
632 Double_t pTC = 1; // small number
633 Double_t etaC = etaMax*2.*(fRandom->Rndm()-0.5); // +- etamax
634 Double_t phiC = fRandom->Rndm()*2.*TMath::Pi(); // 0 - 2pi
635 // use fixed position for random Cones
641 Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC));
642 Double_t pZC = pTC/TMath::Tan(thetaC);
643 Double_t pXC = pTC * TMath::Cos(phiC);
644 Double_t pYC = pTC * TMath::Sin(phiC);
645 Double_t pC = TMath::Sqrt(pTC*pTC+pZC*pZC);
646 AliAODJet tmpRecC (pXC,pYC,pZC, pC);
648 tmpRecC.SetBgEnergy(0,0); // this is use as temporary storage of the summed p_T below
649 if(fTCARandomConesOut)new ((*fTCARandomConesOut)[nCone++]) AliAODJet(tmpRecC);
650 if(fTCARandomConesOutRan)new ((*fTCARandomConesOutRan)[nConeRan++]) AliAODJet(tmpRecC);
652 // loop over the reconstructed particles and add up the pT in the random cones
653 // maybe better to loop over randomized particles not in the real jets...
654 // but this by definition brings dow average energy in the whole event
655 AliAODJet vTmpRanR(1,0,0,1);
656 for(int i = 0; i < recParticles.GetEntries(); i++){
657 AliVParticle *vp = (AliVParticle*)recParticles.At(i);
658 //add up energy in cone
659 if(fTCARandomConesOut){
660 AliAODJet *jC = (AliAODJet*)fTCARandomConesOut->At(0);
661 if(jC&&jC->DeltaR(vp)<fRparam){
662 if(vp->Pt()>fMaxTrackPtInJet)jC->SetTrigger(AliAODJet::kHighTrackPtTriggered);
663 jC->SetBgEnergy(jC->ChargedBgEnergy()+vp->Pt(),0);
665 }// add up energy in cone
667 // the randomized input changes eta and phi, but keeps the p_T
668 if(fTCARandomConesOutRan){
669 Double_t pTR = vp->Pt();
670 Double_t etaR = 2.*fTrackEtaWindow* fRandom->Rndm() - fTrackEtaWindow;
671 Double_t phiR = 2.* TMath::Pi() * fRandom->Rndm();
673 Double_t thetaR = 2.*TMath::ATan(TMath::Exp(-etaR));
674 Double_t pZR = pTR/TMath::Tan(thetaR);
676 Double_t pXR = pTR * TMath::Cos(phiR);
677 Double_t pYR = pTR * TMath::Sin(phiR);
678 Double_t pR = TMath::Sqrt(pTR*pTR+pZR*pZR);
679 vTmpRanR.SetPxPyPzE(pXR,pYR,pZR,pR);
681 AliAODJet *jC = (AliAODJet*)fTCARandomConesOutRan->At(0);
682 if(jC&&jC->DeltaR(&vTmpRanR)<fRparam){
683 if(vTmpRanR.Pt()>fMaxTrackPtInJet)jC->SetTrigger(AliAODJet::kHighTrackPtTriggered);
684 jC->SetBgEnergy(jC->ChargedBgEnergy()+vTmpRanR.Pt(),0);
687 }// loop over recparticles
688 } //fTCARandomConesOut
689 Float_t jetArea = fRparam*fRparam*TMath::Pi();
690 if(fTCARandomConesOut){
691 // rescale the momentum vectors for the random cones
692 AliAODJet *rC = (AliAODJet*)fTCARandomConesOut->At(0);
694 Double_t etaC = rC->Eta();
695 Double_t phiC = rC->Phi();
696 // massless jet, unit vector
697 Double_t pTC = rC->ChargedBgEnergy();
698 if(pTC<=0)pTC = 0.001; // for almost empty events
699 Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC));
700 Double_t pZC = pTC/TMath::Tan(thetaC);
701 Double_t pXC = pTC * TMath::Cos(phiC);
702 Double_t pYC = pTC * TMath::Sin(phiC);
703 Double_t pC = TMath::Sqrt(pTC*pTC+pZC*pZC);
704 rC->SetPxPyPzE(pXC,pYC,pZC, pC);
705 rC->SetBgEnergy(0,0);
706 rC->SetEffArea(jetArea,0);
709 if(fTCARandomConesOutRan){
710 AliAODJet* rC = (AliAODJet*)fTCARandomConesOutRan->At(0);
713 Double_t etaC = rC->Eta();
714 Double_t phiC = rC->Phi();
715 // massless jet, unit vector
716 Double_t pTC = rC->ChargedBgEnergy();
717 if(pTC<=0)pTC = 0.001;// for almost empty events
718 Double_t thetaC = 2.*TMath::ATan(TMath::Exp(-etaC));
719 Double_t pZC = pTC/TMath::Tan(thetaC);
720 Double_t pXC = pTC * TMath::Cos(phiC);
721 Double_t pYC = pTC * TMath::Sin(phiC);
722 Double_t pC = TMath::Sqrt(pTC*pTC+pZC*pZC);
723 rC->SetPxPyPzE(pXC,pYC,pZC, pC);
724 rC->SetBgEnergy(0,0);
725 rC->SetEffArea(jetArea,0);
727 }//find the random jets
728 }//inclusive Jets > 0
731 AliAODJet *randCone = (AliAODJet*)fTCARandomConesOut->At(0);
733 //background is the backbround density per area and area=pi*0.4^2 -> backgroundCone is the background energy under the cone
734 Float_t backgroundCone = background * randCone->EffectiveAreaCharged();
735 //calculates difference between expected and measured energy density
736 Float_t ptSub = randCone->Pt() - backgroundCone;
737 fh1DeltapT->Fill(ptSub);// delta pT
738 fh1Rho->Fill(background);// background rho
739 fh1PtRandCone->Fill(randCone->Pt());// pT of random cone
740 fh1Area->Fill(randCone->EffectiveAreaCharged()); // area of random cone; should always be pi*0.4^2 = 0.5
742 if(fDebug)Printf("%s:%d No random Cone found",(char*)__FILE__,__LINE__);
747 if(fTCARandomConesOut)Printf("%s:%d RC %d",(char*)__FILE__,__LINE__,fTCARandomConesOut->GetEntriesFast());
748 if(fTCARandomConesOutRan)Printf("%s:%d RC Ran %d",(char*)__FILE__,__LINE__,fTCARandomConesOutRan->GetEntriesFast());
750 PostData(1, fHistList);
753 void AliAnalysisTaskJetHBOM::Terminate(Option_t */*option*/)
756 // Terminate analysis
758 if (fDebug > 1) printf("AnalysisJetHBOM: Terminate() \n");
760 if(fMomResH1Fit) delete fMomResH1Fit;
761 if(fMomResH2Fit) delete fMomResH2Fit;
762 if(fMomResH3Fit) delete fMomResH3Fit;
767 Int_t AliAnalysisTaskJetHBOM::GetListOfTracks(TList *list,Int_t type){
770 // get list of tracks/particles for different types
773 if(fDebug>2)Printf("%s:%d Selecting tracks with %d",(char*)__FILE__,__LINE__,type);
776 if(type==kTrackAOD || type==kTrackAODextra || type==kTrackAODextraonly){
777 if(type!=kTrackAODextraonly) {
778 AliAODEvent *aod = 0;
779 if(fUseAODTrackInput)aod = dynamic_cast<AliAODEvent*>(InputEvent());
780 else aod = AODEvent();
782 if(fDebug>2)Printf("%s:%d No AOD",(char*)__FILE__,__LINE__);
786 for(int it = 0;it < aod->GetNumberOfTracks();++it){
787 AliAODTrack *tr = aod->GetTrack(it);
788 Bool_t bGood = false;
789 if(fFilterType == 0)bGood = true;
790 else if(fFilterType == 1)bGood = tr->IsHybridTPCConstrainedGlobal();
791 else if(fFilterType == 2)bGood = tr->IsHybridGlobalConstrainedGlobal();
792 if((fFilterMask>0)&&((!tr->TestFilterBit(fFilterMask)||(!bGood)))){
793 if(fDebug>10)Printf("%s:%d Not matching filter %d/%d %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks(),fFilterMask,tr->GetFilterMap());
796 if(TMath::Abs(tr->Eta())>fTrackEtaWindow){
797 if(fDebug>10)Printf("%s:%d Not matching eta %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks());
800 if(tr->Pt()<fTrackPtCut){
801 if(fDebug>10)Printf("%s:%d Not matching pt %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks());
804 if(fDebug>10)Printf("%s:%d MATCHED %d/%d",(char*)__FILE__,__LINE__,it,aod->GetNumberOfTracks());
809 if(type==kTrackAODextra || type==kTrackAODextraonly) {
810 AliAODEvent *aod = 0;
811 if(fUseAODTrackInput)aod = dynamic_cast<AliAODEvent*>(InputEvent());
812 else aod = AODEvent();
817 TClonesArray *aodExtraTracks = dynamic_cast<TClonesArray*>(aod->FindListObject("aodExtraTracks"));
818 if(!aodExtraTracks)return iCount;
819 for(int it =0; it<aodExtraTracks->GetEntries(); it++) {
820 AliVParticle *track = dynamic_cast<AliVParticle*> ((*aodExtraTracks)[it]);
821 if (!track) continue;
823 AliAODTrack *trackAOD = dynamic_cast<AliAODTrack*> (track);
824 if(!trackAOD)continue;
825 Bool_t bGood = false;
826 if(fFilterType == 0)bGood = true;
827 else if(fFilterType == 1)bGood = trackAOD->IsHybridTPCConstrainedGlobal();
828 else if(fFilterType == 2)bGood = trackAOD->IsHybridGlobalConstrainedGlobal();
829 if((fFilterMask>0)&&((!trackAOD->TestFilterBit(fFilterMask)||(!bGood))))continue;
830 if(TMath::Abs(trackAOD->Eta())>fTrackEtaWindow) continue;
831 if(trackAOD->Pt()<fTrackPtCut) continue;
837 else if (type == kTrackKineAll||type == kTrackKineCharged){
838 AliMCEvent* mcEvent = MCEvent();
839 if(!mcEvent)return iCount;
840 // we want to have alivpartilces so use get track
841 for(int it = 0;it < mcEvent->GetNumberOfTracks();++it){
842 if(!mcEvent->IsPhysicalPrimary(it))continue;
843 AliMCParticle* part = (AliMCParticle*)mcEvent->GetTrack(it);
844 if(type == kTrackKineAll){
845 if(part->Pt()<fTrackPtCut)continue;
849 else if(type == kTrackKineCharged){
850 if(part->Particle()->GetPDG()->Charge()==0)continue;
851 if(part->Pt()<fTrackPtCut)continue;
857 else if (type == kTrackAODMCCharged || type == kTrackAODMCAll || type == kTrackAODMCChargedAcceptance) {
858 AliAODEvent *aod = 0;
859 if(fUseAODMCInput)aod = dynamic_cast<AliAODEvent*>(InputEvent());
860 else aod = AODEvent();
861 if(!aod)return iCount;
862 TClonesArray *tca = dynamic_cast<TClonesArray*>(aod->FindListObject(AliAODMCParticle::StdBranchName()));
863 if(!tca)return iCount;
864 for(int it = 0;it < tca->GetEntriesFast();++it){
865 AliAODMCParticle *part = (AliAODMCParticle*)(tca->At(it));
866 if(!part->IsPhysicalPrimary())continue;
867 if(type == kTrackAODMCAll){
868 if(part->Pt()<fTrackPtCut)continue;
872 else if (type == kTrackAODMCCharged || type == kTrackAODMCChargedAcceptance ){
873 if(part->Charge()==0)continue;
874 if(part->Pt()<fTrackPtCut)continue;
875 if(kTrackAODMCCharged){
879 if(TMath::Abs(part->Eta())>fTrackEtaWindow)continue;
890 void AliAnalysisTaskJetHBOM::SetMomentumResolutionHybrid(TProfile *p1, TProfile *p2, TProfile *p3) {
893 // set mom res profiles
896 fMomResH1 = (TProfile*)p1->Clone("fMomResH1");
897 fMomResH2 = (TProfile*)p2->Clone("fMomResH2");
898 fMomResH3 = (TProfile*)p3->Clone("fMomResH3");
901 void AliAnalysisTaskJetHBOM:: SetEfficiencyHybrid(TH1 *h1, TH1 *h2, TH1 *h3) {
903 // set tracking efficiency histos
906 fhEffH1 = (TH1*)h1->Clone("fhEffH1");
907 fhEffH2 = (TH1*)h2->Clone("fhEffH2");
908 fhEffH3 = (TH1*)h3->Clone("fhEffH3");
911 Double_t AliAnalysisTaskJetHBOM::GetMomentumSmearing(Int_t cat, Double_t pt) {
914 // Get smearing on generated momentum
917 //printf("GetMomentumSmearing for cat %d and pt = %f \n",cat,pt);
919 TProfile *fMomRes = 0x0;
920 if(cat==1) fMomRes = (TProfile*)fMomResH1->Clone("fMomRes");
921 if(cat==2) fMomRes = (TProfile*)fMomResH2->Clone("fMomRes");
922 if(cat==3) fMomRes = (TProfile*)fMomResH3->Clone("fMomRes");
932 if(cat==1 && fMomResH1Fit) smear = fMomResH1Fit->Eval(pt);
933 if(cat==2 && fMomResH2Fit) smear = fMomResH2Fit->Eval(pt);
934 if(cat==3 && fMomResH3Fit) smear = fMomResH3Fit->Eval(pt);
938 Int_t bin = fMomRes->FindBin(pt);
940 smear = fRandom->Gaus(fMomRes->GetBinContent(bin),fMomRes->GetBinError(bin));
944 if(fMomRes) delete fMomRes;
949 void AliAnalysisTaskJetHBOM::FitMomentumResolution() {
951 // Fit linear function on momentum resolution at high pT
954 if(!fMomResH1Fit && fMomResH1) {
955 fMomResH1Fit = new TF1("fMomResH1Fit","[0]+[1]*x",0.,200.);
956 fMomResH1->Fit(fMomResH1Fit,"LL V0","",5.,30.);
957 fMomResH1Fit ->SetRange(5.,100.);
960 if(!fMomResH2Fit && fMomResH2) {
961 fMomResH2Fit = new TF1("fMomResH2Fit","[0]+[1]*x",0.,200.);
962 fMomResH2->Fit(fMomResH2Fit,"LL V0","",5.,30.);
963 fMomResH2Fit ->SetRange(5.,100.);
966 if(!fMomResH3Fit && fMomResH3) {
967 fMomResH3Fit = new TF1("fMomResH3Fit","[0]+[1]*x",0.,200.);
968 fMomResH3->Fit(fMomResH3Fit,"LL V0","",5.,30.);
969 fMomResH3Fit ->SetRange(5.,100.);