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