3 #include "AliAnalysisTaskEMCALPi0PbPb.h"
6 #include <TClonesArray.h>
8 #include <TGeoGlobalMagField.h>
12 #include <TLorentzVector.h>
17 #include "AliAODEvent.h"
18 #include "AliAODMCParticle.h"
19 #include "AliAODVertex.h"
20 #include "AliAnalysisManager.h"
21 #include "AliAnalysisTaskEMCALClusterizeFast.h"
22 #include "AliCDBManager.h"
23 #include "AliCentrality.h"
24 #include "AliEMCALDigit.h"
25 #include "AliEMCALGeometry.h"
26 #include "AliEMCALRecPoint.h"
27 #include "AliEMCALRecoUtils.h"
28 #include "AliESDCaloTrigger.h"
29 #include "AliESDEvent.h"
30 #include "AliESDUtils.h"
31 #include "AliESDVertex.h"
32 #include "AliESDtrack.h"
33 #include "AliESDtrackCuts.h"
34 #include "AliEventplane.h"
35 #include "AliGeomManager.h"
36 #include "AliInputEventHandler.h"
38 #include "AliMCEvent.h"
39 #include "AliMCParticle.h"
41 #include "AliMultiplicity.h"
43 #include "AliTrackerBase.h"
45 ClassImp(AliAnalysisTaskEMCALPi0PbPb)
47 //________________________________________________________________________
48 AliAnalysisTaskEMCALPi0PbPb::AliAnalysisTaskEMCALPi0PbPb()
49 : AliAnalysisTaskSE(),
64 fGeoName("EMCAL_FIRSTYEARV1"),
110 fHTclsBeforeCuts(0x0),
111 fHTclsAfterCuts(0x0),
119 fHCellFreqNoCut(0x0),
120 fHCellFreqCut100M(0x0),
121 fHCellFreqCut300M(0x0),
124 fHClustEccentricity(0),
126 fHClustEnergyPt(0x0),
127 fHClustEnergySigma(0x0),
128 fHClustSigmaSigma(0x0),
129 fHClustNCellEnergyRatio(0x0),
130 fHClustEnergyNCell(0x0),
145 //________________________________________________________________________
146 AliAnalysisTaskEMCALPi0PbPb::AliAnalysisTaskEMCALPi0PbPb(const char *name)
147 : AliAnalysisTaskSE(name),
162 fGeoName("EMCAL_FIRSTYEARV1"),
208 fHTclsBeforeCuts(0x0),
209 fHTclsAfterCuts(0x0),
217 fHCellFreqNoCut(0x0),
218 fHCellFreqCut100M(0x0),
219 fHCellFreqCut300M(0x0),
222 fHClustEccentricity(0),
224 fHClustEnergyPt(0x0),
225 fHClustEnergySigma(0x0),
226 fHClustSigmaSigma(0x0),
227 fHClustNCellEnergyRatio(0x0),
228 fHClustEnergyNCell(0x0),
242 DefineOutput(1, TList::Class());
243 fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.,SPDVertex.,TPCVertex.,EMCALCells.,Tracks EMCALTrigger."
244 "AOD:header,vertices,emcalCells,tracks";
247 //________________________________________________________________________
248 AliAnalysisTaskEMCALPi0PbPb::~AliAnalysisTaskEMCALPi0PbPb()
252 if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
253 delete fOutput; fOutput = 0;
255 delete fPtRanges; fPtRanges = 0;
256 fGeom = 0; // do not delete geometry when using instance
257 delete fReco; fReco = 0;
258 delete fTrClassNamesArr;
260 delete fSelPrimTracks;
261 delete [] fAmpInTrigger;
263 delete [] fHColuRowE;
264 delete [] fHCellMult;
265 delete [] fHCellFreqNoCut;
266 delete [] fHCellFreqCut100M;
267 delete [] fHCellFreqCut300M;
270 //________________________________________________________________________
271 void AliAnalysisTaskEMCALPi0PbPb::UserCreateOutputObjects()
273 // Create user objects here.
275 cout << "AliAnalysisTaskEMCALPi0PbPb: Input settings" << endl;
276 cout << " fCentVar: " << fCentVar << endl;
277 cout << " fCentFrom: " << fCentFrom << endl;
278 cout << " fCentTo: " << fCentTo << endl;
279 cout << " fVtxZMin: " << fVtxZMin << endl;
280 cout << " fVtxZMax: " << fVtxZMax << endl;
281 cout << " fUseQualFlag: " << fUseQualFlag << endl;
282 cout << " fClusName: \"" << fClusName << "\"" << endl;
283 cout << " fDoNtuple: " << fDoNtuple << endl;
284 cout << " fDoAfterburner: " << fDoAfterburner << endl;
285 cout << " fAsymMax: " << fAsymMax << endl;
286 cout << " fNminCells: " << fNminCells << endl;
287 cout << " fMinE: " << fMinE << endl;
288 cout << " fMinErat: " << fMinErat << endl;
289 cout << " fMinEcc: " << fMinEcc << endl;
290 cout << " fGeoName: \"" << fGeoName << "\"" << endl;
291 cout << " fMinNClusPerTr: " << fMinNClusPerTr << endl;
292 cout << " fIsoDist: " << fIsoDist << endl;
293 cout << " fTrClassNames: \"" << fTrClassNames << "\"" << endl;
294 cout << " fTrCuts: " << fTrCuts << endl;
295 cout << " fPrimTrCuts: " << fPrimTrCuts << endl;
296 cout << " fDoTrMatGeom: " << fDoTrMatGeom << endl;
297 cout << " fTrainMode: " << fTrainMode << endl;
298 cout << " fMarkCells: " << fMarkCells << endl;
299 cout << " fMinL0Time: " << fMinL0Time << endl;
300 cout << " fMaxL0Time: " << fMaxL0Time << endl;
301 cout << " fMcMode: " << fMcMode << endl;
302 cout << " fEmbedMode: " << fEmbedMode << endl;
303 cout << " fGeom: " << fGeom << endl;
304 cout << " fReco: " << fReco << endl;
305 cout << " fDoPSel: " << fDoPSel << endl;
308 fGeom = AliEMCALGeometry::GetInstance(fGeoName);
310 if (fGeom->GetMatrixForSuperModule(0))
311 fIsGeoMatsSet = kTRUE;
314 fReco = new AliEMCALRecoUtils();
315 fTrClassNamesArr = fTrClassNames.Tokenize(" ");
316 fOutput = new TList();
317 fOutput->SetOwner(1);
318 fSelTracks = new TObjArray;
319 fSelPrimTracks = new TObjArray;
322 TFile *f = OpenFile(1);
323 TDirectory::TContext context(f);
325 f->SetCompressionLevel(2);
326 fNtuple = new TTree(Form("tree%.0fto%.0f",fCentFrom,fCentTo), "StandaloneTree");
327 fNtuple->SetDirectory(f);
329 fNtuple->SetAutoFlush(-2*1024*1024);
330 fNtuple->SetAutoSave(0);
332 fNtuple->SetAutoFlush(-32*1024*1024);
333 fNtuple->SetAutoSave(0);
336 fHeader = new AliStaHeader;
337 fNtuple->Branch("header", &fHeader, 16*1024, 99);
338 fPrimVert = new AliStaVertex;
339 fNtuple->Branch("primv", &fPrimVert, 16*1024, 99);
340 fSpdVert = new AliStaVertex;
341 fNtuple->Branch("spdv", &fSpdVert, 16*1024, 99);
342 fTpcVert = new AliStaVertex;
343 fNtuple->Branch("tpcv", &fTpcVert, 16*1024, 99);
344 if (TClass::GetClass("AliStaCluster"))
345 TClass::GetClass("AliStaCluster")->IgnoreTObjectStreamer();
346 fClusters = new TClonesArray("AliStaCluster");
347 fNtuple->Branch("clusters", &fClusters, 8*16*1024, 99);
348 if (TClass::GetClass("AliStaTrigger"))
349 TClass::GetClass("AliStaTrigger")->IgnoreTObjectStreamer();
350 fTriggers = new TClonesArray("AliStaTrigger");
351 fNtuple->Branch("l0prim", &fTriggers, 16*1024, 99);
352 if (fMcMode||fEmbedMode) {
353 if (TClass::GetClass("AliStaPart"))
354 TClass::GetClass("AliStaPart")->IgnoreTObjectStreamer();
355 fMcParts = new TClonesArray("AliStaPart");
356 fNtuple->Branch("mcparts", &fMcParts, 8*16*1024, 99);
361 AliEMCALEMCGeometry *emc = fGeom->GetEMCGeometry();
362 Double_t phimin = emc->GetArm1PhiMin()*TMath::DegToRad();
363 Double_t phimax = emc->GetArm1PhiMax()*TMath::DegToRad();
366 Bool_t th1 = TH1::GetDefaultSumw2();
367 TH1::SetDefaultSumw2(kTRUE);
368 Bool_t th2 = TH2::GetDefaultSumw2();
369 TH2::SetDefaultSumw2(kTRUE);
370 fHCuts = new TH1F("hEventCuts","",5,0.5,5.5);
371 fHCuts->GetXaxis()->SetBinLabel(1,"All");
372 fHCuts->GetXaxis()->SetBinLabel(2,"PS");
373 fHCuts->GetXaxis()->SetBinLabel(3,Form("%s: %.0f-%.0f",fCentVar.Data(),fCentFrom,fCentTo));
374 fHCuts->GetXaxis()->SetBinLabel(4,"QFlag");
375 fHCuts->GetXaxis()->SetBinLabel(5,Form("zvtx: %.0f-%.0f",fVtxZMin,fVtxZMax));
376 fOutput->Add(fHCuts);
377 fHVertexZ = new TH1F("hVertexZBeforeCut","",100,-25,25);
378 fHVertexZ->SetXTitle("z [cm]");
379 fOutput->Add(fHVertexZ);
380 fHVertexZ2 = new TH1F("hVertexZAfterCut","",100,-25,25);
381 fHVertexZ2->SetXTitle("z [cm]");
382 fOutput->Add(fHVertexZ2);
383 fHCent = new TH1F("hCentBeforeCut","",102,-1,101);
384 fHCent->SetXTitle(fCentVar.Data());
385 fOutput->Add(fHCent);
386 fHCentQual = new TH1F("hCentAfterCut","",102,-1,101);
387 fHCentQual->SetXTitle(fCentVar.Data());
388 fOutput->Add(fHCentQual);
389 fHTclsBeforeCuts = new TH1F("hTclsBeforeCuts","",fTrClassNamesArr->GetEntries(),0.5,0.5+fTrClassNamesArr->GetEntries());
390 fHTclsAfterCuts = new TH1F("hTclsAfterCuts","",fTrClassNamesArr->GetEntries(),0.5,0.5+fTrClassNamesArr->GetEntries());
391 for (Int_t i = 0; i<fTrClassNamesArr->GetEntries(); ++i) {
392 const char *name = fTrClassNamesArr->At(i)->GetName();
393 fHTclsBeforeCuts->GetXaxis()->SetBinLabel(1+i,name);
394 fHTclsAfterCuts->GetXaxis()->SetBinLabel(1+i,name);
396 fOutput->Add(fHTclsBeforeCuts);
397 fOutput->Add(fHTclsAfterCuts);
399 // histograms for cells
400 Int_t nsm = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
401 fHColuRow = new TH2*[nsm];
402 fHColuRowE = new TH2*[nsm];
403 fHCellMult = new TH1*[nsm];
404 for (Int_t i = 0; i<nsm; ++i) {
405 fHColuRow[i] = new TH2F(Form("hColRow_Mod%d",i),"",48,0,48,24,0.,24);
406 fHColuRow[i]->SetTitle(Form("Module %d: Occupancy", i));
407 fHColuRow[i]->SetXTitle("col (i#eta)");
408 fHColuRow[i]->SetYTitle("row (i#phi)");
409 fHColuRowE[i] = new TH2F(Form("hColRowE_Mod%d", i),"",48,0,48,24,0,24);
410 fHColuRowE[i]->SetTitle(Form("Module %d: Cell energy",i));
411 fHColuRowE[i]->SetXTitle("col (i#eta)");
412 fHColuRowE[i]->SetYTitle("row (i#phi)");
413 fHCellMult[i] = new TH1F(Form("hCellMult_Mod%d",i),"",1000,0,1000);
414 fHCellMult[i]->SetTitle(Form("Module %d: Cell multiplicity",i));
415 fHCellMult[i]->SetXTitle("# of cells");
416 fOutput->Add(fHColuRow[i]);
417 fOutput->Add(fHColuRowE[i]);
418 fOutput->Add(fHCellMult[i]);
420 fHCellE = new TH1F("hCellE","",250,0.,25.);
421 fHCellE->SetXTitle("E_{cell} [GeV]");
422 fOutput->Add(fHCellE);
423 fHCellH = new TH1F ("hCellHighestE","",250,0.,25.);
424 fHCellH->SetXTitle("E^{max}_{cell} [GeV]");
425 fOutput->Add(fHCellH);
426 fHCellM = new TH1F ("hCellMeanEperHitCell","",250,0.,2.5);
427 fHCellM->SetXTitle("#LT E_{cell}#GT [GeV]");
428 fOutput->Add(fHCellM);
429 fHCellM2 = new TH1F ("hCellMeanEperAllCells","",250,0.,1);
430 fHCellM2->SetXTitle("1/N_{cells} #Sigma E_{cell} [GeV]");
431 fOutput->Add(fHCellM2);
433 fHCellFreqNoCut = new TH1*[nsm];
434 fHCellFreqCut100M = new TH1*[nsm];
435 fHCellFreqCut300M = new TH1*[nsm];
436 fHCellFreqE = new TH1*[nsm];
437 for (Int_t i = 0; i<nsm; ++i){
438 Double_t lbin = i*24*48-0.5;
439 Double_t hbin = lbin+24*48;
440 fHCellFreqNoCut[i] = new TH1F(Form("hCellFreqNoCut_SM%d",i),
441 Form("Frequency SM%d (no cut);id;#",i), 1152, lbin, hbin);
442 fHCellFreqCut100M[i] = new TH1F(Form("hCellFreqCut100M_SM%d",i),
443 Form("Frequency SM%d (>0.1GeV);id;#",i), 1152, lbin, hbin);
444 fHCellFreqCut300M[i] = new TH1F(Form("hCellFreqCut300M_SM%d",i),
445 Form("Frequency SM%d (>0.3GeV);id;#",i), 1152, lbin, hbin);
446 fHCellFreqE[i] = new TH1F(Form("hCellFreqE_SM%d",i),
447 Form("Frequency SM%d (E weighted);id;#",i), 1152, lbin, hbin);
448 fOutput->Add(fHCellFreqNoCut[i]);
449 fOutput->Add(fHCellFreqCut100M[i]);
450 fOutput->Add(fHCellFreqCut300M[i]);
451 fOutput->Add(fHCellFreqE[i]);
453 if (!fMarkCells.IsNull()) {
454 fHCellCheckE = new TH1*[24*48*nsm];
455 memset(fHCellCheckE,0,24*48*nsm*sizeof(TH1*));
456 TObjArray *cells = fMarkCells.Tokenize(" ");
457 Int_t n = cells->GetEntries();
458 Int_t *tcs = new Int_t[n];
459 for (Int_t i=0;i<n;++i) {
460 TString name(cells->At(i)->GetName());
463 for (Int_t i = 0; i<n; ++i) {
466 fHCellCheckE[i] = new TH1F(Form("hCellE_id%d",c), Form("Cell %d;E [GeV/c];#",c), 1000, 0, 10);
467 fOutput->Add(fHCellCheckE[i]);
474 // histograms for clusters
476 fHClustEccentricity = new TH1F("hClustEccentricity","",100,-0.1,1.1);
477 fHClustEccentricity->SetXTitle("#epsilon_{C}");
478 fOutput->Add(fHClustEccentricity);
479 fHClustEtaPhi = new TH2F("hClustEtaPhi","",500,-0.8,0.8,100*nsm,phimin,phimax);
480 fHClustEtaPhi->SetXTitle("#eta");
481 fHClustEtaPhi->SetYTitle("#varphi");
482 fOutput->Add(fHClustEtaPhi);
483 fHClustEnergyPt = new TH2F("hClustEnergyPt","",250,0,50,250,0,50);
484 fHClustEnergyPt->SetXTitle("E [GeV]");
485 fHClustEnergyPt->SetYTitle("p_{T} [GeV/c]");
486 fOutput->Add(fHClustEnergyPt);
487 fHClustEnergySigma = new TH2F("hClustEnergySigma","",100,0,100,500,0,50);
488 fHClustEnergySigma->SetXTitle("E_{C} * #sigma_{max} [GeV*cm]");
489 fHClustEnergySigma->SetYTitle("E_{C} [GeV]");
490 fOutput->Add(fHClustEnergySigma);
491 fHClustSigmaSigma = new TH2F("hClustSigmaSigma","",500,0,50,500,0,50);
492 fHClustSigmaSigma->SetXTitle("#lambda_{0} [cm]");
493 fHClustSigmaSigma->SetYTitle("#sigma_{max} [cm]");
494 fOutput->Add(fHClustSigmaSigma);
495 fHClustNCellEnergyRatio = new TH2F("hClustNCellEnergyRatio","",27,-0.5,26.5,101,-0.05,1.05);
496 fHClustNCellEnergyRatio->SetXTitle("N_{cells}");
497 fHClustNCellEnergyRatio->SetYTitle("E^{max}_{cell}/E_{clus}");
498 fOutput->Add(fHClustNCellEnergyRatio);
499 fHClustEnergyNCell = new TH2F("hClustEnergyNCell","",200,0,100,50,0,50);
500 fHClustEnergyNCell->SetXTitle("E_{clus}");
501 fHClustEnergyNCell->SetYTitle("N_{cells}");
502 fOutput->Add(fHClustEnergyNCell);
505 // histograms for primary tracks
506 fHPrimTrackPt = new TH1F("hPrimTrackPt",";p_{T} [GeV/c]",500,0,50);
507 fOutput->Add(fHPrimTrackPt);
508 fHPrimTrackEta = new TH1F("hPrimTrackEta",";#eta",40,-2,2);
509 fOutput->Add(fHPrimTrackEta);
510 fHPrimTrackPhi = new TH1F("hPrimTrackPhi",";#varPhi [rad]",63,0,6.3);
511 fOutput->Add(fHPrimTrackPhi);
512 // histograms for track matching
513 fHMatchDr = new TH1F("hMatchDrDist",";dR [cm]",500,0,200);
514 fOutput->Add(fHMatchDr);
515 fHMatchDz = new TH1F("hMatchDzDist",";dZ [cm]",500,-100,100);
516 fOutput->Add(fHMatchDz);
517 fHMatchEp = new TH1F("hMatchEpDist",";E/p",100,0,10);
518 fOutput->Add(fHMatchEp);
520 // histograms for pion candidates
522 fHPionEtaPhi = new TH2F("hPionEtaPhi","",100,-0.8,0.8,100*nsm,phimin,phimax);
523 fHPionEtaPhi->SetXTitle("#eta_{#gamma#gamma}");
524 fHPionEtaPhi->SetYTitle("#varphi_{#gamma#gamma}");
525 fOutput->Add(fHPionEtaPhi);
526 fHPionMggPt = new TH2F("hPionMggPt","",1000,0,2,100,0,20.0);
527 fHPionMggPt->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
528 fHPionMggPt->SetYTitle("p_{T}^{#gamma#gamma} [GeV/c]");
529 fOutput->Add(fHPionMggPt);
530 fHPionMggAsym = new TH2F("hPionMggAsym","",1000,0,2,100,0,1);
531 fHPionMggAsym->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
532 fHPionMggAsym->SetYTitle("Z_{#gamma#gamma} [GeV]");
533 fOutput->Add(fHPionMggAsym);
534 fHPionMggDgg = new TH2F("hPionMggDgg","",1000,0,2,100,0,10);
535 fHPionMggDgg->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
536 fHPionMggDgg->SetYTitle("opening angle [grad]");
537 fOutput->Add(fHPionMggDgg);
538 const Int_t nbins = 20;
539 Double_t xbins[nbins] = {0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,12.5,15,20,25,50};
540 fPtRanges = new TAxis(nbins-1,xbins);
541 for (Int_t i = 0; i<=nbins; ++i) {
542 fHPionInvMasses[i] = new TH1F(Form("hPionInvMass%d",i),"",1000,0,2);
543 fHPionInvMasses[i]->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
545 fHPionInvMasses[i]->SetTitle(Form("0 < p_{T}^{#gamma#gamma} <%.1f",xbins[0]));
547 fHPionInvMasses[i]->SetTitle(Form("p_{T}^{#gamma#gamma} > 50"));
549 fHPionInvMasses[i]->SetTitle(Form("%.1f < p_{T}^{#gamma#gamma} <%.1f",xbins[i-1],xbins[i]));
550 fOutput->Add(fHPionInvMasses[i]);
554 TH1::SetDefaultSumw2(th1);
555 TH2::SetDefaultSumw2(th2);
556 PostData(1, fOutput);
559 //________________________________________________________________________
560 void AliAnalysisTaskEMCALPi0PbPb::UserExec(Option_t *)
562 // Called for each event.
567 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
568 fEsdEv = dynamic_cast<AliESDEvent*>(InputEvent());
569 UInt_t offtrigger = 0;
571 am->LoadBranch("AliESDRun.");
572 am->LoadBranch("AliESDHeader.");
573 UInt_t mask1 = fEsdEv->GetESDRun()->GetDetectorsInDAQ();
574 UInt_t mask2 = fEsdEv->GetESDRun()->GetDetectorsInReco();
575 Bool_t desc1 = (mask1 >> 18) & 0x1;
576 Bool_t desc2 = (mask2 >> 18) & 0x1;
577 if (desc1==0 || desc2==0) { //AliDAQ::OfflineModuleName(18)=="EMCAL"
578 AliError(Form("EMCAL not in DAQ/RECO: %u (%u)/%u (%u)",
579 mask1, fEsdEv->GetESDRun()->GetDetectorsInReco(),
580 mask2, fEsdEv->GetESDRun()->GetDetectorsInDAQ()));
583 offtrigger = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
585 fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
587 AliFatal("Neither ESD nor AOD event found");
590 am->LoadBranch("header");
591 offtrigger = fAodEv->GetHeader()->GetOfflineTrigger();
593 if (!fMcMode && (offtrigger & AliVEvent::kFastOnly)) {
594 AliWarning(Form("EMCAL not in fast only partition"));
597 if (fDoTrMatGeom && !AliGeomManager::GetGeometry()) { // get geometry
598 AliWarning("Accessing geometry from OCDB, this is not very efficient!");
599 AliCDBManager *cdb = AliCDBManager::Instance();
600 if (!cdb->IsDefaultStorageSet())
601 cdb->SetDefaultStorage("raw://");
602 Int_t runno = InputEvent()->GetRunNumber();
603 if (runno != cdb->GetRun())
605 AliGeomManager::LoadGeometry();
608 if (!AliGeomManager::GetGeometry()&&!fIsGeoMatsSet) { // set misalignment matrices (stored in first event)
609 Int_t nsm = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
610 for (Int_t i=0; i<nsm; ++i) {
611 const TGeoHMatrix *geom = 0;
613 geom = fEsdEv->GetESDRun()->GetEMCALMatrix(i);
615 geom = fAodEv->GetHeader()->GetEMCALMatrix(i);
619 fGeom->SetMisalMatrix(geom,i);
621 fIsGeoMatsSet = kTRUE;
624 if (!TGeoGlobalMagField::Instance()->GetField()) { // construct field map
626 const AliESDRun *erun = fEsdEv->GetESDRun();
627 AliMagF *field = AliMagF::CreateFieldMap(erun->GetCurrentL3(),
628 erun->GetCurrentDip(),
631 erun->GetBeamEnergy(),
632 erun->GetBeamType());
633 TGeoGlobalMagField::Instance()->SetField(field);
635 Double_t pol = -1; //polarity
636 Double_t be = -1; //beam energy
637 AliMagF::BeamType_t btype = AliMagF::kBeamTypepp;
638 Int_t runno = fAodEv->GetRunNumber();
639 if (runno>=136851 && runno<138275) {
642 btype = AliMagF::kBeamTypeAA;
643 } else if (runno>=138275 && runno<=139517) {
646 btype = AliMagF::kBeamTypeAA;
648 AliError(Form("Do not know the bfield parameters for run %d! Using defaults!!!", runno));
650 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", pol, pol, AliMagF::k5kG, btype, be));
658 AliESDHeader *h = dynamic_cast<AliESDHeader*>(InputEvent()->GetHeader());
660 trgclasses = fEsdEv->GetFiredTriggerClasses();
662 AliAODHeader *h2 = dynamic_cast<AliAODHeader*>(InputEvent()->GetHeader());
664 trgclasses = h2->GetFiredTriggerClasses();
666 for (Int_t i = 0; i<fTrClassNamesArr->GetEntries(); ++i) {
667 const char *name = fTrClassNamesArr->At(i)->GetName();
668 if (trgclasses.Contains(name))
669 fHTclsBeforeCuts->Fill(1+i);
672 if (fDoPSel && offtrigger==0)
677 const AliCentrality *centP = InputEvent()->GetCentrality();
678 Double_t cent = centP->GetCentralityPercentileUnchecked(fCentVar);
680 if (cent<fCentFrom||cent>fCentTo)
686 if (centP->GetQuality()>0)
690 fHCentQual->Fill(cent);
694 am->LoadBranch("PrimaryVertex.");
695 am->LoadBranch("SPDVertex.");
696 am->LoadBranch("TPCVertex.");
698 fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
699 am->LoadBranch("vertices");
703 const AliVVertex *vertex = InputEvent()->GetPrimaryVertex();
707 fHVertexZ->Fill(vertex->GetZ());
709 if(vertex->GetZ()<fVtxZMin||vertex->GetZ()>fVtxZMax)
713 fHVertexZ2->Fill(vertex->GetZ());
715 // count number of accepted events
718 for (Int_t i = 0; i<fTrClassNamesArr->GetEntries(); ++i) {
719 const char *name = fTrClassNamesArr->At(i)->GetName();
720 if (trgclasses.Contains(name))
721 fHTclsAfterCuts->Fill(1+i);
724 fRecPoints = 0; // will be set if fClusName is given and AliAnalysisTaskEMCALClusterizeFast is used
725 fDigits = 0; // will be set if fClusName is given and AliAnalysisTaskEMCALClusterizeFast is used
726 fEsdClusters = 0; // will be set if ESD input used and if fRecPoints are not set or if clusters are attached
727 fEsdCells = 0; // will be set if ESD input used
728 fAodClusters = 0; // will be set if AOD input used and if fRecPoints are not set or if clusters are attached
729 // or if fClusName is given and AliAnalysisTaskEMCALClusterizeFast in AOD output mode
730 fAodCells = 0; // will be set if AOD input used
732 // deal with special output from AliAnalysisTaskEMCALClusterizeFast first
733 Bool_t clusattached = 0;
734 Bool_t recalibrated = 0;
735 if (1 && !fClusName.IsNull()) {
736 AliAnalysisTaskEMCALClusterizeFast *cltask = 0;
737 TObjArray *ts = am->GetTasks();
738 cltask = dynamic_cast<AliAnalysisTaskEMCALClusterizeFast*>(ts->FindObject(fClusName));
739 if (cltask && cltask->GetClusters()) {
740 fRecPoints = cltask->GetClusters();
741 fDigits = cltask->GetDigits();
742 clusattached = cltask->GetAttachClusters();
743 if (cltask->GetCalibData()!=0)
744 recalibrated = kTRUE;
747 if (1 && !fClusName.IsNull()) {
750 l = AODEvent()->GetList();
752 l = fAodEv->GetList();
754 fAodClusters = dynamic_cast<TClonesArray*>(l->FindObject(fClusName));
758 if (fEsdEv) { // ESD input mode
759 if (1 && (!fRecPoints||clusattached)) {
761 am->LoadBranch("CaloClusters");
762 TList *l = fEsdEv->GetList();
764 fEsdClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
769 am->LoadBranch("EMCALCells.");
770 fEsdCells = fEsdEv->GetEMCALCells();
772 } else if (fAodEv) { // AOD input mode
773 if (1 && (!fAodClusters || clusattached)) {
775 am->LoadBranch("caloClusters");
776 TList *l = fAodEv->GetList();
778 fAodClusters = dynamic_cast<TClonesArray*>(l->FindObject("caloClusters"));
783 am->LoadBranch("emcalCells");
784 fAodCells = fAodEv->GetEMCALCells();
787 AliFatal("Impossible to not have either pointer to ESD or AOD event");
791 AliDebug(2,Form("fRecPoints set: %p", fRecPoints));
792 AliDebug(2,Form("fDigits set: %p", fDigits));
793 AliDebug(2,Form("fEsdClusters set: %p", fEsdClusters));
794 AliDebug(2,Form("fEsdCells set: %p", fEsdCells));
795 AliDebug(2,Form("fAodClusters set: %p", fAodClusters));
796 AliDebug(2,Form("fAodCells set: %p", fAodCells));
800 ClusterAfterburner();
819 fSelPrimTracks->Clear();
828 PostData(1, fOutput);
831 //________________________________________________________________________
832 void AliAnalysisTaskEMCALPi0PbPb::Terminate(Option_t *)
834 // Terminate called at the end of analysis.
837 TFile *f = OpenFile(1);
838 TDirectory::TContext context(f);
843 AliInfo(Form("%s: Accepted %lld events ", GetName(), fNEvs));
846 //________________________________________________________________________
847 void AliAnalysisTaskEMCALPi0PbPb::CalcCaloTriggers()
849 // Calculate triggers
852 return; // information not available in AOD
859 AliVCaloCells *cells = fEsdCells;
865 Int_t ncells = cells->GetNumberOfCells();
869 if (ncells>fNAmpInTrigger) {
870 delete [] fAmpInTrigger;
871 fAmpInTrigger = new Float_t[ncells];
872 fNAmpInTrigger = ncells;
874 for (Int_t i=0;i<ncells;++i)
875 fAmpInTrigger[i] = 0;
877 std::map<Short_t,Short_t> map;
878 for (Short_t pos=0;pos<ncells;++pos) {
879 Short_t id = cells->GetCellNumber(pos);
883 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
884 am->LoadBranch("EMCALTrigger.");
886 AliESDCaloTrigger *triggers = fEsdEv->GetCaloTrigger("EMCAL");
889 if (triggers->GetEntries()<=0)
894 while (triggers->Next()) {
895 Int_t gCol=0, gRow=0, ntimes=0;
896 triggers->GetPosition(gCol,gRow);
897 triggers->GetNL0Times(ntimes);
901 triggers->GetAmplitude(amp);
903 fGeom->GetAbsFastORIndexFromPositionInEMCAL(gCol,gRow,find);
906 Int_t cidx[4] = {-1};
907 Bool_t ret = fGeom->GetCellIndexFromFastORIndex(find, cidx);
911 triggers->GetL0Times(trgtimes);
912 Int_t mintime = trgtimes[0];
913 Int_t maxtime = trgtimes[0];
914 Bool_t trigInTimeWindow = 0;
915 for (Int_t i=0;i<ntimes;++i) {
916 if (trgtimes[i]<mintime)
917 mintime = trgtimes[i];
918 if (maxtime<trgtimes[i])
919 maxtime = trgtimes[i];
920 if ((fMinL0Time<=trgtimes[i]) && (fMaxL0Time>=trgtimes[i]))
921 trigInTimeWindow = 1;
924 Double_t tenergy = 0;
927 for (Int_t i=0;i<3;++i) {
929 std::map<Short_t,Short_t>::iterator it = map.find(cidx[i]);
934 if (trigInTimeWindow)
935 fAmpInTrigger[pos] = amp;
936 Float_t eta=-1, phi=-1;
937 fGeom->EtaPhiFromIndex(cidx[i],eta,phi);
938 Double_t en= cells->GetAmplitude(pos);
950 AliStaTrigger *trignew = static_cast<AliStaTrigger*>(fTriggers->New(ntrigs++));
951 trignew->fE = tenergy;
952 trignew->fEta = teta;
953 trignew->fPhi = tphi;
955 trignew->fMinTime = mintime;
956 trignew->fMaxTime = maxtime;
960 //________________________________________________________________________
961 void AliAnalysisTaskEMCALPi0PbPb::CalcClusterProps()
963 // Calculate cluster properties
970 AliVCaloCells *cells = fEsdCells;
976 TObjArray *clusters = fEsdClusters;
978 clusters = fAodClusters;
982 Int_t ncells = cells->GetNumberOfCells();
983 Int_t nclus = clusters->GetEntries();
984 Int_t ntrks = fSelTracks->GetEntries();
985 Int_t btracks[6][ntrks];
986 memset(btracks,0,sizeof(Int_t)*6*ntrks);
988 std::map<Short_t,Short_t> map;
989 for (Short_t pos=0;pos<ncells;++pos) {
990 Short_t id = cells->GetCellNumber(pos);
994 TObjArray filtMcParts;
996 Int_t nmc = fMcParts->GetEntries();
997 for (Int_t i=0; i<nmc; ++i) {
998 AliStaPart *pa = static_cast<AliStaPart*>(fMcParts->At(i));
1000 filtMcParts.Add(pa);
1004 for(Int_t i=0, ncl=0; i<nclus; ++i) {
1005 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
1009 if (!clus->IsEMCAL())
1011 if (clus->E()<fMinE)
1014 Float_t clsPos[3] = {0};
1015 clus->GetPosition(clsPos);
1016 TVector3 clsVec(clsPos);
1017 Double_t vertex[3] = {0};
1018 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1019 TLorentzVector clusterVec;
1020 clus->GetMomentum(clusterVec,vertex);
1021 Double_t clsEta = clusterVec.Eta();
1023 AliStaCluster *cl = static_cast<AliStaCluster*>(fClusters->New(ncl++));
1025 cl->fR = clsVec.Perp();
1026 cl->fEta = clsVec.Eta();
1027 cl->fPhi = clsVec.Phi();
1028 cl->fN = clus->GetNCells();
1029 cl->fN1 = GetNCells(clus,0.100);
1030 cl->fN3 = GetNCells(clus,0.300);
1032 Double_t emax = GetMaxCellEnergy(clus, id);
1035 cl->fTmax = cells->GetCellTime(id);
1036 if (clus->GetDistanceToBadChannel()<10000)
1037 cl->fDbc = clus->GetDistanceToBadChannel();
1038 if (!TMath::IsNaN(clus->GetDispersion()))
1039 cl->fDisp = clus->GetDispersion();
1040 if (!TMath::IsNaN(clus->GetM20()))
1041 cl->fM20 = clus->GetM20();
1042 if (!TMath::IsNaN(clus->GetM02()))
1043 cl->fM02 = clus->GetM02();
1044 Double_t maxAxis = 0, minAxis = 0;
1045 GetSigma(clus,maxAxis,minAxis);
1046 clus->SetTOF(maxAxis); // store sigma in TOF
1048 Double_t clusterEcc = 0;
1050 clusterEcc = TMath::Sqrt(1.0 - minAxis*minAxis/(maxAxis*maxAxis));
1051 clus->SetChi2(clusterEcc); // store ecc in chi2
1052 cl->fEcc = clusterEcc;
1053 cl->fTrIso = GetTrackIsolation(clusterVec.Eta(),clusterVec.Phi(),fIsoDist);
1054 cl->fTrIso1 = GetTrackIsolation(clusterVec.Eta(),clusterVec.Phi(),fIsoDist, 1);
1055 cl->fTrIso2 = GetTrackIsolation(clusterVec.Eta(),clusterVec.Phi(),fIsoDist, 2);
1056 cl->fCeCore = GetCellIsolation(clsVec.Eta(),clsVec.Phi(),0.05);
1057 cl->fCeIso = GetCellIsolation(clsVec.Eta(),clsVec.Phi(),fIsoDist);
1059 if (fAmpInTrigger) { // fill trigger info if present
1060 Double_t trigpen = 0;
1061 Double_t trignen = 0;
1062 for(Int_t j=0; j<cl->fN; ++j) {
1063 Short_t cid = TMath::Abs(clus->GetCellAbsId(j));
1065 std::map<Short_t,Short_t>::iterator it = map.find(cid);
1070 if (fAmpInTrigger[pos]>0)
1071 trigpen += cells->GetAmplitude(pos);
1072 else if (fAmpInTrigger[pos]<0)
1073 trignen += cells->GetAmplitude(pos);
1077 cl->fTrigE = trigpen;
1081 cl->fTrigMaskE = trignen;
1084 cl->fIsShared = IsShared(clus);
1087 Double_t mind2 = 1e10;
1088 for(Int_t j = 0; j<ntrks; ++j) {
1089 AliVTrack *track = static_cast<AliVTrack*>(fSelTracks->At(j));
1093 if (TMath::Abs(clsEta-track->Eta())>0.5)
1096 TVector3 vec(clsPos);
1097 Int_t index = (Int_t)(vec.Phi()*TMath::RadToDeg()/20);
1098 if (btracks[index-4][j]) {
1102 Float_t tmpR=-1, tmpZ=-1;
1103 if (!fDoTrMatGeom) {
1104 AliExternalTrackParam *tParam = 0;
1106 AliESDtrack *esdTrack = static_cast<AliESDtrack*>(track);
1107 tParam = new AliExternalTrackParam(*esdTrack->GetTPCInnerParam());
1109 tParam = new AliExternalTrackParam(track);
1111 Double_t bfield[3] = {0};
1112 track->GetBxByBz(bfield);
1113 Double_t alpha = (index+0.5)*20*TMath::DegToRad();
1114 vec.RotateZ(-alpha); //Rotate the cluster to the local extrapolation coordinate system
1115 tParam->Rotate(alpha); //Rotate the track to the same local extrapolation system
1116 Bool_t ret = tParam->PropagateToBxByBz(vec.X(), bfield);
1118 btracks[index-4][j]=1;
1122 Double_t trkPos[3] = {0};
1123 tParam->GetXYZ(trkPos); //Get the extrapolated global position
1124 tmpR = TMath::Sqrt( TMath::Power(clsPos[0]-trkPos[0],2) +
1125 TMath::Power(clsPos[1]-trkPos[1],2) +
1126 TMath::Power(clsPos[2]-trkPos[2],2) );
1127 tmpZ = clsPos[2]-trkPos[2];
1130 if (TMath::Abs(clsEta-track->Eta())>fIsoDist)
1132 AliExternalTrackParam tParam(track);
1133 if (!fReco->ExtrapolateTrackToCluster(&tParam, clus, tmpR, tmpZ))
1141 cl->fTrDr = TMath::Sqrt(tmpR*tmpR-tmpZ*tmpZ);
1142 cl->fTrEp = clus->E()/track->P();
1147 if (cl->fIsTrackM) {
1148 fHMatchDr->Fill(cl->fTrDr);
1149 fHMatchDz->Fill(cl->fTrDz);
1150 fHMatchEp->Fill(cl->fTrEp);
1155 Int_t nmc = filtMcParts.GetEntries();
1156 Double_t diffR2 = 1e9;
1157 AliStaPart *msta = 0;
1158 for (Int_t j=0; j<nmc; ++j) {
1159 AliStaPart *pa = static_cast<AliStaPart*>(filtMcParts.At(j));
1160 Double_t t1=clsVec.Eta()-pa->fVEta;
1161 Double_t t2=TVector2::Phi_mpi_pi(clsVec.Phi()-pa->fVPhi);
1162 Double_t tmp = t1*t1+t2*t2;
1168 if (diffR2<10 && msta!=0) {
1169 cl->fMcLabel = msta->fLab;
1174 if (fDigits && fEmbedMode) {
1175 for(Int_t j=0; j<cl->fN; ++j) {
1176 Short_t cid = TMath::Abs(clus->GetCellAbsId(j));
1178 std::map<Short_t,Short_t>::iterator it = map.find(cid);
1183 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigits->At(pos));
1186 if (digit->GetId() != cid) {
1187 AliError(Form("Ids should be equal: %d %d", cid, digit->GetId()));
1190 if (digit->GetType()<-1) {
1191 cl->fEmbE += digit->GetChi2();
1198 //________________________________________________________________________
1199 void AliAnalysisTaskEMCALPi0PbPb::CalcPrimTracks()
1201 // Calculate track properties for primary tracks.
1203 fSelPrimTracks->Clear();
1205 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
1206 TClonesArray *tracks = 0;
1208 am->LoadBranch("Tracks");
1209 TList *l = fEsdEv->GetList();
1210 tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
1212 am->LoadBranch("tracks");
1213 TList *l = fAodEv->GetList();
1214 tracks = dynamic_cast<TClonesArray*>(l->FindObject("tracks"));
1220 AliEMCALEMCGeometry *emc = fGeom->GetEMCGeometry();
1221 Double_t phimin = emc->GetArm1PhiMin()*TMath::DegToRad()-fIsoDist*1.25;
1222 Double_t phimax = emc->GetArm1PhiMax()*TMath::DegToRad()+fIsoDist*1.25;
1225 fSelPrimTracks->SetOwner(kTRUE);
1226 am->LoadBranch("PrimaryVertex.");
1227 const AliESDVertex *vtx = fEsdEv->GetPrimaryVertexSPD();
1228 am->LoadBranch("SPDVertex.");
1229 const AliESDVertex *vtxSPD = fEsdEv->GetPrimaryVertexSPD();
1230 am->LoadBranch("Tracks");
1231 const Int_t Ntracks = tracks->GetEntries();
1232 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
1233 AliESDtrack *track = static_cast<AliESDtrack*>(tracks->At(iTracks));
1235 AliWarning(Form("Could not receive track %d\n", iTracks));
1238 if (fTrCuts && !fTrCuts->IsSelected(track))
1240 Double_t eta = track->Eta();
1243 if (track->Phi()<phimin||track->Phi()>phimax)
1246 AliESDtrack copyt(*track);
1248 copyt.GetBxByBz(bfield);
1249 AliExternalTrackParam tParam;
1250 Bool_t relate = copyt.RelateToVertexBxByBz(vtxSPD,bfield,kVeryBig,&tParam);
1253 copyt.Set(tParam.GetX(),tParam.GetAlpha(),tParam.GetParameter(),tParam.GetCovariance());
1255 Double_t p[3] = { 0. };
1257 Double_t pos[3] = { 0. };
1259 Double_t covTr[21] = { 0. };
1260 copyt.GetCovarianceXYZPxPyPz(covTr);
1261 Double_t pid[10] = { 0. };
1262 copyt.GetESDpid(pid);
1263 AliAODTrack *aTrack = new AliAODTrack(copyt.GetID(),
1270 (Short_t)copyt.GetSign(),
1271 copyt.GetITSClusterMap(),
1273 0,/*fPrimaryVertex,*/
1274 kTRUE, // check if this is right
1275 vtx->UsesTrack(copyt.GetID()));
1276 aTrack->SetTPCClusterMap(copyt.GetTPCClusterMap());
1277 aTrack->SetTPCSharedMap (copyt.GetTPCSharedMap());
1278 Float_t ndf = copyt.GetTPCNcls() + 1 - 5 ;
1280 aTrack->SetChi2perNDF(copyt.GetTPCchi2()/ndf);
1282 aTrack->SetChi2perNDF(-1);
1283 aTrack->SetFlags(copyt.GetStatus());
1284 aTrack->SetTPCPointsF(copyt.GetTPCNclsF());
1285 fSelPrimTracks->Add(aTrack);
1288 Int_t ntracks = tracks->GetEntries();
1289 for (Int_t i=0; i<ntracks; ++i) {
1290 AliAODTrack *track = static_cast<AliAODTrack*>(tracks->At(i));
1293 Double_t eta = track->Eta();
1296 if (track->Phi()<phimin||track->Phi()>phimax)
1298 if(track->GetTPCNcls()<fMinNClusPerTr)
1300 //todo: Learn how to set/filter AODs for prim/sec tracks
1301 fSelPrimTracks->Add(track);
1306 //________________________________________________________________________
1307 void AliAnalysisTaskEMCALPi0PbPb::CalcTracks()
1309 // Calculate track properties (including secondaries).
1311 fSelTracks->Clear();
1313 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
1314 TClonesArray *tracks = 0;
1316 am->LoadBranch("Tracks");
1317 TList *l = fEsdEv->GetList();
1318 tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
1320 am->LoadBranch("tracks");
1321 TList *l = fAodEv->GetList();
1322 tracks = dynamic_cast<TClonesArray*>(l->FindObject("tracks"));
1329 const Int_t Ntracks = tracks->GetEntries();
1330 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
1331 AliESDtrack *track = static_cast<AliESDtrack*>(tracks->At(iTracks));
1333 AliWarning(Form("Could not receive track %d\n", iTracks));
1336 if (fTrCuts && !fTrCuts->IsSelected(track))
1338 Double_t eta = track->Eta();
1341 fSelTracks->Add(track);
1344 Int_t ntracks = tracks->GetEntries();
1345 for (Int_t i=0; i<ntracks; ++i) {
1346 AliAODTrack *track = static_cast<AliAODTrack*>(tracks->At(i));
1349 Double_t eta = track->Eta();
1352 if(track->GetTPCNcls()<fMinNClusPerTr)
1355 if (0 && (track->Pt()>=0.6) && (track->PxAtDCA()==-999)) { // compute position on EMCAL
1356 AliExternalTrackParam tParam(track);
1357 if (AliTrackerBase::PropagateTrackToBxByBz(&tParam, 438, 0.139, 1, kTRUE)) {
1359 tParam.GetXYZ(trkPos);
1360 track->SetPxPyPzAtDCA(trkPos[0],trkPos[1],trkPos[2]);
1363 fSelTracks->Add(track);
1368 //________________________________________________________________________
1369 void AliAnalysisTaskEMCALPi0PbPb::ClusterAfterburner()
1371 // Run custer reconstruction afterburner.
1373 AliVCaloCells *cells = fEsdCells;
1380 Int_t ncells = cells->GetNumberOfCells();
1384 Double_t cellMeanE = 0, cellSigE = 0;
1385 for (Int_t i = 0; i<ncells; ++i) {
1386 Double_t cellE = cells->GetAmplitude(i);
1388 cellSigE += cellE*cellE;
1390 cellMeanE /= ncells;
1392 cellSigE -= cellMeanE*cellMeanE;
1395 cellSigE = TMath::Sqrt(cellSigE / ncells);
1397 Double_t subE = cellMeanE - 7*cellSigE;
1401 for (Int_t i = 0; i<ncells; ++i) {
1403 Double_t amp=0,time=0;
1404 if (!cells->GetCell(i, id, amp, time))
1409 cells->SetCell(i, id, amp, time);
1412 TObjArray *clusters = fEsdClusters;
1414 clusters = fAodClusters;
1418 Int_t nclus = clusters->GetEntries();
1419 for (Int_t i = 0; i<nclus; ++i) {
1420 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
1421 if (!clus->IsEMCAL())
1423 Int_t nc = clus->GetNCells();
1425 UShort_t ids[100] = {0};
1426 Double_t fra[100] = {0};
1427 for (Int_t j = 0; j<nc; ++j) {
1428 Short_t id = TMath::Abs(clus->GetCellAbsId(j));
1429 Double_t cen = cells->GetCellAmplitude(id);
1437 clusters->RemoveAt(i);
1441 for (Int_t j = 0; j<nc; ++j) {
1442 Short_t id = ids[j];
1443 Double_t cen = cells->GetCellAmplitude(id);
1447 AliAODCaloCluster *aodclus = dynamic_cast<AliAODCaloCluster*>(clus);
1450 aodclus->SetNCells(nc);
1451 aodclus->SetCellsAmplitudeFraction(fra);
1452 aodclus->SetCellsAbsId(ids);
1455 clusters->Compress();
1458 //________________________________________________________________________
1459 void AliAnalysisTaskEMCALPi0PbPb::FillCellHists()
1461 // Fill histograms related to cell properties.
1463 AliVCaloCells *cells = fEsdCells;
1470 Int_t cellModCount[12] = {0};
1471 Double_t cellMaxE = 0;
1472 Double_t cellMeanE = 0;
1473 Int_t ncells = cells->GetNumberOfCells();
1477 Int_t nsm = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
1479 for (Int_t i = 0; i<ncells; ++i) {
1480 Int_t absID = TMath::Abs(cells->GetCellNumber(i));
1481 Double_t cellE = cells->GetAmplitude(i);
1482 fHCellE->Fill(cellE);
1487 Int_t iSM=-1, iTower=-1, nIphi=-1, nIeta=-1;
1488 Bool_t ret = fGeom->GetCellIndex(absID, iSM, iTower, nIphi, nIeta);
1490 AliError(Form("Could not get cell index for %d", absID));
1493 ++cellModCount[iSM];
1494 Int_t iPhi=-1, iEta=-1;
1495 fGeom->GetCellPhiEtaIndexInSModule(iSM, iTower, nIphi, nIeta, iPhi, iEta);
1496 fHColuRow[iSM]->Fill(iEta,iPhi,1);
1497 fHColuRowE[iSM]->Fill(iEta,iPhi,cellE);
1498 fHCellFreqNoCut[iSM]->Fill(absID);
1499 if (cellE > 0.1) fHCellFreqCut100M[iSM]->Fill(absID);
1500 if (cellE > 0.3) fHCellFreqCut300M[iSM]->Fill(absID);
1501 if (fHCellCheckE && fHCellCheckE[absID])
1502 fHCellCheckE[absID]->Fill(cellE);
1503 fHCellFreqE[iSM]->Fill(absID, cellE);
1505 fHCellH->Fill(cellMaxE);
1506 cellMeanE /= ncells;
1507 fHCellM->Fill(cellMeanE);
1508 fHCellM2->Fill(cellMeanE*ncells/24/48/nsm);
1509 for (Int_t i=0; i<nsm; ++i)
1510 fHCellMult[i]->Fill(cellModCount[i]);
1513 //________________________________________________________________________
1514 void AliAnalysisTaskEMCALPi0PbPb::FillClusHists()
1516 // Fill histograms related to cluster properties.
1518 TObjArray *clusters = fEsdClusters;
1520 clusters = fAodClusters;
1524 Double_t vertex[3] = {0};
1525 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1527 Int_t nclus = clusters->GetEntries();
1528 for(Int_t i = 0; i<nclus; ++i) {
1529 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
1532 if (!clus->IsEMCAL())
1534 TLorentzVector clusterVec;
1535 clus->GetMomentum(clusterVec,vertex);
1536 Double_t maxAxis = clus->GetTOF(); //sigma
1537 Double_t clusterEcc = clus->Chi2(); //eccentricity
1538 fHClustEccentricity->Fill(clusterEcc);
1539 fHClustEtaPhi->Fill(clusterVec.Eta(),clusterVec.Phi());
1540 fHClustEnergyPt->Fill(clusterVec.E(),clusterVec.Pt());
1541 fHClustEnergySigma->Fill(clus->E()*maxAxis,clus->E());
1542 fHClustSigmaSigma->Fill(max(clus->GetM02(),clus->GetM20()),clus->E()*maxAxis);
1543 fHClustNCellEnergyRatio->Fill(clus->GetNCells(),GetMaxCellEnergy(clus)/clus->E());
1545 fHClustEnergyNCell->Fill(clus->E(),clus->GetNCells());
1549 //________________________________________________________________________
1550 void AliAnalysisTaskEMCALPi0PbPb::CalcMcInfo()
1552 // Get Mc truth particle information.
1559 AliEMCALEMCGeometry *emc = fGeom->GetEMCGeometry();
1560 Double_t etamin = -0.7;
1561 Double_t etamax = +0.7;
1562 Double_t phimin = emc->GetArm1PhiMin()*TMath::DegToRad();
1563 Double_t phimax = emc->GetArm1PhiMax()*TMath::DegToRad();
1566 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
1567 am->LoadBranch(AliAODMCParticle::StdBranchName());
1568 TClonesArray *tca = dynamic_cast<TClonesArray*>(fAodEv->FindListObject(AliAODMCParticle::StdBranchName()));
1572 Int_t nents = tca->GetEntries();
1573 for(int it=0; it<nents; ++it) {
1574 AliAODMCParticle *part = static_cast<AliAODMCParticle*>(tca->At(it));
1577 // pion or eta meson or direct photon
1578 if(part->GetPdgCode() == 111) {
1579 } else if(part->GetPdgCode() == 221) {
1580 } else if(part->GetPdgCode() == 22 ) {
1585 Double_t dR = TMath::Sqrt((part->Xv()*part->Xv())+(part->Yv()*part->Yv()));
1590 Double_t pt = part->Pt() ;
1593 Double_t eta = part->Eta();
1594 if (eta<etamin||eta>etamax)
1596 Double_t phi = part->Phi();
1597 if (phi<phimin||phi>phimax)
1600 ProcessDaughters(part, it, tca);
1605 AliMCEvent *mcEvent = MCEvent();
1609 const AliVVertex *evtVtx = mcEvent->GetPrimaryVertex();
1613 mcEvent->PreReadAll();
1615 Int_t nTracks = mcEvent->GetNumberOfPrimaries();
1616 for (Int_t iTrack = 0; iTrack<nTracks; ++iTrack) {
1617 AliMCParticle *mcP = static_cast<AliMCParticle*>(mcEvent->GetTrack(iTrack));
1621 // pion or eta meson or direct photon
1622 if(mcP->PdgCode() == 111) {
1623 } else if(mcP->PdgCode() == 221) {
1624 } else if(mcP->PdgCode() == 22 ) {
1629 Double_t dR = TMath::Sqrt((mcP->Xv()-evtVtx->GetX())*(mcP->Xv()-evtVtx->GetX()) +
1630 (mcP->Yv()-evtVtx->GetY())*(mcP->Yv()-evtVtx->GetY()));
1635 Double_t pt = mcP->Pt() ;
1638 Double_t eta = mcP->Eta();
1639 if (eta<etamin||eta>etamax)
1641 Double_t phi = mcP->Phi();
1642 if (phi<phimin||phi>phimax)
1645 ProcessDaughters(mcP, iTrack, mcEvent);
1649 //________________________________________________________________________
1650 void AliAnalysisTaskEMCALPi0PbPb::FillNtuple()
1657 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
1659 fHeader->fRun = fAodEv->GetRunNumber();
1660 fHeader->fOrbit = fAodEv->GetHeader()->GetOrbitNumber();
1661 fHeader->fPeriod = fAodEv->GetHeader()->GetPeriodNumber();
1662 fHeader->fBx = fAodEv->GetHeader()->GetBunchCrossNumber();
1663 fHeader->fL0 = fAodEv->GetHeader()->GetL0TriggerInputs();
1664 fHeader->fL1 = fAodEv->GetHeader()->GetL1TriggerInputs();
1665 fHeader->fL2 = fAodEv->GetHeader()->GetL2TriggerInputs();
1666 fHeader->fTrClassMask = fAodEv->GetHeader()->GetTriggerMask();
1667 fHeader->fTrCluster = fAodEv->GetHeader()->GetTriggerCluster();
1668 fHeader->fOffTriggers = fAodEv->GetHeader()->GetOfflineTrigger();
1669 fHeader->fFiredTriggers = fAodEv->GetHeader()->GetFiredTriggerClasses();
1671 fHeader->fRun = fEsdEv->GetRunNumber();
1672 fHeader->fOrbit = fEsdEv->GetHeader()->GetOrbitNumber();
1673 fHeader->fPeriod = fEsdEv->GetESDRun()->GetPeriodNumber();
1674 fHeader->fBx = fEsdEv->GetHeader()->GetBunchCrossNumber();
1675 fHeader->fL0 = fEsdEv->GetHeader()->GetL0TriggerInputs();
1676 fHeader->fL1 = fEsdEv->GetHeader()->GetL1TriggerInputs();
1677 fHeader->fL2 = fEsdEv->GetHeader()->GetL2TriggerInputs();
1678 fHeader->fTrClassMask = fEsdEv->GetHeader()->GetTriggerMask();
1679 fHeader->fTrCluster = fEsdEv->GetHeader()->GetTriggerCluster();
1680 fHeader->fOffTriggers = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
1681 fHeader->fFiredTriggers = fEsdEv->GetFiredTriggerClasses();
1682 Float_t v0CorrR = 0;
1683 fHeader->fV0 = AliESDUtils::GetCorrV0(fEsdEv,v0CorrR);
1684 const AliMultiplicity *mult = fEsdEv->GetMultiplicity();
1686 fHeader->fCl1 = mult->GetNumberOfITSClusters(1);
1687 fHeader->fTr = AliESDtrackCuts::GetReferenceMultiplicity(fEsdEv,1);
1689 AliCentrality *cent = InputEvent()->GetCentrality();
1690 fHeader->fV0Cent = cent->GetCentralityPercentileUnchecked("V0M");
1691 fHeader->fCl1Cent = cent->GetCentralityPercentileUnchecked("CL1");
1692 fHeader->fTrCent = cent->GetCentralityPercentileUnchecked("TRK");
1693 fHeader->fCqual = cent->GetQuality();
1695 AliEventplane *ep = InputEvent()->GetEventplane();
1697 if (ep->GetQVector())
1698 fHeader->fPsi = ep->GetQVector()->Phi()/2. ;
1701 if (ep->GetQsub1()&&ep->GetQsub2())
1702 fHeader->fPsiRes = ep->GetQsub1()->Phi()/2.-ep->GetQsub2()->Phi()/2.;
1704 fHeader->fPsiRes = 0;
1708 TString trgclasses(fHeader->fFiredTriggers);
1709 for (Int_t j = 0; j<fTrClassNamesArr->GetEntries(); ++j) {
1710 const char *name = fTrClassNamesArr->At(j)->GetName();
1711 if (trgclasses.Contains(name))
1712 val += TMath::Power(2,j);
1714 fHeader->fTcls = (UInt_t)val;
1716 fHeader->fNSelTr = fSelTracks->GetEntries();
1717 fHeader->fNSelPrimTr = fSelPrimTracks->GetEntries();
1718 fHeader->fNSelPrimTr1 = 0;
1719 fHeader->fNSelPrimTr2 = 0;
1720 for(int iTracks=0; iTracks < fSelPrimTracks->GetEntries(); iTracks++){
1721 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(iTracks));
1723 ++fHeader->fNSelPrimTr1;
1725 ++fHeader->fNSelPrimTr2;
1728 fHeader->fNCells = 0;
1729 fHeader->fNCells1 = 0;
1730 fHeader->fNCells2 = 0;
1731 fHeader->fNCells5 = 0;
1732 fHeader->fMaxCellE = 0;
1734 AliVCaloCells *cells = fEsdCells;
1739 Int_t ncells = cells->GetNumberOfCells();
1740 for(Int_t j=0; j<ncells; ++j) {
1741 Double_t cellen = cells->GetAmplitude(j);
1743 ++fHeader->fNCells1;
1745 ++fHeader->fNCells2;
1747 ++fHeader->fNCells5;
1748 if (cellen>fHeader->fMaxCellE)
1749 fHeader->fMaxCellE = cellen;
1751 fHeader->fNCells = ncells;
1754 fHeader->fNClus = 0;
1755 fHeader->fNClus1 = 0;
1756 fHeader->fNClus2 = 0;
1757 fHeader->fNClus5 = 0;
1758 fHeader->fMaxClusE = 0;
1760 TObjArray *clusters = fEsdClusters;
1762 clusters = fAodClusters;
1765 Int_t nclus = clusters->GetEntries();
1766 for(Int_t j=0; j<nclus; ++j) {
1767 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(j));
1768 if (!clus->IsEMCAL())
1770 Double_t clusen = clus->E();
1777 if (clusen>fHeader->fMaxClusE)
1778 fHeader->fMaxClusE = clusen;
1780 fHeader->fNClus = nclus;
1784 am->LoadBranch("vertices");
1785 AliAODVertex *pv = fAodEv->GetPrimaryVertex();
1786 FillVertex(fPrimVert, pv);
1787 AliAODVertex *sv = fAodEv->GetPrimaryVertexSPD();
1788 FillVertex(fSpdVert, sv);
1790 am->LoadBranch("PrimaryVertex.");
1791 const AliESDVertex *pv = fEsdEv->GetPrimaryVertexTracks();
1792 FillVertex(fPrimVert, pv);
1793 am->LoadBranch("SPDVertex.");
1794 const AliESDVertex *sv = fEsdEv->GetPrimaryVertexSPD();
1795 FillVertex(fSpdVert, sv);
1796 am->LoadBranch("TPCVertex.");
1797 const AliESDVertex *tv = fEsdEv->GetPrimaryVertexTPC();
1798 FillVertex(fTpcVert, tv);
1804 //________________________________________________________________________
1805 void AliAnalysisTaskEMCALPi0PbPb::FillPionHists()
1807 // Fill histograms related to pions.
1809 Double_t vertex[3] = {0};
1810 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1812 TObjArray *clusters = fEsdClusters;
1814 clusters = fAodClusters;
1817 TLorentzVector clusterVec1;
1818 TLorentzVector clusterVec2;
1819 TLorentzVector pionVec;
1821 Int_t nclus = clusters->GetEntries();
1822 for (Int_t i = 0; i<nclus; ++i) {
1823 AliVCluster *clus1 = static_cast<AliVCluster*>(clusters->At(i));
1826 if (!clus1->IsEMCAL())
1828 if (clus1->E()<fMinE)
1830 if (clus1->GetNCells()<fNminCells)
1832 if (GetMaxCellEnergy(clus1)/clus1->E()<fMinErat)
1834 if (clus1->Chi2()<fMinEcc) // eccentricity cut
1836 clus1->GetMomentum(clusterVec1,vertex);
1837 for (Int_t j = i+1; j<nclus; ++j) {
1838 AliVCluster *clus2 = static_cast<AliVCluster*>(clusters->At(j));
1841 if (!clus2->IsEMCAL())
1843 if (clus2->E()<fMinE)
1845 if (clus2->GetNCells()<fNminCells)
1847 if (GetMaxCellEnergy(clus2)/clus2->E()<fMinErat)
1849 if (clus2->Chi2()<fMinEcc) // eccentricity cut
1851 clus2->GetMomentum(clusterVec2,vertex);
1852 pionVec = clusterVec1 + clusterVec2;
1853 Double_t pionZgg = TMath::Abs(clusterVec1.E()-clusterVec2.E())/pionVec.E();
1854 Double_t pionOpeningAngle = clusterVec1.Angle(clusterVec2.Vect());
1855 if (pionZgg < fAsymMax) {
1856 fHPionEtaPhi->Fill(pionVec.Eta(),pionVec.Phi());
1857 fHPionMggPt->Fill(pionVec.M(),pionVec.Pt());
1858 fHPionMggAsym->Fill(pionVec.M(),pionZgg);
1859 fHPionMggDgg->Fill(pionVec.M(),pionOpeningAngle);
1860 Int_t bin = fPtRanges->FindBin(pionVec.Pt());
1861 fHPionInvMasses[bin]->Fill(pionVec.M());
1868 //________________________________________________________________________
1869 void AliAnalysisTaskEMCALPi0PbPb::FillMcHists()
1871 // Fill additional MC information histograms.
1876 // check if aod or esd mc mode and the fill histos
1879 //________________________________________________________________________
1880 void AliAnalysisTaskEMCALPi0PbPb::FillOtherHists()
1882 // Fill other histograms.
1884 for(int iTracks=0; iTracks < fSelPrimTracks->GetEntries(); ++iTracks){
1885 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(iTracks));
1888 fHPrimTrackPt->Fill(track->Pt());
1889 fHPrimTrackEta->Fill(track->Eta());
1890 fHPrimTrackPhi->Fill(track->Phi());
1894 //________________________________________________________________________
1895 void AliAnalysisTaskEMCALPi0PbPb::FillTrackHists()
1897 // Fill track histograms.
1899 if (fSelPrimTracks) {
1900 for(int iTracks=0; iTracks < fSelPrimTracks->GetEntries(); iTracks++) {
1901 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(iTracks));
1904 fHPrimTrackPt->Fill(track->Pt());
1905 fHPrimTrackEta->Fill(track->Eta());
1906 fHPrimTrackPhi->Fill(track->Phi());
1911 //__________________________________________________________________________________________________
1912 void AliAnalysisTaskEMCALPi0PbPb::FillVertex(AliStaVertex *v, const AliESDVertex *esdv)
1914 // Fill vertex from ESD vertex info.
1916 v->fVx = esdv->GetX();
1917 v->fVy = esdv->GetY();
1918 v->fVz = esdv->GetZ();
1919 v->fVc = esdv->GetNContributors();
1920 v->fDisp = esdv->GetDispersion();
1921 v->fZres = esdv->GetZRes();
1922 v->fChi2 = esdv->GetChi2();
1923 v->fSt = esdv->GetStatus();
1924 v->fIs3D = esdv->IsFromVertexer3D();
1925 v->fIsZ = esdv->IsFromVertexerZ();
1928 //__________________________________________________________________________________________________
1929 void AliAnalysisTaskEMCALPi0PbPb::FillVertex(AliStaVertex *v, const AliAODVertex *aodv)
1931 // Fill vertex from AOD vertex info.
1933 v->fVx = aodv->GetX();
1934 v->fVy = aodv->GetY();
1935 v->fVz = aodv->GetZ();
1936 v->fVc = aodv->GetNContributors();
1937 v->fChi2 = aodv->GetChi2();
1940 //________________________________________________________________________
1941 Double_t AliAnalysisTaskEMCALPi0PbPb::GetCellIsolation(Double_t cEta, Double_t cPhi, Double_t radius) const
1943 // Compute isolation based on cell content.
1945 AliVCaloCells *cells = fEsdCells;
1951 Double_t cellIsolation = 0;
1952 Double_t rad2 = radius*radius;
1953 Int_t ncells = cells->GetNumberOfCells();
1954 for (Int_t i = 0; i<ncells; ++i) {
1955 Int_t absID = TMath::Abs(cells->GetCellNumber(i));
1956 Float_t eta=-1, phi=-1;
1957 fGeom->EtaPhiFromIndex(absID,eta,phi);
1958 Double_t phidiff = TVector2::Phi_mpi_pi(phi-cPhi);
1959 Double_t dist = (eta-cEta)*(eta-cEta)+phidiff*phidiff;
1962 Double_t cellE = cells->GetAmplitude(i);
1963 cellIsolation += cellE;
1965 return cellIsolation;
1968 //________________________________________________________________________
1969 Double_t AliAnalysisTaskEMCALPi0PbPb::GetCellEnergy(const AliVCluster *cluster) const
1971 // Get maximum energy of attached cell.
1974 Int_t ncells = cluster->GetNCells();
1976 for (Int_t i=0; i<ncells; i++) {
1977 Double_t e = fEsdCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1981 for (Int_t i=0; i<ncells; i++) {
1982 Double_t e = fAodCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1989 //________________________________________________________________________
1990 Double_t AliAnalysisTaskEMCALPi0PbPb::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
1992 // Get maximum energy of attached cell.
1996 Int_t ncells = cluster->GetNCells();
1998 for (Int_t i=0; i<ncells; i++) {
1999 Double_t e = fEsdCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
2002 id = cluster->GetCellAbsId(i);
2006 for (Int_t i=0; i<ncells; i++) {
2007 Double_t e = fAodCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
2010 id = cluster->GetCellAbsId(i);
2016 //________________________________________________________________________
2017 void AliAnalysisTaskEMCALPi0PbPb::GetSigma(const AliVCluster *c, Double_t& sigmaMax, Double_t &sigmaMin) const
2019 // Calculate the (E) weighted variance along the longer (eigen) axis.
2021 sigmaMax = 0; // cluster variance along its longer axis
2022 sigmaMin = 0; // cluster variance along its shorter axis
2023 Double_t Ec = c->E(); // cluster energy
2026 Double_t Xc = 0 ; // cluster first moment along X
2027 Double_t Yc = 0 ; // cluster first moment along Y
2028 Double_t Sxx = 0 ; // cluster second central moment along X (variance_X^2)
2029 Double_t Sxy = 0 ; // cluster second central moment along Y (variance_Y^2)
2030 Double_t Syy = 0 ; // cluster covariance^2
2032 AliVCaloCells *cells = fEsdCells;
2039 Int_t ncells = c->GetNCells();
2043 for(Int_t j=0; j<ncells; ++j) {
2044 Int_t id = TMath::Abs(c->GetCellAbsId(j));
2045 Double_t cellen = cells->GetCellAmplitude(id);
2047 fGeom->GetGlobal(id,pos);
2048 Xc += cellen*pos.X();
2049 Yc += cellen*pos.Y();
2050 Sxx += cellen*pos.X()*pos.X();
2051 Syy += cellen*pos.Y()*pos.Y();
2052 Sxy += cellen*pos.X()*pos.Y();
2062 Sxx = TMath::Abs(Sxx);
2063 Syy = TMath::Abs(Syy);
2064 sigmaMax = (Sxx + Syy + TMath::Sqrt(TMath::Abs((Sxx-Syy)*(Sxx-Syy)+4.0*Sxy*Sxy)))/2.0;
2065 sigmaMax = TMath::Sqrt(TMath::Abs(sigmaMax));
2066 sigmaMin = TMath::Abs(Sxx + Syy - TMath::Sqrt(TMath::Abs((Sxx-Syy)*(Sxx-Syy)+4.0*Sxy*Sxy)))/2.0;
2067 sigmaMin = TMath::Sqrt(TMath::Abs(sigmaMin));
2070 //________________________________________________________________________
2071 Int_t AliAnalysisTaskEMCALPi0PbPb::GetNCells(const AliVCluster *c, Double_t emin) const
2073 // Calculate number of attached cells above emin.
2075 AliVCaloCells *cells = fEsdCells;
2082 Int_t ncells = c->GetNCells();
2083 for(Int_t j=0; j<ncells; ++j) {
2084 Int_t id = TMath::Abs(c->GetCellAbsId(j));
2085 Double_t cellen = cells->GetCellAmplitude(id);
2092 //________________________________________________________________________
2093 Double_t AliAnalysisTaskEMCALPi0PbPb::GetTrackIsolation(Double_t cEta, Double_t cPhi, Double_t radius, Double_t pt) const
2095 // Compute isolation based on tracks.
2097 Double_t trkIsolation = 0;
2098 Double_t rad2 = radius*radius;
2099 Int_t ntrks = fSelPrimTracks->GetEntries();
2100 for(Int_t j = 0; j<ntrks; ++j) {
2101 AliVTrack *track = static_cast<AliVTrack*>(fSelTracks->At(j));
2106 Float_t eta = track->Eta();
2107 Float_t phi = track->Phi();
2108 Double_t phidiff = TVector2::Phi_mpi_pi(phi-cPhi);
2109 Double_t dist = (eta-cEta)*(eta-cEta)+phidiff*phidiff;
2112 trkIsolation += track->Pt();
2114 return trkIsolation;
2117 //________________________________________________________________________
2118 Bool_t AliAnalysisTaskEMCALPi0PbPb::IsShared(const AliVCluster *c) const
2120 // Returns if cluster shared across super modules.
2122 AliVCaloCells *cells = fEsdCells;
2129 Int_t ncells = c->GetNCells();
2130 for(Int_t j=0; j<ncells; ++j) {
2131 Int_t id = TMath::Abs(c->GetCellAbsId(j));
2132 Int_t got = id / (24*48);
2143 //________________________________________________________________________
2144 void AliAnalysisTaskEMCALPi0PbPb::PrintDaughters(const AliVParticle *p, const TObjArray *arr, Int_t level) const
2146 // Print recursively daughter information.
2151 const AliAODMCParticle *amc = dynamic_cast<const AliAODMCParticle*>(p);
2154 for (Int_t i=0; i<level; ++i) printf(" ");
2157 Int_t n = amc->GetNDaughters();
2158 for (Int_t i=0; i<n; ++i) {
2159 Int_t d = amc->GetDaughter(i);
2160 const AliVParticle *dmc = static_cast<const AliVParticle*>(arr->At(d));
2161 PrintDaughters(dmc,arr,level+1);
2165 //________________________________________________________________________
2166 void AliAnalysisTaskEMCALPi0PbPb::PrintDaughters(const AliMCParticle *p, const AliMCEvent *arr, Int_t level) const
2168 // Print recursively daughter information.
2173 for (Int_t i=0; i<level; ++i) printf(" ");
2174 Int_t d1 = p->GetFirstDaughter();
2175 Int_t d2 = p->GetLastDaughter();
2176 printf("pid=%d: %.2f %.2f %.2f (%.2f %.2f %.2f); nd=%d,%d\n",
2177 p->PdgCode(),p->Px(),p->Py(),p->Pz(),p->Xv(),p->Yv(),p->Zv(),d1,d2);
2182 for (Int_t i=d1;i<=d2;++i) {
2183 const AliMCParticle *dmc = static_cast<const AliMCParticle *>(arr->GetTrack(i));
2184 PrintDaughters(dmc,arr,level+1);
2188 //________________________________________________________________________
2189 void AliAnalysisTaskEMCALPi0PbPb::PrintTrackRefs(AliMCParticle *p) const
2191 // Print track ref array.
2196 Int_t n = p->GetNumberOfTrackReferences();
2197 for (Int_t i=0; i<n; ++i) {
2198 AliTrackReference *ref = p->GetTrackReference(i);
2201 ref->SetUserId(ref->DetectorId());
2206 //________________________________________________________________________
2207 void AliAnalysisTaskEMCALPi0PbPb::ProcessDaughters(AliVParticle *p, Int_t index, const TObjArray *arr)
2209 // Process and create daughters.
2214 AliAODMCParticle *amc = dynamic_cast<AliAODMCParticle*>(p);
2220 Int_t nparts = arr->GetEntries();
2221 Int_t nents = fMcParts->GetEntries();
2223 AliStaPart *newp = static_cast<AliStaPart*>(fMcParts->New(nents));
2224 newp->fPt = amc->Pt();
2225 newp->fEta = amc->Eta();
2226 newp->fPhi = amc->Phi();
2227 if (amc->Xv() != 0 || amc->Yv() != 0 || amc->Zv() != 0) {
2228 TVector3 vec(amc->Xv(),amc->Yv(),amc->Zv());
2229 newp->fVR = vec.Perp();
2230 newp->fVEta = vec.Eta();
2231 newp->fVPhi = vec.Phi();
2233 newp->fPid = amc->PdgCode();
2235 Int_t moi = amc->GetMother();
2236 if (moi>=0&&moi<nparts) {
2237 const AliAODMCParticle *mmc = static_cast<const AliAODMCParticle*>(arr->At(moi));
2238 moi = mmc->GetUniqueID();
2241 p->SetUniqueID(nents);
2243 // TODO: Determine which detector was hit
2246 Int_t n = amc->GetNDaughters();
2247 for (Int_t i=0; i<n; ++i) {
2248 Int_t d = amc->GetDaughter(i);
2249 if (d<=index || d>=nparts)
2251 AliVParticle *dmc = static_cast<AliVParticle*>(arr->At(d));
2252 ProcessDaughters(dmc,d,arr);
2256 //________________________________________________________________________
2257 void AliAnalysisTaskEMCALPi0PbPb::ProcessDaughters(AliMCParticle *p, Int_t index, const AliMCEvent *arr)
2259 // Process and create daughters.
2264 Int_t d1 = p->GetFirstDaughter();
2265 Int_t d2 = p->GetLastDaughter();
2267 printf("%d pid=%d: %.3f %.3f %.3f (%.2f %.2f %.2f); nd=%d,%d, mo=%d\n",
2268 index,p->PdgCode(),p->Px(),p->Py(),p->Pz(),p->Xv(),p->Yv(),p->Zv(),d1,d2, p->GetMother());
2271 Int_t nents = fMcParts->GetEntries();
2273 AliStaPart *newp = static_cast<AliStaPart*>(fMcParts->New(nents));
2274 newp->fPt = p->Pt();
2275 newp->fEta = p->Eta();
2276 newp->fPhi = p->Phi();
2277 if (p->Xv() != 0 || p->Yv() != 0 || p->Zv() != 0) {
2278 TVector3 vec(p->Xv(),p->Yv(),p->Zv());
2279 newp->fVR = vec.Perp();
2280 newp->fVEta = vec.Eta();
2281 newp->fVPhi = vec.Phi();
2283 newp->fPid = p->PdgCode();
2285 Int_t moi = p->GetMother();
2287 const AliMCParticle *mmc = static_cast<const AliMCParticle *>(arr->GetTrack(moi));
2288 moi = mmc->GetUniqueID();
2291 p->SetUniqueID(nents);
2293 Int_t nref = p->GetNumberOfTrackReferences();
2295 AliTrackReference *ref = p->GetTrackReference(nref-1);
2297 newp->fDet = ref->DetectorId();
2305 for (Int_t i=d1;i<=d2;++i) {
2306 AliMCParticle *dmc = static_cast<AliMCParticle *>(arr->GetTrack(i));
2309 ProcessDaughters(dmc,i,arr);