]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/muon/AliVAnalysisMuon.h
Fix problem in terminate. Add possibility to select the minimum number of vertex...
[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 SetTerminateOptions(TString physSel="All", TString trigClass="ANY", TString centralityRange="", TString furtherOpts="");
48   
49   /// Get muon track cuts
50   AliMuonTrackCuts* GetMuonTrackCuts() { return fMuonTrackCuts; }
51   /// Get muon pair cuts
52   AliMuonPairCuts* GetMuonPairCuts() { return fMuonPairCuts; }
53   
54   // Utility methods for CF container
55   static Bool_t SetSparseRange(AliCFGridSparse* gridSparse,
56                                Int_t ivar, TString labelName,
57                                Double_t varMin, Double_t varMax,
58                                TString option = "");
59   
60   /// Set minimum number of vertex contributors
61   void SetMinNvtxContributors(Int_t minNvtxContributors) { fMinNvtxContirbutors = minNvtxContributors; }
62
63  protected:
64   
65   /////////////////////////////////////////////////////
66   // Pure virtual methods to be implemented bu users //
67   /////////////////////////////////////////////////////
68   
69   virtual void MyUserCreateOutputObjects() = 0;
70   // In this method you have to create your own output as well as
71   // the mergeable objects that will be then used
72   // in the counter collection.
73   // To do so, create your object and add it to the collection through:
74   //    TH1* histo = new TH1F();
75   //    AddObjectToCollection(histo, index)
76   
77   virtual void ProcessEvent(TString physSel, const TObjArray& selectTrigClasses, TString centrality) = 0;
78   // This method is called at each event.
79   // In this method you can fill the histograms or the CF container that you have created
80   
81   /////////////////////
82   // Utility methods //
83   /////////////////////
84   
85   // Transparently handle tracks in ESD/AOD
86   Int_t GetNTracks();
87   AliVParticle* GetTrack(Int_t itrack);
88   TLorentzVector GetTrackPair(AliVParticle* track1, AliVParticle* track2) const;
89   
90   // Methods for MC
91   Bool_t IsMC();
92   Int_t GetNMCTracks();
93   AliVParticle* GetMCTrack(Int_t trackLabel);
94   Int_t GetMotherIndex(AliVParticle* mcParticle);
95   Int_t GetDaughterIndex(AliVParticle* mcParticle, Int_t idaughter);
96   Int_t GetParticleType(AliVParticle* track);
97   Int_t RecoTrackMother(AliVParticle* mcParticle);
98   
99   // Methods for mergeable object collections
100   Bool_t AddObjectToCollection(TObject* object, Int_t index = -1);
101   TObject* GetMergeableObject(TString physSel, TString trigClassName, TString centrality, TString objectName);
102   TObject* GetSum(TString physSel, TString trigClassNames, TString centrality, TString objectPattern);
103   
104   // A useful constant
105   Double_t MuonMass2() const;
106   
107   // Handle triggers
108   Bool_t TrackPtCutMatchTrigClass(AliVParticle* track, TString trigClassName);
109   Int_t GetTrigClassPtCutLevel(TString trigClassName);
110   
111   // Methods for event information
112   AliVVertex* GetVertexSPD() const;
113   
114   enum {
115     kPhysSelPass,    ///< Physics selected events
116     kPhysSelReject,  ///< Events non-passing selection
117     kNselections     ///< Number of selections
118   };
119   
120   enum {
121     kCharmMu,       ///< Mu from charm
122     kBeautyMu,      ///< Mu from beauty
123     kQuarkoniumMu,  ///< Mu from resonance
124     kWbosonMu,      ///< Mu from W
125     kDecayMu,       ///< Decay mu
126     kSecondaryMu,   ///< Secondary mu
127     kRecoHadron,    ///< Reconstructed hadron
128     kUnidentified,  ///< Particle that fails matching kine
129     kNtrackSources  ///< Total number of track sources
130   };
131     
132   AliMuonTrackCuts* fMuonTrackCuts; ///< Muon track cuts
133   AliMuonPairCuts* fMuonPairCuts;   ///< Muon pair track cuts
134   AliESDEvent* fESDEvent;      //!< ESD event, not owner
135   AliAODEvent* fAODEvent;      //!< AOD event, not owner
136   TObjArray* fTerminateOptions; ///< Terminate options
137   TObjArray* fChargeKeys;      ///< Muon charge keys
138   TObjArray* fSrcKeys;         ///< MC sources names
139   TObjArray* fPhysSelKeys;     ///< Physics selection names
140   TList* fTriggerClasses;      ///< List of trigger classes
141   TAxis* fCentralityClasses;   ///< Centrality classes
142   
143   AliCounterCollection* fEventCounters;  //!< event counters
144   AliMergeableCollection* fMergeableCollection; //!< collection of mergeable objects
145   TObjArray* fOutputList;  //!< List of outputs  
146   Int_t fMinNvtxContirbutors;  ///< Minimum number of vertex contributors
147
148  private:
149   AliVAnalysisMuon(const AliVAnalysisMuon&);
150   AliVAnalysisMuon& operator=(const AliVAnalysisMuon&);
151   
152   void InitKeys();
153   void CreateMergeableObjects(TString physSel, TString trigClassName, TString centrality);
154   TObjArray* BuildTriggerClasses(TString firedTrigClasses);
155   
156   TObjArray* fSelectedTrigPattern; ///< List of triggers to be kept
157   TObjArray* fRejectedTrigPattern; ///< List of triggers to be rejected
158   TObjArray* fSelectedTrigLevel;   ///< Track-trigger pt cut for selected trigger class
159   TObjArray* fOutputPrototypeList; //!< List of prototype object to be used in collection
160
161   ClassDef(AliVAnalysisMuon, 3);
162 };
163
164 #endif