]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/JetTasks/AliAnalysisHelperJetTasks.cxx
fixed coding rule violations
[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
164 for(int i = 0;i < kGenJets;++i)iGenIndex[i] = -1;
165 for(int j = 0;j < kRecJets;++j)iRecIndex[j] = -1;
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,
383 Int_t iDebug, Float_t maxDist){
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
401
402 for(Int_t i=0; i<kClosestJetsN; ++i){
403 for(Int_t j=0; j<2; ++j){
404 closestJets[i][j] = 1e6;
405 }
406 }
407
408
409 const Int_t nGenJets = TMath::Min(genJetsList->GetEntries(),kGenJets);
410 const Int_t nRecJets = TMath::Min(recJetsList->GetEntries(),kRecJets);
411 if(nRecJets==0||nGenJets==0) return;
412
413 AliAODJet *genJet = 0x0;
414 AliAODJet *recJet = 0x0;
415
416 // loop over generated/embedded jets
417 for(Int_t ig=0; ig<nGenJets; ++ig){
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
450 Double_t maxFraction = 0.; // maximum found fraction in one jets
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]);
457 recJet = (AliAODJet*)recJetsList->At(ir);
458 if(!(recJet)) continue;
459
460 fraction = GetFractionOfJet(recJet,genJet);
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
aeb249fb 486Double_t AliAnalysisHelperJetTasks::GetFractionOfJet(const AliAODJet *recJet, const AliAODJet *genJet){
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
512 if(genTrack==recTrack){
513 ptAssocTracks += genTrack->Pt();
514 break;
515 }
516 }
517 }
518
519 // calculate fraction
520 Double_t fraction = ptAssocTracks/ptGen;
521
522 return fraction;
523}
db6bcb0e 524
c74e9b54 525
57cd3e7c 526void AliAnalysisHelperJetTasks::MergeOutputDirs(const char* cFiles,const char* cPattern,const char *cOutFile,Bool_t bUpdate){
c6049d04 527 // Routine to merge only directories containing the pattern
528 //
529 TString outFile(cOutFile);
530 if(outFile.Length()==0)outFile = Form("%s.root",cPattern);
531 ifstream in1;
532 in1.open(cFiles);
533 // open all files
534 TList fileList;
535 char cFile[240];
57cd3e7c 536 while(in1>>cFile){// only open the first file
537 Printf("Adding %s",cFile);
538 TFile *f1 = TFile::Open(cFile);
539 fileList.Add(f1);
c6049d04 540 }
541
542 TFile *fOut = 0;
543 if(fileList.GetEntries()){// open the first file
544 TFile* fIn = dynamic_cast<TFile*>(fileList.At(0));
57cd3e7c 545 if(!fIn){
c6049d04 546 Printf("Input File not Found");
e855f5c5 547 return;
c6049d04 548 }
549 // fetch the keys for the directories
550 TList *ldKeys = fIn->GetListOfKeys();
551 for(int id = 0;id < ldKeys->GetEntries();id++){
552 // check if it is a directory
553 TKey *dKey = (TKey*)ldKeys->At(id);
554 TDirectory *dir = dynamic_cast<TDirectory*>(dKey->ReadObj());
555 if(dir){
556 TString dName(dir->GetName());
557 if(dName.Contains(cPattern)){
558 // open new file if first match
559 if(!fOut){
57cd3e7c 560 if(bUpdate)fOut = new TFile(outFile.Data(),"UPDATE");
561 else fOut = new TFile(outFile.Data(),"RECREATE");
c6049d04 562 }
563 // merge all the stuff that is in this directory
564 TList *llKeys = dir->GetListOfKeys();
565 TList *tmplist;
566 TMethodCall callEnv;
57cd3e7c 567
568 fOut->cd();
569 TDirectory *dOut = fOut->mkdir(dir->GetName());
570
c6049d04 571 for(int il = 0;il < llKeys->GetEntries();il++){
57cd3e7c 572 TKey *lKey = (TKey*)llKeys->At(il);
c6049d04 573 TObject *object = dynamic_cast<TObject*>(lKey->ReadObj());
574 // from TSeqCollections::Merge
575 if(!object)continue;
576 // If current object is not mergeable just skip it
577 if (!object->IsA()) {
578 continue;
579 }
580 callEnv.InitWithPrototype(object->IsA(), "Merge", "TCollection*");
581 if (!callEnv.IsValid()) {
582 continue;
583 }
584 // Current object mergeable - get corresponding objects in input lists
585 tmplist = new TList();
586 for(int i = 1; i < fileList.GetEntries();i++){
587 TDirectory *fInTmp = dynamic_cast<TDirectory*>(fileList.At(i));
588 if(!fInTmp){
589 Printf("File %d not found",i);
590 continue;
591 }
592 TDirectory *dTmp = (TDirectory*)fInTmp->Get(dName.Data());
593 if(!dTmp){
594 Printf("Directory %s not found",dName.Data());
595 continue;
596 }
597 TObject* oTmp = (TObject*)dTmp->Get(object->GetName());
598 if(!oTmp){
599 Printf("Object %s not found",object->GetName());
600 continue;
601 }
602 tmplist->Add(oTmp);
603 }
604 callEnv.SetParam((Long_t) tmplist);
605 callEnv.Execute(object);
606 delete tmplist;tmplist = 0;
57cd3e7c 607 dOut->cd();
608 object->Write(object->GetName(),TObject::kSingleKey);
c6049d04 609 }
610 }
611 }
612 }
613 if(fOut){
614 fOut->Close();
615 }
616 }
617}
db6bcb0e 618
383d44fd 619void AliAnalysisHelperJetTasks::MergeOutput(char* cFiles, char* cDir, char *cList,char *cOutFile,Bool_t bUpdate){
db6bcb0e 620
188a1ba9 621 // This is used to merge the analysis-output from different
622 // data samples/pt_hard bins
623 // in case the eventweigth was set to xsection/ntrials already, this
624 // is not needed. Both methods only work in case we do not mix different
625 // pt_hard bins, and do not have overlapping bins
db6bcb0e 626
188a1ba9 627 const Int_t nMaxBins = 12;
628 // LHC08q jetjet100: Mean = 1.42483e-03, RMS = 6.642e-05
629 // LHC08r jetjet50: Mean = 2.44068e-02, RMS = 1.144e-03
630 // LHC08v jetjet15-50: Mean = 2.168291 , RMS = 7.119e-02
631 // const Float_t xsection[nBins] = {2.168291,2.44068e-02};
632
633 Float_t xsection[nMaxBins];
634 Float_t nTrials[nMaxBins];
635 Float_t sf[nMaxBins];
636 TList *lIn[nMaxBins];
383d44fd 637 TDirectory *dIn[nMaxBins];
188a1ba9 638 TFile *fIn[nMaxBins];
639
640 ifstream in1;
641 in1.open(cFiles);
642
643 char cFile[120];
644 Int_t ibTotal = 0;
645 while(in1>>cFile){
646 fIn[ibTotal] = TFile::Open(cFile);
4d723ede 647 if(strlen(cDir)==0){
648 dIn[ibTotal] = gDirectory;
649 }
650 else{
651 dIn[ibTotal] = (TDirectory*)fIn[ibTotal]->Get(cDir);
652 }
383d44fd 653 if(!dIn[ibTotal]){
654 Printf("%s:%d No directory %s found, exiting...",__FILE__,__LINE__,cDir);
655 fIn[ibTotal]->ls();
656 return;
657 }
658
659 lIn[ibTotal] = (TList*)dIn[ibTotal]->Get(cList);
660 Printf("Merging file %s %s",cFile, cDir);
188a1ba9 661 if(!lIn[ibTotal]){
662 Printf("%s:%d No list %s found, exiting...",__FILE__,__LINE__,cList);
663 fIn[ibTotal]->ls();
664 return;
665 }
666 TH1* hTrials = (TH1F*)lIn[ibTotal]->FindObject("fh1Trials");
667 if(!hTrials){
668 Printf("%s:%d fh1PtHard_Trials not found in list, exiting...",__FILE__,__LINE__);
669 return;
670 }
671 TProfile* hXsec = (TProfile*)lIn[ibTotal]->FindObject("fh1Xsec");
672 if(!hXsec){
673 Printf("%s:%d fh1Xsec not found in list, exiting...",__FILE__,__LINE__);
674 return;
675 }
676 xsection[ibTotal] = hXsec->GetBinContent(1);
677 nTrials[ibTotal] = hTrials->Integral();
678 sf[ibTotal] = xsection[ibTotal]/ nTrials[ibTotal];
679 ibTotal++;
680 }
681
682 if(ibTotal==0){
683 Printf("%s:%d No files found for mergin, exiting",__FILE__,__LINE__);
684 return;
685 }
686
383d44fd 687 TFile *fOut = 0;
688 if(bUpdate)fOut = new TFile(cOutFile,"UPDATE");
689 else fOut = new TFile(cOutFile,"RECREATE");
690 TDirectory *dOut = fOut->mkdir(dIn[0]->GetName());
691 dOut->cd();
188a1ba9 692 TList *lOut = new TList();
693 lOut->SetName(lIn[0]->GetName());
383d44fd 694
188a1ba9 695 // for the start scale all...
696 for(int ie = 0; ie < lIn[0]->GetEntries();++ie){
697 TH1 *h1Add = 0;
698 THnSparse *hnAdd = 0;
699 for(int ib = 0;ib < ibTotal;++ib){
700 // dynamic cast does not work with cint
701 TObject *h = lIn[ib]->At(ie);
702 if(h->InheritsFrom("TH1")){
703 TH1 *h1 = (TH1*)h;
704 if(ib==0){
705 h1Add = (TH1*)h1->Clone(h1->GetName());
706 h1Add->Scale(sf[ib]);
707 }
708 else{
709 h1Add->Add(h1,sf[ib]);
710 }
711 }
712 else if(h->InheritsFrom("THnSparse")){
713 THnSparse *hn = (THnSparse*)h;
714 if(ib==0){
715 hnAdd = (THnSparse*)hn->Clone(hn->GetName());
716 hnAdd->Scale(sf[ib]);
717 }
718 else{
719 hnAdd->Add(hn,sf[ib]);
720 }
721 }
722
723
724 }// ib
725 if(h1Add)lOut->Add(h1Add);
726 else if(hnAdd)lOut->Add(hnAdd);
727 }
383d44fd 728 dOut->cd();
188a1ba9 729 lOut->Write(lOut->GetName(),TObject::kSingleKey);
730 fOut->Close();
731}
519378fb 732
733Bool_t AliAnalysisHelperJetTasks::PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials){
734 //
735 // get the cross section and the trails either from pyxsec.root or from pysec_hists.root
736 // This is to called in Notify and should provide the path to the AOD/ESD file
737
738 TString file(currFile);
739 fXsec = 0;
740 fTrials = 1;
741
742 if(file.Contains("root_archive.zip#")){
743 Ssiz_t pos1 = file.Index("root_archive",12,TString::kExact);
744 Ssiz_t pos = file.Index("#",1,pos1,TString::kExact);
745 file.Replace(pos+1,20,"");
746 }
747 else {
748 // not an archive take the basename....
749 file.ReplaceAll(gSystem->BaseName(file.Data()),"");
750 }
751 Printf("%s",file.Data());
752
753
754
755
756 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
757 if(!fxsec){
758 // next trial fetch the histgram file
759 fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root"));
760 if(!fxsec){
761 // not a severe condition but inciate that we have no information
762 return kFALSE;
763 }
764 else{
765 // find the tlist we want to be independtent of the name so use the Tkey
766 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
767 if(!key){
768 fxsec->Close();
769 return kFALSE;
770 }
771 TList *list = dynamic_cast<TList*>(key->ReadObj());
772 if(!list){
773 fxsec->Close();
774 return kFALSE;
775 }
776 fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1);
777 fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1);
778 fxsec->Close();
779 }
780 } // no tree pyxsec.root
781 else {
782 TTree *xtree = (TTree*)fxsec->Get("Xsection");
783 if(!xtree){
784 fxsec->Close();
785 return kFALSE;
786 }
787 UInt_t ntrials = 0;
788 Double_t xsection = 0;
789 xtree->SetBranchAddress("xsection",&xsection);
790 xtree->SetBranchAddress("ntrials",&ntrials);
791 xtree->GetEntry(0);
792 fTrials = ntrials;
793 fXsec = xsection;
794 fxsec->Close();
795 }
796 return kTRUE;
797}
6f3f79de 798
383d44fd 799Bool_t AliAnalysisHelperJetTasks::PrintDirectorySize(const char* currFile){
800
aeb249fb 801 //
802 // Print the size on disk and in memory occuppied by a directory
803 //
804
383d44fd 805 TFile *fIn = TFile::Open(currFile);
806 if(!fIn){
807 // not a severe condition but inciate that we have no information
808 return kFALSE;
809 }
810 // find the tlists we want to be independtent of the name so use the Tkey
811 TList* keyList = fIn->GetListOfKeys();
cc89bb69 812 Float_t memorySize = 0;
813 Float_t diskSize = 0;
383d44fd 814
815 for(int i = 0;i < keyList->GetEntries();i++){
816 TKey* ikey = (TKey*)keyList->At(i);
817
818 // TList *list = dynamic_cast<TList*>(key->ReadObj());
819 // TNamed *name = dynamic_cast<TNamed*>(ikey->ReadObj());
820 TDirectory *dir = dynamic_cast<TDirectory*>(ikey->ReadObj());
821
822
cc89bb69 823
824
383d44fd 825 if(dir){
826 Printf("%03d : %60s %8d %8d ",i,dir->GetName(),ikey->GetObjlen(),ikey->GetNbytes());
827 TList * dirKeyList = dir->GetListOfKeys();
828 for(int j = 0;j<dirKeyList->GetEntries();j++){
829 TKey* jkey = (TKey*)dirKeyList->At(j);
830 TList *list = dynamic_cast<TList*>(jkey->ReadObj());
cc89bb69 831
832 memorySize += (Float_t)jkey->GetObjlen()/1024./1024.;
833 diskSize += (Float_t)jkey->GetNbytes()/1024./1024.;
383d44fd 834 if(list){
835 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.);
836 }
837 else{
838 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.);
839 }
840 }
841 }
842 }
cc89bb69 843 Printf("Total %5.2f MB %5.2f MB",memorySize,diskSize);
383d44fd 844 return kTRUE;
845}
846
847
59543510 848Bool_t AliAnalysisHelperJetTasks::Selected(Bool_t bSet,Bool_t bNew){
aeb249fb 849 //
850 // Static helper task, (re)set event by event
851 //
852
853
59543510 854 static Bool_t bSelected = kTRUE; // if service task is not run we acccpet all
855 if(bSet){
856 bSelected = bNew;
857 }
858 return bSelected;
859}
860
f2dd0695 861Bool_t AliAnalysisHelperJetTasks::IsCosmic(){
862 return ((SelectInfo()&kIsCosmic)==kIsCosmic);
863}
864
865Bool_t AliAnalysisHelperJetTasks::IsPileUp(){
866 return ((SelectInfo()&kIsPileUp)==kIsPileUp);
867}
868
869
45a11aef 870Bool_t AliAnalysisHelperJetTasks::TestSelectInfo(UInt_t iMask){
871 return ((SelectInfo()&iMask)==iMask);
872}
873
874
f4132e7d 875Bool_t AliAnalysisHelperJetTasks::TestEventClass(Int_t iMask){
876 if(iMask==0)return kTRUE;
877 return (EventClass()==iMask);
878}
879
880
f2dd0695 881UInt_t AliAnalysisHelperJetTasks::SelectInfo(Bool_t bSet,UInt_t iNew){
aeb249fb 882 //
883 // set event by event the slection info
884 //
885
f2dd0695 886 static UInt_t iSelectInfo = 0; //
887 if(bSet){
888 iSelectInfo = iNew;
889 }
890 return iSelectInfo;
891}
892
893
f4132e7d 894Int_t AliAnalysisHelperJetTasks::EventClass(Bool_t bSet,Int_t iNew){
aeb249fb 895 //
896 // gloab storage/access to event class
897 //
898
f4132e7d 899 static Int_t iEventClass = 0; //
900 if(bSet){
901 iEventClass = iNew;
902 }
903 return iEventClass;
904}
905
906
907
908
6f3f79de 909//___________________________________________________________________________________________________________
910
aeb249fb 911Bool_t AliAnalysisHelperJetTasks::GetEventShapes(TVector3 &n01,const TVector3 * pTrack, Int_t nTracks, Double_t * eventShapes)
6f3f79de 912{
913 // ***
914 // Event shape calculation
915 // sona.pochybova@cern.ch
916
917 const Int_t kTracks = 1000;
918 if(nTracks>kTracks)return kFALSE;
919
20d01a2f 920 //variables for thrust calculation
6f3f79de 921 TVector3 pTrackPerp[kTracks];
6f3f79de 922 Double_t psum2 = 0;
20d01a2f 923
924 TVector3 psum;
925 TVector3 psum02;
926 TVector3 psum03;
927
928 Double_t psum1 = 0;
929 Double_t psum102 = 0;
930 Double_t psum103 = 0;
931
79ac637f 932 Double_t thrust[kTracks] = {0.0};
6f3f79de 933 Double_t th = -3;
79ac637f 934 Double_t thrust02[kTracks] = {0.0};
20d01a2f 935 Double_t th02 = -4;
79ac637f 936 Double_t thrust03[kTracks] = {0.0};
20d01a2f 937 Double_t th03 = -5;
6f3f79de 938
20d01a2f 939 //Sphericity calculation variables
6f3f79de 940 TMatrixDSym m(3);
941 Double_t s00 = 0;
942 Double_t s01 = 0;
943 Double_t s02 = 0;
944
945 Double_t s10 = 0;
946 Double_t s11 = 0;
947 Double_t s12 = 0;
948
949 Double_t s20 = 0;
950 Double_t s21 = 0;
951 Double_t s22 = 0;
952
953 Double_t ptot = 0;
954
955 Double_t c = -10;
956
957//
958//loop for thrust calculation
959//
20d01a2f 960
961 for(Int_t i = 0; i < nTracks; i++)
962 {
963 pTrackPerp[i].SetXYZ(pTrack[i].X(), pTrack[i].Y(), 0);
964 psum2 += pTrackPerp[i].Mag();
965 }
966
967 //additional starting axis
968 TVector3 n02;
969 n02 = pTrack[1].Unit();
970 n02.SetZ(0.);
971 TVector3 n03;
972 n03 = pTrack[2].Unit();
973 n03.SetZ(0.);
974
975 //switches for calculating thrust for different starting points
976 Int_t switch1 = 1;
977 Int_t switch2 = 1;
978 Int_t switch3 = 1;
979
980 //indexes for iteration of different starting points
981 Int_t l1 = 0;
982 Int_t l2 = 0;
983 Int_t l3 = 0;
984
985 //maximal number of iterations
986 // Int_t nMaxIter = 100;
987
988 for(Int_t k = 0; k < nTracks; k++)
6f3f79de 989 {
6f3f79de 990
20d01a2f 991 if(switch1 == 1){
992 psum.SetXYZ(0., 0., 0.);
993 psum1 = 0;
994 for(Int_t i = 0; i < nTracks; i++)
995 {
996 psum1 += (TMath::Abs(n01.Dot(pTrackPerp[i])));
997 if (n01.Dot(pTrackPerp[i]) > 0) psum += pTrackPerp[i];
998 if (n01.Dot(pTrackPerp[i]) < 0) psum -= pTrackPerp[i];
999 }
1000 thrust[l1] = psum1/psum2;
1001 }
1002
1003 if(switch2 == 1){
1004 psum02.SetXYZ(0., 0., 0.);
1005 psum102 = 0;
1006 for(Int_t i = 0; i < nTracks; i++)
1007 {
1008 psum102 += (TMath::Abs(n02.Dot(pTrackPerp[i])));
1009 if (n02.Dot(pTrackPerp[i]) > 0) psum02 += pTrackPerp[i];
1010 if (n02.Dot(pTrackPerp[i]) < 0) psum02 -= pTrackPerp[i];
1011 }
1012 thrust02[l2] = psum102/psum2;
1013 }
1014
1015 if(switch3 == 1){
1016 psum03.SetXYZ(0., 0., 0.);
1017 psum103 = 0;
1018 for(Int_t i = 0; i < nTracks; i++)
1019 {
1020 psum103 += (TMath::Abs(n03.Dot(pTrackPerp[i])));
1021 if (n03.Dot(pTrackPerp[i]) > 0) psum03 += pTrackPerp[i];
1022 if (n03.Dot(pTrackPerp[i]) < 0) psum03 -= pTrackPerp[i];
1023 }
1024 thrust03[l3] = psum103/psum2;
1025 }
1026
1027 //check whether thrust value converged
1028 if(TMath::Abs(th-thrust[l1]) < 10e-7){
1029 switch1 = 0;
1030 }
1031
1032 if(TMath::Abs(th02-thrust02[l2]) < 10e-7){
1033 switch2 = 0;
1034 }
1035
1036 if(TMath::Abs(th03-thrust03[l3]) < 10e-7){
1037 switch3 = 0;
1038 }
1039
1040 //if it didn't, continue with the calculation
1041 if(switch1 == 1){
1042 th = thrust[l1];
1043 n01 = psum.Unit();
1044 l1++;
1045 }
1046
1047 if(switch2 == 1){
1048 th02 = thrust02[l2];
1049 n02 = psum02.Unit();
1050 l2++;
1051 }
1052
1053 if(switch3 == 1){
1054 th03 = thrust03[l3];
1055 n03 = psum03.Unit();
1056 l3++;
1057 }
1058
1059 //if thrust values for all starting direction converged check if to the same value
1060 if(switch2 == 0 && switch1 == 0 && switch3 == 0){
1061 if(TMath::Abs(th-th02) < 10e-7 && TMath::Abs(th-th03) < 10e-7 && TMath::Abs(th02-th03) < 10e-7){
1062 eventShapes[0] = th;
e946cd3a 1063 AliInfoGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),Form("===== THRUST VALUE FOUND AT %d :: %f\n", k, th));
20d01a2f 1064 break;
1065 }
1066 //if they did not, reset switches
1067 else{
1068 switch1 = 1;
1069 // th = -1.;
1070 switch2 = 1;
1071 // th02 = -2.;
1072 switch3 = 1;
1073 // th03 = -4.;
1074 }
1075 }
1076
1077 // Printf("========== %d +++ th :: %f=============\n", l1, th);
1078 // Printf("========== %d +++ th2 :: %f=============\n", l2, th02);
1079 // Printf("========== %d +++ th3 :: %f=============\n", l3, th03);
6f3f79de 1080
6f3f79de 1081 }
1082
20d01a2f 1083 //if no common limitng value was found, take the maximum and take the corresponding thrust axis
1084 if(switch1 == 1 && switch2 == 1 && switch3 == 1){
1085 eventShapes[0] = TMath::Max(thrust[l1-1], thrust02[l2-1]);
1086 eventShapes[0] = TMath::Max(eventShapes[0], thrust03[l3-1]);
1087 if(TMath::Abs(eventShapes[0]-thrust[l1-1]) < 10e-7)
1088 n01 = n01;
1089 if(TMath::Abs(eventShapes[0]-thrust02[l2-1]) < 10e-7)
1090 n01 = n02;
1091 if(TMath::Abs(eventShapes[0]-thrust03[l3-1]) < 10e-7)
1092 n01 = n03;
1093 Printf("NO LIMITING VALUE FOUND :: MAXIMUM = %f\n", eventShapes[0]);
1094 }
6f3f79de 1095
1096//
1097//other event shapes variables
1098//
1099 for(Int_t j = 0; j < nTracks; j++)
1100 {
1101 s00 = s00 + (pTrack[j].Px()*pTrack[j].Px())/pTrack[j].Mag();
1102 s01 = s01 + (pTrack[j].Px()*pTrack[j].Py())/pTrack[j].Mag();
1103 s02 = s02 + (pTrack[j].Px()*pTrack[j].Pz())/pTrack[j].Mag();
1104
1105 s10 = s10 + (pTrack[j].Py()*pTrack[j].Px())/pTrack[j].Mag();
1106 s11 = s11 + (pTrack[j].Py()*pTrack[j].Py())/pTrack[j].Mag();
1107 s12 = s12 + (pTrack[j].Py()*pTrack[j].Pz())/pTrack[j].Mag();
1108
1109 s20 = s20 + (pTrack[j].Pz()*pTrack[j].Px())/pTrack[j].Mag();
1110 s21 = s21 + (pTrack[j].Pz()*pTrack[j].Py())/pTrack[j].Mag();
1111 s22 = s22 + (pTrack[j].Pz()*pTrack[j].Pz())/pTrack[j].Mag();
1112
1113 ptot += pTrack[j].Mag();
1114 }
1115
1116 if(ptot > 0.)
1117 {
1118 m(0,0) = s00/ptot;
1119 m(0,1) = s01/ptot;
1120 m(0,2) = s02/ptot;
1121
1122 m(1,0) = s10/ptot;
1123 m(1,1) = s11/ptot;
1124 m(1,2) = s12/ptot;
1125
1126 m(2,0) = s20/ptot;
1127 m(2,1) = s21/ptot;
1128 m(2,2) = s22/ptot;
1129
1130 TMatrixDSymEigen eigen(m);
1131 TVectorD eigenVal = eigen.GetEigenValues();
1132
1133 Double_t sphericity = (3/2)*(eigenVal(2)+eigenVal(1));
1134 eventShapes[1] = sphericity;
1135
1136 Double_t aplanarity = (3/2)*(eigenVal(2));
1137 eventShapes[2] = aplanarity;
1138
1139 c = 3*(eigenVal(0)*eigenVal(1)+eigenVal(0)*eigenVal(2)+eigenVal(1)*eigenVal(2));
1140 eventShapes[3] = c;
1141 }
1142 return kTRUE;
1143}
1144
1145
1146
1147 //__________________________________________________________________________________________________________________________
59543510 1148// Trigger Decisions copid from PWG0/AliTriggerAnalysis
1149
1150
1151Bool_t AliAnalysisHelperJetTasks::IsTriggerFired(const AliVEvent* aEv, Trigger trigger)
1152{
1153 // checks if an event has been triggered
1154 // no usage of ofline trigger here yet
edfbe476 1155
7fa8b2da 1156 // here we do a dirty hack to take also into account the
1157 // missing trigger bits and Bunch crossing paatern for real data
edfbe476 1158
1159
7fa8b2da 1160 if(aEv->InheritsFrom("AliESDEvent")){
cce8b687 1161 const AliESDEvent *esd = (AliESDEvent*)aEv;
1162 switch (trigger)
1163 {
1164 case kAcceptAll:
1165 {
1166 return kTRUE;
1167 break;
1168 }
1169 case kMB1:
1170 {
1c796df8 1171 if(esd->GetFiredTriggerClasses().Contains("CINT1B-"))return kTRUE;
cd9a6fa2 1172 // does the same but without or'ed V0s
edfbe476 1173 if(esd->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE;
1174 if(esd->GetFiredTriggerClasses().Contains("CINT6B-"))return kTRUE;
1c796df8 1175 // this is for simulated data
1176 if(esd->GetFiredTriggerClasses().Contains("MB1"))return kTRUE;
cce8b687 1177 break;
1178 }
1179 case kMB2:
1180 {
1c796df8 1181 if(esd->GetFiredTriggerClasses().Contains("MB2"))return kTRUE;
cce8b687 1182 break;
1183 }
1184 case kMB3:
1185 {
1c796df8 1186 if(esd->GetFiredTriggerClasses().Contains("MB3"))return kTRUE;
cce8b687 1187 break;
1188 }
1189 case kSPDGFO:
1190 {
cd9a6fa2 1191 if(esd->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE;
edfbe476 1192 if(esd->GetFiredTriggerClasses().Contains("CINT6B-"))return kTRUE;
1c796df8 1193 if(esd->GetFiredTriggerClasses().Contains("GFO"))return kTRUE;
cce8b687 1194 break;
1195 }
1196 default:
1197 {
1198 Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger);
1199 break;
1200 }
1201 }
1202 }
1203 else if(aEv->InheritsFrom("AliAODEvent")){
1204 const AliAODEvent *aod = (AliAODEvent*)aEv;
7fa8b2da 1205 switch (trigger)
1206 {
1207 case kAcceptAll:
1208 {
cce8b687 1209 return kTRUE;
7fa8b2da 1210 break;
1211 }
1212 case kMB1:
1213 {
cce8b687 1214 if(aod->GetFiredTriggerClasses().Contains("CINT1B"))return kTRUE;
cd9a6fa2 1215 // does the same but without or'ed V0s
1216 if(aod->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE;
1c796df8 1217 // for sim data
1218 if(aod->GetFiredTriggerClasses().Contains("MB1"))return kTRUE;
7fa8b2da 1219 break;
1220 }
1221 case kMB2:
1222 {
1c796df8 1223 if(aod->GetFiredTriggerClasses().Contains("MB2"))return kTRUE;
7fa8b2da 1224 break;
1225 }
1226 case kMB3:
1227 {
1c796df8 1228 if(aod->GetFiredTriggerClasses().Contains("MB3"))return kTRUE;
7fa8b2da 1229 break;
1230 }
1231 case kSPDGFO:
1232 {
cce8b687 1233 if(aod->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE;
1c796df8 1234 if(aod->GetFiredTriggerClasses().Contains("GFO"))return kTRUE;
7fa8b2da 1235 break;
1236 }
1237 default:
1238 {
1239 Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger);
1240 break;
1241 }
1242 }
1243 }
cce8b687 1244 return kFALSE;
59543510 1245}
955d29ba 1246
1247
1248 AliAnalysisHelperJetTasks::MCProcessType AliAnalysisHelperJetTasks::GetPythiaEventProcessType(AliGenEventHeader* aHeader, Bool_t adebug) {
aeb249fb 1249 //
1250 // fetch the process type from the mc header
1251 //
1252
955d29ba 1253
1254 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(aHeader);
1255
1256 if (!pythiaGenHeader) {
fb03edbe 1257 // printf(" AliAnalysisHelperJetTasks::GetProcessType : Unknown gen Header type). \n");
955d29ba 1258 return kInvalidProcess;
1259 }
1260
1261
1262 Int_t pythiaType = pythiaGenHeader->ProcessType();
1263 fgLastProcessType = pythiaType;
1264 MCProcessType globalType = kInvalidProcess;
1265
1266
1267 if (adebug) {
1268 printf(" AliAnalysisHelperJetTasks::GetProcessType : Pythia process type found: %d \n",pythiaType);
1269 }
1270
1271
1272 if(pythiaType==92||pythiaType==93){
1273 globalType = kSD;
1274 }
1275 else if(pythiaType==94){
1276 globalType = kDD;
1277 }
1278 //else if(pythiaType != 91){ // also exclude elastic to be sure... CKB??
1279 else {
1280 globalType = kND;
1281 }
1282 return globalType;
1283}
1284
1285
1286 AliAnalysisHelperJetTasks::MCProcessType AliAnalysisHelperJetTasks::GetDPMjetEventProcessType(AliGenEventHeader* aHeader, Bool_t adebug) {
1287 //
1288 // get the process type of the event.
1289 //
1290
1291 // can only read pythia headers, either directly or from cocktalil header
1292 AliGenDPMjetEventHeader* dpmJetGenHeader = dynamic_cast<AliGenDPMjetEventHeader*>(aHeader);
1293
1294 if (!dpmJetGenHeader) {
1295 printf(" AliAnalysisHelperJetTasks::GetDPMjetProcessType : Unknown header type (not DPMjet or). \n");
1296 return kInvalidProcess;
1297 }
1298
1299 Int_t dpmJetType = dpmJetGenHeader->ProcessType();
1300 fgLastProcessType = dpmJetType;
1301 MCProcessType globalType = kInvalidProcess;
1302
1303
1304 if (adebug) {
1305 printf(" AliAnalysisHelperJetTasks::GetDPMJetProcessType : DPMJet process type found: %d \n",dpmJetType);
1306 }
1307
1308
1309 if (dpmJetType == 1 || dpmJetType == 4) { // explicitly inelastic plus central diffraction
1310 globalType = kND;
1311 }
1312 else if (dpmJetType==5 || dpmJetType==6) {
1313 globalType = kSD;
1314 }
1315 else if (dpmJetType==7) {
1316 globalType = kDD;
1317 }
1318 return globalType;
1319}
1320