]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/CaloCalib/AliAnalysisTaskEMCALPi0PbPb.cxx
Possibility to keep only D mesons that have a c or b quark as a grandmother (Francesc...
[u/mrichter/AliRoot.git] / PWG4 / CaloCalib / AliAnalysisTaskEMCALPi0PbPb.cxx
CommitLineData
ea3fd2d5 1// $Id$
2
ea3fd2d5 3#include "AliAnalysisTaskEMCALPi0PbPb.h"
fa443410 4#include <TAxis.h>
717fe7de 5#include <TChain.h>
6#include <TClonesArray.h>
f5d4ab70 7#include <TFile.h>
296ea9b4 8#include <TGeoGlobalMagField.h>
717fe7de 9#include <TH1F.h>
10#include <TH2F.h>
11#include <TList.h>
12#include <TLorentzVector.h>
f5d4ab70 13#include <TNtuple.h>
296ea9b4 14#include <TProfile.h>
15#include <TVector2.h>
717fe7de 16#include "AliAODEvent.h"
17#include "AliAODVertex.h"
18#include "AliAnalysisManager.h"
19#include "AliAnalysisTaskEMCALClusterizeFast.h"
296ea9b4 20#include "AliCDBManager.h"
ea3fd2d5 21#include "AliCentrality.h"
ea3fd2d5 22#include "AliEMCALGeoUtils.h"
0ec74551 23#include "AliEMCALGeometry.h"
296ea9b4 24#include "AliEMCALRecoUtils.h"
717fe7de 25#include "AliESDEvent.h"
26#include "AliESDVertex.h"
296ea9b4 27#include "AliESDtrack.h"
0ec74551 28#include "AliESDtrackCuts.h"
296ea9b4 29#include "AliGeomManager.h"
43cfaa06 30#include "AliLog.h"
296ea9b4 31#include "AliMagF.h"
0ec74551 32#include "AliTrackerBase.h"
ea3fd2d5 33
34ClassImp(AliAnalysisTaskEMCALPi0PbPb)
717fe7de 35
ea3fd2d5 36//________________________________________________________________________
37AliAnalysisTaskEMCALPi0PbPb::AliAnalysisTaskEMCALPi0PbPb(const char *name)
38 : AliAnalysisTaskSE(name),
717fe7de 39 fCentVar("V0M"),
40 fCentFrom(0),
41 fCentTo(100),
76332037 42 fVtxZMin(-10),
43 fVtxZMax(+10),
43cfaa06 44 fUseQualFlag(1),
717fe7de 45 fClusName(),
f5d4ab70 46 fDoNtuple(0),
a49742b5 47 fDoAfterburner(0),
f224d35b 48 fAsymMax(1),
a49742b5 49 fNminCells(1),
3c661da5 50 fMinE(0.100),
f224d35b 51 fMinErat(0),
52 fMinEcc(0),
6bf90832 53 fGeoName("EMCAL_FIRSTYEARV1"),
296ea9b4 54 fMinNClustPerTrack(50),
0ec74551 55 fMinPtPerTrack(1.0),
296ea9b4 56 fIsoDist(0.2),
0ec74551 57 fTrCuts(0),
d9f26424 58 fNEvs(0),
d595acbb 59 fGeom(0),
296ea9b4 60 fReco(0),
717fe7de 61 fOutput(0),
62 fEsdEv(0),
63 fAodEv(0),
43cfaa06 64 fRecPoints(0),
717fe7de 65 fEsdClusters(0),
66 fEsdCells(0),
67 fAodClusters(0),
286b47a5 68 fAodCells(0),
fa443410 69 fPtRanges(0),
f5d4ab70 70 fNtuple(0),
296ea9b4 71 fSelTracks(0),
fa443410 72 fHCuts(0x0),
73 fHVertexZ(0x0),
76332037 74 fHVertexZ2(0x0),
fa443410 75 fHCent(0x0),
76 fHCentQual(0x0),
d595acbb 77 fHColuRow(0x0),
78 fHColuRowE(0x0),
79 fHCellMult(0x0),
80 fHCellE(0x0),
81 fHCellH(0x0),
6eb6260e 82 fHCellM(0x0),
a49742b5 83 fHCellM2(0x0),
296ea9b4 84 fHCellFreqNoCut(0x0),
85 fHCellFrequCut100M(0x0),
86 fHCellFrequCut300M(0x0),
87 fHCellCheckE(0x0),
6eb6260e 88 fHClustEccentricity(0),
fa443410 89 fHClustEtaPhi(0x0),
90 fHClustEnergyPt(0x0),
91 fHClustEnergySigma(0x0),
d595acbb 92 fHClustSigmaSigma(0x0),
6eb6260e 93 fHClustNCellEnergyRatio(0x0),
fa443410 94 fHPionEtaPhi(0x0),
95 fHPionMggPt(0x0),
6eb6260e 96 fHPionMggAsym(0x0),
97 fHPionMggDgg(0x0)
ea3fd2d5 98{
717fe7de 99 // Constructor.
ea3fd2d5 100
d595acbb 101 if (!name)
102 return;
103 SetName(name);
ea3fd2d5 104 DefineInput(0, TChain::Class());
ea3fd2d5 105 DefineOutput(1, TList::Class());
296ea9b4 106 fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.,SPDVertex.,TPCVertex.,EMCALCells.,Tracks "
107 "AOD:header,vertices,emcalCells,tracks";
ea3fd2d5 108}
ea3fd2d5 109
717fe7de 110//________________________________________________________________________
111AliAnalysisTaskEMCALPi0PbPb::~AliAnalysisTaskEMCALPi0PbPb()
112{
113 // Destructor.
ea3fd2d5 114
717fe7de 115 delete fOutput; fOutput = 0;
fa443410 116 delete fPtRanges; fPtRanges = 0;
d595acbb 117 delete fGeom; fGeom = 0;
296ea9b4 118 delete fReco; fReco = 0;
119 delete fSelTracks;
d595acbb 120 delete [] fHColuRow;
121 delete [] fHColuRowE;
122 delete [] fHCellMult;
296ea9b4 123 delete [] fHCellFreqNoCut;
124 delete [] fHCellFrequCut100M;
125 delete [] fHCellFrequCut300M;
ea3fd2d5 126}
717fe7de 127
ea3fd2d5 128//________________________________________________________________________
129void AliAnalysisTaskEMCALPi0PbPb::UserCreateOutputObjects()
130{
717fe7de 131 // Create user objects here.
ea3fd2d5 132
296ea9b4 133 fGeom = new AliEMCALGeoUtils(fGeoName,"EMCAL");
134 fReco = new AliEMCALRecoUtils();
717fe7de 135 fOutput = new TList();
136 fOutput->SetOwner();
296ea9b4 137 fSelTracks = new TObjArray;
ea3fd2d5 138
f5d4ab70 139 if (fDoNtuple) {
140 TFile *f = OpenFile(1);
6bf90832 141 if (f) {
142 f->SetCompressionLevel(2);
6eb6260e 143 fNtuple = new TNtuple(Form("nt%.0fto%.0f",fCentFrom,fCentTo),"nt",
c4236a58 144 "run:evt:l0:cent:pt:eta:phi:e:emax:n:n1:db:disp:mn:ms:ecc:sig:tkdz:tkdr:tkep:tkiso:ceiso");
6bf90832 145 fNtuple->SetDirectory(f);
146 fNtuple->SetAutoFlush(-1024*1024*1024);
147 fNtuple->SetAutoSave(-1024*1024*1024);
148 }
f5d4ab70 149 }
150
d595acbb 151 // histograms
a49742b5 152 TH1::SetDefaultSumw2(kTRUE);
153 TH2::SetDefaultSumw2(kTRUE);
fa443410 154 fHCuts = new TH1F("hEventCuts","",4,0.5,4.5);
155 fHCuts->GetXaxis()->SetBinLabel(1,"All (PS)");
156 fHCuts->GetXaxis()->SetBinLabel(2,Form("%s: %.0f-%.0f",fCentVar.Data(),fCentFrom,fCentTo));
157 fHCuts->GetXaxis()->SetBinLabel(3,"QFlag");
158 fHCuts->GetXaxis()->SetBinLabel(4,Form("zvtx: %.0f-%.0f",fVtxZMin,fVtxZMax));
159 fOutput->Add(fHCuts);
160 fHVertexZ = new TH1F("hVertexZBeforeCut","",100,-25,25);
161 fHVertexZ->SetXTitle("z [cm]");
162 fOutput->Add(fHVertexZ);
76332037 163 fHVertexZ2 = new TH1F("hVertexZAfterCut","",100,-25,25);
164 fHVertexZ2->SetXTitle("z [cm]");
165 fOutput->Add(fHVertexZ2);
fa443410 166 fHCent = new TH1F("hCentBeforeCut","",101,-1,100);
167 fHCent->SetXTitle(fCentVar.Data());
76332037 168 fOutput->Add(fHCent);
fa443410 169 fHCentQual = new TH1F("hCentAfterCut","",101,-1,100);
170 fHCentQual->SetXTitle(fCentVar.Data());
171 fOutput->Add(fHCentQual);
90d5b88b 172
d595acbb 173 // histograms for cells
296ea9b4 174 Int_t nsm = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
175 fHColuRow = new TH2*[nsm];
176 fHColuRowE = new TH2*[nsm];
177 fHCellMult = new TH1*[nsm];
178 for (Int_t i = 0; i<nsm; ++i) {
d595acbb 179 fHColuRow[i] = new TH2F(Form("hColRow_Mod%d",i),"",49,0,49,25,0,25);
180 fHColuRow[i]->SetTitle(Form("Module %d: Occupancy", i));
181 fHColuRow[i]->SetXTitle("col (i#eta)");
182 fHColuRow[i]->SetYTitle("row (i#phi)");
183 fHColuRowE[i] = new TH2F(Form("hColRowE_Mod%d", i),"",49,0,49,25,0,25);
90d5b88b 184 fHColuRowE[i]->SetTitle(Form("Module %d: Cell energy",i));
d595acbb 185 fHColuRowE[i]->SetXTitle("col (i#eta)");
186 fHColuRowE[i]->SetYTitle("row (i#phi)");
187 fHCellMult[i] = new TH1F(Form("hCellMult_Mod%d",i),"",1000,0,1000);
188 fHCellMult[i]->SetTitle(Form("Module %d: Cell multiplicity",i));
90d5b88b 189 fHCellMult[i]->SetXTitle("# of cells");
d595acbb 190 fOutput->Add(fHColuRow[i]);
191 fOutput->Add(fHColuRowE[i]);
192 fOutput->Add(fHCellMult[i]);
193 }
a49742b5 194 fHCellE = new TH1F("hCellE","",150,0.,15.);
d595acbb 195 fHCellE->SetXTitle("E_{cell} [GeV]");
196 fOutput->Add(fHCellE);
a49742b5 197 fHCellH = new TH1F ("fHCellHighestE","",150,0.,15.);
6eb6260e 198 fHCellH->SetXTitle("E^{max}_{cell} [GeV]");
d595acbb 199 fOutput->Add(fHCellH);
a49742b5 200 fHCellM = new TH1F ("fHCellMeanEperHitCell","",250,0.,2.5);
6eb6260e 201 fHCellM->SetXTitle("#LT E_{cell}#GT [GeV]");
202 fOutput->Add(fHCellM);
a49742b5 203 fHCellM2 = new TH1F ("fHCellMeanEperAllCells","",250,0.,1);
f4ec884e 204 fHCellM2->SetXTitle("1/N_{cells} #Sigma E_{cell} [GeV]");
a49742b5 205 fOutput->Add(fHCellM2);
90d5b88b 206
296ea9b4 207 fHCellFreqNoCut = new TH1*[nsm];
208 fHCellFrequCut100M = new TH1*[nsm];
209 fHCellFrequCut300M = new TH1*[nsm];
210 for (Int_t i = 0; i<nsm; ++i){
211 Double_t lbin = i*24*48-0.5;
212 Double_t hbin = lbin+24*48;
213 fHCellFreqNoCut[i] = new TH1F(Form("fHCellFreqNoCut_SM%d",i),
214 Form("Frequency SM%d (no cut);id;#",i), 1152, lbin, hbin);
215 fHCellFrequCut100M[i] = new TH1F(Form("fHCellFreqCut100M_SM%d",i),
216 Form("Frequency SM%d (>0.1GeV);id;#",i), 1152, lbin, hbin);
217 fHCellFrequCut300M[i] = new TH1F(Form("fHCellFreqCut300M_SM%d",i),
218 Form("Frequency SM%d (>0.3GeV);id;#",i), 1152, lbin, hbin);
219 fOutput->Add(fHCellFreqNoCut[i]);
220 fOutput->Add(fHCellFrequCut100M[i]);
221 fOutput->Add(fHCellFrequCut300M[i]);
222 }
223 if (1) {
224 fHCellCheckE = new TH1*[24*48*nsm];
225 memset(fHCellCheckE,0,sizeof(fHCellCheckE));
226 Int_t tcs[1] = {4102};
227 for (UInt_t i = 0; i<sizeof(tcs)/sizeof(Int_t); ++i){
228 Int_t c=tcs[i];
229 if (c<24*48*nsm) {
230 fHCellCheckE[i] = new TH1F(Form("fHCellE_id%d",c), Form("Cell %d;E [GeV/c];#",c), 500, 0, 8);
231 fOutput->Add(fHCellCheckE[i]);
232 }
233 }
234 }
235
d595acbb 236 // histograms for clusters
6eb6260e 237 fHClustEccentricity = new TH1F("hClustEccentricity","",100,-0.1,1.1);
238 fHClustEccentricity->SetXTitle("#epsilon_{C}");
239 fOutput->Add(fHClustEccentricity);
a49742b5 240 fHClustEtaPhi = new TH2F("hClustEtaPhi","",500,-0.8,0.8,500,1.2,2.2);
fa443410 241 fHClustEtaPhi->SetXTitle("#eta");
242 fHClustEtaPhi->SetYTitle("#varphi");
243 fOutput->Add(fHClustEtaPhi);
244 fHClustEnergyPt = new TH2F("hClustEnergyPt","",250,0,50,250,0,50);
245 fHClustEnergyPt->SetXTitle("E [GeV]");
6eb6260e 246 fHClustEnergyPt->SetYTitle("p_{T} [GeV/c]");
fa443410 247 fOutput->Add(fHClustEnergyPt);
a49742b5 248 fHClustEnergySigma = new TH2F("hClustEnergySigma","",100,0,100,500,0,50);
249 fHClustEnergySigma->SetXTitle("E_{C} * #sigma_{max} [GeV*cm]");
6eb6260e 250 fHClustEnergySigma->SetYTitle("E_{C} [GeV]");
d595acbb 251 fOutput->Add(fHClustEnergySigma);
a49742b5 252 fHClustSigmaSigma = new TH2F("hClustSigmaSigma","",500,0,50,500,0,50);
6eb6260e 253 fHClustSigmaSigma->SetXTitle("#lambda_{0} [cm]");
254 fHClustSigmaSigma->SetYTitle("#sigma_{max} [cm]");
d595acbb 255 fOutput->Add(fHClustSigmaSigma);
6eb6260e 256 fHClustNCellEnergyRatio = new TH2F("hClustNCellEnergyRatio","",27,-0.5,26.5,101,-0.05,1.05);
257 fHClustNCellEnergyRatio->SetXTitle("N_{cells}");
258 fHClustNCellEnergyRatio->SetYTitle("E^{max}_{cell}/E_{clus}");
259 fOutput->Add(fHClustNCellEnergyRatio);
90d5b88b 260
d595acbb 261 // histograms for pion candidates
fa443410 262 fHPionEtaPhi = new TH2F("hPionEtaPhi","",100,-0.8,0.8,100,1.2,2.2);
a49742b5 263 fHPionEtaPhi->SetXTitle("#eta_{#gamma#gamma}");
264 fHPionEtaPhi->SetYTitle("#varphi_{#gamma#gamma}");
fa443410 265 fOutput->Add(fHPionEtaPhi);
a49742b5 266 fHPionMggPt = new TH2F("hPionMggPt","",1000,0,2,100,0,20.0);
fa443410 267 fHPionMggPt->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
268 fHPionMggPt->SetYTitle("p_{T}^{#gamma#gamma} [GeV/c]");
269 fOutput->Add(fHPionMggPt);
a49742b5 270 fHPionMggAsym = new TH2F("hPionMggAsym","",1000,0,2,100,0,1);
fa443410 271 fHPionMggAsym->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
272 fHPionMggAsym->SetYTitle("Z_{#gamma#gamma} [GeV]");
273 fOutput->Add(fHPionMggAsym);
a49742b5 274 fHPionMggDgg = new TH2F("hPionMggDgg","",1000,0,2,100,0,10);
6eb6260e 275 fHPionMggDgg->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
276 fHPionMggDgg->SetYTitle("opening angle [grad]");
277 fOutput->Add(fHPionMggDgg);
78204d3d 278 const Int_t nbins = 20;
279 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};
fa443410 280 fPtRanges = new TAxis(nbins-1,xbins);
281 for (Int_t i = 0; i<=nbins; ++i) {
a49742b5 282 fHPionInvMasses[i] = new TH1F(Form("hPionInvMass%d",i),"",1000,0,2);
fa443410 283 fHPionInvMasses[i]->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
284 if (i==0)
285 fHPionInvMasses[i]->SetTitle(Form("0 < p_{T}^{#gamma#gamma} <%.1f",xbins[0]));
286 else if (i==nbins)
287 fHPionInvMasses[i]->SetTitle(Form("p_{T}^{#gamma#gamma} > 50"));
288 else
289 fHPionInvMasses[i]->SetTitle(Form("%.1f < p_{T}^{#gamma#gamma} <%.1f",xbins[i-1],xbins[i]));
fa443410 290 fOutput->Add(fHPionInvMasses[i]);
291 }
296ea9b4 292
717fe7de 293 PostData(1, fOutput);
ea3fd2d5 294}
295
296//________________________________________________________________________
297void AliAnalysisTaskEMCALPi0PbPb::UserExec(Option_t *)
298{
717fe7de 299 // Called for each event.
300
301 if (!InputEvent())
302 return;
303
43cfaa06 304 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
305 fEsdEv = dynamic_cast<AliESDEvent*>(InputEvent());
306 if (fEsdEv) {
307 am->LoadBranch("AliESDRun.");
308 am->LoadBranch("AliESDHeader.");
309 } else {
310 fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
311 am->LoadBranch("header");
312 }
313
296ea9b4 314 if (fHCuts->GetEntries()==0) {
315 if (!AliGeomManager::GetGeometry()) { // get geometry
316 AliWarning("Accessing geometry from OCDB, this is not very efficient!");
317 AliCDBManager *cdb = AliCDBManager::Instance();
318 if (!cdb->IsDefaultStorageSet())
319 cdb->SetDefaultStorage("raw://");
320 Int_t runno = InputEvent()->GetRunNumber();
321 if (runno != cdb->GetRun())
322 cdb->SetRun(runno);
323 AliGeomManager::LoadGeometry();
324 }
325
326 if (fEsdEv) { // set misalignment matrices (stored in first event)
6bf90832 327 for (Int_t i=0; i<fGeom->GetEMCGeometry()->GetNumberOfSuperModules(); ++i)
d595acbb 328 fGeom->SetMisalMatrix(fEsdEv->GetESDRun()->GetEMCALMatrix(i),i);
329 } else {
6bf90832 330 for (Int_t i=0; i<fGeom->GetEMCGeometry()->GetNumberOfSuperModules(); ++i)
d595acbb 331 fGeom->SetMisalMatrix(fAodEv->GetHeader()->GetEMCALMatrix(i),i);
332 }
296ea9b4 333
334 if (!TGeoGlobalMagField::Instance()->GetField()) { // construct field map
335 if (fEsdEv) {
336 const AliESDRun *erun = fEsdEv->GetESDRun();
337 AliMagF *field = AliMagF::CreateFieldMap(erun->GetCurrentL3(),
338 erun->GetCurrentDip(),
339 AliMagF::kConvLHC,
340 kFALSE,
341 erun->GetBeamEnergy(),
342 erun->GetBeamType());
343 TGeoGlobalMagField::Instance()->SetField(field);
344 } else {
345 Double_t pol = -1; //polarity
346 Double_t be = -1; //beam energy
347 AliMagF::BeamType_t btype = AliMagF::kBeamTypepp;
348 Int_t runno = fAodEv->GetRunNumber();
349 if (runno>=136851 && runno<138275) {
350 pol = -1;
351 be = 2760;
352 btype = AliMagF::kBeamTypeAA;
353 } else if (runno>=138275 && runno<=139517) {
354 pol = +1;
355 be = 2760;
356 btype = AliMagF::kBeamTypeAA;
357 } else {
358 AliError(Form("Do not know the bfield parameters for run %d! Using defaults!!!", runno));
359 }
360 TGeoGlobalMagField::Instance()->SetField(new AliMagF("Maps","Maps", pol, pol, AliMagF::k5kG, btype, be));
361 }
362 }
d595acbb 363 }
364
286b47a5 365 Int_t cut = 1;
fa443410 366 fHCuts->Fill(cut++);
286b47a5 367
717fe7de 368 const AliCentrality *centP = InputEvent()->GetCentrality();
369 Double_t cent = centP->GetCentralityPercentileUnchecked(fCentVar);
fa443410 370 fHCent->Fill(cent);
717fe7de 371 if (cent<fCentFrom||cent>fCentTo)
286b47a5 372 return;
43cfaa06 373
fa443410 374 fHCuts->Fill(cut++);
286b47a5 375
43cfaa06 376 if (fUseQualFlag) {
377 if (centP->GetQuality()>0)
378 return;
379 }
286b47a5 380
fa443410 381 fHCentQual->Fill(cent);
382 fHCuts->Fill(cut++);
717fe7de 383
d9f26424 384 // count number of accepted events
385 ++fNEvs;
386
43cfaa06 387 if (fEsdEv) {
fa443410 388 am->LoadBranch("PrimaryVertex.");
389 am->LoadBranch("SPDVertex.");
390 am->LoadBranch("TPCVertex.");
43cfaa06 391 } else {
392 fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
393 am->LoadBranch("vertices");
3c661da5 394 if (!fAodEv) return;
43cfaa06 395 }
396
397 const AliVVertex *vertex = InputEvent()->GetPrimaryVertex();
717fe7de 398 if (!vertex)
399 return;
400
fa443410 401 fHVertexZ->Fill(vertex->GetZ());
286b47a5 402
717fe7de 403 if(vertex->GetZ()<fVtxZMin||vertex->GetZ()>fVtxZMax)
404 return;
286b47a5 405
fa443410 406 fHCuts->Fill(cut++);
76332037 407 fHVertexZ2->Fill(vertex->GetZ());
717fe7de 408
43cfaa06 409 fRecPoints = 0; // will be set if fClusName is given and AliAnalysisTaskEMCALClusterizeFast is used
410 fEsdClusters = 0; // will be set if ESD input used and if fRecPoints are not set of if clusters are attached
411 fEsdCells = 0; // will be set if ESD input used
412 fAodClusters = 0; // will be set if AOD input used and if fRecPoints are not set of if clusters are attached
413 // or if fClusName is given and AliAnalysisTaskEMCALClusterizeFast in AOD output mode
414 fAodCells = 0; // will be set if AOD input used
717fe7de 415
43cfaa06 416 // deal with special output from AliAnalysisTaskEMCALClusterizeFast first
417 Bool_t clusattached = 0;
418 Bool_t recalibrated = 0;
419 if (1 && !fClusName.IsNull()) {
420 AliAnalysisTaskEMCALClusterizeFast *cltask = 0;
421 TObjArray *ts = am->GetTasks();
422 cltask = dynamic_cast<AliAnalysisTaskEMCALClusterizeFast*>(ts->FindObject(fClusName));
423 if (cltask && cltask->GetClusters()) {
d595acbb 424 fRecPoints = const_cast<TObjArray*>(cltask->GetClusters());
43cfaa06 425 clusattached = cltask->GetAttachClusters();
426 if (cltask->GetCalibData()!=0)
427 recalibrated = kTRUE;
428 }
429 }
430 if (1 && AODEvent() && !fClusName.IsNull()) {
717fe7de 431 TList *l = AODEvent()->GetList();
432 TClonesArray *clus = 0;
433 if (l) {
434 clus = dynamic_cast<TClonesArray*>(l->FindObject(fClusName));
435 fAodClusters = clus;
436 }
ea3fd2d5 437 }
717fe7de 438
439 if (fEsdEv) { // ESD input mode
43cfaa06 440 if (1 && (!fRecPoints||clusattached)) {
441 if (!clusattached)
442 am->LoadBranch("CaloClusters");
717fe7de 443 TList *l = fEsdEv->GetList();
444 TClonesArray *clus = 0;
445 if (l) {
446 clus = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
447 fEsdClusters = clus;
ea3fd2d5 448 }
449 }
43cfaa06 450 if (1) {
451 if (!recalibrated)
452 am->LoadBranch("EMCALCells.");
717fe7de 453 fEsdCells = fEsdEv->GetEMCALCells();
454 }
455 } else if (fAodEv) { // AOD input mode
43cfaa06 456 if (1 && (!fAodClusters || clusattached)) {
457 if (!clusattached)
458 am->LoadBranch("caloClusters");
717fe7de 459 TList *l = fAodEv->GetList();
460 TClonesArray *clus = 0;
461 if (l) {
462 clus = dynamic_cast<TClonesArray*>(l->FindObject("caloClusters"));
463 fAodClusters = clus;
ea3fd2d5 464 }
465 }
43cfaa06 466 if (1) {
467 if (!recalibrated)
468 am->LoadBranch("emcalCells");
717fe7de 469 fAodCells = fAodEv->GetEMCALCells();
470 }
471 } else {
472 AliFatal("Impossible to not have either pointer to ESD or AOD event");
473 }
ea3fd2d5 474
43cfaa06 475 if (1) {
476 AliDebug(2,Form("fRecPoints set: %p", fRecPoints));
477 AliDebug(2,Form("fEsdClusters set: %p", fEsdClusters));
478 AliDebug(2,Form("fEsdCells set: %p", fEsdCells));
479 AliDebug(2,Form("fAodClusters set: %p", fAodClusters));
480 AliDebug(2,Form("fAodCells set: %p", fAodCells));
481 }
482
a49742b5 483 if (fDoAfterburner)
484 ClusterAfterburner();
6eb6260e 485
296ea9b4 486 CalcTracks();
487 CalcClusterProps();
488
286b47a5 489 FillCellHists();
490 FillClusHists();
491 FillPionHists();
323834f0 492 FillOtherHists();
ea3fd2d5 493
717fe7de 494 PostData(1, fOutput);
ea3fd2d5 495}
496
497//________________________________________________________________________
498void AliAnalysisTaskEMCALPi0PbPb::Terminate(Option_t *)
499{
717fe7de 500 // Terminate called at the end of analysis.
f5d4ab70 501
502 if (fNtuple) {
503 TFile *f = OpenFile(1);
504 if (f)
505 fNtuple->Write();
506 }
d9f26424 507
f224d35b 508 AliInfo(Form("\n%s: Accepted %lld events", GetName(), fNEvs));
ea3fd2d5 509}
ea3fd2d5 510
296ea9b4 511//________________________________________________________________________
512void AliAnalysisTaskEMCALPi0PbPb::CalcTracks()
513{
514 // Calculate track properties.
515
516 fSelTracks->Clear();
517
518 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
519 TClonesArray *tracks = 0;
520 if (fEsdEv) {
521 am->LoadBranch("Tracks");
522 TList *l = fEsdEv->GetList();
523 tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
524 } else {
525 am->LoadBranch("tracks");
526 TList *l = fAodEv->GetList();
527 tracks = dynamic_cast<TClonesArray*>(l->FindObject("tracks"));
528 }
529
530 if (!tracks)
531 return;
532
0ec74551 533 AliEMCALEMCGeometry *emc = fGeom->GetEMCGeometry();
534 Double_t phimin = emc->GetArm1PhiMin()*TMath::DegToRad()-0.25;
535 Double_t phimax = emc->GetArm1PhiMax()*TMath::DegToRad()+0.25;
536
296ea9b4 537 if (fEsdEv) {
0ec74551 538 fSelTracks->SetOwner(kTRUE);
539 am->LoadBranch("PrimaryVertex.");
540 const AliESDVertex *vtx = fEsdEv->GetPrimaryVertexSPD();
541 am->LoadBranch("SPDVertex.");
542 const AliESDVertex *vtxSPD = fEsdEv->GetPrimaryVertexSPD();
543 am->LoadBranch("Tracks");
544 const Int_t Ntracks = tracks->GetEntries();
545 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
546 AliESDtrack *track = static_cast<AliESDtrack*>(tracks->At(iTracks));
547 if (!track) {
548 AliWarning(Form("Could not receive track %d\n", iTracks));
549 continue;
550 }
551 if (fTrCuts && !fTrCuts->IsSelected(track))
296ea9b4 552 continue;
553 Double_t eta = track->Eta();
554 if (eta<-1||eta>1)
555 continue;
0ec74551 556 if (track->Phi()<phimin||track->Phi()>phimax)
557 continue;
296ea9b4 558 Double_t pt = track->Pt();
559 if (pt<fMinPtPerTrack)
560 continue;
561 if(track->GetTPCNcls()<fMinNClustPerTrack)
562 continue;
0ec74551 563 AliESDtrack copyt(*track);
564 Double_t bfield[3];
565 copyt.GetBxByBz(bfield);
566 AliExternalTrackParam tParam;
567 Bool_t relate = copyt.RelateToVertexBxByBz(vtxSPD,bfield,kVeryBig,&tParam);
568 if (!relate)
569 continue;
570 copyt.Set(tParam.GetX(),tParam.GetAlpha(),tParam.GetParameter(),tParam.GetCovariance());
571 Double_t p[3] = { 0. };
572 copyt.GetPxPyPz(p);
573 Double_t pos[3] = { 0. };
574 copyt.GetXYZ(pos);
575 Double_t covTr[21] = { 0. };
576 copyt.GetCovarianceXYZPxPyPz(covTr);
577 Double_t pid[10] = { 0. };
578 copyt.GetESDpid(pid);
579 AliAODTrack *aTrack = new AliAODTrack(copyt.GetID(),
580 copyt.GetLabel(),
581 p,
582 kTRUE,
583 pos,
584 kFALSE,
585 covTr,
586 (Short_t)copyt.GetSign(),
587 copyt.GetITSClusterMap(),
588 pid,
589 0,/*fPrimaryVertex,*/
590 kTRUE, // check if this is right
591 vtx->UsesTrack(copyt.GetID()));
592 aTrack->SetTPCClusterMap(copyt.GetTPCClusterMap());
593 aTrack->SetTPCSharedMap (copyt.GetTPCSharedMap());
594 Float_t ndf = copyt.GetTPCNcls() + 1 - 5 ;
595 if(ndf>0)
596 aTrack->SetChi2perNDF(copyt.GetTPCchi2()/ndf);
597 else
598 aTrack->SetChi2perNDF(-1);
599 aTrack->SetFlags(copyt.GetStatus());
600 aTrack->SetTPCPointsF(copyt.GetTPCNclsF());
601 fSelTracks->Add(aTrack);
296ea9b4 602 }
603 } else {
604 Int_t ntracks = tracks->GetEntries();
605 for (Int_t i=0; i<ntracks; ++i) {
606 AliAODTrack *track = static_cast<AliAODTrack*>(tracks->At(i));
607 if (!track)
608 continue;
609 Double_t eta = track->Eta();
610 if (eta<-1||eta>1)
611 continue;
0ec74551 612 if (track->Phi()<phimin||track->Phi()>phimax)
613 continue;
296ea9b4 614 Double_t pt = track->Pt();
615 if (pt<fMinPtPerTrack)
616 continue;
617 if(track->GetTPCNcls()<fMinNClustPerTrack)
618 continue;
c4236a58 619
620 if (0 && (pt>=0.6) && (track->PxAtDCA()==-999)) { // compute position on EMCAL
621 AliExternalTrackParam tParam(track);
622 if (AliTrackerBase::PropagateTrackToBxByBz(&tParam, 438, 0.139, 1, kTRUE)) {
623 Double_t trkPos[3];
624 tParam.GetXYZ(trkPos);
625 track->SetPxPyPzAtDCA(trkPos[0],trkPos[1],trkPos[2]);
626 }
627 }
296ea9b4 628 fSelTracks->Add(track);
629 }
630 }
631}
632
633//________________________________________________________________________
634void AliAnalysisTaskEMCALPi0PbPb::CalcClusterProps()
635{
636 // Calculate cluster properties
637
638 TObjArray *clusters = fEsdClusters;
639 if (!clusters)
640 clusters = fAodClusters;
641 if (!clusters)
642 return;
643
644 Int_t nclus = clusters->GetEntries();
c4236a58 645 Int_t ntrks = fSelTracks->GetEntries();
646
296ea9b4 647 for(Int_t i = 0; i<nclus; ++i) {
648 fClusProps[i].Reset();
649
650 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
651 if (!clus)
652 continue;
653 if (!clus->IsEMCAL())
654 continue;
655 if (clus->E()<fMinE)
656 continue;
657
658 Float_t clsPos[3] = {0};
659 clus->GetPosition(clsPos);
c4236a58 660 Double_t vertex[3] = {0};
661 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
662 TLorentzVector clusterVec;
663 clus->GetMomentum(clusterVec,vertex);
664 Double_t clsEta = clusterVec.Eta();
296ea9b4 665
296ea9b4 666 Double_t mind2 = 1e10;
667 for(Int_t j = 0; j<ntrks; ++j) {
668 AliVTrack *track = static_cast<AliVTrack*>(fSelTracks->At(j));
669 if (!track)
670 continue;
671 if (track->Pt()<0.6)
672 continue;
c4236a58 673 if (TMath::Abs(clsEta-track->Eta())>fIsoDist)
674 continue;
675
296ea9b4 676 AliExternalTrackParam tParam(track);
677 Float_t tmpR=-1, tmpZ=-1;
678 if (!fReco->ExtrapolateTrackToCluster(&tParam, clus, tmpR, tmpZ))
679 continue;
c4236a58 680 Double_t d2 = tmpR;
296ea9b4 681 if (mind2>d2) {
682 mind2=d2;
683 fClusProps[i].fTrIndex = j;
684 fClusProps[i].fTrDz = tmpZ;
c4236a58 685 fClusProps[i].fTrDr = TMath::Sqrt(tmpR*tmpR-tmpZ*tmpZ);
296ea9b4 686 fClusProps[i].fTrDist = d2;
687 fClusProps[i].fTrEp = clus->E()/track->P();
688 }
689 }
690
c4236a58 691 if (0 && (fClusProps[i].fTrIndex>=0)) {
692 cout << i << " " << fClusProps[i].fTrIndex << ": Dr " << fClusProps[i].fTrDr << " " << " Dz " << fClusProps[i].fTrDz << endl;
693 }
296ea9b4 694 if (1) {
296ea9b4 695 fClusProps[i].fTrIso = GetTrackIsolation(clusterVec.Eta(),clusterVec.Phi(),fIsoDist);
696 fClusProps[i].fTrLowPtIso = 0;
697 }
698 if (1) {
699 TVector3 pVec(clsPos);
700 fClusProps[i].fCellIso = GetCellIsolation(pVec.Eta(),pVec.Phi(),fIsoDist);
701 }
702 }
703}
704
323834f0 705//________________________________________________________________________
706void AliAnalysisTaskEMCALPi0PbPb::ClusterAfterburner()
707{
296ea9b4 708 // Run custer reconstruction afterburner.
323834f0 709
710 AliVCaloCells *cells = fEsdCells;
711 if (!cells)
712 cells = fAodCells;
713
714 if (!cells)
715 return;
716
717 Int_t ncells = cells->GetNumberOfCells();
718 if (ncells<=0)
719 return;
720
721 Double_t cellMeanE = 0, cellSigE = 0;
722 for (Int_t i = 0; i<ncells; ++i) {
723 Double_t cellE = cells->GetAmplitude(i);
724 cellMeanE += cellE;
725 cellSigE += cellE*cellE;
726 }
727 cellMeanE /= ncells;
728 cellSigE /= ncells;
729 cellSigE -= cellMeanE*cellMeanE;
730 if (cellSigE<0)
731 cellSigE = 0;
732 cellSigE = TMath::Sqrt(cellSigE / ncells);
733
734 Double_t subE = cellMeanE - 7*cellSigE;
735 if (subE<0)
736 return;
737
738 for (Int_t i = 0; i<ncells; ++i) {
739 Short_t id=-1;
740 Double_t amp=0,time=0;
741 if (!cells->GetCell(i, id, amp, time))
742 continue;
743 amp -= cellMeanE;
744 if (amp<0.001)
745 amp = 0;
746 cells->SetCell(i, id, amp, time);
747 }
748
749 TObjArray *clusters = fEsdClusters;
750 if (!clusters)
751 clusters = fAodClusters;
323834f0 752 if (!clusters)
753 return;
754
755 Int_t nclus = clusters->GetEntries();
756 for (Int_t i = 0; i<nclus; ++i) {
757 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
758 if (!clus->IsEMCAL())
759 continue;
760 Int_t nc = clus->GetNCells();
761 Double_t clusE = 0;
762 UShort_t ids[100] = {0};
763 Double_t fra[100] = {0};
764 for (Int_t j = 0; j<nc; ++j) {
765 Short_t id = TMath::Abs(clus->GetCellAbsId(j));
766 Double_t cen = cells->GetCellAmplitude(id);
767 clusE += cen;
768 if (cen>0) {
769 ids[nc] = id;
770 ++nc;
771 }
772 }
773 if (clusE<=0) {
774 clusters->RemoveAt(i);
775 continue;
776 }
777
778 for (Int_t j = 0; j<nc; ++j) {
779 Short_t id = ids[j];
780 Double_t cen = cells->GetCellAmplitude(id);
781 fra[j] = cen/clusE;
782 }
783 clus->SetE(clusE);
784 AliAODCaloCluster *aodclus = dynamic_cast<AliAODCaloCluster*>(clus);
785 if (aodclus) {
786 aodclus->Clear("");
787 aodclus->SetNCells(nc);
788 aodclus->SetCellsAmplitudeFraction(fra);
789 aodclus->SetCellsAbsId(ids);
790 }
791 }
792 clusters->Compress();
793}
794
286b47a5 795//________________________________________________________________________
796void AliAnalysisTaskEMCALPi0PbPb::FillCellHists()
797{
798 // Fill histograms related to cell properties.
d595acbb 799
90d5b88b 800 AliVCaloCells *cells = fEsdCells;
801 if (!cells)
802 cells = fAodCells;
803
296ea9b4 804 if (!cells)
805 return;
90d5b88b 806
296ea9b4 807 Int_t cellModCount[12] = {0};
808 Double_t cellMaxE = 0;
809 Double_t cellMeanE = 0;
810 Int_t ncells = cells->GetNumberOfCells();
811 if (ncells==0)
812 return;
813
814 Int_t nsm = fGeom->GetEMCGeometry()->GetNumberOfSuperModules();
815
816 for (Int_t i = 0; i<ncells; ++i) {
817 Int_t absID = TMath::Abs(cells->GetCellNumber(i));
818 Double_t cellE = cells->GetAmplitude(i);
819 fHCellE->Fill(cellE);
820 if (cellE>cellMaxE)
821 cellMaxE = cellE;
822 cellMeanE += cellE;
823
824 Int_t iSM=-1, iTower=-1, nIphi=-1, nIeta=-1;
825 Bool_t ret = fGeom->GetCellIndex(absID, iSM, iTower, nIphi, nIeta);
826 if (!ret) {
827 AliError(Form("Could not get cell index for %d", absID));
828 continue;
829 }
830 ++cellModCount[iSM];
831 Int_t iPhi=-1, iEta=-1;
832 fGeom->GetCellPhiEtaIndexInSModule(iSM, iTower, nIphi, nIeta, iPhi, iEta);
833 fHColuRow[iSM]->Fill(iEta,iPhi,1);
834 fHColuRowE[iSM]->Fill(iEta,iPhi,cellE);
835 fHCellFreqNoCut[iSM]->Fill(absID);
836 if (cellE > 0.1) fHCellFrequCut100M[iSM]->Fill(absID);
837 if (cellE > 0.3) fHCellFrequCut300M[iSM]->Fill(absID);
838 if (fHCellCheckE && fHCellCheckE[absID])
839 fHCellCheckE[absID]->Fill(cellE);
840 }
841 fHCellH->Fill(cellMaxE);
842 cellMeanE /= ncells;
843 fHCellM->Fill(cellMeanE);
844 fHCellM2->Fill(cellMeanE*ncells/24/48/nsm);
845 for (Int_t i=0; i<nsm; ++i)
846 fHCellMult[i]->Fill(cellModCount[i]);
286b47a5 847}
848
849//________________________________________________________________________
850void AliAnalysisTaskEMCALPi0PbPb::FillClusHists()
851{
90d5b88b 852 // Fill histograms related to cluster properties.
fa443410 853
90d5b88b 854 TObjArray *clusters = fEsdClusters;
855 if (!clusters)
856 clusters = fAodClusters;
296ea9b4 857 if (!clusters)
858 return;
90d5b88b 859
296ea9b4 860 Double_t vertex[3] = {0};
861 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
862
863 Int_t nclus = clusters->GetEntries();
864 for(Int_t i = 0; i<nclus; ++i) {
865 AliVCluster *clus = static_cast<AliVCluster*>(clusters->At(i));
866 if (!clus)
867 continue;
868 if (!clus->IsEMCAL())
869 continue;
90d5b88b 870 TLorentzVector clusterVec;
296ea9b4 871 clus->GetMomentum(clusterVec,vertex);
872 Double_t maxAxis = 0, minAxis = 0;
873 GetSigma(clus,maxAxis,minAxis);
874 Double_t clusterEcc = 0;
875 if (maxAxis > 0)
876 clusterEcc = TMath::Sqrt(1.0 - minAxis*minAxis/(maxAxis*maxAxis));
877 clus->SetChi2(clusterEcc); // store ecc in chi2
878 fHClustEccentricity->Fill(clusterEcc);
879 fHClustEtaPhi->Fill(clusterVec.Eta(),clusterVec.Phi());
880 fHClustEnergyPt->Fill(clusterVec.E(),clusterVec.Pt());
881 fHClustEnergySigma->Fill(clus->E()*maxAxis,clus->E());
882 fHClustSigmaSigma->Fill(max(clus->GetM02(),clus->GetM20()),clus->E()*maxAxis);
883 fHClustNCellEnergyRatio->Fill(clus->GetNCells(),GetMaxCellEnergy(clus)/clus->E());
884 if (fNtuple) {
885 if (clus->E()<fMinE)
fa443410 886 continue;
c4236a58 887 Float_t vals[22];
296ea9b4 888 vals[0] = InputEvent()->GetRunNumber();
889 vals[1] = (((UInt_t)InputEvent()->GetOrbitNumber() << 12) | (UInt_t)InputEvent()->GetBunchCrossNumber());
890 if (vals[1]<=0)
891 vals[1] = fNEvs;
892 AliESDHeader *h = dynamic_cast<AliESDHeader*>(InputEvent()->GetHeader());
893 if (h)
894 vals[2] = h->GetL0TriggerInputs();
895 else {
896 AliAODHeader *h2 = dynamic_cast<AliAODHeader*>(InputEvent()->GetHeader());
897 if (h2)
898 vals[2] = h2->GetL0TriggerInputs();
899 else
900 vals[2] = 0;
a49742b5 901 }
296ea9b4 902 vals[3] = InputEvent()->GetCentrality()->GetCentralityPercentileUnchecked(fCentVar);
903 vals[4] = clusterVec.Pt();
904 vals[5] = clusterVec.Eta();
905 vals[6] = clusterVec.Phi();
906 vals[7] = clusterVec.E();
907 vals[8] = GetMaxCellEnergy(clus);
908 vals[9] = clus->GetNCells();
909 vals[10] = GetNCells(clus,0.100);
910 vals[11] = clus->GetDistanceToBadChannel();
911 vals[12] = clus->GetDispersion();
912 vals[13] = clus->GetM20();
913 vals[14] = clus->GetM02();
914 vals[15] = clusterEcc;
915 vals[16] = maxAxis;
916 vals[17] = fClusProps[i].fTrDz;
917 vals[18] = fClusProps[i].fTrDr;
c4236a58 918 vals[19] = fClusProps[i].fTrEp;
919 vals[20] = fClusProps[i].fTrIso;
920 vals[21] = fClusProps[i].fCellIso;
296ea9b4 921 fNtuple->Fill(vals);
fa443410 922 }
923 }
286b47a5 924}
925
926//________________________________________________________________________
927void AliAnalysisTaskEMCALPi0PbPb::FillPionHists()
928{
929 // Fill histograms related to pions.
286b47a5 930
296ea9b4 931 Double_t vertex[3] = {0};
fa443410 932 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
933
90d5b88b 934 TObjArray *clusters = fEsdClusters;
935 if (!clusters)
936 clusters = fAodClusters;
fa443410 937
90d5b88b 938 if (clusters) {
939 TLorentzVector clusterVec1;
940 TLorentzVector clusterVec2;
941 TLorentzVector pionVec;
942
943 Int_t nclus = clusters->GetEntries();
fa443410 944 for (Int_t i = 0; i<nclus; ++i) {
90d5b88b 945 AliVCluster *clus1 = static_cast<AliVCluster*>(clusters->At(i));
fa443410 946 if (!clus1)
947 continue;
948 if (!clus1->IsEMCAL())
949 continue;
3c661da5 950 if (clus1->E()<fMinE)
6eb6260e 951 continue;
a49742b5 952 if (clus1->GetNCells()<fNminCells)
953 continue;
f224d35b 954 if (GetMaxCellEnergy(clus1)/clus1->E()<fMinErat)
955 continue;
3c661da5 956 if (clus1->Chi2()<fMinEcc) // eccentricity cut
f224d35b 957 continue;
fa443410 958 clus1->GetMomentum(clusterVec1,vertex);
959 for (Int_t j = i+1; j<nclus; ++j) {
90d5b88b 960 AliVCluster *clus2 = static_cast<AliVCluster*>(clusters->At(j));
fa443410 961 if (!clus2)
962 continue;
963 if (!clus2->IsEMCAL())
964 continue;
3c661da5 965 if (clus2->E()<fMinE)
6eb6260e 966 continue;
a49742b5 967 if (clus2->GetNCells()<fNminCells)
968 continue;
f224d35b 969 if (GetMaxCellEnergy(clus2)/clus2->E()<fMinErat)
970 continue;
3c661da5 971 if (clus2->Chi2()<fMinEcc) // eccentricity cut
f224d35b 972 continue;
fa443410 973 clus2->GetMomentum(clusterVec2,vertex);
974 pionVec = clusterVec1 + clusterVec2;
975 Double_t pionZgg = TMath::Abs(clusterVec1.E()-clusterVec2.E())/pionVec.E();
6eb6260e 976 Double_t pionOpeningAngle = clusterVec1.Angle(clusterVec2.Vect());
d595acbb 977 if (pionZgg < fAsymMax) {
978 fHPionEtaPhi->Fill(pionVec.Eta(),pionVec.Phi());
979 fHPionMggPt->Fill(pionVec.M(),pionVec.Pt());
980 fHPionMggAsym->Fill(pionVec.M(),pionZgg);
6eb6260e 981 fHPionMggDgg->Fill(pionVec.M(),pionOpeningAngle);
d595acbb 982 Int_t bin = fPtRanges->FindBin(pionVec.Pt());
983 fHPionInvMasses[bin]->Fill(pionVec.M());
984 }
fa443410 985 }
986 }
90d5b88b 987 }
fa443410 988}
d595acbb 989
6eb6260e 990//________________________________________________________________________
323834f0 991void AliAnalysisTaskEMCALPi0PbPb::FillOtherHists()
6eb6260e 992{
323834f0 993 // Fill histograms related to cell properties.
6eb6260e 994}
995
d595acbb 996//________________________________________________________________________
296ea9b4 997Double_t AliAnalysisTaskEMCALPi0PbPb::GetCellIsolation(Double_t cEta, Double_t cPhi, Double_t radius) const
998{
999 // Compute isolation based on cell content.
1000
1001 AliVCaloCells *cells = fEsdCells;
1002 if (!cells)
1003 cells = fAodCells;
1004 if (!cells)
1005 return 0;
1006
1007 Double_t cellIsolation = 0;
1008 Double_t rad2 = radius*radius;
1009 Int_t ncells = cells->GetNumberOfCells();
1010 for (Int_t i = 0; i<ncells; ++i) {
1011 Int_t absID = TMath::Abs(cells->GetCellNumber(i));
1012 Double_t cellE = cells->GetAmplitude(i);
1013 Float_t eta, phi;
1014 fGeom->EtaPhiFromIndex(absID,eta,phi);
1015 Double_t phidiff = TVector2::Phi_0_2pi(phi-cPhi);
1016 Double_t dist = (eta-cEta)*(eta-cEta)+phidiff*phidiff;
1017 if(dist>rad2)
1018 continue;
1019 cellIsolation += cellE;
1020 }
1021 return cellIsolation;
1022}
1023
1024//________________________________________________________________________
1025Double_t AliAnalysisTaskEMCALPi0PbPb::GetMaxCellEnergy(AliVCluster *cluster) const
d595acbb 1026{
90d5b88b 1027 // Get maximum energy of attached cell.
1028
1029 Double_t maxe = 0;
90d5b88b 1030 Int_t ncells = cluster->GetNCells();
1031 if (fEsdCells) {
1032 for (Int_t i=0; i<ncells; i++) {
27422847 1033 Double_t e = fEsdCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
90d5b88b 1034 if (e>maxe)
1035 maxe = e;
1036 }
1037 } else {
1038 for (Int_t i=0; i<ncells; i++) {
27422847 1039 Double_t e = fAodCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
90d5b88b 1040 if (e>maxe)
1041 maxe = e;
1042 }
1043 }
6eb6260e 1044 return maxe;
d595acbb 1045}
1046
1047//________________________________________________________________________
296ea9b4 1048void AliAnalysisTaskEMCALPi0PbPb::GetSigma(AliVCluster *c, Double_t& sigmaMax, Double_t &sigmaMin) const
d595acbb 1049{
90d5b88b 1050 // Calculate the (E) weighted variance along the longer (eigen) axis.
1051
6bf90832 1052 sigmaMax = 0; // cluster variance along its longer axis
1053 sigmaMin = 0; // cluster variance along its shorter axis
1054 Double_t Ec = c->E(); // cluster energy
296ea9b4 1055 if(Ec<=0)
1056 return;
6bf90832 1057 Double_t Xc = 0 ; // cluster first moment along X
1058 Double_t Yc = 0 ; // cluster first moment along Y
1059 Double_t Sxx = 0 ; // cluster second central moment along X (variance_X^2)
1060 Double_t Sxy = 0 ; // cluster second central moment along Y (variance_Y^2)
1061 Double_t Syy = 0 ; // cluster covariance^2
90d5b88b 1062
1063 AliVCaloCells *cells = fEsdCells;
1064 if (!cells)
1065 cells = fAodCells;
1066
6eb6260e 1067 if (!cells)
1068 return;
1069
6bf90832 1070 Int_t ncells = c->GetNCells();
6eb6260e 1071 if (ncells==1)
1072 return;
1073
1074 TVector3 pos;
1075 for(Int_t j=0; j<ncells; ++j) {
6bf90832 1076 Int_t id = TMath::Abs(c->GetCellAbsId(j));
27422847 1077 fGeom->GetGlobal(id,pos);
6eb6260e 1078 Double_t cellen = cells->GetCellAmplitude(id);
1079 Xc += cellen*pos.X();
1080 Yc += cellen*pos.Y();
1081 Sxx += cellen*pos.X()*pos.X();
1082 Syy += cellen*pos.Y()*pos.Y();
1083 Sxy += cellen*pos.X()*pos.Y();
1084 }
1085 Xc /= Ec;
1086 Yc /= Ec;
1087 Sxx /= Ec;
1088 Syy /= Ec;
1089 Sxy /= Ec;
1090 Sxx -= Xc*Xc;
1091 Syy -= Yc*Yc;
1092 Sxy -= Xc*Yc;
296ea9b4 1093 sigmaMax = (Sxx + Syy + TMath::Sqrt(TMath::Abs((Sxx-Syy)*(Sxx-Syy)+4.0*Sxy*Sxy)))/2.0;
1094 sigmaMax = TMath::Sqrt(TMath::Abs(sigmaMax));
1095 sigmaMin = TMath::Abs(Sxx + Syy - TMath::Sqrt(TMath::Abs((Sxx-Syy)*(Sxx-Syy)+4.0*Sxy*Sxy)))/2.0;
1096 sigmaMin = TMath::Sqrt(TMath::Abs(sigmaMin));
d595acbb 1097}
90d5b88b 1098
6bf90832 1099//________________________________________________________________________
296ea9b4 1100Int_t AliAnalysisTaskEMCALPi0PbPb::GetNCells(AliVCluster *c, Double_t emin) const
6bf90832 1101{
1102 // Calculate number of attached cells above emin.
1103
6bf90832 1104 AliVCaloCells *cells = fEsdCells;
1105 if (!cells)
1106 cells = fAodCells;
6bf90832 1107 if (!cells)
296ea9b4 1108 return 0;
6bf90832 1109
296ea9b4 1110 Int_t n = 0;
6bf90832 1111 Int_t ncells = c->GetNCells();
1112 for(Int_t j=0; j<ncells; ++j) {
1113 Int_t id = TMath::Abs(c->GetCellAbsId(j));
1114 Double_t cellen = cells->GetCellAmplitude(id);
1115 if (cellen>=emin)
1116 ++n;
1117 }
1118 return n;
1119}
1120
296ea9b4 1121//________________________________________________________________________
1122Double_t AliAnalysisTaskEMCALPi0PbPb::GetTrackIsolation(Double_t cEta, Double_t cPhi, Double_t radius) const
1123{
1124 // Compute isolation based on tracks.
1125
1126 Double_t trkIsolation = 0;
1127 Double_t rad2 = radius*radius;
1128 Int_t ntrks = fSelTracks->GetEntries();
1129 for(Int_t j = 0; j<ntrks; ++j) {
1130 AliVTrack *track = static_cast<AliVTrack*>(fSelTracks->At(j));
1131 if (!track)
1132 continue;
1133 Float_t eta = track->Eta();
1134 Float_t phi = track->Phi();
1135 Double_t phidiff = TVector2::Phi_0_2pi(phi-cPhi);
1136 Double_t dist = (eta-cEta)*(eta-cEta)+phidiff*phidiff;
1137 if(dist>rad2)
1138 continue;
1139 trkIsolation += track->Pt();
1140 }
1141 return trkIsolation;
1142}