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