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