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),
120 // Default constructor.
121 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
124 //________________________________________________________________________
125 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
126 AliAnalysisTaskSE(name),
135 fGeoName("EMCAL_COMPLETEV1"),
152 fImportGeometryFromFile(0),
153 fImportGeometryFilePath(""),
167 fMCDirPhotonPtEtaPhi(0),
177 fMcPtInConeBGnoUE(0),
178 fMcPtInConeSBGnoUE(0),
180 fAllIsoNoUeEtMcGamma(0),
181 fMCDirPhotonPtEtaPhiNoClus(0),
202 // Define input and output slots here
203 // Input slot #0 works with a TChain
204 DefineInput(0, TChain::Class());
205 // Output slot #0 id reserved by the base class for AOD
206 // Output slot #1 writes into a TH1 container
207 DefineOutput(1, TList::Class());
208 DefineOutput(2, TList::Class());
211 //________________________________________________________________________
212 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
214 // Create histograms, called once.
216 fESDClusters = new TObjArray();
217 fSelPrimTracks = new TObjArray();
220 fOutputList = new TList();
221 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
223 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
224 fOADBContainer = new AliOADBContainer("AliEMCALgeo");
225 fOADBContainer->InitFromFile(Form("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root"),"AliEMCALgeo");
227 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
228 fOutputList->Add(fEvtSel);
230 fNClusEt10 = new TH1F("hNClusEt10","# of cluster with E_{T}>10 per event;E;",101,-0.5,100.5);
231 fOutputList->Add(fNClusEt10);
233 fRecoPV = new TH1F("hRecoPV","Prim. vert. reconstruction (yes or no);reco (0=no, 1=yes) ;",2,-0.5,1.5);
234 fOutputList->Add(fRecoPV);
236 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
237 fOutputList->Add(fPVtxZ);
239 fTrMultDist = new TH1F("fTrMultDist","track multiplicity;tracks/event;#events",200,0.5,200.5);
240 fOutputList->Add(fTrMultDist);
242 fMCDirPhotonPtEtaPhi = new TH3F("hMCDirPhotonPtEtaPhi","photon (gq->#gammaq) p_{T}, #eta, #phi;GeV/c;#eta;#phi",101,-1.5,99.5,154,-0.77,0.77,130,1.38,3.20);
243 fMCDirPhotonPtEtaPhi->Sumw2();
244 fOutputList->Add(fMCDirPhotonPtEtaPhi);
246 fDecayPhotonPtMC = new TH1F("hDecayPhotonPtMC","decay photon p_{T};GeV/c;dN/dp_{T} (c GeV^{-1})",1000,0,100);
247 fDecayPhotonPtMC->Sumw2();
248 fOutputList->Add(fDecayPhotonPtMC);
250 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);
251 fOutputList->Add(fCellAbsIdVsAmpl);
253 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);
254 fOutputList->Add(fNClusHighClusE);
256 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);
257 fOutputList->Add(fHigherPtConeM02);
259 fClusEtMcPt = new TH2F("hClusEtMcPt","E_{T}^{clus} vs. p_{T}^{mc}; p_{T}^{mc};E_{T}^{clus}",500,0,100,500,0,100);
260 fOutputList->Add(fClusEtMcPt);
262 fClusMcDetaDphi = new TH2F("hClusMcDetaDphi","#Delta#phi vs. #Delta#eta (reco-mc);#Delta#eta;#Delta#phi",100,-.7,.7,100,-.7,.7);
263 fOutputList->Add(fClusMcDetaDphi);
265 fNClusPerPho = new TH2F("hNClusPerPho","Number of clusters per prompt photon;p_{T}^{MC};N_{clus}",500,0,100,11,-0.5,10.5);
266 fOutputList->Add(fNClusPerPho);
268 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);
269 fOutputList->Add(fMcPtInConeBG);
271 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);
272 fOutputList->Add(fMcPtInConeSBG);
274 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);
275 fOutputList->Add(fMcPtInConeBGnoUE);
277 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);
278 fOutputList->Add(fMcPtInConeSBGnoUE);
280 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);
281 fOutputList->Add(fAllIsoEtMcGamma);
283 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);
284 fOutputList->Add(fAllIsoNoUeEtMcGamma);
287 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);
288 fOutputList->Add(fMCDirPhotonPtEtaPhiNoClus);
290 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=100;
291 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nCeIsoNoUE, nAllIsoNoUE, nTrClDphi, nTrClDeta,nClEta,nClPhi,nTime,nMult,nPhoMcPt};
292 fNDimensions = sizeof(bins)/sizeof(Int_t);
293 const Int_t ndims = fNDimensions;
294 Double_t xmin[] = { -0.5, 0., -10., -10., -10., -10., -10., -0.1,-0.05, -0.7, 1.4,-0.15e-06,-0.5,-0.5};
295 Double_t xmax[] = { 99.5, 4., 190., 190., 190., 190., 190., 0.1, 0.05, 0.7, 3.192, 0.15e-06,99.5,99.5};
296 if(fPeriod.Contains("11h")){
299 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);
300 fOutputList->Add(fHnOutput);
303 fQAList = new TList();
304 fQAList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
306 fNTracks = new TH1F("hNTracks","# of selected tracks;n-tracks;counts",120,-0.5,119.5);
308 fQAList->Add(fNTracks);
310 fEmcNCells = new TH1F("fEmcNCells",";n/event;count",120,-0.5,119.5);
312 fQAList->Add(fEmcNCells);
313 fEmcNClus = new TH1F("fEmcNClus",";n/event;count",120,-0.5,119.5);
315 fQAList->Add(fEmcNClus);
316 fEmcNClusCut = new TH1F("fEmcNClusCut",";n/event;count",120,-0.5,119.5);
317 fEmcNClusCut->Sumw2();
318 fQAList->Add(fEmcNClusCut);
319 fNTracksECut = new TH1F("fNTracksECut",";n/event;count",120,-0.5,119.5);
320 fNTracksECut->Sumw2();
321 fQAList->Add(fNTracksECut);
322 fEmcNCellsCut = new TH1F("fEmcNCellsCut",";n/event;count",120,-0.5,119.5);
323 fEmcNCellsCut->Sumw2();
324 fQAList->Add(fEmcNCellsCut);
325 fEmcClusEPhi = new TH2F("fEmcClusEPhi",";GeV;#phi",100,-0.25,49.75,63,0,6.3);
326 fEmcClusEPhi->Sumw2();
327 fQAList->Add(fEmcClusEPhi);
328 fEmcClusEPhiCut = new TH2F("fEmcClusEPhiCut",";GeV;#phi",100,-0.25,49.75,63,0,6.3);
329 fEmcClusEPhiCut->Sumw2();
330 fQAList->Add(fEmcClusEPhiCut);
331 fEmcClusEEta = new TH2F("fEmcClusEEta",";GeV;#eta",100,-0.25,49.75,19,-0.9,0.9);
332 fEmcClusEEta->Sumw2();
333 fQAList->Add(fEmcClusEEta);
334 fEmcClusEEtaCut = new TH2F("fEmcClusEEtaCut",";GeV;#eta",100,-0.25,49.75,18,-0.9,0.9);
335 fEmcClusEEtaCut->Sumw2();
336 fQAList->Add(fEmcClusEEtaCut);
337 fTrackPtPhi = new TH2F("fTrackPtPhi",";p_{T} [GeV/c];#phi",100,-0.25,49.75,63,0,6.3);
338 fTrackPtPhi->Sumw2();
339 fQAList->Add(fTrackPtPhi);
340 fTrackPtPhiCut = new TH2F("fTrackPtPhiCut",";p_{T} [GeV/c];#phi",100,-0.25,49.75,63,0,6.3);
341 fTrackPtPhiCut->Sumw2();
342 fQAList->Add(fTrackPtPhiCut);
343 fTrackPtEta = new TH2F("fTrackPtEta",";p_{T} [GeV/c];#eta",100,-0.25,49.75,18,-0.9,0.9);
344 fTrackPtEta->Sumw2();
345 fQAList->Add(fTrackPtEta);
346 fTrackPtEtaCut = new TH2F("fTrackPtEtaCut",";p_{T} [GeV/c];#eta",100,-0.25,49.75,18,-0.9,0.9);
347 fTrackPtEtaCut->Sumw2();
348 fQAList->Add(fTrackPtEtaCut);
351 fMaxCellEPhi = new TH2F("fMaxCellEPhi","Most energetic cell in event; GeV;#phi",100,-0.25,49.75,63,0,6.3);
352 fMaxCellEPhi->Sumw2();
353 fQAList->Add(fMaxCellEPhi);
355 PostData(1, fOutputList);
356 PostData(2, fQAList);
359 //________________________________________________________________________
360 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
362 // Main loop, called for each event.
367 // event trigger selection
368 Bool_t isSelected = 0;
369 if(fPeriod.Contains("11a")){
370 if(fTrigBit.Contains("kEMC"))
371 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
373 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
376 if(fTrigBit.Contains("kEMC"))
377 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
379 if(fTrigBit.Contains("kMB"))
380 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
382 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
384 if(fPeriod.Contains("11h")){
385 if(fTrigBit.Contains("kAny"))
386 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAny);
387 if(fTrigBit.Contains("kAnyINT"))
388 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAnyINT);
393 printf("isSelected = %d, fIsMC=%d\n", isSelected, fIsMc);
397 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
398 TFile *file = (TFile*)tree->GetCurrentFile();
399 TString filename = file->GetName();
400 if(!filename.Contains(fPathStrOpt.Data()))
403 AliVEvent *event = (AliVEvent*)InputEvent();
405 printf("ERROR: event not available\n");
408 Int_t runnumber = InputEvent()->GetRunNumber() ;
410 printf("run number = %d\n",runnumber);
412 fESD = dynamic_cast<AliESDEvent*>(event);
414 fAOD = dynamic_cast<AliAODEvent*>(event);
416 printf("ERROR: Invalid type of event!!!\n");
420 printf("AOD EVENT!\n");
425 printf("event is ok,\n run number=%d\n",runnumber);
428 AliVVertex *pv = (AliVVertex*)event->GetPrimaryVertex();
429 Bool_t pvStatus = kTRUE;
431 AliESDVertex *esdv = (AliESDVertex*)fESD->GetPrimaryVertex();
432 pvStatus = esdv->GetStatus();
440 fPVtxZ->Fill(pv->GetZ());
441 if(TMath::Abs(pv->GetZ())>15)
444 printf("passed vertex cut\n");
448 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("Tracks"));
450 fTracks = dynamic_cast<TClonesArray*>(fAOD->GetTracks());
453 AliError("Track array in event is NULL!");
455 printf("returning due to not finding tracks!\n");
458 // Track loop to fill a pT spectrum
459 const Int_t Ntracks = fTracks->GetEntriesFast();
460 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
461 // for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
462 //AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
463 AliVTrack *track = (AliVTrack*)fTracks->At(iTracks);
466 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack*>(track);
467 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
468 if (esdTrack && fPrTrCuts && fPrTrCuts->IsSelected(track)){
469 fSelPrimTracks->Add(track);
470 /*if(fTrackMaxPt<track->Pt())
471 fTrackMaxPt = track->Pt();*/
472 //printf("pt,eta,phi:%1.1f,%1.1f,%1.1f \n",track->Pt(),track->Eta(), track->Phi());
475 fSelPrimTracks->Add(track);
476 /*if(fTrackMaxPt<track->Pt())
477 fTrackMaxPt = track->Pt();*/
481 TObjArray *matEMCAL=(TObjArray*)fOADBContainer->GetObject(runnumber,"EmcalMatrices");
482 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
483 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
486 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
488 // if(event->GetEMCALMatrix(mod))
489 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod);
490 fGeom->SetMisalMatrix(fGeomMatrix[mod] , mod);
494 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
495 fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
497 printf("ESD Track mult= %d\n",fTrackMult);
500 fTrackMult = Ntracks;
502 printf("AOD Track mult= %d\n",fTrackMult);
504 fTrMultDist->Fill(fTrackMult);
507 TList *l = fESD->GetList();
508 fESDClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
509 fESDCells = fESD->GetEMCALCells();
511 printf("ESD cluster mult= %d\n",fESDClusters->GetEntriesFast());
514 fAODClusters = dynamic_cast<TClonesArray*>(fAOD->GetCaloClusters());
515 fAODCells = fAOD->GetEMCALCells();
517 printf("AOD cluster mult= %d\n",fAODClusters->GetEntriesFast());
521 fMCEvent = MCEvent();
524 std::cout<<"MCevent exists\n";
525 fStack = (AliStack*)fMCEvent->Stack();
529 std::cout<<"ERROR: NO MC EVENT!!!!!!\n";
534 printf("passed calling of FollowGamma\n");
537 printf("passed calling of FillClusHists\n");
540 printf("passed calling of FillMcHists\n");
543 printf("passed calling of FillQA\n");
545 fESDClusters->Clear();*/
546 fSelPrimTracks->Clear();
550 PostData(1, fOutputList);
551 PostData(2, fQAList);
554 //________________________________________________________________________
555 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
558 printf("Inside FillClusHists()....\n");
559 // Fill cluster histograms.
560 TObjArray *clusters = fESDClusters;
563 clusters = fAODClusters;
565 printf("ESD clusters empty...");
569 printf(" and AOD clusters as well!!!\n");
575 const Int_t nclus = clusters->GetEntries();
579 printf("Inside FillClusHists and there are %d clusters\n",nclus);
583 for(Int_t ic=0;ic<nclus;ic++){
585 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
593 Double_t Emax = GetMaxCellEnergy( c, id);
594 Double_t Ecross = GetCrossEnergy( c, id);
595 if((1-Ecross/Emax)>fExoticCut)
597 Float_t clsPos[3] = {0,0,0};
598 c->GetPosition(clsPos);
599 TVector3 clsVec(clsPos);
600 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
602 printf("\tcluster eta=%1.1f,phi=%1.1f,E=%1.1f\n",clsVec.Eta(),clsVec.Phi(),c->E());
605 Float_t ceiso, cephiband, cecore;
606 Float_t triso, trphiband, trcore;
607 Float_t alliso, allphiband, allcore;
608 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
609 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
610 GetCeIso(clsVec, id, ceiso, cephiband, cecore);
611 GetTrIso(clsVec, triso, trphiband, trcore);
612 Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
613 if(Et>10 && Et<15 && dr>0.025){
614 fHigherPtConeM02->Fill(fHigherPtCone,c->GetM02());
616 printf("\t\tHigher track pt inside the cone: %1.1f GeV/c; M02=%1.2f\n",fHigherPtCone,c->GetM02());
618 alliso = ceiso + triso;
619 allphiband = cephiband + trphiband;
620 allcore = cecore + trcore;
621 Float_t ceisoue = cephiband/phibandArea*netConeArea;
622 Float_t trisoue = trphiband/phibandArea*netConeArea;
623 Float_t allisoue = allphiband/phibandArea*netConeArea;
624 Float_t mcptsum = GetMcPtSumInCone(clsVec.Eta(), clsVec.Phi(),fIsoConeR);
626 printf("\t alliso=%1.1f, Et=%1.1f=-=-=-=-=\n",alliso,Et);
627 if(c->GetM02()>0.5 && c->GetM02()<2.0){
628 fMcPtInConeBG->Fill(alliso-Et-allisoue, mcptsum);
629 fMcPtInConeBGnoUE->Fill(alliso-Et, mcptsum);
631 if(c->GetM02()>0.1 && c->GetM02()<0.3 && dr>0.03){
632 fMcPtInConeSBG->Fill(alliso-Et-allisoue, mcptsum);
633 fMcPtInConeSBGnoUE->Fill(alliso-Et, mcptsum);
634 if(fMcIdFamily.Contains((Form("%d",c->GetLabel())))){
635 fAllIsoEtMcGamma->Fill(Et, alliso-/*Et*/cecore-allisoue);
636 fAllIsoNoUeEtMcGamma->Fill(Et, alliso-/*Et*/cecore);
639 const Int_t ndims = fNDimensions;
640 Double_t outputValues[ndims];
641 ptmc = GetClusSource(c);
642 outputValues[0] = Et;
643 outputValues[1] = c->GetM02();
644 outputValues[2] = ceiso/*cecore*/-ceisoue;
645 outputValues[3] = triso-trisoue;
646 outputValues[4] = alliso/*cecore*/-allisoue - trcore;
647 outputValues[5] = ceiso;
648 outputValues[6] = alliso - trcore;
649 outputValues[7] = c->GetTrackDx();
650 outputValues[8] = c->GetTrackDz();
651 outputValues[9] = clsVec.Eta();
652 outputValues[10] = clsVec.Phi();
654 outputValues[11] = fESDCells->GetCellTime(id);
656 outputValues[11] = fAODCells->GetCellTime(id);
657 outputValues[12] = fTrackMult;
658 outputValues[13] = ptmc;
659 fHnOutput->Fill(outputValues);
663 fNClusHighClusE->Fill(maxE,nclus);
665 fNClusEt10->Fill(nclus10);
666 fNClusPerPho->Fill(fDirPhoPt,fNClusForDirPho);
669 //________________________________________________________________________
670 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Int_t maxid, Float_t &iso, Float_t &phiband, Float_t &core)
672 // Get cell isolation.
673 AliVCaloCells *cells = fESDCells;
677 printf("ESD cells empty...");
681 printf(" and AOD cells are empty as well!!!\n");
685 TObjArray *clusters = fESDClusters;
687 clusters = fAODClusters;
692 const Int_t nclus = clusters->GetEntries();
693 //const Int_t ncells = cells->GetNumberOfCells();
697 Float_t etacl = vec.Eta();
698 Float_t phicl = vec.Phi();
699 Float_t maxtcl = cells->GetCellTime(maxid);
701 phicl+=TMath::TwoPi();
703 Float_t eta=-1, phi=-1;
704 for(int icell=0;icell<ncells;icell++){
705 absid = TMath::Abs(cells->GetCellNumber(icell));
706 Float_t celltime = cells->GetCellTime(absid);
707 //if(TMath::Abs(celltime)>2e-8 && (!fIsMc))
708 if(TMath::Abs(celltime-maxtcl)>2e-8 )
712 fGeom->EtaPhiFromIndex(absid,eta,phi);
713 Float_t dphi = TMath::Abs(phi-phicl);
714 Float_t deta = TMath::Abs(eta-etacl);
715 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);*/
716 for(int ic=0;ic<nclus;ic++){
717 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
723 GetMaxCellEnergy( c, id);
724 Double_t maxct = cells->GetCellTime(id);
725 if(TMath::Abs(maxtcl-maxct)>2.5e-9)
727 Float_t clsPos[3] = {0,0,0};
728 c->GetPosition(clsPos);
730 Double_t Et = c->E()*TMath::Sin(cv.Theta());
731 Float_t dphi = TMath::Abs(cv.Phi()-phicl);
732 Float_t deta = TMath::Abs(cv.Eta()-etacl);
733 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
736 Double_t matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
737 Double_t nEt = TMath::Max(Et-matchedpt, 0.0);
739 printf("nEt=%1.1f\n",nEt);
757 //________________________________________________________________________
758 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
760 // Get track isolation.
765 const Int_t ntracks = fSelPrimTracks->GetEntries();
769 Double_t etacl = vec.Eta();
770 Double_t phicl = vec.Phi();
772 phicl+=TMath::TwoPi();
773 for(int itrack=0;itrack<ntracks;itrack++){
774 AliVTrack *track = static_cast<AliVTrack*> (fSelPrimTracks->At(itrack));
777 Double_t dphi = TMath::Abs(track->Phi()-phicl);
778 Double_t deta = TMath::Abs(track->Eta()-etacl);
779 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
780 Double_t pt = track->Pt();
784 totiso += track->Pt();
793 totband += track->Pt();
801 //________________________________________________________________________
802 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
804 // Calculate the energy of cross cells around the leading cell.
806 AliVCaloCells *cells = 0;
825 Double_t crossEnergy = 0;
827 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
828 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
830 Int_t ncells = cluster->GetNCells();
831 for (Int_t i=0; i<ncells; i++) {
832 Int_t cellAbsId = cluster->GetCellAbsId(i);
833 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
834 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
835 Int_t aphidiff = TMath::Abs(iphi-iphis);
838 Int_t aetadiff = TMath::Abs(ieta-ietas);
841 if ( (aphidiff==1 && aetadiff==0) ||
842 (aphidiff==0 && aetadiff==1) ) {
843 crossEnergy += cells->GetCellAmplitude(cellAbsId);
850 //________________________________________________________________________
851 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
853 // Get maximum energy of attached cell.
857 AliVCaloCells *cells = 0;
865 Int_t ncells = cluster->GetNCells();
866 for (Int_t i=0; i<ncells; i++) {
867 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
870 id = cluster->GetCellAbsId(i);
876 //________________________________________________________________________
877 void AliAnalysisTaskEMCALIsoPhoton ::FillMcHists()
881 Int_t nTracks = fStack->GetNtrack();
883 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
884 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
885 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
888 Int_t pdg = mcp->GetPdgCode();
891 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
893 Int_t imom = mcp->GetMother(0);
894 if(imom<0 || imom>nTracks)
896 TParticle *mcmom = static_cast<TParticle*>(fStack->Particle(imom));
899 Int_t pdgMom = mcmom->GetPdgCode();
900 if((imom==6 || imom==7) && pdgMom==22) {
901 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
902 if(fNClusForDirPho==0)
903 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
905 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());
906 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());
910 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
911 fDecayPhotonPtMC->Fill(mcp->Pt());
915 //________________________________________________________________________
916 Float_t AliAnalysisTaskEMCALIsoPhoton::GetClusSource(const AliVCluster *c)
922 Int_t nmcp = fStack->GetNtrack();
923 Int_t clabel = c->GetLabel();
924 if(fDebug && fMcIdFamily.Contains(Form("%d",clabel)))
925 printf("\n\t ==== Label %d is a descendent of the prompt photon ====\n\n",clabel);
926 if(!fMcIdFamily.Contains(Form("%d",clabel)))
929 TString partonposstr = (TSubString)fMcIdFamily.operator()(0,1);
930 Int_t partonpos = partonposstr.Atoi();
932 printf("\t^^^^ parton position = %d ^^^^\n",partonpos);
933 if(clabel<0 || clabel>nmcp)
935 Float_t clsPos[3] = {0,0,0};
936 c->GetPosition(clsPos);
937 TVector3 clsVec(clsPos);
938 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
939 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(partonpos));
943 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);
945 Int_t lab1 = mcp->GetFirstDaughter();
946 if(lab1<0 || lab1>nmcp)
948 TParticle *mcd = static_cast<TParticle*>(fStack->Particle(lab1));
952 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);
953 if(mcd->GetPdgCode()==22){
954 fClusEtMcPt->Fill(mcd->Pt(), Et);
955 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
958 printf("Warning: daughter of photon parton is not a photon\n");
963 //________________________________________________________________________
964 void AliAnalysisTaskEMCALIsoPhoton::FollowGamma()
969 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(selfid));
972 if(mcp->GetPdgCode()!=22){
973 mcp = static_cast<TParticle*>(fStack->Particle(++selfid));
977 Int_t daug0f = mcp->GetFirstDaughter();
978 Int_t daug0l = mcp->GetLastDaughter();
979 Int_t nd0 = daug0l - daug0f;
981 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);
982 fMcIdFamily = Form("%d,",selfid);
983 GetDaughtersInfo(daug0f,daug0l, selfid,"");
985 printf("\t---- end of the prompt gamma's family tree ----\n\n");
986 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
988 TParticle *md = static_cast<TParticle*>(fStack->Particle(daug0f));
991 fDirPhoPt = md->Pt();
993 //________________________________________________________________________
994 void AliAnalysisTaskEMCALIsoPhoton::GetDaughtersInfo(int firstd, int lastd, int selfid, const char *inputind)
996 int nmcp = fStack->GetNtrack();
997 if(firstd<0 || firstd>nmcp)
999 if(lastd<0 || lastd>nmcp)
1002 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1005 TString indenter = Form("\t%s",inputind);
1006 TParticle *dp = 0x0;
1008 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1009 for(int id=firstd; id<lastd+1; id++){
1010 dp = static_cast<TParticle*>(fStack->Particle(id));
1013 Int_t dfd = dp->GetFirstDaughter();
1014 Int_t dld = dp->GetLastDaughter();
1015 Int_t dnd = dld - dfd + 1;
1016 Float_t vr = TMath::Sqrt(dp->Vx()*dp->Vx()+dp->Vy()*dp->Vy());
1018 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);
1019 fMcIdFamily += Form("%d,",id);
1020 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1024 //________________________________________________________________________
1025 Float_t AliAnalysisTaskEMCALIsoPhoton::GetMcPtSumInCone(Float_t etaclus, Float_t phiclus, Float_t R)
1030 printf("Inside GetMcPtSumInCone!!\n");
1031 Int_t nTracks = fStack->GetNtrack();
1033 TString addpartlabels = "";
1034 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1035 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1038 Int_t firstd = mcp->GetFirstDaughter();
1039 Int_t lastd = mcp->GetLastDaughter();
1040 if((iTrack==6 || iTrack==7) && mcp->GetPdgCode()==22){
1041 for(Int_t id=firstd;id<=lastd;id++)
1042 addpartlabels += Form("%d,",id);
1049 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1051 Float_t dphi = mcp->Phi() - phiclus;
1052 Float_t deta = mcp->Eta() - etaclus;
1054 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1057 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1060 if(addpartlabels.Contains(Form("%d",iTrack))){
1062 printf(" >>>> list of particles included (and their daughters) %s\n",addpartlabels.Data());
1065 addpartlabels += Form("%d,",iTrack);
1066 for(Int_t id=firstd;id<=lastd;id++)
1067 addpartlabels += Form("%d,",id);
1072 //________________________________________________________________________
1073 void AliAnalysisTaskEMCALIsoPhoton::FillQA()
1077 const int ntracks = fSelPrimTracks->GetEntriesFast();
1078 const int ncells = fNCells50;//fESDCells->GetNumberOfCells();
1079 const Int_t nclus = fESDClusters->GetEntries();
1081 fNTracks->Fill(ntracks);
1082 fEmcNCells->Fill(ncells);
1083 fEmcNClus->Fill(nclus);
1084 if(fMaxEClus>fECut){
1085 fNTracksECut->Fill(ntracks);
1086 fEmcNCellsCut->Fill(ncells);
1087 fEmcNClusCut->Fill(nclus);
1089 for(int it=0;it<ntracks;it++){
1090 AliVTrack *t = (AliVTrack*)fSelPrimTracks->At(it);
1093 fTrackPtPhi->Fill(t->Pt(),t->Phi());
1094 fTrackPtEta->Fill(t->Pt(),t->Eta());
1095 if(fMaxEClus>fECut){
1096 fTrackPtPhiCut->Fill(t->Pt(), t->Phi());
1097 fTrackPtEtaCut->Fill(t->Pt(), t->Eta());
1100 for(int ic=0;ic<nclus;ic++){
1101 AliVCluster *c = dynamic_cast<AliVCluster*>(fESDClusters->At(ic));
1102 //AliESDCaloCluster *c = (AliESDCaloCluster*)fESDClusters->At(ic);
1107 Float_t clsPos[3] = {0,0,0};
1108 c->GetPosition(clsPos);
1109 TVector3 clsVec(clsPos);
1110 Double_t cphi = clsVec.Phi();
1111 Double_t ceta = clsVec.Eta();
1112 fEmcClusEPhi->Fill(c->E(), cphi);
1113 fEmcClusEEta->Fill(c->E(), ceta);
1114 if(fMaxEClus>fECut){
1115 fEmcClusEPhiCut->Fill(c->E(), cphi);
1116 fEmcClusEEtaCut->Fill(c->E(), ceta);
1120 //________________________________________________________________________
1121 Double_t AliAnalysisTaskEMCALIsoPhoton::GetTrackMatchedPt(Int_t matchIndex)
1126 if(matchIndex<0 || matchIndex>fTracks->GetEntries()){
1128 printf("track-matched index out of track array range!!!\n");
1131 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(matchIndex));
1134 printf("track-matched pointer does not exist!!!\n");
1140 if(!fPrTrCuts->IsSelected(track))
1146 //________________________________________________________________________
1147 void AliAnalysisTaskEMCALIsoPhoton::LoopOnCells()
1149 AliVCaloCells *cells = 0;
1156 Double_t maxphi = -10;
1157 Int_t ncells = cells->GetNumberOfCells();
1159 for (Int_t i=0; i<ncells; i++) {
1160 Short_t absid = TMath::Abs(cells->GetCellNumber(i));
1161 Double_t e = cells->GetCellAmplitude(absid);
1166 fGeom->EtaPhiFromIndex(absid,eta,phi);
1172 fMaxCellEPhi->Fill(maxe,maxphi);
1175 //________________________________________________________________________
1176 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
1178 // Called once at the end of the query.