]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/muon/AliMuonsHFHeader.cxx
Fix Coverity 24835
[u/mrichter/AliRoot.git] / PWG / muon / AliMuonsHFHeader.cxx
CommitLineData
fd1d0cb9 1/**************************************************************************
2 * Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
27de2dfb 16/* $Id$ */
17
fd1d0cb9 18/////////////////////////////////////////////////////////////
19//
20// class used to extract and store info at event level
21//
22// Author: X-M. Zhang, zhang@clermont.in2p3.fr
23// zhangxm@iopp.ccnu.edu.cn
24/////////////////////////////////////////////////////////////
25
4292b3b6 26#include <TMath.h>
fd1d0cb9 27#include <TH1.h>
6709e09d 28#include <TH1D.h>
fd1d0cb9 29#include <TList.h>
1195bb6f 30
9bbc42ca 31#include "AliInputEventHandler.h"
32#include "AliAODMCHeader.h"
9bcac085 33#include "AliVEvent.h"
9bbc42ca 34#include "AliAODEvent.h"
35#include "AliESDEvent.h"
36#include "AliVVertex.h"
37#include "AliCentrality.h"
38#include "AliEventplane.h"
39
40#include "AliMuonTrackCuts.h"
fd1d0cb9 41#include "AliMuonInfoStoreRD.h"
42#include "AliMuonInfoStoreMC.h"
43#include "AliDimuInfoStoreRD.h"
44#include "AliDimuInfoStoreMC.h"
4292b3b6 45#include "AliMuonsHFHeader.h"
46
47ClassImp(AliMuonsHFHeader)
48
fd1d0cb9 49const TString AliMuonsHFHeader::fgkStdBranchName("MuEvsH");
1195bb6f 50Int_t AliMuonsHFHeader::fgAnaMode = 0;
51Bool_t AliMuonsHFHeader::fgIsMC = kFALSE;
9bcac085 52Double_t AliMuonsHFHeader::fgCuts[5] = { -999999., 999999., 999999., -999999., 999999. };
fd1d0cb9 53
4292b3b6 54//_____________________________________________________________________________
55AliMuonsHFHeader::AliMuonsHFHeader() :
56TNamed(),
9bcac085 57fSelMask(AliVEvent::kAny),
b46f66fc 58fIsMB(kFALSE),
59fIsMU(kFALSE),
9bbc42ca 60fIsPileupSPD(kFALSE),
1195bb6f 61fVtxContrsN(0),
62fFiredTriggerClass(),
9bbc42ca 63fCentrality(-1.),
64fCentQA(-1),
65fEventPlane(0.)
4292b3b6 66{
67 //
68 // default constructor
69 //
fd1d0cb9 70 for (Int_t i=3; i--;) fVtx[i] = 0.;
9bbc42ca 71 for (Int_t i=3; i--;) fVMC[i] = 0.;
fd1d0cb9 72}
73
74//_____________________________________________________________________________
75AliMuonsHFHeader::AliMuonsHFHeader(const AliMuonsHFHeader &src) :
76TNamed(),
9bcac085 77fSelMask(src.fSelMask),
b46f66fc 78fIsMB(src.fIsMB),
79fIsMU(src.fIsMU),
9bbc42ca 80fIsPileupSPD(src.fIsPileupSPD),
1195bb6f 81fVtxContrsN(src.fVtxContrsN),
82fFiredTriggerClass(src.fFiredTriggerClass),
9bbc42ca 83fCentrality(src.fCentrality),
84fCentQA(src.fCentQA),
85fEventPlane(src.fEventPlane)
fd1d0cb9 86{
87 //
88 // copy constructor
89 //
1195bb6f 90 for (Int_t i=3; i--;) fVtx[i] = src.fVtx[i];
9bbc42ca 91 for (Int_t i=3; i--;) fVMC[i] = src.fVMC[i];
fd1d0cb9 92}
93
94//_____________________________________________________________________________
95AliMuonsHFHeader& AliMuonsHFHeader::operator=(const AliMuonsHFHeader &src)
96{
97 //
98 // assignment constructor
99 //
1195bb6f 100
4f25a75b 101 if(&src==this) return *this;
102
9bcac085 103 fSelMask = src.fSelMask;
b46f66fc 104 fIsMB = src.fIsMB;
105 fIsMU = src.fIsMU;
9bbc42ca 106 fIsPileupSPD = src.fIsPileupSPD;
1195bb6f 107 fVtxContrsN = src.fVtxContrsN;
108 fFiredTriggerClass = src.fFiredTriggerClass;
109 fCentrality = src.fCentrality;
9bbc42ca 110 fCentQA = src.fCentQA;
111 fEventPlane = src.fEventPlane;
1195bb6f 112 for (Int_t i=3; i--;) fVtx[i] = src.fVtx[i];
9bbc42ca 113 for (Int_t i=3; i--;) fVMC[i] = src.fVMC[i];
fd1d0cb9 114
115 return *this;
4292b3b6 116}
117
118//_____________________________________________________________________________
119AliMuonsHFHeader::~AliMuonsHFHeader()
120{
121 //
122 // default destructor
123 //
124}
125
126//_____________________________________________________________________________
9bbc42ca 127void AliMuonsHFHeader::SetEventInfo(AliInputEventHandler* const handler, AliMCEvent* const eventMC)
4292b3b6 128{
9bbc42ca 129 // fill info at event level
130
131 AliVEvent *event = handler->GetEvent();
132 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(event);
133 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event);
fd1d0cb9 134
9bbc42ca 135 fSelMask = handler->IsEventSelected();
136 if (aod) fFiredTriggerClass = aod->GetFiredTriggerClasses();
137 if (esd) fFiredTriggerClass = esd->GetFiredTriggerClasses();
138 fIsMB = fSelMask & AliVEvent::kMB;
139 fIsMU = fSelMask & AliVEvent::kMUON;
140
141 const AliVVertex *vertex = event->GetPrimaryVertex();
fd1d0cb9 142 vertex->GetXYZ(fVtx);
1195bb6f 143 fVtxContrsN = vertex->GetNContributors();
9bbc42ca 144 if (fgIsMC) {
145 if (esd) eventMC->GetPrimaryVertex()->GetXYZ(fVMC);
146 if (aod) ((AliAODMCHeader*)aod->FindListObject(AliAODMCHeader::StdBranchName()))->GetVertex(fVMC);
147 } this->SetTitle(vertex->GetTitle());
148 fIsPileupSPD = (aod && !aod->GetTracklets()) ? event->IsPileupFromSPD(3,0.8,3.,2.,5.) : event->IsPileupFromSPDInMultBins();
149
150 AliCentrality *cent = event->GetCentrality();
151 if (cent) {
152 fCentrality = cent->GetCentralityPercentileUnchecked("V0M");
153 fCentQA = cent->GetQuality();
154 }
155
156 AliEventplane *evnP = event->GetEventplane();
157 if (evnP) fEventPlane = evnP->GetEventplane("Q");
158//if (evnP) fEventPlane = evnP->GetEventplane("V0A");
fd1d0cb9 159
b46f66fc 160 return;
161}
162
fd1d0cb9 163//_____________________________________________________________________________
6709e09d 164Bool_t AliMuonsHFHeader::IsSelected()
fd1d0cb9 165{
1195bb6f 166 // select event according to the event selection cuts
9bcac085 167 if (this->VtxContrsN()<fgCuts[0]) return kFALSE;
168 if (TMath::Abs(this->Vz())>fgCuts[1]) return kFALSE;
169 if (this->Vt()>fgCuts[2]) return kFALSE;
170
171 // centrality selection
172 Float_t centr = this->Centrality();
173 if (centr<fgCuts[3] || centr>fgCuts[4]) return kFALSE;
1195bb6f 174 return kTRUE;
fd1d0cb9 175}
176
177//_____________________________________________________________________________
1195bb6f 178void AliMuonsHFHeader::CreateHistograms(TList *list)
fd1d0cb9 179{
1195bb6f 180 // create output histos of muon analysis according to the analysis mode & MC flag
fd1d0cb9 181
b46f66fc 182 if (fgIsMC) {
183 this->CreateHistosEvnH(list);
184 if (fgAnaMode!=2) {
185 TString sName[7] = { "Unidentified", "Hadron", "SecondaryMu", "PrimaryMu", "CharmMu", "BottomMu", "" };
186 for (Int_t i=7; i--;) this->CreateHistosMuon(list, sName[i]);
1195bb6f 187 }
b46f66fc 188 if (fgAnaMode!=1) {
189 TString sName[7] = { "Uncorr", "Resonance", "DDsame", "DDdiff", "BBsame", "BBdiff", "" };
190 for (Int_t i=7; i--;) this->CreateHistosDimu(list, sName[i]);
1195bb6f 191 }
b46f66fc 192 return;
fd1d0cb9 193 }
1195bb6f 194
9bcac085 195 this->CreateHistosEvnH(list,"MB"); this->CreateHistosEvnH(list,"MU");
196 if (fgAnaMode!=2) { this->CreateHistosMuon(list,"MB"); this->CreateHistosMuon(list,"MU"); }
197 if (fgAnaMode!=1) { this->CreateHistosDimu(list,"MB"); this->CreateHistosDimu(list,"MU"); }
fd1d0cb9 198 return;
199}
200
201//_____________________________________________________________________________
b46f66fc 202void AliMuonsHFHeader::CreateHistosEvnH(TList *list, TString sName)
fd1d0cb9 203{
204 // create histograms at event level
205
206 if (!list) list = new TList();
207 list->SetOwner();
208 Bool_t oldStatus = TH1::AddDirectoryStatus();
209 TH1::AddDirectory(kFALSE);
210
9bcac085 211 const Int_t nhs = 3;
212 TString tName[nhs] = { "Vz", "Vt", "VtxNcontr" };
213 Int_t nbins[nhs] = { 800 , 40 , 202 };
214 Double_t xlow[nhs] = { -40., 0., -2.5 };
215 Double_t xup[nhs] = { 40., 4., 199.5 };
fd1d0cb9 216
6709e09d 217 TH1D *histo = 0;
9bcac085 218 for (Int_t i=0; i<nhs; i++) {
b46f66fc 219 char *hName = Form("h%s_%s", sName.Data(), tName[i].Data());
220 histo = new TH1D(hName, hName, nbins[i], xlow[i], xup[i]);
1195bb6f 221 histo->Sumw2(); list->Add(histo); histo = 0;
fd1d0cb9 222 }
223
224 TH1::AddDirectory(oldStatus);
225 return;
226}
227
228//_____________________________________________________________________________
1195bb6f 229void AliMuonsHFHeader::CreateHistosMuon(TList *list, TString sName)
fd1d0cb9 230{
231 // create histograms for single muon
232
233 if (!list) list = new TList();
234 list->SetOwner();
235 Bool_t oldStatus = TH1::AddDirectoryStatus();
236 TH1::AddDirectory(kFALSE);
b46f66fc 237
9bcac085 238 const Int_t nhs = 7;
239 TString tName[nhs] = { "P", "Pt", "Eta", "DCA", "TrM", "Charge", "Rabs" };
240 Int_t nbins[nhs] = { 1500 , 300 , 15 , 1000 , 4 , 3 , 48 };
241 Double_t xlow[nhs] = { 0., 0., -4.0, 0., -0.5, -1.5, 17.6 };
242 Double_t xup[nhs] = { 150., 30., -2.5, 500., 3.5, 1.5, 80.0 };
fd1d0cb9 243
6709e09d 244 TH1D *histo = 0;
9bcac085 245 for (Int_t i=0; i<nhs; i++) {
1195bb6f 246 char *hName = Form("h%s_%s", sName.Data(), tName[i].Data());
6709e09d 247 histo = new TH1D(hName, hName, nbins[i], xlow[i], xup[i]);
1195bb6f 248 histo->Sumw2(); list->Add(histo); histo = 0;
fd1d0cb9 249 }
250
251 TH1::AddDirectory(oldStatus);
252 return;
253}
254
255//_____________________________________________________________________________
1195bb6f 256void AliMuonsHFHeader::CreateHistosDimu(TList *list, TString sName)
fd1d0cb9 257{
258 // create histograms for dimuon
259
260 if (!list) list = new TList();
261 list->SetOwner();
262 Bool_t oldStatus = TH1::AddDirectoryStatus();
263 TH1::AddDirectory(kFALSE);
264
6709e09d 265 TH1D *histo = 0;
9bcac085 266 const Int_t nhs = 3;
267 TString tName[nhs] = { "P", "Pt", "InvM" };
268 Int_t nbins[nhs] = { 1500 , 300 , 300 };
269 Double_t xlow[nhs] = { 0., 0., 0. };
270 Double_t xup[nhs] = { 150., 30., 30. };
1195bb6f 271 TString dimuName[3] = { "DimuNN", "DimuNP", "DimuPP" };
fd1d0cb9 272 for (Int_t i=0; i<3; i++) {
9bcac085 273 for (Int_t j=0; j<nhs; j++) {
1195bb6f 274 char *hName = Form("h%s_%s_%s", sName.Data(), dimuName[i].Data(), tName[j].Data());
6709e09d 275 histo = new TH1D(hName, hName, nbins[j], xlow[j], xup[j]);
1195bb6f 276 histo->Sumw2(); list->Add(histo); histo = 0;
fd1d0cb9 277 }
278 }
279
280 TH1::AddDirectory(oldStatus);
281 return;
282}
283
284//_____________________________________________________________________________
1195bb6f 285void AliMuonsHFHeader::FillHistosEvnH(TList *list)
fd1d0cb9 286{
287 // fill histograms at event level according to event selection cuts
288
9bbc42ca 289 if (!list) return;
6709e09d 290 if (!this->IsSelected()) return;
fd1d0cb9 291
9bcac085 292 const Int_t nhs = 3;
293 TString tName[nhs] = { "Vz", "Vt", "VtxNcontr" };
2942f542 294 Double_t dist[nhs] = { this->Vz(), this->Vt(), static_cast<Double_t>(this->VtxContrsN()) };
9bcac085 295 if (fgIsMC && (fSelMask & AliVEvent::kAny)) {
296 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h_%s",tName[i].Data())))->Fill(dist[i]);
b46f66fc 297 } else {
9bcac085 298 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]); }
299 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]); }
b46f66fc 300 }
fd1d0cb9 301 return;
302}
303
304//_____________________________________________________________________________
b46f66fc 305void AliMuonsHFHeader::FillHistosMuon(TList *list, AliMuonInfoStoreRD* const infoStore, Int_t s)
fd1d0cb9 306{
307 // fill histograms for single muon according to event & muon track selection cuts
308
9bbc42ca 309 if (!list) return;
310 if (!this->IsSelected()) return;
311 if (!infoStore->IsSelected(0)) return;
1195bb6f 312
9bcac085 313 const Int_t nhs = 7;
314 TString tName[nhs] = { "P", "Pt", "Eta", "DCA", "TrM", "Charge", "Rabs" };
9bbc42ca 315 Double_t dist[nhs] = { infoStore->MomentumAtVtx().Mag(),
316 infoStore->MomentumAtVtx().Pt(),
317 infoStore->MomentumAtVtx().Eta(),
318 infoStore->DCA(),
2942f542 319 static_cast<Double_t>(infoStore->MatchTrigger()),
320 static_cast<Double_t>(infoStore->Charge()),
9bbc42ca 321 infoStore->RabsEnd() };
b46f66fc 322
9bcac085 323 if (fgIsMC && (fSelMask & AliVEvent::kAny)) {
b46f66fc 324 TString sName[7] = { "BottomMu", "CharmMu", "PrimaryMu", "SecondaryMu", "Hadron", "Unidentified", "" };
9bcac085 325 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s",sName[6].Data(),tName[i].Data())))->Fill(dist[i]);
326 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s",sName[s].Data(),tName[i].Data())))->Fill(dist[i]);
b46f66fc 327 } else {
9bcac085 328 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]); }
329 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]); }
1195bb6f 330 }
fd1d0cb9 331
fd1d0cb9 332 return;
333}
334
335//_____________________________________________________________________________
b46f66fc 336void AliMuonsHFHeader::FillHistosDimu(TList *list, AliDimuInfoStoreRD* const infoStore, Int_t s)
fd1d0cb9 337{
338 // fill histograms for dimuon according to evnet & dimuon candidates selection cuts
339
9bbc42ca 340 if (!list) return;
341 if (!this->IsSelected()) return;
342 if (!infoStore->IsSelected(0)) return;
fd1d0cb9 343
1195bb6f 344 TString dimuName = "DimuNN";
345 if (infoStore->Charge()==0) dimuName = "DimuNP";
346 else if (infoStore->Charge()>0) dimuName = "DimuPP";
fd1d0cb9 347
9bcac085 348 const Int_t nhs = 3;
349 TString tName[nhs] = { "P", "Pt", "InvM" };
350 Double_t dist[nhs] = { infoStore->Momentum().Mag(),
9bbc42ca 351 infoStore->Momentum().Pt(),
352 infoStore->InvM() };
fd1d0cb9 353
9bcac085 354 if (fgIsMC && (fSelMask & AliVEvent::kAny)) {
b46f66fc 355 TString sName[7] = { "BBdiff", "BBsame", "DDdiff", "DDsame", "Resonance", "Uncorr", "" };
9bcac085 356 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]);
357 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]);
b46f66fc 358 } else {
9bcac085 359 if (fIsMB && (fSelMask & AliVEvent::kMB)) {
360 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s_%s","MB",dimuName.Data(),tName[i].Data())))->Fill(dist[i]);
361 }
362 if (fIsMU && (fSelMask & AliVEvent::kMUON)) {
363 for (Int_t i=nhs; i--;) ((TH1D*)list->FindObject(Form("h%s_%s_%s","MU",dimuName.Data(),tName[i].Data())))->Fill(dist[i]);
364 }
1195bb6f 365 }
fd1d0cb9 366
4292b3b6 367 return;
368}