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