]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliAnalysisTaskFastEmbedding.h
Add a protection to avoid crash in QA (Julian)
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskFastEmbedding.h
1 #ifndef ALIANALYSISTASKFASTEMBEDDING_H
2 #define ALIANALYSISTASKFASTEMBEDDING_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 #include "AliAnalysisTaskSE.h"
10
11 class AliESDEvent;
12 class AliAODEvent;
13 class TTree;
14 class TFile;
15 class TChain;
16 class TObjArray;
17 class TObjString;
18 class TRandom3;
19 class TH1F;
20 class TH2F;
21 class TProfile;
22 class AliAODMCHeader;
23
24 class AliAnalysisTaskFastEmbedding : public AliAnalysisTaskSE {
25
26 public:
27    
28    AliAnalysisTaskFastEmbedding();
29    AliAnalysisTaskFastEmbedding(const char *name);
30    AliAnalysisTaskFastEmbedding(const AliAnalysisTaskFastEmbedding &copy);
31    AliAnalysisTaskFastEmbedding& operator=(const AliAnalysisTaskFastEmbedding &o);
32    virtual ~AliAnalysisTaskFastEmbedding();
33
34    virtual void UserCreateOutputObjects();
35    virtual void LocalInit() { Init(); }
36    virtual void Init();
37    virtual Bool_t UserNotify();
38    virtual void UserExec(Option_t*);
39    virtual void Terminate(Option_t */*option*/);
40
41    void SetAODPath(TString path) {fAODPath = path;}
42    void SetArrayOfAODPaths(TObjArray* arr) {fAODPathArray = arr;}
43    void SetArrayOfAODEntries(TArrayI* arr) {fAODEntriesArray = arr;}
44    void SetAODEntriesSum(Int_t i){ fAODEntriesSum = i;}
45    void SetAODEntriesMax(Int_t i){ fAODEntriesMax = i;}
46    
47    virtual void     SetOfflineTrgMask(AliVEvent::EOfflineTriggerTypes mask) { fOfflineTrgMask = mask; }
48    virtual void     SetMinContribVtx(Int_t n) { fMinContribVtx = n; }
49    virtual void     SetVtxZMin(Float_t z) { fVtxZMin = z; }
50    virtual void     SetVtxZMax(Float_t z) { fVtxZMax = z; }
51    virtual void     SetEvtClassMin(Int_t evtClass) { fEvtClassMin = evtClass; }
52    virtual void     SetEvtClassMax(Int_t evtClass) { fEvtClassMax = evtClass; }
53    virtual void     SetCentMin(Float_t cent) { fCentMin = cent; }
54    virtual void     SetCentMax(Float_t cent) { fCentMax = cent; }
55    virtual void     SetNInputTracksMin(Int_t nTr) { fNInputTracksMin = nTr; }
56    virtual void     SetNInputTracksMax(Int_t nTr) { fNInputTracksMax = nTr; }
57    
58    void SetTrackBranch(TString name) {fTrackBranch = name;}
59    void SetMCparticlesBranch(TString name) {fMCparticlesBranch = name;}
60    void SetJetBranch(TString name) {fJetBranch = name;}
61
62    void SetEmbedMode(Int_t m) {fEmbedMode = m;}
63    Int_t GetEmbedMode() const {return fEmbedMode;} 
64    void SetEvtSelecMode(Int_t s) {fEvtSelecMode = s;}
65    Int_t GetEvtSelecMode() const {return fEvtSelecMode;}
66
67    void SetEvtSelJetPtRange(Float_t minPt, Float_t maxPt) {fEvtSelMinJetPt = minPt; fEvtSelMaxJetPt = maxPt;}
68    void SetEvtSelJetEtaRange(Float_t minEta, Float_t maxEta) {fEvtSelMinJetEta = minEta; fEvtSelMaxJetEta = maxEta;}
69    void SetEvtSelJetPhiRange(Float_t minPhi, Float_t maxPhi) {fEvtSelMinJetPhi = minPhi; fEvtSelMaxJetPhi = maxPhi;}
70    
71    void SetToyNumberOfTrackRange(Int_t minN = 1, Int_t maxN = 1){ fToyMinNbOfTracks = minN, fToyMaxNbOfTracks = maxN; }
72    void SetToyTrackRanges(Double_t minPt = 50., Double_t maxPt = 50., Double_t ptDistr=0,
73    Double_t minEta = -.5, Double_t maxEta = .5,
74    Double_t minPhi = 0., Double_t maxPhi = 2*TMath::Pi())
75    {
76       fToyMinTrackPt = minPt; fToyMaxTrackPt = maxPt; fToyDistributionTrackPt = ptDistr;
77       fToyMinTrackEta = minEta; fToyMaxTrackEta = maxEta;
78       fToyMinTrackPhi = minPhi; fToyMaxTrackPhi = maxPhi;}
79    void SetToyFilterMap(UInt_t f) {fToyFilterMap = f;}
80    void SetTrackFilterMap(UInt_t f) {fTrackFilterMap = f;}
81
82    static Float_t GetPtHard(Bool_t bSet=kFALSE, Float_t newValue = 0.);
83    
84    virtual Int_t      GetPtHardBin(Double_t ptHard);
85    virtual Bool_t     PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials);
86
87    // embedding modes
88    enum {kAODFull=0, kAODJetTracks, kAODJet4Mom, kToyTracks};
89    // event selection from AOD
90    enum {kEventsAll=0, kEventsJetPt};
91
92
93 private:
94
95    AliESDEvent    *fESD;        //! ESD object
96    AliAODEvent    *fAODout;     //! AOD out
97    AliAODEvent    *fAODevent;   //! AOD in
98    TTree          *fAODtree;    //! AODin tree
99    TFile          *fAODfile;    //! AODin file
100    AliAODMCHeader *mcHeader;    //! mc header
101    TRandom3       *rndm;        //! random nummer generator
102    Int_t          fInputEntries; // total nb. of events (for this subjob)
103
104    TObjArray *fAODPathArray;    // array of paths of AOD in file
105    TArrayI   *fAODEntriesArray; // array of entries of AODs 
106    TString    fAODPath;         // path of AOD in file
107    Int_t      fAODEntries;      // entries of AOD
108    Int_t      fAODEntriesSum;   // sum of all entries of AODs
109    Int_t      fAODEntriesMax;   // maximum entries of AODs
110
111    AliVEvent::EOfflineTriggerTypes fOfflineTrgMask; // mask of offline triggers to accept
112    Int_t   fMinContribVtx; // minimum number of track contributors for primary vertex
113    Float_t fVtxZMin;          // lower bound on vertex z
114    Float_t fVtxZMax;          // upper bound on vertex z
115    Int_t   fEvtClassMin;        // lower bound on event class
116    Int_t   fEvtClassMax;        // upper bound on event class
117    Float_t fCentMin;          // lower bound on centrality
118    Float_t fCentMax;          // upper bound on centrality
119    Int_t   fNInputTracksMin;  // lower bound of nb. of input tracks
120    Int_t   fNInputTracksMax;  // upper bound of nb. of input tracks
121    
122    TString fTrackBranch;       // name of branch for extra tracks in AOD out
123    TString fMCparticlesBranch; // name of branch for extra mcparticles in AOD out
124    TString fJetBranch;         // name of branch for extra jets AOD in
125
126    Int_t fFileId;   // nb. of file from the list
127    Int_t fAODEntry; // entry of extra AOD
128    Int_t fCountEvents; // count processed events in this file
129
130    Int_t fEmbedMode;     // embedding mode: kAODFull=0, kAODJetTracks=1, kAODJet4Mom=2, kToyTracks=3
131    Int_t fEvtSelecMode;  // event selection criterion: kEventsAll=0, kEventsJetPt=1
132
133    // event selection from AOD
134    Float_t fEvtSelMinJetPt;       // minimum pt of the leading jet
135    Float_t fEvtSelMaxJetPt;       // maximum pt of the leading jet
136    Float_t fEvtSelMinJetEta;      // minimum eta of the leading jet
137    Float_t fEvtSelMaxJetEta;      // maximum eta of the leading jet
138    Float_t fEvtSelMinJetPhi;      // minimum phi of the leading jet
139    Float_t fEvtSelMaxJetPhi;      // maximum phi of the leading jet
140    
141    
142    // settings for toy "track generation"
143    Int_t    fToyMinNbOfTracks;             // minimum nb. of tracks per event
144    Int_t    fToyMaxNbOfTracks;             // maximum nb. of tracks per event
145    Float_t  fToyMinTrackPt;                // minimum track pT
146    Float_t  fToyMaxTrackPt;                // maximum track pT
147    Float_t  fToyDistributionTrackPt;       // distribution of track pt
148    Float_t  fToyMinTrackEta;               // minimum eta of tracks
149    Float_t  fToyMaxTrackEta;               // maximum eta of tracks
150    Float_t  fToyMinTrackPhi;               // minimum phi of tracks
151    Float_t  fToyMaxTrackPhi;               // maximum phi of tracks
152    UInt_t   fToyFilterMap;                 // filter map of tracks
153    UInt_t   fTrackFilterMap;               // filter map of tracks for QA plots
154    
155    Int_t         fNPtHard;      // nb. of pT hard bins
156    Double_t      fPtHard;       // pT hard
157    Int_t         fPtHardBin;    // pT hard bin
158    TClonesArray* fAODJets;      //! array of jets from aod
159    Int_t         fNevents;      // number of events in aod
160    Float_t       fXsection;     // average xsection of the event
161    Float_t       fAvgTrials;    // average number of trials per event
162
163
164    // histos
165    TList *fHistList;          //  list of histograms
166    TH1I  *fHistEvtSelection;  //! stastic of event selection
167    TProfile *fh1Xsec;         //! cross-section
168    TH1F  *fh1Trials;          //! nb. of trials (simulation)
169    TH1F  *fh1TrialsEvtSel;    //! nb. of trials (event selection, e.g. jet pT)
170    TH2F  *fh2PtHard;          //! pT hard bin
171    TH2F  *fh2PtHardEvtSel;    //! pT hard bin (event selection)
172    TH2F  *fh2PtHardTrials;     //! pT hard bin, weighted by nb. of trials
173    
174    // qa histos
175    TH1F  *fh1TrackPt;         //! track pt
176    TH2F  *fh2TrackEtaPhi;     //! track eta-phi
177    TH1F  *fh1TrackN;          //! nb. of tracks
178    TH1F  *fh1JetPt;           //! jet pt
179    TH2F  *fh2JetEtaPhi;       //! jet eta-phi
180    TH1F  *fh1JetN;            //! nb. of jets
181    TH1F  *fh1MCTrackPt;       //! MC track pt
182    TH2F  *fh2MCTrackEtaPhi;   //! MC track eta-phi
183    TH1F  *fh1MCTrackN;        //! nb. of MC tracks
184    TH1I  *fh1AODfile;         //! used AOD files from AODPathArray
185    TH2I  *fh2AODevent;        //! selected events in AODs
186    
187
188    Int_t GetJobID();    // get job id (sub-job id on the GRID)
189    Int_t SelectAODfile();
190    Int_t OpenAODfile(Int_t trial = 0);
191
192
193    ClassDef(AliAnalysisTaskFastEmbedding, 6);
194 };
195
196 #endif
197