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