1 #ifndef KiddiePoolClasses_h
2 #define KiddiePoolClasses_h
15 // Low-memory event mixing classes:
16 // - KiddiePoolManager: Maintain 2D vector (z,cent) of KiddiePools.
17 // - KiddiePool: collections of sub-events in z and mult/cent bins.
18 // - MiniTrack: super-lightweight track "struct" class.
20 // Stores a buffer of tracks that updates continuously. The track type
21 // contained by the pools can be anything inheriting from
22 // TObject. Pools are updated based on maintaining a minimum fixed
23 // number of tracks. Multiplicity/centrality and z-vertex bins must be
24 // passed in at initialization. For example of implementation, see
25 // $ALICE_ROOT/PWG4/JetTasks/AliAnalysisTaskPhiCorrelations.cxx
27 // Authors: A. Adare and C. Loizides
29 typedef std::vector< MiniTrack > MiniEvent;
34 MiniTrack() : fPt(0), fEta(0), fPhi(0), fSign(0) {};
35 MiniTrack(Double_t pt, Double_t eta, Double_t phi, Int_t sign) :
36 fPt(pt), fEta(eta), fPhi(phi), fSign(sign>=0?1:0) {};
38 Float_t Eta() const { return fEta; }
39 Float_t Phi() const { return fPhi; }
40 Float_t Pt() const { return fPt; }
41 Int_t Sign() const { if (fSign) return 1; return -1; }
50 class KiddiePool : public TObject
70 KiddiePool(Int_t d, Double_t multMin, Double_t multMax,
71 Double_t zvtxMin, Double_t zvtxMax) :
89 Bool_t EventMatchesBin(Int_t mult, Double_t zvtx) const;
90 Bool_t EventMatchesBin(Double_t mult, Double_t zvtx) const;
91 Bool_t IsReady() const { return NTracksInPool() >= fTargetTrackDepth; }
92 Bool_t IsFirstReady() const { return fFirstFilled; }
93 Int_t GetNTimes() const { return fNTimes; }
94 Int_t GetCurrentNEvents() const { return fEvents.size(); }
95 Int_t GlobalEventIndex(Int_t j) const;
96 MiniEvent* GetEvent(Int_t i) const;
97 Int_t MultBinIndex() const { return fMultBinIndex; }
98 Int_t NTracksInEvent(Int_t iEvent) const;
99 Int_t NTracksInCurrentEvent() const { if (fNTracksInEvent.empty()) return 0;
100 return fNTracksInEvent.back(); }
101 void PrintInfo() const;
102 Int_t NTracksInPool() const;
103 Bool_t WasUpdated() const { return fWasUpdated; }
104 Int_t ZvtxBinIndex() const { return fZvtxBinIndex; }
105 void SetDebug(Bool_t b) { fDebug = b; }
106 void SetTargetTrackDepth(Int_t d) { fTargetTrackDepth = d; }
107 Int_t SetEventMultRange(Int_t multMin, Int_t multMax);
108 Int_t SetEventMultRange(Double_t multMin, Double_t multMax);
109 Int_t SetEventZvtxRange(Double_t zvtxMin, Double_t zvtxMax);
110 void SetMultBinIndex(Int_t iM) { fMultBinIndex = iM; }
111 void SetZvtxBinIndex(Int_t iZ) { fZvtxBinIndex = iZ; }
112 Int_t UpdatePool(MiniEvent* miniEvt);
115 deque< MiniEvent* > fEvents; //Pool of events storing Minitracks
116 deque<int> fNTracksInEvent; //Tracks in event
117 deque<int> fEventIndex; //Original event index
118 Int_t fMixDepth; //Number of evts. to mix with
119 Double_t fMultMin, fMultMax; //Track multiplicity bin range
120 Double_t fZvtxMin, fZvtxMax; //Event z-vertex bin range
121 Bool_t fWasUpdated; //Evt. succesfully passed selection?
122 Int_t fMultBinIndex; //Multiplicity bin
123 Int_t fZvtxBinIndex; //Zvertex bin
124 Int_t fDebug; //If 1 then debug on
125 Int_t fTargetTrackDepth; //Number of tracks, once full
126 Bool_t fFirstFilled; //Init to false
127 Int_t fNTimes; //Number of times init. condition reached
129 ClassDef(KiddiePool,1) // Event pool class
132 class KiddiePoolManager : public TObject
135 KiddiePoolManager() :
140 fTargetTrackDepth(0) {;}
141 KiddiePoolManager(Int_t maxEvts, Int_t minNTracks,
142 Int_t nMultBins, Double_t *multbins,
143 Int_t nZvtxBins, Double_t *zvtxbins);
145 ~KiddiePoolManager();
147 // First uses bin indices, second uses the variables themselves.
148 KiddiePool *GetEventPool(Int_t iMult, Int_t iZvtx) const;
149 KiddiePool *GetEventPool(Int_t centVal, Double_t zvtxVal) const;
150 KiddiePool *GetEventPool(Double_t centVal, Double_t zvtxVal) const;
152 Int_t InitEventPools(Int_t depth,
153 Int_t nmultbins, Double_t *multbins,
154 Int_t nzvtxbins, Double_t *zvtxbins);
155 void SetTargetTrackDepth(Int_t d) { fTargetTrackDepth = d;}
156 Int_t UpdatePools(MiniEvent*);
157 void SetDebug(Bool_t b) { fDebug = b; }
160 Int_t fDebug; // If 1 then debug on
161 Int_t fNMultBins; // number mult bins
162 Int_t fNZvtxBins; // number vertex bins
163 vector< vector<KiddiePool*> > fEvPool; // pool in bins of [fMultBin][fZvtxBin]
164 Int_t fTargetTrackDepth; // Required track size, same for all pools.
166 ClassDef(KiddiePoolManager,1)