2 // *** Class AliRsnPair ***
4 // "Core" method for defining the work on a pari of particles.
5 // For one analysis, one must setup one of this for each pair he wants to analyze,
6 // adding to it all analysis which he desires to do.
7 // Here he defines the cuts, and the particle types and charges, and can add
8 // functions which do different operations on the same pair, and some binning
9 // with respect to some kinematic variables (eta, momentum)
11 // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
12 // M. Vala (email: martin.vala@cern.ch)
15 #include <Riostream.h>
16 #include <TObjArray.h>
20 #include "AliRsnFunction.h"
22 #include "AliRsnPair.h"
26 //_____________________________________________________________________________
27 AliRsnPair::AliRsnPair(EPairType type, AliRsnPairDef *def) :
31 fPIDMethod(AliRsnDaughter::kRealistic),
34 fFunctions("AliRsnFunction", 0),
39 // Default constructor
41 AliDebug(AliLog::kDebug+2,"<-");
42 AliDebug(AliLog::kDebug+2,"->");
45 //_____________________________________________________________________________
46 AliRsnPair::~AliRsnPair()
51 AliDebug(AliLog::kDebug+2,"<-");
52 AliDebug(AliLog::kDebug+2,"->");
55 //_____________________________________________________________________________
56 void AliRsnPair::SetUp(EPairType type)
59 // Sets up flag values by the pair types
61 AliDebug(AliLog::kDebug+2,"<-");
64 SetAllFlags(AliRsnDaughter::kNoPID, kFALSE);
67 SetAllFlags(AliRsnDaughter::kNoPID, kTRUE);
70 SetAllFlags(AliRsnDaughter::kRealistic, kFALSE);
72 case kRealisticPIDMix:
73 SetAllFlags(AliRsnDaughter::kRealistic, kTRUE);
76 SetAllFlags (AliRsnDaughter::kPerfect, kFALSE);
79 SetAllFlags (AliRsnDaughter::kPerfect, kTRUE);
82 AliWarning("Wrong type selected: setting up for realistic PID - no mixing.");
83 SetAllFlags(AliRsnDaughter::kRealistic, kFALSE);
86 AliDebug(AliLog::kDebug+2,"->");
89 //_____________________________________________________________________________
90 void AliRsnPair::Print(Option_t* /*option*/) const
93 // Prints info about pair
95 AliDebug(AliLog::kDebug+2,"<-");
96 AliInfo(Form("%s", GetPairHistTitle(0x0).Data()));
97 AliInfo(Form("PDG %d %d", AliPID::ParticleCode(fPairDef->GetType(0)),
98 AliPID::ParticleCode(fPairDef->GetType(1))));
99 AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1)));
100 AliInfo(Form("Number of functions %d", fFunctions.GetEntries()));
102 switch (fPIDMethod) {
103 case AliRsnDaughter::kNoPID:
104 AliInfo("PID method: none");
106 case AliRsnDaughter::kRealistic:
107 AliInfo("PID method: realistic");
109 case AliRsnDaughter::kPerfect:
110 AliInfo("PID method: perfect");
113 AliInfo("PID method: undefined");
115 AliDebug(AliLog::kDebug+2,"->");
118 //_____________________________________________________________________________
119 void AliRsnPair::LoopPair
120 (AliRsnPIDIndex *pidIndex1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndex2, AliRsnEvent *ev2)
123 // Prepare the loop for computation of functions.
124 // Each PIDIndex is used to retrieve the appropriate array of indexes
125 // of the tracks to be used in each event.
126 // In case of single-event analysis, only the first two arguments are used
127 // and both arrays are taken from the same PIDIndex and will loop on the same event
128 // In case of mixing, all arguments are used, and first set of tracks will be found
129 // in the first event with the first PIDIndex, and the second set of tracks will
130 // be found in second event with second PIDIndex.
133 AliDebug(AliLog::kDebug+2,"<-");
138 if (fPIDMethod == AliRsnDaughter::kNoPID)
140 AliDebug(AliLog::kDebug+2, Form("Returning indexes of with NO PID (%d) ...", fPIDMethod));
141 a1 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(0), AliPID::kUnknown);
142 if (pidIndex2 && ev2)
143 a2 = pidIndex2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), AliPID::kUnknown);
145 a2 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), AliPID::kUnknown);
149 AliDebug(AliLog::kDebug+2, Form("Returning indexes of with PID (%d) ...", fPIDMethod));
150 a1 = pidIndex1->GetTracksArray(fPIDMethod,fPairDef->GetCharge(0), (AliPID::EParticleType)fPairDef->GetType(0));
151 if (pidIndex2 && ev2)
152 a2 = pidIndex2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), (AliPID::EParticleType)fPairDef->GetType(1));
154 a2 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), (AliPID::EParticleType)fPairDef->GetType(1));
157 LoopPair(a1, a2, ev1, ev2);
159 AliDebug(AliLog::kDebug+2,"->");
162 //_____________________________________________________________________________
163 void AliRsnPair::LoopPair(TArrayI *a1, TArrayI *a2, AliRsnEvent *ev1, AliRsnEvent *ev2)
166 // Loop on all pairs of tracks of the defined types/charges,
167 // using the arrays of indexes and the events containing them.
168 // This method is private, for safety reasons.
170 AliDebug(AliLog::kDebug+2,"<-");
171 if (!ev1) {AliError(Form("ev1 is %p. skipping LoopPair() ...",ev1))return;}
172 AliDebug(AliLog::kDebug+1,"ev1 is OK ...");
177 AliDebug(AliLog::kDebug, "ev2 is null and fIsMixed is true. Skipping ...");
183 if (!a1) {AliDebug(AliLog::kDebug, "No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;}
184 if (!a2) {AliDebug(AliLog::kDebug, "No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;}
186 AliDebug(AliLog::kDebug+1,Form("a1=%d a2=%d",a1->GetSize(),a2->GetSize()));
187 if (a1->GetSize()<=0) {AliDebug(AliLog::kDebug, "Size of TArrayI 1 is 0 or less ..."); return;}
188 if (a2->GetSize()<=0) {AliDebug(AliLog::kDebug, "Size of TArrayI 2 is 0 or less ..."); return;}
192 if (!CutPass(ev1) || !CutPass(ev2)) return;
193 AliDebug(AliLog::kDebug+1,"Event cut passed...");
194 AliRsnDaughter::SetPIDMethod(fPIDMethod);
195 AliRsnFunction *fcn = 0;
197 Bool_t isLikeSign = fPairDef->IsLikeSign();
200 for (Int_t i = 0; i < a1->GetSize(); i++) {
202 ev1->SetDaughter(fTrack1, a1->At(i));
203 if (!fTrack1.IsOK()) continue;
204 AliDebug(AliLog::kDebug+1,"daughter1 is OK ...");
206 if (!CutPass(&fTrack1)) continue;
207 AliDebug(AliLog::kDebug+1,"daughter1 cut passed ...");
208 // check starting index for searching the event:
209 // for like-sign pairs we avoid duplicating the pairs
210 if (isLikeSign) startj = i+1; else startj = 0;
211 // loop on event for all track #2 to be combined with the found track #1
212 for (j = startj; j < a2->GetSize(); j++) {
213 ev2->SetDaughter(fTrack2, a2->At(j));
214 if (!fTrack2.IsOK()) continue;
215 AliDebug(AliLog::kDebug+1,"daughter2 is OK ...");
217 if (!CutPass(&fTrack2)) continue;
218 AliDebug(AliLog::kDebug+1,"daughter2 cut passed ...");
220 fPairParticle.SetPair(&fTrack1, &fTrack2);
223 if (!CutPass(&fPairParticle)) continue;
224 AliDebug(AliLog::kDebug+1, "pairParticle cut passed");
226 // pairParticle.PrintInfo();
228 // fill all histograms
229 TObjArrayIter nextFcn(&fFunctions);
230 while ( (fcn = (AliRsnFunction*)nextFcn()) ) {
231 fcn->SetPairDef(fPairDef);
232 fcn->SetPair(&fPairParticle);
238 AliDebug(AliLog::kDebug+2,"->");
241 //_____________________________________________________________________________
242 TList * AliRsnPair::GenerateHistograms(TString prefix)
245 // Generates needed histograms, giving them a name based on
246 // the flags defined here, on the pair definition, and attaches
247 // a prefix to it, according to the argument.
249 // All generated histograms are stored into the output TList.
251 AliDebug(AliLog::kDebug+2,"<-");
252 TList *list = new TList();
253 list->SetName(GetPairHistName(0x0).Data());
255 Char_t hName[255], hTitle[255];
256 //AliRsnFunction *fcn = 0;
257 AliRsnFunction *fcn = 0;
258 for (Int_t i=0;i< fFunctions.GetEntries();i++) {
259 fcn = (AliRsnFunction*)fFunctions.At(i);
260 sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data());
261 sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data());
262 //TList *histos = fcn->Init(hName, hTitle);
263 list->Add(fcn->CreateHistogram(hName, hTitle));
267 cout << "PRINTING LIST" << endl;
269 AliDebug(AliLog::kDebug+2,"->");
275 //_____________________________________________________________________________
276 TString AliRsnPair::GetPairTypeName(EPairType type) const
279 // Returns type name, made with particle names ant chosen PID
281 AliDebug(AliLog::kDebug+2,"<-");
282 AliDebug(AliLog::kDebug+2,"->");
284 case kNoPID : return ("NOPID_");break;
285 case kNoPIDMix : return ("NOPIDMIX_");break;
286 case kRealisticPID : return ("REALISTIC_");break;
287 case kRealisticPIDMix : return ("REALISTICMIX_");break;
288 case kPerfectPID : return ("PERFECT_");break;
289 case kPerfectPIDMix : return ("PERFECTMIX_");break;
291 AliWarning("Unrecognized value of EPairTypeName argument");
298 //_____________________________________________________________________________
299 TString AliRsnPair::GetPairName() const
304 AliDebug(AliLog::kDebug+2,"<-");
306 sName += GetPairTypeName(fPairType);
307 sName += fPairDef->GetPairName();
308 AliDebug(AliLog::kDebug+2,"->");
312 //_____________________________________________________________________________
313 TString AliRsnPair::GetPairHistName(AliRsnFunction *fcn, TString text) const
316 // Returns definitive histogram name
318 AliDebug(AliLog::kDebug+2,"<-");
321 sName = fcn->GetName();
324 sName += GetPairName();
326 if (fCutMgr) sName += fCutMgr->GetName();
328 AliDebug(AliLog::kDebug+2,"->");
332 //_____________________________________________________________________________
333 TString AliRsnPair::GetPairHistTitle(AliRsnFunction *fcn, TString text) const
336 // Returns definitive histogram title
338 AliDebug(AliLog::kDebug+2,"<-");
341 sTitle = fcn->GetTitle();
344 sTitle += GetPairName();
346 if (fCutMgr) sTitle += fCutMgr->GetTitle();
348 AliDebug(AliLog::kDebug+2,"->");
352 //_____________________________________________________________________________
353 void AliRsnPair::AddFunction(AliRsnFunction *fcn)
356 // Adds a new computing function
358 AliDebug(AliLog::kDebug+2,"<-");
359 Int_t size = fFunctions.GetEntries();
360 new (fFunctions[size]) AliRsnFunction(*fcn);
361 AliDebug(AliLog::kDebug+2,"->");
365 //_____________________________________________________________________________
366 void AliRsnPair::AddFunction(AliRsnFunctionDef *fcn)
369 // Adds a new computing function
371 AliDebug(AliLog::kDebug+2,"<-");
372 Int_t size = fFunctions.GetEntries();
373 new (fFunctions[size]) AliRsnFunctionNew(fcn);
374 AliDebug(AliLog::kDebug+2,"->");
378 //________________________________________________________________________________________
379 Bool_t AliRsnPair::CutPass(AliRsnDaughter *d)
382 // Check if the AliRsnDaughter argument pass its cuts.
383 // If the cut data member is not initialized for it, returns kTRUE.
385 AliDebug(AliLog::kDebug+2,"<-AliRsnDaughter");
386 AliDebug(AliLog::kDebug+2,"->");
387 if (!fCutMgr) return kTRUE;
388 else return fCutMgr->IsSelected(AliRsnCut::kParticle, d);
391 //________________________________________________________________________________________
392 Bool_t AliRsnPair::CutPass(AliRsnPairParticle *p)
395 // Check if the AliRsnPairParticle argument pass its cuts.
396 // If the cut data member is not initialized for it, returns kTRUE.
398 AliDebug(AliLog::kDebug+2,"<-AliRsnPairParticle");
399 AliDebug(AliLog::kDebug+2,"->");
400 if (!fCutMgr) return kTRUE;
401 else return fCutMgr->IsSelected(AliRsnCut::kPair, p);
404 //________________________________________________________________________________________
405 Bool_t AliRsnPair::CutPass(AliRsnEvent *e)
408 // Check if the AliRsnEvent argument pass its cuts.
409 // If the cut data member is not initialized for it, returns kTRUE.
411 AliDebug(AliLog::kDebug+2,"<-AliRsnEvent");
412 AliDebug(AliLog::kDebug+2,"->");
413 if (!fCutMgr) return kTRUE;
414 else return fCutMgr->IsSelected(AliRsnCut::kEvent, e);