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