1 // MUON track QA referring AliMuonEffMC.cxx
2 // Author : Saehanseul Oh
4 #include "AliMuonEffMC.h"
14 #include "AliAnalysisManager.h"
15 #include "AliAnalysisTask.h"
16 #include "AliESDVertex.h"
17 #include "AliESDEvent.h"
18 #include "AliAODEvent.h"
19 #include "AliESDMuonTrack.h"
20 #include "AliESDVertex.h"
21 #include "AliAODVertex.h"
22 #include "AliCentrality.h"
23 #include "AliVParticle.h"
24 #include "AliMCParticle.h"
25 #include "AliAnalysisHelperJetTasks.h"
26 #include "AliMCEvent.h"
31 ClassImp(AliMuonEffMC)
33 //________________________________________________________________________
34 AliMuonEffMC::AliMuonEffMC() :
35 AliAnalysisTaskSE(), fESD(0), fAOD(0), fMC(0), fCentrality(99), fZVertex(99), fOutputList(0x0),
36 fHEventStat(0), fHEvt(0x0), fIsMc(kTRUE), fMDProcess(kTRUE), fCentralityEstimator("V0M"),
37 fNEtaBins(15), fNpTBins(100), fNCentBins(5), fNZvtxBins(10), fNPhiBins(24),
38 fHMuonParGen(0x0), fHMuonDetGen(0x0), fHMuonDetRec(0x0), fHEtcDetRec(0x0)
41 DefineInput(0, TChain::Class());
42 DefineOutput(1, TList::Class());
44 for(Int_t i=0; i<4; i++)
46 fHMuMotherGenPt[i] = 0x0;
47 fHMuMotherRecPt[i] = 0x0;
48 fHMuMotherGenPhi[i] = 0x0;
49 fHMuMotherRecPhi[i] = 0x0;
50 fHMuMotherGenEta[i] = 0x0;
51 fHMuMotherRecEta[i] = 0x0;
56 //________________________________________________________________________
57 AliMuonEffMC::AliMuonEffMC(const char *name) :
58 AliAnalysisTaskSE(name), fESD(0), fAOD(0), fMC(0), fCentrality(99), fZVertex(99), fOutputList(0x0),
59 fHEventStat(0), fHEvt(0x0), fIsMc(kTRUE), fMDProcess(kTRUE), fCentralityEstimator("V0M"),
60 fNEtaBins(15), fNpTBins(100), fNCentBins(5), fNZvtxBins(10), fNPhiBins(24),
61 fHMuonParGen(0x0), fHMuonDetGen(0x0), fHMuonDetRec(0x0), fHEtcDetRec(0x0)
64 DefineInput(0, TChain::Class());
65 DefineOutput(1, TList::Class());
67 for(Int_t i=0; i<4; i++)
69 fHMuMotherGenPt[i] = 0x0;
70 fHMuMotherRecPt[i] = 0x0;
71 fHMuMotherGenPhi[i] = 0x0;
72 fHMuMotherRecPhi[i] = 0x0;
73 fHMuMotherGenEta[i] = 0x0;
74 fHMuMotherRecEta[i] = 0x0;
79 //________________________________________________________________________
80 AliMuonEffMC::~AliMuonEffMC()
85 //________________________________________________________________________
86 void AliMuonEffMC::UserCreateOutputObjects()
89 // Called once (per slave on PROOF!)
91 fOutputList = new TList();
92 fOutputList->SetOwner(1);
94 fHEventStat = new TH1D("fHEventStat","Event statistics for analysis",18,0,18);
95 fHEventStat->GetXaxis()->SetBinLabel(1,"Event");
96 fHEventStat->GetXaxis()->SetBinLabel(2,"SelectedEvent");
97 fHEventStat->GetXaxis()->SetBinLabel(3,"File");
98 fHEventStat->GetXaxis()->SetBinLabel(4,"fSPHighpt"); //!Global Trigger Single plus High p_T
99 fHEventStat->GetXaxis()->SetBinLabel(5,"fSPAllpt"); //!Global Trigger Single plus All p_T
100 fHEventStat->GetXaxis()->SetBinLabel(6,"fSMLowpt"); //!Global Trigger Single minus Low p_T
101 fHEventStat->GetXaxis()->SetBinLabel(7,"fSMHighpt"); //!Global Trigger Single minus High p_T
102 fHEventStat->GetXaxis()->SetBinLabel(8,"fSMAllpt"); //!Global Trigger Single minus All p_T
103 fHEventStat->GetXaxis()->SetBinLabel(9,"fSULowpt"); //!Global Trigger Single undefined Low p_T
104 fHEventStat->GetXaxis()->SetBinLabel(10,"fSUHighpt"); //!Global Trigger Single undefined High p_T
105 fHEventStat->GetXaxis()->SetBinLabel(11,"fSUAllpt"); //!Global Trigger Single undefined All p_T
106 fHEventStat->GetXaxis()->SetBinLabel(12,"fUSLowpt"); //!Global Trigger UnlikeSign pair Low p_T
107 fHEventStat->GetXaxis()->SetBinLabel(13,"fUSHighpt"); //!Global Trigger UnlikeSign pair High p_T
108 fHEventStat->GetXaxis()->SetBinLabel(14,"fUSAllpt"); //!Global Trigger UnlikeSign pair All p_T
109 fHEventStat->GetXaxis()->SetBinLabel(15,"fLSLowpt"); //!Global Trigger LikeSign pair pair Low p_T
110 fHEventStat->GetXaxis()->SetBinLabel(16,"fLSHighpt"); //!Global Trigger LikeSign pair pair High p_T
111 fHEventStat->GetXaxis()->SetBinLabel(17,"fLSAllpt"); //!Global Trigger LikeSign pair pair All p_T
112 fHEventStat->GetXaxis()->SetBinLabel(18,"fSPLowpt"); //!Global Trigger Single plus Low p_T
113 fOutputList->Add(fHEventStat);
115 fHEvt = new TH2F("fHEvt", "Event-level variables; Zvtx; Cent", 30, -15, 15, 103, -2, 101);
116 fOutputList->Add(fHEvt);
120 Double_t* trackBins[5];
121 const char* trackAxisTitle[5];
124 Double_t etaBins[fNEtaBins+1];
125 for (Int_t i=0; i<=fNEtaBins; i++) { etaBins[i] = (Double_t)(-4.0 + 1.5/fNEtaBins*i); }
126 iTrackBin[0] = fNEtaBins;
127 trackBins[0] = etaBins;
128 trackAxisTitle[0] = "#eta";
131 Double_t pTBins[fNpTBins+1];
132 for (Int_t i=0; i<=fNpTBins; i++) { pTBins[i] = (Double_t)(10.0/fNpTBins*i); }
133 iTrackBin[1] = fNpTBins;
134 trackBins[1] = pTBins;
135 trackAxisTitle[1] = "p_{T} (GeV/c)";
138 Double_t CentBins[fNCentBins+1];
139 for (Int_t i=0; i<=fNCentBins; i++) { CentBins[i] = (Double_t)(100.0/fNCentBins*i); }
140 iTrackBin[2] = fNCentBins;
141 trackBins[2] = CentBins;
142 trackAxisTitle[2] = "Cent";
145 Double_t ZvtxBins[fNZvtxBins+1];
146 for (Int_t i=0; i<=fNZvtxBins; i++) { ZvtxBins[i] = (Double_t)(-10.0 + 20.0/fNZvtxBins*i); }
147 iTrackBin[3] = fNZvtxBins;
148 trackBins[3] = ZvtxBins;
149 trackAxisTitle[3] = "Zvtx";
152 Double_t phiBins[fNPhiBins+1];
153 for (Int_t i=0; i<=fNPhiBins; i++) { phiBins[i] = (Double_t)(TMath::TwoPi()/fNPhiBins * i); }
154 iTrackBin[4] = fNPhiBins;
155 trackBins[4] = phiBins;
156 trackAxisTitle[4] = "#phi";
158 // THn for tracking efficiency
159 fHMuonParGen = new THnF("fHMuonParGen", "", 5, iTrackBin, 0, 0);
160 for (Int_t i=0; i<5; i++)
162 fHMuonParGen->SetBinEdges(i, trackBins[i]);
163 fHMuonParGen->GetAxis(i)->SetTitle(trackAxisTitle[i]);
165 fHMuonParGen->Sumw2();
166 fOutputList->Add(fHMuonParGen);
168 fHMuonDetGen = (THnF*) fHMuonParGen->Clone("fHMuonDetGen");
169 fHMuonDetGen->Sumw2();
170 fOutputList->Add(fHMuonDetGen);
172 fHMuonDetRec = (THnF*) fHMuonParGen->Clone("fHMuonDetRec");
173 fHMuonDetRec->Sumw2();
174 fOutputList->Add(fHMuonDetRec);
176 fHEtcDetRec = (THnF*) fHMuonParGen->Clone("fHEtcDetRec");
177 fHEtcDetRec->Sumw2();
178 fOutputList->Add(fHEtcDetRec);
182 const char* MotherSpecies[4] = {"Pion","Kaon","D", "Etc"};
184 for(Int_t i=0; i<4; i++)
186 fHMuMotherGenPt[i] = new TH2F(Form("fHMuMotherGenPt_%s",MotherSpecies[i]),";p_{T,muon}^{gen} (GeV/c);p_{T,mother}^{Truth} (GeV/c);",500, 0, 50, 500, 0, 50);
187 fOutputList->Add(fHMuMotherGenPt[i]);
189 fHMuMotherRecPt[i] = new TH2F(Form("fHMuMotherRecPt_%s",MotherSpecies[i]),";p_{T,muon}^{rec} (GeV/c);p_{T,mother}^{Truth} (GeV/c);",500, 0, 50, 500, 0, 50);
190 fOutputList->Add(fHMuMotherRecPt[i]);
192 fHMuMotherGenPhi[i] = new TH2F(Form("fHMuMotherGenPhi_%s",MotherSpecies[i]),";#phi_{gen};mother #phi;",100, 0, TMath::TwoPi(), 100, 0, TMath::TwoPi());
193 fOutputList->Add(fHMuMotherGenPhi[i]);
195 fHMuMotherRecPhi[i] = new TH2F(Form("fHMuMotherRecPhi_%s",MotherSpecies[i]),";#phi_{rec};mother #phi;",100, 0, TMath::TwoPi(), 100, 0, TMath::TwoPi());
196 fOutputList->Add(fHMuMotherRecPhi[i]);
198 fHMuMotherGenEta[i] = new TH2F(Form("fHMuMotherGenEta_%s",MotherSpecies[i]),";#eta_{gen};mother #eta;",100, -5., -1., 100, -5., -1.);
199 fOutputList->Add(fHMuMotherGenEta[i]);
201 fHMuMotherRecEta[i] = new TH2F(Form("fHMuMotherRecEta_%s",MotherSpecies[i]),";#eta_{rec};mother #eta;",100, -5., -1., 100, -5., -1.);
202 fOutputList->Add(fHMuMotherRecEta[i]);
204 fHMuDCA[i] = new TH1F(Form("fHMuDCA_%s",MotherSpecies[i]), ";DCA", 100, 0, 50);
205 fOutputList->Add(fHMuDCA[i]);
208 PostData(1, fOutputList);
211 //________________________________________________________________________
212 void AliMuonEffMC::UserExec(Option_t *)
214 // Main loop, Called for each event
215 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
218 fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
223 AliError("Neither fESD nor fAOD available");
227 fHEventStat->Fill(0.5);
232 printf("ERROR: fMC not available\n");
237 const AliESDVertex* vertex = fESD->GetPrimaryVertex();
238 fZVertex = vertex->GetZ();
239 if(fESD->GetCentrality()) fCentrality = fESD->GetCentrality()->GetCentralityPercentile("fCentralityEstimator");
241 // Fill Event histogram
242 fHEvt->Fill(fZVertex, fCentrality);
244 // Centrality, vertex, other event variables...
245 if (!VertexOk(fESD)) {
246 AliInfo(Form("Event REJECTED. z = %.1f", fZVertex));
250 if (fCentrality > 100. || fCentrality < -1.5) {
251 AliInfo(Form("Event REJECTED. fCentrality = %.1f", fCentrality));
255 if(fCentrality < 0) fCentrality = 1.0;
256 fHEventStat->Fill(1.5);
258 ULong64_t trigword=fESD->GetTriggerMask();
260 if (trigword & 0x01) fHEventStat->Fill(17.5);
261 if (trigword & 0x02) fHEventStat->Fill(3.5);
262 if (trigword & 0x04) fHEventStat->Fill(4.5);
263 if (trigword & 0x08) fHEventStat->Fill(5.5);
264 if (trigword & 0x010) fHEventStat->Fill(6.5);
265 if (trigword & 0x020) fHEventStat->Fill(7.5);
266 if (trigword & 0x040) fHEventStat->Fill(8.5);
267 if (trigword & 0x080) fHEventStat->Fill(9.5);
268 if (trigword & 0x100) fHEventStat->Fill(10.5);
269 if (trigword & 0x200) fHEventStat->Fill(11.5);
270 if (trigword & 0x400) fHEventStat->Fill(12.5);
271 if (trigword & 0x800) fHEventStat->Fill(13.5);
272 if (trigword & 0x1000) fHEventStat->Fill(14.5);
273 if (trigword & 0x2000) fHEventStat->Fill(15.5);
274 if (trigword & 0x4000) fHEventStat->Fill(16.5);
278 for (Int_t iTrack = 0; iTrack<fESD->GetNumberOfMuonTracks(); iTrack++)
280 // loop on muon tracks
281 AliESDMuonTrack* muonTrack = fESD->GetMuonTrack(iTrack);
284 if(!IsGoodMUONtrack(*muonTrack)) continue;
285 Double_t fillArrayDetRec[5] = { muonTrack->Eta(), muonTrack->Pt(), fCentrality, fZVertex, muonTrack->Phi() };
286 fHMuonDetRec->Fill(fillArrayDetRec);
288 Int_t label = TMath::Abs(muonTrack->GetLabel());
289 AliMCParticle *McParticle = (AliMCParticle*)fMC->GetTrack(label);
290 if(TMath::Abs(McParticle->PdgCode()) != 13)
292 fHEtcDetRec->Fill(fillArrayDetRec);
295 Double_t fillArrayDetGen[5] = { McParticle->Eta(), McParticle->Pt(), fCentrality, fZVertex, McParticle->Phi() };
296 fHMuonDetGen->Fill(fillArrayDetGen);
300 if(McParticle->GetMother() > 0)
302 AliMCParticle *MotherParticle = (AliMCParticle*)fMC->GetTrack(McParticle->GetMother());
303 Int_t motherlabel = TMath::Abs(MotherParticle->PdgCode());
305 if(motherlabel==411 || motherlabel==413 || motherlabel==421 || motherlabel==423 || motherlabel==431 || motherlabel==433 || motherlabel==10413 || motherlabel==10411 || motherlabel==10423 || motherlabel==10421 || motherlabel==10433 || motherlabel==10431 || motherlabel==20413 || motherlabel==415 || motherlabel==20423 || motherlabel==425 || motherlabel==20433 || motherlabel==435)
307 fHMuMotherGenPt[2]->Fill(McParticle->Pt(), MotherParticle->Pt());
308 fHMuMotherRecPt[2]->Fill(muonTrack->Pt(), MotherParticle->Pt());
309 fHMuMotherGenPhi[2]->Fill(McParticle->Phi(), MotherParticle->Phi());
310 fHMuMotherRecPhi[2]->Fill(muonTrack->Phi(), MotherParticle->Phi());
311 fHMuMotherGenEta[2]->Fill(McParticle->Eta(), MotherParticle->Eta());
312 fHMuMotherRecEta[2]->Fill(muonTrack->Eta(), MotherParticle->Eta());
313 fHMuDCA[2]->Fill(muonTrack->GetDCA());
315 else if(motherlabel==211)
317 fHMuMotherGenPt[0]->Fill(McParticle->Pt(), MotherParticle->Pt());
318 fHMuMotherRecPt[0]->Fill(muonTrack->Pt(), MotherParticle->Pt());
319 fHMuMotherGenPhi[0]->Fill(McParticle->Phi(), MotherParticle->Phi());
320 fHMuMotherRecPhi[0]->Fill(muonTrack->Phi(), MotherParticle->Phi());
321 fHMuMotherGenEta[0]->Fill(McParticle->Eta(), MotherParticle->Eta());
322 fHMuMotherRecEta[0]->Fill(muonTrack->Eta(), MotherParticle->Eta());
323 fHMuDCA[0]->Fill(muonTrack->GetDCA());
325 else if(motherlabel==321)
327 fHMuMotherGenPt[1]->Fill(McParticle->Pt(), MotherParticle->Pt());
328 fHMuMotherRecPt[1]->Fill(muonTrack->Pt(), MotherParticle->Pt());
329 fHMuMotherGenPhi[1]->Fill(McParticle->Phi(), MotherParticle->Phi());
330 fHMuMotherRecPhi[1]->Fill(muonTrack->Phi(), MotherParticle->Phi());
331 fHMuMotherGenEta[1]->Fill(McParticle->Eta(), MotherParticle->Eta());
332 fHMuMotherRecEta[1]->Fill(muonTrack->Eta(), MotherParticle->Eta());
333 fHMuDCA[1]->Fill(muonTrack->GetDCA());
337 fHMuMotherGenPt[3]->Fill(McParticle->Pt(), MotherParticle->Pt());
338 fHMuMotherRecPt[3]->Fill(muonTrack->Pt(), MotherParticle->Pt());
339 fHMuMotherGenPhi[3]->Fill(McParticle->Phi(), MotherParticle->Phi());
340 fHMuMotherRecPhi[3]->Fill(muonTrack->Phi(), MotherParticle->Phi());
341 fHMuMotherGenEta[3]->Fill(McParticle->Eta(), MotherParticle->Eta());
342 fHMuMotherRecEta[3]->Fill(muonTrack->Eta(), MotherParticle->Eta());
343 fHMuDCA[3]->Fill(muonTrack->GetDCA());
346 } // (mother hadron) : (daughter muon) QA
350 for (Int_t ipart=0; ipart<fMC->GetNumberOfTracks(); ipart++)
352 AliMCParticle *McParticle = (AliMCParticle*)fMC->GetTrack(ipart);
353 if(TMath::Abs(McParticle->PdgCode())==13)
355 Double_t fillArrayParGen[5] = { McParticle->Eta(), McParticle->Pt(), fCentrality, fZVertex, McParticle->Phi() };
356 fHMuonParGen->Fill(fillArrayParGen);
360 PostData(1, fOutputList);
364 //________________________________________________________________________
365 void AliMuonEffMC::Terminate(Option_t *)
367 // Draw result to the screen
368 // Called once at the end of the query
370 fOutputList = dynamic_cast<TList*> (GetOutputData(1));
372 AliError("Output list not available");
377 //________________________________________________________________________
378 Bool_t AliMuonEffMC::VertexOk(TObject* obj) const
380 // Modified from AliAnalyseLeadingTrackUE::VertexSelection()
382 Int_t nContributors = 0;
383 Double_t zVertex = 999;
386 if (obj->InheritsFrom("AliESDEvent")) {
387 AliESDEvent* esdevt = (AliESDEvent*) obj;
388 const AliESDVertex* vtx = esdevt->GetPrimaryVertex();
391 nContributors = vtx->GetNContributors();
392 zVertex = vtx->GetZ();
393 name = vtx->GetName();
395 else if (obj->InheritsFrom("AliAODEvent")) {
396 AliAODEvent* aodevt = (AliAODEvent*) obj;
397 if (aodevt->GetNumberOfVertices() < 1)
399 const AliAODVertex* vtx = aodevt->GetPrimaryVertex();
400 nContributors = vtx->GetNContributors();
401 zVertex = vtx->GetZ();
402 name = vtx->GetName();
405 // Reject if TPC-only vertex
406 if (name.CompareTo("TPCVertex")==0)
409 // Check # contributors and range...
410 if( nContributors < 1 || TMath::Abs(zVertex) > 10 ) {
418 //________________________________________________________________________
419 Bool_t AliMuonEffMC::IsGoodMUONtrack(AliESDMuonTrack &track)
421 // Applying track cuts for MUON tracks
422 if(!track.ContainTrackerData()) return kFALSE;
423 if(!track.ContainTriggerData()) return kFALSE;
425 Double_t thetaTrackAbsEnd = TMath::ATan(track.GetRAtAbsorberEnd()/505.) * TMath::RadToDeg();
426 Double_t eta = track.Eta();
428 // Theta cut at absorber end
429 if(thetaTrackAbsEnd <= 2. || thetaTrackAbsEnd >= 10.) return kFALSE;
431 if(eta <= -4. || eta >= -2.5) return kFALSE;
432 if(track.GetMatchTrigger() <= 0) return kFALSE;