]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/Base/AliAnalysisHelperJetTasks.cxx
fixcompiler warnings
[u/mrichter/AliRoot.git] / PWG4 / Base / AliAnalysisHelperJetTasks.cxx
CommitLineData
aeb249fb 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
16//
17// Helper Class that contains a lot of
18// usefull static functions jet matchin pythia access etc.
19//
20// Author: C. Klein-Boesing IKP Muenster
f3050824 21
22#include "TROOT.h"
383d44fd 23#include "TDirectory.h"
519378fb 24#include "TKey.h"
f3050824 25#include "TList.h"
519378fb 26#include "TSystem.h"
188a1ba9 27#include "TH1F.h"
28#include "TProfile.h"
29#include "THnSparse.h"
c6049d04 30#include "TSeqCollection.h"
31#include "TMethodCall.h"
188a1ba9 32#include "TFile.h"
519378fb 33#include "TString.h"
c74e9b54 34#include "TArrayI.h"
35#include "TArrayS.h"
c0ff24c6 36#include "TArrayF.h"
c74e9b54 37
f3050824 38#include "AliMCEvent.h"
5c047edc 39#include "AliLog.h"
59543510 40#include "AliESDEvent.h"
db6bcb0e 41#include "AliAODJet.h"
cce8b687 42#include "AliAODEvent.h"
f3050824 43#include "AliStack.h"
44#include "AliGenEventHeader.h"
45#include "AliGenCocktailEventHeader.h"
955d29ba 46#include <AliGenDPMjetEventHeader.h>
f3050824 47#include "AliGenPythiaEventHeader.h"
48#include <fstream>
49#include <iostream>
50#include "AliAnalysisHelperJetTasks.h"
6f3f79de 51#include "TMatrixDSym.h"
52#include "TMatrixDSymEigen.h"
53#include "TVector.h"
f3050824 54
55ClassImp(AliAnalysisHelperJetTasks)
56
955d29ba 57Int_t AliAnalysisHelperJetTasks::fgLastProcessType = -1;
f3050824 58
59
aeb249fb 60AliGenPythiaEventHeader* AliAnalysisHelperJetTasks::GetPythiaEventHeader(const AliMCEvent *mcEvent){
61 //
62 // Fetch the pythia event header
63 //
3e1c1eee 64 if(!mcEvent)return 0;
f3050824 65 AliGenEventHeader* genHeader = mcEvent->GenEventHeader();
66 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
67 if(!pythiaGenHeader){
68 // cocktail ??
69 AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(genHeader);
70
71 if (!genCocktailHeader) {
5c047edc 72 AliWarningGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),"Unknown header type (not Pythia or Cocktail)");
73 // AliWarning(Form("%s %d: Unknown header type (not Pythia or Cocktail)",(char*)__FILE__,__LINE__));
f3050824 74 return 0;
75 }
76 TList* headerList = genCocktailHeader->GetHeaders();
77 for (Int_t i=0; i<headerList->GetEntries(); i++) {
78 pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
79 if (pythiaGenHeader)
80 break;
81 }
82 if(!pythiaGenHeader){
5c047edc 83 AliWarningGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),"Pythia event header not found");
f3050824 84 return 0;
85 }
86 }
87 return pythiaGenHeader;
88
89}
90
91
92void AliAnalysisHelperJetTasks::PrintStack(AliMCEvent *mcEvent,Int_t iFirst,Int_t iLast,Int_t iMaxPrint){
aeb249fb 93 //
94 // Print the stack informatuin up to the iMaxPrint event
95 //
f3050824 96
97 AliStack *stack = mcEvent->Stack();
98 if(!stack){
99 Printf("%s%d No Stack available",(char*)__FILE__,__LINE__);
100 return;
101 }
102
103 static Int_t iCount = 0;
104 if(iCount>iMaxPrint)return;
105 Int_t nStack = stack->GetNtrack();
106 if(iLast == 0)iLast = nStack;
107 else if(iLast > nStack)iLast = nStack;
108
109
110 Printf("####################################################################");
111 for(Int_t np = iFirst;np<iLast;++np){
112 TParticle *p = stack->Particle(np);
113 Printf("Nr.%d --- Status %d ---- Mother1 %d Mother2 %d Daughter1 %d Daughter2 %d ",
114 np,p->GetStatusCode(),p->GetMother(0),p->GetMother(1),p->GetDaughter(0),p->GetDaughter(1));
115 Printf("Eta %3.3f Phi %3.3f ",p->Eta(),p->Phi());
116 p->Print();
117 Printf("---------------------------------------");
118 }
119 iCount++;
120}
121
122
db6bcb0e 123
124
3dc5a1a4 125void AliAnalysisHelperJetTasks::GetClosestJets(AliAODJet *genJets,const Int_t &kGenJets,
aeb249fb 126 const AliAODJet *recJets,const Int_t &kRecJets,
db6bcb0e 127 Int_t *iGenIndex,Int_t *iRecIndex,
128 Int_t iDebug,Float_t maxDist){
129
130 //
131 // Relate the two input jet Arrays
132 //
133
134 //
135 // The association has to be unique
136 // So check in two directions
137 // find the closest rec to a gen
138 // and check if there is no other rec which is closer
139 // Caveat: Close low energy/split jets may disturb this correlation
140
3dc5a1a4 141
db6bcb0e 142 // Idea: search in two directions generated e.g (a--e) and rec (1--3)
143 // Fill a matrix with Flags (1 for closest rec jet, 2 for closest rec jet
144 // in the end we have something like this
145 // 1 2 3
146 // ------------
147 // a| 3 2 0
148 // b| 0 1 0
149 // c| 0 0 3
150 // d| 0 0 1
151 // e| 0 0 1
152 // Topology
153 // 1 2
154 // a b
155 //
156 // d c
157 // 3 e
158 // Only entries with "3" match from both sides
3dc5a1a4 159
160 // In case we have more jets than kmaxjets only the
161 // first kmaxjets are searched
162 // all other are -1
163 // use kMaxJets for a test not to fragemnt the memory...
164
92432351 165 for(int i = 0;i < kRecJets;++i)iGenIndex[i] = -1;
166 for(int j = 0;j < kGenJets;++j)iRecIndex[j] = -1;
3dc5a1a4 167
168
db6bcb0e 169
170 const int kMode = 3;
171
3dc5a1a4 172 const Int_t nGenJets = TMath::Min(kMaxJets,kGenJets);
173 const Int_t nRecJets = TMath::Min(kMaxJets,kRecJets);
db6bcb0e 174
175 if(nRecJets==0||nGenJets==0)return;
176
3dc5a1a4 177 // UShort_t *iFlag = new UShort_t[nGenJets*nRecJets];
79ac637f 178 UShort_t iFlag[kMaxJets*kMaxJets] = {0}; // all values set to zero
db6bcb0e 179 for(int i = 0;i < nGenJets;++i){
180 for(int j = 0;j < nRecJets;++j){
181 iFlag[i*nGenJets+j] = 0;
182 }
183 }
184
185
186
187 // find the closest distance to the generated
188 for(int ig = 0;ig<nGenJets;++ig){
189 Float_t dist = maxDist;
190 if(iDebug>1)Printf("Gen (%d) p_T %3.3f eta %3.3f ph %3.3f ",ig,genJets[ig].Pt(),genJets[ig].Eta(),genJets[ig].Phi());
191 for(int ir = 0;ir<nRecJets;++ir){
e6a92928 192 if(iDebug>1){
193 printf("Rec (%d) ",ir);
194 Printf("p_T %3.3f eta %3.3f ph %3.3f ",recJets[ir].Pt(),recJets[ir].Eta(),recJets[ir].Phi());
195 }
db6bcb0e 196 Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
db6bcb0e 197 if(iDebug>1)Printf("Distance (%d)--(%d) %3.3f ",ig,ir,dR);
198 if(dR<dist){
199 iRecIndex[ig] = ir;
200 dist = dR;
201 }
202 }
c74e9b54 203 if(iRecIndex[ig]>=0)iFlag[ig*nRecJets+iRecIndex[ig]]+=1;
db6bcb0e 204 // reset...
205 iRecIndex[ig] = -1;
206 }
207 // other way around
208 for(int ir = 0;ir<nRecJets;++ir){
209 Float_t dist = maxDist;
210 for(int ig = 0;ig<nGenJets;++ig){
211 Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
212 if(dR<dist){
213 iGenIndex[ir] = ig;
214 dist = dR;
215 }
216 }
c74e9b54 217 if(iGenIndex[ir]>=0)iFlag[iGenIndex[ir]*nRecJets+ir]+=2;
db6bcb0e 218 // reset...
219 iGenIndex[ir] = -1;
220 }
221
222 // check for "true" correlations
223
224 if(iDebug>1)Printf(">>>>>> Matrix");
225
226 for(int ig = 0;ig<nGenJets;++ig){
227 for(int ir = 0;ir<nRecJets;++ir){
228 // Print
c74e9b54 229 if(iDebug>1)printf("Flag[%d][%d] %d ",ig,ir,iFlag[ig*nRecJets+ir]);
230
231 if(kMode==3){
232 // we have a uniqie correlation
233 if(iFlag[ig*nRecJets+ir]==3){
234 iGenIndex[ir] = ig;
235 iRecIndex[ig] = ir;
236 }
237 }
238 else{
239 // we just take the correlation from on side
240 if((iFlag[ig*nRecJets+ir]&2)==2){
241 iGenIndex[ir] = ig;
242 }
243 if((iFlag[ig*nRecJets+ir]&1)==1){
244 iRecIndex[ig] = ir;
245 }
246 }
247 }
248 if(iDebug>1)printf("\n");
249 }
250}
251
252
253
aeb249fb 254void AliAnalysisHelperJetTasks::GetClosestJets(const TList *genJetsList,const Int_t &kGenJets,
255 const TList *recJetsList,const Int_t &kRecJets,
c74e9b54 256 TArrayI &iGenIndex,TArrayI &iRecIndex,
257 Int_t iDebug,Float_t maxDist){
258
259 // Size indepnedendentt Implemenation of jet matching
260 // Thepassed TArrayI should be static in the user function an only increased if needed
261
262 //
263 // Relate the two input jet Arrays
264 //
265
266 //
267 // The association has to be unique
268 // So check in two directions
269 // find the closest rec to a gen
270 // and check if there is no other rec which is closer
271 // Caveat: Close low energy/split jets may disturb this correlation
272
273
274 // Idea: search in two directions generated e.g (a--e) and rec (1--3)
275 // Fill a matrix with Flags (1 for closest rec jet, 2 for closest rec jet
276 // in the end we have something like this
277 // 1 2 3
278 // ------------
279 // a| 3 2 0
280 // b| 0 1 0
281 // c| 0 0 3
282 // d| 0 0 1
283 // e| 0 0 1
284 // Topology
285 // 1 2
286 // a b
287 //
288 // d c
289 // 3 e
290 // Only entries with "3" match from both sides
291
292 iGenIndex.Reset(-1);
293 iRecIndex.Reset(-1);
294
295 const int kMode = 3;
296 const Int_t nGenJets = TMath::Min(genJetsList->GetEntries(),kGenJets);
297 const Int_t nRecJets = TMath::Min(recJetsList->GetEntries(),kRecJets);
298 if(nRecJets==0||nGenJets==0)return;
299
300 static TArrayS iFlag(nGenJets*nRecJets);
301 if(iFlag.GetSize()<(nGenJets*nRecJets)){
302 iFlag.Set(nGenJets*nRecJets);
303 }
304 iFlag.Reset(0);
305
306 // find the closest distance to the generated
307 for(int ig = 0;ig<nGenJets;++ig){
308 AliAODJet *genJet = (AliAODJet*)genJetsList->At(ig);
309 if(!genJet)continue;
310
311 Float_t dist = maxDist;
312 if(iDebug>1)Printf("Gen (%d) p_T %3.3f eta %3.3f ph %3.3f ",ig,genJet->Pt(),genJet->Eta(),genJet->Phi());
313 for(int ir = 0;ir<nRecJets;++ir){
314 AliAODJet *recJet = (AliAODJet*)recJetsList->At(ir);
315 if(!recJet)continue;
316 if(iDebug>1){
317 printf("Rec (%d) ",ir);
318 Printf("p_T %3.3f eta %3.3f ph %3.3f ",recJet->Pt(),recJet->Eta(),recJet->Phi());
319 }
320 Double_t dR = genJet->DeltaR(recJet);
321 if(iDebug>1)Printf("Distance (%d)--(%d) %3.3f ",ig,ir,dR);
322 if(dR<dist){
323 iRecIndex[ig] = ir;
324 dist = dR;
325 }
326 }
327 if(iRecIndex[ig]>=0)iFlag[ig*nRecJets+iRecIndex[ig]]+=1;
328 // reset...
329 iRecIndex[ig] = -1;
330 }
331 // other way around
332
333 for(int ir = 0;ir<nRecJets;++ir){
334 AliAODJet *recJet = (AliAODJet*)recJetsList->At(ir);
335 if(!recJet)continue;
336 Float_t dist = maxDist;
337 for(int ig = 0;ig<nGenJets;++ig){
338 AliAODJet *genJet = (AliAODJet*)genJetsList->At(ig);
339 if(!genJet)continue;
340 Double_t dR = genJet->DeltaR(recJet);
341 if(dR<dist){
342 iGenIndex[ir] = ig;
343 dist = dR;
344 }
345 }
346 if(iGenIndex[ir]>=0)iFlag[iGenIndex[ir]*nRecJets+ir]+=2;
347 // reset...
348 iGenIndex[ir] = -1;
349 }
350
351 // check for "true" correlations
352
353 if(iDebug>1)Printf(">>>>>> Matrix Size %d",iFlag.GetSize());
354
355 for(int ig = 0;ig<nGenJets;++ig){
356 for(int ir = 0;ir<nRecJets;++ir){
357 // Print
358 if(iDebug>1)printf("Flag2[%d][%d] %d ",ig,ir,iFlag[ig*nRecJets+ir]);
db6bcb0e 359
360 if(kMode==3){
361 // we have a uniqie correlation
c74e9b54 362 if(iFlag[ig*nRecJets+ir]==3){
db6bcb0e 363 iGenIndex[ir] = ig;
364 iRecIndex[ig] = ir;
365 }
366 }
367 else{
368 // we just take the correlation from on side
c74e9b54 369 if((iFlag[ig*nRecJets+ir]&2)==2){
db6bcb0e 370 iGenIndex[ir] = ig;
371 }
c74e9b54 372 if((iFlag[ig*nRecJets+ir]&1)==1){
db6bcb0e 373 iRecIndex[ig] = ir;
374 }
375 }
376 }
377 if(iDebug>1)printf("\n");
378 }
db6bcb0e 379}
380
aeb249fb 381void AliAnalysisHelperJetTasks::GetJetMatching(const TList *genJetsList, const Int_t &kGenJets,
382 const TList *recJetsList, const Int_t &kRecJets,
a7ac11bf 383 TArrayI &iMatchIndex, TArrayF &fPtFraction,
739e606a 384 Int_t iDebug, Float_t maxDist, Int_t mode){
a7ac11bf 385
386
387 // Matching jets from two lists
388 // Start with highest energetic jet from first list (generated/embedded)
389 // Calculate distance (\Delta R) to all jets from second list (reconstructed)
390 // Select N closest jets = kClosestJetsN
391 // Check energy fraction from jets from first list in jets from second list
392 // Matched jets = jet with largest energy fraction
393 // Store index of matched jet in TArrayI iMatchIndex
394
395 // reset index
396 iMatchIndex.Reset(-1);
397 fPtFraction.Reset(-1.);
398
399 // N closest jets: store list with index and \Delta R
400 const Int_t kClosestJetsN = 4;
401 Double_t closestJets[kClosestJetsN][2]; //[][0] = index, [][1] = \Delta R
739e606a 402
a7ac11bf 403 const Int_t nGenJets = TMath::Min(genJetsList->GetEntries(),kGenJets);
404 const Int_t nRecJets = TMath::Min(recJetsList->GetEntries(),kRecJets);
405 if(nRecJets==0||nGenJets==0) return;
406
407 AliAODJet *genJet = 0x0;
408 AliAODJet *recJet = 0x0;
409
410 // loop over generated/embedded jets
411 for(Int_t ig=0; ig<nGenJets; ++ig){
739e606a 412
413 for(Int_t i=0; i<kClosestJetsN; ++i){
414 closestJets[i][0] = -1; // index
415 closestJets[i][1] = 1e6; // delta R
416 }
417
a7ac11bf 418 genJet = (AliAODJet*)genJetsList->At(ig);
419 //if(!genJet || !JetSelected(genJet)) continue;
420 if(!genJet) continue;
421
422 // find N closest reconstructed jets
423 Double_t deltaR = 0.;
424 for(Int_t ir=0; ir<nRecJets; ++ir){
425 recJet = (AliAODJet*)recJetsList->At(ir);
426 //if(!recJet || !JetSelected(recJet)) continue;
427 if(!recJet) continue;
428
429 deltaR = genJet->DeltaR(recJet);
430
431 Int_t i=kClosestJetsN-1;
432 if(deltaR<closestJets[i][1] && deltaR<maxDist){
433 closestJets[i][0] = (Double_t) ir; // index
434 closestJets[i][1] = deltaR;
435
436 // sort array (closest at the beginning)
437 while(i>=1 && closestJets[i][1]<closestJets[i-1][1]){
438 Double_t tmpArr[2];
439 for(Int_t j=0; j<2; j++){
440 tmpArr[j] = closestJets[i-1][j];
441 closestJets[i-1][j] = closestJets[i][j];
442 closestJets[i][j] = tmpArr[j];
443 }
444 i--;
445 }
446 }
447 } // end: loop over reconstructed jets
448
449 // calculate fraction for the N closest jets
739e606a 450 Double_t maxFraction = -1.; // maximum found fraction in one jets
a7ac11bf 451 Double_t cumFraction = 0.; // cummulated fraction of closest jets (for break condition)
452 Double_t fraction = 0.;
453 Int_t ir = -1; // index of close reconstruced jet
454
455 for(Int_t irc=0; irc<kClosestJetsN; irc++){
456 ir = (Int_t)(closestJets[irc][0]);
739e606a 457 if(ir<0 || ir>nRecJets-1) continue;
a7ac11bf 458 recJet = (AliAODJet*)recJetsList->At(ir);
459 if(!(recJet)) continue;
460
739e606a 461 fraction = GetFractionOfJet(recJet,genJet,mode);
a7ac11bf 462
463 cumFraction += fraction;
464
465 // check if jet fullfills current matching condition
466 if(fraction>maxFraction){
467 // avoid multiple links
468 for(Int_t ij=0; ij<ig; ++ij){
469 if(iMatchIndex[ij]==ir) continue;
470 }
471 // set index
472 maxFraction = fraction;
473 fPtFraction[ig] = fraction;
474 iMatchIndex[ig] = ir;
475 }
476 // break condition: less energy left as already found in one jet or
477 // as required for positiv matching
478 if(1-cumFraction<maxFraction) break;
479 } // end: loop over closest jets
480
481 if(iMatchIndex[ig]<0){
482 if(iDebug) Printf("Matching failed for (gen) jet #%d", ig);
483 }
484 }
485}
486
739e606a 487Double_t AliAnalysisHelperJetTasks::GetFractionOfJet(const AliAODJet *recJet, const AliAODJet *genJet, Int_t mode){
aeb249fb 488 //
489 // get the fraction of hte signal jet in the full jt
490 //
a7ac11bf 491 Double_t ptGen = genJet->Pt();
492 if(ptGen==0.) return 999.;
493
494 Double_t ptAssocTracks = 0.; // sum of pT of tracks found in both jets
495
496 // look at tracks inside jet
497 TRefArray *genTrackList = genJet->GetRefTracks();
498 TRefArray *recTrackList = recJet->GetRefTracks();
499 Int_t nTracksGenJet = genTrackList->GetEntriesFast();
500 Int_t nTracksRecJet = recTrackList->GetEntriesFast();
501
502 AliAODTrack* recTrack;
503 AliAODTrack* genTrack;
504 for(Int_t ir=0; ir<nTracksRecJet; ++ir){
505 recTrack = (AliAODTrack*)(recTrackList->At(ir));
506 if(!recTrack) continue;
507
508 for(Int_t ig=0; ig<nTracksGenJet; ++ig){
509 genTrack = (AliAODTrack*)(genTrackList->At(ig));
510 if(!genTrack) continue;
511
512 // look if it points to the same track
739e606a 513 if( (mode&1)!=0 && genTrack==recTrack){
a7ac11bf 514 ptAssocTracks += genTrack->Pt();
515 break;
516 }
739e606a 517
518 if( (mode&2)!=0
519 && genTrack->GetLabel()>-1
520 && recTrack->GetLabel()>-1
521 && genTrack->GetLabel()==recTrack->GetLabel()){
522
523 ptAssocTracks += genTrack->Pt();
524 break;
525 }
a7ac11bf 526 }
527 }
528
529 // calculate fraction
530 Double_t fraction = ptAssocTracks/ptGen;
531
532 return fraction;
533}
db6bcb0e 534
c74e9b54 535
57cd3e7c 536void AliAnalysisHelperJetTasks::MergeOutputDirs(const char* cFiles,const char* cPattern,const char *cOutFile,Bool_t bUpdate){
c6049d04 537 // Routine to merge only directories containing the pattern
538 //
539 TString outFile(cOutFile);
540 if(outFile.Length()==0)outFile = Form("%s.root",cPattern);
541 ifstream in1;
542 in1.open(cFiles);
543 // open all files
544 TList fileList;
545 char cFile[240];
57cd3e7c 546 while(in1>>cFile){// only open the first file
547 Printf("Adding %s",cFile);
548 TFile *f1 = TFile::Open(cFile);
549 fileList.Add(f1);
c6049d04 550 }
551
552 TFile *fOut = 0;
553 if(fileList.GetEntries()){// open the first file
554 TFile* fIn = dynamic_cast<TFile*>(fileList.At(0));
57cd3e7c 555 if(!fIn){
c6049d04 556 Printf("Input File not Found");
e855f5c5 557 return;
c6049d04 558 }
559 // fetch the keys for the directories
560 TList *ldKeys = fIn->GetListOfKeys();
561 for(int id = 0;id < ldKeys->GetEntries();id++){
562 // check if it is a directory
563 TKey *dKey = (TKey*)ldKeys->At(id);
564 TDirectory *dir = dynamic_cast<TDirectory*>(dKey->ReadObj());
565 if(dir){
566 TString dName(dir->GetName());
567 if(dName.Contains(cPattern)){
568 // open new file if first match
569 if(!fOut){
57cd3e7c 570 if(bUpdate)fOut = new TFile(outFile.Data(),"UPDATE");
571 else fOut = new TFile(outFile.Data(),"RECREATE");
c6049d04 572 }
573 // merge all the stuff that is in this directory
574 TList *llKeys = dir->GetListOfKeys();
575 TList *tmplist;
576 TMethodCall callEnv;
57cd3e7c 577
578 fOut->cd();
579 TDirectory *dOut = fOut->mkdir(dir->GetName());
580
c6049d04 581 for(int il = 0;il < llKeys->GetEntries();il++){
57cd3e7c 582 TKey *lKey = (TKey*)llKeys->At(il);
c6049d04 583 TObject *object = dynamic_cast<TObject*>(lKey->ReadObj());
584 // from TSeqCollections::Merge
585 if(!object)continue;
586 // If current object is not mergeable just skip it
587 if (!object->IsA()) {
588 continue;
589 }
590 callEnv.InitWithPrototype(object->IsA(), "Merge", "TCollection*");
591 if (!callEnv.IsValid()) {
592 continue;
593 }
594 // Current object mergeable - get corresponding objects in input lists
595 tmplist = new TList();
596 for(int i = 1; i < fileList.GetEntries();i++){
597 TDirectory *fInTmp = dynamic_cast<TDirectory*>(fileList.At(i));
598 if(!fInTmp){
599 Printf("File %d not found",i);
600 continue;
601 }
602 TDirectory *dTmp = (TDirectory*)fInTmp->Get(dName.Data());
603 if(!dTmp){
604 Printf("Directory %s not found",dName.Data());
605 continue;
606 }
607 TObject* oTmp = (TObject*)dTmp->Get(object->GetName());
608 if(!oTmp){
609 Printf("Object %s not found",object->GetName());
610 continue;
611 }
612 tmplist->Add(oTmp);
613 }
614 callEnv.SetParam((Long_t) tmplist);
615 callEnv.Execute(object);
616 delete tmplist;tmplist = 0;
57cd3e7c 617 dOut->cd();
618 object->Write(object->GetName(),TObject::kSingleKey);
c6049d04 619 }
620 }
621 }
622 }
623 if(fOut){
624 fOut->Close();
625 }
626 }
627}
db6bcb0e 628
04152663 629void AliAnalysisHelperJetTasks::MergeOutput(const char* cFiles,const char* cDir,const char *cList,const char *cOutFile,Bool_t bUpdate){
db6bcb0e 630
188a1ba9 631 // This is used to merge the analysis-output from different
632 // data samples/pt_hard bins
633 // in case the eventweigth was set to xsection/ntrials already, this
634 // is not needed. Both methods only work in case we do not mix different
635 // pt_hard bins, and do not have overlapping bins
db6bcb0e 636
188a1ba9 637 const Int_t nMaxBins = 12;
638 // LHC08q jetjet100: Mean = 1.42483e-03, RMS = 6.642e-05
639 // LHC08r jetjet50: Mean = 2.44068e-02, RMS = 1.144e-03
640 // LHC08v jetjet15-50: Mean = 2.168291 , RMS = 7.119e-02
641 // const Float_t xsection[nBins] = {2.168291,2.44068e-02};
642
643 Float_t xsection[nMaxBins];
644 Float_t nTrials[nMaxBins];
645 Float_t sf[nMaxBins];
646 TList *lIn[nMaxBins];
383d44fd 647 TDirectory *dIn[nMaxBins];
188a1ba9 648 TFile *fIn[nMaxBins];
649
650 ifstream in1;
651 in1.open(cFiles);
652
653 char cFile[120];
654 Int_t ibTotal = 0;
655 while(in1>>cFile){
656 fIn[ibTotal] = TFile::Open(cFile);
4d723ede 657 if(strlen(cDir)==0){
658 dIn[ibTotal] = gDirectory;
659 }
660 else{
661 dIn[ibTotal] = (TDirectory*)fIn[ibTotal]->Get(cDir);
662 }
383d44fd 663 if(!dIn[ibTotal]){
664 Printf("%s:%d No directory %s found, exiting...",__FILE__,__LINE__,cDir);
665 fIn[ibTotal]->ls();
666 return;
667 }
668
669 lIn[ibTotal] = (TList*)dIn[ibTotal]->Get(cList);
670 Printf("Merging file %s %s",cFile, cDir);
188a1ba9 671 if(!lIn[ibTotal]){
672 Printf("%s:%d No list %s found, exiting...",__FILE__,__LINE__,cList);
673 fIn[ibTotal]->ls();
674 return;
675 }
676 TH1* hTrials = (TH1F*)lIn[ibTotal]->FindObject("fh1Trials");
677 if(!hTrials){
678 Printf("%s:%d fh1PtHard_Trials not found in list, exiting...",__FILE__,__LINE__);
679 return;
680 }
681 TProfile* hXsec = (TProfile*)lIn[ibTotal]->FindObject("fh1Xsec");
682 if(!hXsec){
683 Printf("%s:%d fh1Xsec not found in list, exiting...",__FILE__,__LINE__);
684 return;
685 }
686 xsection[ibTotal] = hXsec->GetBinContent(1);
687 nTrials[ibTotal] = hTrials->Integral();
688 sf[ibTotal] = xsection[ibTotal]/ nTrials[ibTotal];
689 ibTotal++;
690 }
691
692 if(ibTotal==0){
693 Printf("%s:%d No files found for mergin, exiting",__FILE__,__LINE__);
694 return;
695 }
696
383d44fd 697 TFile *fOut = 0;
698 if(bUpdate)fOut = new TFile(cOutFile,"UPDATE");
699 else fOut = new TFile(cOutFile,"RECREATE");
700 TDirectory *dOut = fOut->mkdir(dIn[0]->GetName());
701 dOut->cd();
188a1ba9 702 TList *lOut = new TList();
703 lOut->SetName(lIn[0]->GetName());
383d44fd 704
188a1ba9 705 // for the start scale all...
706 for(int ie = 0; ie < lIn[0]->GetEntries();++ie){
707 TH1 *h1Add = 0;
708 THnSparse *hnAdd = 0;
709 for(int ib = 0;ib < ibTotal;++ib){
710 // dynamic cast does not work with cint
711 TObject *h = lIn[ib]->At(ie);
712 if(h->InheritsFrom("TH1")){
713 TH1 *h1 = (TH1*)h;
714 if(ib==0){
715 h1Add = (TH1*)h1->Clone(h1->GetName());
716 h1Add->Scale(sf[ib]);
717 }
718 else{
719 h1Add->Add(h1,sf[ib]);
720 }
721 }
722 else if(h->InheritsFrom("THnSparse")){
723 THnSparse *hn = (THnSparse*)h;
724 if(ib==0){
725 hnAdd = (THnSparse*)hn->Clone(hn->GetName());
726 hnAdd->Scale(sf[ib]);
727 }
728 else{
729 hnAdd->Add(hn,sf[ib]);
730 }
731 }
732
733
734 }// ib
735 if(h1Add)lOut->Add(h1Add);
736 else if(hnAdd)lOut->Add(hnAdd);
737 }
383d44fd 738 dOut->cd();
188a1ba9 739 lOut->Write(lOut->GetName(),TObject::kSingleKey);
740 fOut->Close();
741}
519378fb 742
743Bool_t AliAnalysisHelperJetTasks::PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials){
744 //
745 // get the cross section and the trails either from pyxsec.root or from pysec_hists.root
746 // This is to called in Notify and should provide the path to the AOD/ESD file
747
748 TString file(currFile);
749 fXsec = 0;
750 fTrials = 1;
751
752 if(file.Contains("root_archive.zip#")){
753 Ssiz_t pos1 = file.Index("root_archive",12,TString::kExact);
754 Ssiz_t pos = file.Index("#",1,pos1,TString::kExact);
755 file.Replace(pos+1,20,"");
756 }
757 else {
758 // not an archive take the basename....
759 file.ReplaceAll(gSystem->BaseName(file.Data()),"");
760 }
761 Printf("%s",file.Data());
762
763
764
765
766 TFile *fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec.root")); // problem that we cannot really test the existance of a file in a archive so we have to lvie with open error message from root
767 if(!fxsec){
768 // next trial fetch the histgram file
769 fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root"));
770 if(!fxsec){
771 // not a severe condition but inciate that we have no information
772 return kFALSE;
773 }
774 else{
775 // find the tlist we want to be independtent of the name so use the Tkey
776 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
777 if(!key){
778 fxsec->Close();
779 return kFALSE;
780 }
781 TList *list = dynamic_cast<TList*>(key->ReadObj());
782 if(!list){
783 fxsec->Close();
784 return kFALSE;
785 }
786 fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1);
787 fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1);
788 fxsec->Close();
789 }
790 } // no tree pyxsec.root
791 else {
792 TTree *xtree = (TTree*)fxsec->Get("Xsection");
793 if(!xtree){
794 fxsec->Close();
795 return kFALSE;
796 }
797 UInt_t ntrials = 0;
798 Double_t xsection = 0;
799 xtree->SetBranchAddress("xsection",&xsection);
800 xtree->SetBranchAddress("ntrials",&ntrials);
801 xtree->GetEntry(0);
802 fTrials = ntrials;
803 fXsec = xsection;
804 fxsec->Close();
805 }
806 return kTRUE;
807}
6f3f79de 808
1aa3886d 809Bool_t AliAnalysisHelperJetTasks::PrintDirectorySize(const char* currFile,Int_t iDetail){
383d44fd 810
aeb249fb 811 //
812 // Print the size on disk and in memory occuppied by a directory
813 //
814
1aa3886d 815 TFile *fDummy = 0;
816 if(iDetail>=0)fDummy = TFile::Open("/tmp/dummy.root","RECREATE");
817
383d44fd 818 TFile *fIn = TFile::Open(currFile);
819 if(!fIn){
820 // not a severe condition but inciate that we have no information
821 return kFALSE;
822 }
823 // find the tlists we want to be independtent of the name so use the Tkey
824 TList* keyList = fIn->GetListOfKeys();
cc89bb69 825 Float_t memorySize = 0;
826 Float_t diskSize = 0;
383d44fd 827
828 for(int i = 0;i < keyList->GetEntries();i++){
829 TKey* ikey = (TKey*)keyList->At(i);
830
831 // TList *list = dynamic_cast<TList*>(key->ReadObj());
832 // TNamed *name = dynamic_cast<TNamed*>(ikey->ReadObj());
833 TDirectory *dir = dynamic_cast<TDirectory*>(ikey->ReadObj());
834
835
cc89bb69 836
837
383d44fd 838 if(dir){
839 Printf("%03d : %60s %8d %8d ",i,dir->GetName(),ikey->GetObjlen(),ikey->GetNbytes());
840 TList * dirKeyList = dir->GetListOfKeys();
841 for(int j = 0;j<dirKeyList->GetEntries();j++){
842 TKey* jkey = (TKey*)dirKeyList->At(j);
843 TList *list = dynamic_cast<TList*>(jkey->ReadObj());
cc89bb69 844
845 memorySize += (Float_t)jkey->GetObjlen()/1024./1024.;
846 diskSize += (Float_t)jkey->GetNbytes()/1024./1024.;
383d44fd 847 if(list){
848 Printf("%03d/%03d: %60s %5.2f MB %5.2f MB",i,j,list->GetName(),(Float_t)jkey->GetObjlen()/1024./1024.,(Float_t)jkey->GetNbytes()/1024./1024.);
1aa3886d 849 if(iDetail==i){
850 for(int il = 0;il<list->GetEntries();il++){
851 TObject *ob = list->At(il);
852 if(fDummy){
853 fDummy->cd();
854 Int_t nBytesWrite = ob->Write();
855 Printf("%03d/%03d/%03d: %60s %5.2f kB",i,j,il,ob->GetName(),(Float_t)nBytesWrite/1024.);
856 }
857 }
858 }
383d44fd 859 }
860 else{
861 Printf("%03d/%03d: %60s %5.2f MB %5.2f MB",i,j,jkey->GetName(),(Float_t)jkey->GetObjlen()/1024./1024.,(Float_t)jkey->GetNbytes()/1024./1024.);
862 }
863 }
864 }
865 }
cc89bb69 866 Printf("Total %5.2f MB %5.2f MB",memorySize,diskSize);
383d44fd 867 return kTRUE;
868}
869
870
59543510 871Bool_t AliAnalysisHelperJetTasks::Selected(Bool_t bSet,Bool_t bNew){
aeb249fb 872 //
873 // Static helper task, (re)set event by event
874 //
875
876
59543510 877 static Bool_t bSelected = kTRUE; // if service task is not run we acccpet all
878 if(bSet){
879 bSelected = bNew;
880 }
881 return bSelected;
882}
883
f2dd0695 884Bool_t AliAnalysisHelperJetTasks::IsCosmic(){
885 return ((SelectInfo()&kIsCosmic)==kIsCosmic);
886}
887
888Bool_t AliAnalysisHelperJetTasks::IsPileUp(){
889 return ((SelectInfo()&kIsPileUp)==kIsPileUp);
890}
891
892
45a11aef 893Bool_t AliAnalysisHelperJetTasks::TestSelectInfo(UInt_t iMask){
894 return ((SelectInfo()&iMask)==iMask);
895}
896
897
f4132e7d 898Bool_t AliAnalysisHelperJetTasks::TestEventClass(Int_t iMask){
899 if(iMask==0)return kTRUE;
900 return (EventClass()==iMask);
901}
902
903
f2dd0695 904UInt_t AliAnalysisHelperJetTasks::SelectInfo(Bool_t bSet,UInt_t iNew){
aeb249fb 905 //
906 // set event by event the slection info
907 //
908
f2dd0695 909 static UInt_t iSelectInfo = 0; //
910 if(bSet){
911 iSelectInfo = iNew;
912 }
913 return iSelectInfo;
914}
915
916
f4132e7d 917Int_t AliAnalysisHelperJetTasks::EventClass(Bool_t bSet,Int_t iNew){
aeb249fb 918 //
919 // gloab storage/access to event class
920 //
921
f4132e7d 922 static Int_t iEventClass = 0; //
923 if(bSet){
924 iEventClass = iNew;
925 }
926 return iEventClass;
927}
928
929
930
931
6f3f79de 932//___________________________________________________________________________________________________________
933
aeb249fb 934Bool_t AliAnalysisHelperJetTasks::GetEventShapes(TVector3 &n01,const TVector3 * pTrack, Int_t nTracks, Double_t * eventShapes)
6f3f79de 935{
936 // ***
937 // Event shape calculation
938 // sona.pochybova@cern.ch
939
940 const Int_t kTracks = 1000;
941 if(nTracks>kTracks)return kFALSE;
942
20d01a2f 943 //variables for thrust calculation
6f3f79de 944 TVector3 pTrackPerp[kTracks];
6f3f79de 945 Double_t psum2 = 0;
20d01a2f 946
947 TVector3 psum;
948 TVector3 psum02;
949 TVector3 psum03;
950
951 Double_t psum1 = 0;
952 Double_t psum102 = 0;
953 Double_t psum103 = 0;
954
79ac637f 955 Double_t thrust[kTracks] = {0.0};
6f3f79de 956 Double_t th = -3;
79ac637f 957 Double_t thrust02[kTracks] = {0.0};
20d01a2f 958 Double_t th02 = -4;
79ac637f 959 Double_t thrust03[kTracks] = {0.0};
20d01a2f 960 Double_t th03 = -5;
6f3f79de 961
20d01a2f 962 //Sphericity calculation variables
6f3f79de 963 TMatrixDSym m(3);
964 Double_t s00 = 0;
965 Double_t s01 = 0;
966 Double_t s02 = 0;
967
968 Double_t s10 = 0;
969 Double_t s11 = 0;
970 Double_t s12 = 0;
971
972 Double_t s20 = 0;
973 Double_t s21 = 0;
974 Double_t s22 = 0;
975
976 Double_t ptot = 0;
977
978 Double_t c = -10;
979
980//
981//loop for thrust calculation
982//
20d01a2f 983
984 for(Int_t i = 0; i < nTracks; i++)
985 {
986 pTrackPerp[i].SetXYZ(pTrack[i].X(), pTrack[i].Y(), 0);
987 psum2 += pTrackPerp[i].Mag();
988 }
989
990 //additional starting axis
991 TVector3 n02;
992 n02 = pTrack[1].Unit();
993 n02.SetZ(0.);
994 TVector3 n03;
995 n03 = pTrack[2].Unit();
996 n03.SetZ(0.);
997
998 //switches for calculating thrust for different starting points
999 Int_t switch1 = 1;
1000 Int_t switch2 = 1;
1001 Int_t switch3 = 1;
1002
1003 //indexes for iteration of different starting points
1004 Int_t l1 = 0;
1005 Int_t l2 = 0;
1006 Int_t l3 = 0;
1007
1008 //maximal number of iterations
1009 // Int_t nMaxIter = 100;
1010
1011 for(Int_t k = 0; k < nTracks; k++)
6f3f79de 1012 {
6f3f79de 1013
20d01a2f 1014 if(switch1 == 1){
1015 psum.SetXYZ(0., 0., 0.);
1016 psum1 = 0;
1017 for(Int_t i = 0; i < nTracks; i++)
1018 {
1019 psum1 += (TMath::Abs(n01.Dot(pTrackPerp[i])));
1020 if (n01.Dot(pTrackPerp[i]) > 0) psum += pTrackPerp[i];
1021 if (n01.Dot(pTrackPerp[i]) < 0) psum -= pTrackPerp[i];
1022 }
1023 thrust[l1] = psum1/psum2;
1024 }
1025
1026 if(switch2 == 1){
1027 psum02.SetXYZ(0., 0., 0.);
1028 psum102 = 0;
1029 for(Int_t i = 0; i < nTracks; i++)
1030 {
1031 psum102 += (TMath::Abs(n02.Dot(pTrackPerp[i])));
1032 if (n02.Dot(pTrackPerp[i]) > 0) psum02 += pTrackPerp[i];
1033 if (n02.Dot(pTrackPerp[i]) < 0) psum02 -= pTrackPerp[i];
1034 }
1035 thrust02[l2] = psum102/psum2;
1036 }
1037
1038 if(switch3 == 1){
1039 psum03.SetXYZ(0., 0., 0.);
1040 psum103 = 0;
1041 for(Int_t i = 0; i < nTracks; i++)
1042 {
1043 psum103 += (TMath::Abs(n03.Dot(pTrackPerp[i])));
1044 if (n03.Dot(pTrackPerp[i]) > 0) psum03 += pTrackPerp[i];
1045 if (n03.Dot(pTrackPerp[i]) < 0) psum03 -= pTrackPerp[i];
1046 }
1047 thrust03[l3] = psum103/psum2;
1048 }
1049
1050 //check whether thrust value converged
1051 if(TMath::Abs(th-thrust[l1]) < 10e-7){
1052 switch1 = 0;
1053 }
1054
1055 if(TMath::Abs(th02-thrust02[l2]) < 10e-7){
1056 switch2 = 0;
1057 }
1058
1059 if(TMath::Abs(th03-thrust03[l3]) < 10e-7){
1060 switch3 = 0;
1061 }
1062
1063 //if it didn't, continue with the calculation
1064 if(switch1 == 1){
1065 th = thrust[l1];
1066 n01 = psum.Unit();
1067 l1++;
1068 }
1069
1070 if(switch2 == 1){
1071 th02 = thrust02[l2];
1072 n02 = psum02.Unit();
1073 l2++;
1074 }
1075
1076 if(switch3 == 1){
1077 th03 = thrust03[l3];
1078 n03 = psum03.Unit();
1079 l3++;
1080 }
1081
1082 //if thrust values for all starting direction converged check if to the same value
1083 if(switch2 == 0 && switch1 == 0 && switch3 == 0){
1084 if(TMath::Abs(th-th02) < 10e-7 && TMath::Abs(th-th03) < 10e-7 && TMath::Abs(th02-th03) < 10e-7){
1085 eventShapes[0] = th;
e946cd3a 1086 AliInfoGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),Form("===== THRUST VALUE FOUND AT %d :: %f\n", k, th));
20d01a2f 1087 break;
1088 }
1089 //if they did not, reset switches
1090 else{
1091 switch1 = 1;
1092 // th = -1.;
1093 switch2 = 1;
1094 // th02 = -2.;
1095 switch3 = 1;
1096 // th03 = -4.;
1097 }
1098 }
1099
1100 // Printf("========== %d +++ th :: %f=============\n", l1, th);
1101 // Printf("========== %d +++ th2 :: %f=============\n", l2, th02);
1102 // Printf("========== %d +++ th3 :: %f=============\n", l3, th03);
6f3f79de 1103
6f3f79de 1104 }
1105
20d01a2f 1106 //if no common limitng value was found, take the maximum and take the corresponding thrust axis
1107 if(switch1 == 1 && switch2 == 1 && switch3 == 1){
1108 eventShapes[0] = TMath::Max(thrust[l1-1], thrust02[l2-1]);
1109 eventShapes[0] = TMath::Max(eventShapes[0], thrust03[l3-1]);
1110 if(TMath::Abs(eventShapes[0]-thrust[l1-1]) < 10e-7)
1111 n01 = n01;
1112 if(TMath::Abs(eventShapes[0]-thrust02[l2-1]) < 10e-7)
1113 n01 = n02;
1114 if(TMath::Abs(eventShapes[0]-thrust03[l3-1]) < 10e-7)
1115 n01 = n03;
1116 Printf("NO LIMITING VALUE FOUND :: MAXIMUM = %f\n", eventShapes[0]);
1117 }
6f3f79de 1118
1119//
1120//other event shapes variables
1121//
1122 for(Int_t j = 0; j < nTracks; j++)
1123 {
1124 s00 = s00 + (pTrack[j].Px()*pTrack[j].Px())/pTrack[j].Mag();
1125 s01 = s01 + (pTrack[j].Px()*pTrack[j].Py())/pTrack[j].Mag();
1126 s02 = s02 + (pTrack[j].Px()*pTrack[j].Pz())/pTrack[j].Mag();
1127
1128 s10 = s10 + (pTrack[j].Py()*pTrack[j].Px())/pTrack[j].Mag();
1129 s11 = s11 + (pTrack[j].Py()*pTrack[j].Py())/pTrack[j].Mag();
1130 s12 = s12 + (pTrack[j].Py()*pTrack[j].Pz())/pTrack[j].Mag();
1131
1132 s20 = s20 + (pTrack[j].Pz()*pTrack[j].Px())/pTrack[j].Mag();
1133 s21 = s21 + (pTrack[j].Pz()*pTrack[j].Py())/pTrack[j].Mag();
1134 s22 = s22 + (pTrack[j].Pz()*pTrack[j].Pz())/pTrack[j].Mag();
1135
1136 ptot += pTrack[j].Mag();
1137 }
1138
1139 if(ptot > 0.)
1140 {
1141 m(0,0) = s00/ptot;
1142 m(0,1) = s01/ptot;
1143 m(0,2) = s02/ptot;
1144
1145 m(1,0) = s10/ptot;
1146 m(1,1) = s11/ptot;
1147 m(1,2) = s12/ptot;
1148
1149 m(2,0) = s20/ptot;
1150 m(2,1) = s21/ptot;
1151 m(2,2) = s22/ptot;
1152
1153 TMatrixDSymEigen eigen(m);
1154 TVectorD eigenVal = eigen.GetEigenValues();
1155
1156 Double_t sphericity = (3/2)*(eigenVal(2)+eigenVal(1));
1157 eventShapes[1] = sphericity;
1158
1159 Double_t aplanarity = (3/2)*(eigenVal(2));
1160 eventShapes[2] = aplanarity;
1161
1162 c = 3*(eigenVal(0)*eigenVal(1)+eigenVal(0)*eigenVal(2)+eigenVal(1)*eigenVal(2));
1163 eventShapes[3] = c;
1164 }
1165 return kTRUE;
1166}
1167
1168
1169
1170 //__________________________________________________________________________________________________________________________
59543510 1171// Trigger Decisions copid from PWG0/AliTriggerAnalysis
1172
1173
1174Bool_t AliAnalysisHelperJetTasks::IsTriggerFired(const AliVEvent* aEv, Trigger trigger)
1175{
1176 // checks if an event has been triggered
1177 // no usage of ofline trigger here yet
edfbe476 1178
7fa8b2da 1179 // here we do a dirty hack to take also into account the
1180 // missing trigger bits and Bunch crossing paatern for real data
edfbe476 1181
1182
7fa8b2da 1183 if(aEv->InheritsFrom("AliESDEvent")){
cce8b687 1184 const AliESDEvent *esd = (AliESDEvent*)aEv;
1185 switch (trigger)
1186 {
1187 case kAcceptAll:
1188 {
1189 return kTRUE;
1190 break;
1191 }
1192 case kMB1:
1193 {
1c796df8 1194 if(esd->GetFiredTriggerClasses().Contains("CINT1B-"))return kTRUE;
cd9a6fa2 1195 // does the same but without or'ed V0s
edfbe476 1196 if(esd->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE;
1197 if(esd->GetFiredTriggerClasses().Contains("CINT6B-"))return kTRUE;
1c796df8 1198 // this is for simulated data
1199 if(esd->GetFiredTriggerClasses().Contains("MB1"))return kTRUE;
cce8b687 1200 break;
1201 }
1202 case kMB2:
1203 {
1c796df8 1204 if(esd->GetFiredTriggerClasses().Contains("MB2"))return kTRUE;
cce8b687 1205 break;
1206 }
1207 case kMB3:
1208 {
1c796df8 1209 if(esd->GetFiredTriggerClasses().Contains("MB3"))return kTRUE;
cce8b687 1210 break;
1211 }
1212 case kSPDGFO:
1213 {
cd9a6fa2 1214 if(esd->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE;
edfbe476 1215 if(esd->GetFiredTriggerClasses().Contains("CINT6B-"))return kTRUE;
1c796df8 1216 if(esd->GetFiredTriggerClasses().Contains("GFO"))return kTRUE;
cce8b687 1217 break;
1218 }
1219 default:
1220 {
1221 Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger);
1222 break;
1223 }
1224 }
1225 }
1226 else if(aEv->InheritsFrom("AliAODEvent")){
1227 const AliAODEvent *aod = (AliAODEvent*)aEv;
7fa8b2da 1228 switch (trigger)
1229 {
1230 case kAcceptAll:
1231 {
cce8b687 1232 return kTRUE;
7fa8b2da 1233 break;
1234 }
1235 case kMB1:
1236 {
cce8b687 1237 if(aod->GetFiredTriggerClasses().Contains("CINT1B"))return kTRUE;
cd9a6fa2 1238 // does the same but without or'ed V0s
1239 if(aod->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE;
1c796df8 1240 // for sim data
1241 if(aod->GetFiredTriggerClasses().Contains("MB1"))return kTRUE;
7fa8b2da 1242 break;
1243 }
1244 case kMB2:
1245 {
1c796df8 1246 if(aod->GetFiredTriggerClasses().Contains("MB2"))return kTRUE;
7fa8b2da 1247 break;
1248 }
1249 case kMB3:
1250 {
1c796df8 1251 if(aod->GetFiredTriggerClasses().Contains("MB3"))return kTRUE;
7fa8b2da 1252 break;
1253 }
1254 case kSPDGFO:
1255 {
cce8b687 1256 if(aod->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE;
1c796df8 1257 if(aod->GetFiredTriggerClasses().Contains("GFO"))return kTRUE;
7fa8b2da 1258 break;
1259 }
1260 default:
1261 {
1262 Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger);
1263 break;
1264 }
1265 }
1266 }
cce8b687 1267 return kFALSE;
59543510 1268}
955d29ba 1269
1270
1271 AliAnalysisHelperJetTasks::MCProcessType AliAnalysisHelperJetTasks::GetPythiaEventProcessType(AliGenEventHeader* aHeader, Bool_t adebug) {
aeb249fb 1272 //
1273 // fetch the process type from the mc header
1274 //
1275
955d29ba 1276
1277 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader);
1278
1279 if (!pythiaGenHeader) {
fb03edbe 1280 // printf(" AliAnalysisHelperJetTasks::GetProcessType : Unknown gen Header type). \n");
955d29ba 1281 return kInvalidProcess;
1282 }
1283
1284
1285 Int_t pythiaType = pythiaGenHeader->ProcessType();
1286 fgLastProcessType = pythiaType;
1287 MCProcessType globalType = kInvalidProcess;
1288
1289
1290 if (adebug) {
1291 printf(" AliAnalysisHelperJetTasks::GetProcessType : Pythia process type found: %d \n",pythiaType);
1292 }
1293
1294
1295 if(pythiaType==92||pythiaType==93){
1296 globalType = kSD;
1297 }
1298 else if(pythiaType==94){
1299 globalType = kDD;
1300 }
1301 //else if(pythiaType != 91){ // also exclude elastic to be sure... CKB??
1302 else {
1303 globalType = kND;
1304 }
1305 return globalType;
1306}
1307
1308
1309 AliAnalysisHelperJetTasks::MCProcessType AliAnalysisHelperJetTasks::GetDPMjetEventProcessType(AliGenEventHeader* aHeader, Bool_t adebug) {
1310 //
1311 // get the process type of the event.
1312 //
1313
1314 // can only read pythia headers, either directly or from cocktalil header
1315 AliGenDPMjetEventHeader* dpmJetGenHeader = dynamic_cast<AliGenDPMjetEventHeader*>(aHeader);
1316
1317 if (!dpmJetGenHeader) {
1318 printf(" AliAnalysisHelperJetTasks::GetDPMjetProcessType : Unknown header type (not DPMjet or). \n");
1319 return kInvalidProcess;
1320 }
1321
1322 Int_t dpmJetType = dpmJetGenHeader->ProcessType();
1323 fgLastProcessType = dpmJetType;
1324 MCProcessType globalType = kInvalidProcess;
1325
1326
1327 if (adebug) {
1328 printf(" AliAnalysisHelperJetTasks::GetDPMJetProcessType : DPMJet process type found: %d \n",dpmJetType);
1329 }
1330
1331
1332 if (dpmJetType == 1 || dpmJetType == 4) { // explicitly inelastic plus central diffraction
1333 globalType = kND;
1334 }
1335 else if (dpmJetType==5 || dpmJetType==6) {
1336 globalType = kSD;
1337 }
1338 else if (dpmJetType==7) {
1339 globalType = kDD;
1340 }
1341 return globalType;
1342}
1343
40445651 1344
1345Int_t AliAnalysisHelperJetTasks::GetPhiBin(Double_t phi,Int_t fNRPBins)
1346{
1347 Int_t phibin=-1;
1348 if(!(TMath::Abs(phi)<=2*TMath::Pi()))return -1;
1349 Double_t phiwrtrp=TMath::ACos(TMath::Abs(TMath::Cos(phi)));
1350 phibin=Int_t(fNRPBins*phiwrtrp/(0.5*TMath::Pi()));
1351 return phibin;
1352}
1353
1354Double_t AliAnalysisHelperJetTasks::ReactionPlane(Bool_t bSet,Double_t fNew){
1355 //
1356 // Static helper task, (re)set event by event
1357 //
1358
1359
1360 static Double_t fRP = 0; // if service task is not run we acccpet all
1361 if(bSet){
1362 fRP = fNew;
1363 }
1364 return fRP;
1365}