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),
40 // Default constructor
42 AliDebug(AliLog::kDebug+2,"<-");
43 AliDebug(AliLog::kDebug+2,"->");
46 //_____________________________________________________________________________
47 AliRsnPair::~AliRsnPair()
52 AliDebug(AliLog::kDebug+2,"<-");
53 AliDebug(AliLog::kDebug+2,"->");
56 //_____________________________________________________________________________
57 void AliRsnPair::SetUp(EPairType type)
60 // Sets up flag values by the pair types
62 AliDebug(AliLog::kDebug+2,"<-");
65 SetAllFlags(AliRsnDaughter::kNoPID, kFALSE);
68 SetAllFlags(AliRsnDaughter::kNoPID, kTRUE);
71 SetAllFlags(AliRsnDaughter::kRealistic, kFALSE);
73 case kRealisticPIDMix:
74 SetAllFlags(AliRsnDaughter::kRealistic, kTRUE);
77 SetAllFlags (AliRsnDaughter::kPerfect, kFALSE);
80 SetAllFlags (AliRsnDaughter::kPerfect, kTRUE);
83 AliWarning("Wrong type selected: setting up for realistic PID - no mixing.");
84 SetAllFlags(AliRsnDaughter::kRealistic, kFALSE);
87 AliDebug(AliLog::kDebug+2,"->");
90 //_____________________________________________________________________________
91 void AliRsnPair::Print(Option_t* /*option*/) const
94 // Prints info about pair
96 AliDebug(AliLog::kDebug+2,"<-");
97 AliInfo(Form("%s", GetPairHistTitle(0x0).Data()));
98 AliInfo(Form("PDG %d %d", AliPID::ParticleCode(fPairDef->GetType(0)),
99 AliPID::ParticleCode(fPairDef->GetType(1))));
100 AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1)));
101 AliInfo(Form("Number of functions %d", fFunctions.GetEntries()));
103 switch (fPIDMethod) {
104 case AliRsnDaughter::kNoPID:
105 AliInfo("PID method: none");
107 case AliRsnDaughter::kRealistic:
108 AliInfo("PID method: realistic");
110 case AliRsnDaughter::kPerfect:
111 AliInfo("PID method: perfect");
114 AliInfo("PID method: undefined");
116 AliDebug(AliLog::kDebug+2,"->");
119 //_____________________________________________________________________________
120 void AliRsnPair::LoopPair
121 (AliRsnPIDIndex *pidIndex1, AliRsnEvent *ev1, AliRsnPIDIndex *pidIndex2, AliRsnEvent *ev2)
124 // Prepare the loop for computation of functions.
125 // Each PIDIndex is used to retrieve the appropriate array of indexes
126 // of the tracks to be used in each event.
127 // In case of single-event analysis, only the first two arguments are used
128 // and both arrays are taken from the same PIDIndex and will loop on the same event
129 // In case of mixing, all arguments are used, and first set of tracks will be found
130 // in the first event with the first PIDIndex, and the second set of tracks will
131 // be found in second event with second PIDIndex.
134 AliDebug(AliLog::kDebug+2,"<-");
139 if (fPIDMethod == AliRsnDaughter::kNoPID)
141 AliDebug(AliLog::kDebug+2, Form("Returning indexes of with NO PID (%d) ...", fPIDMethod));
142 a1 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(0), AliPID::kUnknown);
143 if (pidIndex2 && ev2)
144 a2 = pidIndex2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), AliPID::kUnknown);
146 a2 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), AliPID::kUnknown);
150 AliDebug(AliLog::kDebug+2, Form("Returning indexes of with PID (%d) ...", fPIDMethod));
151 a1 = pidIndex1->GetTracksArray(fPIDMethod,fPairDef->GetCharge(0), (AliPID::EParticleType)fPairDef->GetType(0));
152 if (pidIndex2 && ev2)
153 a2 = pidIndex2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), (AliPID::EParticleType)fPairDef->GetType(1));
155 a2 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), (AliPID::EParticleType)fPairDef->GetType(1));
158 LoopPair(a1, a2, ev1, ev2);
160 AliDebug(AliLog::kDebug+2,"->");
163 //_____________________________________________________________________________
164 void AliRsnPair::LoopPair(TArrayI *a1, TArrayI *a2, AliRsnEvent *ev1, AliRsnEvent *ev2)
167 // Loop on all pairs of tracks of the defined types/charges,
168 // using the arrays of indexes and the events containing them.
169 // This method is private, for safety reasons.
171 AliDebug(AliLog::kDebug+2,"<-");
172 if (!ev1) {AliError(Form("ev1 is %p. skipping LoopPair() ...",ev1))return;}
173 AliDebug(AliLog::kDebug+1,"ev1 is OK ...");
178 AliDebug(AliLog::kDebug, "ev2 is null and fIsMixed is true. Skipping ...");
184 if (!a1) {AliDebug(AliLog::kDebug, "No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;}
185 if (!a2) {AliDebug(AliLog::kDebug, "No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;}
187 AliDebug(AliLog::kDebug+1,Form("a1=%d a2=%d",a1->GetSize(),a2->GetSize()));
188 if (a1->GetSize()<=0) {AliDebug(AliLog::kDebug, "Size of TArrayI 1 is 0 or less ..."); return;}
189 if (a2->GetSize()<=0) {AliDebug(AliLog::kDebug, "Size of TArrayI 2 is 0 or less ..."); return;}
193 if (!CutPass(ev1) || !CutPass(ev2)) return;
194 AliDebug(AliLog::kDebug+1,"Event cut passed...");
195 AliRsnDaughter::SetPIDMethod(fPIDMethod);
196 AliRsnFunction *fcn = 0;
198 Bool_t isLikeSign = fPairDef->IsLikeSign();
201 for (Int_t i = 0; i < a1->GetSize(); i++) {
203 ev1->SetDaughter(fTrack1, a1->At(i));
204 if (!fTrack1.IsOK()) continue;
205 AliDebug(AliLog::kDebug+1,"daughter1 is OK ...");
207 if (!CutPass(&fTrack1)) continue;
208 AliDebug(AliLog::kDebug+1,"daughter1 cut passed ...");
209 // check starting index for searching the event:
210 // for like-sign pairs we avoid duplicating the pairs
211 if (isLikeSign) startj = i+1; else startj = 0;
212 // loop on event for all track #2 to be combined with the found track #1
213 for (j = startj; j < a2->GetSize(); j++) {
214 ev2->SetDaughter(fTrack2, a2->At(j));
215 if (!fTrack2.IsOK()) continue;
216 AliDebug(AliLog::kDebug+1,"daughter2 is OK ...");
218 if (!CutPass(&fTrack2)) continue;
219 AliDebug(AliLog::kDebug+1,"daughter2 cut passed ...");
221 fPairParticle.SetPair(&fTrack1, &fTrack2);
224 if (!CutPass(&fPairParticle)) continue;
225 AliDebug(AliLog::kDebug+1, "pairParticle cut passed");
227 // pairParticle.PrintInfo();
229 // fill all histograms
230 TObjArrayIter nextFcn(&fFunctions);
231 while ( (fcn = (AliRsnFunction*)nextFcn()) ) {
232 fcn->SetPairDef(fPairDef);
233 fcn->SetPair(&fPairParticle);
239 AliDebug(AliLog::kDebug+2,"->");
242 //_____________________________________________________________________________
243 TList * AliRsnPair::GenerateHistograms(TString prefix)
246 // Generates needed histograms, giving them a name based on
247 // the flags defined here, on the pair definition, and attaches
248 // a prefix to it, according to the argument.
250 // All generated histograms are stored into the output TList.
252 AliDebug(AliLog::kDebug+2,"<-");
253 TList *list = new TList();
254 list->SetName(GetPairHistName(0x0).Data());
256 Char_t hName[255], hTitle[255];
257 //AliRsnFunction *fcn = 0;
258 AliRsnFunction *fcn = 0;
259 for (Int_t i=0;i< fFunctions.GetEntries();i++) {
260 fcn = (AliRsnFunction*)fFunctions.At(i);
261 sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data());
262 sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data());
263 //TList *histos = fcn->Init(hName, hTitle);
264 list->Add(fcn->CreateHistogram(hName, hTitle));
268 cout << "PRINTING LIST" << endl;
270 AliDebug(AliLog::kDebug+2,"->");
276 //_____________________________________________________________________________
277 TString AliRsnPair::GetPairTypeName(EPairType type) const
280 // Returns type name, made with particle names ant chosen PID
282 AliDebug(AliLog::kDebug+2,"<-");
283 AliDebug(AliLog::kDebug+2,"->");
285 case kNoPID : return ("NOPID_");break;
286 case kNoPIDMix : return ("NOPIDMIX_");break;
287 case kRealisticPID : return ("REALISTIC_");break;
288 case kRealisticPIDMix : return ("REALISTICMIX_");break;
289 case kPerfectPID : return ("PERFECT_");break;
290 case kPerfectPIDMix : return ("PERFECTMIX_");break;
292 AliWarning("Unrecognized value of EPairTypeName argument");
299 //_____________________________________________________________________________
300 TString AliRsnPair::GetPairName() const
305 AliDebug(AliLog::kDebug+2,"<-");
307 sName += GetPairTypeName(fPairType);
308 sName += fPairDef->GetPairName();
309 AliDebug(AliLog::kDebug+2,"->");
313 //_____________________________________________________________________________
314 TString AliRsnPair::GetPairHistName(AliRsnFunction *fcn, TString text) const
317 // Returns definitive histogram name
319 AliDebug(AliLog::kDebug+2,"<-");
322 sName = fcn->GetName();
325 sName += GetPairName();
327 if (fCutMgr) sName += fCutMgr->GetName();
329 AliDebug(AliLog::kDebug+2,"->");
333 //_____________________________________________________________________________
334 TString AliRsnPair::GetPairHistTitle(AliRsnFunction *fcn, TString text) const
337 // Returns definitive histogram title
339 AliDebug(AliLog::kDebug+2,"<-");
342 sTitle = fcn->GetTitle();
345 sTitle += GetPairName();
347 if (fCutMgr) sTitle += fCutMgr->GetTitle();
349 AliDebug(AliLog::kDebug+2,"->");
353 //_____________________________________________________________________________
354 void AliRsnPair::AddFunction(AliRsnFunction *fcn)
357 // Adds a new computing function
359 AliDebug(AliLog::kDebug+2,"<-");
360 Int_t size = fFunctions.GetEntries();
361 new (fFunctions[size]) AliRsnFunction(*fcn);
362 AliDebug(AliLog::kDebug+2,"->");
366 //_____________________________________________________________________________
367 void AliRsnPair::AddFunction(AliRsnFunctionDef *fcn)
370 // Adds a new computing function
372 AliDebug(AliLog::kDebug+2,"<-");
373 Int_t size = fFunctions.GetEntries();
374 new (fFunctions[size]) AliRsnFunctionNew(fcn);
375 AliDebug(AliLog::kDebug+2,"->");
379 //________________________________________________________________________________________
380 Bool_t AliRsnPair::CutPass(AliRsnDaughter *d)
383 // Check if the AliRsnDaughter argument pass its cuts.
384 // If the cut data member is not initialized for it, returns kTRUE.
386 AliDebug(AliLog::kDebug+2,"<-AliRsnDaughter");
387 AliDebug(AliLog::kDebug+2,"->");
388 if (!fCutMgr) return kTRUE;
389 else return fCutMgr->IsSelected(AliRsnCut::kParticle, d);
392 //________________________________________________________________________________________
393 Bool_t AliRsnPair::CutPass(AliRsnPairParticle *p)
396 // Check if the AliRsnPairParticle argument pass its cuts.
397 // If the cut data member is not initialized for it, returns kTRUE.
399 AliDebug(AliLog::kDebug+2,"<-AliRsnPairParticle");
400 AliDebug(AliLog::kDebug+2,"->");
401 if (!fCutMgr) return kTRUE;
402 else return fCutMgr->IsSelected(AliRsnCut::kPair, p);
405 //________________________________________________________________________________________
406 Bool_t AliRsnPair::CutPass(AliRsnEvent *e)
409 // Check if the AliRsnEvent argument pass its cuts.
410 // If the cut data member is not initialized for it, returns kTRUE.
412 AliDebug(AliLog::kDebug+2,"<-AliRsnEvent");
413 AliDebug(AliLog::kDebug+2,"->");
414 if (!fCutMgr) return kTRUE;
415 else return fCutMgr->IsSelected(AliRsnCut::kEvent, e);