]>
Commit | Line | Data |
---|---|---|
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 | |
28 | ClassImp(AliAnalysisHelperJetTasks) | |
29 | ||
30 | ||
31 | ||
32 | ||
33 | AliGenPythiaEventHeader* 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 | ||
62 | void 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 | 92 | void 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 | ||
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 | 218 | void 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); | |
383d44fd | 246 | dIn[ibTotal] = (TDirectory*)fIn[ibTotal]->Get(cDir); |
247 | if(!dIn[ibTotal]){ | |
248 | Printf("%s:%d No directory %s found, exiting...",__FILE__,__LINE__,cDir); | |
249 | fIn[ibTotal]->ls(); | |
250 | return; | |
251 | } | |
252 | ||
253 | lIn[ibTotal] = (TList*)dIn[ibTotal]->Get(cList); | |
254 | Printf("Merging file %s %s",cFile, cDir); | |
188a1ba9 | 255 | if(!lIn[ibTotal]){ |
256 | Printf("%s:%d No list %s found, exiting...",__FILE__,__LINE__,cList); | |
257 | fIn[ibTotal]->ls(); | |
258 | return; | |
259 | } | |
260 | TH1* hTrials = (TH1F*)lIn[ibTotal]->FindObject("fh1Trials"); | |
261 | if(!hTrials){ | |
262 | Printf("%s:%d fh1PtHard_Trials not found in list, exiting...",__FILE__,__LINE__); | |
263 | return; | |
264 | } | |
265 | TProfile* hXsec = (TProfile*)lIn[ibTotal]->FindObject("fh1Xsec"); | |
266 | if(!hXsec){ | |
267 | Printf("%s:%d fh1Xsec not found in list, exiting...",__FILE__,__LINE__); | |
268 | return; | |
269 | } | |
270 | xsection[ibTotal] = hXsec->GetBinContent(1); | |
271 | nTrials[ibTotal] = hTrials->Integral(); | |
272 | sf[ibTotal] = xsection[ibTotal]/ nTrials[ibTotal]; | |
273 | ibTotal++; | |
274 | } | |
275 | ||
276 | if(ibTotal==0){ | |
277 | Printf("%s:%d No files found for mergin, exiting",__FILE__,__LINE__); | |
278 | return; | |
279 | } | |
280 | ||
383d44fd | 281 | TFile *fOut = 0; |
282 | if(bUpdate)fOut = new TFile(cOutFile,"UPDATE"); | |
283 | else fOut = new TFile(cOutFile,"RECREATE"); | |
284 | TDirectory *dOut = fOut->mkdir(dIn[0]->GetName()); | |
285 | dOut->cd(); | |
188a1ba9 | 286 | TList *lOut = new TList(); |
287 | lOut->SetName(lIn[0]->GetName()); | |
383d44fd | 288 | |
188a1ba9 | 289 | // for the start scale all... |
290 | for(int ie = 0; ie < lIn[0]->GetEntries();++ie){ | |
291 | TH1 *h1Add = 0; | |
292 | THnSparse *hnAdd = 0; | |
293 | for(int ib = 0;ib < ibTotal;++ib){ | |
294 | // dynamic cast does not work with cint | |
295 | TObject *h = lIn[ib]->At(ie); | |
296 | if(h->InheritsFrom("TH1")){ | |
297 | TH1 *h1 = (TH1*)h; | |
298 | if(ib==0){ | |
299 | h1Add = (TH1*)h1->Clone(h1->GetName()); | |
300 | h1Add->Scale(sf[ib]); | |
301 | } | |
302 | else{ | |
303 | h1Add->Add(h1,sf[ib]); | |
304 | } | |
305 | } | |
306 | else if(h->InheritsFrom("THnSparse")){ | |
307 | THnSparse *hn = (THnSparse*)h; | |
308 | if(ib==0){ | |
309 | hnAdd = (THnSparse*)hn->Clone(hn->GetName()); | |
310 | hnAdd->Scale(sf[ib]); | |
311 | } | |
312 | else{ | |
313 | hnAdd->Add(hn,sf[ib]); | |
314 | } | |
315 | } | |
316 | ||
317 | ||
318 | }// ib | |
319 | if(h1Add)lOut->Add(h1Add); | |
320 | else if(hnAdd)lOut->Add(hnAdd); | |
321 | } | |
383d44fd | 322 | dOut->cd(); |
188a1ba9 | 323 | lOut->Write(lOut->GetName(),TObject::kSingleKey); |
324 | fOut->Close(); | |
325 | } | |
519378fb | 326 | |
327 | Bool_t AliAnalysisHelperJetTasks::PythiaInfoFromFile(const char* currFile,Float_t &fXsec,Float_t &fTrials){ | |
328 | // | |
329 | // get the cross section and the trails either from pyxsec.root or from pysec_hists.root | |
330 | // This is to called in Notify and should provide the path to the AOD/ESD file | |
331 | ||
332 | TString file(currFile); | |
333 | fXsec = 0; | |
334 | fTrials = 1; | |
335 | ||
336 | if(file.Contains("root_archive.zip#")){ | |
337 | Ssiz_t pos1 = file.Index("root_archive",12,TString::kExact); | |
338 | Ssiz_t pos = file.Index("#",1,pos1,TString::kExact); | |
339 | file.Replace(pos+1,20,""); | |
340 | } | |
341 | else { | |
342 | // not an archive take the basename.... | |
343 | file.ReplaceAll(gSystem->BaseName(file.Data()),""); | |
344 | } | |
345 | Printf("%s",file.Data()); | |
346 | ||
347 | ||
348 | ||
349 | ||
350 | 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 | |
351 | if(!fxsec){ | |
352 | // next trial fetch the histgram file | |
353 | fxsec = TFile::Open(Form("%s%s",file.Data(),"pyxsec_hists.root")); | |
354 | if(!fxsec){ | |
355 | // not a severe condition but inciate that we have no information | |
356 | return kFALSE; | |
357 | } | |
358 | else{ | |
359 | // find the tlist we want to be independtent of the name so use the Tkey | |
360 | TKey* key = (TKey*)fxsec->GetListOfKeys()->At(0); | |
361 | if(!key){ | |
362 | fxsec->Close(); | |
363 | return kFALSE; | |
364 | } | |
365 | TList *list = dynamic_cast<TList*>(key->ReadObj()); | |
366 | if(!list){ | |
367 | fxsec->Close(); | |
368 | return kFALSE; | |
369 | } | |
370 | fXsec = ((TProfile*)list->FindObject("h1Xsec"))->GetBinContent(1); | |
371 | fTrials = ((TH1F*)list->FindObject("h1Trials"))->GetBinContent(1); | |
372 | fxsec->Close(); | |
373 | } | |
374 | } // no tree pyxsec.root | |
375 | else { | |
376 | TTree *xtree = (TTree*)fxsec->Get("Xsection"); | |
377 | if(!xtree){ | |
378 | fxsec->Close(); | |
379 | return kFALSE; | |
380 | } | |
381 | UInt_t ntrials = 0; | |
382 | Double_t xsection = 0; | |
383 | xtree->SetBranchAddress("xsection",&xsection); | |
384 | xtree->SetBranchAddress("ntrials",&ntrials); | |
385 | xtree->GetEntry(0); | |
386 | fTrials = ntrials; | |
387 | fXsec = xsection; | |
388 | fxsec->Close(); | |
389 | } | |
390 | return kTRUE; | |
391 | } | |
6f3f79de | 392 | |
383d44fd | 393 | Bool_t AliAnalysisHelperJetTasks::PrintDirectorySize(const char* currFile){ |
394 | ||
395 | TFile *fIn = TFile::Open(currFile); | |
396 | if(!fIn){ | |
397 | // not a severe condition but inciate that we have no information | |
398 | return kFALSE; | |
399 | } | |
400 | // find the tlists we want to be independtent of the name so use the Tkey | |
401 | TList* keyList = fIn->GetListOfKeys(); | |
402 | ||
403 | for(int i = 0;i < keyList->GetEntries();i++){ | |
404 | TKey* ikey = (TKey*)keyList->At(i); | |
405 | ||
406 | // TList *list = dynamic_cast<TList*>(key->ReadObj()); | |
407 | // TNamed *name = dynamic_cast<TNamed*>(ikey->ReadObj()); | |
408 | TDirectory *dir = dynamic_cast<TDirectory*>(ikey->ReadObj()); | |
409 | ||
410 | ||
411 | if(dir){ | |
412 | Printf("%03d : %60s %8d %8d ",i,dir->GetName(),ikey->GetObjlen(),ikey->GetNbytes()); | |
413 | TList * dirKeyList = dir->GetListOfKeys(); | |
414 | for(int j = 0;j<dirKeyList->GetEntries();j++){ | |
415 | TKey* jkey = (TKey*)dirKeyList->At(j); | |
416 | TList *list = dynamic_cast<TList*>(jkey->ReadObj()); | |
417 | if(list){ | |
418 | 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.); | |
419 | } | |
420 | else{ | |
421 | 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.); | |
422 | } | |
423 | } | |
424 | } | |
425 | } | |
426 | return kTRUE; | |
427 | } | |
428 | ||
429 | ||
59543510 | 430 | Bool_t AliAnalysisHelperJetTasks::Selected(Bool_t bSet,Bool_t bNew){ |
431 | static Bool_t bSelected = kTRUE; // if service task is not run we acccpet all | |
432 | if(bSet){ | |
433 | bSelected = bNew; | |
434 | } | |
435 | return bSelected; | |
436 | } | |
437 | ||
6f3f79de | 438 | //___________________________________________________________________________________________________________ |
439 | ||
440 | Bool_t AliAnalysisHelperJetTasks::GetEventShapes(TVector3 &n01, TVector3 * pTrack, Int_t nTracks, Double_t * eventShapes) | |
441 | { | |
442 | // *** | |
443 | // Event shape calculation | |
444 | // sona.pochybova@cern.ch | |
445 | ||
446 | const Int_t kTracks = 1000; | |
447 | if(nTracks>kTracks)return kFALSE; | |
448 | ||
20d01a2f | 449 | //variables for thrust calculation |
6f3f79de | 450 | TVector3 pTrackPerp[kTracks]; |
6f3f79de | 451 | Double_t psum2 = 0; |
20d01a2f | 452 | |
453 | TVector3 psum; | |
454 | TVector3 psum02; | |
455 | TVector3 psum03; | |
456 | ||
457 | Double_t psum1 = 0; | |
458 | Double_t psum102 = 0; | |
459 | Double_t psum103 = 0; | |
460 | ||
6f3f79de | 461 | Double_t thrust[kTracks]; |
462 | Double_t th = -3; | |
20d01a2f | 463 | Double_t thrust02[kTracks]; |
464 | Double_t th02 = -4; | |
465 | Double_t thrust03[kTracks]; | |
466 | Double_t th03 = -5; | |
6f3f79de | 467 | |
20d01a2f | 468 | //Sphericity calculation variables |
6f3f79de | 469 | TMatrixDSym m(3); |
470 | Double_t s00 = 0; | |
471 | Double_t s01 = 0; | |
472 | Double_t s02 = 0; | |
473 | ||
474 | Double_t s10 = 0; | |
475 | Double_t s11 = 0; | |
476 | Double_t s12 = 0; | |
477 | ||
478 | Double_t s20 = 0; | |
479 | Double_t s21 = 0; | |
480 | Double_t s22 = 0; | |
481 | ||
482 | Double_t ptot = 0; | |
483 | ||
484 | Double_t c = -10; | |
485 | ||
486 | // | |
487 | //loop for thrust calculation | |
488 | // | |
20d01a2f | 489 | |
490 | for(Int_t i = 0; i < nTracks; i++) | |
491 | { | |
492 | pTrackPerp[i].SetXYZ(pTrack[i].X(), pTrack[i].Y(), 0); | |
493 | psum2 += pTrackPerp[i].Mag(); | |
494 | } | |
495 | ||
496 | //additional starting axis | |
497 | TVector3 n02; | |
498 | n02 = pTrack[1].Unit(); | |
499 | n02.SetZ(0.); | |
500 | TVector3 n03; | |
501 | n03 = pTrack[2].Unit(); | |
502 | n03.SetZ(0.); | |
503 | ||
504 | //switches for calculating thrust for different starting points | |
505 | Int_t switch1 = 1; | |
506 | Int_t switch2 = 1; | |
507 | Int_t switch3 = 1; | |
508 | ||
509 | //indexes for iteration of different starting points | |
510 | Int_t l1 = 0; | |
511 | Int_t l2 = 0; | |
512 | Int_t l3 = 0; | |
513 | ||
514 | //maximal number of iterations | |
515 | // Int_t nMaxIter = 100; | |
516 | ||
517 | for(Int_t k = 0; k < nTracks; k++) | |
6f3f79de | 518 | { |
6f3f79de | 519 | |
20d01a2f | 520 | if(switch1 == 1){ |
521 | psum.SetXYZ(0., 0., 0.); | |
522 | psum1 = 0; | |
523 | for(Int_t i = 0; i < nTracks; i++) | |
524 | { | |
525 | psum1 += (TMath::Abs(n01.Dot(pTrackPerp[i]))); | |
526 | if (n01.Dot(pTrackPerp[i]) > 0) psum += pTrackPerp[i]; | |
527 | if (n01.Dot(pTrackPerp[i]) < 0) psum -= pTrackPerp[i]; | |
528 | } | |
529 | thrust[l1] = psum1/psum2; | |
530 | } | |
531 | ||
532 | if(switch2 == 1){ | |
533 | psum02.SetXYZ(0., 0., 0.); | |
534 | psum102 = 0; | |
535 | for(Int_t i = 0; i < nTracks; i++) | |
536 | { | |
537 | psum102 += (TMath::Abs(n02.Dot(pTrackPerp[i]))); | |
538 | if (n02.Dot(pTrackPerp[i]) > 0) psum02 += pTrackPerp[i]; | |
539 | if (n02.Dot(pTrackPerp[i]) < 0) psum02 -= pTrackPerp[i]; | |
540 | } | |
541 | thrust02[l2] = psum102/psum2; | |
542 | } | |
543 | ||
544 | if(switch3 == 1){ | |
545 | psum03.SetXYZ(0., 0., 0.); | |
546 | psum103 = 0; | |
547 | for(Int_t i = 0; i < nTracks; i++) | |
548 | { | |
549 | psum103 += (TMath::Abs(n03.Dot(pTrackPerp[i]))); | |
550 | if (n03.Dot(pTrackPerp[i]) > 0) psum03 += pTrackPerp[i]; | |
551 | if (n03.Dot(pTrackPerp[i]) < 0) psum03 -= pTrackPerp[i]; | |
552 | } | |
553 | thrust03[l3] = psum103/psum2; | |
554 | } | |
555 | ||
556 | //check whether thrust value converged | |
557 | if(TMath::Abs(th-thrust[l1]) < 10e-7){ | |
558 | switch1 = 0; | |
559 | } | |
560 | ||
561 | if(TMath::Abs(th02-thrust02[l2]) < 10e-7){ | |
562 | switch2 = 0; | |
563 | } | |
564 | ||
565 | if(TMath::Abs(th03-thrust03[l3]) < 10e-7){ | |
566 | switch3 = 0; | |
567 | } | |
568 | ||
569 | //if it didn't, continue with the calculation | |
570 | if(switch1 == 1){ | |
571 | th = thrust[l1]; | |
572 | n01 = psum.Unit(); | |
573 | l1++; | |
574 | } | |
575 | ||
576 | if(switch2 == 1){ | |
577 | th02 = thrust02[l2]; | |
578 | n02 = psum02.Unit(); | |
579 | l2++; | |
580 | } | |
581 | ||
582 | if(switch3 == 1){ | |
583 | th03 = thrust03[l3]; | |
584 | n03 = psum03.Unit(); | |
585 | l3++; | |
586 | } | |
587 | ||
588 | //if thrust values for all starting direction converged check if to the same value | |
589 | if(switch2 == 0 && switch1 == 0 && switch3 == 0){ | |
590 | if(TMath::Abs(th-th02) < 10e-7 && TMath::Abs(th-th03) < 10e-7 && TMath::Abs(th02-th03) < 10e-7){ | |
591 | eventShapes[0] = th; | |
e946cd3a | 592 | AliInfoGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),Form("===== THRUST VALUE FOUND AT %d :: %f\n", k, th)); |
20d01a2f | 593 | break; |
594 | } | |
595 | //if they did not, reset switches | |
596 | else{ | |
597 | switch1 = 1; | |
598 | // th = -1.; | |
599 | switch2 = 1; | |
600 | // th02 = -2.; | |
601 | switch3 = 1; | |
602 | // th03 = -4.; | |
603 | } | |
604 | } | |
605 | ||
606 | // Printf("========== %d +++ th :: %f=============\n", l1, th); | |
607 | // Printf("========== %d +++ th2 :: %f=============\n", l2, th02); | |
608 | // Printf("========== %d +++ th3 :: %f=============\n", l3, th03); | |
6f3f79de | 609 | |
6f3f79de | 610 | } |
611 | ||
20d01a2f | 612 | //if no common limitng value was found, take the maximum and take the corresponding thrust axis |
613 | if(switch1 == 1 && switch2 == 1 && switch3 == 1){ | |
614 | eventShapes[0] = TMath::Max(thrust[l1-1], thrust02[l2-1]); | |
615 | eventShapes[0] = TMath::Max(eventShapes[0], thrust03[l3-1]); | |
616 | if(TMath::Abs(eventShapes[0]-thrust[l1-1]) < 10e-7) | |
617 | n01 = n01; | |
618 | if(TMath::Abs(eventShapes[0]-thrust02[l2-1]) < 10e-7) | |
619 | n01 = n02; | |
620 | if(TMath::Abs(eventShapes[0]-thrust03[l3-1]) < 10e-7) | |
621 | n01 = n03; | |
622 | Printf("NO LIMITING VALUE FOUND :: MAXIMUM = %f\n", eventShapes[0]); | |
623 | } | |
6f3f79de | 624 | |
625 | // | |
626 | //other event shapes variables | |
627 | // | |
628 | for(Int_t j = 0; j < nTracks; j++) | |
629 | { | |
630 | s00 = s00 + (pTrack[j].Px()*pTrack[j].Px())/pTrack[j].Mag(); | |
631 | s01 = s01 + (pTrack[j].Px()*pTrack[j].Py())/pTrack[j].Mag(); | |
632 | s02 = s02 + (pTrack[j].Px()*pTrack[j].Pz())/pTrack[j].Mag(); | |
633 | ||
634 | s10 = s10 + (pTrack[j].Py()*pTrack[j].Px())/pTrack[j].Mag(); | |
635 | s11 = s11 + (pTrack[j].Py()*pTrack[j].Py())/pTrack[j].Mag(); | |
636 | s12 = s12 + (pTrack[j].Py()*pTrack[j].Pz())/pTrack[j].Mag(); | |
637 | ||
638 | s20 = s20 + (pTrack[j].Pz()*pTrack[j].Px())/pTrack[j].Mag(); | |
639 | s21 = s21 + (pTrack[j].Pz()*pTrack[j].Py())/pTrack[j].Mag(); | |
640 | s22 = s22 + (pTrack[j].Pz()*pTrack[j].Pz())/pTrack[j].Mag(); | |
641 | ||
642 | ptot += pTrack[j].Mag(); | |
643 | } | |
644 | ||
645 | if(ptot > 0.) | |
646 | { | |
647 | m(0,0) = s00/ptot; | |
648 | m(0,1) = s01/ptot; | |
649 | m(0,2) = s02/ptot; | |
650 | ||
651 | m(1,0) = s10/ptot; | |
652 | m(1,1) = s11/ptot; | |
653 | m(1,2) = s12/ptot; | |
654 | ||
655 | m(2,0) = s20/ptot; | |
656 | m(2,1) = s21/ptot; | |
657 | m(2,2) = s22/ptot; | |
658 | ||
659 | TMatrixDSymEigen eigen(m); | |
660 | TVectorD eigenVal = eigen.GetEigenValues(); | |
661 | ||
662 | Double_t sphericity = (3/2)*(eigenVal(2)+eigenVal(1)); | |
663 | eventShapes[1] = sphericity; | |
664 | ||
665 | Double_t aplanarity = (3/2)*(eigenVal(2)); | |
666 | eventShapes[2] = aplanarity; | |
667 | ||
668 | c = 3*(eigenVal(0)*eigenVal(1)+eigenVal(0)*eigenVal(2)+eigenVal(1)*eigenVal(2)); | |
669 | eventShapes[3] = c; | |
670 | } | |
671 | return kTRUE; | |
672 | } | |
673 | ||
674 | ||
675 | ||
676 | //__________________________________________________________________________________________________________________________ | |
59543510 | 677 | // Trigger Decisions copid from PWG0/AliTriggerAnalysis |
678 | ||
679 | ||
680 | Bool_t AliAnalysisHelperJetTasks::IsTriggerFired(const AliVEvent* aEv, Trigger trigger) | |
681 | { | |
682 | // checks if an event has been triggered | |
683 | // no usage of ofline trigger here yet | |
edfbe476 | 684 | |
7fa8b2da | 685 | // here we do a dirty hack to take also into account the |
686 | // missing trigger bits and Bunch crossing paatern for real data | |
edfbe476 | 687 | |
688 | ||
7fa8b2da | 689 | if(aEv->InheritsFrom("AliESDEvent")){ |
cce8b687 | 690 | const AliESDEvent *esd = (AliESDEvent*)aEv; |
691 | switch (trigger) | |
692 | { | |
693 | case kAcceptAll: | |
694 | { | |
695 | return kTRUE; | |
696 | break; | |
697 | } | |
698 | case kMB1: | |
699 | { | |
1c796df8 | 700 | if(esd->GetFiredTriggerClasses().Contains("CINT1B-"))return kTRUE; |
cd9a6fa2 | 701 | // does the same but without or'ed V0s |
edfbe476 | 702 | if(esd->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE; |
703 | if(esd->GetFiredTriggerClasses().Contains("CINT6B-"))return kTRUE; | |
1c796df8 | 704 | // this is for simulated data |
705 | if(esd->GetFiredTriggerClasses().Contains("MB1"))return kTRUE; | |
cce8b687 | 706 | break; |
707 | } | |
708 | case kMB2: | |
709 | { | |
1c796df8 | 710 | if(esd->GetFiredTriggerClasses().Contains("MB2"))return kTRUE; |
cce8b687 | 711 | break; |
712 | } | |
713 | case kMB3: | |
714 | { | |
1c796df8 | 715 | if(esd->GetFiredTriggerClasses().Contains("MB3"))return kTRUE; |
cce8b687 | 716 | break; |
717 | } | |
718 | case kSPDGFO: | |
719 | { | |
cd9a6fa2 | 720 | if(esd->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE; |
edfbe476 | 721 | if(esd->GetFiredTriggerClasses().Contains("CINT6B-"))return kTRUE; |
1c796df8 | 722 | if(esd->GetFiredTriggerClasses().Contains("GFO"))return kTRUE; |
cce8b687 | 723 | break; |
724 | } | |
725 | default: | |
726 | { | |
727 | Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger); | |
728 | break; | |
729 | } | |
730 | } | |
731 | } | |
732 | else if(aEv->InheritsFrom("AliAODEvent")){ | |
733 | const AliAODEvent *aod = (AliAODEvent*)aEv; | |
7fa8b2da | 734 | switch (trigger) |
735 | { | |
736 | case kAcceptAll: | |
737 | { | |
cce8b687 | 738 | return kTRUE; |
7fa8b2da | 739 | break; |
740 | } | |
741 | case kMB1: | |
742 | { | |
cce8b687 | 743 | if(aod->GetFiredTriggerClasses().Contains("CINT1B"))return kTRUE; |
cd9a6fa2 | 744 | // does the same but without or'ed V0s |
745 | if(aod->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE; | |
1c796df8 | 746 | // for sim data |
747 | if(aod->GetFiredTriggerClasses().Contains("MB1"))return kTRUE; | |
7fa8b2da | 748 | break; |
749 | } | |
750 | case kMB2: | |
751 | { | |
1c796df8 | 752 | if(aod->GetFiredTriggerClasses().Contains("MB2"))return kTRUE; |
7fa8b2da | 753 | break; |
754 | } | |
755 | case kMB3: | |
756 | { | |
1c796df8 | 757 | if(aod->GetFiredTriggerClasses().Contains("MB3"))return kTRUE; |
7fa8b2da | 758 | break; |
759 | } | |
760 | case kSPDGFO: | |
761 | { | |
cce8b687 | 762 | if(aod->GetFiredTriggerClasses().Contains("CSMBB"))return kTRUE; |
1c796df8 | 763 | if(aod->GetFiredTriggerClasses().Contains("GFO"))return kTRUE; |
7fa8b2da | 764 | break; |
765 | } | |
766 | default: | |
767 | { | |
768 | Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger); | |
769 | break; | |
770 | } | |
771 | } | |
772 | } | |
cce8b687 | 773 | return kFALSE; |
59543510 | 774 | } |