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(const char *name)
49 : AliAnalysisTaskSE(name),
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),
147 DefineInput(0, TChain::Class());
148 DefineOutput(1, TList::Class());
149 fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.,SPDVertex.,TPCVertex.,EMCALCells.,Tracks EMCALTrigger."
150 "AOD:header,vertices,emcalCells,tracks";
153 //________________________________________________________________________
154 AliAnalysisTaskEMCALPi0PbPb::~AliAnalysisTaskEMCALPi0PbPb()
158 if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
159 delete fOutput; fOutput = 0;
161 delete fPtRanges; fPtRanges = 0;
162 delete fGeom; fGeom = 0;
163 delete fReco; fReco = 0;
164 delete fTrClassNamesArr;
166 delete fSelPrimTracks;
167 delete [] fAmpInTrigger;
169 delete [] fHColuRowE;
170 delete [] fHCellMult;
171 delete [] fHCellFreqNoCut;
172 delete [] fHCellFreqCut100M;
173 delete [] fHCellFreqCut300M;
176 //________________________________________________________________________
177 void AliAnalysisTaskEMCALPi0PbPb::UserCreateOutputObjects()
179 // Create user objects here.
181 cout << "AliAnalysisTaskEMCALPi0PbPb: Input settings" << endl;
182 cout << " fCentVar: " << fCentVar << endl;
183 cout << " fCentFrom: " << fCentFrom << endl;
184 cout << " fCentTo: " << fCentTo << endl;
185 cout << " fVtxZMin: " << fVtxZMin << endl;
186 cout << " fVtxZMax: " << fVtxZMax << endl;
187 cout << " fUseQualFlag: " << fUseQualFlag << endl;
188 cout << " fClusName: \"" << fClusName << "\"" << endl;
189 cout << " fDoNtuple: " << fDoNtuple << endl;
190 cout << " fDoAfterburner: " << fDoAfterburner << endl;
191 cout << " fAsymMax: " << fAsymMax << endl;
192 cout << " fNminCells: " << fNminCells << endl;
193 cout << " fMinE: " << fMinE << endl;
194 cout << " fMinErat: " << fMinErat << endl;
195 cout << " fMinEcc: " << fMinEcc << endl;
196 cout << " fGeoName: \"" << fGeoName << "\"" << endl;
197 cout << " fMinNClusPerTr: " << fMinNClusPerTr << endl;
198 cout << " fIsoDist: " << fIsoDist << endl;
199 cout << " fTrClassNames: \"" << fTrClassNames << "\"" << endl;
200 cout << " fTrCuts: " << fTrCuts << endl;
201 cout << " fPrimTrCuts: " << fPrimTrCuts << endl;
202 cout << " fDoTrMatGeom: " << fDoTrMatGeom << endl;
203 cout << " fTrainMode: " << fTrainMode << endl;
204 cout << " fMarkCells: " << fMarkCells << endl;
205 cout << " fMinL0Time: " << fMinL0Time << endl;
206 cout << " fMaxL0Time: " << fMaxL0Time << endl;
207 cout << " fMcMode: " << fMcMode << endl;
208 cout << " fEmbedMode: " << fEmbedMode << endl;
209 cout << " fGeom: " << fGeom << endl;
210 cout << " fReco: " << fReco << endl;
211 cout << " fDoPSel: " << fDoPSel << endl;
214 fGeom = AliEMCALGeometry::GetInstance(fGeoName);
216 if (fGeom->GetMatrixForSuperModule(0))
217 fIsGeoMatsSet = kTRUE;
220 fReco = new AliEMCALRecoUtils();
221 fTrClassNamesArr = fTrClassNames.Tokenize(" ");
222 fOutput = new TList();
224 fSelTracks = new TObjArray;
225 fSelPrimTracks = new TObjArray;
228 TFile *f = OpenFile(1);
230 f->SetCompressionLevel(2);
231 fNtuple = new TTree(Form("tree%.0fto%.0f",fCentFrom,fCentTo), "StandaloneTree");
232 fNtuple->SetDirectory(f);
234 fNtuple->SetAutoFlush(-2*1024*1024);
235 fNtuple->SetAutoSave(0);
237 fNtuple->SetAutoFlush(-32*1024*1024);
238 fNtuple->SetAutoSave(0);
241 fHeader = new AliStaHeader;
242 fNtuple->Branch("header", &fHeader, 16*1024, 99);
243 fPrimVert = new AliStaVertex;
244 fNtuple->Branch("primv", &fPrimVert, 16*1024, 99);
245 fSpdVert = new AliStaVertex;
246 fNtuple->Branch("spdv", &fSpdVert, 16*1024, 99);
247 fTpcVert = new AliStaVertex;
248 fNtuple->Branch("tpcv", &fTpcVert, 16*1024, 99);
249 if (TClass::GetClass("AliStaCluster"))
250 TClass::GetClass("AliStaCluster")->IgnoreTObjectStreamer();
251 fClusters = new TClonesArray("AliStaCluster");
252 fNtuple->Branch("clusters", &fClusters, 8*16*1024, 99);
253 if (TClass::GetClass("AliStaTrigger"))
254 TClass::GetClass("AliStaTrigger")->IgnoreTObjectStreamer();
255 fTriggers = new TClonesArray("AliStaTrigger");
256 fNtuple->Branch("l0prim", &fTriggers, 16*1024, 99);
257 if (fMcMode||fEmbedMode) {
258 if (TClass::GetClass("AliStaPart"))
259 TClass::GetClass("AliStaPart")->IgnoreTObjectStreamer();
260 fMcParts = new TClonesArray("AliStaPart");
261 fNtuple->Branch("mcparts", &fMcParts, 8*16*1024, 99);
266 AliEMCALEMCGeometry *emc = fGeom->GetEMCGeometry();
267 Double_t phimin = emc->GetArm1PhiMin()*TMath::DegToRad();
268 Double_t phimax = emc->GetArm1PhiMax()*TMath::DegToRad();
271 TH1::SetDefaultSumw2(kTRUE);
272 TH2::SetDefaultSumw2(kTRUE);
273 fHCuts = new TH1F("hEventCuts","",5,0.5,5.5);
274 fHCuts->GetXaxis()->SetBinLabel(1,"All");
275 fHCuts->GetXaxis()->SetBinLabel(2,"PS");
276 fHCuts->GetXaxis()->SetBinLabel(3,Form("%s: %.0f-%.0f",fCentVar.Data(),fCentFrom,fCentTo));
277 fHCuts->GetXaxis()->SetBinLabel(4,"QFlag");
278 fHCuts->GetXaxis()->SetBinLabel(5,Form("zvtx: %.0f-%.0f",fVtxZMin,fVtxZMax));
279 fOutput->Add(fHCuts);
280 fHVertexZ = new TH1F("hVertexZBeforeCut","",100,-25,25);
281 fHVertexZ->SetXTitle("z [cm]");
282 fOutput->Add(fHVertexZ);
283 fHVertexZ2 = new TH1F("hVertexZAfterCut","",100,-25,25);
284 fHVertexZ2->SetXTitle("z [cm]");
285 fOutput->Add(fHVertexZ2);
286 fHCent = new TH1F("hCentBeforeCut","",102,-1,101);
287 fHCent->SetXTitle(fCentVar.Data());
288 fOutput->Add(fHCent);
289 fHCentQual = new TH1F("hCentAfterCut","",102,-1,101);
290 fHCentQual->SetXTitle(fCentVar.Data());
291 fOutput->Add(fHCentQual);
292 fHTclsBeforeCuts = new TH1F("hTclsBeforeCuts","",fTrClassNamesArr->GetEntries(),0.5,0.5+fTrClassNamesArr->GetEntries());
293 fHTclsAfterCuts = new TH1F("hTclsAfterCuts","",fTrClassNamesArr->GetEntries(),0.5,0.5+fTrClassNamesArr->GetEntries());
294 for (Int_t i = 0; i<fTrClassNamesArr->GetEntries(); ++i) {
295 const char *name = fTrClassNamesArr->At(i)->GetName();
296 fHTclsBeforeCuts->GetXaxis()->SetBinLabel(1+i,name);
297 fHTclsAfterCuts->GetXaxis()->SetBinLabel(1+i,name);
299 fOutput->Add(fHTclsBeforeCuts);
300 fOutput->Add(fHTclsAfterCuts);
302 // histograms for cells
303 Int_t nsm = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
304 fHColuRow = new TH2*[nsm];
305 fHColuRowE = new TH2*[nsm];
306 fHCellMult = new TH1*[nsm];
307 for (Int_t i = 0; i<nsm; ++i) {
308 fHColuRow[i] = new TH2F(Form("hColRow_Mod%d",i),"",48,0,48,24,0.,24);
309 fHColuRow[i]->SetTitle(Form("Module %d: Occupancy", i));
310 fHColuRow[i]->SetXTitle("col (i#eta)");
311 fHColuRow[i]->SetYTitle("row (i#phi)");
312 fHColuRowE[i] = new TH2F(Form("hColRowE_Mod%d", i),"",48,0,48,24,0,24);
313 fHColuRowE[i]->SetTitle(Form("Module %d: Cell energy",i));
314 fHColuRowE[i]->SetXTitle("col (i#eta)");
315 fHColuRowE[i]->SetYTitle("row (i#phi)");
316 fHCellMult[i] = new TH1F(Form("hCellMult_Mod%d",i),"",1000,0,1000);
317 fHCellMult[i]->SetTitle(Form("Module %d: Cell multiplicity",i));
318 fHCellMult[i]->SetXTitle("# of cells");
319 fOutput->Add(fHColuRow[i]);
320 fOutput->Add(fHColuRowE[i]);
321 fOutput->Add(fHCellMult[i]);
323 fHCellE = new TH1F("hCellE","",250,0.,25.);
324 fHCellE->SetXTitle("E_{cell} [GeV]");
325 fOutput->Add(fHCellE);
326 fHCellH = new TH1F ("hCellHighestE","",250,0.,25.);
327 fHCellH->SetXTitle("E^{max}_{cell} [GeV]");
328 fOutput->Add(fHCellH);
329 fHCellM = new TH1F ("hCellMeanEperHitCell","",250,0.,2.5);
330 fHCellM->SetXTitle("#LT E_{cell}#GT [GeV]");
331 fOutput->Add(fHCellM);
332 fHCellM2 = new TH1F ("hCellMeanEperAllCells","",250,0.,1);
333 fHCellM2->SetXTitle("1/N_{cells} #Sigma E_{cell} [GeV]");
334 fOutput->Add(fHCellM2);
336 fHCellFreqNoCut = new TH1*[nsm];
337 fHCellFreqCut100M = new TH1*[nsm];
338 fHCellFreqCut300M = new TH1*[nsm];
339 fHCellFreqE = new TH1*[nsm];
340 for (Int_t i = 0; i<nsm; ++i){
341 Double_t lbin = i*24*48-0.5;
342 Double_t hbin = lbin+24*48;
343 fHCellFreqNoCut[i] = new TH1F(Form("hCellFreqNoCut_SM%d",i),
344 Form("Frequency SM%d (no cut);id;#",i), 1152, lbin, hbin);
345 fHCellFreqCut100M[i] = new TH1F(Form("hCellFreqCut100M_SM%d",i),
346 Form("Frequency SM%d (>0.1GeV);id;#",i), 1152, lbin, hbin);
347 fHCellFreqCut300M[i] = new TH1F(Form("hCellFreqCut300M_SM%d",i),
348 Form("Frequency SM%d (>0.3GeV);id;#",i), 1152, lbin, hbin);
349 fHCellFreqE[i] = new TH1F(Form("hCellFreqE_SM%d",i),
350 Form("Frequency SM%d (E weighted);id;#",i), 1152, lbin, hbin);
351 fOutput->Add(fHCellFreqNoCut[i]);
352 fOutput->Add(fHCellFreqCut100M[i]);
353 fOutput->Add(fHCellFreqCut300M[i]);
354 fOutput->Add(fHCellFreqE[i]);
356 if (!fMarkCells.IsNull()) {
357 fHCellCheckE = new TH1*[24*48*nsm];
358 memset(fHCellCheckE,0,24*48*nsm*sizeof(TH1*));
359 TObjArray *cells = fMarkCells.Tokenize(" ");
360 Int_t n = cells->GetEntries();
361 Int_t *tcs = new Int_t[n];
362 for (Int_t i=0;i<n;++i) {
363 TString name(cells->At(i)->GetName());
366 for (Int_t i = 0; i<n; ++i) {
369 fHCellCheckE[i] = new TH1F(Form("hCellE_id%d",c), Form("Cell %d;E [GeV/c];#",c), 1000, 0, 10);
370 fOutput->Add(fHCellCheckE[i]);
377 // histograms for clusters
379 fHClustEccentricity = new TH1F("hClustEccentricity","",100,-0.1,1.1);
380 fHClustEccentricity->SetXTitle("#epsilon_{C}");
381 fOutput->Add(fHClustEccentricity);
382 fHClustEtaPhi = new TH2F("hClustEtaPhi","",500,-0.8,0.8,100*nsm,phimin,phimax);
383 fHClustEtaPhi->SetXTitle("#eta");
384 fHClustEtaPhi->SetYTitle("#varphi");
385 fOutput->Add(fHClustEtaPhi);
386 fHClustEnergyPt = new TH2F("hClustEnergyPt","",250,0,50,250,0,50);
387 fHClustEnergyPt->SetXTitle("E [GeV]");
388 fHClustEnergyPt->SetYTitle("p_{T} [GeV/c]");
389 fOutput->Add(fHClustEnergyPt);
390 fHClustEnergySigma = new TH2F("hClustEnergySigma","",100,0,100,500,0,50);
391 fHClustEnergySigma->SetXTitle("E_{C} * #sigma_{max} [GeV*cm]");
392 fHClustEnergySigma->SetYTitle("E_{C} [GeV]");
393 fOutput->Add(fHClustEnergySigma);
394 fHClustSigmaSigma = new TH2F("hClustSigmaSigma","",500,0,50,500,0,50);
395 fHClustSigmaSigma->SetXTitle("#lambda_{0} [cm]");
396 fHClustSigmaSigma->SetYTitle("#sigma_{max} [cm]");
397 fOutput->Add(fHClustSigmaSigma);
398 fHClustNCellEnergyRatio = new TH2F("hClustNCellEnergyRatio","",27,-0.5,26.5,101,-0.05,1.05);
399 fHClustNCellEnergyRatio->SetXTitle("N_{cells}");
400 fHClustNCellEnergyRatio->SetYTitle("E^{max}_{cell}/E_{clus}");
401 fOutput->Add(fHClustNCellEnergyRatio);
402 fHClustEnergyNCell = new TH2F("hClustEnergyNCell","",200,0,100,50,0,50);
403 fHClustEnergyNCell->SetXTitle("E_{clus}");
404 fHClustEnergyNCell->SetYTitle("N_{cells}");
405 fOutput->Add(fHClustEnergyNCell);
408 // histograms for primary tracks
409 fHPrimTrackPt = new TH1F("hPrimTrackPt",";p_{T} [GeV/c]",500,0,50);
410 fOutput->Add(fHPrimTrackPt);
411 fHPrimTrackEta = new TH1F("hPrimTrackEta",";#eta",40,-2,2);
412 fOutput->Add(fHPrimTrackEta);
413 fHPrimTrackPhi = new TH1F("hPrimTrackPhi",";#varPhi [rad]",63,0,6.3);
414 fOutput->Add(fHPrimTrackPhi);
415 // histograms for track matching
416 fHMatchDr = new TH1F("hMatchDrDist",";dR [cm]",500,0,200);
417 fOutput->Add(fHMatchDr);
418 fHMatchDz = new TH1F("hMatchDzDist",";dZ [cm]",500,-100,100);
419 fOutput->Add(fHMatchDz);
420 fHMatchEp = new TH1F("hMatchEpDist",";E/p",100,0,10);
421 fOutput->Add(fHMatchEp);
423 // histograms for pion candidates
425 fHPionEtaPhi = new TH2F("hPionEtaPhi","",100,-0.8,0.8,100*nsm,phimin,phimax);
426 fHPionEtaPhi->SetXTitle("#eta_{#gamma#gamma}");
427 fHPionEtaPhi->SetYTitle("#varphi_{#gamma#gamma}");
428 fOutput->Add(fHPionEtaPhi);
429 fHPionMggPt = new TH2F("hPionMggPt","",1000,0,2,100,0,20.0);
430 fHPionMggPt->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
431 fHPionMggPt->SetYTitle("p_{T}^{#gamma#gamma} [GeV/c]");
432 fOutput->Add(fHPionMggPt);
433 fHPionMggAsym = new TH2F("hPionMggAsym","",1000,0,2,100,0,1);
434 fHPionMggAsym->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
435 fHPionMggAsym->SetYTitle("Z_{#gamma#gamma} [GeV]");
436 fOutput->Add(fHPionMggAsym);
437 fHPionMggDgg = new TH2F("hPionMggDgg","",1000,0,2,100,0,10);
438 fHPionMggDgg->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
439 fHPionMggDgg->SetYTitle("opening angle [grad]");
440 fOutput->Add(fHPionMggDgg);
441 const Int_t nbins = 20;
442 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};
443 fPtRanges = new TAxis(nbins-1,xbins);
444 for (Int_t i = 0; i<=nbins; ++i) {
445 fHPionInvMasses[i] = new TH1F(Form("hPionInvMass%d",i),"",1000,0,2);
446 fHPionInvMasses[i]->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
448 fHPionInvMasses[i]->SetTitle(Form("0 < p_{T}^{#gamma#gamma} <%.1f",xbins[0]));
450 fHPionInvMasses[i]->SetTitle(Form("p_{T}^{#gamma#gamma} > 50"));
452 fHPionInvMasses[i]->SetTitle(Form("%.1f < p_{T}^{#gamma#gamma} <%.1f",xbins[i-1],xbins[i]));
453 fOutput->Add(fHPionInvMasses[i]);
457 PostData(1, fOutput);
460 //________________________________________________________________________
461 void AliAnalysisTaskEMCALPi0PbPb::UserExec(Option_t *)
463 // Called for each event.
468 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
469 fEsdEv = dynamic_cast<AliESDEvent*>(InputEvent());
470 UInt_t offtrigger = 0;
472 am->LoadBranch("AliESDRun.");
473 am->LoadBranch("AliESDHeader.");
474 UInt_t mask1 = fEsdEv->GetESDRun()->GetDetectorsInDAQ();
475 UInt_t mask2 = fEsdEv->GetESDRun()->GetDetectorsInReco();
476 Bool_t desc1 = (mask1 >> 18) & 0x1;
477 Bool_t desc2 = (mask2 >> 18) & 0x1;
478 if (desc1==0 || desc2==0) { //AliDAQ::OfflineModuleName(180=="EMCAL"
479 AliError(Form("EMCAL not in DAQ/RECO: %u (%u)/%u (%u)",
480 mask1, fEsdEv->GetESDRun()->GetDetectorsInReco(),
481 mask2, fEsdEv->GetESDRun()->GetDetectorsInDAQ()));
484 offtrigger = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
486 fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
488 AliFatal("Neither ESD nor AOD event found");
491 am->LoadBranch("header");
492 offtrigger = fAodEv->GetHeader()->GetOfflineTrigger();
494 if (!fMcMode && (offtrigger & AliVEvent::kFastOnly)) {
495 AliWarning(Form("EMCAL not in fast only partition"));
498 if (fDoTrMatGeom && !AliGeomManager::GetGeometry()) { // get geometry
499 AliWarning("Accessing geometry from OCDB, this is not very efficient!");
500 AliCDBManager *cdb = AliCDBManager::Instance();
501 if (!cdb->IsDefaultStorageSet())
502 cdb->SetDefaultStorage("raw://");
503 Int_t runno = InputEvent()->GetRunNumber();
504 if (runno != cdb->GetRun())
506 AliGeomManager::LoadGeometry();
509 if (!AliGeomManager::GetGeometry()&&!fIsGeoMatsSet) { // set misalignment matrices (stored in first event)
510 Int_t nsm = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
511 for (Int_t i=0; i<nsm; ++i) {
512 const TGeoHMatrix *geom = 0;
514 geom = fEsdEv->GetESDRun()->GetEMCALMatrix(i);
516 geom = fAodEv->GetHeader()->GetEMCALMatrix(i);
520 fGeom->SetMisalMatrix(geom,i);
522 fIsGeoMatsSet = kTRUE;
525 if (!TGeoGlobalMagField::Instance()->GetField()) { // construct field map
527 const AliESDRun *erun = fEsdEv->GetESDRun();
528 AliMagF *field = AliMagF::CreateFieldMap(erun->GetCurrentL3(),
529 erun->GetCurrentDip(),
532 erun->GetBeamEnergy(),
533 erun->GetBeamType());
534 TGeoGlobalMagField::Instance()->SetField(field);
536 Double_t pol = -1; //polarity
537 Double_t be = -1; //beam energy
538 AliMagF::BeamType_t btype = AliMagF::kBeamTypepp;
539 Int_t runno = fAodEv->GetRunNumber();
540 if (runno>=136851 && runno<138275) {
543 btype = AliMagF::kBeamTypeAA;
544 } else if (runno>=138275 && runno<=139517) {
547 btype = AliMagF::kBeamTypeAA;
549 AliError(Form("Do not know the bfield parameters for run %d! Using defaults!!!", runno));
551 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", pol, pol, AliMagF::k5kG, btype, be));
559 AliESDHeader *h = dynamic_cast<AliESDHeader*>(InputEvent()->GetHeader());
561 trgclasses = fEsdEv->GetFiredTriggerClasses();
563 AliAODHeader *h2 = dynamic_cast<AliAODHeader*>(InputEvent()->GetHeader());
565 trgclasses = h2->GetFiredTriggerClasses();
567 for (Int_t i = 0; i<fTrClassNamesArr->GetEntries(); ++i) {
568 const char *name = fTrClassNamesArr->At(i)->GetName();
569 if (trgclasses.Contains(name))
570 fHTclsBeforeCuts->Fill(1+i);
573 if (fDoPSel && offtrigger==0)
578 const AliCentrality *centP = InputEvent()->GetCentrality();
579 Double_t cent = centP->GetCentralityPercentileUnchecked(fCentVar);
581 if (cent<fCentFrom||cent>fCentTo)
587 if (centP->GetQuality()>0)
591 fHCentQual->Fill(cent);
595 am->LoadBranch("PrimaryVertex.");
596 am->LoadBranch("SPDVertex.");
597 am->LoadBranch("TPCVertex.");
599 fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
600 am->LoadBranch("vertices");
604 const AliVVertex *vertex = InputEvent()->GetPrimaryVertex();
608 fHVertexZ->Fill(vertex->GetZ());
610 if(vertex->GetZ()<fVtxZMin||vertex->GetZ()>fVtxZMax)
614 fHVertexZ2->Fill(vertex->GetZ());
616 // count number of accepted events
619 for (Int_t i = 0; i<fTrClassNamesArr->GetEntries(); ++i) {
620 const char *name = fTrClassNamesArr->At(i)->GetName();
621 if (trgclasses.Contains(name))
622 fHTclsAfterCuts->Fill(1+i);
625 fRecPoints = 0; // will be set if fClusName is given and AliAnalysisTaskEMCALClusterizeFast is used
626 fDigits = 0; // will be set if fClusName is given and AliAnalysisTaskEMCALClusterizeFast is used
627 fEsdClusters = 0; // will be set if ESD input used and if fRecPoints are not set or if clusters are attached
628 fEsdCells = 0; // will be set if ESD input used
629 fAodClusters = 0; // will be set if AOD input used and if fRecPoints are not set or if clusters are attached
630 // or if fClusName is given and AliAnalysisTaskEMCALClusterizeFast in AOD output mode
631 fAodCells = 0; // will be set if AOD input used
633 // deal with special output from AliAnalysisTaskEMCALClusterizeFast first
634 Bool_t clusattached = 0;
635 Bool_t recalibrated = 0;
636 if (1 && !fClusName.IsNull()) {
637 AliAnalysisTaskEMCALClusterizeFast *cltask = 0;
638 TObjArray *ts = am->GetTasks();
639 cltask = dynamic_cast<AliAnalysisTaskEMCALClusterizeFast*>(ts->FindObject(fClusName));
640 if (cltask && cltask->GetClusters()) {
641 fRecPoints = cltask->GetClusters();
642 fDigits = cltask->GetDigits();
643 clusattached = cltask->GetAttachClusters();
644 if (cltask->GetCalibData()!=0)
645 recalibrated = kTRUE;
648 if (1 && !fClusName.IsNull()) {
651 l = AODEvent()->GetList();
653 l = fAodEv->GetList();
655 fAodClusters = dynamic_cast<TClonesArray*>(l->FindObject(fClusName));
659 if (fEsdEv) { // ESD input mode
660 if (1 && (!fRecPoints||clusattached)) {
662 am->LoadBranch("CaloClusters");
663 TList *l = fEsdEv->GetList();
665 fEsdClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
670 am->LoadBranch("EMCALCells.");
671 fEsdCells = fEsdEv->GetEMCALCells();
673 } else if (fAodEv) { // AOD input mode
674 if (1 && (!fAodClusters || clusattached)) {
676 am->LoadBranch("caloClusters");
677 TList *l = fAodEv->GetList();
679 fAodClusters = dynamic_cast<TClonesArray*>(l->FindObject("caloClusters"));
684 am->LoadBranch("emcalCells");
685 fAodCells = fAodEv->GetEMCALCells();
688 AliFatal("Impossible to not have either pointer to ESD or AOD event");
692 AliDebug(2,Form("fRecPoints set: %p", fRecPoints));
693 AliDebug(2,Form("fDigits set: %p", fDigits));
694 AliDebug(2,Form("fEsdClusters set: %p", fEsdClusters));
695 AliDebug(2,Form("fEsdCells set: %p", fEsdCells));
696 AliDebug(2,Form("fAodClusters set: %p", fAodClusters));
697 AliDebug(2,Form("fAodCells set: %p", fAodCells));
701 ClusterAfterburner();
720 fSelPrimTracks->Clear();
726 PostData(1, fOutput);
729 //________________________________________________________________________
730 void AliAnalysisTaskEMCALPi0PbPb::Terminate(Option_t *)
732 // Terminate called at the end of analysis.
735 TFile *f = OpenFile(1);
740 AliInfo(Form("%s: Accepted %lld events ", GetName(), fNEvs));
743 //________________________________________________________________________
744 void AliAnalysisTaskEMCALPi0PbPb::CalcCaloTriggers()
746 // Calculate triggers
749 return; // information not available in AOD
753 AliVCaloCells *cells = fEsdCells;
759 Int_t ncells = cells->GetNumberOfCells();
763 if (ncells>fNAmpInTrigger) {
764 delete [] fAmpInTrigger;
765 fAmpInTrigger = new Float_t[ncells];
766 fNAmpInTrigger = ncells;
768 for (Int_t i=0;i<ncells;++i)
769 fAmpInTrigger[i] = 0;
771 std::map<Short_t,Short_t> map;
772 for (Short_t pos=0;pos<ncells;++pos) {
773 Short_t id = cells->GetCellNumber(pos);
777 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
778 am->LoadBranch("EMCALTrigger.");
780 AliESDCaloTrigger *triggers = fEsdEv->GetCaloTrigger("EMCAL");
783 if (triggers->GetEntries()<=0)
788 while (triggers->Next()) {
789 Int_t gCol=0, gRow=0, ntimes=0;
790 triggers->GetPosition(gCol,gRow);
791 triggers->GetNL0Times(ntimes);
795 triggers->GetAmplitude(amp);
797 fGeom->GetAbsFastORIndexFromPositionInEMCAL(gCol,gRow,find);
800 Int_t cidx[4] = {-1};
801 Bool_t ret = fGeom->GetCellIndexFromFastORIndex(find, cidx);
805 triggers->GetL0Times(trgtimes);
806 Int_t mintime = trgtimes[0];
807 Int_t maxtime = trgtimes[0];
808 Bool_t trigInTimeWindow = 0;
809 for (Int_t i=0;i<ntimes;++i) {
810 if (trgtimes[i]<mintime)
811 mintime = trgtimes[i];
812 if (maxtime<trgtimes[i])
813 maxtime = trgtimes[i];
814 if ((fMinL0Time<=trgtimes[i]) && (fMaxL0Time>=trgtimes[i]))
815 trigInTimeWindow = 1;
818 Double_t tenergy = 0;
821 for (Int_t i=0;i<3;++i) {
823 std::map<Short_t,Short_t>::iterator it = map.find(cidx[i]);
828 if (trigInTimeWindow)
829 fAmpInTrigger[pos] = amp;
830 Float_t eta=-1, phi=-1;
831 fGeom->EtaPhiFromIndex(cidx[i],eta,phi);
832 Double_t en= cells->GetAmplitude(pos);
839 AliStaTrigger *trignew = static_cast<AliStaTrigger*>(fTriggers->New(ntrigs++));
840 trignew->fE = tenergy;
841 trignew->fEta = teta;
842 trignew->fPhi = tphi;
844 trignew->fMinTime = mintime;
845 trignew->fMaxTime = maxtime;
849 //________________________________________________________________________
850 void AliAnalysisTaskEMCALPi0PbPb::CalcClusterProps()
852 // Calculate cluster properties
856 AliVCaloCells *cells = fEsdCells;
862 TObjArray *clusters = fEsdClusters;
864 clusters = fAodClusters;
868 Int_t ncells = cells->GetNumberOfCells();
869 Int_t nclus = clusters->GetEntries();
870 Int_t ntrks = fSelTracks->GetEntries();
871 Bool_t btracks[6][ntrks];
872 memset(btracks,0,sizeof(btracks));
874 std::map<Short_t,Short_t> map;
875 for (Short_t pos=0;pos<ncells;++pos) {
876 Short_t id = cells->GetCellNumber(pos);
880 TObjArray filtMcParts;
882 Int_t nmc = fMcParts->GetEntries();
883 for (Int_t i=0; i<nmc; ++i) {
884 AliStaPart *pa = static_cast<AliStaPart*>(fMcParts->At(i));
890 for(Int_t i=0, ncl=0; i<nclus; ++i) {
891 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
895 if (!clus->IsEMCAL())
900 Float_t clsPos[3] = {0};
901 clus->GetPosition(clsPos);
902 TVector3 clsVec(clsPos);
903 Double_t vertex[3] = {0};
904 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
905 TLorentzVector clusterVec;
906 clus->GetMomentum(clusterVec,vertex);
907 Double_t clsEta = clusterVec.Eta();
909 AliStaCluster *cl = static_cast<AliStaCluster*>(fClusters->New(ncl++));
911 cl->fR = clsVec.Perp();
912 cl->fEta = clsVec.Eta();
913 cl->fPhi = clsVec.Phi();
914 cl->fN = clus->GetNCells();
915 cl->fN1 = GetNCells(clus,0.100);
916 cl->fN3 = GetNCells(clus,0.300);
918 Double_t emax = GetMaxCellEnergy(clus, id);
921 cl->fTmax = cells->GetCellTime(id);
922 if (clus->GetDistanceToBadChannel()<10000)
923 cl->fDbc = clus->GetDistanceToBadChannel();
924 if (!TMath::IsNaN(clus->GetDispersion()))
925 cl->fDisp = clus->GetDispersion();
926 if (!TMath::IsNaN(clus->GetM20()))
927 cl->fM20 = clus->GetM20();
928 if (!TMath::IsNaN(clus->GetM02()))
929 cl->fM02 = clus->GetM02();
930 Double_t maxAxis = 0, minAxis = 0;
931 GetSigma(clus,maxAxis,minAxis);
932 clus->SetTOF(maxAxis); // store sigma in TOF
934 Double_t clusterEcc = 0;
936 clusterEcc = TMath::Sqrt(1.0 - minAxis*minAxis/(maxAxis*maxAxis));
937 clus->SetChi2(clusterEcc); // store ecc in chi2
938 cl->fEcc = clusterEcc;
939 cl->fTrIso = GetTrackIsolation(clusterVec.Eta(),clusterVec.Phi(),fIsoDist);
940 cl->fTrIso1 = GetTrackIsolation(clusterVec.Eta(),clusterVec.Phi(),fIsoDist, 1);
941 cl->fTrIso2 = GetTrackIsolation(clusterVec.Eta(),clusterVec.Phi(),fIsoDist, 2);
942 cl->fCeCore = GetCellIsolation(clsVec.Eta(),clsVec.Phi(),0.05);
943 cl->fCeIso = GetCellIsolation(clsVec.Eta(),clsVec.Phi(),fIsoDist);
945 if (fAmpInTrigger) { // fill trigger info if present
946 Double_t trigpen = 0;
947 Double_t trignen = 0;
948 for(Int_t j=0; j<cl->fN; ++j) {
949 Short_t cid = TMath::Abs(clus->GetCellAbsId(j));
951 std::map<Short_t,Short_t>::iterator it = map.find(cid);
956 if (fAmpInTrigger[pos]>0)
957 trigpen += cells->GetAmplitude(pos);
958 else if (fAmpInTrigger[pos]<0)
959 trignen += cells->GetAmplitude(pos);
963 cl->fTrigE = trigpen;
967 cl->fTrigMaskE = trignen;
970 cl->fIsShared = IsShared(clus);
973 Double_t mind2 = 1e10;
974 for(Int_t j = 0; j<ntrks; ++j) {
975 AliVTrack *track = static_cast<AliVTrack*>(fSelTracks->At(j));
979 if (TMath::Abs(clsEta-track->Eta())>0.5)
982 TVector3 vec(clsPos);
983 Int_t index = (Int_t)(vec.Phi()*TMath::RadToDeg()/20);
984 if (btracks[index-4][j]) {
988 Float_t tmpR=-1, tmpZ=-1;
990 AliExternalTrackParam *tParam = 0;
992 AliESDtrack *esdTrack = static_cast<AliESDtrack*>(track);
993 tParam = new AliExternalTrackParam(*esdTrack->GetTPCInnerParam());
995 tParam = new AliExternalTrackParam(track);
997 Double_t bfield[3] = {0};
998 track->GetBxByBz(bfield);
999 Double_t alpha = (index+0.5)*20*TMath::DegToRad();
1000 vec.RotateZ(-alpha); //Rotate the cluster to the local extrapolation coordinate system
1001 tParam->Rotate(alpha); //Rotate the track to the same local extrapolation system
1002 Bool_t ret = tParam->PropagateToBxByBz(vec.X(), bfield);
1004 btracks[index-4][j]=1;
1008 Double_t trkPos[3] = {0};
1009 tParam->GetXYZ(trkPos); //Get the extrapolated global position
1010 tmpR = TMath::Sqrt( TMath::Power(clsPos[0]-trkPos[0],2) +
1011 TMath::Power(clsPos[1]-trkPos[1],2) +
1012 TMath::Power(clsPos[2]-trkPos[2],2) );
1013 tmpZ = clsPos[2]-trkPos[2];
1016 if (TMath::Abs(clsEta-track->Eta())>fIsoDist)
1018 AliExternalTrackParam tParam(track);
1019 if (!fReco->ExtrapolateTrackToCluster(&tParam, clus, tmpR, tmpZ))
1027 cl->fTrDr = TMath::Sqrt(tmpR*tmpR-tmpZ*tmpZ);
1028 cl->fTrEp = clus->E()/track->P();
1033 if (cl->fIsTrackM) {
1034 fHMatchDr->Fill(cl->fTrDr);
1035 fHMatchDz->Fill(cl->fTrDz);
1036 fHMatchEp->Fill(cl->fTrEp);
1041 Int_t nmc = filtMcParts.GetEntries();
1042 Double_t diffR2 = 1e9;
1043 AliStaPart *msta = 0;
1044 for (Int_t j=0; j<nmc; ++j) {
1045 AliStaPart *pa = static_cast<AliStaPart*>(filtMcParts.At(j));
1046 Double_t t1=clsVec.Eta()-pa->fVEta;
1047 Double_t t2=TVector2::Phi_mpi_pi(clsVec.Phi()-pa->fVPhi);
1048 Double_t tmp = t1*t1+t2*t2;
1054 if (diffR2<10 && msta!=0) {
1055 cl->fMcLabel = msta->fLab;
1060 if (fDigits && fEmbedMode) {
1061 for(Int_t j=0; j<cl->fN; ++j) {
1062 Short_t cid = TMath::Abs(clus->GetCellAbsId(j));
1064 std::map<Short_t,Short_t>::iterator it = map.find(cid);
1069 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigits->At(pos));
1072 if (digit->GetId() != cid) {
1073 AliError(Form("Ids should be equal: %d %d", cid, digit->GetId()));
1076 if (digit->GetType()<-1) {
1077 cl->fEmbE += digit->GetChi2();
1084 //________________________________________________________________________
1085 void AliAnalysisTaskEMCALPi0PbPb::CalcPrimTracks()
1087 // Calculate track properties.
1089 fSelPrimTracks->Clear();
1091 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
1092 TClonesArray *tracks = 0;
1094 am->LoadBranch("Tracks");
1095 TList *l = fEsdEv->GetList();
1096 tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
1098 am->LoadBranch("tracks");
1099 TList *l = fAodEv->GetList();
1100 tracks = dynamic_cast<TClonesArray*>(l->FindObject("tracks"));
1106 AliEMCALEMCGeometry *emc = fGeom->GetEMCGeometry();
1107 Double_t phimin = emc->GetArm1PhiMin()*TMath::DegToRad()-fIsoDist*1.25;
1108 Double_t phimax = emc->GetArm1PhiMax()*TMath::DegToRad()+fIsoDist*1.25;
1111 fSelPrimTracks->SetOwner(kTRUE);
1112 am->LoadBranch("PrimaryVertex.");
1113 const AliESDVertex *vtx = fEsdEv->GetPrimaryVertexSPD();
1114 am->LoadBranch("SPDVertex.");
1115 const AliESDVertex *vtxSPD = fEsdEv->GetPrimaryVertexSPD();
1116 am->LoadBranch("Tracks");
1117 const Int_t Ntracks = tracks->GetEntries();
1118 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
1119 AliESDtrack *track = static_cast<AliESDtrack*>(tracks->At(iTracks));
1121 AliWarning(Form("Could not receive track %d\n", iTracks));
1124 if (fTrCuts && !fTrCuts->IsSelected(track))
1126 Double_t eta = track->Eta();
1129 if (track->Phi()<phimin||track->Phi()>phimax)
1132 AliESDtrack copyt(*track);
1134 copyt.GetBxByBz(bfield);
1135 AliExternalTrackParam tParam;
1136 Bool_t relate = copyt.RelateToVertexBxByBz(vtxSPD,bfield,kVeryBig,&tParam);
1139 copyt.Set(tParam.GetX(),tParam.GetAlpha(),tParam.GetParameter(),tParam.GetCovariance());
1141 Double_t p[3] = { 0. };
1143 Double_t pos[3] = { 0. };
1145 Double_t covTr[21] = { 0. };
1146 copyt.GetCovarianceXYZPxPyPz(covTr);
1147 Double_t pid[10] = { 0. };
1148 copyt.GetESDpid(pid);
1149 AliAODTrack *aTrack = new AliAODTrack(copyt.GetID(),
1156 (Short_t)copyt.GetSign(),
1157 copyt.GetITSClusterMap(),
1159 0,/*fPrimaryVertex,*/
1160 kTRUE, // check if this is right
1161 vtx->UsesTrack(copyt.GetID()));
1162 aTrack->SetTPCClusterMap(copyt.GetTPCClusterMap());
1163 aTrack->SetTPCSharedMap (copyt.GetTPCSharedMap());
1164 Float_t ndf = copyt.GetTPCNcls() + 1 - 5 ;
1166 aTrack->SetChi2perNDF(copyt.GetTPCchi2()/ndf);
1168 aTrack->SetChi2perNDF(-1);
1169 aTrack->SetFlags(copyt.GetStatus());
1170 aTrack->SetTPCPointsF(copyt.GetTPCNclsF());
1171 fSelPrimTracks->Add(aTrack);
1174 Int_t ntracks = tracks->GetEntries();
1175 for (Int_t i=0; i<ntracks; ++i) {
1176 AliAODTrack *track = static_cast<AliAODTrack*>(tracks->At(i));
1179 Double_t eta = track->Eta();
1182 if (track->Phi()<phimin||track->Phi()>phimax)
1184 if(track->GetTPCNcls()<fMinNClusPerTr)
1186 //todo: Learn how to set/filter AODs for prim/sec tracks
1187 fSelPrimTracks->Add(track);
1192 //________________________________________________________________________
1193 void AliAnalysisTaskEMCALPi0PbPb::CalcTracks()
1195 // Calculate track properties (including secondaries).
1197 fSelTracks->Clear();
1199 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
1200 TClonesArray *tracks = 0;
1202 am->LoadBranch("Tracks");
1203 TList *l = fEsdEv->GetList();
1204 tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
1206 am->LoadBranch("tracks");
1207 TList *l = fAodEv->GetList();
1208 tracks = dynamic_cast<TClonesArray*>(l->FindObject("tracks"));
1215 const Int_t Ntracks = tracks->GetEntries();
1216 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
1217 AliESDtrack *track = static_cast<AliESDtrack*>(tracks->At(iTracks));
1219 AliWarning(Form("Could not receive track %d\n", iTracks));
1222 if (fTrCuts && !fTrCuts->IsSelected(track))
1224 Double_t eta = track->Eta();
1227 fSelTracks->Add(track);
1230 Int_t ntracks = tracks->GetEntries();
1231 for (Int_t i=0; i<ntracks; ++i) {
1232 AliAODTrack *track = static_cast<AliAODTrack*>(tracks->At(i));
1235 Double_t eta = track->Eta();
1238 if(track->GetTPCNcls()<fMinNClusPerTr)
1241 if (0 && (track->Pt()>=0.6) && (track->PxAtDCA()==-999)) { // compute position on EMCAL
1242 AliExternalTrackParam tParam(track);
1243 if (AliTrackerBase::PropagateTrackToBxByBz(&tParam, 438, 0.139, 1, kTRUE)) {
1245 tParam.GetXYZ(trkPos);
1246 track->SetPxPyPzAtDCA(trkPos[0],trkPos[1],trkPos[2]);
1249 fSelTracks->Add(track);
1254 //________________________________________________________________________
1255 void AliAnalysisTaskEMCALPi0PbPb::ClusterAfterburner()
1257 // Run custer reconstruction afterburner.
1259 AliVCaloCells *cells = fEsdCells;
1266 Int_t ncells = cells->GetNumberOfCells();
1270 Double_t cellMeanE = 0, cellSigE = 0;
1271 for (Int_t i = 0; i<ncells; ++i) {
1272 Double_t cellE = cells->GetAmplitude(i);
1274 cellSigE += cellE*cellE;
1276 cellMeanE /= ncells;
1278 cellSigE -= cellMeanE*cellMeanE;
1281 cellSigE = TMath::Sqrt(cellSigE / ncells);
1283 Double_t subE = cellMeanE - 7*cellSigE;
1287 for (Int_t i = 0; i<ncells; ++i) {
1289 Double_t amp=0,time=0;
1290 if (!cells->GetCell(i, id, amp, time))
1295 cells->SetCell(i, id, amp, time);
1298 TObjArray *clusters = fEsdClusters;
1300 clusters = fAodClusters;
1304 Int_t nclus = clusters->GetEntries();
1305 for (Int_t i = 0; i<nclus; ++i) {
1306 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
1307 if (!clus->IsEMCAL())
1309 Int_t nc = clus->GetNCells();
1311 UShort_t ids[100] = {0};
1312 Double_t fra[100] = {0};
1313 for (Int_t j = 0; j<nc; ++j) {
1314 Short_t id = TMath::Abs(clus->GetCellAbsId(j));
1315 Double_t cen = cells->GetCellAmplitude(id);
1323 clusters->RemoveAt(i);
1327 for (Int_t j = 0; j<nc; ++j) {
1328 Short_t id = ids[j];
1329 Double_t cen = cells->GetCellAmplitude(id);
1333 AliAODCaloCluster *aodclus = dynamic_cast<AliAODCaloCluster*>(clus);
1336 aodclus->SetNCells(nc);
1337 aodclus->SetCellsAmplitudeFraction(fra);
1338 aodclus->SetCellsAbsId(ids);
1341 clusters->Compress();
1344 //________________________________________________________________________
1345 void AliAnalysisTaskEMCALPi0PbPb::FillCellHists()
1347 // Fill histograms related to cell properties.
1349 AliVCaloCells *cells = fEsdCells;
1356 Int_t cellModCount[12] = {0};
1357 Double_t cellMaxE = 0;
1358 Double_t cellMeanE = 0;
1359 Int_t ncells = cells->GetNumberOfCells();
1363 Int_t nsm = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
1365 for (Int_t i = 0; i<ncells; ++i) {
1366 Int_t absID = TMath::Abs(cells->GetCellNumber(i));
1367 Double_t cellE = cells->GetAmplitude(i);
1368 fHCellE->Fill(cellE);
1373 Int_t iSM=-1, iTower=-1, nIphi=-1, nIeta=-1;
1374 Bool_t ret = fGeom->GetCellIndex(absID, iSM, iTower, nIphi, nIeta);
1376 AliError(Form("Could not get cell index for %d", absID));
1379 ++cellModCount[iSM];
1380 Int_t iPhi=-1, iEta=-1;
1381 fGeom->GetCellPhiEtaIndexInSModule(iSM, iTower, nIphi, nIeta, iPhi, iEta);
1382 fHColuRow[iSM]->Fill(iEta,iPhi,1);
1383 fHColuRowE[iSM]->Fill(iEta,iPhi,cellE);
1384 fHCellFreqNoCut[iSM]->Fill(absID);
1385 if (cellE > 0.1) fHCellFreqCut100M[iSM]->Fill(absID);
1386 if (cellE > 0.3) fHCellFreqCut300M[iSM]->Fill(absID);
1387 if (fHCellCheckE && fHCellCheckE[absID])
1388 fHCellCheckE[absID]->Fill(cellE);
1389 fHCellFreqE[iSM]->Fill(absID, cellE);
1391 fHCellH->Fill(cellMaxE);
1392 cellMeanE /= ncells;
1393 fHCellM->Fill(cellMeanE);
1394 fHCellM2->Fill(cellMeanE*ncells/24/48/nsm);
1395 for (Int_t i=0; i<nsm; ++i)
1396 fHCellMult[i]->Fill(cellModCount[i]);
1399 //________________________________________________________________________
1400 void AliAnalysisTaskEMCALPi0PbPb::FillClusHists()
1402 // Fill histograms related to cluster properties.
1404 TObjArray *clusters = fEsdClusters;
1406 clusters = fAodClusters;
1410 Double_t vertex[3] = {0};
1411 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1413 Int_t nclus = clusters->GetEntries();
1414 for(Int_t i = 0; i<nclus; ++i) {
1415 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
1418 if (!clus->IsEMCAL())
1420 TLorentzVector clusterVec;
1421 clus->GetMomentum(clusterVec,vertex);
1422 Double_t maxAxis = clus->GetTOF(); //sigma
1423 Double_t clusterEcc = clus->Chi2(); //eccentricity
1424 fHClustEccentricity->Fill(clusterEcc);
1425 fHClustEtaPhi->Fill(clusterVec.Eta(),clusterVec.Phi());
1426 fHClustEnergyPt->Fill(clusterVec.E(),clusterVec.Pt());
1427 fHClustEnergySigma->Fill(clus->E()*maxAxis,clus->E());
1428 fHClustSigmaSigma->Fill(max(clus->GetM02(),clus->GetM20()),clus->E()*maxAxis);
1429 fHClustNCellEnergyRatio->Fill(clus->GetNCells(),GetMaxCellEnergy(clus)/clus->E());
1431 fHClustEnergyNCell->Fill(clus->E(),clus->GetNCells());
1435 //________________________________________________________________________
1436 void AliAnalysisTaskEMCALPi0PbPb::CalcMcInfo()
1438 // Get Mc truth particle information.
1445 AliEMCALEMCGeometry *emc = fGeom->GetEMCGeometry();
1446 Double_t etamin = -0.7;
1447 Double_t etamax = +0.7;
1448 Double_t phimin = emc->GetArm1PhiMin()*TMath::DegToRad();
1449 Double_t phimax = emc->GetArm1PhiMax()*TMath::DegToRad();
1452 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
1453 am->LoadBranch(AliAODMCParticle::StdBranchName());
1454 TClonesArray *tca = dynamic_cast<TClonesArray*>(fAodEv->FindListObject(AliAODMCParticle::StdBranchName()));
1458 Int_t nents = tca->GetEntries();
1459 for(int it=0; it<nents; ++it) {
1460 AliAODMCParticle *part = static_cast<AliAODMCParticle*>(tca->At(it));
1463 // pion or eta meson or direct photon
1464 if(part->GetPdgCode() == 111) {
1465 } else if(part->GetPdgCode() == 221) {
1466 } else if(part->GetPdgCode() == 22 ) {
1471 if(part->GetMother()>=0 && part->GetMother()<nents)
1473 Double_t dR = TMath::Sqrt((part->Xv()*part->Xv())+(part->Yv()*part->Yv()));
1478 Double_t pt = part->Pt() ;
1481 Double_t eta = part->Eta();
1482 if (eta<etamin||eta>etamax)
1484 Double_t phi = part->Phi();
1485 if (phi<phimin||phi>phimax)
1488 ProcessDaughters(part, it, tca);
1493 AliMCEvent *mcEvent = MCEvent();
1497 const AliVVertex *evtVtx = mcEvent->GetPrimaryVertex();
1501 mcEvent->PreReadAll();
1503 Int_t nTracks = mcEvent->GetNumberOfPrimaries();
1504 for (Int_t iTrack = 0; iTrack<nTracks; ++iTrack) {
1505 AliMCParticle *mcP = static_cast<AliMCParticle*>(mcEvent->GetTrack(iTrack));
1509 // pion or eta meson or direct photon
1510 if(mcP->PdgCode() == 111) {
1511 } else if(mcP->PdgCode() == 221) {
1512 } else if(mcP->PdgCode() == 22 ) {
1517 if(mcP->GetMother()>=0 && mcP->GetMother()<nTracks)
1519 Double_t dR = TMath::Sqrt((mcP->Xv()-evtVtx->GetX())*(mcP->Xv()-evtVtx->GetX()) +
1520 (mcP->Yv()-evtVtx->GetY())*(mcP->Yv()-evtVtx->GetY()));
1525 Double_t pt = mcP->Pt() ;
1528 Double_t eta = mcP->Eta();
1529 if (eta<etamin||eta>etamax)
1531 Double_t phi = mcP->Phi();
1532 if (phi<phimin||phi>phimax)
1535 ProcessDaughters(mcP, iTrack, mcEvent);
1539 //________________________________________________________________________
1540 void AliAnalysisTaskEMCALPi0PbPb::FillNtuple()
1547 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
1549 fHeader->fRun = fAodEv->GetRunNumber();
1550 fHeader->fOrbit = fAodEv->GetHeader()->GetOrbitNumber();
1551 fHeader->fPeriod = fAodEv->GetHeader()->GetPeriodNumber();
1552 fHeader->fBx = fAodEv->GetHeader()->GetBunchCrossNumber();
1553 fHeader->fL0 = fAodEv->GetHeader()->GetL0TriggerInputs();
1554 fHeader->fL1 = fAodEv->GetHeader()->GetL1TriggerInputs();
1555 fHeader->fL2 = fAodEv->GetHeader()->GetL2TriggerInputs();
1556 fHeader->fTrClassMask = fAodEv->GetHeader()->GetTriggerMask();
1557 fHeader->fTrCluster = fAodEv->GetHeader()->GetTriggerCluster();
1558 fHeader->fOffTriggers = fAodEv->GetHeader()->GetOfflineTrigger();
1559 fHeader->fFiredTriggers = fAodEv->GetHeader()->GetFiredTriggerClasses();
1561 fHeader->fRun = fEsdEv->GetRunNumber();
1562 fHeader->fOrbit = fEsdEv->GetHeader()->GetOrbitNumber();
1563 fHeader->fPeriod = fEsdEv->GetESDRun()->GetPeriodNumber();
1564 fHeader->fBx = fEsdEv->GetHeader()->GetBunchCrossNumber();
1565 fHeader->fL0 = fEsdEv->GetHeader()->GetL0TriggerInputs();
1566 fHeader->fL1 = fEsdEv->GetHeader()->GetL1TriggerInputs();
1567 fHeader->fL2 = fEsdEv->GetHeader()->GetL2TriggerInputs();
1568 fHeader->fTrClassMask = fEsdEv->GetHeader()->GetTriggerMask();
1569 fHeader->fTrCluster = fEsdEv->GetHeader()->GetTriggerCluster();
1570 fHeader->fOffTriggers = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
1571 fHeader->fFiredTriggers = fEsdEv->GetFiredTriggerClasses();
1572 Float_t v0CorrR = 0;
1573 fHeader->fV0 = AliESDUtils::GetCorrV0(fEsdEv,v0CorrR);
1574 const AliMultiplicity *mult = fEsdEv->GetMultiplicity();
1576 fHeader->fCl1 = mult->GetNumberOfITSClusters(1);
1577 fHeader->fTr = AliESDtrackCuts::GetReferenceMultiplicity(fEsdEv,1);
1579 AliCentrality *cent = InputEvent()->GetCentrality();
1580 fHeader->fV0Cent = cent->GetCentralityPercentileUnchecked("V0M");
1581 fHeader->fCl1Cent = cent->GetCentralityPercentileUnchecked("CL1");
1582 fHeader->fTrCent = cent->GetCentralityPercentileUnchecked("TRK");
1583 fHeader->fCqual = cent->GetQuality();
1585 AliEventplane *ep = InputEvent()->GetEventplane();
1587 if (ep->GetQVector())
1588 fHeader->fPsi = ep->GetQVector()->Phi()/2. ;
1591 if (ep->GetQsub1()&&ep->GetQsub2())
1592 fHeader->fPsiRes = ep->GetQsub1()->Phi()/2.-ep->GetQsub2()->Phi()/2.;
1594 fHeader->fPsiRes = 0;
1598 TString trgclasses(fHeader->fFiredTriggers);
1599 for (Int_t j = 0; j<fTrClassNamesArr->GetEntries(); ++j) {
1600 const char *name = fTrClassNamesArr->At(j)->GetName();
1601 if (trgclasses.Contains(name))
1602 val += TMath::Power(2,j);
1604 fHeader->fTcls = (UInt_t)val;
1606 fHeader->fNSelTr = fSelTracks->GetEntries();
1607 fHeader->fNSelPrimTr = fSelPrimTracks->GetEntries();
1608 fHeader->fNSelPrimTr1 = 0;
1609 fHeader->fNSelPrimTr2 = 0;
1610 for(int iTracks=0; iTracks < fSelPrimTracks->GetEntries(); iTracks++){
1611 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(iTracks));
1613 ++fHeader->fNSelPrimTr1;
1615 ++fHeader->fNSelPrimTr2;
1618 fHeader->fNCells = 0;
1619 fHeader->fNCells1 = 0;
1620 fHeader->fNCells2 = 0;
1621 fHeader->fNCells5 = 0;
1622 fHeader->fMaxCellE = 0;
1624 AliVCaloCells *cells = fEsdCells;
1629 Int_t ncells = cells->GetNumberOfCells();
1630 for(Int_t j=0; j<ncells; ++j) {
1631 Double_t cellen = cells->GetAmplitude(j);
1633 ++fHeader->fNCells1;
1635 ++fHeader->fNCells2;
1637 ++fHeader->fNCells5;
1638 if (cellen>fHeader->fMaxCellE)
1639 fHeader->fMaxCellE = cellen;
1641 fHeader->fNCells = ncells;
1644 fHeader->fNClus = 0;
1645 fHeader->fNClus1 = 0;
1646 fHeader->fNClus2 = 0;
1647 fHeader->fNClus5 = 0;
1648 fHeader->fMaxClusE = 0;
1650 TObjArray *clusters = fEsdClusters;
1652 clusters = fAodClusters;
1655 Int_t nclus = clusters->GetEntries();
1656 for(Int_t j=0; j<nclus; ++j) {
1657 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(j));
1658 if (!clus->IsEMCAL())
1660 Double_t clusen = clus->E();
1667 if (clusen>fHeader->fMaxClusE)
1668 fHeader->fMaxClusE = clusen;
1670 fHeader->fNClus = nclus;
1674 am->LoadBranch("vertices");
1675 AliAODVertex *pv = fAodEv->GetPrimaryVertex();
1676 FillVertex(fPrimVert, pv);
1677 AliAODVertex *sv = fAodEv->GetPrimaryVertexSPD();
1678 FillVertex(fSpdVert, sv);
1680 am->LoadBranch("PrimaryVertex.");
1681 const AliESDVertex *pv = fEsdEv->GetPrimaryVertexTracks();
1682 FillVertex(fPrimVert, pv);
1683 am->LoadBranch("SPDVertex.");
1684 const AliESDVertex *sv = fEsdEv->GetPrimaryVertexSPD();
1685 FillVertex(fSpdVert, sv);
1686 am->LoadBranch("TPCVertex.");
1687 const AliESDVertex *tv = fEsdEv->GetPrimaryVertexTPC();
1688 FillVertex(fTpcVert, tv);
1694 //________________________________________________________________________
1695 void AliAnalysisTaskEMCALPi0PbPb::FillPionHists()
1697 // Fill histograms related to pions.
1699 Double_t vertex[3] = {0};
1700 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1702 TObjArray *clusters = fEsdClusters;
1704 clusters = fAodClusters;
1707 TLorentzVector clusterVec1;
1708 TLorentzVector clusterVec2;
1709 TLorentzVector pionVec;
1711 Int_t nclus = clusters->GetEntries();
1712 for (Int_t i = 0; i<nclus; ++i) {
1713 AliVCluster *clus1 = static_cast<AliVCluster*>(clusters->At(i));
1716 if (!clus1->IsEMCAL())
1718 if (clus1->E()<fMinE)
1720 if (clus1->GetNCells()<fNminCells)
1722 if (GetMaxCellEnergy(clus1)/clus1->E()<fMinErat)
1724 if (clus1->Chi2()<fMinEcc) // eccentricity cut
1726 clus1->GetMomentum(clusterVec1,vertex);
1727 for (Int_t j = i+1; j<nclus; ++j) {
1728 AliVCluster *clus2 = static_cast<AliVCluster*>(clusters->At(j));
1731 if (!clus2->IsEMCAL())
1733 if (clus2->E()<fMinE)
1735 if (clus2->GetNCells()<fNminCells)
1737 if (GetMaxCellEnergy(clus2)/clus2->E()<fMinErat)
1739 if (clus2->Chi2()<fMinEcc) // eccentricity cut
1741 clus2->GetMomentum(clusterVec2,vertex);
1742 pionVec = clusterVec1 + clusterVec2;
1743 Double_t pionZgg = TMath::Abs(clusterVec1.E()-clusterVec2.E())/pionVec.E();
1744 Double_t pionOpeningAngle = clusterVec1.Angle(clusterVec2.Vect());
1745 if (pionZgg < fAsymMax) {
1746 fHPionEtaPhi->Fill(pionVec.Eta(),pionVec.Phi());
1747 fHPionMggPt->Fill(pionVec.M(),pionVec.Pt());
1748 fHPionMggAsym->Fill(pionVec.M(),pionZgg);
1749 fHPionMggDgg->Fill(pionVec.M(),pionOpeningAngle);
1750 Int_t bin = fPtRanges->FindBin(pionVec.Pt());
1751 fHPionInvMasses[bin]->Fill(pionVec.M());
1758 //________________________________________________________________________
1759 void AliAnalysisTaskEMCALPi0PbPb::FillMcHists()
1761 // Fill additional MC information histograms.
1766 // check if aod or esd mc mode and the fill histos
1769 //________________________________________________________________________
1770 void AliAnalysisTaskEMCALPi0PbPb::FillOtherHists()
1772 // Fill other histograms.
1774 for(int iTracks=0; iTracks < fSelPrimTracks->GetEntries(); ++iTracks){
1775 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(iTracks));
1778 fHPrimTrackPt->Fill(track->Pt());
1779 fHPrimTrackEta->Fill(track->Eta());
1780 fHPrimTrackPhi->Fill(track->Phi());
1784 //________________________________________________________________________
1785 void AliAnalysisTaskEMCALPi0PbPb::FillTrackHists()
1787 // Fill track histograms.
1789 if (fSelPrimTracks) {
1790 for(int iTracks=0; iTracks < fSelPrimTracks->GetEntries(); iTracks++) {
1791 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(iTracks));
1794 fHPrimTrackPt->Fill(track->Pt());
1795 fHPrimTrackEta->Fill(track->Eta());
1796 fHPrimTrackPhi->Fill(track->Phi());
1801 //__________________________________________________________________________________________________
1802 void AliAnalysisTaskEMCALPi0PbPb::FillVertex(AliStaVertex *v, const AliESDVertex *esdv)
1804 // Fill vertex from ESD vertex info.
1806 v->fVx = esdv->GetX();
1807 v->fVy = esdv->GetY();
1808 v->fVz = esdv->GetZ();
1809 v->fVc = esdv->GetNContributors();
1810 v->fDisp = esdv->GetDispersion();
1811 v->fZres = esdv->GetZRes();
1812 v->fChi2 = esdv->GetChi2();
1813 v->fSt = esdv->GetStatus();
1814 v->fIs3D = esdv->IsFromVertexer3D();
1815 v->fIsZ = esdv->IsFromVertexerZ();
1818 //__________________________________________________________________________________________________
1819 void AliAnalysisTaskEMCALPi0PbPb::FillVertex(AliStaVertex *v, const AliAODVertex *aodv)
1821 // Fill vertex from AOD vertex info.
1823 v->fVx = aodv->GetX();
1824 v->fVy = aodv->GetY();
1825 v->fVz = aodv->GetZ();
1826 v->fVc = aodv->GetNContributors();
1827 v->fChi2 = aodv->GetChi2();
1830 //________________________________________________________________________
1831 Double_t AliAnalysisTaskEMCALPi0PbPb::GetCellIsolation(Double_t cEta, Double_t cPhi, Double_t radius) const
1833 // Compute isolation based on cell content.
1835 AliVCaloCells *cells = fEsdCells;
1841 Double_t cellIsolation = 0;
1842 Double_t rad2 = radius*radius;
1843 Int_t ncells = cells->GetNumberOfCells();
1844 for (Int_t i = 0; i<ncells; ++i) {
1845 Int_t absID = TMath::Abs(cells->GetCellNumber(i));
1846 Float_t eta=-1, phi=-1;
1847 fGeom->EtaPhiFromIndex(absID,eta,phi);
1848 Double_t phidiff = TVector2::Phi_mpi_pi(phi-cPhi);
1849 Double_t dist = (eta-cEta)*(eta-cEta)+phidiff*phidiff;
1852 Double_t cellE = cells->GetAmplitude(i);
1853 cellIsolation += cellE;
1855 return cellIsolation;
1858 //________________________________________________________________________
1859 Double_t AliAnalysisTaskEMCALPi0PbPb::GetCellEnergy(const AliVCluster *cluster) const
1861 // Get maximum energy of attached cell.
1864 Int_t ncells = cluster->GetNCells();
1866 for (Int_t i=0; i<ncells; i++) {
1867 Double_t e = fEsdCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1871 for (Int_t i=0; i<ncells; i++) {
1872 Double_t e = fAodCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1879 //________________________________________________________________________
1880 Double_t AliAnalysisTaskEMCALPi0PbPb::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
1882 // Get maximum energy of attached cell.
1886 Int_t ncells = cluster->GetNCells();
1888 for (Int_t i=0; i<ncells; i++) {
1889 Double_t e = fEsdCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1892 id = cluster->GetCellAbsId(i);
1896 for (Int_t i=0; i<ncells; i++) {
1897 Double_t e = fAodCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1900 id = cluster->GetCellAbsId(i);
1906 //________________________________________________________________________
1907 void AliAnalysisTaskEMCALPi0PbPb::GetSigma(const AliVCluster *c, Double_t& sigmaMax, Double_t &sigmaMin) const
1909 // Calculate the (E) weighted variance along the longer (eigen) axis.
1911 sigmaMax = 0; // cluster variance along its longer axis
1912 sigmaMin = 0; // cluster variance along its shorter axis
1913 Double_t Ec = c->E(); // cluster energy
1916 Double_t Xc = 0 ; // cluster first moment along X
1917 Double_t Yc = 0 ; // cluster first moment along Y
1918 Double_t Sxx = 0 ; // cluster second central moment along X (variance_X^2)
1919 Double_t Sxy = 0 ; // cluster second central moment along Y (variance_Y^2)
1920 Double_t Syy = 0 ; // cluster covariance^2
1922 AliVCaloCells *cells = fEsdCells;
1929 Int_t ncells = c->GetNCells();
1933 for(Int_t j=0; j<ncells; ++j) {
1934 Int_t id = TMath::Abs(c->GetCellAbsId(j));
1935 Double_t cellen = cells->GetCellAmplitude(id);
1937 fGeom->GetGlobal(id,pos);
1938 Xc += cellen*pos.X();
1939 Yc += cellen*pos.Y();
1940 Sxx += cellen*pos.X()*pos.X();
1941 Syy += cellen*pos.Y()*pos.Y();
1942 Sxy += cellen*pos.X()*pos.Y();
1952 Sxx = TMath::Abs(Sxx);
1953 Syy = TMath::Abs(Syy);
1954 sigmaMax = (Sxx + Syy + TMath::Sqrt(TMath::Abs((Sxx-Syy)*(Sxx-Syy)+4.0*Sxy*Sxy)))/2.0;
1955 sigmaMax = TMath::Sqrt(TMath::Abs(sigmaMax));
1956 sigmaMin = TMath::Abs(Sxx + Syy - TMath::Sqrt(TMath::Abs((Sxx-Syy)*(Sxx-Syy)+4.0*Sxy*Sxy)))/2.0;
1957 sigmaMin = TMath::Sqrt(TMath::Abs(sigmaMin));
1960 //________________________________________________________________________
1961 Int_t AliAnalysisTaskEMCALPi0PbPb::GetNCells(const AliVCluster *c, Double_t emin) const
1963 // Calculate number of attached cells above emin.
1965 AliVCaloCells *cells = fEsdCells;
1972 Int_t ncells = c->GetNCells();
1973 for(Int_t j=0; j<ncells; ++j) {
1974 Int_t id = TMath::Abs(c->GetCellAbsId(j));
1975 Double_t cellen = cells->GetCellAmplitude(id);
1982 //________________________________________________________________________
1983 Double_t AliAnalysisTaskEMCALPi0PbPb::GetTrackIsolation(Double_t cEta, Double_t cPhi, Double_t radius, Double_t pt) const
1985 // Compute isolation based on tracks.
1987 Double_t trkIsolation = 0;
1988 Double_t rad2 = radius*radius;
1989 Int_t ntrks = fSelPrimTracks->GetEntries();
1990 for(Int_t j = 0; j<ntrks; ++j) {
1991 AliVTrack *track = static_cast<AliVTrack*>(fSelTracks->At(j));
1996 Float_t eta = track->Eta();
1997 Float_t phi = track->Phi();
1998 Double_t phidiff = TVector2::Phi_mpi_pi(phi-cPhi);
1999 Double_t dist = (eta-cEta)*(eta-cEta)+phidiff*phidiff;
2002 trkIsolation += track->Pt();
2004 return trkIsolation;
2007 //________________________________________________________________________
2008 Bool_t AliAnalysisTaskEMCALPi0PbPb::IsShared(const AliVCluster *c) const
2010 // Returns if cluster shared across super modules.
2012 AliVCaloCells *cells = fEsdCells;
2019 Int_t ncells = c->GetNCells();
2020 for(Int_t j=0; j<ncells; ++j) {
2021 Int_t id = TMath::Abs(c->GetCellAbsId(j));
2022 Int_t got = id / (24*48);
2033 //________________________________________________________________________
2034 void AliAnalysisTaskEMCALPi0PbPb::PrintDaughters(const AliVParticle *p, const TObjArray *arr, Int_t level) const
2036 // Print recursively daughter information.
2041 const AliAODMCParticle *amc = dynamic_cast<const AliAODMCParticle*>(p);
2044 for (Int_t i=0; i<level; ++i) printf(" ");
2047 Int_t n = amc->GetNDaughters();
2048 for (Int_t i=0; i<n; ++i) {
2049 Int_t d = amc->GetDaughter(i);
2050 const AliVParticle *dmc = static_cast<const AliVParticle*>(arr->At(d));
2051 PrintDaughters(dmc,arr,level+1);
2055 //________________________________________________________________________
2056 void AliAnalysisTaskEMCALPi0PbPb::PrintDaughters(const AliMCParticle *p, const AliMCEvent *arr, Int_t level) const
2058 // Print recursively daughter information.
2063 for (Int_t i=0; i<level; ++i) printf(" ");
2064 Int_t d1 = p->GetFirstDaughter();
2065 Int_t d2 = p->GetLastDaughter();
2066 printf("pid=%d: %.2f %.2f %.2f (%.2f %.2f %.2f); nd=%d,%d\n",
2067 p->PdgCode(),p->Px(),p->Py(),p->Pz(),p->Xv(),p->Yv(),p->Zv(),d1,d2);
2072 for (Int_t i=d1;i<=d2;++i) {
2073 const AliMCParticle *dmc = static_cast<const AliMCParticle *>(arr->GetTrack(i));
2074 PrintDaughters(dmc,arr,level+1);
2078 //________________________________________________________________________
2079 void AliAnalysisTaskEMCALPi0PbPb::PrintTrackRefs(AliMCParticle *p) const
2081 // Print track ref array.
2086 Int_t n = p->GetNumberOfTrackReferences();
2087 for (Int_t i=0; i<n; ++i) {
2088 AliTrackReference *ref = p->GetTrackReference(i);
2091 ref->SetUserId(ref->DetectorId());
2096 //________________________________________________________________________
2097 void AliAnalysisTaskEMCALPi0PbPb::ProcessDaughters(AliVParticle *p, Int_t index, const TObjArray *arr)
2099 // Process and create daughters.
2104 AliAODMCParticle *amc = dynamic_cast<AliAODMCParticle*>(p);
2110 Int_t nparts = arr->GetEntries();
2111 Int_t nents = fMcParts->GetEntries();
2113 AliStaPart *newp = static_cast<AliStaPart*>(fMcParts->New(nents));
2114 newp->fPt = amc->Pt();
2115 newp->fEta = amc->Eta();
2116 newp->fPhi = amc->Phi();
2117 if (amc->Xv() != 0 || amc->Yv() != 0 || amc->Zv() != 0) {
2118 TVector3 vec(amc->Xv(),amc->Yv(),amc->Zv());
2119 newp->fVR = vec.Perp();
2120 newp->fVEta = vec.Eta();
2121 newp->fVPhi = vec.Phi();
2123 newp->fPid = amc->PdgCode();
2125 Int_t moi = amc->GetMother();
2126 if (moi>=0&&moi<nparts) {
2127 const AliAODMCParticle *mmc = static_cast<const AliAODMCParticle*>(arr->At(moi));
2128 moi = mmc->GetUniqueID();
2131 p->SetUniqueID(nents);
2133 // TODO: Determine which detector was hit
2136 Int_t n = amc->GetNDaughters();
2137 for (Int_t i=0; i<n; ++i) {
2138 Int_t d = amc->GetDaughter(i);
2139 if (d<=index || d>=nparts)
2141 AliVParticle *dmc = static_cast<AliVParticle*>(arr->At(d));
2142 ProcessDaughters(dmc,d,arr);
2146 //________________________________________________________________________
2147 void AliAnalysisTaskEMCALPi0PbPb::ProcessDaughters(AliMCParticle *p, Int_t index, const AliMCEvent *arr)
2149 // Process and create daughters.
2154 Int_t d1 = p->GetFirstDaughter();
2155 Int_t d2 = p->GetLastDaughter();
2157 printf("%d pid=%d: %.3f %.3f %.3f (%.2f %.2f %.2f); nd=%d,%d, mo=%d\n",
2158 index,p->PdgCode(),p->Px(),p->Py(),p->Pz(),p->Xv(),p->Yv(),p->Zv(),d1,d2, p->GetMother());
2161 Int_t nents = fMcParts->GetEntries();
2163 AliStaPart *newp = static_cast<AliStaPart*>(fMcParts->New(nents));
2164 newp->fPt = p->Pt();
2165 newp->fEta = p->Eta();
2166 newp->fPhi = p->Phi();
2167 if (p->Xv() != 0 || p->Yv() != 0 || p->Zv() != 0) {
2168 TVector3 vec(p->Xv(),p->Yv(),p->Zv());
2169 newp->fVR = vec.Perp();
2170 newp->fVEta = vec.Eta();
2171 newp->fVPhi = vec.Phi();
2173 newp->fPid = p->PdgCode();
2175 Int_t moi = p->GetMother();
2177 const AliMCParticle *mmc = static_cast<const AliMCParticle *>(arr->GetTrack(moi));
2178 moi = mmc->GetUniqueID();
2181 p->SetUniqueID(nents);
2183 Int_t nref = p->GetNumberOfTrackReferences();
2185 AliTrackReference *ref = p->GetTrackReference(nref-1);
2187 newp->fDet = ref->DetectorId();
2195 for (Int_t i=d1;i<=d2;++i) {
2196 AliMCParticle *dmc = static_cast<AliMCParticle *>(arr->GetTrack(i));
2199 ProcessDaughters(dmc,i,arr);