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"
21 #include "AliRsnPairParticle.h"
23 #include "AliRsnPair.h"
27 //_____________________________________________________________________________
28 AliRsnPair::AliRsnPair(EPairType type, AliRsnPairDef *def) :
32 fPIDMethod(AliRsnDaughter::kRealistic),
35 fFunctions("AliRsnFunction", 0)
38 // Default constructor
43 //_____________________________________________________________________________
44 AliRsnPair::~AliRsnPair()
51 //_____________________________________________________________________________
52 void AliRsnPair::SetUp(EPairType type)
55 // Sets up flag values by the pair types
61 SetAllFlags(AliRsnDaughter::kNoPID, kFALSE);
64 SetAllFlags(AliRsnDaughter::kNoPID, kTRUE);
67 SetAllFlags(AliRsnDaughter::kRealistic, kFALSE);
69 case kRealisticPIDMix:
70 SetAllFlags(AliRsnDaughter::kRealistic, kTRUE);
73 SetAllFlags (AliRsnDaughter::kPerfect, kFALSE);
76 SetAllFlags (AliRsnDaughter::kPerfect, kTRUE);
79 AliWarning("Wrong type selected: setting up for realistic PID - no mixing.");
80 SetAllFlags(AliRsnDaughter::kRealistic, kFALSE);
85 //_____________________________________________________________________________
86 void AliRsnPair::Print(Option_t* /*option*/) const
89 // Prints info about pair
92 AliInfo(Form("%s", GetPairHistTitle(0x0).Data()));
93 AliInfo(Form("PDG %d %d", AliRsnPID::PDGCode(fPairDef->GetType(0)),
94 AliRsnPID::PDGCode(fPairDef->GetType(1))));
95 AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1)));
96 AliInfo(Form("Number of functions %d", fFunctions.GetEntries()));
100 case AliRsnDaughter::kNoPID:
101 AliInfo("PID method: none");
103 case AliRsnDaughter::kRealistic:
104 AliInfo("PID method: realistic");
106 case AliRsnDaughter::kPerfect:
107 AliInfo("PID method: perfect");
110 AliInfo("PID method: undefined");
114 //_____________________________________________________________________________
115 void AliRsnPair::ProcessPair(AliRsnEvent *ev1, AliRsnEvent *ev2)
118 // Fills the functions' histograms using tracks from passed events.
119 // What tracks are taken in each event depend from the order of
120 // track types defined in the AliRsnPairDef for this object:
121 // - tracks of type 0 are the ones stored as pairDef data members with index [0]
122 // ---> taken from first argument (ev1)
123 // - tracks of type 1 are the ones stored as pairDef data members with index [1]
124 // ---> taken from second argument (ev2)
126 // When doing single-event analysis (e.g. signal, like-sign), second argument
127 // can be NULL, and it will be forced to point to the same object of first one.
132 TArrayI *array1 = ev1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(0), fPairDef->GetType(0));
133 TArrayI *array2 = ev2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), fPairDef->GetType(1));
135 LoopPair(ev1, array1, ev2, array2);
138 //_____________________________________________________________________________
139 void AliRsnPair::LoopPair
140 (AliRsnEvent * ev1, TArrayI * a1, AliRsnEvent * ev2, TArrayI * a2)
143 // Loop on all pairs of tracks of the defined types/charges,
144 // using the arrays of indexes and the events containing them.
145 // This method is private, for safety reasons.
148 if (!a1) {AliDebug(4, "No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;}
149 if (!a2) {AliDebug(4, "No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;}
152 if (!CutPass(ev1) || !CutPass(ev2)) return;
154 AliRsnDaughter::SetPIDMethod(fPIDMethod);
155 AliRsnDaughter *daughter1 = 0;
156 AliRsnDaughter *daughter2 = 0;
157 AliRsnFunction *fcn = 0;
158 //AliRsnFunctionNew *fnew = 0;
160 Bool_t isLikeSign = fPairDef->IsLikeSign();
163 for (Int_t i = 0; i < a1->GetSize(); i++)
166 daughter1 = (AliRsnDaughter *) ev1->GetTrack(a1->At(i));
167 if (!daughter1) continue;
168 // assign PID and mass of particle of type #1
169 daughter1->AssignPID(fPairDef->GetType(0));
171 if (!CutPass(daughter1)) continue;
174 // check starting index for searching the event:
175 // for like-sign pairs we avoid duplicating the pairs
176 if (isLikeSign) startj = i+1; else startj = 0;
177 // AliInfo(Form("%d",startj));
178 // loop on event for all track #2 to be combined with the found track #1
179 for (j = startj; j < a2->GetSize(); j++)
181 daughter2 = (AliRsnDaughter *) ev2->GetTrack(a2->At(j));
182 if (!daughter2) continue;
183 // assign PID and mass of particle of type #2
184 daughter2->AssignPID(fPairDef->GetType(0));
186 if (!CutPass(daughter2)) continue;
188 AliRsnPairParticle pairParticle;
189 pairParticle.SetPair(daughter1, daughter2);
191 if (!CutPass(&pairParticle)) continue;
192 // fill all histograms
193 TObjArrayIter nextFcn(&fFunctions);
194 while ( (fcn = (AliRsnFunction*)nextFcn()) ) {
195 fcn->Fill(&pairParticle, fPairDef);
198 while ( (fnew = (AliRsnFunction*)nextFcn()) ) {
199 fnew->Fill(&pairParticle, fPairDef);
206 //_____________________________________________________________________________
207 TList * AliRsnPair::GenerateHistograms(TString prefix)
210 // Generates needed histograms, giving them a name based on
211 // the flags defined here, on the pair definition, and attaches
212 // a prefix to it, according to the argument.
214 // All generated histograms are stored into the output TList.
217 TList *list = new TList();
218 list->SetName(GetPairHistName(0x0).Data());
220 Char_t hName[255], hTitle[255];
221 AliRsnFunction *fcn = 0;
222 for (Int_t i=0;i< fFunctions.GetEntries();i++)
224 fcn = (AliRsnFunction*)fFunctions.At(i);
225 sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data());
226 sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data());
227 TList *histos = fcn->Init(hName, hTitle);
235 //_____________________________________________________________________________
236 void AliRsnPair::GenerateHistograms(TString prefix, TList *tgt)
239 // Generates needed histograms, giving them a name based on
240 // the flags defined here, on the pair definition, and attaches
241 // a prefix to it, according to the argument.
243 // All generated histograms are stored into the TList passed as argument
247 AliError("NULL target list!");
251 Char_t hName[255], hTitle[255];
252 AliRsnFunction *fcn = 0;
253 for (Int_t i=0;i< fFunctions.GetEntries();i++)
255 fcn = (AliRsnFunction*)fFunctions.At(i);
256 sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data());
257 sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data());
258 fcn->Init(hName, hTitle, tgt);
262 //_____________________________________________________________________________
263 TString AliRsnPair::GetPairTypeName(EPairType type) const
266 // Returns type name, made with particle names ant chosen PID
271 case kNoPID : return ("NOPID_");break;
272 case kNoPIDMix : return ("NOPIDMIX_");break;
273 case kRealisticPID : return ("REALISTIC_");break;
274 case kRealisticPIDMix : return ("REALISTICMIX_");break;
275 case kPerfectPID : return ("PERFECT_");break;
276 case kPerfectPIDMix : return ("PERFECTMIX_");break;
278 AliWarning("Unrecognized value of EPairTypeName argument");
285 //_____________________________________________________________________________
286 TString AliRsnPair::GetPairName() const
293 sName += GetPairTypeName(fPairType);
294 sName += fPairDef->GetPairName();
299 //_____________________________________________________________________________
300 TString AliRsnPair::GetPairHistName(AliRsnFunction *fcn, TString text) const
303 // Returns definitive histogram name
309 sName = fcn->GetFcnName();
312 sName += GetPairName();
314 if (fCutMgr) sName += fCutMgr->GetName();
320 //_____________________________________________________________________________
321 TString AliRsnPair::GetPairHistTitle(AliRsnFunction *fcn, TString text) const
324 // Returns definitive histogram title
330 sTitle = fcn->GetFcnTitle();
333 sTitle += GetPairName();
335 if (fCutMgr) sTitle += fCutMgr->GetTitle();
341 //_____________________________________________________________________________
342 void AliRsnPair::AddFunction(AliRsnFunction *fcn)
345 // Adds a new computing function
348 Int_t size = fFunctions.GetEntries();
349 new (fFunctions[size]) AliRsnFunction(*fcn);
353 //_____________________________________________________________________________
354 void AliRsnPair::AddFunction(AliRsnFunctionDef *fcn)
357 // Adds a new computing function
360 Int_t size = fFunctions.GetEntries();
361 new (fFunctions[size]) AliRsnFunctionNew(fcn);
365 //________________________________________________________________________________________
366 Bool_t AliRsnPair::CutPass(AliRsnDaughter *d)
369 // Check if the AliRsnDaughter argument pass its cuts.
370 // If the cut data member is not initialized for it, returns kTRUE.
373 if (!fCutMgr) return kTRUE;
374 else return fCutMgr->IsSelected(AliRsnCut::kParticle, d);
377 //________________________________________________________________________________________
378 Bool_t AliRsnPair::CutPass(AliRsnPairParticle *p)
381 // Check if the AliRsnPairParticle argument pass its cuts.
382 // If the cut data member is not initialized for it, returns kTRUE.
385 if (!fCutMgr) return kTRUE;
386 else return fCutMgr->IsSelected(AliRsnCut::kPair, p);
389 //________________________________________________________________________________________
390 Bool_t AliRsnPair::CutPass(AliRsnEvent *e)
393 // Check if the AliRsnEvent argument pass its cuts.
394 // If the cut data member is not initialized for it, returns kTRUE.
397 if (!fCutMgr) return kTRUE;
398 else return fCutMgr->IsSelected(AliRsnCut::kEvent, e);