]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTAnalysis.cxx
Compilation warnings removed
[u/mrichter/AliRoot.git] / HBTAN / AliHBTAnalysis.cxx
CommitLineData
1b446896 1#include "AliHBTAnalysis.h"
1b446896 2#include "AliHBTRun.h"
dc2c3f36 3#include "AliHBTEvent.h"
1b446896 4#include "AliHBTReader.h"
5#include "AliHBTParticle.h"
6#include "AliHBTParticleCut.h"
7#include "AliHBTPair.h"
8#include "AliHBTPairCut.h"
9#include "AliHBTFunction.h"
5c58441a 10#include "AliHBTMonitorFunction.h"
81b7b887 11
dc2c3f36 12#include <TBenchmark.h>
1b446896 13#include <TList.h>
14
e4f2b1da 15//_________________________________________________________
16///////////////////////////////////////////////////////////
17//
18//Central Object Of HBTAnalyser:
19//This class performs main looping within HBT Analysis
20//User must plug a reader of Type AliHBTReader
21//User plugs in coorelation and monitor functions
22//as well as monitor functions
23//
24//HBT Analysis Tool, which is integral part of AliRoot,
25//ALICE Off-Line framework:
26//
27//Piotr.Skowronski@cern.ch
28//more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
29//
30//_________________________________________________________
31
1b446896 32ClassImp(AliHBTAnalysis)
33
34const UInt_t AliHBTAnalysis::fgkFctnArraySize = 100;
81b7b887 35const UInt_t AliHBTAnalysis::fgkDefaultMixingInfo = 1000;
36const Int_t AliHBTAnalysis::fgkDefaultBufferSize = 5;
37
38AliHBTAnalysis::AliHBTAnalysis():
2dc7203b 39 fReader(0x0),
40 fNTrackFunctions(0),
41 fNParticleFunctions(0),
42 fNParticleAndTrackFunctions(0),
43 fNTrackMonitorFunctions(0),
44 fNParticleMonitorFunctions(0),
45 fNParticleAndTrackMonitorFunctions(0),
46 fBufferSize(2),
47 fDisplayMixingInfo(fgkDefaultMixingInfo),
48 fIsOwner(kFALSE)
1b446896 49 {
2dc7203b 50//default constructor
27b3fe5d 51 fTrackFunctions = new AliHBTOnePairFctn* [fgkFctnArraySize];
52 fParticleFunctions = new AliHBTOnePairFctn* [fgkFctnArraySize];
53 fParticleAndTrackFunctions = new AliHBTTwoPairFctn* [fgkFctnArraySize];
1b446896 54
5c58441a 55 fParticleMonitorFunctions = new AliHBTMonOneParticleFctn* [fgkFctnArraySize];
56 fTrackMonitorFunctions = new AliHBTMonOneParticleFctn* [fgkFctnArraySize];
57 fParticleAndTrackMonitorFunctions = new AliHBTMonTwoParticleFctn* [fgkFctnArraySize];
58
1b446896 59 fPairCut = new AliHBTEmptyPairCut();//empty cut - accepts all particles
1b446896 60 }
491d1b5d 61/*************************************************************************************/
1b446896 62
81b7b887 63AliHBTAnalysis::AliHBTAnalysis(const AliHBTAnalysis& in):
2dc7203b 64 fReader(0x0),
65 fNTrackFunctions(0),
66 fNParticleFunctions(0),
67 fNParticleAndTrackFunctions(0),
68 fNTrackMonitorFunctions(0),
69 fNParticleMonitorFunctions(0),
70 fNParticleAndTrackMonitorFunctions(0),
71 fTrackFunctions(0x0),
72 fParticleFunctions(0x0),
73 fParticleAndTrackFunctions(0x0),
74 fParticleMonitorFunctions(0x0),
75 fTrackMonitorFunctions(0x0),
76 fParticleAndTrackMonitorFunctions(0x0),
77 fPairCut(0x0),
78 fBufferSize(fgkDefaultBufferSize),
79 fDisplayMixingInfo(fgkDefaultMixingInfo),
80 fIsOwner(kFALSE)
81b7b887 81 {
2dc7203b 82//copy constructor
81b7b887 83 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
84 }
85/*************************************************************************************/
558f1503 86const AliHBTAnalysis& AliHBTAnalysis::operator=(const AliHBTAnalysis& right)
81b7b887 87 {
2dc7203b 88//operator =
81b7b887 89 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
90 return *this;
91 }
92/*************************************************************************************/
1b446896 93AliHBTAnalysis::~AliHBTAnalysis()
94 {
95 //destructor
96 //note that we do not delete functions itself
97 // they should be deleted by whom where created
98 //we only store pointers, and we use "new" only for pointers array
b70eb506 99 if (fIsOwner)
100 DeleteFunctions();
1b446896 101 delete [] fTrackFunctions;
102 delete [] fParticleFunctions;
103 delete [] fParticleAndTrackFunctions;
104
5c58441a 105 delete [] fParticleMonitorFunctions;
106 delete [] fTrackMonitorFunctions;
107 delete [] fParticleAndTrackMonitorFunctions;
108
1b446896 109 delete fPairCut; // always have an copy of an object - we create we dstroy
110 }
111
112/*************************************************************************************/
e4f2b1da 113
81b7b887 114void AliHBTAnalysis::DeleteFunctions()
115{
e4f2b1da 116 //Deletes all functions added to analysis
81b7b887 117 UInt_t ii;
118 for(ii = 0;ii<fNParticleFunctions;ii++)
119 delete fParticleFunctions[ii];
e4f2b1da 120 fNParticleFunctions = 0;
81b7b887 121
122 for(ii = 0;ii<fNTrackFunctions;ii++)
123 delete fTrackFunctions[ii];
e4f2b1da 124 fNTrackFunctions = 0;
125
81b7b887 126 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
127 delete fParticleAndTrackFunctions[ii];
e4f2b1da 128 fNParticleAndTrackFunctions = 0;
81b7b887 129
130 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
131 delete fParticleMonitorFunctions[ii];
e4f2b1da 132 fNParticleMonitorFunctions = 0;
81b7b887 133
134 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
135 delete fTrackMonitorFunctions[ii];
e4f2b1da 136 fNTrackMonitorFunctions = 0;
81b7b887 137
138 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
139 delete fParticleAndTrackMonitorFunctions[ii];
e4f2b1da 140 fNParticleAndTrackMonitorFunctions = 0;
81b7b887 141}
e4f2b1da 142/*************************************************************************************/
143
144void AliHBTAnalysis::Init()
145{
2dc7203b 146//Initializeation method
147//calls Init for all functions
e4f2b1da 148 UInt_t ii;
149 for(ii = 0;ii<fNParticleFunctions;ii++)
150 fParticleFunctions[ii]->Init();
151
152 for(ii = 0;ii<fNTrackFunctions;ii++)
153 fTrackFunctions[ii]->Init();
154
155 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
156 fParticleAndTrackFunctions[ii]->Init();
157
158 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
159 fParticleMonitorFunctions[ii]->Init();
160
161 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
162 fTrackMonitorFunctions[ii]->Init();
163
164 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
165 fParticleAndTrackMonitorFunctions[ii]->Init();
166}
167/*************************************************************************************/
168
169void AliHBTAnalysis::ResetFunctions()
170{
171//In case fOwner is true, deletes all functions
172//in other case, just set number of analysis to 0
173 if (fIsOwner) DeleteFunctions();
174 else
175 {
176 fNParticleFunctions = 0;
177 fNTrackFunctions = 0;
178 fNParticleAndTrackFunctions = 0;
179 fNParticleMonitorFunctions = 0;
180 fNTrackMonitorFunctions = 0;
181 fNParticleAndTrackMonitorFunctions = 0;
182 }
183}
184/*************************************************************************************/
185
1b446896 186void AliHBTAnalysis::Process(Option_t* option)
187{
188 //default option = "TracksAndParticles"
189 //Main method of the HBT Analysis Package
190 //It triggers reading with the global cut (default is an empty cut)
191 //Than it checks options and data which are read
192 //if everything is OK, then it calls one of the looping methods
193 //depending on tfReaderhe option
194 //These methods differs on what thay are looping on
195 //
196 // METHOD OPTION
197 //--------------------------------------------------------------------
198 //ProcessTracksAndParticles - "TracksAndParticles"
199 // DEFAULT
200 // it loops over both, tracks(reconstructed) and particles(simulated)
201 // all function gethered in all 3 lists are called for each (double)pair
202 //
203 //ProcessTracks - "Tracks"
204 // it loops only on tracks(reconstructed),
205 // functions ONLY from fTrackFunctions list are called
206 //
207 //ProcessParticles - "Particles"
208 // it loops only on particles(simulated),
209 // functions ONLY from fParticleAndTrackFunctions list are called
210 //
211 //
212 if (!fReader)
213 {
01725374 214 Error("Process","The reader is not set");
1b446896 215 return;
216 }
217
1b446896 218 const char *oT = strstr(option,"Tracks");
219 const char *oP = strstr(option,"Particles");
220
dc2c3f36 221 Bool_t nonid = IsNonIdentAnalysis();
222
1b446896 223 if(oT && oP)
224 {
225 if (fReader->GetNumberOfPartEvents() <1)
226 {
01725374 227 Error("Process","There is no Particles. Maybe change the option?");
1b446896 228 return;
229 }
230 if (fReader->GetNumberOfTrackEvents() <1)
231 {
01725374 232 Error("Process","There is no Tracks. Maybe change the option?");
1b446896 233 return;
234 }
235
236 if ( RunCoherencyCheck() )
237 {
01725374 238 Error("Process",
1b446896 239 "Coherency check not passed. Maybe change the option?\n");
240 return;
241 }
2c33acf3 242 Init();
dc2c3f36 243 if (nonid) ProcessTracksAndParticlesNonIdentAnal();
244 else ProcessTracksAndParticles();
1b446896 245 return;
246 }
247
248 if(oT)
249 {
7836ee94 250 if (fReader->GetNumberOfTrackEvents() <1)
251 {
252 Error("Process","There is no data to analyze.");
253 return;
254 }
2c33acf3 255 Init();
dc2c3f36 256 if (nonid) ProcessTracksNonIdentAnal();
257 else ProcessTracks();
1b446896 258 return;
259 }
260
261 if(oP)
262 {
7836ee94 263 if (fReader->GetNumberOfPartEvents() <1)
264 {
265 Error("Process","There is no data to analyze.");
266 return;
267 }
2c33acf3 268 Init();
dc2c3f36 269 if (nonid) ProcessParticlesNonIdentAnal();
270 else ProcessParticles();
1b446896 271 return;
272 }
273
274}
1b446896 275/*************************************************************************************/
491d1b5d 276
1b446896 277void AliHBTAnalysis::ProcessTracksAndParticles()
278{
1b446896 279//In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
280//the loops are splited
281
282
283 AliHBTParticle * part1, * part2;
284 AliHBTParticle * track1, * track2;
285
286 AliHBTEvent * trackEvent, *partEvent;
287 AliHBTEvent * trackEvent2,*partEvent2;
288
289// Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
290
2dc7203b 291 Int_t nev = fReader->GetNumberOfTrackEvents();
1b446896 292
293 /***************************************/
294 /****** Looping same events ********/
295 /****** filling numerators ********/
296 /***************************************/
297 AliHBTPair * trackpair = new AliHBTPair();
298 AliHBTPair * partpair = new AliHBTPair();
491d1b5d 299
300 AliHBTPair * tmptrackpair;//temprary pointers to pairs
301 AliHBTPair * tmppartpair;
81b7b887 302
303 register UInt_t ii;
7a2c8238 304
2dc7203b 305 for (Int_t i = 0;i<nev;i++)
1b446896 306 {
307 partEvent= fReader->GetParticleEvent(i);
308 trackEvent = fReader->GetTrackEvent(i);
309
310 if (!partEvent) continue;
311
312 //N = 0;
313
314 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
315 {
81b7b887 316
317 if ( (j%fDisplayMixingInfo) == 0)
318 Info("ProcessTracksAndParticles",
319 "Mixing particle %d from event %d with particles from event %d",j,i,i);
1b446896 320
321 part1= partEvent->GetParticle(j);
5c58441a 322 track1= trackEvent->GetParticle(j);
81b7b887 323
324 if (fPairCut->GetFirstPartCut()->Pass(part1)) continue;
325
326 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
e4f2b1da 327 fParticleMonitorFunctions[ii]->Process(part1);
81b7b887 328 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
e4f2b1da 329 fTrackMonitorFunctions[ii]->Process(track1);
81b7b887 330 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
e4f2b1da 331 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
5c58441a 332
333 if ( (fNParticleFunctions == 0) && (fNTrackFunctions ==0) && (fNParticleAndTrackFunctions == 0))
334 continue;
335
1b446896 336 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
337 {
338 part2= partEvent->GetParticle(k);
d74e6a27 339 if (part1->GetUID() == part2->GetUID()) continue;
1b446896 340 partpair->SetParticles(part1,part2);
341
5c58441a 342 track2= trackEvent->GetParticle(k);
1b446896 343 trackpair->SetParticles(track1,track2);
344
81b7b887 345 if(fPairCut->Pass(partpair) ) //check pair cut
1b446896 346 { //do not meets crietria of the pair cut, try with swaped pairs
81b7b887 347 if( fPairCut->Pass(partpair->GetSwapedPair()) )
1b446896 348 continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
349 else
5c58441a 350 { //swaped pair meets all the criteria
491d1b5d 351 tmppartpair = partpair->GetSwapedPair();
352 tmptrackpair = trackpair->GetSwapedPair();
1b446896 353 }
354 }
491d1b5d 355 else
356 {//meets criteria of the pair cut
357 tmptrackpair = trackpair;
358 tmppartpair = partpair;
359 }
1b446896 360 for(ii = 0;ii<fNParticleFunctions;ii++)
491d1b5d 361 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
1b446896 362
363 for(ii = 0;ii<fNTrackFunctions;ii++)
491d1b5d 364 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
1b446896 365
366 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
491d1b5d 367 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair,tmppartpair);
1b446896 368 }
369 }
370 }
371
d74e6a27 372
1b446896 373 /***** Filling denominators *********/
374 /***************************************/
81b7b887 375 if (fBufferSize != 0)
2dc7203b 376 for (Int_t i = 0;i<nev-1;i++) //In each event (but last) ....
1b446896 377 {
5c58441a 378
379 if ((fNParticleFunctions == 0) && (fNTrackFunctions ==0) && (fNParticleAndTrackFunctions == 0))
380 continue;
381
1b446896 382 partEvent= fReader->GetParticleEvent(i);
383 if (!partEvent) continue;
384
385 trackEvent = fReader->GetTrackEvent(i);
386
1b446896 387 for (Int_t j = 0; j< partEvent->GetNumberOfParticles(); j++) // ... Loop over all particles ...
388 {
1b446896 389 part1= partEvent->GetParticle(j);
1b446896 390 track1= trackEvent->GetParticle(j);
81b7b887 391
392 if (fPairCut->GetFirstPartCut()->Pass(part1)) continue;
1b446896 393
2dc7203b 394 Int_t maxeventnumber;
7a2c8238 395
2dc7203b 396 if ( ((i+fBufferSize) >= nev) ||( fBufferSize < 0) ) //if buffer size is negative
7a2c8238 397 //or current event+buffersize is greater
398 //than max nuber of events
81b7b887 399 {
2dc7203b 400 maxeventnumber = nev; //set the max event number
81b7b887 401 }
7a2c8238 402 else
81b7b887 403 {
2dc7203b 404 maxeventnumber = i+fBufferSize; //set the current event number + fBufferSize
81b7b887 405 }
1b446896 406
2dc7203b 407 for (Int_t k = i+1; k<maxeventnumber;k++) // ... Loop over next event
1b446896 408 {
409
81b7b887 410 partEvent2= fReader->GetParticleEvent(k);
411 if (!partEvent2) continue;
1b446896 412
81b7b887 413 trackEvent2 = fReader->GetTrackEvent(k);
1b446896 414
81b7b887 415 if ( (j%fDisplayMixingInfo) == 0)
416 Info("ProcessTracksAndParticles",
417 "Mixing particle %d from event %d with particles from event %d",j,i,k);
5c58441a 418
1b446896 419 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
420 {
1b446896 421 part2= partEvent2->GetParticle(l);
422 partpair->SetParticles(part1,part2);
423
424 track2= trackEvent2->GetParticle(l);
425 trackpair->SetParticles(track1,track2);
426
81b7b887 427 if( fPairCut->Pass(partpair) ) //check pair cut
1b446896 428 { //do not meets crietria of the
81b7b887 429 if( fPairCut->Pass(partpair->GetSwapedPair()) )
430 continue;
431 else
432 {
433 tmppartpair = partpair->GetSwapedPair();
434 tmptrackpair = trackpair->GetSwapedPair();
435 }
1b446896 436 }
491d1b5d 437 else
438 {//meets criteria of the pair cut
439 tmptrackpair = trackpair;
440 tmppartpair = partpair;
441 }
1b446896 442 for(ii = 0;ii<fNParticleFunctions;ii++)
491d1b5d 443 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
1b446896 444
445 for(ii = 0;ii<fNTrackFunctions;ii++)
491d1b5d 446 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
1b446896 447
448 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
491d1b5d 449 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
1b446896 450 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
2dc7203b 451 }//for (Int_t k = i+1; k<maxeventnumber;k++) // ... Loop over next event
1b446896 452 }
1b446896 453 }
1b446896 454 /***************************************/
1b446896 455}
456/*************************************************************************************/
457
458void AliHBTAnalysis::ProcessTracks()
459{
2dc7203b 460//In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1b446896 461//the loops are splited
462 AliHBTParticle * track1, * track2;
1b446896 463 AliHBTEvent * trackEvent;
464 AliHBTEvent * trackEvent2;
81b7b887 465
466 UInt_t ii;
2dc7203b 467 Int_t nev = fReader->GetNumberOfTrackEvents();
81b7b887 468
469 AliHBTPair * trackpair = new AliHBTPair();
470 AliHBTPair * tmptrackpair; //temporary pointer
1b446896 471
472 /***************************************/
473 /****** Looping same events ********/
474 /****** filling numerators ********/
475 /***************************************/
2dc7203b 476 for (Int_t i = 0;i<nev;i++)
1b446896 477 {
478 trackEvent = fReader->GetTrackEvent(i);
479 if (!trackEvent) continue;
1b446896 480
481 for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
482 {
81b7b887 483 if ( (j%fDisplayMixingInfo) == 0)
484 Info("ProcessTracks",
485 "Mixing particle %d from event %d with particles from event %d",j,i,i);
486
5c58441a 487 track1= trackEvent->GetParticle(j);
81b7b887 488 if (fPairCut->GetFirstPartCut()->Pass(track1)) continue;
489
490 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
e4f2b1da 491 fTrackMonitorFunctions[ii]->Process(track1);
5c58441a 492
493 if ( fNTrackFunctions ==0 )
494 continue;
495
1b446896 496 for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
497 {
d74e6a27 498 track2= trackEvent->GetParticle(k);
499 if (track1->GetUID() == track2->GetUID()) continue;
500
5c58441a 501 trackpair->SetParticles(track1,track2);
502 if(fPairCut->Pass(trackpair)) //check pair cut
81b7b887 503 { //do not meets crietria of the
5c58441a 504 if( fPairCut->Pass(trackpair->GetSwapedPair()) ) continue;
505 else tmptrackpair = trackpair->GetSwapedPair();
81b7b887 506 }
507 else
508 {
509 tmptrackpair = trackpair;
510 }
511 for(ii = 0;ii<fNTrackFunctions;ii++)
512 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
513 }
1b446896 514 }
515 }
516
517 /***************************************/
518 /***** Filling diff histogram *********/
519 /***************************************/
81b7b887 520 if (fBufferSize != 0)
2dc7203b 521 for (Int_t i = 0;i<nev-1;i++) //In each event (but last) ....
1b446896 522 {
5c58441a 523 if ( fNTrackFunctions ==0 )
524 continue;
525
1b446896 526 trackEvent = fReader->GetTrackEvent(i);
527 if (!trackEvent) continue;
81b7b887 528
1b446896 529 for (Int_t j = 0; j< trackEvent->GetNumberOfParticles(); j++) // ... Loop over all particles ...
530 {
81b7b887 531 track1= trackEvent->GetParticle(j);
532 if (fPairCut->GetFirstPartCut()->Pass(track1)) continue;
533
2dc7203b 534 Int_t maxeventnumber;
7a2c8238 535
2dc7203b 536 if ( ((i+fBufferSize) >= nev) ||( fBufferSize < 0) ) //if buffer size is negative
81b7b887 537 //or current event+buffersize is greater
538 //than max nuber of events
539 {
2dc7203b 540 maxeventnumber = nev; //set the max event number
81b7b887 541 }
542 else
543 {
2dc7203b 544 maxeventnumber = i+fBufferSize; //set the current event number + fBufferSize
81b7b887 545 }
1b446896 546
2dc7203b 547 for (Int_t k = i+1; k<maxeventnumber;k++) // ... Loop over next event
81b7b887 548 {
549 trackEvent2 = fReader->GetTrackEvent(k);
550 if (!trackEvent2) continue;
1b446896 551
81b7b887 552 if ( (j%fDisplayMixingInfo) == 0)
0465f84a 553 Info("ProcessTracks",
81b7b887 554 "Mixing particle %d from event %d with particles from event %d",j,i,k);
5c58441a 555
81b7b887 556 for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++) // ... on all particles
557 {
558 track2= trackEvent2->GetParticle(l);
559 trackpair->SetParticles(track1,track2);
1b446896 560
81b7b887 561 if(fPairCut->Pass(trackpair)) //check pair cut
562 { //do not meets crietria of the
563 if( fPairCut->Pass(trackpair->GetSwapedPair()) ) continue;
564 else tmptrackpair = trackpair->GetSwapedPair();
565 }
566 else
567 {
568 tmptrackpair = trackpair;
569 }
570 for(ii = 0;ii<fNTrackFunctions;ii++)
571 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
1b446896 572
81b7b887 573 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
2dc7203b 574 }//for (Int_t k = i+1; k<maxeventnumber;k++) // ... Loop over next event
1b446896 575 }
1b446896 576 }
1b446896 577 /***************************************/
1b446896 578}
579
580/*************************************************************************************/
491d1b5d 581
1b446896 582void AliHBTAnalysis::ProcessParticles()
583{
81b7b887 584//In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1b446896 585//the loops are splited
586 AliHBTParticle * part1, * part2;
587
588 AliHBTEvent * partEvent;
589 AliHBTEvent * partEvent2;
491d1b5d 590
591 AliHBTPair * partpair = new AliHBTPair();
592 AliHBTPair * tmppartpair; //temporary pointer to the pair
1b446896 593
2dc7203b 594 Int_t nev = fReader->GetNumberOfPartEvents();
1b446896 595
596 /***************************************/
597 /****** Looping same events ********/
598 /****** filling numerators ********/
599 /***************************************/
2dc7203b 600 for (Int_t i = 0;i<nev;i++)
1b446896 601 {
602 partEvent= fReader->GetParticleEvent(i);
603 if (!partEvent) continue;
604 //N = 0;
605
606 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
607 {
81b7b887 608 if ( (j%fDisplayMixingInfo) == 0)
609 Info("ProcessParticles",
610 "Mixing particle %d from event %d with particles from event %d",j,i,i);
1b446896 611
612 part1= partEvent->GetParticle(j);
81b7b887 613 if (fPairCut->GetFirstPartCut()->Pass(part1)) continue;
5c58441a 614
615 UInt_t zz;
616 for(zz = 0; zz<fNParticleMonitorFunctions; zz++)
e4f2b1da 617 fParticleMonitorFunctions[zz]->Process(part1);
5c58441a 618
619 if ( fNParticleFunctions ==0 )
620 continue;
621
1b446896 622 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
623 {
624 part2= partEvent->GetParticle(k);
d74e6a27 625 if (part1->GetUID() == part2->GetUID()) continue; //this is the same particle but different incarnation (PID)
1b446896 626 partpair->SetParticles(part1,part2);
627
628 if( fPairCut->Pass(partpair) ) //check pair cut
629 { //do not meets crietria of the pair cut, try with swaped pairs
630 if( fPairCut->Pass(partpair->GetSwapedPair() ) )
631 continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
632 else
633 { //swaped pair meets all the criteria
491d1b5d 634 tmppartpair = partpair->GetSwapedPair();
1b446896 635 }
636 }
491d1b5d 637 else
638 {
639 tmppartpair = partpair;
640 }
5c58441a 641
1b446896 642 UInt_t ii;
1b446896 643 for(ii = 0;ii<fNParticleFunctions;ii++)
491d1b5d 644 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
1b446896 645 }
646 }
647 }
648
649 /***************************************/
650 /***** Filling diff histogram *********/
651 /***************************************/
81b7b887 652 if (fBufferSize != 0) //less then 0 mix everything, == 0 do not mix denominator
2dc7203b 653 for (Int_t i = 0;i<nev-1;i++) //In each event (but last)....
1b446896 654 {
5c58441a 655 if ( fNParticleFunctions ==0 )
656 continue;
657
1b446896 658 partEvent= fReader->GetParticleEvent(i);
659 if (!partEvent) continue;
660
1b446896 661 for (Int_t j = 0; j< partEvent->GetNumberOfParticles(); j++) // ... Loop over all particles ...
662 {
1b446896 663 part1= partEvent->GetParticle(j);
81b7b887 664 if (fPairCut->GetFirstPartCut()->Pass(part1)) continue;
2dc7203b 665 Int_t maxeventnumber;
81b7b887 666
2dc7203b 667 if ( ((i+fBufferSize) >= nev) ||( fBufferSize < 0) ) //if buffer size is negative
7a2c8238 668 //or current event+buffersize is greater
669 //than max nuber of events
670 {
2dc7203b 671 maxeventnumber = nev; //set the max event number
7a2c8238 672 }
673 else
674 {
2dc7203b 675 maxeventnumber = i+fBufferSize; //set the current event number + fBufferSize
7a2c8238 676 }
677
2dc7203b 678 for (Int_t k = i+1; k<maxeventnumber;k++) // ... Loop over next event
1b446896 679 {
680
681 partEvent2= fReader->GetParticleEvent(k);
682 if (!partEvent2) continue;
683
81b7b887 684 if ( (j%fDisplayMixingInfo) == 0)
685 Info("ProcessParticles",
686 "Mixing particle %d from event %d with particles from event %d",j,i,k);
5c58441a 687
1b446896 688 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
689 {
1b446896 690 part2= partEvent2->GetParticle(l);
691 partpair->SetParticles(part1,part2);
692
693 if(fPairCut->Pass(partpair)) //check pair cut
694 { //do not meets crietria of the
695 if( fPairCut->Pass(partpair->GetSwapedPair()) ) continue;
81b7b887 696 else tmppartpair = partpair->GetSwapedPair();
491d1b5d 697 }
698 else
699 {
700 tmppartpair = partpair;
1b446896 701 }
702 UInt_t ii;
703 for(ii = 0;ii<fNParticleFunctions;ii++)
491d1b5d 704 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
1b446896 705
706 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
2dc7203b 707 }//for (Int_t k = i+1; k<maxeventnumber;k++) // ... Loop over next event
1b446896 708 }
1b446896 709 }
1b446896 710 /***************************************/
1b446896 711
712}
1b446896 713/*************************************************************************************/
714
491d1b5d 715void AliHBTAnalysis::WriteFunctions()
1b446896 716{
81b7b887 717//Calls Write for all defined functions in analysis
718//== writes all results
1b446896 719 UInt_t ii;
720 for(ii = 0;ii<fNParticleFunctions;ii++)
721 fParticleFunctions[ii]->Write();
722
723 for(ii = 0;ii<fNTrackFunctions;ii++)
724 fTrackFunctions[ii]->Write();
725
726 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
727 fParticleAndTrackFunctions[ii]->Write();
5c58441a 728
729 for(ii = 0;ii<fNParticleMonitorFunctions;ii++)
730 fParticleMonitorFunctions[ii]->Write();
731
732 for(ii = 0;ii<fNTrackMonitorFunctions;ii++)
733 fTrackMonitorFunctions[ii]->Write();
734
735 for(ii = 0;ii<fNParticleAndTrackMonitorFunctions;ii++)
736 fParticleAndTrackMonitorFunctions[ii]->Write();
1b446896 737}
738/*************************************************************************************/
491d1b5d 739
1b446896 740void AliHBTAnalysis::SetGlobalPairCut(AliHBTPairCut* cut)
741{
81b7b887 742//Sets the global cut
1b446896 743 if (cut == 0x0)
744 {
745 Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
746 }
747 delete fPairCut;
748 fPairCut = (AliHBTPairCut*)cut->Clone();
749}
750
751/*************************************************************************************/
491d1b5d 752
27b3fe5d 753void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
1b446896 754{
81b7b887 755//Adds track function
1b446896 756 if (f == 0x0) return;
757 if (fNTrackFunctions == fgkFctnArraySize)
758 {
759 Error("AliHBTAnalysis::AddTrackFunction","Can not add this function, not enough place in the array.");
760 }
761 fTrackFunctions[fNTrackFunctions] = f;
762 fNTrackFunctions++;
763}
491d1b5d 764/*************************************************************************************/
765
27b3fe5d 766void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
1b446896 767{
81b7b887 768//adds particle function
1b446896 769 if (f == 0x0) return;
770
771 if (fNParticleFunctions == fgkFctnArraySize)
772 {
773 Error("AliHBTAnalysis::AddParticleFunction","Can not add this function, not enough place in the array.");
774 }
775 fParticleFunctions[fNParticleFunctions] = f;
776 fNParticleFunctions++;
1b446896 777}
5c58441a 778/*************************************************************************************/
779
27b3fe5d 780void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
1b446896 781{
81b7b887 782//add resolution function
1b446896 783 if (f == 0x0) return;
784 if (fNParticleAndTrackFunctions == fgkFctnArraySize)
785 {
786 Error("AliHBTAnalysis::AddParticleAndTrackFunction","Can not add this function, not enough place in the array.");
787 }
788 fParticleAndTrackFunctions[fNParticleAndTrackFunctions] = f;
789 fNParticleAndTrackFunctions++;
790}
5c58441a 791/*************************************************************************************/
792
793void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
794{
81b7b887 795//add particle monitoring function
5c58441a 796 if (f == 0x0) return;
797
798 if (fNParticleMonitorFunctions == fgkFctnArraySize)
799 {
800 Error("AliHBTAnalysis::AddParticleMonitorFunction","Can not add this function, not enough place in the array.");
801 }
802 fParticleMonitorFunctions[fNParticleMonitorFunctions] = f;
803 fNParticleMonitorFunctions++;
804}
805/*************************************************************************************/
1b446896 806
5c58441a 807void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
808{
81b7b887 809//add track monitoring function
5c58441a 810 if (f == 0x0) return;
1b446896 811
5c58441a 812 if (fNTrackMonitorFunctions == fgkFctnArraySize)
813 {
814 Error("AliHBTAnalysis::AddTrackMonitorFunction","Can not add this function, not enough place in the array.");
815 }
816 fTrackMonitorFunctions[fNTrackMonitorFunctions] = f;
817 fNTrackMonitorFunctions++;
818}
1b446896 819/*************************************************************************************/
820
5c58441a 821void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
822{
81b7b887 823//add resolution monitoring function
5c58441a 824 if (f == 0x0) return;
825 if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
826 {
827 Error("AliHBTAnalysis::AddParticleAndTrackMonitorFunction","Can not add this function, not enough place in the array.");
828 }
829 fParticleAndTrackMonitorFunctions[fNParticleAndTrackMonitorFunctions] = f;
830 fNParticleAndTrackMonitorFunctions++;
831}
832
1b446896 833
5c58441a 834/*************************************************************************************/
1b446896 835/*************************************************************************************/
491d1b5d 836
1b446896 837Bool_t AliHBTAnalysis::RunCoherencyCheck()
838{
839 //Checks if both HBTRuns are similar
840 //return true if error found
841 //if they seem to be OK return false
842 Int_t i;
81b7b887 843 Info("RunCoherencyCheck","Checking HBT Runs Coherency");
844
845 Info("RunCoherencyCheck","Number of events ...");
1b446896 846 if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same number of events
847 {
81b7b887 848 Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
1b446896 849 }
850 else
851 { //if not the same - ERROR
852 Error("AliHBTAnalysis::RunCoherencyCheck()",
853 "Number of simulated events (%d) is not equal to number of reconstructed events(%d)",
854 fReader->GetNumberOfPartEvents(),fReader->GetNumberOfTrackEvents());
855 return kTRUE;
856 }
857
81b7b887 858 Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
1b446896 859
860 AliHBTEvent *partEvent;
861 AliHBTEvent *trackEvent;
862 for( i = 0; i<fReader->GetNumberOfTrackEvents();i++)
863 {
864 partEvent= fReader->GetParticleEvent(i); //gets the "ith" event
865 trackEvent = fReader->GetTrackEvent(i);
866
867 if ( (partEvent == 0x0) && (partEvent == 0x0) ) continue;
868 if ( (partEvent == 0x0) || (partEvent == 0x0) )
869 {
870 Error("AliHBTAnalysis::RunCoherencyCheck()",
871 "One event is NULL and the other one not. Event Number %d",i);
872 return kTRUE;
873 }
874
875 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
876 {
877 Error("AliHBTAnalysis::RunCoherencyCheck()",
878 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
879 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
880 return kTRUE;
881 }
882 else
883 for (Int_t j = 0; j<partEvent->GetNumberOfParticles(); j++)
884 {
885 if( partEvent->GetParticle(j)->GetPdgCode() != trackEvent->GetParticle(j)->GetPdgCode() )
886 {
887 Error("AliHBTAnalysis::RunCoherencyCheck()",
888 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
889 i,j, partEvent->GetParticle(j)->GetPdgCode(),trackEvent->GetParticle(j)->GetPdgCode() );
890 return kTRUE;
891
892 }
893 }
894 }
81b7b887 895 Info("RunCoherencyCheck"," Done");
896 Info("RunCoherencyCheck"," Everything looks OK");
1b446896 897 return kFALSE;
898}
899
dc2c3f36 900/*************************************************************************************/
901
902void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
903{
81b7b887 904//Performs analysis for both, tracks and particles
905
dc2c3f36 906 AliHBTParticle * part1, * part2;
907 AliHBTParticle * track1, * track2;
908
aeba88d7 909 AliHBTEvent * trackEvent1=0x0,*partEvent1=0x0;
910 AliHBTEvent * trackEvent2=0x0,*partEvent2=0x0;
911 AliHBTEvent * trackEvent3=0x0,*partEvent3=0x0;
dc2c3f36 912
913 AliHBTEvent * rawtrackEvent, *rawpartEvent;
dc2c3f36 914
2dc7203b 915 Int_t nev = fReader->GetNumberOfTrackEvents();
dc2c3f36 916
917 AliHBTPair * trackpair = new AliHBTPair();
918 AliHBTPair * partpair = new AliHBTPair();
919
920 TList tbuffer;
921 TList pbuffer;
922 Int_t ninbuffer = 0;
81b7b887 923 UInt_t ii;
dc2c3f36 924
925 trackEvent1 = new AliHBTEvent();
926 partEvent1 = new AliHBTEvent();
927 trackEvent1->SetOwner(kFALSE);
928 partEvent1->SetOwner(kFALSE);;
929
81b7b887 930 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
931 Info("ProcessTracksAndParticlesNonIdentAnal","***** NON IDENT MODE ****************");
932 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
933
2dc7203b 934 for (Int_t i = 0;i<nev;i++)
dc2c3f36 935 {
936 rawpartEvent = fReader->GetParticleEvent(i);
937 rawtrackEvent = fReader->GetTrackEvent(i);
938 if ( (rawpartEvent == 0x0) || (rawtrackEvent == 0x0) ) continue;//in case of any error
939
940 /********************************/
941 /* Filtering out */
942 /********************************/
81b7b887 943 if ( (fBufferSize != 0) || ( (partEvent2==0x0)||(trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
944 if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
945 {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
946 partEvent2 = (AliHBTEvent*)pbuffer.Remove(pbuffer.Last()); //remove from the end to be reset, filled and put on the beginning
947 trackEvent2 = (AliHBTEvent*)tbuffer.Remove(tbuffer.Last());
948 ninbuffer--;
949 }
950 else
951 {
952 partEvent2 = new AliHBTEvent();
953 trackEvent2 = new AliHBTEvent();
954 partEvent2->SetOwner(kFALSE);
955 trackEvent2->SetOwner(kFALSE);
956 }
dc2c3f36 957 FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
958
959 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
960 {
81b7b887 961 if ( (j%fDisplayMixingInfo) == 0)
962 Info("ProcessTracksAndParticlesNonIdentAnal",
963 "Mixing particle %d from event %d with particles from event %d",j,i,i);
dc2c3f36 964
965 part1= partEvent1->GetParticle(j);
966 track1= trackEvent1->GetParticle(j);
967
81b7b887 968 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
e4f2b1da 969 fParticleMonitorFunctions[ii]->Process(part1);
81b7b887 970 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
e4f2b1da 971 fTrackMonitorFunctions[ii]->Process(track1);
81b7b887 972 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
e4f2b1da 973 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
dc2c3f36 974
975 /***************************************/
976 /****** filling numerators ********/
977 /****** (particles from event2) ********/
978 /***************************************/
979 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++)
980 {
981 part2= partEvent2->GetParticle(k);
d74e6a27 982 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
dc2c3f36 983 partpair->SetParticles(part1,part2);
984
985 track2= trackEvent2->GetParticle(k);
986 trackpair->SetParticles(track1,track2);
987
81b7b887 988 if( (fPairCut->PassPairProp(partpair)) ) //check pair cut
989 { //do not meets crietria of the pair cut
990 continue;
991 }
dc2c3f36 992 else
993 {//meets criteria of the pair cut
dc2c3f36 994 for(ii = 0;ii<fNParticleFunctions;ii++)
995 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
996
997 for(ii = 0;ii<fNTrackFunctions;ii++)
998 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
999
1000 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1001 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
1002 }
1003 }
5c58441a 1004
81b7b887 1005 if ( fBufferSize == 0) continue;//do not mix diff histograms
dc2c3f36 1006 /***************************************/
1007 /***** Filling denominators *********/
1008 /***************************************/
1009 TIter piter(&pbuffer);
1010 TIter titer(&tbuffer);
1011 Int_t nmonitor = 0;
1012
1013 while ( (partEvent3 = (AliHBTEvent*)piter.Next()) != 0x0)
1014 {
1015 trackEvent3 = (AliHBTEvent*)titer.Next();
81b7b887 1016 if ( (j%fDisplayMixingInfo) == 0)
1017 Info("ProcessTracksAndParticlesNonIdentAnal",
1018 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
dc2c3f36 1019
1020 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1021 {
1022 part2= partEvent3->GetParticle(k);
1023 partpair->SetParticles(part1,part2);
1b446896 1024
dc2c3f36 1025 track2= trackEvent3->GetParticle(k);
1026 trackpair->SetParticles(track1,track2);
1027
81b7b887 1028 if( (fPairCut->PassPairProp(partpair)) ) //check pair cut
1029 { //do not meets crietria of the pair cut
1030 continue;
1031 }
dc2c3f36 1032 else
1033 {//meets criteria of the pair cut
1034 UInt_t ii;
1035 for(ii = 0;ii<fNParticleFunctions;ii++)
1036 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1037
1038 for(ii = 0;ii<fNTrackFunctions;ii++)
1039 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1040
1041 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1042 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
1043 }
1044 }// for particles event2
1045 }//while event2
1046 }//for over particles in event1
1047
b70eb506 1048 if ( fBufferSize == 0) continue;//do not mix diff histograms-> do not add to buffer list
dc2c3f36 1049 pbuffer.AddFirst(partEvent2);
1050 tbuffer.AddFirst(trackEvent2);
81b7b887 1051 partEvent2 = 0x0;
1052 trackEvent2 = 0x0;
dc2c3f36 1053 ninbuffer++;
1054
1055 }//end of loop over events (1)
dc2c3f36 1056 pbuffer.SetOwner(); //to clean stored events by the way of buffer destruction
1057 tbuffer.SetOwner();
b70eb506 1058 delete partEvent1;
1059 delete trackEvent1;
1060 delete partpair;
1061 delete trackpair;
1062 if ( fBufferSize == 0)
1063 {//in that case we did not add these events to list
1064 delete partEvent2;
1065 delete trackEvent2;
1066 }
81b7b887 1067
dc2c3f36 1068}
1b446896 1069/*************************************************************************************/
1070
dc2c3f36 1071void AliHBTAnalysis::ProcessTracksNonIdentAnal()
1072{
2dc7203b 1073//Process Tracks only with non identical mode
dc2c3f36 1074 AliHBTParticle * track1, * track2;
1075
aeba88d7 1076 AliHBTEvent * trackEvent1=0x0;
1077 AliHBTEvent * trackEvent2=0x0;
1078 AliHBTEvent * trackEvent3=0x0;
dc2c3f36 1079
d74e6a27 1080
dc2c3f36 1081 AliHBTEvent * rawtrackEvent;
dc2c3f36 1082
2dc7203b 1083 Int_t nev = fReader->GetNumberOfTrackEvents();
dc2c3f36 1084
1085 AliHBTPair * trackpair = new AliHBTPair();
1086
1087 TList tbuffer;
1088 Int_t ninbuffer = 0;
81b7b887 1089 register UInt_t ii;
dc2c3f36 1090
1091 trackEvent1 = new AliHBTEvent();
1092 trackEvent1->SetOwner(kFALSE);
1093
81b7b887 1094 Info("ProcessTracksNonIdentAnal","**************************************");
1095 Info("ProcessTracksNonIdentAnal","***** NON IDENT MODE ****************");
1096 Info("ProcessTracksNonIdentAnal","**************************************");
1097
2dc7203b 1098 for (Int_t i = 0;i<nev;i++)
dc2c3f36 1099 {
1100 rawtrackEvent = fReader->GetTrackEvent(i);
1101 if (rawtrackEvent == 0x0) continue;//in case of any error
1102
1103 /********************************/
1104 /* Filtering out */
1105 /********************************/
81b7b887 1106 if ( (fBufferSize != 0) || ( trackEvent2==0x0) )//in case fBufferSize == 0 and pointers are created do not eneter
1107 if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
1108 {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
1109 trackEvent2 = (AliHBTEvent*)tbuffer.Remove(tbuffer.Last());
1110 ninbuffer--;
1111 }
1112 else
1113 {
1114 trackEvent2 = new AliHBTEvent();
1115 trackEvent2->SetOwner(kFALSE);
1116 }
dc2c3f36 1117 FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
1118
1119 for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
1120 {
81b7b887 1121 if ( (j%fDisplayMixingInfo) == 0)
1122 Info("ProcessTracksNonIdentAnal",
1123 "Mixing particle %d from event %d with particles from event %d",j,i,i);
dc2c3f36 1124
1125 track1= trackEvent1->GetParticle(j);
1126
81b7b887 1127 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
e4f2b1da 1128 fTrackMonitorFunctions[ii]->Process(track1);
dc2c3f36 1129
1130 /***************************************/
1131 /****** filling numerators ********/
1132 /****** (particles from event2) ********/
1133 /***************************************/
1134 for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++)
1135 {
1136 track2= trackEvent2->GetParticle(k);
d74e6a27 1137 if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
dc2c3f36 1138 trackpair->SetParticles(track1,track2);
1139
1140
1141 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1142 { //do not meets crietria of the pair cut
1143 continue;
1144 }
1145 else
1146 {//meets criteria of the pair cut
1147 UInt_t ii;
1148 for(ii = 0;ii<fNTrackFunctions;ii++)
1149 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
1150 }
1151 }
81b7b887 1152 if ( fBufferSize == 0) continue;//do not mix diff histograms
dc2c3f36 1153 /***************************************/
1154 /***** Filling denominators *********/
1155 /***************************************/
1156 TIter titer(&tbuffer);
1157 Int_t nmonitor = 0;
1158
1159 while ( (trackEvent3 = (AliHBTEvent*)titer.Next()) != 0x0)
1160 {
1161
81b7b887 1162 if ( (j%fDisplayMixingInfo) == 0)
1163 Info("ProcessTracksNonIdentAnal",
1164 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
dc2c3f36 1165
1166 for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
1167 {
1168
1169 track2= trackEvent3->GetParticle(k);
1170 trackpair->SetParticles(track1,track2);
1171
1172
1173 if( fPairCut->PassPairProp(trackpair)) //check pair cut
81b7b887 1174 { //do not meets crietria of the pair cut
1175 continue;
1176 }
dc2c3f36 1177 else
1178 {//meets criteria of the pair cut
81b7b887 1179 for(ii = 0;ii<fNTrackFunctions;ii++)
1180 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
dc2c3f36 1181 }
1182 }// for particles event2
1183 }//while event2
1184 }//for over particles in event1
1185
b70eb506 1186 if ( fBufferSize == 0) continue;//do not mix diff histograms
dc2c3f36 1187 tbuffer.AddFirst(trackEvent2);
b70eb506 1188 trackEvent2 = 0x0;
dc2c3f36 1189 ninbuffer++;
1190
1191 }//end of loop over events (1)
b70eb506 1192
1193 delete trackpair;
1194 delete trackEvent1;
1195 if (fBufferSize == 0) delete trackEvent2;
dc2c3f36 1196 tbuffer.SetOwner();
1197}
1198/*************************************************************************************/
1199
1200void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
1201{
2dc7203b 1202//process paricles only with non identical mode
dc2c3f36 1203 AliHBTParticle * part1 = 0x0, * part2 = 0x0;
1204
1205 AliHBTEvent * partEvent1 = 0x0;
1206 AliHBTEvent * partEvent2 = 0x0;
1207 AliHBTEvent * partEvent3 = 0x0;
1208
1209 AliHBTEvent * rawpartEvent = 0x0;
1210
2dc7203b 1211 Int_t nev = fReader->GetNumberOfPartEvents();
dc2c3f36 1212
1213 AliHBTPair * partpair = new AliHBTPair();
1214
1215 TList pbuffer;
1216 Int_t ninbuffer = 0;
1217
1218 partEvent1 = new AliHBTEvent();
1219 partEvent1->SetOwner(kFALSE);;
1220
81b7b887 1221 Info("ProcessParticlesNonIdentAnal","**************************************");
1222 Info("ProcessParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1223 Info("ProcessParticlesNonIdentAnal","**************************************");
dc2c3f36 1224
2dc7203b 1225 for (Int_t i = 0;i<nev;i++)
dc2c3f36 1226 {
1227 rawpartEvent = fReader->GetParticleEvent(i);
1228 if ( rawpartEvent == 0x0 ) continue;//in case of any error
1229
1230 /********************************/
1231 /* Filtering out */
1232 /********************************/
b70eb506 1233 if ( (fBufferSize != 0) || ( partEvent2==0x0) )//in case fBufferSize == 0 and pointers are created do not eneter
1234 if ((ninbuffer > fBufferSize) && (fBufferSize > 0))
1235 {//if we have in buffer desired number of events, use the last. If fBufferSize<0 mix all events for background
1236 partEvent2 = (AliHBTEvent*)pbuffer.Remove(pbuffer.Last()); //remove from the end to be reset, filled and put on the beginning
1237 ninbuffer--;
1238 }
1239 else
1240 {
1241 partEvent2 = new AliHBTEvent();
1242 partEvent2->SetOwner(kFALSE);
1243 }
dc2c3f36 1244 FilterOut(partEvent1, partEvent2, rawpartEvent);
1245
1246 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
1247 {
81b7b887 1248 if ( (j%fDisplayMixingInfo) == 0)
1249 Info("ProcessParticlesNonIdentAnal",
1250 "Mixing particle %d from event %d with particles from event %d",j,i,i);
dc2c3f36 1251
1252 part1= partEvent1->GetParticle(j);
1253
5c58441a 1254 UInt_t zz;
1255 for(zz = 0; zz<fNParticleMonitorFunctions; zz++)
e4f2b1da 1256 fParticleMonitorFunctions[zz]->Process(part1);
dc2c3f36 1257
1258 /***************************************/
1259 /****** filling numerators ********/
1260 /****** (particles from event2) ********/
1261 /***************************************/
1262 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++)
1263 {
1264 part2= partEvent2->GetParticle(k);
d74e6a27 1265 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
dc2c3f36 1266 partpair->SetParticles(part1,part2);
1267
1268 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1269 { //do not meets crietria of the pair cut
1270 continue;
1271 }
1272 else
1273 {//meets criteria of the pair cut
1274 UInt_t ii;
1275 for(ii = 0;ii<fNParticleFunctions;ii++)
5c58441a 1276 {
5c58441a 1277 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
1278 }
dc2c3f36 1279 }
1280 }
b70eb506 1281 if ( fBufferSize == 0) continue;//do not mix diff histograms
dc2c3f36 1282 /***************************************/
1283 /***** Filling denominators *********/
1284 /***************************************/
1285 TIter piter(&pbuffer);
1286 Int_t nmonitor = 0;
1287
1288 while ( (partEvent3 = (AliHBTEvent*)piter.Next()) != 0x0)
1289 {
81b7b887 1290 if ( (j%fDisplayMixingInfo) == 0)
1291 Info("ProcessParticlesNonIdentAnal",
1292 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
1293
dc2c3f36 1294 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1295 {
1296 part2= partEvent3->GetParticle(k);
1297 partpair->SetParticles(part1,part2);
1298
dc2c3f36 1299 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1300 { //do not meets crietria of the pair cut
1301 continue;
1302 }
1303 else
1304 {//meets criteria of the pair cut
1305 UInt_t ii;
1306 for(ii = 0;ii<fNParticleFunctions;ii++)
5c58441a 1307 {
5c58441a 1308 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1309 }
dc2c3f36 1310 }
1311 }// for particles event2
1312 }//while event2
1313 }//for over particles in event1
b70eb506 1314 if ( fBufferSize == 0) continue;//do not mix diff histograms
dc2c3f36 1315 pbuffer.AddFirst(partEvent2);
b70eb506 1316 partEvent2 = 0x0;
dc2c3f36 1317 ninbuffer++;
1318
1319 }//end of loop over events (1)
b70eb506 1320 delete partpair;
1321 delete partEvent1;
1322 if ( fBufferSize == 0) delete partEvent2;
dc2c3f36 1323 pbuffer.SetOwner();//to delete stered events.
1324}
1325
1326/*************************************************************************************/
1327void AliHBTAnalysis::FilterOut(AliHBTEvent* outpart1, AliHBTEvent* outpart2, AliHBTEvent* inpart,
1328 AliHBTEvent* outtrack1, AliHBTEvent* outtrack2, AliHBTEvent* intrack)
1329{
1330 //Puts particles accepted as a first particle by global cut in out1
1331 //and as a second particle in out2
1332
1333 AliHBTParticle* part, *track;
1334
1335 outpart1->Reset();
1336 outpart2->Reset();
1337 outtrack1->Reset();
1338 outtrack2->Reset();
1339
1340 AliHBTParticleCut *cut1 = fPairCut->GetFirstPartCut();
1341 AliHBTParticleCut *cut2 = fPairCut->GetSecondPartCut();
1342
1343 Bool_t in1, in2;
1344
1345 for (Int_t i = 0; i < inpart->GetNumberOfParticles(); i++)
1346 {
1347 in1 = in2 = kTRUE;
1348 part = inpart->GetParticle(i);
1349 track = intrack->GetParticle(i);
1350
81b7b887 1351 if ( (cut1->Pass(part)) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1352 if ( (cut2->Pass(part)) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
dc2c3f36 1353
1354 if (gDebug)//to be removed in real analysis
1355 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1356 {
1357 //Particle accpted by both cuts
1358 Error("FilterOut","Particle accepted by both cuts");
1359 continue;
1360 }
1361
1362 if (in1)
1363 {
1364 outpart1->AddParticle(part);
1365 outtrack1->AddParticle(track);
1366 continue;
1367 }
1368
1369 if (in2)
1370 {
1371 outpart2->AddParticle(part);
1372 outtrack2->AddParticle(track);
1373 continue;
1374 }
1375 }
dc2c3f36 1376}
1b446896 1377/*************************************************************************************/
81b7b887 1378
dc2c3f36 1379void AliHBTAnalysis::FilterOut(AliHBTEvent* out1, AliHBTEvent* out2, AliHBTEvent* in)
1380{
1381 //Puts particles accepted as a first particle by global cut in out1
1382 //and as a second particle in out2
1383 AliHBTParticle* part;
1384
1385 out1->Reset();
1386 out2->Reset();
1387
1388 AliHBTParticleCut *cut1 = fPairCut->GetFirstPartCut();
1389 AliHBTParticleCut *cut2 = fPairCut->GetSecondPartCut();
1390
1391 Bool_t in1, in2;
1392
1393 for (Int_t i = 0; i < in->GetNumberOfParticles(); i++)
1394 {
1395 in1 = in2 = kTRUE;
1396 part = in->GetParticle(i);
1397
1398 if ( cut1->Pass(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1399 if ( cut2->Pass(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1400
1401 if (gDebug)//to be removed in real analysis
1402 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1403 {
1404 //Particle accpted by both cuts
1405 Error("FilterOut","Particle accepted by both cuts");
1406 continue;
1407 }
1b446896 1408
dc2c3f36 1409 if (in1)
1410 {
1411 out1->AddParticle(part);
1412 continue;
1413 }
1414
1415 if (in2)
1416 {
1417 out2->AddParticle(part);
1418 continue;
1419 }
1420 }
1421}
1422/*************************************************************************************/
1b446896 1423
dc2c3f36 1424Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
1425{
1426 //checks if it is possible to use special analysis for non identical particles
1427 //it means - in global pair cut first particle id is different than second one
1428 //and both are different from 0
1429 //in the future is possible to perform more sophisticated check
1430 //if cuts have excluding requirements
1431
5c58441a 1432 if (fPairCut->IsEmpty())
1433 return kFALSE;
1434
1435 if (fPairCut->GetFirstPartCut()->IsEmpty())
1436 return kFALSE;
1437
1438 if (fPairCut->GetSecondPartCut()->IsEmpty())
1439 return kFALSE;
dc2c3f36 1440
1441 Int_t id1 = fPairCut->GetFirstPartCut()->GetPID();
1442 Int_t id2 = fPairCut->GetSecondPartCut()->GetPID();
dc2c3f36 1443
5c58441a 1444 if ( (id1==0) || (id2==0) || (id1==id2) )
1445 return kFALSE;
1446
dc2c3f36 1447 return kTRUE;
1448}