]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliEventPoolManager.h
-remove printouts
[u/mrichter/AliRoot.git] / ANALYSIS / AliEventPoolManager.h
1 #ifndef AliEventPoolManager_h
2 #define AliEventPoolManager_h
3
4 #include <vector>
5 #include <deque>
6 #include <Rtypes.h>
7 #include <Riostream.h>
8 #include <TObjArray.h>
9 #include <TFile.h>
10 #include <TMath.h>
11 #include <TRandom.h>
12 #include <TSystem.h>
13
14 // Generic event mixing classes
15 //
16 // Stores a buffer of tracks that updates continuously. The track type
17 // contained by the pools can be anything inheriting from
18 // TObject. Pools are updated based on maintaining a minimum fixed
19 // number of tracks. Multiplicity/centrality and z-vertex bins must be
20 // passed in at initialization. For example of implementation, see
21 // $ALICE_ROOT/PWGCF/Correlations/DPhi/AliAnalysisTaskPhiCorrelations.cxx
22 //
23 // Authors: A. Adare and C. Loizides
24
25 using std::deque;
26
27 class AliEventPool : public TObject
28 {
29  public:
30  AliEventPool(Int_t d) 
31    : fEvents(0),
32     fNTracksInEvent(0),
33     fEventIndex(0),
34     fMixDepth(d), 
35     fMultMin(-999), 
36     fMultMax(+999), 
37     fZvtxMin(-999), 
38     fZvtxMax(+999), 
39     fPsiMin(-999), 
40     fPsiMax(+999), 
41     fWasUpdated(0), 
42     fMultBinIndex(0), 
43     fZvtxBinIndex(0), 
44     fPsiBinIndex(0), 
45     fDebug(0), 
46     fTargetTrackDepth(0),
47     fFirstFilled(0),
48     fNTimes(0) {;}
49   
50
51  AliEventPool(Int_t d, Double_t multMin, Double_t multMax, 
52               Double_t zvtxMin, Double_t zvtxMax,
53               Double_t psiMin=-999., Double_t psiMax=999.) 
54    : fEvents(0),
55     fNTracksInEvent(0),
56     fEventIndex(0),
57     fMixDepth(d), 
58     fMultMin(multMin), 
59     fMultMax(multMax), 
60     fZvtxMin(zvtxMin),
61     fZvtxMax(zvtxMax),
62     fPsiMin(psiMin),
63     fPsiMax(psiMax),
64     fWasUpdated(0),
65     fMultBinIndex(0), 
66     fZvtxBinIndex(0),
67     fPsiBinIndex(0),
68     fDebug(0),
69     fTargetTrackDepth(0),
70     fFirstFilled(0),
71     fNTimes(0) {;}
72   
73   ~AliEventPool() {;}
74   
75   Bool_t      EventMatchesBin(Int_t mult,    Double_t zvtx, Double_t psi=0.) const;
76   Bool_t      EventMatchesBin(Double_t mult, Double_t zvtx, Double_t psi=0.) const;
77   Bool_t      IsReady()                    const { return NTracksInPool() >= fTargetTrackDepth; }
78   Bool_t      IsFirstReady()               const { return fFirstFilled;   }
79   Int_t       GetNTimes()                  const { return fNTimes;        }
80   Int_t       GetCurrentNEvents()          const { return fEvents.size(); }
81   Int_t       GlobalEventIndex(Int_t j)    const;
82   TObject    *GetRandomTrack()             const;
83   TObjArray  *GetRandomEvent()             const;
84   TObjArray  *GetEvent(Int_t i)            const;
85   Int_t       MultBinIndex()               const { return fMultBinIndex; }
86   Int_t       NTracksInEvent(Int_t iEvent) const;
87   Int_t       NTracksInCurrentEvent()      const { return fNTracksInEvent.back(); }
88   void        PrintInfo()                  const;
89   Int_t       PsiBinIndex()                   const { return fPsiBinIndex; }
90   Int_t       NTracksInPool()              const;
91   Bool_t      WasUpdated()                 const { return fWasUpdated; }
92   Int_t       ZvtxBinIndex()               const { return fZvtxBinIndex; }
93   void        SetDebug(Bool_t b)                 { fDebug = b; }
94   void        SetTargetTrackDepth(Int_t d)       { fTargetTrackDepth = d; }
95   Int_t       SetEventMultRange(Int_t    multMin, Int_t multMax);
96   Int_t       SetEventMultRange(Double_t multMin, Double_t multMax);
97   Int_t       SetEventZvtxRange(Double_t zvtxMin, Double_t zvtxMax);
98   Int_t       SetEventPsiRange(Double_t psiMin, Double_t psiMax);
99   void        SetMultBinIndex(Int_t iM) { fMultBinIndex = iM; }
100   void        SetZvtxBinIndex(Int_t iZ) { fZvtxBinIndex = iZ; }
101   void        SetPsiBinIndex(Int_t iP) { fPsiBinIndex  = iP; }
102   Int_t       UpdatePool(TObjArray *trk);
103   
104 protected:
105   deque<TObjArray*>     fEvents;              //Holds TObjArrays of MyTracklets
106   deque<int>            fNTracksInEvent;      //Tracks in event
107   deque<int>            fEventIndex;          //Original event index
108   Int_t                 fMixDepth;            //Number of evts. to mix with
109   Double_t              fMultMin, fMultMax;   //Track multiplicity bin range
110   Double_t              fZvtxMin, fZvtxMax;   //Event z-vertex bin range
111   Double_t              fPsiMin, fPsiMax;     //Event plane angle (Psi) bin range
112   Bool_t                fWasUpdated;          //Evt. succesfully passed selection?
113   Int_t                 fMultBinIndex;        //Multiplicity bin
114   Int_t                 fZvtxBinIndex;        //Zvertex bin
115   Int_t                 fPsiBinIndex;         //Event plane angle (Psi) bin
116   Int_t                 fDebug;               //If 1 then debug on
117   Int_t                 fTargetTrackDepth;    //Number of tracks, once full
118   Bool_t                fFirstFilled;         //Init to false
119   Int_t                 fNTimes;              //Number of times init. condition reached
120
121   ClassDef(AliEventPool,2) // Event pool class
122 };
123
124 class AliEventPoolManager : public TObject
125 {
126 public:
127   AliEventPoolManager() 
128     : fDebug(0),
129     fNMultBins(0), 
130     fNZvtxBins(0),
131     fNPsiBins(0),
132     fEvPool(0),
133     fTargetTrackDepth(0) {;}
134   AliEventPoolManager(Int_t maxEvts, Int_t minNTracks,
135                       Int_t nMultBins, Double_t *multbins,
136                       Int_t nZvtxBins, Double_t *zvtxbins);
137   
138   AliEventPoolManager(Int_t maxEvts, Int_t minNTracks,
139                       Int_t nMultBins, Double_t *multbins,
140                       Int_t nZvtxBins, Double_t *zvtxbins,
141                       Int_t nPsiBins, Double_t *psibins);
142   
143   ~AliEventPoolManager() {;}
144   
145   // First uses bin indices, second uses the variables themselves.
146   AliEventPool *GetEventPool(Int_t iMult, Int_t iZvtx, Int_t iPsi=0) const;
147   AliEventPool *GetEventPool(Int_t centVal, Double_t zvtxVal, Double_t psiVal=0.) const;
148   AliEventPool *GetEventPool(Double_t centVal, Double_t zvtxVal, Double_t psiVal=0.) const;
149
150   Int_t       InitEventPools(Int_t depth, 
151                              Int_t nmultbins, Double_t *multbins, 
152                              Int_t nzvtxbins, Double_t *zvtxbins,
153                              Int_t npsibins, Double_t *psibins);
154   
155   void        SetTargetTrackDepth(Int_t d) { fTargetTrackDepth = d;} // Same as for G.E.P. class
156   Int_t       UpdatePools(TObjArray *trk);
157   void        SetDebug(Bool_t b) { fDebug = b; }
158   
159  protected:
160   Int_t      fDebug;                                    // If 1 then debug on
161   Int_t      fNMultBins;                                // number mult bins
162   Int_t      fNZvtxBins;                                // number vertex bins
163   Int_t      fNPsiBins;                                 // number Event plane angle (Psi) bins
164   std::vector<AliEventPool*> fEvPool;                   // pool in bins of [fNMultBin][fNZvtxBin][fNPsiBin]
165   Int_t      fTargetTrackDepth;                         // Required track size, same for all pools.
166   
167   ClassDef(AliEventPoolManager,2)
168 };
169 #endif