1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //-------------------------------------------------------------------------
17 // Class AliRsnManager
18 //-------------------------------------------------------------------------
19 // This class is a manager to process one or more pair analysis with a
20 // given event sample, specified as a TTree passed to this object.
21 // Each single pair analysis must be defined with its specifications, like
22 // histogram binning, cuts and everything else.
23 // This class utiliy consists in defining a unique event sample which is
24 // used for all pairs analysis, and all kinds of event mixing (if required).
25 // All histograms computed in a single execution, are then saved into a file.
26 // This object contains a two TObjArray's:
27 // - one to contain single event pair analysis objects (signal, like-sign)
28 // - one to contain all event-mixing pair analysis objects
29 // When a new pair is added, it must be then specified in what container it
30 // must be placed, in order to avoid meaningless results.
32 // author: A. Pulvirenti
33 // email : alberto.pulvirenti@ct.infn.it
34 //-------------------------------------------------------------------------
40 #include <TClonesArray.h>
44 #include "AliRsnEvent.h"
45 #include "AliRsnPair.h"
46 #include "AliRsnManager.h"
48 ClassImp(AliRsnManager)
50 //_____________________________________________________________________________
51 AliRsnManager::AliRsnManager() :
70 //_____________________________________________________________________________
71 void AliRsnManager::Clear(Option_t* /*option*/)
85 if (fBuffer) delete fBuffer;
87 fOutputList->Delete();
92 //_____________________________________________________________________________
93 void AliRsnManager::SetQueueSize(Int_t size)
99 fBuffer = new TObjArray(size);
104 //_____________________________________________________________________________
105 void AliRsnManager::AddPair(AliRsnPair *pair)
108 // Add a pair of particle types to be analyzed.
109 // Second argument tells if the added object is for event mixing.
112 Bool_t mixing = pair->IsForMixing();
113 TObjArray* &target = mixing ? fMixPairs : fPairs;
114 if (!target) target = new TObjArray(0);
115 target->AddLast(pair);
117 if (!fOutputList) fOutputList = new TList;
119 fOutputList->Add(pair->GetHistogram());
122 //_____________________________________________________________________________
123 Stat_t AliRsnManager::Process(AliRsnEvent *event)
126 // For each AliRsnPair definition, fills its histogram
127 // taking particles from the passed event.
130 if (!event) return nPairs;
134 AliError("Uninitialized array");
137 if (fPairs->IsEmpty()) {
138 AliError("No pairs defined");
142 AliError("Buffer uninitialized");
146 // create an iterator which run over all pairs
147 TObjArrayIter pairIterator(fPairs);
148 AliRsnPair *pair = 0;
149 while ( (pair = (AliRsnPair*)pairIterator.Next()) ) {
150 nPairs += pair->Process(event, event);
153 // if there are mix pairs, do event mixing
154 if (fMixPairs) Mix(event);
156 // add this event to the queue
158 if (fQueuePos >= fBuffer->GetSize()) fQueuePos = 0;
159 AliRsnEvent *prev = (AliRsnEvent*) fBuffer->At(fQueuePos);
160 if (prev) fBuffer->RemoveAt(fQueuePos);
161 fBuffer->AddAt(event, fQueuePos);
167 //_____________________________________________________________________________
168 Stat_t AliRsnManager::Mix(AliRsnEvent *event)
171 // Performs event mixing.
172 // It takes the array of fMixPairDefs and stores results in fMixHistograms.
173 // First parameter defines how many events must be mixed with each one.
174 // Events to be mixed are chosen using the other parameters:
176 // - multDiffMax defines the maximum allowed difference in particle multiplicity,
177 // a) when last argument is kFALSE (default) the multiplicity comparison is made with respect
178 // to the particles of 'type 2' in the pair
179 // b) when last argument is kTRUE, the multiplicity comparison is made with respect of total
180 // particle multiplicity in the events
182 // - vzDiffMax defines maximum allowed difference in Z coordinate of prim. vertex.
184 // If one wants to exchange the particle types, one has to add both combinations of particles
185 // as different pair defs.
190 AliError("Uninitialized queue");
194 // iterator for pairs
195 TObjArrayIter pairIterator(fMixPairs);
196 AliRsnPair *pair = 0;
198 // iterator for events
199 TObjArrayIter eventIterator(fBuffer);
200 AliRsnEvent *mixed = 0;
202 // loop on array and mix with passed event
203 while ( (mixed = (AliRsnEvent*)eventIterator.Next()) ) {
204 if (!CanBeMixed(event, mixed)) continue;
205 pairIterator.Reset();
206 while ( (pair = (AliRsnPair*)pairIterator.Next()) ) {
207 nPairs += pair->Process(event, mixed);
214 //_____________________________________________________________________________
215 Bool_t AliRsnManager::CanBeMixed(AliRsnEvent *ev1, AliRsnEvent *ev2)
218 // Checks if two events are within the mixing cuts
221 Int_t diffMult = TMath::Abs(ev1->GetMultiplicity() - ev2->GetMultiplicity());
222 Bool_t diffVz = TMath::Abs(ev1->GetPrimaryVertexZ() - ev2->GetPrimaryVertexZ());
223 if (diffMult <= fMixMultCut && diffVz <= fMixVzCut) {