]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliEventPoolManager.h
Add new online gain tables
[u/mrichter/AliRoot.git] / ANALYSIS / AliEventPoolManager.h
CommitLineData
2a910c25 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
3d4e011d 21// $ALICE_ROOT/PWG4/Correlations/AliAnalysisTaskPhiCorrelations.cxx
2a910c25 22//
23// Authors: A. Adare and C. Loizides
24
25class AliEventPool : public TObject
26{
27 public:
28 AliEventPool(Int_t d)
29 : fEvents(0),
30 fNTracksInEvent(0),
31 fEventIndex(0),
32 fMixDepth(d),
33 fMultMin(-999),
34 fMultMax(+999),
35 fZvtxMin(-999),
36 fZvtxMax(+999),
37 fWasUpdated(0),
38 fMultBinIndex(0),
39 fZvtxBinIndex(0),
40 fDebug(0),
41 fTargetTrackDepth(0),
42 fFirstFilled(0),
43 fNTimes(0) {;}
44
45 AliEventPool(Int_t d, Double_t multMin, Double_t multMax,
46 Double_t zvtxMin, Double_t zvtxMax)
47 : fEvents(0),
48 fNTracksInEvent(0),
49 fEventIndex(0),
50 fMixDepth(d),
51 fMultMin(multMin),
52 fMultMax(multMax),
53 fZvtxMin(zvtxMin),
54 fZvtxMax(zvtxMax),
55 fWasUpdated(0),
56 fMultBinIndex(0),
57 fZvtxBinIndex(0),
58 fDebug(0),
59 fTargetTrackDepth(0),
60 fFirstFilled(0),
61 fNTimes(0) {;}
62 ~AliEventPool() {;}
63
64 Bool_t EventMatchesBin(Int_t mult, Double_t zvtx) const;
65 Bool_t EventMatchesBin(Double_t mult, Double_t zvtx) const;
66 Bool_t IsReady() const { return NTracksInPool() >= fTargetTrackDepth; }
fa67180e 67 Bool_t IsFirstReady() const { return fFirstFilled; }
68 Int_t GetNTimes() const { return fNTimes; }
2a910c25 69 Int_t GetCurrentNEvents() const { return fEvents.size(); }
70 Int_t GlobalEventIndex(Int_t j) const;
71 TObject *GetRandomTrack() const;
72 TObjArray *GetRandomEvent() const;
73 TObjArray *GetEvent(Int_t i) const;
74 Int_t MultBinIndex() const { return fMultBinIndex; }
75 Int_t NTracksInEvent(Int_t iEvent) const;
76 Int_t NTracksInCurrentEvent() const { return fNTracksInEvent.back(); }
77 void PrintInfo() const;
78 Int_t NTracksInPool() const;
79 Bool_t WasUpdated() const { return fWasUpdated; }
80 Int_t ZvtxBinIndex() const { return fZvtxBinIndex; }
81 void SetDebug(Bool_t b) { fDebug = b; }
82 void SetTargetTrackDepth(Int_t d) { fTargetTrackDepth = d; }
83 Int_t SetEventMultRange(Int_t multMin, Int_t multMax);
84 Int_t SetEventMultRange(Double_t multMin, Double_t multMax);
85 Int_t SetEventZvtxRange(Double_t zvtxMin, Double_t zvtxMax);
86 void SetMultBinIndex(Int_t iM) { fMultBinIndex = iM; }
87 void SetZvtxBinIndex(Int_t iZ) { fZvtxBinIndex = iZ; }
88 Int_t UpdatePool(TObjArray *trk);
89
90protected:
91 deque<TObjArray*> fEvents; //Holds TObjArrays of MyTracklets
92 deque<int> fNTracksInEvent; //Tracks in event
93 deque<int> fEventIndex; //Original event index
94 Int_t fMixDepth; //Number of evts. to mix with
95 Double_t fMultMin, fMultMax; //Track multiplicity bin range
96 Double_t fZvtxMin, fZvtxMax; //Event z-vertex bin range
97 Bool_t fWasUpdated; //Evt. succesfully passed selection?
98 Int_t fMultBinIndex; //Multiplicity bin
99 Int_t fZvtxBinIndex; //Zvertex bin
100 Int_t fDebug; //If 1 then debug on
101 Int_t fTargetTrackDepth; //Number of tracks, once full
102 Bool_t fFirstFilled; //Init to false
103 Int_t fNTimes; //Number of times init. condition reached
104
105 ClassDef(AliEventPool,1) // Event pool class
106};
107
108class AliEventPoolManager : public TObject
109{
110public:
111 AliEventPoolManager()
112 : fDebug(0),
113 fNMultBins(0),
114 fNZvtxBins(0),
115 fEvPool(0),
116 fTargetTrackDepth(0) {;}
117 AliEventPoolManager(Int_t maxEvts, Int_t minNTracks,
118 Int_t nMultBins, Double_t *multbins,
119 Int_t nZvtxBins, Double_t *zvtxbins);
120
121 ~AliEventPoolManager() {;}
122
123 // First uses bin indices, second uses the variables themselves.
124 AliEventPool *GetEventPool(Int_t iMult, Int_t iZvtx) const;
125 AliEventPool *GetEventPool(Int_t centVal, Double_t zvtxVal) const;
126 AliEventPool *GetEventPool(Double_t centVal, Double_t zvtxVal) const;
127
128 Int_t InitEventPools(Int_t depth,
129 Int_t nmultbins, Double_t *multbins,
130 Int_t nzvtxbins, Double_t *zvtxbins);
131 void SetTargetTrackDepth(Int_t d) { fTargetTrackDepth = d;} // Same as for G.E.P. class
132 Int_t UpdatePools(TObjArray *trk);
133 void SetDebug(Bool_t b) { fDebug = b; }
134
135protected:
136 Int_t fDebug; // If 1 then debug on
137 Int_t fNMultBins; // number mult bins
138 Int_t fNZvtxBins; // number vertex bins
139 std::vector<std::vector<AliEventPool*> > fEvPool; // pool in bins of [fMultBin][fZvtxBin]
140 Int_t fTargetTrackDepth; // Required track size, same for all pools.
141
142 ClassDef(AliEventPoolManager,1)
143};
144#endif