]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/muon/AliAnalysisMuMuGlobal.cxx
Split the TaskMuMu into more manageable sub-analysis (Laurent)
[u/mrichter/AliRoot.git] / PWG / muon / AliAnalysisMuMuGlobal.cxx
1 #include "AliAnalysisMuMuGlobal.h"
2
3 /**
4  * \ingroup pwg-muon-mumu
5  *
6  * \class AliAnalysisMuMuGlobal
7  *
8  * Very simple histogramming analysis for global event properties, like vertex, bunch-crossing,
9  * background, etc...
10  *
11  * Warning : not really ready for prime-time
12  *
13  */
14
15 #include "TH1.h"
16 #include "AliVVertex.h"
17 #include "AliVEvent.h"
18 #include "AliAODEvent.h"
19 #include "AliAnalysisMuonUtility.h"
20 #include "AliAODTZERO.h"
21 #include "AliESDEvent.h"
22 #include "AliAnalysisMuMuBinning.h"
23 #include <set>
24 #include "AliMergeableCollection.h"
25 #include "AliAnalysisMuonUtility.h"
26
27 ClassImp(AliAnalysisMuMuGlobal)
28
29 //_____________________________________________________________________________
30 AliAnalysisMuMuGlobal::AliAnalysisMuMuGlobal() : AliAnalysisMuMuBase()
31 {
32   /// ctor
33 }
34
35 //_____________________________________________________________________________
36 void AliAnalysisMuMuGlobal::DefineHistogramCollection(const char* eventSelection,
37                                                       const char* triggerClassName,
38                                                       const char* centrality)
39 {
40   /// Actually create the histograms for phyics/triggerClassName
41   
42   //  AliInfo(Form("%s %s %s %d",eventSelection,triggerClassName,centrality,hasMC));
43   
44   if (HistogramCollection()->Histo(Form("/%s/%s/%s/Zvertex",eventSelection,triggerClassName,centrality)))
45   {
46     return;
47   }
48   
49   Double_t xmin = -40;
50   Double_t xmax = +40;
51   Int_t nbins = GetNbins(xmin,xmax,0.5);
52   
53   CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Zvertex","z vertex",nbins,xmin,xmax);
54   
55   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"T0Zvertex","T0 zvertex",nbins,xmin,xmax);
56   
57   CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,
58                     "RecZvertexVsMCZvertex","Reconstructed vertex (w/ Ncontrib>=1) vs MC vertex",nbins,xmin,xmax,nbins,xmin,xmax);
59   
60   xmin = -5;
61   xmax = 5;
62   nbins = GetNbins(xmin,xmax,0.01);
63   
64   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"ZvertexMinusZvertexSPD","Primary vertex z - SPD vertex",nbins,xmin,xmax);
65   
66   xmin = -1;
67   xmax = 50;
68   nbins = GetNbins(xmin,xmax,1);
69   
70   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"ZvertexNContributors","z vertex nof contributors",nbins,xmin,xmax);
71   
72   xmin = -2;
73   xmax = 2;
74   nbins = GetNbins(xmin,xmax,0.01);
75   
76   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"Xvertex","x vertex",nbins,xmin,xmax);
77   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"Yvertex","y vertex",nbins,xmin,xmax);
78   
79   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"Nevents","number of events",2,-0.5,1.5);
80   
81   CreateEventHistos(kHistoForMCInput | kHistoForData,eventSelection,triggerClassName,centrality,
82                     "VertexType","Type of vertexer used",10,0,10);
83   
84   
85   xmin = 0;
86   xmax = 3564;
87   nbins = GetNbins(xmin,xmax,1.0);
88   
89   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"BCX","bunch-crossing ids",nbins,xmin-0.5,xmax-0.5);
90   
91   
92   xmin = -30;
93   xmax = +30;
94   nbins = GetNbins(xmin,xmax,0.1);
95   
96   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02D","V0C+V0A versus V0A-V0C;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
97   
98   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02DwT0BB","V0C+V0A versus V0A-V0C with T0 BB;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
99   
100   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02DwT0BG","V0C+V0A versus V0A-V0C with T0 background flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
101   
102   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02DwT0PU","V0C+V0A versus V0A-V0C with T0 pile up flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
103   
104   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V02DwT0SAT","V0C+V0A versus V0A-V0C with T0 satellite flag on;Time V0A - V0C (ns);Time V0A+V0C (ns)",nbins,xmin,xmax,nbins,xmin,xmax);
105   
106   xmin = 0;
107   xmax = 600;
108   nbins = GetNbins(xmin,xmax,1);
109   
110   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"V0AMult","V0A multiplicity",nbins,xmin,xmax);
111   
112   if ( !IsHistogramDisabled("Centrality") )
113   {
114     TObjArray* centralities = Binning()->CreateBinObjArray("centrality");
115     TIter next(centralities);
116     AliAnalysisMuMuBinning::Range* r;
117     std::set<std::string> estimators;
118     
119     while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next())) )
120     {
121       estimators.insert(r->Quantity().Data());
122     }
123     
124     std::set<std::string>::const_iterator it;
125     
126     for ( it = estimators.begin(); it != estimators.end(); ++it )
127     {
128       TH1* h = new TH1F("Centrality","Centrality",12,-10,110);
129       HistogramCollection()->Adopt(Form("/%s/%s/%s",eventSelection,triggerClassName,it->c_str()),h);
130     }
131     
132     delete centralities;
133   }
134   
135   CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"PileUpEstimators","pile up estimators",10,0,10);
136 }
137
138
139 //_____________________________________________________________________________
140 void AliAnalysisMuMuGlobal::FillHistosForEvent(const char* eventSelection,
141                                                const char* triggerClassName,
142                                                const char* centrality)
143 {
144   // Fill event-wise histograms
145   
146   if (!IsHistogramDisabled("BCX"))
147   {
148     Histo(eventSelection,triggerClassName,centrality,"BCX")->Fill(1.0*Event()->GetBunchCrossNumber());
149   }
150   if (!IsHistogramDisabled("Nevents"))
151   {
152     Histo(eventSelection,triggerClassName,centrality,"Nevents")->Fill(1.0);
153   }
154   
155   const AliVVertex* vertex = Event()->GetPrimaryVertex();
156   const AliVVertex* vertexFromSPD = AliAnalysisMuonUtility::GetVertexSPD(Event());
157   
158   if ( vertex && vertexFromSPD )
159   {
160     if ( vertex->GetNContributors() > 0 )
161     {
162       if (!IsHistogramDisabled("Xvertex"))
163       {
164         Histo(eventSelection,triggerClassName,centrality,"Xvertex")->Fill(vertex->GetX());
165       }
166       if (!IsHistogramDisabled("Yvertex"))
167       {
168         Histo(eventSelection,triggerClassName,centrality,"Yvertex")->Fill(vertex->GetY());
169       }
170       if (!IsHistogramDisabled("Zvertex"))
171       {
172         Histo(eventSelection,triggerClassName,centrality,"Zvertex")->Fill(vertex->GetZ());
173       }
174       if (!IsHistogramDisabled("ZvertexMinusZvertexSPD"))
175       {
176         Histo(eventSelection,triggerClassName,centrality,"ZvertexMinusZvertexSPD")->Fill(vertexFromSPD->GetZ()-vertex->GetZ());
177       }
178       if (!IsHistogramDisabled("VertexType"))
179       {
180         Histo(eventSelection,triggerClassName,centrality,"VertexType")->Fill(vertex->GetTitle(),1.0);
181       }
182     }
183     if (!IsHistogramDisabled("ZvertexNContributors"))
184     {
185       Histo(eventSelection,triggerClassName,centrality,"ZvertexNContributors")->Fill(vertex->GetNContributors());
186     }
187   }
188   
189   if ( AliAnalysisMuonUtility::IsAODEvent(Event()) )
190   {
191     const AliAODTZERO* tzero = static_cast<const AliAODEvent*>(Event())->GetTZEROData();
192     
193     if (tzero && !IsHistogramDisabled("T0Zvertex"))
194     {
195       Histo(eventSelection,triggerClassName,centrality,"T0Zvertex")->Fill(tzero->GetT0VertexRaw());
196     }
197   }
198   else
199   {
200     const AliESDTZERO* tzero = static_cast<const AliESDEvent*>(Event())->GetESDTZERO();
201     
202     if (tzero && !IsHistogramDisabled("T0Zvertex"))
203     {
204       Histo(eventSelection,triggerClassName,centrality,"T0Zvertex")->Fill(tzero->GetT0zVertex());
205     }
206   }
207   
208   AliVVZERO* vzero = Event()->GetVZEROData();
209   
210   if (vzero)
211   {
212     Float_t v0a = vzero->GetV0ATime();
213     Float_t v0c = vzero->GetV0CTime();
214     
215     Float_t x = v0a-v0c;
216     Float_t y = v0a+v0c;
217     
218     if (!IsHistogramDisabled("V0A"))
219     {
220       Histo(eventSelection,triggerClassName,centrality,"V0AMult")->Fill(vzero->GetMTotV0A());
221     }
222     if (!IsHistogramDisabled("V02D"))
223     {
224       Histo(eventSelection,triggerClassName,centrality,"V02D")->Fill(x,y);
225     }
226     
227     Bool_t background,pileup,satellite;
228     
229     Bool_t tzero = AliAnalysisMuonUtility::EAGetTZEROFlags(Event(),background,pileup,satellite);
230     
231     if (tzero)
232     {
233       if ( background )
234       {
235         if (!IsHistogramDisabled("V02DwT0BG"))
236         {
237           Histo(eventSelection,triggerClassName,centrality,"V02DwT0BG")->Fill(x,y);
238         }
239       }
240       
241       if ( pileup )
242       {
243         if (!IsHistogramDisabled("V02DwT0PU"))
244         {
245           Histo(eventSelection,triggerClassName,centrality,"V02DwT0PU")->Fill(x,y);
246         }
247         
248         if ( !IsHistogramDisabled("PileUpEstimators") )
249         {
250           Histo(eventSelection,triggerClassName,centrality,"PileUpEstimators")->Fill("TZERO",1.0);
251         }
252       }
253       
254       if ( satellite )
255       {
256         if (!IsHistogramDisabled("V02DwT0SAT"))
257         {
258           Histo(eventSelection,triggerClassName,centrality,"V02DwT0SAT")->Fill(x,y);
259         }
260       }
261       
262       if ( !background && !pileup && !satellite )
263       {
264         if (!IsHistogramDisabled("V02DwT0BB"))
265         {
266           Histo(eventSelection,triggerClassName,centrality,"V02DwT0BB")->Fill(x,y);
267         }
268       }
269     }
270   }
271   
272   //  /* FIXME : how to properly get multiplicity from AOD and ESD consistently ?
273   //   is is doable at all ?
274   
275   TH1* hpileup = Histo(eventSelection,triggerClassName,centrality,"PileUpEstimators");
276   
277   
278   //  virtual Bool_t  IsPileupFromSPD(Int_t minContributors=3, Double_t minZdist=0.8, Double_t nSigmaZdist=3., Double_t nSigmaDiamXY=2., Double_t nSigmaDiamZ=5.) const;
279   
280   const Double_t nSigmaZdist=3.0;
281   const Double_t nSigmaDiamXY=2.0;
282   const Double_t nSigmaDiamZ=5.0;
283   
284   for ( Int_t minContributors = 3; minContributors <= 6; ++minContributors )
285   {
286     for ( double minZdist = 0.6; minZdist <= 0.8; minZdist += 0.2 )
287     {
288       if ( Event()->IsPileupFromSPD(minContributors,minZdist,nSigmaZdist,nSigmaDiamXY,nSigmaDiamZ) )
289       {
290         hpileup->Fill(Form("SPD:n%dd%d",minContributors,static_cast<Int_t>(10*minZdist)),1);
291       }
292     }
293   }
294   
295   
296 }
297
298 //_____________________________________________________________________________
299 void AliAnalysisMuMuGlobal::FillHistosForMCEvent(const char* eventSelection,
300                                                  const char* triggerClassName,
301                                                  const char* centrality)
302 {
303   // Fill MCEvent-wise histograms
304   
305   Double_t Zvertex = AliAnalysisMuonUtility::GetMCVertexZ(Event(),MCEvent());
306   
307   if (!IsHistogramDisabled("Zvertex"))
308   {
309     MCHisto(eventSelection,triggerClassName,centrality,"Zvertex")->Fill(Zvertex);
310   }
311
312   if (!IsHistogramDisabled("RecZvertexVsMCZvertex"))
313   {
314     const AliVVertex* vertex = Event()->GetPrimaryVertex();
315     if  (vertex && vertex->GetNContributors()>0)
316     {
317       MCHisto(eventSelection,triggerClassName,centrality,"RecZvertexVsMCZvertex")->Fill(Zvertex,vertex->GetZ());
318     }
319   }
320   
321 }
322
323 //_____________________________________________________________________________
324 Bool_t AliAnalysisMuMuGlobal::SelectAnyTriggerClass(const TString& firedTriggerClasses, TString& acceptedTriggerClasses) const
325 {
326   /// Accept all trigger classes
327   if ( firedTriggerClasses.Length()>0)
328   {
329     acceptedTriggerClasses = "NOTRIGGERSELECTION";
330     return kTRUE;
331   }
332   return kFALSE;
333 }
334