]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/muon/AliVAnalysisMuon.h
adding cuts for muons
[u/mrichter/AliRoot.git] / PWG / muon / AliVAnalysisMuon.h
1 #ifndef ALIVANALYSISMUON_H
2 #define ALIVANALYSISMUON_H
3
4 /* $Id: AliVAnalysisMuon.h 47782 2011-02-24 18:37:31Z martinez $ */ 
5
6 //
7 // Base class for single muon analysis
8 //
9 // Author: Diego Stocco
10 //
11
12 #include "AliAnalysisTaskSE.h"
13
14 class TString;
15 class TObjArray;
16 class TAxis;
17 class TLorentzVector;
18 class TList;
19 class AliMergeableCollection;
20 class AliCounterCollection;
21 class AliVParticle;
22 class AliAODEvent;
23 class AliESDEvent;
24 class AliCFGridSparse;
25 class AliMuonTrackCuts;
26 class AliMuonPairCuts;
27 class AliVVertex;
28
29 class AliVAnalysisMuon : public AliAnalysisTaskSE {
30  public:
31   AliVAnalysisMuon();
32   AliVAnalysisMuon(const char *name, const AliMuonTrackCuts& trackCuts);
33   AliVAnalysisMuon(const char *name, const AliMuonPairCuts& pairCuts);
34   AliVAnalysisMuon(const char *name, const AliMuonTrackCuts& trackCuts, const AliMuonPairCuts& pairCuts);
35   
36   virtual ~AliVAnalysisMuon();
37
38   virtual void   UserCreateOutputObjects();
39   virtual void   UserExec(Option_t *option);
40   virtual void   Terminate(Option_t *option);
41   virtual void   NotifyRun();
42   virtual void   FinishTaskOutput();
43
44   void SetCentralityClasses(Int_t nCentralityBins = -1, Double_t* centralityBins = 0x0);
45
46   void SetTrigClassPatterns(TString pattern = "CINT CMU !CMUP CMBAC CPBI !-ACE- !-AC- !-E- !WU !EGA !EJE");
47   void SetTrigClassLevels(TString pattern = "MSL:Lpt MSH:Hpt MUL:Lpt MLL:Lpt");
48   void SetTerminateOptions(TString physSel="All", TString trigClass="ANY", TString centralityRange="", TString furtherOpts="");
49   
50   /// Get muon track cuts
51   AliMuonTrackCuts* GetMuonTrackCuts() { return fMuonTrackCuts; }
52   /// Get muon pair cuts
53   AliMuonPairCuts* GetMuonPairCuts() { return fMuonPairCuts; }
54   
55   // Utility methods for CF container
56   static Bool_t SetSparseRange(AliCFGridSparse* gridSparse,
57                                Int_t ivar, TString labelName,
58                                Double_t varMin, Double_t varMax,
59                                TString option = "");
60   
61   /// Set minimum number of vertex contributors
62   void SetMinNvtxContributors(Int_t minNvtxContributors) { fMinNvtxContirbutors = minNvtxContributors; }
63
64  protected:
65   
66   /////////////////////////////////////////////////////
67   // Pure virtual methods to be implemented bu users //
68   /////////////////////////////////////////////////////
69   
70   virtual void MyUserCreateOutputObjects() = 0;
71   // In this method you have to create your own output as well as
72   // the mergeable objects that will be then used
73   // in the counter collection.
74   // To do so, create your object and add it to the collection through:
75   //    TH1* histo = new TH1F();
76   //    AddObjectToCollection(histo, index)
77   
78   virtual void ProcessEvent(TString physSel, const TObjArray& selectTrigClasses, TString centrality) = 0;
79   // This method is called at each event.
80   // In this method you can fill the histograms or the CF container that you have created
81   
82   /////////////////////
83   // Utility methods //
84   /////////////////////
85   
86   // Transparently handle tracks in ESD/AOD
87   Int_t GetNTracks();
88   AliVParticle* GetTrack(Int_t itrack);
89   TLorentzVector GetTrackPair(AliVParticle* track1, AliVParticle* track2) const;
90   
91   // Methods for MC
92   Bool_t IsMC();
93   Int_t GetNMCTracks();
94   AliVParticle* GetMCTrack(Int_t trackLabel);
95   Int_t GetMotherIndex(AliVParticle* mcParticle);
96   Int_t GetDaughterIndex(AliVParticle* mcParticle, Int_t idaughter);
97   Int_t GetParticleType(AliVParticle* track);
98   Int_t RecoTrackMother(AliVParticle* mcParticle);
99   
100   // Methods for mergeable object collections
101   Bool_t AddObjectToCollection(TObject* object, Int_t index = -1);
102   TObject* GetMergeableObject(TString physSel, TString trigClassName, TString centrality, TString objectName);
103   TObject* GetSum(TString physSel, TString trigClassNames, TString centrality, TString objectPattern);
104   
105   // A useful constant
106   Double_t MuonMass2() const;
107   
108   // Handle triggers
109   Bool_t TrackPtCutMatchTrigClass(AliVParticle* track, TString trigClassName);
110   Int_t GetTrigClassPtCutLevel(TString trigClassName);
111   
112   // Methods for event information
113   AliVVertex* GetVertexSPD() const;
114   
115   enum {
116     kPhysSelPass,    ///< Physics selected events
117     kPhysSelReject,  ///< Events non-passing selection
118     kNselections     ///< Number of selections
119   };
120   
121   enum {
122     kCharmMu,       ///< Mu from charm
123     kBeautyMu,      ///< Mu from beauty
124     kQuarkoniumMu,  ///< Mu from resonance
125     kWbosonMu,      ///< Mu from W
126     kDecayMu,       ///< Decay mu
127     kSecondaryMu,   ///< Secondary mu
128     kRecoHadron,    ///< Reconstructed hadron
129     kUnidentified,  ///< Particle that fails matching kine
130     kNtrackSources  ///< Total number of track sources
131   };
132     
133   AliMuonTrackCuts* fMuonTrackCuts; ///< Muon track cuts
134   AliMuonPairCuts* fMuonPairCuts;   ///< Muon pair track cuts
135   AliESDEvent* fESDEvent;      //!< ESD event, not owner
136   AliAODEvent* fAODEvent;      //!< AOD event, not owner
137   TObjArray* fTerminateOptions; ///< Terminate options
138   TObjArray* fChargeKeys;      ///< Muon charge keys
139   TObjArray* fSrcKeys;         ///< MC sources names
140   TObjArray* fPhysSelKeys;     ///< Physics selection names
141   TList* fTriggerClasses;      ///< List of trigger classes
142   TAxis* fCentralityClasses;   ///< Centrality classes
143   
144   AliCounterCollection* fEventCounters;  //!< event counters
145   AliMergeableCollection* fMergeableCollection; //!< collection of mergeable objects
146   TObjArray* fOutputList;  //!< List of outputs  
147   Int_t fMinNvtxContirbutors;  ///< Minimum number of vertex contributors
148
149  private:
150   AliVAnalysisMuon(const AliVAnalysisMuon&);
151   AliVAnalysisMuon& operator=(const AliVAnalysisMuon&);
152   
153   void InitKeys();
154   void CreateMergeableObjects(TString physSel, TString trigClassName, TString centrality);
155   TObjArray* BuildTriggerClasses(TString firedTrigClasses);
156   
157   TObjArray* fSelectedTrigPattern; ///< List of triggers to be kept
158   TObjArray* fRejectedTrigPattern; ///< List of triggers to be rejected
159   TObjArray* fSelectedTrigLevel;   ///< Track-trigger pt cut for selected trigger class
160   TObjArray* fOutputPrototypeList; //!< List of prototype object to be used in collection
161
162   ClassDef(AliVAnalysisMuon, 3);
163 };
164
165 #endif