1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Permission to use, copy, modify and distribute this software and its *
5 * documentation strictly for non-commercial purposes is hereby granted *
6 * without fee, provided that the above copyright notice appears in all *
7 * copies and that both the copyright notice and this permission notice *
8 * appear in the supporting documentation. The authors make no claims *
9 * about the suitability of this software for any purpose. It is *
10 * provided "as is" without express or implied warranty. *
11 **************************************************************************/
15 //---------------------------------------------------------------------------//
17 // Fill histograms (one per cell) with two-cluster invariant mass //
18 // using calibration coefficients of the previous iteration. //
19 // Histogram for a given cell is filled if the most energy of one cluster //
20 // is deposited in this cell and the other cluster could be anywherein EMCAL.//
23 // Author: Boris Polishchuk //
24 // Adapted to AOD reading by Gustavo Conesa //
27 //---------------------------------------------------------------------------//
30 #include "TLorentzVector.h"
31 #include "TRefArray.h"
34 #include <TGeoManager.h>
37 #include "AliAnalysisTaskEMCALPi0CalibSelection.h"
38 #include "AliAODEvent.h"
39 #include "AliESDEvent.h"
40 #include "AliEMCALGeometry.h"
41 #include "AliVCluster.h"
42 #include "AliVCaloCells.h"
43 #include "AliEMCALRecoUtils.h"
44 #include "AliOADBContainer.h"
46 ClassImp(AliAnalysisTaskEMCALPi0CalibSelection)
49 //______________________________________________________________________________________________
50 AliAnalysisTaskEMCALPi0CalibSelection::AliAnalysisTaskEMCALPi0CalibSelection(const char* name) :
51 AliAnalysisTaskSE(name),fEMCALGeo(0x0),
52 fEmin(0.5), fEmax(15.),
53 fL0min(0.01), fL0max(0.5),
54 fDTimeCut(100.), fTimeMax(1000000), fTimeMin(-1000000),
55 fAsyCut(1.), fMinNCells(2), fGroupNCells(0),
56 fLogWeight(4.5), fSameSM(kFALSE), fFilteredInput(kFALSE),
57 fCorrectClusters(kFALSE), fEMCALGeoName("EMCAL_COMPLETE12SMV1"),
58 fTriggerName("EMC"), fOADBFilePath(""),
59 fRecoUtils(new AliEMCALRecoUtils),
60 fCuts(0x0), fLoadMatrices(0),
61 fNMaskCellColumns(11), fMaskCellColumns(0x0),
62 fInvMassCutMin(110.), fInvMassCutMax(160.),
64 fOutputContainer(0x0), fNbins(300),
65 fMinBin(0.), fMaxBin(300.),
66 fNTimeBins(1000), fMinTimeBin(0.), fMaxTimeBin(1000.),
67 fHmgg(0x0), fHmggDifferentSM(0x0),
68 fHmggMaskFrame(0x0), fHmggDifferentSMMaskFrame(0x0),
69 fHOpeningAngle(0x0), fHOpeningAngleDifferentSM(0x0),
70 fHAsymmetry(0x0), fHAsymmetryDifferentSM(0x0),
72 fhClusterTime(0x0), fhClusterPairDiffTime(0x0)
74 //Named constructor which should be used.
76 for(Int_t iMod=0; iMod < AliEMCALGeoParams::fgkEMCALModules; iMod++) {
77 for(Int_t iX=0; iX<24; iX++) {
78 for(Int_t iZ=0; iZ<48; iZ++) {
79 fHmpi0[iMod][iZ][iX] = 0 ;
89 fMaskCellColumns = new Int_t[fNMaskCellColumns];
90 fMaskCellColumns[0] = 6 ; fMaskCellColumns[1] = 7 ; fMaskCellColumns[2] = 8 ;
91 fMaskCellColumns[3] = 35; fMaskCellColumns[4] = 36; fMaskCellColumns[5] = 37;
92 fMaskCellColumns[6] = 12+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[7] = 13+AliEMCALGeoParams::fgkEMCALCols;
93 fMaskCellColumns[8] = 40+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[9] = 41+AliEMCALGeoParams::fgkEMCALCols;
94 fMaskCellColumns[10]= 42+AliEMCALGeoParams::fgkEMCALCols;
96 for(Int_t iSMPair = 0; iSMPair < AliEMCALGeoParams::fgkEMCALModules/2; iSMPair++)
98 fHmggPairSameSectorSM[iSMPair] = 0;
99 fHmggPairSameSectorSMMaskFrame[iSMPair] = 0;
100 fhClusterPairDiffTimeSameSector[iSMPair]= 0;
103 for(Int_t iSMPair = 0; iSMPair < AliEMCALGeoParams::fgkEMCALModules-2; iSMPair++)
105 fHmggPairSameSideSM[iSMPair] = 0;
106 fHmggPairSameSideSMMaskFrame[iSMPair] = 0;
107 fhClusterPairDiffTimeSameSide[iSMPair] = 0;
110 for(Int_t iSM = 0; iSM < AliEMCALGeoParams::fgkEMCALModules; iSM++)
113 fHmggSMMaskFrame[iSM] = 0;
114 fHOpeningAngleSM[iSM] = 0;
115 fHOpeningAnglePairSM[iSM] = 0;
116 fHAsymmetrySM[iSM] = 0;
117 fHAsymmetryPairSM[iSM] = 0;
118 fhTowerDecayPhotonHit[iSM] = 0;
119 fhTowerDecayPhotonEnergy[iSM] = 0;
120 fhTowerDecayPhotonAsymmetry[iSM] = 0;
121 fhTowerDecayPhotonHitMaskFrame[iSM]= 0;
123 fhClusterTimeSM[iSM] = 0;
124 fhClusterPairDiffTimeSameSM[iSM] = 0;
127 DefineOutput(1, TList::Class());
128 DefineOutput(2, TList::Class()); // will contain cuts or local params
132 //_____________________________________________________________________________
133 AliAnalysisTaskEMCALPi0CalibSelection::~AliAnalysisTaskEMCALPi0CalibSelection()
139 fOutputContainer->Delete() ;
140 delete fOutputContainer ;
143 if(fEMCALGeo) delete fEMCALGeo ;
144 if(fRecoUtils) delete fRecoUtils ;
145 if(fNMaskCellColumns) delete [] fMaskCellColumns;
150 //________________________________________________________________
151 void AliAnalysisTaskEMCALPi0CalibSelection::InitGeometryMatrices()
153 // Init geometry and set the geometry matrix, for the first event, skip the rest
154 // Also set once the run dependent calibrations
156 if(fhNEvents->GetEntries()!=1) return;
158 Int_t runnumber = InputEvent()->GetRunNumber() ;
162 printf("AliAnalysisTaskEMCALPi0CalibSelection::InitGeometryMatrices() - Load user defined EMCAL geometry matrices\n");
165 AliOADBContainer emcGeoMat("AliEMCALgeo");
166 if(fOADBFilePath=="") fOADBFilePath = "$ALICE_ROOT/OADB/EMCAL" ;
167 emcGeoMat.InitFromFile(Form("%s/EMCALlocal2master.root",fOADBFilePath.Data()),"AliEMCALgeo");
168 TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(runnumber,"EmcalMatrices");
171 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
174 if (!fMatrix[mod]) // Get it from OADB
177 printf("AliAnalysisTaskEMCALPi0CalibSelection::InitGeometryMatrices() - EMCAL matrices SM %d, %p\n",
178 mod,((TGeoHMatrix*) matEMCAL->At(mod)));
179 //((TGeoHMatrix*) matEMCAL->At(mod))->Print();
181 fMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ;
187 fMatrix[mod]->Print();
189 fEMCALGeo->SetMisalMatrix(fMatrix[mod],mod) ;
194 else if(!gGeoManager)
196 printf("AliAnalysisTaskEMCALPi0CalibSelection::InitGeometryMatrices() - Get geo matrices from data");
197 //Still not implemented in AOD, just a workaround to be able to work at least with ESDs
198 if(!strcmp(InputEvent()->GetName(),"AliAODEvent"))
201 Warning("UserExec","Use ideal geometry, values geometry matrix not kept in AODs.");
206 printf("AliAnalysisTaskEMCALPi0CalibSelection::InitGeometryMatrices() - AliAnalysisTaskEMCALClusterize Load Misaligned matrices.");
208 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()) ;
210 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
213 esd->GetEMCALMatrix(mod)->Print();
215 if(esd->GetEMCALMatrix(mod)) fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
220 }//Load matrices from Data
224 //___________________________________________________________________
225 void AliAnalysisTaskEMCALPi0CalibSelection::UserCreateOutputObjects()
227 //Create output container, init geometry
229 fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ;
230 Int_t nSM = (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules();
232 fOutputContainer = new TList();
233 const Int_t buffersize = 255;
234 char hname[buffersize], htitl[buffersize];
236 fhNEvents = new TH1I("hNEvents", "Number of analyzed events" , 1 , 0 , 1 ) ;
237 fOutputContainer->Add(fhNEvents);
239 fHmgg = new TH2F("hmgg","2-cluster invariant mass",fNbins,fMinBin,fMaxBin,100,0,10);
240 fHmgg->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
241 fHmgg->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
242 fOutputContainer->Add(fHmgg);
244 fHmggDifferentSM = new TH2F("hmggDifferentSM","2-cluster invariant mass, different SM",fNbins,fMinBin,fMaxBin,100,0,10);
245 fHmggDifferentSM->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
246 fHmggDifferentSM->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
247 fOutputContainer->Add(fHmggDifferentSM);
249 fHOpeningAngle = new TH2F("hopang","2-cluster opening angle",100,0.,50.,100,0,10);
250 fHOpeningAngle->SetXTitle("#alpha_{#gamma #gamma}");
251 fHOpeningAngle->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
252 fOutputContainer->Add(fHOpeningAngle);
254 fHOpeningAngleDifferentSM = new TH2F("hopangDifferentSM","2-cluster opening angle, different SM",100,0,50.,100,0,10);
255 fHOpeningAngleDifferentSM->SetXTitle("#alpha_{#gamma #gamma}");
256 fHOpeningAngleDifferentSM->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
257 fOutputContainer->Add(fHOpeningAngleDifferentSM);
259 fHAsymmetry = new TH2F("hasym","2-cluster opening angle",100,0.,1.,100,0,10);
260 fHAsymmetry->SetXTitle("a");
261 fHAsymmetry->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
262 fOutputContainer->Add(fHAsymmetry);
264 fHAsymmetryDifferentSM = new TH2F("hasymDifferentSM","2-cluster opening angle, different SM",100,0,1.,100,0,10);
265 fHAsymmetryDifferentSM->SetXTitle("a");
266 fHAsymmetryDifferentSM->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
267 fOutputContainer->Add(fHAsymmetryDifferentSM);
270 //TString pairname[] = {"A side (0-2)", "C side (1-3)","Row 0 (0-1)", "Row 1 (2-3)"};
272 fHmggMaskFrame = new TH2F("hmggMaskFrame","2-cluster invariant mass, frame masked",fNbins,fMinBin,fMaxBin,100,0,10);
273 fHmggMaskFrame->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
274 fHmggMaskFrame->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
275 fOutputContainer->Add(fHmggMaskFrame);
277 fHmggDifferentSMMaskFrame = new TH2F("hmggDifferentSMMaskFrame","2-cluster invariant mass, different SM, frame masked",
278 fNbins,fMinBin,fMaxBin,100,0,10);
279 fHmggDifferentSMMaskFrame->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
280 fHmggDifferentSMMaskFrame->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
281 fOutputContainer->Add(fHmggDifferentSMMaskFrame);
284 for(Int_t iSM = 0; iSM < nSM; iSM++)
286 snprintf(hname, buffersize, "hmgg_SM%d",iSM);
287 snprintf(htitl, buffersize, "Two-gamma inv. mass for super mod %d",iSM);
288 fHmggSM[iSM] = new TH2F(hname,htitl,fNbins,fMinBin,fMaxBin,100,0,10);
289 fHmggSM[iSM]->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
290 fHmggSM[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
291 fOutputContainer->Add(fHmggSM[iSM]);
293 snprintf(hname, buffersize, "hmgg_SM%d_MaskFrame",iSM);
294 snprintf(htitl, buffersize, "Two-gamma inv. mass for super mod %d",iSM);
295 fHmggSMMaskFrame[iSM] = new TH2F(hname,htitl,fNbins,fMinBin,fMaxBin,100,0,10);
296 fHmggSMMaskFrame[iSM]->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
297 fHmggSMMaskFrame[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
298 fOutputContainer->Add(fHmggSMMaskFrame[iSM]);
303 snprintf(hname,buffersize, "hmgg_PairSameSectorSM%d",iSM);
304 snprintf(htitl,buffersize, "Two-gamma inv. mass for SM pair Sector: %d",iSM);
305 fHmggPairSameSectorSM[iSM] = new TH2F(hname,htitl,fNbins,fMinBin,fMaxBin,100,0,10);
306 fHmggPairSameSectorSM[iSM]->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
307 fHmggPairSameSectorSM[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
308 fOutputContainer->Add(fHmggPairSameSectorSM[iSM]);
310 snprintf(hname,buffersize, "hmgg_PairSameSectorSM%d_MaskFrame",iSM);
311 snprintf(htitl,buffersize, "Two-gamma inv. mass for SM pair Sector: %d",iSM);
312 fHmggPairSameSectorSMMaskFrame[iSM] = new TH2F(hname,htitl,fNbins,fMinBin,fMaxBin,100,0,10);
313 fHmggPairSameSectorSMMaskFrame[iSM]->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
314 fHmggPairSameSectorSMMaskFrame[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
315 fOutputContainer->Add(fHmggPairSameSectorSMMaskFrame[iSM]);
317 fhClusterPairDiffTimeSameSector[iSM] = new TH2F(Form("hClusterPairDiffTimeSameSector%d",iSM),
318 Form("cluster pair time difference vs E, Sector %d",iSM),
319 100,0,10, 200,-100,100);
320 fhClusterPairDiffTimeSameSector[iSM]->SetXTitle("E_{pair} (GeV)");
321 fhClusterPairDiffTimeSameSector[iSM]->SetYTitle("#Delta t (ns)");
322 fOutputContainer->Add(fhClusterPairDiffTimeSameSector[iSM]);
329 snprintf(hname,buffersize, "hmgg_PairSameSideSM%d",iSM);
330 snprintf(htitl,buffersize, "Two-gamma inv. mass for SM pair Sector: %d",iSM);
331 fHmggPairSameSideSM[iSM] = new TH2F(hname,htitl,fNbins,fMinBin,fMaxBin,100,0,10);
332 fHmggPairSameSideSM[iSM]->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
333 fHmggPairSameSideSM[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
334 fOutputContainer->Add(fHmggPairSameSideSM[iSM]);
336 snprintf(hname,buffersize, "hmgg_PairSameSideSM%d_MaskFrame",iSM);
337 snprintf(htitl,buffersize, "Two-gamma inv. mass for SM pair Sector: %d",iSM);
338 fHmggPairSameSideSMMaskFrame[iSM] = new TH2F(hname,htitl,fNbins,fMinBin,fMaxBin,100,0,10);
339 fHmggPairSameSideSMMaskFrame[iSM]->SetXTitle("m_{#gamma #gamma} (MeV/c^{2})");
340 fHmggPairSameSideSMMaskFrame[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
341 fOutputContainer->Add(fHmggPairSameSideSMMaskFrame[iSM]);
343 fhClusterPairDiffTimeSameSide[iSM] = new TH2F(Form("hClusterPairDiffTimeSameSide%d",iSM),
344 Form("cluster pair time difference vs E, Side %d",iSM),
345 100,0,10, 200,-100,100);
346 fhClusterPairDiffTimeSameSide[iSM]->SetXTitle("E_{pair} (GeV)");
347 fhClusterPairDiffTimeSameSide[iSM]->SetYTitle("#Delta t (ns)");
348 fOutputContainer->Add(fhClusterPairDiffTimeSameSide[iSM]);
352 snprintf(hname, buffersize, "hopang_SM%d",iSM);
353 snprintf(htitl, buffersize, "Opening angle for super mod %d",iSM);
354 fHOpeningAngleSM[iSM] = new TH2F(hname,htitl,100,0.,50.,100,0,10);
355 fHOpeningAngleSM[iSM]->SetXTitle("#alpha_{#gamma #gamma} (deg)");
356 fHOpeningAngleSM[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
357 fOutputContainer->Add(fHOpeningAngleSM[iSM]);
359 snprintf(hname,buffersize, "hopang_PairSM%d",iSM);
360 snprintf(htitl,buffersize, "Opening angle for SM pair: %d",iSM);
361 fHOpeningAnglePairSM[iSM] = new TH2F(hname,htitl,100,0.,50.,100,0,10);
362 fHOpeningAnglePairSM[iSM]->SetXTitle("#alpha_{#gamma #gamma} (deg)");
363 fHOpeningAnglePairSM[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
364 fOutputContainer->Add(fHOpeningAnglePairSM[iSM]);
366 snprintf(hname, buffersize, "hasym_SM%d",iSM);
367 snprintf(htitl, buffersize, "Asymmetry for super mod %d",iSM);
368 fHAsymmetrySM[iSM] = new TH2F(hname,htitl,100,0.,1.,100,0,10);
369 fHAsymmetrySM[iSM]->SetXTitle("a");
370 fHAsymmetrySM[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
371 fOutputContainer->Add(fHAsymmetrySM[iSM]);
373 snprintf(hname,buffersize, "hasym_PairSM%d",iSM);
374 snprintf(htitl,buffersize, "Asymmetry for SM pair: %d",iSM);
375 fHAsymmetryPairSM[iSM] = new TH2F(hname,htitl,100,0.,1.,100,0,10);
376 fHAsymmetryPairSM[iSM]->SetXTitle("a");
377 fHAsymmetryPairSM[iSM]->SetYTitle("p_{T #gamma #gamma} (GeV/c)");
378 fOutputContainer->Add(fHAsymmetryPairSM[iSM]);
383 fhTowerDecayPhotonHit[iSM] = new TH2F (Form("hTowerDecPhotonHit_Mod%d",iSM),
384 Form("Entries in grid of cells in Module %d",iSM),
385 colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5);
386 fhTowerDecayPhotonHit[iSM]->SetYTitle("row (phi direction)");
387 fhTowerDecayPhotonHit[iSM]->SetXTitle("column (eta direction)");
388 fOutputContainer->Add(fhTowerDecayPhotonHit[iSM]);
390 fhTowerDecayPhotonEnergy[iSM] = new TH2F (Form("hTowerDecPhotonEnergy_Mod%d",iSM),
391 Form("Accumulated energy in grid of cells in Module %d",iSM),
392 colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5);
393 fhTowerDecayPhotonEnergy[iSM]->SetYTitle("row (phi direction)");
394 fhTowerDecayPhotonEnergy[iSM]->SetXTitle("column (eta direction)");
395 fOutputContainer->Add(fhTowerDecayPhotonEnergy[iSM]);
397 fhTowerDecayPhotonAsymmetry[iSM] = new TH2F (Form("hTowerDecPhotonAsymmetry_Mod%d",iSM),
398 Form("Accumulated asymmetry in grid of cells in Module %d",iSM),
399 colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5);
400 fhTowerDecayPhotonAsymmetry[iSM]->SetYTitle("row (phi direction)");
401 fhTowerDecayPhotonAsymmetry[iSM]->SetXTitle("column (eta direction)");
402 fOutputContainer->Add(fhTowerDecayPhotonAsymmetry[iSM]);
404 fhTowerDecayPhotonHitMaskFrame[iSM] = new TH2F (Form("hTowerDecPhotonHit_Mod%d_MaskFrame",iSM),Form("Entries in grid of cells in Module %d",iSM),
405 colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5);
406 fhTowerDecayPhotonHitMaskFrame[iSM]->SetYTitle("row (phi direction)");
407 fhTowerDecayPhotonHitMaskFrame[iSM]->SetXTitle("column (eta direction)");
408 fOutputContainer->Add(fhTowerDecayPhotonHitMaskFrame[iSM]);
410 fhClusterTimeSM[iSM] = new TH2F(Form("hClusterTime_SM%d",iSM),"cluster time vs E",100,0,10, 100,0,1000);
411 fhClusterTimeSM[iSM]->SetXTitle("E (GeV)");
412 fhClusterTimeSM[iSM]->SetYTitle("t (ns)");
413 fOutputContainer->Add(fhClusterTimeSM[iSM]);
415 fhClusterPairDiffTimeSameSM[iSM] = new TH2F(Form("hClusterPairDiffTimeSameSM%d",iSM),
416 Form("cluster pair time difference vs E, SM %d",iSM),
417 100,0,10, 200,-100,100);
418 fhClusterPairDiffTimeSameSM[iSM]->SetXTitle("E (GeV)");
419 fhClusterPairDiffTimeSameSM[iSM]->SetYTitle("#Delta t (ns)");
420 fOutputContainer->Add(fhClusterPairDiffTimeSameSM[iSM]);
424 Int_t nchannels = nSM*AliEMCALGeoParams::fgkEMCALRows*AliEMCALGeoParams::fgkEMCALCols;
425 for(Int_t ibc = 0; ibc < 4; ibc++)
427 fHTpi0[ibc] = new TH2F(Form("hTime_BC%d",ibc),Form("Time of cell clusters under pi0 peak, bunch crossing %d",ibc),
428 nchannels,0,nchannels, fNTimeBins,fMinTimeBin,fMaxTimeBin);
429 fOutputContainer->Add(fHTpi0[ibc]);
430 fHTpi0[ibc]->SetYTitle("time (ns)");
431 fHTpi0[ibc]->SetXTitle("abs. Id. ");
435 fhClusterTime = new TH2F("hClusterTime","cluster time vs E",100,0,10, 100,0,1000);
436 fhClusterTime->SetXTitle("E (GeV)");
437 fhClusterTime->SetYTitle("t (ns)");
438 fOutputContainer->Add(fhClusterTime);
440 fhClusterPairDiffTime = new TH2F("hClusterPairDiffTime","cluster pair time difference vs E",100,0,10, 800,-400,400);
441 fhClusterPairDiffTime->SetXTitle("E_{pair} (GeV)");
442 fhClusterPairDiffTime->SetYTitle("#Delta t (ns)");
443 fOutputContainer->Add(fhClusterPairDiffTime);
445 for(Int_t iMod=0; iMod < nSM; iMod++)
447 for(Int_t iRow=0; iRow < AliEMCALGeoParams::fgkEMCALRows; iRow++)
449 for(Int_t iCol=0; iCol < AliEMCALGeoParams::fgkEMCALCols; iCol++)
451 snprintf(hname,buffersize, "%d_%d_%d",iMod,iCol,iRow);
452 snprintf(htitl,buffersize, "Two-gamma inv. mass for super mod %d, cell(col,row)=(%d,%d)",iMod,iCol,iRow);
453 fHmpi0[iMod][iCol][iRow] = new TH1F(hname,htitl,fNbins,fMinBin,fMaxBin);
454 fHmpi0[iMod][iCol][iRow]->SetXTitle("mass (MeV/c^{2})");
455 fOutputContainer->Add(fHmpi0[iMod][iCol][iRow]);
460 fOutputContainer->SetOwner(kTRUE);
462 PostData(1,fOutputContainer);
464 // cuts container, set in terminate but init and post here
468 fCuts ->SetOwner(kTRUE);
474 //______________________________________________________________________________________________________
475 Bool_t AliAnalysisTaskEMCALPi0CalibSelection::MaskFrameCluster(const Int_t iSM, const Int_t ieta) const
477 //Check if cell is in one of the regions where we have significant amount of material in front of EMCAL
480 if(iSM%2) icol+=48; // Impair SM, shift index [0-47] to [48-96]
482 if (fNMaskCellColumns && fMaskCellColumns)
484 for (Int_t imask = 0; imask < fNMaskCellColumns; imask++)
486 if(icol==fMaskCellColumns[imask]) return kTRUE;
494 //__________________________________________________________________________
495 void AliAnalysisTaskEMCALPi0CalibSelection::UserExec(Option_t* /* option */)
497 //Analysis per event.
499 if(fRecoUtils->GetParticleType()!=AliEMCALRecoUtils::kPhoton)
501 printf("Wrong particle type for cluster position recalculation! = %d\n", fRecoUtils->GetParticleType());
507 AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (InputEvent());
508 AliAODEvent* aodevent = dynamic_cast<AliAODEvent*> (InputEvent());
510 TString triggerClass = "";
511 if (esdevent) triggerClass = esdevent->GetFiredTriggerClasses();
512 else if(aodevent) triggerClass = aodevent->GetFiredTriggerClasses();
514 if(triggerClass.Contains(fTriggerName))
516 //printf("Reject Event %d, FiredClass %s\n",(Int_t)Entry(),(((AliESDEvent*)InputEvent())->GetFiredTriggerClasses()).Data());
521 fhNEvents->Fill(0); //Event analyzed
523 //Get the input event
524 AliVEvent* event = 0;
525 if(fFilteredInput) event = AODEvent();
526 else event = InputEvent();
530 printf("Input event not available!\n");
535 printf("AliAnalysisTaskEMCALPi0CalibSelection <<< %s: Event %d >>>\n",event->GetName(), (Int_t)Entry());
537 //Get the primary vertex
539 event->GetPrimaryVertex()->GetXYZ(v) ;
541 if(DebugLevel() > 1) printf("AliAnalysisTaskEMCALPi0CalibSelection Vertex: (%.3f,%.3f,%.3f)\n",v[0],v[1],v[2]);
543 //Int_t runNum = aod->GetRunNumber();
544 //if(DebugLevel() > 1) printf("Run number: %d\n",runNum);
546 InitGeometryMatrices();
548 Int_t nSM = (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules();
550 if(DebugLevel() > 1) printf("AliAnalysisTaskEMCALPi0CalibSelection Will use fLogWeight %.3f .\n",fLogWeight);
559 Bool_t shared = kFALSE;
565 //Get the list of clusters
566 TRefArray * caloClustersArr = new TRefArray();
568 event->GetEMCALClusters(caloClustersArr);
570 const Int_t kNumberOfEMCALClusters = caloClustersArr->GetEntries() ;
572 if(DebugLevel() > 1) printf("AliAnalysisTaskEMCALPi0CalibSelection - N CaloClusters: %d \n", kNumberOfEMCALClusters);
575 AliVCaloCells *emCells = event->GetEMCALCells();
577 // loop over EMCAL clusters
578 //----------------------------------------------------------
579 // First recalibrate and recalculate energy and position
580 Float_t pos[]={0,0,0};
584 for(Int_t iClu=0; iClu<kNumberOfEMCALClusters; iClu++)
586 AliVCluster *c1 = (AliVCluster *) caloClustersArr->At(iClu);
588 Float_t e1i = c1->E(); // cluster energy before correction
589 if (e1i < fEmin) continue;
590 else if (e1i > fEmax) continue;
592 else if (c1->GetNCells() < fMinNCells) continue;
594 else if (c1->GetM02() < fL0min || c1->GetM02() > fL0max) continue;
596 if(fRecoUtils->ClusterContainsBadChannel(fEMCALGeo, c1->GetCellsAbsId(), c1->GetNCells())) continue;
600 printf("Std : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",c1->GetID(),c1->E(),c1->GetDispersion(),c1->GetM02(),c1->GetM20());
601 c1->GetPosition(pos);
602 printf("Std : i %d, x %f, y %f, z %f\n",c1->GetID(), pos[0], pos[1], pos[2]);
605 //Correct cluster energy and position if requested, and not corrected previously, by default Off
606 if(fRecoUtils->IsRecalibrationOn())
608 fRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, c1, emCells);
609 fRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, emCells,c1);
610 fRecoUtils->RecalculateClusterPID(c1);
614 printf("Energy: after recalibration %f; \n",c1->E());
616 // Recalculate cluster position
617 fRecoUtils->RecalculateClusterPosition(fEMCALGeo, emCells,c1);
619 // Correct Non-Linearity
620 c1->SetE(fRecoUtils->CorrectClusterEnergyLinearity(c1));
623 printf("\t after linearity correction %f\n",c1->E());
625 //In case of MC analysis, to match resolution/calibration in real data
626 c1->SetE(fRecoUtils->SmearClusterEnergy(c1));
629 printf("\t after smearing %f\n",c1->E());
633 printf("Cor : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",c1->GetID(),c1->E(),c1->GetDispersion(),c1->GetM02(),c1->GetM20());
634 c1->GetPosition(pos);
635 printf("Cor : i %d, x %f, y %f, z %f\n",c1->GetID(), pos[0], pos[1], pos[2]);
640 //----------------------------------------------------------
641 //Now the invariant mass analysis with the corrected clusters
642 Int_t bc = event->GetBunchCrossNumber();
644 for(Int_t iClu=0; iClu<kNumberOfEMCALClusters-1; iClu++)
646 AliVCluster *c1 = (AliVCluster *) caloClustersArr->At(iClu);
648 if(fRecoUtils->ClusterContainsBadChannel(fEMCALGeo, c1->GetCellsAbsId(), c1->GetNCells())) continue;
650 Float_t e1i = c1->E(); // cluster energy before correction
652 if (e1i < fEmin) continue;
653 else if (e1i > fEmax) continue;
655 else if (!fRecoUtils->IsGoodCluster(c1,fEMCALGeo,emCells,bc)) continue;
657 else if (c1->GetNCells() < fMinNCells) continue;
659 else if (c1->GetM02() < fL0min || c1->GetM02() > fL0max) continue;
663 printf("IMA : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",c1->GetID(),e1i,c1->GetDispersion(),c1->GetM02(),c1->GetM20());
664 c1->GetPosition(pos);
665 printf("IMA : i %d, x %f, y %f, z %f\n",c1->GetID(), pos[0], pos[1], pos[2]);
668 fRecoUtils->GetMaxEnergyCell(fEMCALGeo, emCells,c1,absId1,iSupMod1,ieta1,iphi1,shared);
669 c1->GetMomentum(p1,v);
671 //Check if cluster is in fidutial region, not too close to borders
672 Bool_t in1 = fRecoUtils->CheckCellFiducialRegion(fEMCALGeo, c1, emCells);
674 // Clusters not facing frame structures
675 Bool_t mask1 = MaskFrameCluster(iSupMod1, ieta1);
676 //if(mask1) printf("Reject eta %d SM %d\n",ieta1, iSupMod1);
678 Double_t time1 = c1->GetTOF()*1.e9;
680 if(time1 > fTimeMax || time1 < fTimeMin) continue;
682 fhClusterTime ->Fill(c1->E(),time1);
683 fhClusterTimeSM[iSupMod1]->Fill(c1->E(),time1);
685 // Combine cluster with other clusters and get the invariant mass
686 for (Int_t jClu=iClu+1; jClu<kNumberOfEMCALClusters; jClu++)
688 AliAODCaloCluster *c2 = (AliAODCaloCluster *) caloClustersArr->At(jClu);
690 Float_t e2i = c2->E();
691 if (e2i < fEmin) continue;
692 else if (e2i > fEmax) continue;
694 else if (!fRecoUtils->IsGoodCluster(c2,fEMCALGeo,emCells,bc))continue;
696 else if (c2->GetNCells() < fMinNCells) continue;
698 else if (c2->GetM02() < fL0min || c2->GetM02() > fL0max) continue;
701 fRecoUtils->GetMaxEnergyCell(fEMCALGeo, emCells,c2,absId2,iSupMod2,ieta2,iphi2,shared);
702 c2->GetMomentum(p2,v);
705 Float_t invmass = p12.M()*1000;
708 Float_t asym = TMath::Abs(p1.E()-p2.E())/(p1.E()+p2.E());
710 if(asym > fAsyCut) continue;
713 Double_t time2 = c2->GetTOF()*1.e9;
715 if(time2 > fTimeMax || time2 < fTimeMin) continue;
717 fhClusterPairDiffTime->Fill(p12.E(),time1-time2);
718 if(TMath::Abs(time1-time2) > fDTimeCut) continue;
720 if(invmass < fMaxBin && invmass > fMinBin )
722 //Check if cluster is in fidutial region, not too close to borders
723 Bool_t in2 = fRecoUtils->CheckCellFiducialRegion(fEMCALGeo, c2, emCells);
725 // Clusters not facing frame structures
726 Bool_t mask2 = MaskFrameCluster(iSupMod2, ieta2);
727 //if(mask2) printf("Reject eta %d SM %d\n",ieta2, iSupMod2);
731 fHmgg->Fill(invmass,p12.Pt());
733 if(iSupMod1==iSupMod2)
735 fHmggSM[iSupMod1]->Fill(invmass,p12.Pt());
736 fhClusterPairDiffTimeSameSM[iSupMod1]->Fill(p12.E(),time1-time2);
739 fHmggDifferentSM ->Fill(invmass,p12.Pt());
743 for(Int_t i = 0; i < nSM/2; i++)
746 if((iSupMod1==j && iSupMod2==j+1) || (iSupMod1==j+1 && iSupMod2==j))
748 fHmggPairSameSectorSM[i]->Fill(invmass,p12.Pt());
749 fhClusterPairDiffTimeSameSector[i]->Fill(p12.E(),time1-time2);
754 for(Int_t i = 0; i < nSM-2; i++)
756 if((iSupMod1==i && iSupMod2==i+2) || (iSupMod1==i+2 && iSupMod2==i))
758 fHmggPairSameSideSM[i]->Fill(invmass,p12.Pt());
759 fhClusterPairDiffTimeSameSide[i]->Fill(p12.E(),time1-time2);
766 fHmggMaskFrame->Fill(invmass,p12.Pt());
768 if(iSupMod1==iSupMod2) fHmggSMMaskFrame[iSupMod1]->Fill(invmass,p12.Pt());
769 else fHmggDifferentSMMaskFrame ->Fill(invmass,p12.Pt());
773 for(Int_t i = 0; i < nSM/2; i++)
776 if((iSupMod1==j && iSupMod2==j+1) || (iSupMod1==j+1 && iSupMod2==j)) fHmggPairSameSectorSMMaskFrame[i]->Fill(invmass,p12.Pt());
780 for(Int_t i = 0; i < nSM-2; i++)
782 if((iSupMod1==i && iSupMod2==i+2) || (iSupMod1==i+2 && iSupMod2==i)) fHmggPairSameSideSMMaskFrame[i]->Fill(invmass,p12.Pt());
785 }// Pair not facing frame
788 if(invmass > fInvMassCutMin && invmass < fInvMassCutMax) //restrict to clusters really close to pi0 peak
791 // Check time of cells in both clusters, and fill time histogram
792 for(Int_t icell = 0; icell < c1->GetNCells(); icell++)
794 Int_t absID = c1->GetCellAbsId(icell);
795 fHTpi0[bc%4]->Fill(absID, emCells->GetCellTime(absID)*1.e9);
798 for(Int_t icell = 0; icell < c2->GetNCells(); icell++)
800 Int_t absID = c2->GetCellAbsId(icell);
801 fHTpi0[bc%4]->Fill(absID, emCells->GetCellTime(absID)*1.e9);
804 //Opening angle of 2 photons
805 Float_t opangle = p1.Angle(p2.Vect())*TMath::RadToDeg();
806 //printf("*******>>>>>>>> In PEAK pt %f, angle %f \n",p12.Pt(),opangle);
809 fHOpeningAngle ->Fill(opangle,p12.Pt());
810 fHAsymmetry ->Fill(asym,p12.Pt());
812 if(iSupMod1==iSupMod2)
814 fHOpeningAngleSM[iSupMod1] ->Fill(opangle,p12.Pt());
815 fHAsymmetrySM[iSupMod1] ->Fill(asym,p12.Pt());
819 fHOpeningAngleDifferentSM ->Fill(opangle,p12.Pt());
820 fHAsymmetryDifferentSM ->Fill(asym,p12.Pt());
823 if((iSupMod1==0 && iSupMod2==2) || (iSupMod1==2 && iSupMod2==0))
825 fHOpeningAnglePairSM[0] ->Fill(opangle,p12.Pt());
826 fHAsymmetryPairSM[0] ->Fill(asym,p12.Pt());
829 if((iSupMod1==1 && iSupMod2==3) || (iSupMod1==3 && iSupMod2==1))
831 fHOpeningAnglePairSM[1] ->Fill(opangle,p12.Pt());
832 fHAsymmetryPairSM[1] ->Fill(asym,p12.Pt());
835 if((iSupMod1==0 && iSupMod2==1) || (iSupMod1==1 && iSupMod2==0))
837 fHOpeningAnglePairSM[2] ->Fill(opangle,p12.Pt());
838 fHAsymmetryPairSM[2] ->Fill(asym,p12.Pt());
840 if((iSupMod1==2 && iSupMod2==3) || (iSupMod1==3 && iSupMod2==2))
842 fHOpeningAnglePairSM[3] ->Fill(opangle,p12.Pt());
843 fHAsymmetryPairSM[3] ->Fill(asym,p12.Pt());
846 }// pair in 100 < mass < 160
848 }//in acceptance cuts
850 //In case of filling only channels with second cluster in same SM
851 if(fSameSM && iSupMod1!=iSupMod2) continue;
853 if (fGroupNCells == 0)
855 fHmpi0[iSupMod1][ieta1][iphi1]->Fill(invmass);
856 fHmpi0[iSupMod2][ieta2][iphi2]->Fill(invmass);
858 if(invmass > fInvMassCutMin && invmass < fInvMassCutMax)//restrict to clusters really close to pi0 peak
860 fhTowerDecayPhotonHit [iSupMod1]->Fill(ieta1,iphi1);
861 fhTowerDecayPhotonEnergy [iSupMod1]->Fill(ieta1,iphi1,p1.E());
862 fhTowerDecayPhotonAsymmetry[iSupMod1]->Fill(ieta1,iphi1,asym);
864 fhTowerDecayPhotonHit [iSupMod2]->Fill(ieta2,iphi2);
865 fhTowerDecayPhotonEnergy [iSupMod2]->Fill(ieta2,iphi2,p2.E());
866 fhTowerDecayPhotonAsymmetry[iSupMod2]->Fill(ieta2,iphi2,asym);
868 if(!mask1)fhTowerDecayPhotonHitMaskFrame[iSupMod1]->Fill(ieta1,iphi1);
869 if(!mask2)fhTowerDecayPhotonHitMaskFrame[iSupMod2]->Fill(ieta2,iphi2);
871 }// pair in mass of pi0
874 //printf("Regroup N %d, eta1 %d, phi1 %d, eta2 %d, phi2 %d \n",fGroupNCells, ieta1, iphi1, ieta2, iphi2);
875 for (Int_t i = -fGroupNCells; i < fGroupNCells+1; i++)
877 for (Int_t j = -fGroupNCells; j < fGroupNCells+1; j++)
879 Int_t absId11 = fEMCALGeo->GetAbsCellIdFromCellIndexes(iSupMod1, iphi1+j, ieta1+i);
880 Int_t absId22 = fEMCALGeo->GetAbsCellIdFromCellIndexes(iSupMod2, iphi2+j, ieta2+i);
883 for(Int_t icell = 0; icell < c1->GetNCells(); icell++){
884 if(c1->GetCellsAbsId()[icell] == absId11) ok1=kTRUE;
886 for(Int_t icell = 0; icell < c2->GetNCells(); icell++){
887 if(c2->GetCellsAbsId()[icell] == absId22) ok2=kTRUE;
890 if(ok1 && (ieta1+i >= 0) && (iphi1+j >= 0) && (ieta1+i < 48) && (iphi1+j < 24))
892 fHmpi0[iSupMod1][ieta1+i][iphi1+j]->Fill(invmass);
894 if(ok2 && (ieta2+i >= 0) && (iphi2+j >= 0) && (ieta2+i < 48) && (iphi2+j < 24))
896 fHmpi0[iSupMod2][ieta2+i][iphi2+j]->Fill(invmass);
902 if(DebugLevel() > 1) printf("AliAnalysisTaskEMCALPi0CalibSelection Mass in (SM%d,%d,%d) and (SM%d,%d,%d): %.3f GeV E1_i=%f E1_ii=%f E2_i=%f E2_ii=%f\n",
903 iSupMod1,iphi1,ieta1,iSupMod2,iphi2,ieta2,p12.M(),e1i,c1->E(),e2i,c2->E());
908 } // end of loop over EMCAL clusters
910 delete caloClustersArr;
912 PostData(1,fOutputContainer);
916 //_____________________________________________________
917 void AliAnalysisTaskEMCALPi0CalibSelection::PrintInfo()
921 printf("Cluster cuts: %2.2f < E < %2.2f GeV; number of cells > %d; Assymetry < %1.2f, pair time diff < %2.2f, %2.2f < t < %2.2f ns\n",
922 fEmin,fEmax, fMinNCells, fAsyCut, fDTimeCut,fTimeMin,fTimeMax) ;
924 printf("Group %d cells\n", fGroupNCells) ;
926 printf("Cluster maximal cell away from border at least %d cells\n", fRecoUtils->GetNumberOfCellsFromEMCALBorder()) ;
928 printf("Histograms: bins %d; energy range: %2.2f < E < %2.2f GeV\n",fNbins,fMinBin,fMaxBin) ;
930 printf("Switchs:\n \t Remove Bad Channels? %d; Use filtered input? %d; Correct Clusters? %d, \n \t Mass per channel same SM clusters? %d\n",
931 fRecoUtils->IsBadChannelsRemovalSwitchedOn(),fFilteredInput,fCorrectClusters, fSameSM) ;
933 printf("EMCAL Geometry name: < %s >, Load Matrices %d\n",fEMCALGeoName.Data(), fLoadMatrices) ;
934 if(fLoadMatrices) {for(Int_t ism = 0; ism < AliEMCALGeoParams::fgkEMCALModules; ism++) if(fMatrix[ism]) fMatrix[ism]->Print() ; }
939 //____________________________________________________________________
940 void AliAnalysisTaskEMCALPi0CalibSelection::Terminate(Option_t*)
942 // Create cuts/param objects and publish to slot
943 const Int_t buffersize = 255;
944 char onePar[buffersize] ;
946 snprintf(onePar,buffersize, "Custer cuts: %2.2f < E < %2.2f GeV; %2.2f < Lambda0_2 < %2.2f GeV; min number of cells %d; Assymetry cut %1.2f, time1-time2 < %2.2f; %2.2f < T < %2.2f ns; %3.1f < Mass < %3.1f",
947 fEmin,fEmax, fL0min, fL0max, fMinNCells, fAsyCut, fDTimeCut, fTimeMin, fTimeMax, fInvMassCutMin, fInvMassCutMax) ;
948 fCuts->Add(new TObjString(onePar));
949 snprintf(onePar,buffersize, "Group %d cells;", fGroupNCells) ;
950 fCuts->Add(new TObjString(onePar));
951 snprintf(onePar,buffersize, "Cluster maximal cell away from border at least %d cells;", fRecoUtils->GetNumberOfCellsFromEMCALBorder()) ;
952 fCuts->Add(new TObjString(onePar));
953 snprintf(onePar,buffersize, "Histograms, Mass bins %d; energy range: %2.2f < E < %2.2f GeV;",fNbins,fMinBin,fMaxBin) ;
954 fCuts->Add(new TObjString(onePar));
955 snprintf(onePar,buffersize, "Histograms, Time bins %d; energy range: %2.2f < E < %2.2f GeV;",fNTimeBins,fMinTimeBin,fMaxTimeBin) ;
956 fCuts->Add(new TObjString(onePar));
957 snprintf(onePar,buffersize, "Switchs: Remove Bad Channels? %d; Use filtered input? %d; Correct Clusters? %d, Mass per channel same SM clusters? %d ",
958 fRecoUtils->IsBadChannelsRemovalSwitchedOn(),fFilteredInput,fCorrectClusters, fSameSM) ;
959 fCuts->Add(new TObjString(onePar));
960 snprintf(onePar,buffersize, "EMCAL Geometry name: < %s >, Load Matrices? %d",fEMCALGeoName.Data(),fLoadMatrices) ;
961 fCuts->Add(new TObjString(onePar));