]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/muon/AliMuonsHFHeader.cxx
Follow PB requested that, for the time being, TRD info is not used to update
[u/mrichter/AliRoot.git] / PWG3 / muon / AliMuonsHFHeader.cxx
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
24 #include <TMath.h>
25 #include <TH1.h>
26 #include <TH1D.h>
27 #include <TList.h>
28
29 #include "AliVEvent.h"
30 #include "AliMuonInfoStoreRD.h"
31 #include "AliMuonInfoStoreMC.h"
32 #include "AliDimuInfoStoreRD.h"
33 #include "AliDimuInfoStoreMC.h"
34 #include "AliMuonsHFHeader.h"
35
36 class TNamed;
37 class AliVVertex;
38
39 ClassImp(AliMuonsHFHeader)
40
41 const TString AliMuonsHFHeader::fgkStdBranchName("MuEvsH");
42 Int_t         AliMuonsHFHeader::fgAnaMode = 0;
43 Bool_t        AliMuonsHFHeader::fgIsMC    = kFALSE;
44 Double_t      AliMuonsHFHeader::fgCuts[5] = { -999999., 999999., 999999., -999999., 999999. };
45
46 //_____________________________________________________________________________
47 AliMuonsHFHeader::AliMuonsHFHeader() :
48 TNamed(),
49 fSelMask(AliVEvent::kAny),
50 fIsMB(kFALSE),
51 fIsMU(kFALSE),
52 fVtxContrsN(0),
53 fFiredTriggerClass(),
54 fCentrality(0.)
55 {
56   //
57   // default constructor
58   //
59   for (Int_t i=3; i--;) fVtx[i] = 0.;
60 }
61
62 //_____________________________________________________________________________
63 AliMuonsHFHeader::AliMuonsHFHeader(const AliMuonsHFHeader &src) :
64 TNamed(),
65 fSelMask(src.fSelMask),
66 fIsMB(src.fIsMB),
67 fIsMU(src.fIsMU),
68 fVtxContrsN(src.fVtxContrsN),
69 fFiredTriggerClass(src.fFiredTriggerClass),
70 fCentrality(src.fCentrality)
71 {
72   //
73   // copy constructor
74   //
75   for (Int_t i=3; i--;) fVtx[i] = src.fVtx[i];
76 }
77
78 //_____________________________________________________________________________
79 AliMuonsHFHeader& AliMuonsHFHeader::operator=(const AliMuonsHFHeader &src)
80 {
81   //
82   // assignment constructor
83   //
84
85   fSelMask           = src.fSelMask;
86   fIsMB              = src.fIsMB;
87   fIsMU              = src.fIsMU;
88   fVtxContrsN        = src.fVtxContrsN;
89   fFiredTriggerClass = src.fFiredTriggerClass;
90   fCentrality        = src.fCentrality;
91   for (Int_t i=3; i--;) fVtx[i] = src.fVtx[i];
92
93   return *this;
94 }
95
96 //_____________________________________________________________________________
97 AliMuonsHFHeader::~AliMuonsHFHeader()
98 {
99   //
100   // default destructor
101   //
102 }
103
104 //_____________________________________________________________________________
105 void AliMuonsHFHeader::SetVertex(AliVVertex *vertex)
106 {
107   // extract event info from AOD event
108
109   vertex->GetXYZ(fVtx);
110   fVtxContrsN = vertex->GetNContributors();
111   this->SetTitle(vertex->GetTitle());
112   return;
113 }
114
115 void AliMuonsHFHeader::SetFiredTriggerClass(TString trigger)
116 {
117   fFiredTriggerClass = trigger;
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 
127   return;
128 }
129
130 //_____________________________________________________________________________
131 Bool_t AliMuonsHFHeader::IsSelected()
132 {
133   // select event according to the event selection cuts
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;
141   return kTRUE;
142 }
143
144 //_____________________________________________________________________________
145 void AliMuonsHFHeader::CreateHistograms(TList *list)
146 {
147   // create output histos of muon analysis according to the analysis mode & MC flag
148
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]);
154     }
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]);
158     }
159     return;
160   }
161
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"); }
165   return;
166 }
167
168 //_____________________________________________________________________________
169 void AliMuonsHFHeader::CreateHistosEvnH(TList *list, TString sName)
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
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 };
183
184   TH1D *histo = 0;
185   for (Int_t i=0; i<nhs; i++) {
186     char *hName = Form("h%s_%s", sName.Data(), tName[i].Data());
187     histo = new TH1D(hName, hName, nbins[i], xlow[i], xup[i]);
188     histo->Sumw2(); list->Add(histo); histo = 0;
189   }
190
191   TH1::AddDirectory(oldStatus);
192   return;
193 }
194
195 //_____________________________________________________________________________
196 void AliMuonsHFHeader::CreateHistosMuon(TList *list, TString sName)
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);
204
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 };
210
211   TH1D *histo = 0;
212   for (Int_t i=0; i<nhs; i++) {
213     char *hName = Form("h%s_%s", sName.Data(), tName[i].Data());
214     histo = new TH1D(hName, hName, nbins[i], xlow[i], xup[i]);
215     histo->Sumw2(); list->Add(histo); histo = 0;
216   }
217
218   TH1::AddDirectory(oldStatus);
219   return;
220 }
221
222 //_____________________________________________________________________________
223 void AliMuonsHFHeader::CreateHistosDimu(TList *list, TString sName)
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
232   TH1D *histo = 0;
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.   };
238   TString dimuName[3] = { "DimuNN", "DimuNP", "DimuPP" };
239   for (Int_t i=0; i<3; i++) {
240     for (Int_t j=0; j<nhs; j++) {
241       char *hName = Form("h%s_%s_%s", sName.Data(), dimuName[i].Data(), tName[j].Data());
242       histo = new TH1D(hName, hName, nbins[j], xlow[j], xup[j]);
243       histo->Sumw2(); list->Add(histo); histo = 0;
244     }
245   }
246
247   TH1::AddDirectory(oldStatus);
248   return;
249 }
250
251 //_____________________________________________________________________________
252 void AliMuonsHFHeader::FillHistosEvnH(TList *list)
253 {
254   // fill histograms at event level according to event selection cuts
255
256   if (!list)                   return;
257   if (!this->IsSelected()) return;
258
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]);
264   } else {
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]); }
267   }
268   return;
269 }
270
271 //_____________________________________________________________________________
272 void AliMuonsHFHeader::FillHistosMuon(TList *list, AliMuonInfoStoreRD* const infoStore, Int_t s)
273 {
274   // fill histograms for single muon according to event & muon track selection cuts
275
276   if (!list)                    return;
277   if (!this->IsSelected())      return;
278   if (!infoStore->IsSelected()) return;
279
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(),
283                              infoStore->Momentum().Pt(),
284                              infoStore->Momentum().Eta(),
285                              infoStore->DCA(),
286                              infoStore->MatchTrigger(),
287                              infoStore->Charge(),
288                              infoStore->RabsEnd() };
289
290   if (fgIsMC && (fSelMask & AliVEvent::kAny)) {
291     TString sName[7] = { "BottomMu", "CharmMu", "PrimaryMu", "SecondaryMu", "Hadron", "Unidentified", "" };
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]);
294   } else {
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]); }
297   }
298
299   return; 
300 }
301
302 //_____________________________________________________________________________
303 void AliMuonsHFHeader::FillHistosDimu(TList *list, AliDimuInfoStoreRD* const infoStore, Int_t s)
304 {
305   // fill histograms for dimuon according to evnet & dimuon candidates selection cuts
306
307   if (!list)                    return;
308   if (!this->IsSelected())      return;
309   if (!infoStore->IsSelected()) return;
310
311   TString dimuName = "DimuNN";
312   if (infoStore->Charge()==0)     dimuName = "DimuNP";
313   else if (infoStore->Charge()>0) dimuName = "DimuPP";
314
315   const Int_t nhs    = 3;
316   TString tName[nhs] = { "P", "Pt", "InvM" };
317   Double_t dist[nhs] = { infoStore->Momentum().Mag(),
318                              infoStore->Momentum().Pt(),
319                              infoStore->InvM() };
320
321   if (fgIsMC && (fSelMask & AliVEvent::kAny)) {
322     TString sName[7] = { "BBdiff", "BBsame", "DDdiff", "DDsame", "Resonance", "Uncorr", "" };
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]);
325   } else {
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     }
332   }
333
334   return;
335 }