]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/JetTasks/AliAnalysisHelperJetTasks.cxx
updated for mini train analysis
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / AliAnalysisHelperJetTasks.cxx
CommitLineData
f3050824 1
2#include "TROOT.h"
519378fb 3#include "TKey.h"
f3050824 4#include "TList.h"
519378fb 5#include "TSystem.h"
188a1ba9 6#include "TH1F.h"
7#include "TProfile.h"
8#include "THnSparse.h"
9#include "TFile.h"
519378fb 10#include "TString.h"
f3050824 11#include "AliMCEvent.h"
5c047edc 12#include "AliLog.h"
59543510 13#include "AliESDEvent.h"
db6bcb0e 14#include "AliAODJet.h"
f3050824 15#include "AliStack.h"
16#include "AliGenEventHeader.h"
17#include "AliGenCocktailEventHeader.h"
18#include "AliGenPythiaEventHeader.h"
19#include <fstream>
20#include <iostream>
21#include "AliAnalysisHelperJetTasks.h"
6f3f79de 22#include "TMatrixDSym.h"
23#include "TMatrixDSymEigen.h"
24#include "TVector.h"
f3050824 25
26ClassImp(AliAnalysisHelperJetTasks)
27
28
29
30
31AliGenPythiaEventHeader* AliAnalysisHelperJetTasks::GetPythiaEventHeader(AliMCEvent *mcEvent){
32
33 AliGenEventHeader* genHeader = mcEvent->GenEventHeader();
34 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
35 if(!pythiaGenHeader){
36 // cocktail ??
37 AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(genHeader);
38
39 if (!genCocktailHeader) {
5c047edc 40 AliWarningGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),"Unknown header type (not Pythia or Cocktail)");
41 // AliWarning(Form("%s %d: Unknown header type (not Pythia or Cocktail)",(char*)__FILE__,__LINE__));
f3050824 42 return 0;
43 }
44 TList* headerList = genCocktailHeader->GetHeaders();
45 for (Int_t i=0; i<headerList->GetEntries(); i++) {
46 pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
47 if (pythiaGenHeader)
48 break;
49 }
50 if(!pythiaGenHeader){
5c047edc 51 AliWarningGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),"Pythia event header not found");
f3050824 52 return 0;
53 }
54 }
55 return pythiaGenHeader;
56
57}
58
59
60void AliAnalysisHelperJetTasks::PrintStack(AliMCEvent *mcEvent,Int_t iFirst,Int_t iLast,Int_t iMaxPrint){
61
62 AliStack *stack = mcEvent->Stack();
63 if(!stack){
64 Printf("%s%d No Stack available",(char*)__FILE__,__LINE__);
65 return;
66 }
67
68 static Int_t iCount = 0;
69 if(iCount>iMaxPrint)return;
70 Int_t nStack = stack->GetNtrack();
71 if(iLast == 0)iLast = nStack;
72 else if(iLast > nStack)iLast = nStack;
73
74
75 Printf("####################################################################");
76 for(Int_t np = iFirst;np<iLast;++np){
77 TParticle *p = stack->Particle(np);
78 Printf("Nr.%d --- Status %d ---- Mother1 %d Mother2 %d Daughter1 %d Daughter2 %d ",
79 np,p->GetStatusCode(),p->GetMother(0),p->GetMother(1),p->GetDaughter(0),p->GetDaughter(1));
80 Printf("Eta %3.3f Phi %3.3f ",p->Eta(),p->Phi());
81 p->Print();
82 Printf("---------------------------------------");
83 }
84 iCount++;
85}
86
87
db6bcb0e 88
89
3dc5a1a4 90void AliAnalysisHelperJetTasks::GetClosestJets(AliAODJet *genJets,const Int_t &kGenJets,
91 AliAODJet *recJets,const Int_t &kRecJets,
db6bcb0e 92 Int_t *iGenIndex,Int_t *iRecIndex,
93 Int_t iDebug,Float_t maxDist){
94
95 //
96 // Relate the two input jet Arrays
97 //
98
99 //
100 // The association has to be unique
101 // So check in two directions
102 // find the closest rec to a gen
103 // and check if there is no other rec which is closer
104 // Caveat: Close low energy/split jets may disturb this correlation
105
3dc5a1a4 106
db6bcb0e 107 // Idea: search in two directions generated e.g (a--e) and rec (1--3)
108 // Fill a matrix with Flags (1 for closest rec jet, 2 for closest rec jet
109 // in the end we have something like this
110 // 1 2 3
111 // ------------
112 // a| 3 2 0
113 // b| 0 1 0
114 // c| 0 0 3
115 // d| 0 0 1
116 // e| 0 0 1
117 // Topology
118 // 1 2
119 // a b
120 //
121 // d c
122 // 3 e
123 // Only entries with "3" match from both sides
3dc5a1a4 124
125 // In case we have more jets than kmaxjets only the
126 // first kmaxjets are searched
127 // all other are -1
128 // use kMaxJets for a test not to fragemnt the memory...
129
130 for(int i = 0;i < kGenJets;++i)iGenIndex[i] = -1;
131 for(int j = 0;j < kRecJets;++j)iRecIndex[j] = -1;
132
133
db6bcb0e 134
135 const int kMode = 3;
136
3dc5a1a4 137 const Int_t nGenJets = TMath::Min(kMaxJets,kGenJets);
138 const Int_t nRecJets = TMath::Min(kMaxJets,kRecJets);
db6bcb0e 139
140 if(nRecJets==0||nGenJets==0)return;
141
3dc5a1a4 142 // UShort_t *iFlag = new UShort_t[nGenJets*nRecJets];
143 UShort_t iFlag[kMaxJets*kMaxJets];
db6bcb0e 144 for(int i = 0;i < nGenJets;++i){
145 for(int j = 0;j < nRecJets;++j){
146 iFlag[i*nGenJets+j] = 0;
147 }
148 }
149
150
151
152 // find the closest distance to the generated
153 for(int ig = 0;ig<nGenJets;++ig){
154 Float_t dist = maxDist;
155 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());
156 for(int ir = 0;ir<nRecJets;++ir){
157 Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
158 if(iDebug>1)Printf("Rec (%d) p_T %3.3f eta %3.3f ph %3.3f ",ir,recJets[ir].Pt(),recJets[ir].Eta(),recJets[ir].Phi());
159 if(iDebug>1)Printf("Distance (%d)--(%d) %3.3f ",ig,ir,dR);
160 if(dR<dist){
161 iRecIndex[ig] = ir;
162 dist = dR;
163 }
164 }
165 if(iRecIndex[ig]>=0)iFlag[ig*nGenJets+iRecIndex[ig]]+=1;
166 // reset...
167 iRecIndex[ig] = -1;
168 }
169 // other way around
170 for(int ir = 0;ir<nRecJets;++ir){
171 Float_t dist = maxDist;
172 for(int ig = 0;ig<nGenJets;++ig){
173 Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
174 if(dR<dist){
175 iGenIndex[ir] = ig;
176 dist = dR;
177 }
178 }
179 if(iGenIndex[ir]>=0)iFlag[iGenIndex[ir]*nGenJets+ir]+=2;
180 // reset...
181 iGenIndex[ir] = -1;
182 }
183
184 // check for "true" correlations
185
186 if(iDebug>1)Printf(">>>>>> Matrix");
187
188 for(int ig = 0;ig<nGenJets;++ig){
189 for(int ir = 0;ir<nRecJets;++ir){
190 // Print
191 if(iDebug>1)printf("Flag[%d][%d] %d ",ig,ir,iFlag[ig*nGenJets+ir]);
192
193 if(kMode==3){
194 // we have a uniqie correlation
195 if(iFlag[ig*nGenJets+ir]==3){
196 iGenIndex[ir] = ig;
197 iRecIndex[ig] = ir;
198 }
199 }
200 else{
201 // we just take the correlation from on side
202 if((iFlag[ig*nGenJets+ir]&2)==2){
203 iGenIndex[ir] = ig;
204 }
205 if((iFlag[ig*nGenJets+ir]&1)==1){
206 iRecIndex[ig] = ir;
207 }
208 }
209 }
210 if(iDebug>1)printf("\n");
211 }
db6bcb0e 212}
213
214
215
188a1ba9 216void AliAnalysisHelperJetTasks::MergeOutput(char* cFiles, char* cList){
db6bcb0e 217
188a1ba9 218 // This is used to merge the analysis-output from different
219 // data samples/pt_hard bins
220 // in case the eventweigth was set to xsection/ntrials already, this
221 // is not needed. Both methods only work in case we do not mix different
222 // pt_hard bins, and do not have overlapping bins
db6bcb0e 223
188a1ba9 224 const Int_t nMaxBins = 12;
225 // LHC08q jetjet100: Mean = 1.42483e-03, RMS = 6.642e-05
226 // LHC08r jetjet50: Mean = 2.44068e-02, RMS = 1.144e-03
227 // LHC08v jetjet15-50: Mean = 2.168291 , RMS = 7.119e-02
228 // const Float_t xsection[nBins] = {2.168291,2.44068e-02};
229
230 Float_t xsection[nMaxBins];
231 Float_t nTrials[nMaxBins];
232 Float_t sf[nMaxBins];
233 TList *lIn[nMaxBins];
234 TFile *fIn[nMaxBins];
235
236 ifstream in1;
237 in1.open(cFiles);
238
239 char cFile[120];
240 Int_t ibTotal = 0;
241 while(in1>>cFile){
242 fIn[ibTotal] = TFile::Open(cFile);
243 lIn[ibTotal] = (TList*)fIn[ibTotal]->Get(cList);
5c047edc 244 Printf("Merging file %s",cFile);
188a1ba9 245 if(!lIn[ibTotal]){
246 Printf("%s:%d No list %s found, exiting...",__FILE__,__LINE__,cList);
247 fIn[ibTotal]->ls();
248 return;
249 }
250 TH1* hTrials = (TH1F*)lIn[ibTotal]->FindObject("fh1Trials");
251 if(!hTrials){
252 Printf("%s:%d fh1PtHard_Trials not found in list, exiting...",__FILE__,__LINE__);
253 return;
254 }
255 TProfile* hXsec = (TProfile*)lIn[ibTotal]->FindObject("fh1Xsec");
256 if(!hXsec){
257 Printf("%s:%d fh1Xsec not found in list, exiting...",__FILE__,__LINE__);
258 return;
259 }
260 xsection[ibTotal] = hXsec->GetBinContent(1);
261 nTrials[ibTotal] = hTrials->Integral();
262 sf[ibTotal] = xsection[ibTotal]/ nTrials[ibTotal];
263 ibTotal++;
264 }
265
266 if(ibTotal==0){
267 Printf("%s:%d No files found for mergin, exiting",__FILE__,__LINE__);
268 return;
269 }
270
271 TFile *fOut = new TFile("allpt.root","RECREATE");
272 TList *lOut = new TList();
273 lOut->SetName(lIn[0]->GetName());
274 // for the start scale all...
275 for(int ie = 0; ie < lIn[0]->GetEntries();++ie){
276 TH1 *h1Add = 0;
277 THnSparse *hnAdd = 0;
278 for(int ib = 0;ib < ibTotal;++ib){
279 // dynamic cast does not work with cint
280 TObject *h = lIn[ib]->At(ie);
281 if(h->InheritsFrom("TH1")){
282 TH1 *h1 = (TH1*)h;
283 if(ib==0){
284 h1Add = (TH1*)h1->Clone(h1->GetName());
285 h1Add->Scale(sf[ib]);
286 }
287 else{
288 h1Add->Add(h1,sf[ib]);
289 }
290 }
291 else if(h->InheritsFrom("THnSparse")){
292 THnSparse *hn = (THnSparse*)h;
293 if(ib==0){
294 hnAdd = (THnSparse*)hn->Clone(hn->GetName());
295 hnAdd->Scale(sf[ib]);
296 }
297 else{
298 hnAdd->Add(hn,sf[ib]);
299 }
300 }
301
302
303 }// ib
304 if(h1Add)lOut->Add(h1Add);
305 else if(hnAdd)lOut->Add(hnAdd);
306 }
307 fOut->cd();
308 lOut->Write(lOut->GetName(),TObject::kSingleKey);
309 fOut->Close();
310}
519378fb 311
312Bool_t AliAnalysisHelperJetTasks::PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials){
313 //
314 // get the cross section and the trails either from pyxsec.root or from pysec_hists.root
315 // This is to called in Notify and should provide the path to the AOD/ESD file
316
317 TString file(currFile);
318 fXsec = 0;
319 fTrials = 1;
320
321 if(file.Contains("root_archive.zip#")){
322 Ssiz_t pos1 = file.Index("root_archive",12,TString::kExact);
323 Ssiz_t pos = file.Index("#",1,pos1,TString::kExact);
324 file.Replace(pos+1,20,"");
325 }
326 else {
327 // not an archive take the basename....
328 file.ReplaceAll(gSystem->BaseName(file.Data()),"");
329 }
330 Printf("%s",file.Data());
331
332
333
334
335 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
336 if(!fxsec){
337 // next trial fetch the histgram file
338 fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root"));
339 if(!fxsec){
340 // not a severe condition but inciate that we have no information
341 return kFALSE;
342 }
343 else{
344 // find the tlist we want to be independtent of the name so use the Tkey
345 TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0);
346 if(!key){
347 fxsec->Close();
348 return kFALSE;
349 }
350 TList *list = dynamic_cast<TList*>(key->ReadObj());
351 if(!list){
352 fxsec->Close();
353 return kFALSE;
354 }
355 fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1);
356 fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1);
357 fxsec->Close();
358 }
359 } // no tree pyxsec.root
360 else {
361 TTree *xtree = (TTree*)fxsec->Get("Xsection");
362 if(!xtree){
363 fxsec->Close();
364 return kFALSE;
365 }
366 UInt_t ntrials = 0;
367 Double_t xsection = 0;
368 xtree->SetBranchAddress("xsection",&xsection);
369 xtree->SetBranchAddress("ntrials",&ntrials);
370 xtree->GetEntry(0);
371 fTrials = ntrials;
372 fXsec = xsection;
373 fxsec->Close();
374 }
375 return kTRUE;
376}
6f3f79de 377
59543510 378Bool_t AliAnalysisHelperJetTasks::Selected(Bool_t bSet,Bool_t bNew){
379 static Bool_t bSelected = kTRUE; // if service task is not run we acccpet all
380 if(bSet){
381 bSelected = bNew;
382 }
383 return bSelected;
384}
385
6f3f79de 386//___________________________________________________________________________________________________________
387
388Bool_t AliAnalysisHelperJetTasks::GetEventShapes(TVector3 &n01, TVector3 * pTrack, Int_t nTracks, Double_t * eventShapes)
389{
390 // ***
391 // Event shape calculation
392 // sona.pochybova@cern.ch
393
394 const Int_t kTracks = 1000;
395 if(nTracks>kTracks)return kFALSE;
396
20d01a2f 397 //variables for thrust calculation
6f3f79de 398 TVector3 pTrackPerp[kTracks];
6f3f79de 399 Double_t psum2 = 0;
20d01a2f 400
401 TVector3 psum;
402 TVector3 psum02;
403 TVector3 psum03;
404
405 Double_t psum1 = 0;
406 Double_t psum102 = 0;
407 Double_t psum103 = 0;
408
6f3f79de 409 Double_t thrust[kTracks];
410 Double_t th = -3;
20d01a2f 411 Double_t thrust02[kTracks];
412 Double_t th02 = -4;
413 Double_t thrust03[kTracks];
414 Double_t th03 = -5;
6f3f79de 415
20d01a2f 416 //Sphericity calculation variables
6f3f79de 417 TMatrixDSym m(3);
418 Double_t s00 = 0;
419 Double_t s01 = 0;
420 Double_t s02 = 0;
421
422 Double_t s10 = 0;
423 Double_t s11 = 0;
424 Double_t s12 = 0;
425
426 Double_t s20 = 0;
427 Double_t s21 = 0;
428 Double_t s22 = 0;
429
430 Double_t ptot = 0;
431
432 Double_t c = -10;
433
434//
435//loop for thrust calculation
436//
20d01a2f 437
438 for(Int_t i = 0; i < nTracks; i++)
439 {
440 pTrackPerp[i].SetXYZ(pTrack[i].X(), pTrack[i].Y(), 0);
441 psum2 += pTrackPerp[i].Mag();
442 }
443
444 //additional starting axis
445 TVector3 n02;
446 n02 = pTrack[1].Unit();
447 n02.SetZ(0.);
448 TVector3 n03;
449 n03 = pTrack[2].Unit();
450 n03.SetZ(0.);
451
452 //switches for calculating thrust for different starting points
453 Int_t switch1 = 1;
454 Int_t switch2 = 1;
455 Int_t switch3 = 1;
456
457 //indexes for iteration of different starting points
458 Int_t l1 = 0;
459 Int_t l2 = 0;
460 Int_t l3 = 0;
461
462 //maximal number of iterations
463 // Int_t nMaxIter = 100;
464
465 for(Int_t k = 0; k < nTracks; k++)
6f3f79de 466 {
6f3f79de 467
20d01a2f 468 if(switch1 == 1){
469 psum.SetXYZ(0., 0., 0.);
470 psum1 = 0;
471 for(Int_t i = 0; i < nTracks; i++)
472 {
473 psum1 += (TMath::Abs(n01.Dot(pTrackPerp[i])));
474 if (n01.Dot(pTrackPerp[i]) > 0) psum += pTrackPerp[i];
475 if (n01.Dot(pTrackPerp[i]) < 0) psum -= pTrackPerp[i];
476 }
477 thrust[l1] = psum1/psum2;
478 }
479
480 if(switch2 == 1){
481 psum02.SetXYZ(0., 0., 0.);
482 psum102 = 0;
483 for(Int_t i = 0; i < nTracks; i++)
484 {
485 psum102 += (TMath::Abs(n02.Dot(pTrackPerp[i])));
486 if (n02.Dot(pTrackPerp[i]) > 0) psum02 += pTrackPerp[i];
487 if (n02.Dot(pTrackPerp[i]) < 0) psum02 -= pTrackPerp[i];
488 }
489 thrust02[l2] = psum102/psum2;
490 }
491
492 if(switch3 == 1){
493 psum03.SetXYZ(0., 0., 0.);
494 psum103 = 0;
495 for(Int_t i = 0; i < nTracks; i++)
496 {
497 psum103 += (TMath::Abs(n03.Dot(pTrackPerp[i])));
498 if (n03.Dot(pTrackPerp[i]) > 0) psum03 += pTrackPerp[i];
499 if (n03.Dot(pTrackPerp[i]) < 0) psum03 -= pTrackPerp[i];
500 }
501 thrust03[l3] = psum103/psum2;
502 }
503
504 //check whether thrust value converged
505 if(TMath::Abs(th-thrust[l1]) < 10e-7){
506 switch1 = 0;
507 }
508
509 if(TMath::Abs(th02-thrust02[l2]) < 10e-7){
510 switch2 = 0;
511 }
512
513 if(TMath::Abs(th03-thrust03[l3]) < 10e-7){
514 switch3 = 0;
515 }
516
517 //if it didn't, continue with the calculation
518 if(switch1 == 1){
519 th = thrust[l1];
520 n01 = psum.Unit();
521 l1++;
522 }
523
524 if(switch2 == 1){
525 th02 = thrust02[l2];
526 n02 = psum02.Unit();
527 l2++;
528 }
529
530 if(switch3 == 1){
531 th03 = thrust03[l3];
532 n03 = psum03.Unit();
533 l3++;
534 }
535
536 //if thrust values for all starting direction converged check if to the same value
537 if(switch2 == 0 && switch1 == 0 && switch3 == 0){
538 if(TMath::Abs(th-th02) < 10e-7 && TMath::Abs(th-th03) < 10e-7 && TMath::Abs(th02-th03) < 10e-7){
539 eventShapes[0] = th;
e946cd3a 540 AliInfoGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),Form("===== THRUST VALUE FOUND AT %d :: %f\n", k, th));
20d01a2f 541 break;
542 }
543 //if they did not, reset switches
544 else{
545 switch1 = 1;
546 // th = -1.;
547 switch2 = 1;
548 // th02 = -2.;
549 switch3 = 1;
550 // th03 = -4.;
551 }
552 }
553
554 // Printf("========== %d +++ th :: %f=============\n", l1, th);
555 // Printf("========== %d +++ th2 :: %f=============\n", l2, th02);
556 // Printf("========== %d +++ th3 :: %f=============\n", l3, th03);
6f3f79de 557
6f3f79de 558 }
559
20d01a2f 560 //if no common limitng value was found, take the maximum and take the corresponding thrust axis
561 if(switch1 == 1 && switch2 == 1 && switch3 == 1){
562 eventShapes[0] = TMath::Max(thrust[l1-1], thrust02[l2-1]);
563 eventShapes[0] = TMath::Max(eventShapes[0], thrust03[l3-1]);
564 if(TMath::Abs(eventShapes[0]-thrust[l1-1]) < 10e-7)
565 n01 = n01;
566 if(TMath::Abs(eventShapes[0]-thrust02[l2-1]) < 10e-7)
567 n01 = n02;
568 if(TMath::Abs(eventShapes[0]-thrust03[l3-1]) < 10e-7)
569 n01 = n03;
570 Printf("NO LIMITING VALUE FOUND :: MAXIMUM = %f\n", eventShapes[0]);
571 }
6f3f79de 572
573//
574//other event shapes variables
575//
576 for(Int_t j = 0; j < nTracks; j++)
577 {
578 s00 = s00 + (pTrack[j].Px()*pTrack[j].Px())/pTrack[j].Mag();
579 s01 = s01 + (pTrack[j].Px()*pTrack[j].Py())/pTrack[j].Mag();
580 s02 = s02 + (pTrack[j].Px()*pTrack[j].Pz())/pTrack[j].Mag();
581
582 s10 = s10 + (pTrack[j].Py()*pTrack[j].Px())/pTrack[j].Mag();
583 s11 = s11 + (pTrack[j].Py()*pTrack[j].Py())/pTrack[j].Mag();
584 s12 = s12 + (pTrack[j].Py()*pTrack[j].Pz())/pTrack[j].Mag();
585
586 s20 = s20 + (pTrack[j].Pz()*pTrack[j].Px())/pTrack[j].Mag();
587 s21 = s21 + (pTrack[j].Pz()*pTrack[j].Py())/pTrack[j].Mag();
588 s22 = s22 + (pTrack[j].Pz()*pTrack[j].Pz())/pTrack[j].Mag();
589
590 ptot += pTrack[j].Mag();
591 }
592
593 if(ptot > 0.)
594 {
595 m(0,0) = s00/ptot;
596 m(0,1) = s01/ptot;
597 m(0,2) = s02/ptot;
598
599 m(1,0) = s10/ptot;
600 m(1,1) = s11/ptot;
601 m(1,2) = s12/ptot;
602
603 m(2,0) = s20/ptot;
604 m(2,1) = s21/ptot;
605 m(2,2) = s22/ptot;
606
607 TMatrixDSymEigen eigen(m);
608 TVectorD eigenVal = eigen.GetEigenValues();
609
610 Double_t sphericity = (3/2)*(eigenVal(2)+eigenVal(1));
611 eventShapes[1] = sphericity;
612
613 Double_t aplanarity = (3/2)*(eigenVal(2));
614 eventShapes[2] = aplanarity;
615
616 c = 3*(eigenVal(0)*eigenVal(1)+eigenVal(0)*eigenVal(2)+eigenVal(1)*eigenVal(2));
617 eventShapes[3] = c;
618 }
619 return kTRUE;
620}
621
622
623
624 //__________________________________________________________________________________________________________________________
59543510 625// Trigger Decisions copid from PWG0/AliTriggerAnalysis
626
627
628Bool_t AliAnalysisHelperJetTasks::IsTriggerFired(const AliVEvent* aEv, Trigger trigger)
629{
630 // checks if an event has been triggered
631 // no usage of ofline trigger here yet
632 return IsTriggerBitFired(aEv, trigger);
633}
634
635Bool_t AliAnalysisHelperJetTasks::IsTriggerBitFired(const AliVEvent* aEv, Trigger trigger)
636{
637 // checks if an event is fired using the trigger bits
7fa8b2da 638 // here we do a dirty hack to take also into account the
639 // missing trigger bits and Bunch crossing paatern for real data
640
641 Bool_t bitFired = IsTriggerBitFired(aEv->GetTriggerMask(), trigger);
642 Bool_t isStringFired = false;
643
644 if(aEv->InheritsFrom("AliESDEvent")){
645 const AliESDEvent *esd = (AliESDEvent*)(aEv);
646 switch (trigger)
647 {
648 case kAcceptAll:
649 {
650 isStringFired = kTRUE;
651 break;
652 }
653 case kMB1:
654 {
655 if(esd->GetFiredTriggerClasses().Contains("CINT1B"))isStringFired = true;;
656 break;
657 }
658 case kMB2:
659 {
660 break;
661 }
662 case kMB3:
663 {
664 break;
665 }
666 case kSPDGFO:
667 {
668 if(esd->GetFiredTriggerClasses().Contains("CSMBB"))isStringFired = true;;
669 break;
670 }
671 default:
672 {
673 Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger);
674 break;
675 }
676 }
677 }
678 return bitFired||isStringFired;
59543510 679}
680
681Bool_t AliAnalysisHelperJetTasks::IsTriggerBitFired(ULong64_t triggerMask, Trigger trigger)
682{
683 // checks if an event is fired using the trigger bits
684 //
685 // this function needs the branch TriggerMask in the ESD
59543510 686
687 // definitions from p-p.cfg
688 ULong64_t spdFO = (1 << 14);
689 ULong64_t v0left = (1 << 10);
690 ULong64_t v0right = (1 << 11);
691
692 switch (trigger)
693 {
694 case kAcceptAll:
695 {
696 return kTRUE;
697 break;
698 }
699 case kMB1:
700 {
701 if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right)))
702 return kTRUE;
703 break;
704 }
705 case kMB2:
706 {
707 if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right)))
708 return kTRUE;
709 break;
710 }
711 case kMB3:
712 {
713 if (triggerMask & spdFO && (triggerMask & v0left) && (triggerMask & v0right))
714 return kTRUE;
715 break;
716 }
717 case kSPDGFO:
718 {
719 if (triggerMask & spdFO)
720 return kTRUE;
721 break;
722 }
723 default:
724 Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger);
725 break;
726 }
727
728 return kFALSE;
729}
730
731Bool_t AliAnalysisHelperJetTasks::IsTriggerBitFired(const AliVEvent* aEv, ULong64_t tclass)
732{
733 // Checks if corresponding bit in mask is on
734
735 ULong64_t trigmask = aEv->GetTriggerMask();
736 return (trigmask & (1ull << (tclass-1)));
737}