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