update to master versions
[u/mrichter/AliRoot.git] / PWGCF / Correlations / JCORRAN / AliJDataManager.cxx
CommitLineData
66be7134 1// $Id: AliJDataManager.cxx,v 1.13 2008/02/12 15:51:27 djkim Exp $
2////////////////////////////////////////////////////
3/*!
4 \file AliJDataManager.cxx
5 \brief
6 \author J. Rak, D.J.Kim, B.S Chang (University of Jyvaskyla)
7 \email: djkim@cc.jyu.fi
8 \version $Revision: 1.13 $
9 \date $Date: 2008/02/12 15:51:27 $
10 */
11////////////////////////////////////////////////////
12
13
14#include "AliJDataManager.h"
15
16#include <TH1.h>
17#include <TH2.h>
18#include <TProfile.h>
19#include <TFile.h>
20#include <TTree.h>
21#include <TChain.h>
22#include <TClonesArray.h>
23
24#include "AliJConst.h"
25#include "AliJBaseTrack.h"
26#include "AliJTrack.h"
27#include "AliJMCTrack.h"
28#include "AliJPhoton.h"
29#include "AliJEventHeader.h"
30// TODO #include "AliESDVZERO.h"
31#include "AliJHistos.h"
32
33#include "AliJCard.h"
34#include "AliJEventPool.h"
35
36#include "AliJRunHeader.h"
37#include "AliJCorrelations.h"
38#include "AliJTrackCut.h"
39#include <AliJRunTable.h>
40
41//______________________________________________________________________________
42AliJDataManager::AliJDataManager(AliJCard *inCard, AliJHistos *histin, AliJCorrelations *corrin, Bool_t execLocal ):
43 fChain(NULL),
44 fCard(inCard),
45 fhistos(histin),
46 fcorrelations(corrin),
47 fRunHeader(NULL),
48 fEventHeader(NULL),
49 fEventHeaderList(NULL),
50 fTrackList(NULL),
51 fPhotonList(NULL),
52 fCellList(NULL),
53 fPhotonListRecalib(NULL),
54 fCellListRecalib(NULL),
55 fMCTrackList(NULL),
56 fVZEROData(NULL),
57 fRunInfoList(NULL),
58 fhadronSelectionCut(0),
59 fFilterMap(0),
60 fFName(),
61 fExecLocal(execLocal),
62 fTriggerMask(0),
63 fTrackCut(NULL)
64{
65 // constructor
66 fChain = new TChain("JODTree");
67 fhadronSelectionCut = int(fCard->Get("HadronSelectionCut"));
68
69
70 fTriggerMask = fCard->Get("TriggerMask");
71
72 fTrackCut = new AliJTrackCut;
73}
74
75//______________________________________________________________________________
76AliJDataManager::~AliJDataManager(){
77 // destructor
78 if( fChain ) delete fChain;
79 if( fTrackCut) delete fTrackCut;
80}
81
82//______________________________________________________________________________
83AliJDataManager::AliJDataManager() :
84 fChain(NULL),
85 fCard(NULL),
86 fhistos(NULL),
87 fcorrelations(NULL),
88 fRunHeader(NULL),
89 fEventHeader(NULL),
90 fEventHeaderList(NULL),
91 fTrackList(NULL),
92 fPhotonList(NULL),
93 fCellList(NULL),
94 fPhotonListRecalib(NULL),
95 fCellListRecalib(NULL),
96 fMCTrackList(NULL),
97 fVZEROData(NULL),
98 fRunInfoList(NULL),
99 fhadronSelectionCut(0),
100 fFilterMap(0),
101 fFName(),
102 fExecLocal(true),
103 fTriggerMask(0),
104 fTrackCut(NULL)
105{
106 // default constructor
107}
108
109//______________________________________________________________________________
110AliJDataManager::AliJDataManager(const AliJDataManager& obj) :
111 fChain(obj.fChain),
112 fCard(obj.fCard),
113 fhistos(obj.fhistos),
114 fcorrelations(obj.fcorrelations),
115 fRunHeader(obj.fRunHeader),
116 fEventHeader(obj.fEventHeader),
117 fEventHeaderList(obj.fEventHeaderList),
118 fTrackList(obj.fTrackList),
119 fPhotonList(obj.fPhotonList),
120 fCellList(obj.fCellList),
121 fPhotonListRecalib(obj.fPhotonListRecalib),
122 fCellListRecalib(obj.fCellListRecalib),
123 fMCTrackList(obj.fMCTrackList),
124 fVZEROData(obj.fVZEROData),
125 fRunInfoList(obj.fRunInfoList),
126 fhadronSelectionCut(obj.fhadronSelectionCut),
127 fFilterMap(obj.fFilterMap),
128 fFName(obj.fFName),
129 fExecLocal(obj.fExecLocal),
130 fTriggerMask(obj.fTriggerMask),
131 fTrackCut(obj.fTrackCut)
132{
133 // copy constructor TODO: proper handling of pointer data members
134 JUNUSED(obj);
135}
136
137//______________________________________________________________________________
138AliJDataManager& AliJDataManager::operator=(const AliJDataManager& obj){
139 // equal sign TODO: contents
140 JUNUSED(obj);
141 return *this;
142}
143
144
145//______________________________________________________________________________
146
147bool AliJDataManager::IsGoodEvent(){
148 // event checker
149 if(fEventHeader==NULL) return false;
150 int nContributorVtx = fEventHeader->GetVtxMult();
151 double zVert = fEventHeader->GetZVertex();
152 UInt_t triggermaskJCorran = fEventHeader->GetTriggerMaskJCorran();
153 //double ZVertErr = fEventHeader->GetZVertexErr();
154 bool goodVertex = kFALSE;
155 bool triggerred = (IsSelectedTrigger((int) triggermaskJCorran)); // CUT1
156
157 bool aMB = triggermaskJCorran & ( 1<< kMinBiasTriggerBitJCorran );
158 bool aCentral = triggermaskJCorran & ( 1<<kCentralTriggerBitJCorran );
159 bool aSemiCentral = triggermaskJCorran & ( 1<<kSemiCentralTriggerBitJCorran );
160
161 /*
162 for( int i=0;i<32;i++ ){
163 cout<<(triggermaskJCorran&(1<<i)?1:0)<<" ";
164 }
165 cout<<endl;
166 */
167
168 if( aMB ) fhistos->fhEvents->Fill( 10 );
169 if( aCentral ) fhistos->fhEvents->Fill( 11 );
170 if( aSemiCentral ) fhistos->fhEvents->Fill( 12 );
171 if( aMB || aCentral ) fhistos->fhEvents->Fill( 13 );
172 if( aMB || aCentral || aSemiCentral ) fhistos->fhEvents->Fill( 14 );
173
174 for( int i=0;i < 31 ;i++ ){
175 if( fEventHeader->GetTriggerMaskAlice() & BIT(i) )
176 fhistos->fhEventTrigger->Fill(i);
177 }
178 fhistos->fhEventTrigger->Fill(41);
179
180 /*
181 if(!AliJRunTable::GetInstance().IsHeavyIon()){ //pp data
182 if(fRunHeader->GetRunNumber() >= 146686 && fRunHeader->GetRunNumber() <= 146860){ //p+p 2.76
183 if(!(fEventHeader->GetTriggerMaskAlice() & (1<<13))) triggerred= kFALSE; //noSDD CINT1-B-NOPF-FASTNOTRD
184 // Check with BS again about woSDD
185 }
186 }
187 */
188 // pPb run
189 /*
190 if(AliJRunTable::GetInstance().IsPA()){ //p+Pb
191 if(
192 //(fEventHeader->GetTriggerMaskAlice() & (1<<20)) ) // kINT7 MB
193 ////(fEventHeader->GetTriggerMaskJCorran() & (1<<3)) ) // Emc1Gamma
194 (fEventHeader->GetTriggerMaskJCorran() & (1<<4)) ) // kEMCEJE
195 triggerred= kTRUE; //
196 // Check with BS again about woSDD
197 }
198 */
199 //6 CINT7-B-NOPF-ALLNOTRD
200 //7 CINT7-ACE-NOPF-ALLNOTRD
201 //8 CINT7-A-NOPF-ALLNOTRD
202 //9 CINT7-C-NOPF-ALLNOTRD
203 //17 CEMC7EG1-B-NOPF-ALLNOTRD
204 //18 CEMC7EG2-B-NOPF-ALLNOTRD
205 //19 CEMC7EJ1-B-NOPF-ALLNOTRD
206 //20 CEMC7EJ2-B-NOPF-ALLNOTRD
207
208 //Emc1GammaTriggerBitJCorran
209
210 if(triggerred){
211 fhistos->fhEvents->Fill( 1 );
212 if(nContributorVtx==0){
213 fhistos->fhVertexZTriggVtx->Fill(nContributorVtx,0.);
214 }else{
215 fhistos->fhEvents->Fill( 2 );
216 //cout<<zVert << endl;
217 fhistos->fhZVertRaw->Fill(zVert);
218 //fhistos->fhZVertRawErr->Fill(ZVertErr);
219 fhistos->fhVertexZTriggVtx->Fill(nContributorVtx,zVert);
220 goodVertex = (bool) fCard->VertInZRange(zVert);
221
222 if( goodVertex )
223 fhistos->fhEvents->Fill( 3 );
224 }
225 }
226 //Trigger to be selected from the JCorran trigger mask is specified in the fCard
227 //if(( IsSelectedTrigger((int) triggermaskJCorran )
228 // || ( fCard->MbTrigger((int) triggermaskJCorran ) && fCard->MixMBForPi0Mass() ))
229 if(
230 triggerred
231 && goodVertex ){ //Cut2
232
233 fhistos->fhEvents->Fill( 4 );
234 return true;
235 }else{
236 return false;
237 }
238}
239
240//______________________________________________________________________________
241void AliJDataManager::RegisterList(TClonesArray* listToFill, TClonesArray* listFromToFill,
242 int cBin, int zBin, particleType whatToFill){
243 // corrType whatCorrType){
244
245 // this is here just to silence the bloody rule checker
246 JUNUSED( cBin );
247 JUNUSED( zBin );
248 JUNUSED(listFromToFill);
249 JUNUSED( listToFill );
250
251 int noIn=0, counter=0;
252 // Double_t pid[10]={0};
253 // bool isAliPion = 0;
254 // bool isAliKaon = 0;
255 // bool isAliProton = 0;
256
257 switch (whatToFill) {
258
5ca97880 259 case kJPhoton:
66be7134 260 break;
5ca97880 261 case kJPizero:
66be7134 262 break;
5ca97880 263 case kJHadron:
66be7134 264 noIn = fTrackList->GetEntriesFast();
265 counter = 0;
266 {
267 for(int ii=0;ii<noIn;ii++){ // loop for all tracks
268 AliJTrack *cgl = (AliJTrack*)fTrackList->At(ii);
269 //if(fhadronSelectionCut == kTrackCutJFG || fhadronSelectionCut == kTrackCutHBT) cgl->SetUseTPCTrack();
270
271 // checking bit convention
272 for(int iTrackSelection=0; iTrackSelection<32; iTrackSelection++) {
273 if( cgl->IsFiltered(iTrackSelection) ) fhistos->fhTrackSelection->Fill( iTrackSelection );
274 }
275 for(int iTrackSelection=0; iTrackSelection<32; iTrackSelection++) {
276 if( cgl->TestBit(BIT(iTrackSelection)) ) fhistos->fhTrackSelection->Fill( iTrackSelection+50 );
277 }
278
279 if( 1
280 //&& ( cgl->GetFilterMap() & GetFilterMap() )
281 && fTrackCut->IsSelected( cgl, fhadronSelectionCut )
282 && fTrackCut->SetMomentum( cgl, fhadronSelectionCut )
283 && fCard->IsInEtaRange(cgl->Eta())
284 ){ //
285 cgl->SetID(ii);
5ca97880 286 cgl->SetParticleType(kJHadron);
66be7134 287 new ((*listToFill)[counter++]) AliJTrack(*cgl);
288 }
289 }
290 }
291 break;
292
5ca97880 293 case kJProton:
66be7134 294 noIn = fTrackList->GetEntriesFast();
295 counter = 0;
296 for(int ii=0;ii<noIn;ii++){ // loop for all tracks
297 AliJTrack *cgl = (AliJTrack*)fTrackList->At(ii);
298 Double32_t prob = 0.9;//cgl->GetPID(AliJTrack::kProtonAliJ, AliJTrack::kTPCTOF);
299 //cout << AliJTrack::kProtonAli <<"\t"<< AliJTrack::kTPCTOF <<"\t"<< prob<< endl;
300 //Double32_t prob = cgl->GetPID(AliJTrack::AliJTrkPID(4), AliJTrack::AliJTrkPIDmethod(2));
301 if( 1
302 && fCard->IsInEtaRange(cgl->Eta())
303 && ( cgl->GetFilterMap() & GetFilterMap() )
304 && prob > 0.9
305 ){ // All cuts applied in the Train production stage
306 cgl->SetID(ii);
5ca97880 307 cgl->SetParticleType(kJHadron);
66be7134 308 new ((*listToFill)[counter++]) AliJTrack(*cgl);
309 }
310 }
311 break;
312
313 default :
314 cout<<"Unknown particle type in JDatamenager.cxx/fillList()"<<endl;
315 exit(0);
316 }//switch for PID
317
318 // make the indexing correct
319 listToFill->Compress();
320}
321
322
323//______________________________________________________________________________
324void AliJDataManager::ChainInputStream(const char* infileList){
325 // chainer
326
327 if( fExecLocal ){
328
329 // read root nano data files in a list
330 char inFile[200];
331 ifstream infiles(infileList);
332 while ( infiles >> inFile){
333 fChain->Add(inFile);
334 }
335 //fChain->Print();
336
337 if(fChain->GetEntriesFast()<=0){
338 cout<<"Empty chain from "<<infileList<<endl;
339 exit(0);
340 }
341 cout<<Form("there are %d events.\n", (int)fChain->GetEntries())<<endl;
342
343 // Load Branch
344 if( fChain->FindBranch("HeaderList") )
345 fChain->SetBranchAddress("HeaderList", &fEventHeaderList);
346 if( fChain->FindBranch("TrackList") )
347 fChain->SetBranchAddress("TrackList", &fTrackList);
348 if( fChain->FindBranch("PhotonList") )
349 fChain->SetBranchAddress("PhotonList", &fPhotonList);
350 if( fChain->FindBranch("CaloCellList") )
351 fChain->SetBranchAddress("CaloCellList", &fCellList);
352 if( fChain->FindBranch("MCTrackList") )
353 fChain->SetBranchAddress("MCTrackList", &fMCTrackList);
354
355 if( AliJRunTable::GetInstance().IsHeavyIon() && fChain->FindBranch("AliESDVZERO")) { // if fevent-plane sources were stored
356 fChain->SetBranchAddress("AliESDVZERO", &fVZEROData);
357 // TODO for FMD, TZERO
358 }
359
360 // fChain->SetBranchAddress("AliJMCTrackList", &fMCTrackList);
361 // Event Header
362 //Read Run Header
363 TFile* firstfile = fChain->GetFile();
364 cout<<"============================================DEBUG 10 "<<endl;
365 TList *fUserInfo =(TList*) firstfile->Get("RunInfo");
366 fUserInfo->Print();
367 fRunHeader=(AliJRunHeader*) fUserInfo->First();
368 }
369 else{
370 fRunHeader=(AliJRunHeader*) fRunInfoList->First();
371 }
372
373 if(fRunHeader){
374 fRunHeader->PrintOut();
375 }
376
377}
378
379
380//______________________________________________________________________________
381Double_t AliJDataManager::LoadEvent(int ievt){
382 //clear clones array and counters
383 //load the new fevent
384
385 int v;
386
387 v = 0;
388
389 if( fExecLocal ){
390 //fChain->GetEntry(ievt);
391 TString fp;
392
393 //if( fExperiment == kMC ){
394 // return fMCJDmg->GenerateEvent();
395 //} else {
396 v = ((TTree*)fChain)->GetEntry(ievt);
397
398 fp = fChain->GetCurrentFile()->GetPath();
399 if( fp != fFName ){
400 cout << fp.Data() << endl;
401 fFName = fp;
402 }
403
404 }
405
406 fEventHeader = dynamic_cast<AliJEventHeader*>(fEventHeaderList->At(0));
407
408 return v;
409 //}
410}
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431