3 #include "AliAnalysisTaskEMCALIsoPhoton.h"
11 #include <THnSparse.h>
12 #include <TLorentzVector.h>
15 #include "AliAnalysisManager.h"
16 #include "AliAnalysisTask.h"
17 #include "AliEMCALGeometry.h"
18 #include "AliEMCALRecoUtils.h"
19 #include "AliESDCaloCells.h"
20 #include "AliESDCaloCluster.h"
21 #include "AliESDEvent.h"
22 #include "AliESDHeader.h"
23 #include "AliESDInputHandler.h"
24 #include "AliESDUtils.h"
25 #include "AliESDtrack.h"
26 #include "AliESDtrackCuts.h"
27 #include "AliAODEvent.h"
28 #include "AliAODTrack.h"
29 #include "AliMCEvent.h"
30 #include "AliMCEventHandler.h"
32 #include "AliVEvent.h"
33 #include "AliVTrack.h"
34 #include "AliV0vertexer.h"
35 #include "AliVCluster.h"
36 #include "AliOADBContainer.h"
42 ClassImp(AliAnalysisTaskEMCALIsoPhoton)
44 //________________________________________________________________________
45 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton() :
55 fGeoName("EMCAL_COMPLETEV1"),
72 fImportGeometryFromFile(0),
73 fImportGeometryFilePath(""),
87 fMCDirPhotonPtEtaPhi(0),
98 fMcPtInConeSBGnoUE(0),
100 fAllIsoNoUeEtMcGamma(0),
101 fMCDirPhotonPtEtaPhiNoClus(0),
119 // Default constructor.
120 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
123 //________________________________________________________________________
124 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
125 AliAnalysisTaskSE(name),
134 fGeoName("EMCAL_COMPLETEV1"),
151 fImportGeometryFromFile(0),
152 fImportGeometryFilePath(""),
166 fMCDirPhotonPtEtaPhi(0),
176 fMcPtInConeBGnoUE(0),
177 fMcPtInConeSBGnoUE(0),
179 fAllIsoNoUeEtMcGamma(0),
180 fMCDirPhotonPtEtaPhiNoClus(0),
200 // Define input and output slots here
201 // Input slot #0 works with a TChain
202 DefineInput(0, TChain::Class());
203 // Output slot #0 id reserved by the base class for AOD
204 // Output slot #1 writes into a TH1 container
205 DefineOutput(1, TList::Class());
206 DefineOutput(2, TList::Class());
209 //________________________________________________________________________
210 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
212 // Create histograms, called once.
214 fESDClusters = new TObjArray();
215 fSelPrimTracks = new TObjArray();
218 fOutputList = new TList();
219 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
221 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
222 fOADBContainer = new AliOADBContainer("AliEMCALgeo");
223 fOADBContainer->InitFromFile(Form("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root"),"AliEMCALgeo");
225 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
226 fOutputList->Add(fEvtSel);
228 fNClusEt10 = new TH1F("hNClusEt10","# of cluster with E_{T}>10 per event;E;",101,-0.5,100.5);
229 fOutputList->Add(fNClusEt10);
231 fRecoPV = new TH1F("hRecoPV","Prim. vert. reconstruction (yes or no);reco (0=no, 1=yes) ;",2,-0.5,1.5);
232 fOutputList->Add(fRecoPV);
234 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
235 fOutputList->Add(fPVtxZ);
237 fTrMultDist = new TH1F("fTrMultDist","track multiplicity;tracks/event;#events",200,0.5,200.5);
238 fOutputList->Add(fTrMultDist);
240 fMCDirPhotonPtEtaPhi = new TH3F("hMCDirPhotonPtEtaPhi","photon (gq->#gammaq) p_{T}, #eta, #phi;GeV/c;#eta;#phi",1000,0,100,154,-0.77,0.77,130,1.38,3.20);
241 fMCDirPhotonPtEtaPhi->Sumw2();
242 fOutputList->Add(fMCDirPhotonPtEtaPhi);
244 fDecayPhotonPtMC = new TH1F("hDecayPhotonPtMC","decay photon p_{T};GeV/c;dN/dp_{T} (c GeV^{-1})",1000,0,100);
245 fDecayPhotonPtMC->Sumw2();
246 fOutputList->Add(fDecayPhotonPtMC);
248 fCellAbsIdVsAmpl = new TH2F("hCellAbsIdVsAmpl","cell abs id vs cell amplitude (energy);E (GeV);ID",200,0,100,24*48*10,-0.5,24*48*10-0.5);
249 fOutputList->Add(fCellAbsIdVsAmpl);
251 fNClusHighClusE = new TH2F("hNClusHighClusE","total number of clusters vs. highest clus energy in the event;E (GeV);NClus",200,0,100,301,-0.5,300.5);
252 fOutputList->Add(fNClusHighClusE);
254 fHigherPtConeM02 = new TH2F("hHigherPtConeM02","#lambda_{0}^{2} vs. in-cone-p_{T}^{max};p_{T}^{max} (GeV/c, in the cone);#lambda_{0}^{2}",1000,0,100,400,0,4);
255 fOutputList->Add(fHigherPtConeM02);
257 fClusEtMcPt = new TH2F("hClusEtMcPt","E_{T}^{clus} vs. p_{T}^{mc}; p_{T}^{mc};E_{T}^{clus}",500,0,100,500,0,100);
258 fOutputList->Add(fClusEtMcPt);
260 fClusMcDetaDphi = new TH2F("hClusMcDetaDphi","#Delta#phi vs. #Delta#eta (reco-mc);#Delta#eta;#Delta#phi",100,-.7,.7,100,-.7,.7);
261 fOutputList->Add(fClusMcDetaDphi);
263 fNClusPerPho = new TH2F("hNClusPerPho","Number of clusters per prompt photon;p_{T}^{MC};N_{clus}",500,0,100,11,-0.5,10.5);
264 fOutputList->Add(fNClusPerPho);
266 fMcPtInConeBG = new TH2F("hMcPtInConeBG","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK+EMC} (BG template);ISO^{TRK+EMC} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
267 fOutputList->Add(fMcPtInConeBG);
269 fMcPtInConeSBG = new TH2F("hMcPtInConeSBG","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK+EMC} (SBG range);ISO^{TRK+EMC} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
270 fOutputList->Add(fMcPtInConeSBG);
272 fMcPtInConeBGnoUE = new TH2F("hMcPtInConeBGnoUE","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK+EMC} (BG template);ISO^{TRK+EMC} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
273 fOutputList->Add(fMcPtInConeBGnoUE);
275 fMcPtInConeSBGnoUE = new TH2F("hMcPtInConeSBGnoUE","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK+EMC} (SBG range);ISO^{TRK+EMC} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
276 fOutputList->Add(fMcPtInConeSBGnoUE);
278 fAllIsoEtMcGamma = new TH2F("hAllIsoEtMcGammaE","ISO^{TRK+EMC} vs. E_{T}^{clus} for clusters comming from a MC prompt #gamma; E_{T}^{clus} (GeV);ISO^{TRK+EMC} (GeV);",1000,0,100,600,-10,50);
279 fOutputList->Add(fAllIsoEtMcGamma);
281 fAllIsoNoUeEtMcGamma = new TH2F("hAllIsoNoUeEtMcGammaE","ISO^{TRK+EMC}_{noue} vs. E_{T}^{clus} for clusters comming from a MC prompt #gamma; E_{T}^{clus} (GeV);ISO^{TRK+EMC}_{noue} (GeV);",1000,0,100,600,-10,50);
282 fOutputList->Add(fAllIsoNoUeEtMcGamma);
285 fMCDirPhotonPtEtaPhiNoClus = new TH3F("hMCDirPhotonPhiEtaNoClus","p_{T}, #eta and #phi of prompt photons with no reco clusters;p_{T};#eta;#phi",1000,0,100,154,-0.77,0.77,130,1.38,3.20);
286 fOutputList->Add(fMCDirPhotonPtEtaPhiNoClus);
288 Int_t nEt=1000, nM02=400, nCeIso=1000, nTrIso=1000, nAllIso=1000, nCeIsoNoUE=1000, nAllIsoNoUE=1000, nTrClDphi=200, nTrClDeta=100, nClEta=140, nClPhi=128, nTime=60, nMult=100, nPhoMcPt=101;
289 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nCeIsoNoUE, nAllIsoNoUE, nTrClDphi, nTrClDeta,nClEta,nClPhi,nTime,nMult,nPhoMcPt};
290 fNDimensions = sizeof(bins)/sizeof(Int_t);
291 const Int_t ndims = fNDimensions;
292 Double_t xmin[] = { 0., 0., -10., -10., -10., -10., -10., -0.1,-0.05, -0.7, 1.4,-0.15e-06,-0.5,-1.5};
293 Double_t xmax[] = { 100., 4., 190., 190., 190., 190., 190., 0.1, 0.05, 0.7, 3.192, 0.15e-06,99.5,99.5};
294 if(fPeriod.Contains("11h")){
297 fHnOutput = new THnSparseF("fHnOutput","Output matrix: E_{T},M02,CeIso,TrIso,AllIso, CeIsoNoUESub, AllIsoNoUESub, d#phi_{trk},d#eta_{trk},#eta_{clus},#phi_{clus},T_{max},mult,mc-p_{T}^{#gamma}", ndims, bins, xmin, xmax);
298 fOutputList->Add(fHnOutput);
301 fQAList = new TList();
302 fQAList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
304 fNTracks = new TH1F("hNTracks","# of selected tracks;n-tracks;counts",120,-0.5,119.5);
306 fQAList->Add(fNTracks);
308 fEmcNCells = new TH1F("fEmcNCells",";n/event;count",120,-0.5,119.5);
310 fQAList->Add(fEmcNCells);
311 fEmcNClus = new TH1F("fEmcNClus",";n/event;count",120,-0.5,119.5);
313 fQAList->Add(fEmcNClus);
314 fEmcNClusCut = new TH1F("fEmcNClusCut",";n/event;count",120,-0.5,119.5);
315 fEmcNClusCut->Sumw2();
316 fQAList->Add(fEmcNClusCut);
317 fNTracksECut = new TH1F("fNTracksECut",";n/event;count",120,-0.5,119.5);
318 fNTracksECut->Sumw2();
319 fQAList->Add(fNTracksECut);
320 fEmcNCellsCut = new TH1F("fEmcNCellsCut",";n/event;count",120,-0.5,119.5);
321 fEmcNCellsCut->Sumw2();
322 fQAList->Add(fEmcNCellsCut);
323 fEmcClusEPhi = new TH2F("fEmcClusEPhi",";GeV;#phi",100,-0.25,49.75,63,0,6.3);
324 fEmcClusEPhi->Sumw2();
325 fQAList->Add(fEmcClusEPhi);
326 fEmcClusEPhiCut = new TH2F("fEmcClusEPhiCut",";GeV;#phi",100,-0.25,49.75,63,0,6.3);
327 fEmcClusEPhiCut->Sumw2();
328 fQAList->Add(fEmcClusEPhiCut);
329 fEmcClusEEta = new TH2F("fEmcClusEEta",";GeV;#eta",100,-0.25,49.75,19,-0.9,0.9);
330 fEmcClusEEta->Sumw2();
331 fQAList->Add(fEmcClusEEta);
332 fEmcClusEEtaCut = new TH2F("fEmcClusEEtaCut",";GeV;#eta",100,-0.25,49.75,18,-0.9,0.9);
333 fEmcClusEEtaCut->Sumw2();
334 fQAList->Add(fEmcClusEEtaCut);
335 fTrackPtPhi = new TH2F("fTrackPtPhi",";p_{T} [GeV/c];#phi",100,-0.25,49.75,63,0,6.3);
336 fTrackPtPhi->Sumw2();
337 fQAList->Add(fTrackPtPhi);
338 fTrackPtPhiCut = new TH2F("fTrackPtPhiCut",";p_{T} [GeV/c];#phi",100,-0.25,49.75,63,0,6.3);
339 fTrackPtPhiCut->Sumw2();
340 fQAList->Add(fTrackPtPhiCut);
341 fTrackPtEta = new TH2F("fTrackPtEta",";p_{T} [GeV/c];#eta",100,-0.25,49.75,18,-0.9,0.9);
342 fTrackPtEta->Sumw2();
343 fQAList->Add(fTrackPtEta);
344 fTrackPtEtaCut = new TH2F("fTrackPtEtaCut",";p_{T} [GeV/c];#eta",100,-0.25,49.75,18,-0.9,0.9);
345 fTrackPtEtaCut->Sumw2();
346 fQAList->Add(fTrackPtEtaCut);
348 PostData(1, fOutputList);
349 PostData(2, fQAList);
352 //________________________________________________________________________
353 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
355 // Main loop, called for each event.
360 // event trigger selection
361 Bool_t isSelected = 0;
362 if(fPeriod.Contains("11a")){
363 if(fTrigBit.Contains("kEMC"))
364 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
366 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
369 if(fTrigBit.Contains("kEMC"))
370 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
372 if(fTrigBit.Contains("kMB"))
373 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
375 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
377 if(fPeriod.Contains("11h")){
378 if(fTrigBit.Contains("kAny"))
379 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAny);
380 if(fTrigBit.Contains("kAnyINT"))
381 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAnyINT);
386 printf("isSelected = %d, fIsMC=%d\n", isSelected, fIsMc);
390 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
391 TFile *file = (TFile*)tree->GetCurrentFile();
392 TString filename = file->GetName();
393 if(!filename.Contains(fPathStrOpt.Data()))
396 AliVEvent *event = (AliVEvent*)InputEvent();
398 printf("ERROR: event not available\n");
401 Int_t runnumber = InputEvent()->GetRunNumber() ;
403 printf("run number = %d\n",runnumber);
405 fESD = dynamic_cast<AliESDEvent*>(event);
407 fAOD = dynamic_cast<AliAODEvent*>(event);
409 printf("ERROR: Invalid type of event!!!\n");
413 printf("AOD EVENT!\n");
418 printf("event is ok,\n run number=%d\n",runnumber);
421 AliVVertex *pv = (AliVVertex*)event->GetPrimaryVertex();
422 Bool_t pvStatus = kTRUE;
424 AliESDVertex *esdv = (AliESDVertex*)fESD->GetPrimaryVertex();
425 pvStatus = esdv->GetStatus();
433 fPVtxZ->Fill(pv->GetZ());
434 if(TMath::Abs(pv->GetZ())>15)
437 printf("passed vertex cut\n");
441 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("Tracks"));
443 fTracks = dynamic_cast<TClonesArray*>(fAOD->GetTracks());
446 AliError("Track array in event is NULL!");
448 printf("returning due to not finding tracks!\n");
451 // Track loop to fill a pT spectrum
452 const Int_t Ntracks = fTracks->GetEntriesFast();
453 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
454 // for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
455 //AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
456 AliVTrack *track = (AliVTrack*)fTracks->At(iTracks);
459 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack*>(track);
460 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
461 if (esdTrack && fPrTrCuts && fPrTrCuts->IsSelected(track)){
462 fSelPrimTracks->Add(track);
463 /*if(fTrackMaxPt<track->Pt())
464 fTrackMaxPt = track->Pt();*/
465 //printf("pt,eta,phi:%1.1f,%1.1f,%1.1f \n",track->Pt(),track->Eta(), track->Phi());
468 fSelPrimTracks->Add(track);
469 /*if(fTrackMaxPt<track->Pt())
470 fTrackMaxPt = track->Pt();*/
474 TObjArray *matEMCAL=(TObjArray*)fOADBContainer->GetObject(runnumber,"EmcalMatrices");
475 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
476 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
479 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
481 // if(event->GetEMCALMatrix(mod))
482 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod);
483 fGeom->SetMisalMatrix(fGeomMatrix[mod] , mod);
487 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
488 fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
490 printf("ESD Track mult= %d\n",fTrackMult);
493 fTrackMult = Ntracks;
495 printf("AOD Track mult= %d\n",fTrackMult);
497 fTrMultDist->Fill(fTrackMult);
500 TList *l = fESD->GetList();
501 fESDClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
502 fESDCells = fESD->GetEMCALCells();
504 printf("ESD cluster mult= %d\n",fESDClusters->GetEntriesFast());
507 fAODClusters = dynamic_cast<TClonesArray*>(fAOD->GetCaloClusters());
508 fAODCells = fAOD->GetEMCALCells();
510 printf("AOD cluster mult= %d\n",fAODClusters->GetEntriesFast());
514 fMCEvent = MCEvent();
517 std::cout<<"MCevent exists\n";
518 fStack = (AliStack*)fMCEvent->Stack();
522 std::cout<<"ERROR: NO MC EVENT!!!!!!\n";
527 printf("passed calling of FollowGamma\n");
530 printf("passed calling of FillClusHists\n");
533 printf("passed calling of FillMcHists\n");
536 printf("passed calling of FillQA\n");
538 fESDClusters->Clear();*/
539 fSelPrimTracks->Clear();
543 PostData(1, fOutputList);
544 PostData(2, fQAList);
547 //________________________________________________________________________
548 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
551 printf("Inside FillClusHists()....\n");
552 // Fill cluster histograms.
553 TObjArray *clusters = fESDClusters;
556 clusters = fAODClusters;
558 printf("ESD clusters empty...");
562 printf(" and AOD clusters as well!!!\n");
568 const Int_t nclus = clusters->GetEntries();
572 printf("Inside FillClusHists and there are %d clusters\n",nclus);
576 for(Int_t ic=0;ic<nclus;ic++){
578 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
586 Double_t Emax = GetMaxCellEnergy( c, id);
587 Double_t Ecross = GetCrossEnergy( c, id);
588 if((1-Ecross/Emax)>fExoticCut)
590 Float_t clsPos[3] = {0,0,0};
591 c->GetPosition(clsPos);
592 TVector3 clsVec(clsPos);
593 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
595 printf("\tcluster eta=%1.1f,phi=%1.1f,E=%1.1f\n",clsVec.Eta(),clsVec.Phi(),c->E());
598 Float_t ceiso, cephiband, cecore;
599 Float_t triso, trphiband, trcore;
600 Float_t alliso, allphiband, allcore;
601 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
602 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
603 GetCeIso(clsVec, id, ceiso, cephiband, cecore);
604 GetTrIso(clsVec, triso, trphiband, trcore);
605 Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
606 if(Et>10 && Et<15 && dr>0.025){
607 fHigherPtConeM02->Fill(fHigherPtCone,c->GetM02());
609 printf("\t\tHigher track pt inside the cone: %1.1f GeV/c; M02=%1.2f\n",fHigherPtCone,c->GetM02());
611 alliso = ceiso + triso;
612 allphiband = cephiband + trphiband;
613 allcore = cecore + trcore;
614 Float_t ceisoue = cephiband/phibandArea*netConeArea;
615 Float_t trisoue = trphiband/phibandArea*netConeArea;
616 Float_t allisoue = allphiband/phibandArea*netConeArea;
617 Float_t mcptsum = GetMcPtSumInCone(clsVec.Eta(), clsVec.Phi(),fIsoConeR);
619 printf("\t alliso=%1.1f, Et=%1.1f=-=-=-=-=\n",alliso,Et);
620 if(c->GetM02()>0.5 && c->GetM02()<2.0){
621 fMcPtInConeBG->Fill(alliso-Et-allisoue, mcptsum);
622 fMcPtInConeBGnoUE->Fill(alliso-Et, mcptsum);
624 if(c->GetM02()>0.1 && c->GetM02()<0.3 && dr>0.03){
625 fMcPtInConeSBG->Fill(alliso-Et-allisoue, mcptsum);
626 fMcPtInConeSBGnoUE->Fill(alliso-Et, mcptsum);
627 if(fMcIdFamily.Contains((Form("%d",c->GetLabel())))){
628 fAllIsoEtMcGamma->Fill(Et, alliso-/*Et*/cecore-allisoue);
629 fAllIsoNoUeEtMcGamma->Fill(Et, alliso-/*Et*/cecore);
632 const Int_t ndims = fNDimensions;
633 Double_t outputValues[ndims];
634 ptmc = GetClusSource(c);
635 outputValues[0] = Et;
636 outputValues[1] = c->GetM02();
637 outputValues[2] = ceiso/*cecore*/-ceisoue;
638 outputValues[3] = triso-trisoue;
639 outputValues[4] = alliso/*cecore*/-allisoue - trcore;
640 outputValues[5] = ceiso;
641 outputValues[6] = alliso - trcore;
642 outputValues[7] = c->GetTrackDx();
643 outputValues[8] = c->GetTrackDz();
644 outputValues[9] = clsVec.Eta();
645 outputValues[10] = clsVec.Phi();
647 outputValues[11] = fESDCells->GetCellTime(id);
649 outputValues[11] = fAODCells->GetCellTime(id);
650 outputValues[12] = fTrackMult;
651 outputValues[13] = ptmc;
652 fHnOutput->Fill(outputValues);
656 fNClusHighClusE->Fill(maxE,nclus);
658 fNClusEt10->Fill(nclus10);
659 fNClusPerPho->Fill(fDirPhoPt,fNClusForDirPho);
662 //________________________________________________________________________
663 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Int_t maxid, Float_t &iso, Float_t &phiband, Float_t &core)
665 // Get cell isolation.
666 AliVCaloCells *cells = fESDCells;
670 printf("ESD cells empty...");
674 printf(" and AOD cells are empty as well!!!\n");
678 TObjArray *clusters = fESDClusters;
680 clusters = fAODClusters;
685 const Int_t nclus = clusters->GetEntries();
686 //const Int_t ncells = cells->GetNumberOfCells();
690 Float_t etacl = vec.Eta();
691 Float_t phicl = vec.Phi();
692 Float_t maxtcl = cells->GetCellTime(maxid);
694 phicl+=TMath::TwoPi();
696 Float_t eta=-1, phi=-1;
697 for(int icell=0;icell<ncells;icell++){
698 absid = TMath::Abs(cells->GetCellNumber(icell));
699 Float_t celltime = cells->GetCellTime(absid);
700 //if(TMath::Abs(celltime)>2e-8 && (!fIsMc))
701 if(TMath::Abs(celltime-maxtcl)>2e-8 )
705 fGeom->EtaPhiFromIndex(absid,eta,phi);
706 Float_t dphi = TMath::Abs(phi-phicl);
707 Float_t deta = TMath::Abs(eta-etacl);
708 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);*/
709 for(int ic=0;ic<nclus;ic++){
710 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
716 GetMaxCellEnergy( c, id);
717 Double_t maxct = cells->GetCellTime(id);
718 if(TMath::Abs(maxtcl-maxct)>2.5e-9)
720 Float_t clsPos[3] = {0,0,0};
721 c->GetPosition(clsPos);
723 Double_t Et = c->E()*TMath::Sin(cv.Theta());
724 Float_t dphi = TMath::Abs(cv.Phi()-phicl);
725 Float_t deta = TMath::Abs(cv.Eta()-etacl);
726 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
729 Double_t matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
730 Double_t nEt = TMath::Max(Et-matchedpt, 0.0);
732 printf("nEt=%1.1f\n",nEt);
750 //________________________________________________________________________
751 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
753 // Get track isolation.
758 const Int_t ntracks = fSelPrimTracks->GetEntries();
762 Double_t etacl = vec.Eta();
763 Double_t phicl = vec.Phi();
765 phicl+=TMath::TwoPi();
766 for(int itrack=0;itrack<ntracks;itrack++){
767 AliVTrack *track = static_cast<AliVTrack*> (fSelPrimTracks->At(itrack));
770 Double_t dphi = TMath::Abs(track->Phi()-phicl);
771 Double_t deta = TMath::Abs(track->Eta()-etacl);
772 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
773 Double_t pt = track->Pt();
777 totiso += track->Pt();
786 totband += track->Pt();
794 //________________________________________________________________________
795 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
797 // Calculate the energy of cross cells around the leading cell.
799 AliVCaloCells *cells = 0;
818 Double_t crossEnergy = 0;
820 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
821 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
823 Int_t ncells = cluster->GetNCells();
824 for (Int_t i=0; i<ncells; i++) {
825 Int_t cellAbsId = cluster->GetCellAbsId(i);
826 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
827 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
828 Int_t aphidiff = TMath::Abs(iphi-iphis);
831 Int_t aetadiff = TMath::Abs(ieta-ietas);
834 if ( (aphidiff==1 && aetadiff==0) ||
835 (aphidiff==0 && aetadiff==1) ) {
836 crossEnergy += cells->GetCellAmplitude(cellAbsId);
843 //________________________________________________________________________
844 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
846 // Get maximum energy of attached cell.
850 AliVCaloCells *cells = 0;
858 Int_t ncells = cluster->GetNCells();
859 for (Int_t i=0; i<ncells; i++) {
860 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
863 id = cluster->GetCellAbsId(i);
869 //________________________________________________________________________
870 void AliAnalysisTaskEMCALIsoPhoton ::FillMcHists()
874 Int_t nTracks = fStack->GetNtrack();
876 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
877 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
878 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
881 Int_t pdg = mcp->GetPdgCode();
884 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
886 Int_t imom = mcp->GetMother(0);
887 if(imom<0 || imom>nTracks)
889 TParticle *mcmom = static_cast<TParticle*>(fStack->Particle(imom));
892 Int_t pdgMom = mcmom->GetPdgCode();
893 if((imom==6 || imom==7) && pdgMom==22) {
894 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
895 if(fNClusForDirPho==0)
896 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
898 printf("Found \"photonic\" parton at position %d, with pt=%1.1f, eta=%1.1f and phi=%1.1f, and status=%d,\n",imom,mcmom->Pt(), mcmom->Eta(), mcmom->Phi(), mcmom->GetStatusCode());
899 printf("with a final photon at position %d, with pt=%1.1f, eta=%1.1f and phi=%1.1f, and status=%d\n",iTrack,mcp->Pt(), mcp->Eta(), mcp->Phi(),mcp->GetStatusCode());
903 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
904 fDecayPhotonPtMC->Fill(mcp->Pt());
908 //________________________________________________________________________
909 Float_t AliAnalysisTaskEMCALIsoPhoton::GetClusSource(const AliVCluster *c)
915 Int_t nmcp = fStack->GetNtrack();
916 Int_t clabel = c->GetLabel();
917 if(fDebug && fMcIdFamily.Contains(Form("%d",clabel)))
918 printf("\n\t ==== Label %d is a descendent of the prompt photon ====\n\n",clabel);
919 if(!fMcIdFamily.Contains(Form("%d",clabel)))
922 TString partonposstr = (TSubString)fMcIdFamily.operator()(0,1);
923 Int_t partonpos = partonposstr.Atoi();
925 printf("\t^^^^ parton position = %d ^^^^\n",partonpos);
926 if(clabel<0 || clabel>nmcp)
928 Float_t clsPos[3] = {0,0,0};
929 c->GetPosition(clsPos);
930 TVector3 clsVec(clsPos);
931 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
932 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(partonpos));
936 printf("\tclus mc truth eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, stackpos=%d\n",mcp->Eta(),mcp->Phi(),mcp->Energy(),mcp->GetPdgCode(),clabel);
938 Int_t lab1 = mcp->GetFirstDaughter();
939 if(lab1<0 || lab1>nmcp)
941 TParticle *mcd = static_cast<TParticle*>(fStack->Particle(lab1));
945 printf("\t\tmom mc truth eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, stackpos=%d\n",mcd->Eta(),mcd->Phi(),mcd->Energy(),mcd->GetPdgCode(),lab1);
946 if(mcd->GetPdgCode()==22){
947 fClusEtMcPt->Fill(mcd->Pt(), Et);
948 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
951 printf("Warning: daughter of photon parton is not a photon\n");
956 //________________________________________________________________________
957 void AliAnalysisTaskEMCALIsoPhoton::FollowGamma()
962 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(selfid));
965 if(mcp->GetPdgCode()!=22){
966 mcp = static_cast<TParticle*>(fStack->Particle(++selfid));
970 Int_t daug0f = mcp->GetFirstDaughter();
971 Int_t daug0l = mcp->GetLastDaughter();
972 Int_t nd0 = daug0l - daug0f;
974 printf("\n\tGenerated gamma (%d) eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, n-daug=%d\n",selfid,mcp->Eta(),mcp->Phi(),mcp->Energy(),mcp->GetPdgCode(),nd0+1);
975 fMcIdFamily = Form("%d,",selfid);
976 GetDaughtersInfo(daug0f,daug0l, selfid,"");
978 printf("\t---- end of the prompt gamma's family tree ----\n\n");
979 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
981 TParticle *md = static_cast<TParticle*>(fStack->Particle(daug0f));
984 fDirPhoPt = md->Pt();
986 //________________________________________________________________________
987 void AliAnalysisTaskEMCALIsoPhoton::GetDaughtersInfo(int firstd, int lastd, int selfid, const char *inputind)
989 int nmcp = fStack->GetNtrack();
990 if(firstd<0 || firstd>nmcp)
992 if(lastd<0 || lastd>nmcp)
995 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
998 TString indenter = Form("\t%s",inputind);
1001 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1002 for(int id=firstd; id<lastd+1; id++){
1003 dp = static_cast<TParticle*>(fStack->Particle(id));
1006 Int_t dfd = dp->GetFirstDaughter();
1007 Int_t dld = dp->GetLastDaughter();
1008 Int_t dnd = dld - dfd + 1;
1009 Float_t vr = TMath::Sqrt(dp->Vx()*dp->Vx()+dp->Vy()*dp->Vy());
1011 printf("\t%sParticle daughter(%d) eta=%1.1f,phi=%1.1f,E=%1.1f, vR=%1.1f, pdgcode=%d, n-daug=%d(%d,%d)\n", indenter.Data(),id, dp->Eta(), dp->Phi(), dp->Energy(), vr, dp->GetPdgCode(), dnd, dfd, dld);
1012 fMcIdFamily += Form("%d,",id);
1013 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1017 //________________________________________________________________________
1018 Float_t AliAnalysisTaskEMCALIsoPhoton::GetMcPtSumInCone(Float_t etaclus, Float_t phiclus, Float_t R)
1023 printf("Inside GetMcPtSumInCone!!\n");
1024 Int_t nTracks = fStack->GetNtrack();
1026 TString addpartlabels = "";
1027 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1028 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1031 Int_t firstd = mcp->GetFirstDaughter();
1032 Int_t lastd = mcp->GetLastDaughter();
1033 if((iTrack==6 || iTrack==7) && mcp->GetPdgCode()==22){
1034 for(Int_t id=firstd;id<=lastd;id++)
1035 addpartlabels += Form("%d,",id);
1042 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1044 Float_t dphi = mcp->Phi() - phiclus;
1045 Float_t deta = mcp->Eta() - etaclus;
1047 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1050 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1053 if(addpartlabels.Contains(Form("%d",iTrack))){
1055 printf(" >>>> list of particles included (and their daughters) %s\n",addpartlabels.Data());
1058 addpartlabels += Form("%d,",iTrack);
1059 for(Int_t id=firstd;id<=lastd;id++)
1060 addpartlabels += Form("%d,",id);
1065 //________________________________________________________________________
1066 void AliAnalysisTaskEMCALIsoPhoton::FillQA()
1070 const int ntracks = fSelPrimTracks->GetEntriesFast();
1071 const int ncells = fNCells50;//fESDCells->GetNumberOfCells();
1072 const Int_t nclus = fESDClusters->GetEntries();
1074 fNTracks->Fill(ntracks);
1075 fEmcNCells->Fill(ncells);
1076 fEmcNClus->Fill(nclus);
1077 if(fMaxEClus>fECut){
1078 fNTracksECut->Fill(ntracks);
1079 fEmcNCellsCut->Fill(ncells);
1080 fEmcNClusCut->Fill(nclus);
1082 for(int it=0;it<ntracks;it++){
1083 AliVTrack *t = (AliVTrack*)fSelPrimTracks->At(it);
1086 fTrackPtPhi->Fill(t->Pt(),t->Phi());
1087 fTrackPtEta->Fill(t->Pt(),t->Eta());
1088 if(fMaxEClus>fECut){
1089 fTrackPtPhiCut->Fill(t->Pt(), t->Phi());
1090 fTrackPtEtaCut->Fill(t->Pt(), t->Eta());
1093 for(int ic=0;ic<nclus;ic++){
1094 AliVCluster *c = (AliVCluster*)fESDClusters->At(ic);
1097 Float_t clsPos[3] = {0,0,0};
1098 c->GetPosition(clsPos);
1099 TVector3 clsVec(clsPos);
1100 Double_t cphi = clsVec.Phi();
1101 Double_t ceta = clsVec.Eta();
1102 fEmcClusEPhi->Fill(c->E(), cphi);
1103 fEmcClusEEta->Fill(c->E(), ceta);
1104 if(fMaxEClus>fECut){
1105 fEmcClusEPhiCut->Fill(c->E(), cphi);
1106 fEmcClusEEtaCut->Fill(c->E(), ceta);
1110 //________________________________________________________________________
1111 Double_t AliAnalysisTaskEMCALIsoPhoton::GetTrackMatchedPt(Int_t matchIndex)
1116 if(matchIndex<0 || matchIndex>fTracks->GetEntries()){
1118 printf("track-matched index out of track array range!!!\n");
1121 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(matchIndex));
1124 printf("track-matched pointer does not exist!!!\n");
1130 if(!fPrTrCuts->IsSelected(track))
1136 //________________________________________________________________________
1137 void AliAnalysisTaskEMCALIsoPhoton::LoopOnCells()
1139 AliVCaloCells *cells = 0;
1145 Int_t ncells = cells->GetNumberOfCells();
1146 for (Int_t i=0; i<ncells; i++) {
1147 Short_t absid = TMath::Abs(cells->GetCellNumber(i));
1148 Double_t e = cells->GetCellAmplitude(absid);
1154 //________________________________________________________________________
1155 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
1157 // Called once at the end of the query.