15 // Low-memory event mixing classes:
16 // - AliEvtPoolManager: Maintain 2D vector (z,cent) of AliEvtPools.
17 // - AliEvtPool: collections of sub-events in z and mult/cent bins.
18 // - AliMiniTrack: 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 (no inheritance from
22 // AliVParticle, or even TObject, required). To use a track type other
23 // than AliMiniTrack, just redefine the MiniEvent typedef (for example,
24 // using AliESDTracks, or TLorenzVectors).
25 // Pools are updated based on maintaining a minimum fixed
26 // number of tracks. Multiplicity/centrality and z-vertex bins must be
27 // passed in at initialization. For example of implementation, see
28 // $ALICE_ROOT/PWGCF/Correlations/DPhi/FourierDecomposition/AliDhcTask.cxx
30 // Authors: A. Adare and C. Loizides
32 typedef std::vector< AliMiniTrack > MiniEvent;
37 AliMiniTrack() : fPt(0), fEta(0), fPhi(0), fSign(0) {};
38 AliMiniTrack(Double_t pt, Double_t eta, Double_t phi, Int_t sign) :
39 fPt(pt), fEta(eta), fPhi(phi), fSign(sign>=0?1:0) {};
41 Float_t Eta() const { return fEta; }
42 Float_t Phi() const { return fPhi; }
43 Float_t Pt() const { return fPt; }
44 Int_t Sign() const { if (fSign) return 1; return -1; }
53 class AliEvtPool : public TObject
73 AliEvtPool(Int_t d, Double_t multMin, Double_t multMax,
74 Double_t zvtxMin, Double_t zvtxMax) :
92 Bool_t EventMatchesBin(Int_t mult, Double_t zvtx) const;
93 Bool_t EventMatchesBin(Double_t mult, Double_t zvtx) const;
94 Bool_t IsReady() const { return NTracksInPool() >= fTargetTrackDepth; }
95 Bool_t IsFirstReady() const { return fFirstFilled; }
96 Int_t GetNTimes() const { return fNTimes; }
97 Int_t GetCurrentNEvents() const { return fEvents.size(); }
98 Int_t GlobalEventIndex(Int_t j) const;
99 MiniEvent* GetEvent(Int_t i) const;
100 Int_t MultBinIndex() const { return fMultBinIndex; }
101 Int_t NTracksInEvent(Int_t iEvent) const;
102 Int_t NTracksInCurrentEvent() const { if (fNTracksInEvent.empty()) return 0;
103 return fNTracksInEvent.back(); }
104 void PrintInfo() const;
105 Int_t NTracksInPool() const;
106 Bool_t WasUpdated() const { return fWasUpdated; }
107 Int_t ZvtxBinIndex() const { return fZvtxBinIndex; }
108 void SetDebug(Bool_t b) { fDebug = b; }
109 void SetTargetTrackDepth(Int_t d) { fTargetTrackDepth = d; }
110 Int_t SetEventMultRange(Int_t multMin, Int_t multMax);
111 Int_t SetEventMultRange(Double_t multMin, Double_t multMax);
112 Int_t SetEventZvtxRange(Double_t zvtxMin, Double_t zvtxMax);
113 void SetMultBinIndex(Int_t iM) { fMultBinIndex = iM; }
114 void SetZvtxBinIndex(Int_t iZ) { fZvtxBinIndex = iZ; }
115 Int_t UpdatePool(MiniEvent* miniEvt);
118 deque< MiniEvent* > fEvents; //Pool of events storing Minitracks
119 deque<int> fNTracksInEvent; //Tracks in event
120 deque<int> fEventIndex; //Original event index
121 Int_t fMixDepth; //Number of evts. to mix with
122 Double_t fMultMin, fMultMax; //Track multiplicity bin range
123 Double_t fZvtxMin, fZvtxMax; //Event z-vertex bin range
124 Bool_t fWasUpdated; //Evt. succesfully passed selection?
125 Int_t fMultBinIndex; //Multiplicity bin
126 Int_t fZvtxBinIndex; //Zvertex bin
127 Int_t fDebug; //If 1 then debug on
128 Int_t fTargetTrackDepth; //Number of tracks, once full
129 Bool_t fFirstFilled; //Init to false
130 Int_t fNTimes; //Number of times init. condition reached
132 ClassDef(AliEvtPool,1) // Event pool class
135 class AliEvtPoolManager : public TObject
138 AliEvtPoolManager() :
143 fTargetTrackDepth(0) {;}
144 AliEvtPoolManager(Int_t maxEvts, Int_t minNTracks,
145 Int_t nMultBins, Double_t *multbins,
146 Int_t nZvtxBins, Double_t *zvtxbins);
148 ~AliEvtPoolManager();
150 // First uses bin indices, second uses the variables themselves.
151 AliEvtPool *GetEventPool(Int_t iMult, Int_t iZvtx) const;
152 AliEvtPool *GetEventPool(Int_t centVal, Double_t zvtxVal) const;
153 AliEvtPool *GetEventPool(Double_t centVal, Double_t zvtxVal) const;
155 Int_t InitEventPools(Int_t depth,
156 Int_t nmultbins, Double_t *multbins,
157 Int_t nzvtxbins, Double_t *zvtxbins);
158 void SetTargetTrackDepth(Int_t d) { fTargetTrackDepth = d;}
159 Int_t UpdatePools(MiniEvent*);
160 void SetDebug(Bool_t b) { fDebug = b; }
163 Int_t fDebug; // If 1 then debug on
164 Int_t fNMultBins; // number mult bins
165 Int_t fNZvtxBins; // number vertex bins
166 vector< vector<AliEvtPool*> > fEvPool; // pool in bins of [fMultBin][fZvtxBin]
167 Int_t fTargetTrackDepth; // Required track size, same for all pools.
169 ClassDef(AliEvtPoolManager,1)