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