5 #include "AliAnalysisTaskEmcalJetPatchTriggerQA.h"
9 #include <TClonesArray.h>
13 #include <THnSparse.h>
15 #include <TLorentzVector.h>
16 #include <TParameter.h>
17 #include <TParticle.h>
21 #include "AliAODEvent.h"
22 #include "AliAnalysisManager.h"
23 #include "AliAnalysisTask.h"
24 #include "AliCentrality.h"
25 #include "AliESDEvent.h"
26 #include "AliESDInputHandler.h"
27 #include "AliEmcalJet.h"
28 #include "AliVCluster.h"
29 #include "AliRhoParameter.h"
30 #include "AliEmcalParticle.h"
31 #include "AliLocalRhoParameter.h"
32 #include "AliAnalysisTaskLocalRho.h"
33 #include <AliInputEventHandler.h>
34 #include <AliVEventHandler.h>
36 ClassImp(AliAnalysisTaskEmcalJetPatchTriggerQA)
38 //________________________________________________________________________
39 AliAnalysisTaskEmcalJetPatchTriggerQA::AliAnalysisTaskEmcalJetPatchTriggerQA() :
40 AliAnalysisTaskEmcalJet("ChristineQA",kFALSE),
41 fPhimin(-10), fPhimax(10),
42 fEtamin(-0.9), fEtamax(0.9),
48 // Default constructor.
49 SetMakeGeneralHistograms(kTRUE);
53 //________________________________________________________________________
54 AliAnalysisTaskEmcalJetPatchTriggerQA::AliAnalysisTaskEmcalJetPatchTriggerQA(const char *name) :
55 AliAnalysisTaskEmcalJet(name,kTRUE),
56 fPhimin(-10), fPhimax(10),
57 fEtamin(-0.9), fEtamax(0.9),
64 SetMakeGeneralHistograms(kTRUE);
66 // DefineInput(0,TChain::Class());
67 // DefineOutput(1, TList::Class());
70 //_______________________________________________________________________
71 AliAnalysisTaskEmcalJetPatchTriggerQA::~AliAnalysisTaskEmcalJetPatchTriggerQA()
81 //________________________________________________________________________
82 void AliAnalysisTaskEmcalJetPatchTriggerQA::UserCreateOutputObjects()
86 AliAnalysisTaskEmcalJet::UserCreateOutputObjects();
88 fHistNjetvsCent = new TH2F("NjetvsCent", "NjetvsCent", 100, 0.0, 100.0, 100, 0, 100);
89 fOutput->Add(fHistNjetvsCent);
91 UInt_t bitcode = 0; // bit codes, see GetDimParams() below
92 //bitcode = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<9;
93 bitcode = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 ;
94 fhnJetTriggerQA = NewTHnSparseF("fhnJetTriggerQA", bitcode);
95 fhnJetTriggerQA->Sumw2();
96 fOutput->Add(fhnJetTriggerQA);
101 //________________________________________________________
102 void AliAnalysisTaskEmcalJetPatchTriggerQA::ExecOnce()
104 // Initialize the analysis
105 AliAnalysisTaskEmcalJet::ExecOnce();
109 //________________________________________________________________________
110 Bool_t AliAnalysisTaskEmcalJetPatchTriggerQA::Run()
112 // TEST TEST TEST TEST for OBJECTS!!
114 AliWarning(Form("%s: Could not retrieve LocalRho object!", GetName()));
115 fLocalRho = GetLocalRhoFromEvent(fLocalRhoName);
118 // check to see if we have jet object
119 if (!fJets) return kTRUE;
121 // find NUMBER of jets
122 const Int_t Njets = fJets->GetEntries();
125 // loop over jets in the event and make appropriate cuts
126 //cout<<"I at least get in the event and I have "<<Njets<<" jets"<<endl;
127 for (Int_t iJets = 0; iJets < Njets; ++iJets) {
128 AliEmcalJet *jet = static_cast<AliEmcalJet*>(fJets->At(iJets));
129 if (!jet) // see if we have a jet
131 if (!AcceptMyJet(jet))
134 //cout<<"jet pt "<<jet->Pt()<<" area "<<jet->Area()<<" maxtrackpt "<<jet->MaxTrackPt()<<endl;
135 //This somehow needs to be fixed but I'm not sure what it does yet. It seems the defaults are wacky.
136 // if (! AcceptJet(jet)) // sees if jet is accepted
138 // jets.push_back(jet);
142 // Initializations and Calculations
143 // Double_t jetphi = jet->Phi();
144 //Double_t jeteta = jet->Eta(); // ETA of jet
146 Double_t jetPtraw = jet->Pt(); // raw pT of jet
147 Double_t jetPtLocal = -500; // initialize corr jet pt LOCAL
148 Double_t jetPtGlobal = -500; // initialize corr jet pt GLOBAL
149 Double_t jetarea = -500; // initialize jet area
150 jetarea = jet->Area(); // jet area
152 Double_t dEP = -500; // initialize angle between jet and event plane
153 dEP = RelativeEPJET(jet->Phi(),fEPV0);
155 // get LOCAL rho from event and fill histo's
156 fRhoVal = fRho->GetVal();
157 fLocalRhoVal = fLocalRho->GetLocalVal(jet->Phi(), 0.2); // jet angle, then jet radius
159 jetPtLocal = jet->Pt() - jetarea*fLocalRhoVal; // corrected pT of jet from LOCAL rho value
160 jetPtGlobal = jet->Pt() - jetarea*fRhoVal; // corrected pT of jet from GLOBAL rho value
162 // need to update entries soon
163 //Double_t Entries[10] = {centbin, jetPtLocal, jetPtGlobal, jetPtraw, jet->Eta(), jet->Phi(), dEP, fLocalRhoVal, fRhoVal, fEPV0};
164 Double_t Entries[9] = {fCent, jetPtLocal, jetPtGlobal, jetPtraw, jet->Phi(), dEP, fLocalRhoVal, fRhoVal, fEPV0};
165 fhnJetTriggerQA->Fill(Entries); // fill Sparse Histo with entries
167 // in plane and out of plane histo's
168 if( dEP>0 && dEP<=(TMath::Pi()/6) ){
169 // we are IN plane, lets fill some histo's
170 }else if( dEP>(TMath::Pi()/3) && dEP<=(TMath::Pi()/2) ){
171 // we are OUT of PLANE, lets fill some histo's
174 fHistNjetvsCent->Fill(fCent,NjetAcc);
176 } // LOOP over JETS in event
181 //________________________________________________________________________
182 void AliAnalysisTaskEmcalJetPatchTriggerQA::Terminate(Option_t *)
185 } // end of terminate
187 //________________________________________________________________________
188 Int_t AliAnalysisTaskEmcalJetPatchTriggerQA::GetCentBin(Double_t cent) const
189 { // Get centrality bin.
192 if (cent>=0 && cent<10)
194 else if (cent>=10 && cent<20)
196 else if (cent>=20 && cent<30)
198 else if (cent>=30 && cent<40)
200 else if (cent>=40 && cent<50)
202 else if (cent>=50 && cent<90)
207 //_________________________________________________________________________
208 Double_t AliAnalysisTaskEmcalJetPatchTriggerQA:: RelativeEPJET(Double_t jetAng, Double_t EPAng) const
209 { // function to calculate angle between jet and EP in the 1st quadrant (0,Pi/2)
210 Double_t dphi = (EPAng - jetAng);
212 // ran into trouble with a few dEP<-Pi so trying this...
213 if( dphi<-1*TMath::Pi() ){
214 dphi = dphi + 1*TMath::Pi();
217 if( (dphi>0) && (dphi<1*TMath::Pi()/2) ){
218 // Do nothing! we are in quadrant 1
219 }else if( (dphi>1*TMath::Pi()/2) && (dphi<1*TMath::Pi()) ){
220 dphi = 1*TMath::Pi() - dphi;
221 }else if( (dphi<0) && (dphi>-1*TMath::Pi()/2) ){
223 }else if( (dphi<-1*TMath::Pi()/2) && (dphi>-1*TMath::Pi()) ){
224 dphi = dphi + 1*TMath::Pi();
228 if( dphi < 0 || dphi > TMath::Pi()/2 )
229 AliWarning(Form("%s: dPHI not constrained from [0, Pi/2]", GetName()));
231 return dphi; // dphi in [0, Pi/2]
234 //______________________________________________________________________
235 THnSparse* AliAnalysisTaskEmcalJetPatchTriggerQA::NewTHnSparseF(const char* name, UInt_t entries)
237 // generate new THnSparseF, axes are defined in GetDimParams()
239 UInt_t tmp = entries;
242 tmp = tmp &~ -tmp; // clear lowest bit
245 TString hnTitle(name);
246 const Int_t dim = count;
253 while(c<dim && i<32){
257 GetDimParams(i, label, nbins[c], xmin[c], xmax[c]);
258 hnTitle += Form(";%s",label.Data());
266 return new THnSparseF(name, hnTitle.Data(), dim, nbins, xmin, xmax);
267 } // end of NewTHnSparseF
269 void AliAnalysisTaskEmcalJetPatchTriggerQA::GetDimParams(Int_t iEntry, TString &label, Int_t &nbins, Double_t &xmin, Double_t &xmax)
271 // stores label and binning of axis for THnSparse
272 const Double_t pi = TMath::Pi();
277 label = "V0 centrality (%)";
284 label = "Corrected jet p_{T}: Local #rho";
291 label = "Corrected jet p_{T}: Global #rho";
298 label = "Raw jet p_{T}";
307 xmin = 1.4;//-1.0*pi;
312 label = "Relative angle between jet and Reaction plane";
319 label = "Local #rho value";
326 label = "Global #rho value";
333 label = "fEPV0 event plane";
335 xmin = -TMath::Pi()/2.0;
336 xmax = TMath::Pi()/2.0;
340 } // end of getting dim-params
342 //________________________________________________________________________
343 Int_t AliAnalysisTaskEmcalJetPatchTriggerQA::AcceptMyJet(AliEmcalJet *jet) {
344 //applies all jet cuts except pt
345 if ((jet->Phi()<fPhimin)||(jet->Phi()>fPhimax)) return 0;
346 if ((jet->Eta()<fEtamin)||(jet->Eta()>fEtamax)) return 0;
347 if (jet->Area()<fAreacut) return 0;
348 // prevents 0 area jets from sneaking by when area cut == 0
349 if (jet->Area()==0) return 0;
350 //exclude jets with extremely high pt tracks which are likely misreconstructed
351 if(jet->MaxTrackPt()>100) return 0;
353 //passed all above cuts