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