]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/JetCorrel/AliJetCorrelMixer.cxx
new correlation histogramming, Paul Constantin
[u/mrichter/AliRoot.git] / PWG4 / JetCorrel / AliJetCorrelMixer.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id: $ */
16
17 //__________________________________________
18 // Event mixing class. A 5-dimensinal pool fPool is maintained:
19 // type_idx(fixed), vertex(fixed), centrality(fixed), 
20 // and event(dynamic), particle(dynamic)
21 // fixed dimensions are fixed at task initialization time (via AliJetCorrelSelector)
22 // event&particle are allow to float during runtime (via linked lists TList=event & CorrelList_t=particle)
23 //-- Author: Paul Constantin
24
25 #include "AliJetCorrelMixer.h"
26
27 using namespace std;
28
29 ClassImp(AliJetCorrelMixer)
30
31 AliJetCorrelMixer::AliJetCorrelMixer() :
32   fSelector(NULL), fMaker(NULL), fWriter(NULL),
33   fTriggEvnt(NULL), fAssocEvnt(NULL),
34   fAssocIter(NULL), fTriggIter(NULL) {
35   // constructor
36 }
37
38 AliJetCorrelMixer::~AliJetCorrelMixer(){
39   // destructor
40   CleanPool();
41 }
42
43 void AliJetCorrelMixer::Init(AliJetCorrelSelector * const s, AliJetCorrelMaker * const m, AliJetCorrelWriter * const w){
44   // initialization method
45   fSelector = s;
46   fMaker = m;
47   fWriter = w;
48   
49   for(UInt_t vBin=0; vBin<fSelector->NoOfBins(t_vert); vBin++)
50     for(UInt_t cBin=0; cBin<fSelector->NoOfBins(t_cent); cBin++)
51       for(UInt_t ia=0; ia<fMaker->NoOfAssoc(); ia++)
52         fPool[ia][vBin][cBin] = new TList;
53 }
54
55 void AliJetCorrelMixer::FillPool(CorrelList_t *partList, UInt_t pIdx, UInt_t vBin, UInt_t cBin){
56   // pool filling method
57   if(partList->Size()<1) return;
58   UInt_t pSize = fPool[pIdx][vBin][cBin]->GetSize();
59   // when pool depth is reached, pop pool before new event push (keep const depth)
60   if(pSize>=fSelector->PoolDepth()) fPool[pIdx][vBin][cBin]->RemoveFirst();
61   // incoming list is cleared at end-of-event; hence, store in pool a deep copy:
62   fPool[pIdx][vBin][cBin]->AddLast(partList->DeepCopy());
63 }
64
65 void AliJetCorrelMixer::Mix(UInt_t vBin, UInt_t cBin, UInt_t ia, UInt_t ic) {
66   // rolling buffer mixing method
67   TListIter* iterPool=(TListIter*)fPool[ia][vBin][cBin]->MakeIterator();
68   if(!fTriggEvnt) {std::cerr<<"AliJetCorrelMixer::Mix - ERROR: Trigger list not set!"<<std::endl; exit(-1);}
69   fTriggIter = fTriggEvnt->Head();
70   while((fAssocEvnt=(CorrelList_t*)iterPool->Next())){
71     fAssocIter = fAssocEvnt->Head();  
72     if(fTriggEvnt->EvtID()==fAssocEvnt->EvtID()) continue; // don't mix same event!
73     
74     while(!fTriggIter.HasEnded()){
75       while(!fAssocIter.HasEnded()){
76         fWriter->FillCorrelations(1,ic,cBin,vBin,fTriggIter.Data(),fAssocIter.Data()); // trigg first!
77         fAssocIter.Move();
78       } // loop over associated particles
79       fAssocIter = fAssocEvnt->Head(); // reset associated particle iterator to list head
80       fTriggIter.Move();
81     } // loop over trigger particles
82     fTriggIter = fTriggEvnt->Head(); // reset trigger particle iterator to list head
83   } // loop over associated pool
84   delete iterPool;
85 }
86
87 void AliJetCorrelMixer::CleanPool(){
88   // pool cleaning
89   UInt_t size = fMaker->NoOfAssoc();
90   for(UInt_t k=0; k<size; k++){
91     for(UInt_t vBin=0; vBin<fSelector->NoOfBins(t_vert); vBin++)
92       for(UInt_t cBin=0; cBin<fSelector->NoOfBins(t_cent); cBin++)
93         fPool[k][vBin][cBin]->Delete(); // Remove all list objects AND delete all heap based objects
94   }
95 }
96
97 void AliJetCorrelMixer::ShowSummary(UInt_t pIdx, UInt_t vBin, UInt_t cBin) const {
98   // pool printout method
99   UInt_t totalPoolSize=0;
100   TListIter* iter=(TListIter*)fPool[pIdx][vBin][cBin]->MakeIterator();
101   CorrelList_t* partList;
102   while((partList=(CorrelList_t*)iter->Next())) totalPoolSize += partList->Size();
103   delete iter;
104   std::cout<<"Pool["<<vBin<<"]["<<cBin<<"]: nevt="<<fPool[pIdx][vBin][cBin]->GetSize()<<" npart="<<totalPoolSize<<std::endl;
105 }