1 /**************************************************************************
2 * Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 /////////////////////////////////////////////////////////////
20 // class used to extract and store info at event level
22 // Author: X-M. Zhang, zhang@clermont.in2p3.fr
23 // zhangxm@iopp.ccnu.edu.cn
24 /////////////////////////////////////////////////////////////
31 #include "AliInputEventHandler.h"
32 #include "AliAODMCHeader.h"
33 #include "AliVEvent.h"
34 #include "AliAODEvent.h"
35 #include "AliESDEvent.h"
36 #include "AliVVertex.h"
37 #include "AliCentrality.h"
38 #include "AliEventplane.h"
39 #include "AliAnalysisUtils.h"
40 #include "AliMultiplicity.h"
41 #include "AliMuonTrackCuts.h"
42 #include "AliMuonInfoStoreRD.h"
43 #include "AliMuonInfoStoreMC.h"
44 #include "AliDimuInfoStoreRD.h"
45 #include "AliDimuInfoStoreMC.h"
46 #include "AliMuonsHFHeader.h"
48 #include "AliMCEvent.h"
49 #include "AliGenEventHeader.h"
50 #include "AliGenDPMjetEventHeader.h"
52 ClassImp(AliMuonsHFHeader)
54 const TString AliMuonsHFHeader::fgkStdBranchName("MuEvsH");
55 Double_t AliMuonsHFHeader::fgCuts[5] = { -999999., 999999., 999999., -999999., 999999. };
57 //_____________________________________________________________________________
58 AliMuonsHFHeader::AliMuonsHFHeader() :
62 fSelMask(AliVEvent::kAny),
69 fIsEvtInChunk(kFALSE),
70 fIsVtxSeled2013pA(kFALSE),
83 // default constructor
85 for (Int_t i=3; i--;) fVtx[i] = 0.;
86 for (Int_t i=3; i--;) fVMC[i] = 0.;
89 //_____________________________________________________________________________
90 AliMuonsHFHeader::AliMuonsHFHeader(const AliMuonsHFHeader &src) :
92 fAnaMode(src.fAnaMode),
94 fSelMask(src.fSelMask),
97 fVtxContrsN(src.fVtxContrsN),
98 fFiredTriggerClass(src.fFiredTriggerClass),
100 fEventPlane(src.fEventPlane),
101 fIsEvtInChunk(src.fIsEvtInChunk),
102 fIsVtxSeled2013pA(src.fIsVtxSeled2013pA),
103 fNumOfTrklets(src.fNumOfTrklets),
104 fTrgInpts(src.fTrgInpts),
105 fImpParam(src.fImpParam),
106 fCentralityV0M(src.fCentralityV0M),
107 fCentralityV0A(src.fCentralityV0A),
108 fCentralityV0C(src.fCentralityV0C),
109 fCentralityCL1(src.fCentralityCL1),
110 fCentralityZNA(src.fCentralityZNA),
111 fCentralityZNC(src.fCentralityZNC),
117 for (Int_t i=3; i--;) fVtx[i] = src.fVtx[i];
118 for (Int_t i=3; i--;) fVMC[i] = src.fVMC[i];
121 //_____________________________________________________________________________
122 AliMuonsHFHeader& AliMuonsHFHeader::operator=(const AliMuonsHFHeader &src)
125 // assignment constructor
128 if(&src==this) return *this;
130 fAnaMode = src.fAnaMode;
132 fSelMask = src.fSelMask;
135 fVtxContrsN = src.fVtxContrsN;
136 fFiredTriggerClass = src.fFiredTriggerClass;
137 fCentQA = src.fCentQA;
138 fEventPlane = src.fEventPlane;
139 fIsEvtInChunk = src.fIsEvtInChunk;
140 fIsVtxSeled2013pA = src.fIsVtxSeled2013pA;
141 fNumOfTrklets = src.fNumOfTrklets;
142 fTrgInpts = src.fTrgInpts;
143 fImpParam = src.fImpParam;
144 fCentralityV0M = src.fCentralityV0M;
145 fCentralityV0A = src.fCentralityV0A;
146 fCentralityV0C = src.fCentralityV0C;
147 fCentralityCL1 = src.fCentralityCL1;
148 fCentralityZNA = src.fCentralityZNA;
149 fCentralityZNC = src.fCentralityZNC;
150 fPUMask = src.fPUMask;
151 for (Int_t i=3; i--;) fVtx[i] = src.fVtx[i];
152 for (Int_t i=3; i--;) fVMC[i] = src.fVMC[i];
157 //_____________________________________________________________________________
158 AliMuonsHFHeader::~AliMuonsHFHeader()
161 // default destructor
165 //_____________________________________________________________________________
166 void AliMuonsHFHeader::SetEventInfo(AliInputEventHandler* const handler)
168 // fill info at event level
170 AliVEvent *event = handler->GetEvent();
171 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(event);
172 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event);
174 fSelMask = handler->IsEventSelected();
175 if (aod) { fFiredTriggerClass = aod->GetFiredTriggerClasses(); fTrgInpts = aod->GetHeader()->GetL0TriggerInputs(); }
176 if (esd) { fFiredTriggerClass = esd->GetFiredTriggerClasses(); fTrgInpts = esd->GetHeader()->GetL0TriggerInputs(); }
177 fIsMB = fSelMask & AliVEvent::kMB;
178 fIsMU = fSelMask & AliVEvent::kMUON;
180 const AliVVertex *vertex = event->GetPrimaryVertex();
181 vertex->GetXYZ(fVtx);
182 fVtxContrsN = vertex->GetNContributors();
184 AliMCEvent *mcEvent = handler->MCEvent();
185 AliGenEventHeader *genHeader = mcEvent->GenEventHeader();
186 if (!genHeader) { AliError("Header not found. Nothing done!"); return; }
187 AliGenDPMjetEventHeader *dpmHeader = dynamic_cast<AliGenDPMjetEventHeader*>(genHeader);
188 if (dpmHeader) fImpParam = dpmHeader->ImpactParameter();
190 if (esd) mcEvent->GetPrimaryVertex()->GetXYZ(fVMC);
191 if (aod) ((AliAODMCHeader*)aod->FindListObject(AliAODMCHeader::StdBranchName()))->GetVertex(fVMC);
192 } this->SetTitle(vertex->GetTitle());
193 //(aod && !aod->GetTracklets()) ? event->IsPileupFromSPD(3,0.8,3.,2.,5.) : event->IsPileupFromSPDInMultBins();
195 AliAnalysisUtils *anaUtils = new AliAnalysisUtils();
197 fIsEvtInChunk = anaUtils->IsFirstEventInChunk(esd);
198 fIsVtxSeled2013pA = anaUtils->IsVertexSelected2013pA(esd);
199 fNumOfTrklets = esd->GetMultiplicity()->GetNumberOfTracklets();
202 fIsEvtInChunk = anaUtils->IsFirstEventInChunk(aod);
203 fIsVtxSeled2013pA = anaUtils->IsVertexSelected2013pA(aod);
204 fNumOfTrklets = aod->GetTracklets()->GetNumberOfTracklets();
207 fPUMask = this->CollectPUMask(event);
209 AliEventplane *evnP = event->GetEventplane();
210 if (evnP) fEventPlane = evnP->GetEventplane("Q");
211 //if (evnP) fEventPlane = evnP->GetEventplane("V0A");
213 AliCentrality *cent = event->GetCentrality(); if (cent) {
214 fCentQA = cent->GetQuality();
215 fCentralityV0M = cent->GetCentralityPercentileUnchecked("V0M");
216 fCentralityV0A = cent->GetCentralityPercentileUnchecked("V0A");
217 fCentralityV0C = cent->GetCentralityPercentileUnchecked("V0C");
218 fCentralityCL1 = cent->GetCentralityPercentileUnchecked("CL1");
219 fCentralityZNA = cent->GetCentralityPercentileUnchecked("ZNA");
220 fCentralityZNC = cent->GetCentralityPercentileUnchecked("ZNC");
224 delete anaUtils; anaUtils = 0;
229 //_____________________________________________________________________________
230 Bool_t AliMuonsHFHeader::IsSelected()
232 // select event according to the event selection cuts
233 if (this->VtxContrsN()<fgCuts[0]) return kFALSE;
234 if (TMath::Abs(this->Vz())>fgCuts[1]) return kFALSE;
235 if (this->Vt()>fgCuts[2]) return kFALSE;
237 // centrality selection
238 Float_t centrV0M = this->Centrality(kV0M);
239 Float_t centrV0A = this->Centrality(kV0A);
240 Float_t centrV0C = this->Centrality(kV0C);
241 Float_t centrCL1 = this->Centrality(kCL1);
242 Float_t centrZNA = this->Centrality(kZNA);
243 Float_t centrZNC = this->Centrality(kZNC);
245 if (centrV0M<fgCuts[3] || centrV0M>fgCuts[4]) return kFALSE;
246 if (centrV0A<fgCuts[3] || centrV0A>fgCuts[4]) return kFALSE;
247 if (centrV0C<fgCuts[3] || centrV0C>fgCuts[4]) return kFALSE;
248 if (centrCL1<fgCuts[3] || centrCL1>fgCuts[4]) return kFALSE;
249 if (centrZNA<fgCuts[3] || centrZNA>fgCuts[4]) return kFALSE;
250 if (centrZNC<fgCuts[3] || centrZNC>fgCuts[4]) return kFALSE;
255 //_____________________________________________________________________________
256 void AliMuonsHFHeader::CreateHistograms(TList *list)
258 // create output histos of muon analysis according to the analysis mode & MC flag
261 this->CreateHistosEvnH(list);
263 TString sName[7] = { "Unidentified", "Hadron", "SecondaryMu", "PrimaryMu", "CharmMu", "BottomMu", "" };
264 for (Int_t i=7; i--;) this->CreateHistosMuon(list, sName[i]);
267 TString sName[7] = { "Uncorr", "Resonance", "DDsame", "DDdiff", "BBsame", "BBdiff", "" };
268 for (Int_t i=7; i--;) this->CreateHistosDimu(list, sName[i]);
273 this->CreateHistosEvnH(list,"MB"); this->CreateHistosEvnH(list,"MU");
274 if (fAnaMode!=2) { this->CreateHistosMuon(list,"MB"); this->CreateHistosMuon(list,"MU"); }
275 if (fAnaMode!=1) { this->CreateHistosDimu(list,"MB"); this->CreateHistosDimu(list,"MU"); }
280 //_____________________________________________________________________________
281 void AliMuonsHFHeader::CreateHistosEvnH(TList *list, TString sName)
283 // create histograms at event level
285 if (!list) list = new TList();
287 Bool_t oldStatus = TH1::AddDirectoryStatus();
288 TH1::AddDirectory(kFALSE);
291 TString tName[nhs] = { "Vz", "Vt", "VtxNcontr" };
292 Int_t nbins[nhs] = { 800 , 40 , 202 };
293 Double_t xlow[nhs] = { -40., 0., -2.5 };
294 Double_t xup[nhs] = { 40., 4., 199.5 };
297 for (Int_t i=0; i<nhs; i++) {
298 char *hName = Form("h%s_%s", sName.Data(), tName[i].Data());
299 histo = new TH1D(hName, hName, nbins[i], xlow[i], xup[i]);
300 histo->Sumw2(); list->Add(histo); histo = 0;
303 TH1::AddDirectory(oldStatus);
308 //_____________________________________________________________________________
309 void AliMuonsHFHeader::CreateHistosMuon(TList *list, TString sName)
311 // create histograms for single muon
313 if (!list) list = new TList();
315 Bool_t oldStatus = TH1::AddDirectoryStatus();
316 TH1::AddDirectory(kFALSE);
319 TString tName[nhs] = { "P", "Pt", "Eta", "DCA", "TrM", "Charge", "Rabs" };
320 Int_t nbins[nhs] = { 1500 , 300 , 15 , 1000 , 4 , 3 , 48 };
321 Double_t xlow[nhs] = { 0., 0., -4.0, 0., -0.5, -1.5, 17.6 };
322 Double_t xup[nhs] = { 150., 30., -2.5, 500., 3.5, 1.5, 80.0 };
325 for (Int_t i=0; i<nhs; i++) {
326 char *hName = Form("h%s_%s", sName.Data(), tName[i].Data());
327 histo = new TH1D(hName, hName, nbins[i], xlow[i], xup[i]);
328 histo->Sumw2(); list->Add(histo); histo = 0;
331 TH1::AddDirectory(oldStatus);
336 //_____________________________________________________________________________
337 void AliMuonsHFHeader::CreateHistosDimu(TList *list, TString sName)
339 // create histograms for dimuon
341 if (!list) list = new TList();
343 Bool_t oldStatus = TH1::AddDirectoryStatus();
344 TH1::AddDirectory(kFALSE);
348 TString tName[nhs] = { "P", "Pt", "InvM" };
349 Int_t nbins[nhs] = { 1500 , 300 , 300 };
350 Double_t xlow[nhs] = { 0., 0., 0. };
351 Double_t xup[nhs] = { 150., 30., 30. };
352 TString dimuName[3] = { "DimuNN", "DimuNP", "DimuPP" };
353 for (Int_t i=0; i<3; i++) {
354 for (Int_t j=0; j<nhs; j++) {
355 char *hName = Form("h%s_%s_%s", sName.Data(), dimuName[i].Data(), tName[j].Data());
356 histo = new TH1D(hName, hName, nbins[j], xlow[j], xup[j]);
357 histo->Sumw2(); list->Add(histo); histo = 0;
361 TH1::AddDirectory(oldStatus);
366 //_____________________________________________________________________________
367 void AliMuonsHFHeader::FillHistosEvnH(TList *list)
369 // fill histograms at event level according to event selection cuts
372 if (!this->IsSelected()) return;
375 TString tName[nhs] = { "Vz", "Vt", "VtxNcontr" };
376 Double_t dist[nhs] = { this->Vz(), this->Vt(), static_cast<Double_t>(this->VtxContrsN()) };
377 if (fIsMC && (fSelMask & AliVEvent::kAny)) {
378 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h_%s",tName[i].Data())))->Fill(dist[i]);
380 if (fIsMB && (fSelMask & AliVEvent::kMB)) { for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s","MB",tName[i].Data())))->Fill(dist[i]); }
381 if (fIsMU && (fSelMask & AliVEvent::kMUON)) { for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s","MU",tName[i].Data())))->Fill(dist[i]); }
387 //_____________________________________________________________________________
388 void AliMuonsHFHeader::FillHistosMuon(TList *list, AliMuonInfoStoreRD* const infoStore, Int_t s)
390 // fill histograms for single muon according to event & muon track selection cuts
393 if (!this->IsSelected()) return;
394 if (!infoStore->IsSelected(0)) return;
397 TString tName[nhs] = { "P", "Pt", "Eta", "DCA", "TrM", "Charge", "Rabs" };
398 Double_t dist[nhs] = { infoStore->MomentumAtVtx().Mag(),
399 infoStore->MomentumAtVtx().Pt(),
400 infoStore->MomentumAtVtx().Eta(),
402 static_cast<Double_t>(infoStore->MatchTrigger()),
403 static_cast<Double_t>(infoStore->Charge()),
404 infoStore->RabsEnd() };
406 if (fIsMC && (fSelMask & AliVEvent::kAny)) {
407 TString sName[7] = { "BottomMu", "CharmMu", "PrimaryMu", "SecondaryMu", "Hadron", "Unidentified", "" };
408 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s",sName[6].Data(),tName[i].Data())))->Fill(dist[i]);
409 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s",sName[s].Data(),tName[i].Data())))->Fill(dist[i]);
411 if (fIsMB && (fSelMask & AliVEvent::kMB)) { for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s","MB",tName[i].Data())))->Fill(dist[i]); }
412 if (fIsMU && (fSelMask & AliVEvent::kMUON)) { for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s","MU",tName[i].Data())))->Fill(dist[i]); }
418 //_____________________________________________________________________________
419 void AliMuonsHFHeader::FillHistosDimu(TList *list, AliDimuInfoStoreRD* const infoStore, Int_t s)
421 // fill histograms for dimuon according to evnet & dimuon candidates selection cuts
424 if (!this->IsSelected()) return;
425 if (!infoStore->IsSelected(0)) return;
427 TString dimuName = "DimuNN";
428 if (infoStore->Charge()==0) dimuName = "DimuNP";
429 else if (infoStore->Charge()>0) dimuName = "DimuPP";
432 TString tName[nhs] = { "P", "Pt", "InvM" };
433 Double_t dist[nhs] = { infoStore->Momentum().Mag(),
434 infoStore->Momentum().Pt(),
437 if (fIsMC && (fSelMask & AliVEvent::kAny)) {
438 TString sName[7] = { "BBdiff", "BBsame", "DDdiff", "DDsame", "Resonance", "Uncorr", "" };
439 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s_%s",sName[6].Data(),dimuName.Data(),tName[i].Data())))->Fill(dist[i]);
440 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s_%s",sName[s].Data(),dimuName.Data(),tName[i].Data())))->Fill(dist[i]);
442 if (fIsMB && (fSelMask & AliVEvent::kMB)) {
443 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s_%s","MB",dimuName.Data(),tName[i].Data())))->Fill(dist[i]);
445 if (fIsMU && (fSelMask & AliVEvent::kMUON)) {
446 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s_%s","MU",dimuName.Data(),tName[i].Data())))->Fill(dist[i]);
453 //_____________________________________________________________________________
454 Float_t AliMuonsHFHeader::Centrality(Int_t centrality)
456 // obtain centrality via selected estimators
458 if (centrality==kV0M) return fCentralityV0M;
459 else if (centrality==kV0A) return fCentralityV0A;
460 else if (centrality==kV0C) return fCentralityV0C;
461 else if (centrality==kCL1) return fCentralityCL1;
462 else if (centrality==kZNA) return fCentralityZNA;
463 else if (centrality==kZNC) return fCentralityZNC;
467 //_____________________________________________________________________________
468 UInt_t AliMuonsHFHeader::CollectPUMask(AliVEvent *event)
470 // collect the mask for different combination of the parameters;
471 // used to tag pile-up events (IsPileupFromSPD, no IsPileupFromSPDInMultBins at the moment)
473 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(event);
474 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event);
476 UInt_t collectMask = 0;
477 Bool_t ISc1z1 = kFALSE, ISc1z2 = kFALSE, ISc1z3 = kFALSE, ISc1z4 = kFALSE,
478 ISc2z1 = kFALSE, ISc2z2 = kFALSE, ISc2z3 = kFALSE, ISc2z4 = kFALSE,
479 ISc3z1 = kFALSE, ISc3z2 = kFALSE, ISc3z3 = kFALSE, ISc3z4 = kFALSE,
480 ISc4z1 = kFALSE, ISc4z2 = kFALSE, ISc4z3 = kFALSE, ISc4z4 = kFALSE;
482 ISc1z1 = (aod) ? aod->IsPileupFromSPD(3,0.5,3.,2.,5.) : esd->IsPileupFromSPD(3,0.5,3.,2.,5.);
483 ISc1z2 = (aod) ? aod->IsPileupFromSPD(3,0.6,3.,2.,5.) : esd->IsPileupFromSPD(3,0.6,3.,2.,5.);
484 ISc1z3 = (aod) ? aod->IsPileupFromSPD(3,0.8,3.,2.,5.) : esd->IsPileupFromSPD(3,0.8,3.,2.,5.);
485 ISc1z4 = (aod) ? aod->IsPileupFromSPD(3,0.9,3.,2.,5.) : esd->IsPileupFromSPD(3,0.9,3.,2.,5.);
486 ISc2z1 = (aod) ? aod->IsPileupFromSPD(4,0.5,3.,2.,5.) : esd->IsPileupFromSPD(4,0.5,3.,2.,5.);
487 ISc2z2 = (aod) ? aod->IsPileupFromSPD(4,0.6,3.,2.,5.) : esd->IsPileupFromSPD(4,0.6,3.,2.,5.);
488 ISc2z3 = (aod) ? aod->IsPileupFromSPD(4,0.8,3.,2.,5.) : esd->IsPileupFromSPD(4,0.8,3.,2.,5.);
489 ISc2z4 = (aod) ? aod->IsPileupFromSPD(4,0.9,3.,2.,5.) : esd->IsPileupFromSPD(4,0.9,3.,2.,5.);
490 ISc3z1 = (aod) ? aod->IsPileupFromSPD(5,0.5,3.,2.,5.) : esd->IsPileupFromSPD(5,0.5,3.,2.,5.);
491 ISc3z2 = (aod) ? aod->IsPileupFromSPD(5,0.6,3.,2.,5.) : esd->IsPileupFromSPD(5,0.6,3.,2.,5.);
492 ISc3z3 = (aod) ? aod->IsPileupFromSPD(5,0.8,3.,2.,5.) : esd->IsPileupFromSPD(5,0.8,3.,2.,5.);
493 ISc3z4 = (aod) ? aod->IsPileupFromSPD(5,0.9,3.,2.,5.) : esd->IsPileupFromSPD(5,0.9,3.,2.,5.);
494 ISc4z1 = (aod) ? aod->IsPileupFromSPD(6,0.5,3.,2.,5.) : esd->IsPileupFromSPD(6,0.5,3.,2.,5.);
495 ISc4z2 = (aod) ? aod->IsPileupFromSPD(6,0.6,3.,2.,5.) : esd->IsPileupFromSPD(6,0.6,3.,2.,5.);
496 ISc4z3 = (aod) ? aod->IsPileupFromSPD(6,0.8,3.,2.,5.) : esd->IsPileupFromSPD(6,0.8,3.,2.,5.);
497 ISc4z4 = (aod) ? aod->IsPileupFromSPD(6,0.9,3.,2.,5.) : esd->IsPileupFromSPD(6,0.9,3.,2.,5.);
498 if (ISc1z1) collectMask |= kPUc1z1;
499 if (ISc1z2) collectMask |= kPUc1z2;
500 if (ISc1z3) collectMask |= kPUc1z3;
501 if (ISc1z4) collectMask |= kPUc1z4;
502 if (ISc2z1) collectMask |= kPUc2z1;
503 if (ISc2z2) collectMask |= kPUc2z2;
504 if (ISc2z3) collectMask |= kPUc2z3;
505 if (ISc2z4) collectMask |= kPUc2z4;
506 if (ISc3z1) collectMask |= kPUc3z1;
507 if (ISc3z2) collectMask |= kPUc3z2;
508 if (ISc3z3) collectMask |= kPUc3z3;
509 if (ISc3z4) collectMask |= kPUc3z4;
510 if (ISc4z1) collectMask |= kPUc4z1;
511 if (ISc4z2) collectMask |= kPUc4z2;
512 if (ISc4z3) collectMask |= kPUc4z3;
513 if (ISc4z4) collectMask |= kPUc4z4;