]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/muon/AliAnalysisTaskMuMu.h
1) Fix small bugs for ESD case 2) Now allow combinations of trigger classes and L0...
[u/mrichter/AliRoot.git] / PWG / muon / AliAnalysisTaskMuMu.h
1
2 #ifndef ALIANALYSISTASKMUMU_H
3 #define ALIANALYSISTASKMUMU_H
4
5 //
6 // AliAnalysisTaskMuMu : base class for mu pairs analysis 
7 // Contains common things for ESD-based and AOD-based analysis
8 //
9 // author: L. Aphecetche (Subatech)
10 //
11
12 #ifndef ALIANALYSISTASKSE_H
13 #  include "AliAnalysisTaskSE.h"
14 #endif
15
16 #include <set>
17 #include <vector>
18
19 #ifndef ROOT_TArrayI
20 #  include "TArrayI.h"
21 #endif
22
23 class TList;
24 class AliHistogramCollection;
25 class TObjArray;
26 class AliCounterCollection;
27 class TArrayF;
28 class AliMuonTrackCuts;
29 class AliVEvent;
30 class AliVParticle;
31
32 class AliAnalysisTaskMuMu : public AliAnalysisTaskSE
33 {
34 public:
35   
36   enum ETrackCut
37   {
38     kAll=BIT(0),
39     kPt1=BIT(1),
40     kRabs=BIT(2),
41     kMatched=BIT(3),
42     kMatchedLow=BIT(4),
43     kMatchedHigh=BIT(5),
44     kEta=BIT(6),
45     kChi2=BIT(7),
46     kDCA=BIT(8),
47     kPairRapidity=BIT(9),
48     kBelowPt=BIT(10),
49     kPt1dot2=BIT(11),
50     kPt1dot5=BIT(12),
51     kPt2=BIT(13),
52     kDeg23=BIT(14),
53     kDeg310=BIT(15),
54     kP10=BIT(16),
55     kChi2MatchTrigger=BIT(17)
56   };
57   
58   enum EEventCut
59   {
60     kEventAll=BIT(0),
61     kEventPS=BIT(1),
62     kEventTVX=BIT(2),
63     kEventV0AND=BIT(3),
64     kEventV0UP=BIT(4),
65     kEventZSPD=BIT(5),
66     kEventZ7=BIT(7),    
67     kEventZ10=BIT(10),
68     kEventSD2=BIT(16),
69     kEventMSL=BIT(17)
70   };
71   
72   AliAnalysisTaskMuMu();
73   AliAnalysisTaskMuMu(Bool_t fromESD, TList* triggerClassesToConsider, const char* beamYear=0x0, TArrayF* centralities=0x0);
74   AliAnalysisTaskMuMu(Bool_t fromESD, const char* beamYear, TArrayF* centralities=0x0);
75   virtual ~AliAnalysisTaskMuMu();
76   
77   virtual void AddEventCut(const char* cutName, UInt_t mask);
78   
79   virtual void AddPairCut(const char* cutName, UInt_t maskForOneOrBothTrack, UInt_t maskForTrackPair=0);
80   
81   virtual void AddSingleCut(const char* cutName, UInt_t mask);
82   
83   void AddTriggerClasses(const char* triggerlist, const char* sep=",");
84   
85   virtual void DisableHistogramming() { fIsHistogrammingDisabled = kTRUE; }
86   
87   virtual void FinishTaskOutput();
88   
89   Bool_t IsPP() const;
90
91   virtual Bool_t IsHistogrammingDisabled() const { return fIsHistogrammingDisabled; }
92
93   static void MergeCentralities(AliHistogramCollection* histogramCollection);
94   
95   virtual void NotifyRun();
96   
97   virtual void Print(Option_t* opt="") const;
98   
99   virtual void ShouldSeparatePlusAndMinus(Bool_t value) { fShouldSeparatePlusAndMinus = value; }
100   
101   virtual Bool_t ShouldSeparatePlusAndMinus() const { return fShouldSeparatePlusAndMinus; }
102   
103   virtual void Terminate(Option_t *);
104   
105   void UseBackgroundTriggers(Bool_t value=kTRUE) { fUseBackgroundTriggers = value; }
106
107   void UserCreateOutputObjects();
108
109   virtual void UserExec(Option_t* opt);
110   
111   class PairCut : public TObject {
112   public:
113     PairCut(const char* name="", UInt_t maskForOneOrBothTrack=0, UInt_t maskForTrackPair=0)
114     : TObject(), fName("p"),fMaskForOneOrBothTrack(maskForOneOrBothTrack),fMaskForTrackPair(maskForTrackPair)
115     {
116       fName += name;
117     }
118     const char* GetName() const { return fName.Data(); }
119     UInt_t MaskForOneOrBothTrack() const { return fMaskForOneOrBothTrack; }
120     UInt_t MaskForTrackPair() const { return fMaskForTrackPair; }
121     void Print(Option_t* opt="") const;
122     
123   private:
124     TString fName; // name of the cut
125     UInt_t fMaskForOneOrBothTrack; // mask for the cut that at least of the two tracks should match
126     UInt_t fMaskForTrackPair; // mask for the cut both tracks should match
127     
128     ClassDef(AliAnalysisTaskMuMu::PairCut,1); // a simple wrapper for two masks
129   };
130   
131   
132 private:
133
134   Bool_t PassPhysicsSelection() const;
135
136   Bool_t CheckTriggerClass(const TString& toCheck, const TString& firedTriggerClasses, UInt_t l0Inputs) const;
137
138   virtual void FillHistos(const char* physics, const char* triggerClassName, const char* centrality, const AliVEvent& event);
139
140   void FillHistosForTrack(const char* physics, const char* triggerClassName, const char* centrality, const AliVParticle& track, Int_t trackIndex);
141
142   void Fill(const char* eventtype, TObjString* tname, const char* centrality, float fcent, const AliVEvent& event);
143
144   void AssertHistogramCollection(const char* physics, const char* triggerClassName);
145
146   void BeautifyHistos();
147
148    void CreateHisto(TObjArray* array,
149                    const char* physics,
150                    const char* triggerClassName,
151                    const char* hname, const char* htitle, 
152                    Int_t nbinsx, Double_t xmin, Double_t xmax,
153                    Int_t nbinsy, Double_t ymin, Double_t ymax) const;
154   
155   void CreateEventHisto(const char* physics,
156                         const char* triggerClassName,
157                         const char* hname, const char* htitle, 
158                         Int_t nbinsx, Double_t xmin, Double_t xmax,
159                         Int_t nbinsy=0, Double_t ymin=0.0, Double_t ymax=0.0) const;
160   
161   void CreateSingleHisto(const char* physics,
162                          const char* triggerClassName,
163                          const char* hname, const char* htitle, 
164                          Int_t nbinsx, Double_t xmin, Double_t xmax,
165                          Int_t nbinsy=0, Double_t ymin=0.0, Double_t ymax=0.0,
166                          Bool_t separatePlusAndMinus=kFALSE) const;
167
168   void CreatePairHisto(const char* physics,
169                        const char* triggerClassName,
170                        const char* hname, const char* htitle, 
171                        Int_t nbinsx, Double_t xmin, Double_t xmax,
172                        Int_t nbinsy=0, Double_t ymin=0.0, Double_t ymax=0.0) const;
173   
174    void DefineCentralityClasses(TArrayF* centralities);
175   
176   void FillHistogramCollection(const char* physics, const char* triggerClassName);
177
178   UInt_t GetTriggerInputBitMaskFromInputName(const char* inputName) const;
179
180   TH1* Histo(const char* physics, const char* histoname);
181   
182   TH1* Histo(const char* physics, const char* triggerClassName, const char* histoname);
183   
184   TH1* Histo(const char* physics, const char* triggerClassName, const char* what, const char* histoname);
185
186   TH1* Histo(const char* physics, const char* triggerClassName, const char* cent, const char* what, const char* histoname);
187
188   Double_t MuonMass2() const;
189   
190   const char* DefaultCentralityName() const;
191   
192   const char* CentralityName(Double_t centrality) const;
193   
194   Double_t Deg2() const { return 2.0*TMath::DegToRad(); }
195   Double_t Deg3() const { return 3.0*TMath::DegToRad(); }
196   Double_t Deg10() const { return 10.2*TMath::DegToRad(); }
197     
198   Double_t AbsZEnd() const { return 505.0; /* cm */ }
199   
200   Bool_t IsDynamicTriggerClasses() const { return fIsDynamicTriggerClasses; }
201
202 private:
203   
204   void ComputeTrackMask(const AliVParticle& track, Int_t trackIndex);
205
206   UInt_t GetEventMask(const AliVEvent& event) const;
207
208   void GetPairMask(const AliVParticle& t1, const AliVParticle& t2,
209                    Int_t trackIndex1, Int_t trackIndex2,
210                    UInt_t& mask1, UInt_t& mask2,
211                    UInt_t& mask12) const;
212   
213   UInt_t GetTrackMask(Int_t trackIndex) const;
214   
215   Double_t GetTrackTheta(const AliVParticle& particle) const;
216   
217   Bool_t PairRapidityCut(const AliVParticle& t1, const AliVParticle& t2) const;
218
219   /* methods prefixed with EA should really not exist at all. They are there
220    only because the some of our base interfaces are shamelessly incomplete or
221    inadequate...
222    */
223   
224   void EAComputeTrackMasks(const AliVEvent& event);
225
226   TString EAGetFiredTriggerClasses(const AliVEvent& event) const;
227   
228   Int_t EAGetNumberOfMuonTracks(const AliVEvent& event) const;
229
230   UInt_t EAGetL0TriggerInputs(const AliVEvent& event) const;
231   
232   AliVParticle* EAGetTrack(const AliVEvent& event, Int_t i) const;
233   
234   Double_t EAGetTrackChi2MatchTrigger(const AliVParticle& track) const;
235
236   Double_t EAGetTrackDCA(const AliVParticle& particle) const;
237
238   Double_t EAGetTrackRabs(const AliVParticle& particle) const;
239
240   Double_t EAGetTrackNormalizedChi2(const AliVParticle& particle) const;
241
242   Bool_t EAGetTZEROFlags(const AliVEvent& event, Bool_t& backgroundFlag, Bool_t& pileupFlag, Bool_t& satelliteFlag) const;
243
244   Bool_t AtLeastOneMuonTrigger(const TString& firedTriggerClasses) const;
245
246   Bool_t AtLeastOneEmcalTrigger(const TString& firedTriggerClasses) const;
247
248   Bool_t AtLeastOneMBTrigger(const TString& firedTriggerClasses) const;
249
250   Bool_t TriggerSBACECondition(const TString& triggerName) const;
251
252 private:
253   
254   TList* fOutput; //! list of output objects
255   AliHistogramCollection* fHistogramCollection; //! collection of histograms
256   AliCounterCollection* fEventCounters; //! event counters
257   
258   AliMuonTrackCuts* fMuonTrackCuts; //! common cuts for muon tracks (from Diego)
259   TArrayI fPrecomputedTrackMasks; //! track masks
260
261   Bool_t fIsFromESD; // whether we read from ESD or AOD
262   Bool_t fIsDynamicTriggerClasses; // whether or not to update considered triggers on the fly
263   Bool_t fShouldSeparatePlusAndMinus; // whether or not to histogram mu+ and mu- separately
264   Bool_t fIsHistogrammingDisabled; // disable histogramming completely (only counters will be filled)
265
266   TString fBeamYear; // beam and year
267   std::vector<double> fCentralityLimits; // centrality limits
268
269   TList* fTriggerClasses; // trigger classes to consider
270   TObjArray* fSingleTrackCutNames; // cut on single tracks (array of TObjString)
271   TObjArray* fPairTrackCutNames; // cut on track pairs (array of TObjString)
272   TObjArray* fCentralityNames; // names to create histograms
273   TObjArray* fEventCutNames; // cut at event level (array of TObjString)
274   
275   Bool_t fUseBackgroundTriggers; // whether or not we should use the ACE triggers
276   
277   std::map<std::string,int> fTriggerInputBitMap; // map of L0 input name to bit
278   
279   AliAnalysisTaskMuMu(const AliAnalysisTaskMuMu&); // not implemented (on purpose)
280   AliAnalysisTaskMuMu& operator=(const AliAnalysisTaskMuMu&); // not implemented (on purpose)
281   
282   
283   ClassDef(AliAnalysisTaskMuMu,17) // a class to analyse muon pairs (and single also ;-) )
284 };
285
286 #endif
287