]>
Commit | Line | Data |
---|---|---|
765d44e7 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
765d44e7 | 15 | |
16 | //_________________________________________________________________________ | |
17 | // Class utility for Calorimeter specific selection methods /// | |
18 | // | |
19 | // | |
20 | // | |
21 | //-- Author: Gustavo Conesa (LPSC-Grenoble) | |
22 | ////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | ||
25 | // --- ROOT system --- | |
3c1d9afb | 26 | #include <TGeoManager.h> |
27 | #include <TH2F.h> | |
28 | #include <TCanvas.h> | |
29 | #include <TStyle.h> | |
30 | #include <TPad.h> | |
55d66f31 | 31 | #include <TFile.h> |
4eb65103 | 32 | #include <TParticle.h> |
765d44e7 | 33 | |
c5693f62 | 34 | // --- ANALYSIS system --- |
765d44e7 | 35 | #include "AliCalorimeterUtils.h" |
4b892846 | 36 | #include "AliESDEvent.h" |
46a3cde6 | 37 | #include "AliMCEvent.h" |
38 | #include "AliStack.h" | |
765d44e7 | 39 | #include "AliAODPWG4Particle.h" |
c8fe2783 | 40 | #include "AliVCluster.h" |
41 | #include "AliVCaloCells.h" | |
3c1d9afb | 42 | #include "AliAODCaloCluster.h" |
55d66f31 | 43 | #include "AliOADBContainer.h" |
44 | #include "AliAnalysisManager.h" | |
4eb65103 | 45 | #include "AliAODMCParticle.h" |
765d44e7 | 46 | |
c5693f62 | 47 | // --- Detector --- |
48 | #include "AliEMCALGeometry.h" | |
49 | #include "AliPHOSGeoUtils.h" | |
50 | ||
765d44e7 | 51 | ClassImp(AliCalorimeterUtils) |
52 | ||
53 | ||
cb5780f4 | 54 | //____________________________________________ |
765d44e7 | 55 | AliCalorimeterUtils::AliCalorimeterUtils() : |
56 | TObject(), fDebug(0), | |
12e91266 | 57 | fEMCALGeoName(""), |
58 | fPHOSGeoName (""), | |
9e8998b1 | 59 | fEMCALGeo(0x0), fPHOSGeo(0x0), |
60 | fEMCALGeoMatrixSet(kFALSE), fPHOSGeoMatrixSet(kFALSE), | |
61 | fLoadEMCALMatrices(kFALSE), fLoadPHOSMatrices(kFALSE), | |
62 | fRemoveBadChannels(kFALSE), fPHOSBadChannelMap(0x0), | |
a5fb4114 | 63 | fNCellsFromPHOSBorder(0), |
9e8998b1 | 64 | fNMaskCellColumns(0), fMaskCellColumns(0x0), |
5bddb161 | 65 | fRecalibration(kFALSE), fRunDependentCorrection(kFALSE), |
66 | fPHOSRecalibrationFactors(), fEMCALRecoUtils(new AliEMCALRecoUtils), | |
9e8998b1 | 67 | fRecalculatePosition(kFALSE), fCorrectELinearity(kFALSE), |
68 | fRecalculateMatching(kFALSE), | |
69 | fCutR(20), fCutZ(20), | |
7db7dcb6 | 70 | fCutEta(20), fCutPhi(20), |
3c1d9afb | 71 | fLocMaxCutE(0), fLocMaxCutEDiff(0), |
55d66f31 | 72 | fPlotCluster(0), fOADBSet(kFALSE), |
73 | fOADBForEMCAL(kFALSE), fOADBForPHOS(kFALSE), | |
5bddb161 | 74 | fOADBFilePathEMCAL(""), fOADBFilePathPHOS(""), |
190f6f2d | 75 | fImportGeometryFromFile(0), fImportGeometryFilePath(""), |
e1d24b6a | 76 | fNSuperModulesUsed(0), |
77 | fMCECellClusFracCorrOn(0), fMCECellClusFracCorrParam() | |
765d44e7 | 78 | { |
79 | //Ctor | |
80 | ||
81 | //Initialize parameters | |
82 | InitParameters(); | |
90e32961 | 83 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ; |
84 | for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix [i] = 0 ; | |
7cc7d3f8 | 85 | |
765d44e7 | 86 | } |
765d44e7 | 87 | |
cb5780f4 | 88 | //_________________________________________ |
89 | AliCalorimeterUtils::~AliCalorimeterUtils() | |
90 | { | |
765d44e7 | 91 | //Dtor |
92 | ||
4df35693 | 93 | //if(fPHOSGeo) delete fPHOSGeo ; |
765d44e7 | 94 | if(fEMCALGeo) delete fEMCALGeo ; |
7cc7d3f8 | 95 | |
765d44e7 | 96 | if(fPHOSBadChannelMap) { |
97 | fPHOSBadChannelMap->Clear(); | |
98 | delete fPHOSBadChannelMap; | |
99 | } | |
100 | ||
09e819c9 | 101 | if(fPHOSRecalibrationFactors) { |
78219bac | 102 | fPHOSRecalibrationFactors->Clear(); |
103 | delete fPHOSRecalibrationFactors; | |
09e819c9 | 104 | } |
105 | ||
a5fb4114 | 106 | if(fEMCALRecoUtils) delete fEMCALRecoUtils ; |
107 | if(fNMaskCellColumns) delete [] fMaskCellColumns; | |
9584c261 | 108 | |
765d44e7 | 109 | } |
110 | ||
55d66f31 | 111 | //____________________________________________________ |
112 | void AliCalorimeterUtils::AccessOADB(AliVEvent* event) | |
113 | { | |
114 | // Set the AODB calibration, bad channels etc. parameters at least once | |
115 | // alignment matrices from OADB done in SetGeometryMatrices | |
116 | ||
117 | //Set it only once | |
118 | if(fOADBSet) return ; | |
119 | ||
120 | Int_t runnumber = event->GetRunNumber() ; | |
121 | TString pass = GetPass(); | |
122 | ||
123 | // EMCAL | |
124 | if(fOADBForEMCAL) | |
125 | { | |
126 | printf("AliCalorimeterUtils::SetOADBParameters() - Get AODB parameters from EMCAL in %s for run %d, and <%s> \n",fOADBFilePathEMCAL.Data(),runnumber,pass.Data()); | |
127 | ||
128 | Int_t nSM = fEMCALGeo->GetNumberOfSuperModules(); | |
129 | ||
130 | // Bad map | |
131 | if(fRemoveBadChannels) | |
132 | { | |
133 | AliOADBContainer *contBC=new AliOADBContainer(""); | |
134 | contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fOADBFilePathEMCAL.Data()),"AliEMCALBadChannels"); | |
135 | ||
136 | TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runnumber); | |
137 | ||
138 | if(arrayBC) | |
139 | { | |
6f557f7f | 140 | SwitchOnDistToBadChannelRecalculation(); |
141 | printf("AliCalorimeterUtils::SetOADBParameters() - Remove EMCAL bad cells \n"); | |
55d66f31 | 142 | |
6f557f7f | 143 | for (Int_t i=0; i<nSM; ++i) |
55d66f31 | 144 | { |
6f557f7f | 145 | TH2I *hbm = GetEMCALChannelStatusMap(i); |
146 | ||
147 | if (hbm) | |
148 | delete hbm; | |
55d66f31 | 149 | |
6f557f7f | 150 | hbm=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i)); |
151 | ||
152 | if (!hbm) | |
55d66f31 | 153 | { |
6f557f7f | 154 | AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i)); |
155 | continue; | |
156 | } | |
157 | ||
158 | hbm->SetDirectory(0); | |
159 | SetEMCALChannelStatusMap(i,hbm); | |
160 | ||
161 | } // loop | |
162 | } else printf("AliCalorimeterUtils::SetOADBParameters() - Do NOT remove EMCAL bad channels\n"); // run array | |
55d66f31 | 163 | } // Remove bad |
164 | ||
165 | // Energy Recalibration | |
166 | if(fRecalibration) | |
167 | { | |
168 | AliOADBContainer *contRF=new AliOADBContainer(""); | |
169 | ||
170 | contRF->InitFromFile(Form("%s/EMCALRecalib.root",fOADBFilePathEMCAL.Data()),"AliEMCALRecalib"); | |
171 | ||
172 | TObjArray *recal=(TObjArray*)contRF->GetObject(runnumber); | |
173 | ||
174 | if(recal) | |
175 | { | |
176 | TObjArray *recalpass=(TObjArray*)recal->FindObject(pass); | |
177 | ||
178 | if(recalpass) | |
179 | { | |
180 | TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib"); | |
181 | ||
182 | if(recalib) | |
183 | { | |
184 | printf("AliCalorimeterUtils::SetOADBParameters() - Recalibrate EMCAL \n"); | |
185 | for (Int_t i=0; i<nSM; ++i) | |
186 | { | |
187 | TH2F *h = GetEMCALChannelRecalibrationFactors(i); | |
188 | ||
189 | if (h) | |
190 | delete h; | |
191 | ||
192 | h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i)); | |
193 | ||
194 | if (!h) | |
195 | { | |
196 | AliError(Form("Could not load EMCALRecalFactors_SM%d",i)); | |
197 | continue; | |
198 | } | |
199 | ||
200 | h->SetDirectory(0); | |
201 | ||
202 | SetEMCALChannelRecalibrationFactors(i,h); | |
203 | } // SM loop | |
6f557f7f | 204 | }else printf("AliCalorimeterUtils::SetOADBParameters() - Do NOT recalibrate EMCAL, no params object array\n"); // array ok |
205 | }else printf("AliCalorimeterUtils::SetOADBParameters() - Do NOT recalibrate EMCAL, no params for pass\n"); // array pass ok | |
206 | }else printf("AliCalorimeterUtils::SetOADBParameters() - Do NOT recalibrate EMCAL, no params for run\n"); // run number array ok | |
55d66f31 | 207 | |
208 | // once set, apply run dependent corrections if requested | |
7bf608c9 | 209 | //fEMCALRecoUtils->SetRunDependentCorrections(runnumber); |
210 | ||
55d66f31 | 211 | } // Recalibration on |
212 | ||
7bf608c9 | 213 | // Energy Recalibration, apply on top of previous calibration factors |
214 | if(fRunDependentCorrection) | |
215 | { | |
216 | AliOADBContainer *contRFTD=new AliOADBContainer(""); | |
217 | ||
218 | contRFTD->InitFromFile(Form("%s/EMCALTemperatureCorrCalib.root",fOADBFilePathEMCAL.Data()),"AliEMCALRunDepTempCalibCorrections"); | |
219 | ||
220 | TH1S *htd=(TH1S*)contRFTD->GetObject(runnumber); | |
221 | ||
74d2310f | 222 | //If it did not exist for this run, get closes one |
223 | if (!htd) | |
224 | { | |
225 | AliWarning(Form("No TemperatureCorrCalib Objects for run: %d",runnumber)); | |
226 | // let's get the closest runnumber instead then.. | |
227 | Int_t lower = 0; | |
228 | Int_t ic = 0; | |
229 | Int_t maxEntry = contRFTD->GetNumberOfEntries(); | |
230 | ||
231 | while ( (ic < maxEntry) && (contRFTD->UpperLimit(ic) < runnumber) ) { | |
232 | lower = ic; | |
233 | ic++; | |
234 | } | |
235 | ||
236 | Int_t closest = lower; | |
237 | if ( (ic<maxEntry) && | |
238 | (contRFTD->LowerLimit(ic)-runnumber) < (runnumber - contRFTD->UpperLimit(lower)) ) { | |
239 | closest = ic; | |
240 | } | |
241 | ||
242 | AliWarning(Form("TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRFTD->LowerLimit(closest))); | |
243 | htd = (TH1S*) contRFTD->GetObjectByIndex(closest); | |
244 | } | |
245 | ||
7bf608c9 | 246 | if(htd) |
247 | { | |
248 | printf("AliCalorimeterUtils::SetOADBParameters() - Recalibrate (Temperature) EMCAL \n"); | |
249 | ||
250 | for (Int_t ism=0; ism<nSM; ++ism) | |
251 | { | |
252 | for (Int_t icol=0; icol<48; ++icol) | |
253 | { | |
254 | for (Int_t irow=0; irow<24; ++irow) | |
255 | { | |
256 | Float_t factor = GetEMCALChannelRecalibrationFactor(ism,icol,irow); | |
257 | ||
258 | Int_t absID = fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol); // original calibration factor | |
259 | factor *= htd->GetBinContent(absID) / 10000. ; // correction dependent on T | |
260 | //printf("\t ism %d, icol %d, irow %d,absID %d, corrA %2.3f, corrB %2.3f, corrAB %2.3f\n",ism, icol, irow, absID, | |
261 | // GetEMCALChannelRecalibrationFactor(ism,icol,irow) , htd->GetBinContent(absID) / 10000., factor); | |
262 | SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor); | |
263 | } // columns | |
264 | } // rows | |
265 | } // SM loop | |
266 | }else printf("AliCalorimeterUtils::SetOADBParameters() - Do NOT recalibrate EMCAL with T variations, no params TH1 \n"); | |
267 | } // Run by Run T calibration | |
55d66f31 | 268 | |
269 | // Time Recalibration | |
270 | if(fEMCALRecoUtils->IsTimeRecalibrationOn()) | |
271 | { | |
272 | AliOADBContainer *contTRF=new AliOADBContainer(""); | |
273 | ||
f46af216 | 274 | contTRF->InitFromFile(Form("%s/EMCALTimeCalib.root",fOADBFilePathEMCAL.Data()),"AliEMCALTimeCalib"); |
55d66f31 | 275 | |
276 | TObjArray *trecal=(TObjArray*)contTRF->GetObject(runnumber); | |
277 | ||
278 | if(trecal) | |
279 | { | |
d4c9aa67 | 280 | TString passM = pass; |
281 | if(pass=="spc_calo") passM = "pass1"; | |
282 | TObjArray *trecalpass=(TObjArray*)trecal->FindObject(passM); | |
55d66f31 | 283 | |
284 | if(trecalpass) | |
285 | { | |
f46af216 | 286 | printf("AliCalorimeterUtils::SetOADBParameters() - Time Recalibrate EMCAL \n"); |
287 | for (Int_t ibc = 0; ibc < 4; ++ibc) | |
55d66f31 | 288 | { |
f46af216 | 289 | TH1F *h = GetEMCALChannelTimeRecalibrationFactors(ibc); |
290 | ||
291 | if (h) | |
292 | delete h; | |
293 | ||
294 | h = (TH1F*)trecalpass->FindObject(Form("hAllTimeAvBC%d",ibc)); | |
295 | ||
296 | if (!h) | |
55d66f31 | 297 | { |
f46af216 | 298 | AliError(Form("Could not load hAllTimeAvBC%d",ibc)); |
299 | continue; | |
300 | } | |
301 | ||
302 | h->SetDirectory(0); | |
303 | ||
304 | SetEMCALChannelTimeRecalibrationFactors(ibc,h); | |
305 | } // bunch crossing loop | |
6f557f7f | 306 | }else printf("AliCalorimeterUtils::SetOADBParameters() - Do NOT recalibrate time EMCAL, no params for pass\n"); // array pass ok |
307 | }else printf("AliCalorimeterUtils::SetOADBParameters() - Do NOT recalibrate time EMCAL, no params for run\n"); // run number array ok | |
55d66f31 | 308 | |
309 | } // Recalibration on | |
310 | ||
311 | }// EMCAL | |
312 | ||
313 | // PHOS | |
314 | if(fOADBForPHOS) | |
315 | { | |
316 | printf("AliCalorimeterUtils::SetOADBParameters() - Get AODB parameters from PHOS in %s for run %d, and <%s> \n",fOADBFilePathPHOS.Data(),runnumber,pass.Data()); | |
317 | ||
318 | // Bad map | |
319 | if(fRemoveBadChannels) | |
320 | { | |
321 | AliOADBContainer badmapContainer(Form("phosBadMap")); | |
322 | TString fileName="$ALICE_ROOT/OADB/PHOS/PHOSBadMaps.root"; | |
323 | badmapContainer.InitFromFile(Form("%s/PHOSBadMaps.root",fOADBFilePathPHOS.Data()),"phosBadMap"); | |
324 | ||
325 | //Use a fixed run number from year 2010, this year not available yet. | |
326 | TObjArray *maps = (TObjArray*)badmapContainer.GetObject(139000,"phosBadMap"); | |
327 | if(!maps) | |
328 | { | |
329 | printf("AliCalorimeterUtils::SetOADBParameters() - Can not read PHOS bad map for run %d.\n",runnumber) ; | |
330 | } | |
331 | else | |
332 | { | |
333 | printf("AliCalorimeterUtils::SetOADBParameters() - Setting PHOS bad map with name %s \n",maps->GetName()) ; | |
334 | for(Int_t mod=1; mod<5;mod++) | |
335 | { | |
336 | TH2I *hbmPH = GetPHOSChannelStatusMap(mod); | |
337 | ||
338 | if(hbmPH) | |
339 | delete hbmPH ; | |
340 | ||
341 | hbmPH = (TH2I*)maps->At(mod); | |
342 | ||
343 | if(hbmPH) hbmPH->SetDirectory(0); | |
344 | ||
345 | SetPHOSChannelStatusMap(mod-1,hbmPH); | |
346 | ||
347 | } // modules loop | |
348 | } // maps exist | |
349 | } // Remove bad channels | |
350 | } // PHOS | |
351 | ||
352 | // Parameters already set once, so do not it again | |
353 | fOADBSet = kTRUE; | |
354 | ||
355 | } | |
356 | ||
357 | //_____________________________________________________________ | |
358 | void AliCalorimeterUtils::AccessGeometry(AliVEvent* inputEvent) | |
359 | { | |
360 | //Set the calorimeters transformation matrices and init geometry | |
361 | ||
362 | // First init the geometry, a priory not done before | |
363 | Int_t runnumber = inputEvent->GetRunNumber() ; | |
364 | InitPHOSGeometry (runnumber); | |
365 | InitEMCALGeometry(runnumber); | |
366 | ||
367 | //Get the EMCAL transformation geometry matrices from ESD | |
368 | if(!fEMCALGeoMatrixSet && fEMCALGeo) | |
369 | { | |
370 | if(fLoadEMCALMatrices) | |
371 | { | |
372 | printf("AliCalorimeterUtils::AccessGeometry() - Load user defined EMCAL geometry matrices\n"); | |
373 | ||
374 | // OADB if available | |
375 | AliOADBContainer emcGeoMat("AliEMCALgeo"); | |
376 | emcGeoMat.InitFromFile(Form("%s/EMCALlocal2master.root",fOADBFilePathEMCAL.Data()),"AliEMCALgeo"); | |
377 | TObjArray *matEMCAL=(TObjArray*)emcGeoMat.GetObject(runnumber,"EmcalMatrices"); | |
378 | ||
379 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++) | |
380 | { | |
381 | if (!fEMCALMatrix[mod]) // Get it from OADB | |
382 | { | |
383 | if(fDebug > 1 ) | |
384 | printf("AliCalorimeterUtils::AccessGeometry() - EMCAL matrices SM %d, %p\n", | |
385 | mod,((TGeoHMatrix*) matEMCAL->At(mod))); | |
386 | //((TGeoHMatrix*) matEMCAL->At(mod))->Print(); | |
387 | ||
388 | fEMCALMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod) ; | |
389 | } | |
390 | ||
391 | if(fEMCALMatrix[mod]) | |
392 | { | |
393 | if(fDebug > 1) | |
394 | fEMCALMatrix[mod]->Print(); | |
395 | ||
396 | fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ; | |
397 | } | |
398 | }//SM loop | |
399 | ||
400 | fEMCALGeoMatrixSet = kTRUE;//At least one, so good | |
401 | ||
402 | }//Load matrices | |
403 | else if (!gGeoManager) | |
404 | { | |
405 | if(fDebug > 1) | |
406 | printf(" AliCalorimeterUtils::AccessGeometry() - Load EMCAL misalignment matrices. \n"); | |
407 | if(!strcmp(inputEvent->GetName(),"AliESDEvent")) | |
408 | { | |
409 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++) | |
410 | { | |
411 | //printf("Load ESD matrix %d, %p\n",mod,((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod)); | |
412 | if(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod)) | |
413 | { | |
414 | fEMCALGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod),mod) ; | |
415 | } | |
416 | }// loop over super modules | |
417 | ||
418 | fEMCALGeoMatrixSet = kTRUE;//At least one, so good | |
419 | ||
420 | }//ESD as input | |
421 | else | |
422 | { | |
423 | if(fDebug > 1) | |
424 | printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n"); | |
425 | }//AOD as input | |
426 | }//Get matrix from data | |
427 | else if(gGeoManager) | |
428 | { | |
429 | fEMCALGeoMatrixSet = kTRUE; | |
430 | } | |
431 | }//EMCAL geo && no geoManager | |
432 | ||
433 | //Get the PHOS transformation geometry matrices from ESD | |
434 | if(!fPHOSGeoMatrixSet && fPHOSGeo) | |
435 | { | |
436 | if(fLoadPHOSMatrices) | |
437 | { | |
438 | printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load user defined PHOS geometry matrices\n"); | |
439 | ||
440 | // OADB if available | |
441 | AliOADBContainer geomContainer("phosGeo"); | |
442 | geomContainer.InitFromFile(Form("%s/PHOSGeometry.root",fOADBFilePathPHOS.Data()),"PHOSRotationMatrixes"); | |
443 | TObjArray *matPHOS = (TObjArray*)geomContainer.GetObject(139000,"PHOSRotationMatrixes"); | |
444 | ||
445 | for(Int_t mod = 0 ; mod < 5 ; mod++) | |
446 | { | |
447 | if (!fPHOSMatrix[mod]) // Get it from OADB | |
448 | { | |
449 | if(fDebug > 1 ) | |
450 | printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - PHOS matrices module %d, %p\n", | |
451 | mod,((TGeoHMatrix*) matPHOS->At(mod))); | |
452 | //((TGeoHMatrix*) matPHOS->At(mod))->Print(); | |
453 | ||
454 | fPHOSMatrix[mod] = (TGeoHMatrix*) matPHOS->At(mod) ; | |
455 | } | |
456 | ||
457 | // Set it, if it exists | |
458 | if(fPHOSMatrix[mod]) | |
459 | { | |
460 | if(fDebug > 1 ) | |
461 | fPHOSMatrix[mod]->Print(); | |
462 | ||
463 | fPHOSGeo->SetMisalMatrix(fPHOSMatrix[mod],mod) ; | |
464 | } | |
465 | }// SM loop | |
466 | ||
467 | fPHOSGeoMatrixSet = kTRUE;//At least one, so good | |
468 | ||
469 | }//Load matrices | |
470 | else if (!gGeoManager) | |
471 | { | |
472 | if(fDebug > 1) | |
473 | printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load PHOS misalignment matrices. \n"); | |
474 | if(!strcmp(inputEvent->GetName(),"AliESDEvent")) | |
475 | { | |
476 | for(Int_t mod = 0; mod < 5; mod++) | |
477 | { | |
478 | if( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod)) | |
479 | { | |
480 | //printf("PHOS: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod)); | |
481 | fPHOSGeo->SetMisalMatrix( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod),mod) ; | |
482 | } | |
483 | }// loop over modules | |
484 | fPHOSGeoMatrixSet = kTRUE; //At least one so good | |
485 | }//ESD as input | |
486 | else | |
487 | { | |
488 | if(fDebug > 1) | |
489 | printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n"); | |
490 | }//AOD as input | |
491 | }// get matrix from data | |
492 | else if(gGeoManager) | |
493 | { | |
494 | fPHOSGeoMatrixSet = kTRUE; | |
495 | } | |
496 | }//PHOS geo and geoManager was not set | |
497 | ||
498 | } | |
499 | ||
8a2dbbff | 500 | //________________________________________________________________________________________ |
9dcf63c2 | 501 | Bool_t AliCalorimeterUtils::AreNeighbours(Int_t calo, Int_t absId1, Int_t absId2 ) const |
7db7dcb6 | 502 | { |
503 | // Tells if (true) or not (false) two cells are neighbours | |
504 | // A neighbour is defined as being two cells which share a side or corner | |
505 | ||
506 | Bool_t areNeighbours = kFALSE ; | |
507 | ||
508 | Int_t iRCU1 = -1, irow1 = -1, icol1 = -1; | |
509 | Int_t iRCU2 = -1, irow2 = -1, icol2 = -1; | |
510 | ||
511 | Int_t rowdiff = 0, coldiff = 0; | |
512 | ||
9369a2b1 | 513 | Int_t nSupMod1 = GetModuleNumberCellIndexes(absId1, calo, icol1, irow1, iRCU1); |
514 | Int_t nSupMod2 = GetModuleNumberCellIndexes(absId2, calo, icol2, irow2, iRCU2); | |
7db7dcb6 | 515 | |
9dcf63c2 | 516 | if(calo==kEMCAL && nSupMod1!=nSupMod2) |
7db7dcb6 | 517 | { |
518 | // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2-1 | |
519 | // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0 | |
520 | if(nSupMod1%2) icol1+=AliEMCALGeoParams::fgkEMCALCols; | |
9369a2b1 | 521 | else icol2+=AliEMCALGeoParams::fgkEMCALCols; |
7db7dcb6 | 522 | } |
523 | ||
524 | rowdiff = TMath::Abs( irow1 - irow2 ) ; | |
525 | coldiff = TMath::Abs( icol1 - icol2 ) ; | |
526 | ||
7b108480 | 527 | //if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0)) |
528 | if ((coldiff + rowdiff == 1 )) | |
7db7dcb6 | 529 | areNeighbours = kTRUE ; |
530 | ||
531 | return areNeighbours; | |
532 | ||
533 | } | |
e1d24b6a | 534 | //_____________________________________________________________________________________ |
535 | Bool_t AliCalorimeterUtils::IsClusterSharedByTwoSuperModules(const AliEMCALGeometry * geom, | |
536 | AliVCluster* cluster) | |
537 | { | |
538 | //Method that checks if any of the cells in the cluster belongs to a different SM | |
539 | ||
540 | Int_t iSupMod = -1; | |
541 | Int_t iSM0 = -1; | |
542 | Int_t iTower = -1; | |
543 | Int_t iIphi = -1; | |
544 | Int_t iIeta = -1; | |
545 | Int_t iphi = -1; | |
546 | Int_t ieta = -1; | |
547 | ||
548 | for(Int_t iDigit=0; iDigit < cluster->GetNCells(); iDigit++) | |
549 | { | |
550 | //Get from the absid the supermodule, tower and eta/phi numbers | |
551 | geom->GetCellIndex(cluster->GetCellAbsId(iDigit),iSupMod,iTower,iIphi,iIeta); | |
552 | geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta); | |
553 | ||
554 | //Check if there are cells of different SM | |
555 | if (iDigit == 0 ) iSM0 = iSupMod; | |
556 | else if(iSupMod!= iSM0) return kTRUE; | |
557 | } | |
558 | ||
559 | return kFALSE; | |
560 | ||
561 | } | |
7db7dcb6 | 562 | |
cb5780f4 | 563 | //_____________________________________________________________________________________ |
564 | Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliVCluster* cluster, | |
6b28ddba | 565 | AliVCaloCells* cells) const |
cb5780f4 | 566 | { |
7cc7d3f8 | 567 | |
765d44e7 | 568 | // Given the list of AbsId of the cluster, get the maximum cell and |
569 | // check if there are fNCellsFromBorder from the calorimeter border | |
570 | ||
7cc7d3f8 | 571 | //If the distance to the border is 0 or negative just exit accept all clusters |
247abff4 | 572 | if(cells->GetType()==AliVCaloCells::kEMCALCell && fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder() <= 0 ) return kTRUE; |
c8fe2783 | 573 | if(cells->GetType()==AliVCaloCells::kPHOSCell && fNCellsFromPHOSBorder <= 0 ) return kTRUE; |
7cc7d3f8 | 574 | |
c8fe2783 | 575 | Int_t absIdMax = -1; |
765d44e7 | 576 | Float_t ampMax = -1; |
c8fe2783 | 577 | |
6b28ddba | 578 | for(Int_t i = 0; i < cluster->GetNCells() ; i++) |
579 | { | |
580 | Int_t absId = cluster->GetCellAbsId(i) ; | |
581 | Float_t amp = cells->GetCellAmplitude(absId); | |
582 | if(amp > ampMax) | |
583 | { | |
584 | ampMax = amp; | |
585 | absIdMax = absId; | |
c8fe2783 | 586 | } |
587 | } | |
765d44e7 | 588 | |
589 | if(fDebug > 1) | |
280e6766 | 590 | printf("AliCalorimeterUtils::CheckCellFiducialRegion() - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n", |
7cc7d3f8 | 591 | absIdMax, ampMax, cluster->E()); |
765d44e7 | 592 | |
593 | if(absIdMax==-1) return kFALSE; | |
594 | ||
595 | //Check if the cell is close to the borders: | |
596 | Bool_t okrow = kFALSE; | |
597 | Bool_t okcol = kFALSE; | |
7cc7d3f8 | 598 | |
6b28ddba | 599 | if(cells->GetType()==AliVCaloCells::kEMCALCell) |
600 | { | |
765d44e7 | 601 | Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1; |
602 | fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta); | |
603 | fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta); | |
280e6766 | 604 | if(iSM < 0 || iphi < 0 || ieta < 0 ) { |
605 | Fatal("CheckCellFidutialRegion","Negative value for super module: %d, or cell ieta: %d, or cell iphi: %d, check EMCAL geometry name\n",iSM,ieta,iphi); | |
606 | } | |
7cc7d3f8 | 607 | |
765d44e7 | 608 | //Check rows/phi |
247abff4 | 609 | Int_t nborder = fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(); |
5408e59e | 610 | if(iSM < 10) |
611 | { | |
247abff4 | 612 | if(iphi >= nborder && iphi < 24-nborder) okrow =kTRUE; |
7cc7d3f8 | 613 | } |
5408e59e | 614 | else |
615 | { | |
616 | if(fEMCALGeoName.Contains("12SM")) // 1/3 SM | |
297ee714 | 617 | { |
5408e59e | 618 | if(iphi >= nborder && iphi < 8-nborder) okrow =kTRUE; |
297ee714 | 619 | } |
5408e59e | 620 | else // 1/2 SM |
297ee714 | 621 | { |
5408e59e | 622 | if(iphi >= nborder && iphi <12-nborder) okrow =kTRUE; |
297ee714 | 623 | } |
765d44e7 | 624 | } |
625 | ||
247abff4 | 626 | //Check columns/eta |
5408e59e | 627 | if(!fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) |
628 | { | |
247abff4 | 629 | if(ieta > nborder && ieta < 48-nborder) okcol =kTRUE; |
765d44e7 | 630 | } |
5408e59e | 631 | else |
632 | { | |
633 | if(iSM%2==0) | |
634 | { | |
247abff4 | 635 | if(ieta >= nborder) okcol = kTRUE; |
765d44e7 | 636 | } |
5408e59e | 637 | else |
638 | { | |
247abff4 | 639 | if(ieta < 48-nborder) okcol = kTRUE; |
765d44e7 | 640 | } |
641 | }//eta 0 not checked | |
5408e59e | 642 | |
765d44e7 | 643 | if(fDebug > 1) |
644 | { | |
280e6766 | 645 | printf("AliCalorimeterUtils::CheckCellFiducialRegion() - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?", |
7cc7d3f8 | 646 | nborder, ieta, iphi, iSM); |
765d44e7 | 647 | if (okcol && okrow ) printf(" YES \n"); |
648 | else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow); | |
649 | } | |
650 | }//EMCAL | |
6b28ddba | 651 | else if ( cells->GetType() == AliVCaloCells::kPHOSCell ) |
652 | { | |
765d44e7 | 653 | Int_t relId[4]; |
654 | Int_t irow = -1, icol = -1; | |
655 | fPHOSGeo->AbsToRelNumbering(absIdMax,relId); | |
656 | irow = relId[2]; | |
657 | icol = relId[3]; | |
658 | //imod = relId[0]-1; | |
659 | if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE; | |
660 | if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE; | |
661 | if(fDebug > 1) | |
662 | { | |
280e6766 | 663 | printf("AliCalorimeterUtils::CheckCellFiducialRegion() - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d?", |
7cc7d3f8 | 664 | fNCellsFromPHOSBorder, icol, irow, relId[0]-1); |
765d44e7 | 665 | if (okcol && okrow ) printf(" YES \n"); |
666 | else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow); | |
667 | } | |
668 | }//PHOS | |
669 | ||
670 | if (okcol && okrow) return kTRUE; | |
671 | else return kFALSE; | |
672 | ||
673 | } | |
674 | ||
8a2dbbff | 675 | //__________________________________________________________________________________________________________ |
9dcf63c2 | 676 | Bool_t AliCalorimeterUtils::ClusterContainsBadChannel(Int_t calorimeter, UShort_t* cellList, Int_t nCells) |
cb5780f4 | 677 | { |
765d44e7 | 678 | // Check that in the cluster cells, there is no bad channel of those stored |
679 | // in fEMCALBadChannelMap or fPHOSBadChannelMap | |
680 | ||
681 | if (!fRemoveBadChannels) return kFALSE; | |
36037088 | 682 | //printf("fEMCALBadChannelMap %p, fPHOSBadChannelMap %p \n",fEMCALBadChannelMap,fPHOSBadChannelMap); |
9dcf63c2 | 683 | if(calorimeter == kEMCAL && !fEMCALRecoUtils->GetEMCALChannelStatusMap(0)) return kFALSE; |
684 | if(calorimeter == kPHOS && !fPHOSBadChannelMap) return kFALSE; | |
7cc7d3f8 | 685 | |
765d44e7 | 686 | Int_t icol = -1; |
687 | Int_t irow = -1; | |
688 | Int_t imod = -1; | |
689 | for(Int_t iCell = 0; iCell<nCells; iCell++){ | |
7cc7d3f8 | 690 | |
765d44e7 | 691 | //Get the column and row |
9dcf63c2 | 692 | if(calorimeter == kEMCAL){ |
247abff4 | 693 | return fEMCALRecoUtils->ClusterContainsBadChannel((AliEMCALGeometry*)fEMCALGeo,cellList,nCells); |
765d44e7 | 694 | } |
9dcf63c2 | 695 | else if(calorimeter==kPHOS){ |
765d44e7 | 696 | Int_t relId[4]; |
697 | fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId); | |
698 | irow = relId[2]; | |
699 | icol = relId[3]; | |
700 | imod = relId[0]-1; | |
701 | if(fPHOSBadChannelMap->GetEntries() <= imod)continue; | |
c5693f62 | 702 | //printf("PHOS bad channels imod %d, icol %d, irow %d\n",imod, irow, icol); |
703 | if(GetPHOSChannelStatus(imod, irow, icol)) return kTRUE; | |
765d44e7 | 704 | } |
705 | else return kFALSE; | |
706 | ||
707 | }// cell cluster loop | |
7cc7d3f8 | 708 | |
765d44e7 | 709 | return kFALSE; |
7cc7d3f8 | 710 | |
765d44e7 | 711 | } |
712 | ||
cb5780f4 | 713 | //_______________________________________________________________ |
714 | void AliCalorimeterUtils::CorrectClusterEnergy(AliVCluster *clus) | |
715 | { | |
9584c261 | 716 | // Correct cluster energy non linearity |
13cd2872 | 717 | |
9584c261 | 718 | clus->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(clus)); |
13cd2872 | 719 | |
720 | } | |
721 | ||
c5693f62 | 722 | //________________________________________________________________________________________ |
723 | Int_t AliCalorimeterUtils::GetMaxEnergyCell(AliVCaloCells* cells, const AliVCluster* clu, | |
724 | Float_t & clusterFraction) const | |
cb5780f4 | 725 | { |
13cd2872 | 726 | |
727 | //For a given CaloCluster gets the absId of the cell | |
728 | //with maximum energy deposit. | |
729 | ||
730 | if( !clu || !cells ){ | |
731 | AliInfo("Cluster or cells pointer is null!"); | |
732 | return -1; | |
733 | } | |
734 | ||
735 | Double_t eMax =-1.; | |
736 | Double_t eTot = 0.; | |
737 | Double_t eCell =-1.; | |
738 | Float_t fraction = 1.; | |
739 | Float_t recalFactor = 1.; | |
740 | Int_t cellAbsId =-1 , absId =-1 ; | |
741 | Int_t iSupMod =-1 , ieta =-1 , iphi = -1, iRCU = -1; | |
742 | ||
9dcf63c2 | 743 | Int_t calo = kEMCAL; |
744 | if(clu->IsPHOS()) calo = kPHOS ; | |
13cd2872 | 745 | |
746 | for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) { | |
747 | ||
748 | cellAbsId = clu->GetCellAbsId(iDig); | |
749 | ||
750 | fraction = clu->GetCellAmplitudeFraction(iDig); | |
751 | if(fraction < 1e-4) fraction = 1.; // in case unfolding is off | |
752 | ||
b08dd6d5 | 753 | iSupMod = GetModuleNumberCellIndexes(cellAbsId, calo, ieta, iphi, iRCU); |
13cd2872 | 754 | |
755 | if(IsRecalibrationOn()) { | |
9dcf63c2 | 756 | if(calo==kEMCAL) recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi); |
757 | else recalFactor = GetPHOSChannelRecalibrationFactor (iSupMod,iphi,ieta); | |
13cd2872 | 758 | } |
759 | ||
760 | eCell = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor; | |
761 | ||
762 | if(eCell > eMax) { | |
763 | eMax = eCell; | |
764 | absId = cellAbsId; | |
765 | } | |
766 | ||
767 | eTot+=eCell; | |
768 | ||
769 | }// cell loop | |
770 | ||
e9413ebb | 771 | if(eTot > 0.1) |
772 | clusterFraction = (eTot-eMax)/eTot; //Do not use cluster energy in case it was corrected for non linearity. | |
773 | else | |
774 | clusterFraction =1.; | |
13cd2872 | 775 | |
776 | return absId; | |
777 | ||
9584c261 | 778 | } |
779 | ||
8a2dbbff | 780 | //___________________________________________________________________________________ |
781 | AliVTrack * AliCalorimeterUtils::GetMatchedTrack(AliVCluster* cluster, | |
782 | AliVEvent* event, Int_t index) const | |
d832b695 | 783 | { |
784 | // Get the matched track given its index, usually just the first match | |
785 | // Since it is different for ESDs and AODs here it is a wrap method to do it | |
786 | ||
787 | AliVTrack *track = 0; | |
788 | ||
789 | // EMCAL case only when matching is recalculated | |
790 | if(cluster->IsEMCAL() && IsRecalculationOfClusterTrackMatchingOn()) | |
791 | { | |
792 | Int_t trackIndex = fEMCALRecoUtils->GetMatchedTrackIndex(cluster->GetID()); | |
793 | //printf("track index %d, cluster ID %d \n ",trackIndex,cluster->GetID()); | |
794 | ||
795 | if(trackIndex < 0 ) | |
796 | { | |
797 | printf("AliCalorimeterUtils::GetMatchedTrack() - Wrong track index %d, from recalculation\n", trackIndex); | |
798 | } | |
799 | else | |
800 | { | |
801 | track = dynamic_cast<AliVTrack*> (event->GetTrack(trackIndex)); | |
802 | } | |
803 | ||
804 | return track ; | |
805 | ||
806 | } | |
807 | ||
808 | // Normal case, get info from ESD or AOD | |
809 | // ESDs | |
810 | if(!strcmp("AliESDCaloCluster",Form("%s",cluster->ClassName()))) | |
811 | { | |
812 | Int_t iESDtrack = cluster->GetTrackMatchedIndex(); | |
813 | ||
814 | if(iESDtrack < 0 ) | |
815 | { | |
816 | printf("AliCalorimeterUtils::GetMatchedTrack() - Wrong track index %d\n", index); | |
817 | return 0x0; | |
818 | } | |
819 | ||
820 | track = dynamic_cast<AliVTrack*> (event->GetTrack(iESDtrack)); | |
821 | ||
822 | } | |
823 | else // AODs | |
824 | { | |
825 | if(cluster->GetNTracksMatched() > 0 ) | |
826 | track = dynamic_cast<AliVTrack*>(cluster->GetTrackMatched(index)); | |
827 | } | |
828 | ||
829 | return track ; | |
830 | ||
831 | } | |
e1d24b6a | 832 | //______________________________________________________________________________________________ |
833 | Float_t AliCalorimeterUtils::GetMCECellClusFracCorrection(Float_t eCell, Float_t eCluster) const | |
834 | { | |
835 | // Correction factor for cell energy in cluster to temptatively match Data and MC | |
836 | if( eCluster <= 0 || eCluster < eCell ) | |
837 | { | |
838 | printf("AliCalorimeterUtils::GetMCECellClusFracCorrection() - Bad values eCell=%f, eCluster %f\n",eCell,eCluster); | |
839 | return 1; | |
840 | } | |
841 | ||
842 | Float_t frac = eCell / eCluster; | |
843 | ||
844 | Float_t correction = fMCECellClusFracCorrParam[0] + | |
845 | TMath::Exp( frac*fMCECellClusFracCorrParam[2]+fMCECellClusFracCorrParam[1] ) + | |
846 | fMCECellClusFracCorrParam[3]/TMath::Sqrt(frac); | |
847 | ||
848 | // printf("AliCalorimeterUtils::GetMCECellClusFracCorrection(eCell=%f, eCluster %f, frac %f) = %f\n",eCell, eCluster, frac, correction); | |
849 | // printf("\t %2.2f + TMath::Exp( %2.3f*%2.2f + %2.2f ) + %2.2f/TMath::Sqrt(%2.3f)) = %f\n", | |
850 | // fMCECellClusFracCorrParam[0],frac,fMCECellClusFracCorrParam[2],fMCECellClusFracCorrParam[1],fMCECellClusFracCorrParam[3], frac, correction); | |
851 | ||
852 | return correction; | |
853 | } | |
854 | ||
cb5780f4 | 855 | //_____________________________________________________________________________________________________ |
765d44e7 | 856 | Int_t AliCalorimeterUtils::GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent * inputEvent) const |
857 | { | |
858 | //Get the EMCAL/PHOS module number that corresponds to this particle | |
859 | ||
860 | Int_t absId = -1; | |
9dcf63c2 | 861 | if(particle->GetDetector()==kEMCAL) |
e95c8cc6 | 862 | { |
765d44e7 | 863 | fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId); |
e95c8cc6 | 864 | |
865 | if(fDebug > 2) | |
765d44e7 | 866 | printf("AliCalorimeterUtils::GetModuleNumber(PWG4AOD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n", |
7cc7d3f8 | 867 | particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId)); |
e95c8cc6 | 868 | |
765d44e7 | 869 | return fEMCALGeo->GetSuperModuleNumber(absId) ; |
870 | }//EMCAL | |
9dcf63c2 | 871 | else if(particle->GetDetector()==kPHOS) |
55d66f31 | 872 | { |
e95c8cc6 | 873 | // In case we use the MC reader, the input are TParticles, |
46a3cde6 | 874 | // in this case use the corresponing method in PHOS Geometry to get the particle. |
875 | if(strcmp(inputEvent->ClassName(), "AliMCEvent") == 0 ) | |
876 | { | |
877 | Int_t mod =-1; | |
878 | Double_t z = 0., x=0.; | |
879 | TParticle* primary = 0x0; | |
880 | AliStack * stack = ((AliMCEvent*)inputEvent)->Stack(); | |
e95c8cc6 | 881 | if(stack) |
882 | { | |
46a3cde6 | 883 | primary = stack->Particle(particle->GetCaloLabel(0)); |
884 | } | |
e95c8cc6 | 885 | else |
886 | { | |
280e6766 | 887 | Fatal("GetModuleNumber(PWG4AOD)", "Stack not available, stop!"); |
46a3cde6 | 888 | } |
898c9d44 | 889 | |
e95c8cc6 | 890 | if(primary) |
891 | { | |
898c9d44 | 892 | fPHOSGeo->ImpactOnEmc(primary,mod,z,x) ; |
893 | } | |
e95c8cc6 | 894 | else |
895 | { | |
898c9d44 | 896 | Fatal("GetModuleNumber(PWG4AOD)", "Primary not available, stop!"); |
897 | } | |
46a3cde6 | 898 | return mod; |
899 | } | |
900 | // Input are ESDs or AODs, get the PHOS module number like this. | |
e95c8cc6 | 901 | else |
902 | { | |
2206e918 | 903 | //FIXME |
904 | //AliVCluster *cluster = inputEvent->GetCaloCluster(particle->GetCaloLabel(0)); | |
905 | //return GetModuleNumber(cluster); | |
906 | //MEFIX | |
907 | return -1; | |
46a3cde6 | 908 | } |
765d44e7 | 909 | }//PHOS |
910 | ||
911 | return -1; | |
912 | } | |
913 | ||
cb5780f4 | 914 | //_____________________________________________________________________ |
c8fe2783 | 915 | Int_t AliCalorimeterUtils::GetModuleNumber(AliVCluster * cluster) const |
765d44e7 | 916 | { |
280e6766 | 917 | //Get the EMCAL/PHOS module number that corresponds to this cluster |
e95c8cc6 | 918 | |
55d66f31 | 919 | if(!cluster) |
920 | { | |
9cbbc28b | 921 | if(fDebug > 1) printf("AliCalorimeterUtils::GetModuleNumber() - NUL Cluster, please check!!!"); |
e95c8cc6 | 922 | |
9cbbc28b | 923 | return -1; |
924 | } | |
55d66f31 | 925 | |
e95c8cc6 | 926 | if ( cluster->GetNCells() <= 0 ) return -1; |
927 | ||
928 | Int_t absId = cluster->GetCellAbsId(0); | |
929 | ||
930 | if ( absId < 0 ) return -1; | |
931 | ||
932 | if( cluster->IsEMCAL() ) | |
933 | { | |
934 | if(fDebug > 2) printf("AliCalorimeterUtils::GetModuleNumber() - EMCAL absid %d, SuperModule %d\n",absId, fEMCALGeo->GetSuperModuleNumber(absId)); | |
935 | ||
765d44e7 | 936 | return fEMCALGeo->GetSuperModuleNumber(absId) ; |
937 | }//EMCAL | |
e95c8cc6 | 938 | else if ( cluster->IsPHOS() ) |
55d66f31 | 939 | { |
765d44e7 | 940 | Int_t relId[4]; |
e95c8cc6 | 941 | fPHOSGeo->AbsToRelNumbering(absId,relId); |
942 | ||
943 | if(fDebug > 2) printf("AliCalorimeterUtils::GetModuleNumber() - PHOS absid %d Module %d\n",absId, relId[0]-1); | |
944 | ||
945 | return relId[0]-1; | |
946 | }//PHOS | |
765d44e7 | 947 | |
948 | return -1; | |
949 | } | |
950 | ||
cb5780f4 | 951 | //___________________________________________________________________________________________________ |
9dcf63c2 | 952 | Int_t AliCalorimeterUtils::GetModuleNumberCellIndexes(Int_t absId, Int_t calo, |
cb5780f4 | 953 | Int_t & icol, Int_t & irow, Int_t & iRCU) const |
765d44e7 | 954 | { |
955 | //Get the EMCAL/PHOS module, columns, row and RCU number that corresponds to this absId | |
e95c8cc6 | 956 | |
765d44e7 | 957 | Int_t imod = -1; |
e95c8cc6 | 958 | |
959 | if ( absId < 0) return -1 ; | |
960 | ||
9dcf63c2 | 961 | if ( calo == kEMCAL ) |
55d66f31 | 962 | { |
e95c8cc6 | 963 | Int_t iTower = -1, iIphi = -1, iIeta = -1; |
964 | fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta); | |
965 | fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol); | |
966 | ||
967 | if(imod < 0 || irow < 0 || icol < 0 ) | |
55d66f31 | 968 | { |
e95c8cc6 | 969 | Fatal("GetModuleNumberCellIndexes()","Negative value for super module: %d, or cell icol: %d, or cell irow: %d, check EMCAL geometry name\n",imod,icol,irow); |
970 | } | |
971 | ||
972 | //RCU0 | |
973 | if(imod < 10 ) | |
974 | { | |
975 | if (0<=irow&&irow<8) iRCU=0; // first cable row | |
976 | else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half; | |
977 | //second cable row | |
978 | //RCU1 | |
979 | else if (8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half; | |
980 | //second cable row | |
981 | else if (16<=irow&&irow<24) iRCU=1; // third cable row | |
55d66f31 | 982 | |
e95c8cc6 | 983 | if (imod%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same |
984 | } | |
985 | else | |
55d66f31 | 986 | { |
e95c8cc6 | 987 | // Last 2 SM have one single SRU, just assign RCU 0 |
988 | iRCU = 0 ; | |
989 | } | |
990 | ||
991 | if (iRCU<0) | |
992 | { | |
993 | Fatal("GetModuleNumberCellIndexes()","Wrong EMCAL RCU number = %d\n", iRCU); | |
994 | } | |
995 | ||
996 | return imod ; | |
997 | ||
998 | }//EMCAL | |
999 | else //PHOS | |
1000 | { | |
1001 | Int_t relId[4]; | |
1002 | fPHOSGeo->AbsToRelNumbering(absId,relId); | |
1003 | irow = relId[2]; | |
1004 | icol = relId[3]; | |
1005 | imod = relId[0]-1; | |
1006 | iRCU= (Int_t)(relId[2]-1)/16 ; | |
1007 | //Int_t iBranch= (Int_t)(relid[3]-1)/28 ; //0 to 1 | |
1008 | if (iRCU >= 4) | |
1009 | { | |
1010 | Fatal("GetModuleNumberCellIndexes()","Wrong PHOS RCU number = %d\n", iRCU); | |
1011 | } | |
1012 | return imod; | |
1013 | }//PHOS | |
765d44e7 | 1014 | |
1015 | return -1; | |
1016 | } | |
1017 | ||
71e3889f | 1018 | //___________________________________________________________________________________________ |
1019 | Int_t AliCalorimeterUtils::GetNumberOfLocalMaxima(AliVCluster* cluster, AliVCaloCells* cells) | |
1020 | { | |
1021 | // Find local maxima in cluster | |
1022 | ||
1023 | const Int_t nc = cluster->GetNCells(); | |
2bf17171 | 1024 | Int_t absIdList[nc]; |
1025 | Float_t maxEList[nc]; | |
71e3889f | 1026 | |
1027 | Int_t nMax = GetNumberOfLocalMaxima(cluster, cells, absIdList, maxEList); | |
1028 | ||
71e3889f | 1029 | return nMax; |
1030 | ||
1031 | } | |
1032 | ||
7db7dcb6 | 1033 | //___________________________________________________________________________________________ |
1034 | Int_t AliCalorimeterUtils::GetNumberOfLocalMaxima(AliVCluster* cluster, AliVCaloCells* cells, | |
1035 | Int_t *absIdList, Float_t *maxEList) | |
1036 | { | |
1037 | // Find local maxima in cluster | |
f241ecc3 | 1038 | |
7db7dcb6 | 1039 | Int_t iDigitN = 0 ; |
1040 | Int_t iDigit = 0 ; | |
1041 | Int_t absId1 = -1 ; | |
1042 | Int_t absId2 = -1 ; | |
1043 | const Int_t nCells = cluster->GetNCells(); | |
1044 | ||
e1d24b6a | 1045 | Float_t eCluster = RecalibrateClusterEnergy(cluster, cells);// recalculate cluster energy, avoid non lin correction. |
1046 | ||
1047 | Float_t simuTotWeight = 0; | |
1048 | if(fMCECellClusFracCorrOn) | |
1049 | { | |
1050 | simuTotWeight = RecalibrateClusterEnergyWeightCell(cluster, cells,eCluster);// same but apply a weight | |
1051 | simuTotWeight/= eCluster; | |
1052 | } | |
1053 | ||
9dcf63c2 | 1054 | Int_t calorimeter = kEMCAL; |
1055 | if(!cluster->IsEMCAL()) calorimeter = kPHOS; | |
7db7dcb6 | 1056 | |
1057 | //printf("cluster : ncells %d \n",nCells); | |
f241ecc3 | 1058 | |
1059 | Float_t emax = 0; | |
1060 | Int_t idmax =-1; | |
9369a2b1 | 1061 | for(iDigit = 0; iDigit < nCells ; iDigit++) |
1062 | { | |
7db7dcb6 | 1063 | absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit] ; |
f241ecc3 | 1064 | Float_t en = cells->GetCellAmplitude(absIdList[iDigit]); |
e1d24b6a | 1065 | RecalibrateCellAmplitude(en,calorimeter,absIdList[iDigit]); |
1066 | ||
1067 | if(fMCECellClusFracCorrOn) | |
1068 | en*=GetMCECellClusFracCorrection(en,eCluster)/simuTotWeight; | |
1069 | ||
f241ecc3 | 1070 | if( en > emax ) |
1071 | { | |
1072 | emax = en ; | |
1073 | idmax = absIdList[iDigit] ; | |
1074 | } | |
1075 | //Int_t icol = -1, irow = -1, iRCU = -1; | |
1076 | //Int_t sm = GetModuleNumberCellIndexes(absIdList[iDigit], calorimeter, icol, irow, iRCU) ; | |
1077 | //printf("\t cell %d, id %d, sm %d, col %d, row %d, e %f\n", iDigit, absIdList[iDigit], sm, icol, irow, en ); | |
7db7dcb6 | 1078 | } |
1079 | ||
9369a2b1 | 1080 | for(iDigit = 0 ; iDigit < nCells; iDigit++) |
1081 | { | |
1082 | if(absIdList[iDigit]>=0) | |
1083 | { | |
1084 | absId1 = cluster->GetCellsAbsId()[iDigit]; | |
7db7dcb6 | 1085 | |
1086 | Float_t en1 = cells->GetCellAmplitude(absId1); | |
1087 | RecalibrateCellAmplitude(en1,calorimeter,absId1); | |
f241ecc3 | 1088 | |
e1d24b6a | 1089 | if(fMCECellClusFracCorrOn) |
1090 | en1*=GetMCECellClusFracCorrection(en1,eCluster)/simuTotWeight; | |
1091 | ||
9369a2b1 | 1092 | //printf("%d : absIDi %d, E %f\n",iDigit, absId1,en1); |
7db7dcb6 | 1093 | |
9369a2b1 | 1094 | for(iDigitN = 0; iDigitN < nCells; iDigitN++) |
1095 | { | |
1096 | absId2 = cluster->GetCellsAbsId()[iDigitN] ; | |
7db7dcb6 | 1097 | |
9369a2b1 | 1098 | if(absId2==-1 || absId2==absId1) continue; |
7db7dcb6 | 1099 | |
9369a2b1 | 1100 | //printf("\t %d : absIDj %d\n",iDigitN, absId2); |
7db7dcb6 | 1101 | |
1102 | Float_t en2 = cells->GetCellAmplitude(absId2); | |
1103 | RecalibrateCellAmplitude(en2,calorimeter,absId2); | |
f241ecc3 | 1104 | |
e1d24b6a | 1105 | if(fMCECellClusFracCorrOn) |
1106 | en2*=GetMCECellClusFracCorrection(en2,eCluster)/simuTotWeight; | |
1107 | ||
9369a2b1 | 1108 | //printf("\t %d : absIDj %d, E %f\n",iDigitN, absId2,en2); |
7db7dcb6 | 1109 | |
9369a2b1 | 1110 | if ( AreNeighbours(calorimeter, absId1, absId2) ) |
1111 | { | |
1112 | // printf("\t \t Neighbours \n"); | |
1113 | if (en1 > en2 ) | |
1114 | { | |
7db7dcb6 | 1115 | absIdList[iDigitN] = -1 ; |
1116 | //printf("\t \t indexN %d not local max\n",iDigitN); | |
1117 | // but may be digit too is not local max ? | |
1118 | if(en1 < en2 + fLocMaxCutEDiff) { | |
9369a2b1 | 1119 | //printf("\t \t index %d not local max cause locMaxCutEDiff\n",iDigit); |
7db7dcb6 | 1120 | absIdList[iDigit] = -1 ; |
1121 | } | |
1122 | } | |
9369a2b1 | 1123 | else |
1124 | { | |
7db7dcb6 | 1125 | absIdList[iDigit] = -1 ; |
1126 | //printf("\t \t index %d not local max\n",iDigitN); | |
1127 | // but may be digitN too is not local max ? | |
1128 | if(en1 > en2 - fLocMaxCutEDiff) | |
1129 | { | |
1130 | absIdList[iDigitN] = -1 ; | |
9369a2b1 | 1131 | //printf("\t \t indexN %d not local max cause locMaxCutEDiff\n",iDigit); |
7db7dcb6 | 1132 | } |
1133 | } | |
9369a2b1 | 1134 | } // if Are neighbours |
1135 | //else printf("\t \t NOT Neighbours \n"); | |
7db7dcb6 | 1136 | } // while digitN |
1137 | } // slot not empty | |
1138 | } // while digit | |
1139 | ||
1140 | iDigitN = 0 ; | |
9369a2b1 | 1141 | for(iDigit = 0; iDigit < nCells; iDigit++) |
1142 | { | |
1143 | if(absIdList[iDigit]>=0 ) | |
1144 | { | |
7db7dcb6 | 1145 | absIdList[iDigitN] = absIdList[iDigit] ; |
e1d24b6a | 1146 | |
7db7dcb6 | 1147 | Float_t en = cells->GetCellAmplitude(absIdList[iDigit]); |
e1d24b6a | 1148 | RecalibrateCellAmplitude(en,calorimeter,absIdList[iDigit]); |
1149 | ||
1150 | if(fMCECellClusFracCorrOn) | |
1151 | en*=GetMCECellClusFracCorrection(en,eCluster)/simuTotWeight; | |
1152 | ||
7db7dcb6 | 1153 | if(en < fLocMaxCutE) continue; // Maxima only with seed energy at least |
e1d24b6a | 1154 | |
7db7dcb6 | 1155 | maxEList[iDigitN] = en ; |
e1d24b6a | 1156 | |
7db7dcb6 | 1157 | //printf("Local max %d, id %d, en %f\n", iDigit,absIdList[iDigitN],en); |
1158 | iDigitN++ ; | |
1159 | } | |
1160 | } | |
1161 | ||
f241ecc3 | 1162 | if(iDigitN == 0) |
1163 | { | |
1164 | if(fDebug > 0) | |
1165 | printf("AliCalorimeterUtils::GetNumberOfLocalMaxima() - No local maxima found, assign highest energy cell as maxima, id %d, en cell %2.2f, en cluster %2.2f\n", | |
1166 | idmax,emax,cluster->E()); | |
1167 | iDigitN = 1 ; | |
1168 | maxEList[0] = emax ; | |
1169 | absIdList[0] = idmax ; | |
1170 | } | |
1171 | ||
1172 | if(fDebug > 0) | |
1173 | { | |
e1d24b6a | 1174 | printf("AliCalorimeterUtils::GetNumberOfLocalMaxima() - In cluster E %2.2f (wth non lin. %2.2f), M02 %2.2f, M20 %2.2f, N maxima %d \n", |
1175 | cluster->E(),eCluster, cluster->GetM02(),cluster->GetM20(), iDigitN); | |
f241ecc3 | 1176 | |
1177 | if(fDebug > 1) for(Int_t imax = 0; imax < iDigitN; imax++) | |
1178 | { | |
1179 | printf(" \t i %d, absId %d, Ecell %f\n",imax,absIdList[imax],maxEList[imax]); | |
1180 | } | |
1181 | } | |
7db7dcb6 | 1182 | |
1183 | return iDigitN ; | |
1184 | ||
1185 | } | |
1186 | ||
55d66f31 | 1187 | //____________________________________ |
1188 | TString AliCalorimeterUtils::GetPass() | |
1189 | { | |
1190 | // Get passx from filename. | |
1191 | ||
1192 | if (!AliAnalysisManager::GetAnalysisManager()->GetTree()) | |
1193 | { | |
1194 | AliError("AliCalorimeterUtils::GetPass() - Pointer to tree = 0, returning null\n"); | |
1195 | return TString(""); | |
1196 | } | |
1197 | ||
1198 | if (!AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()) | |
1199 | { | |
1200 | AliError("AliCalorimeterUtils::GetPass() - Null pointer input file, returning null\n"); | |
1201 | return TString(""); | |
1202 | } | |
1203 | ||
1204 | TString pass(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName()); | |
1205 | if (pass.Contains("ass1")) return TString("pass1"); | |
1206 | else if (pass.Contains("ass2")) return TString("pass2"); | |
1207 | else if (pass.Contains("ass3")) return TString("pass3"); | |
4898bb87 | 1208 | else if (pass.Contains("ass4")) return TString("pass4"); |
1209 | else if (pass.Contains("ass5")) return TString("pass5"); | |
9783326d | 1210 | else if (pass.Contains("LHC11c") && pass.Contains("spc_calo") ) return TString("spc_calo"); |
fca053d8 | 1211 | else if (pass.Contains("calo") || pass.Contains("high_lumi")) |
1212 | { | |
1213 | printf("AliCalorimeterUtils::GetPass() - Path contains <calo> or <high-lumi>, set as <pass1>\n"); | |
1214 | return TString("pass1"); | |
1215 | } | |
55d66f31 | 1216 | |
1217 | // No condition fullfilled, give a default value | |
1218 | printf("AliCalorimeterUtils::GetPass() - Pass number string not found \n"); | |
1219 | return TString(""); | |
1220 | ||
1221 | } | |
1222 | ||
cb5780f4 | 1223 | //________________________________________ |
765d44e7 | 1224 | void AliCalorimeterUtils::InitParameters() |
1225 | { | |
1226 | //Initialize the parameters of the analysis. | |
7db7dcb6 | 1227 | |
12e91266 | 1228 | fEMCALGeoName = ""; |
1229 | fPHOSGeoName = ""; | |
7db7dcb6 | 1230 | |
7cc7d3f8 | 1231 | fEMCALGeoMatrixSet = kFALSE; |
1232 | fPHOSGeoMatrixSet = kFALSE; | |
7db7dcb6 | 1233 | |
7cc7d3f8 | 1234 | fRemoveBadChannels = kFALSE; |
7db7dcb6 | 1235 | |
7cc7d3f8 | 1236 | fNCellsFromPHOSBorder = 0; |
a5fb4114 | 1237 | |
7db7dcb6 | 1238 | fLocMaxCutE = 0.1 ; |
1239 | fLocMaxCutEDiff = 0.0 ; | |
1240 | ||
7cc7d3f8 | 1241 | // fMaskCellColumns = new Int_t[fNMaskCellColumns]; |
1242 | // fMaskCellColumns[0] = 6 ; fMaskCellColumns[1] = 7 ; fMaskCellColumns[2] = 8 ; | |
1243 | // fMaskCellColumns[3] = 35; fMaskCellColumns[4] = 36; fMaskCellColumns[5] = 37; | |
1244 | // fMaskCellColumns[6] = 12+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[7] = 13+AliEMCALGeoParams::fgkEMCALCols; | |
1245 | // fMaskCellColumns[8] = 40+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[9] = 41+AliEMCALGeoParams::fgkEMCALCols; | |
1246 | // fMaskCellColumns[10]= 42+AliEMCALGeoParams::fgkEMCALCols; | |
a5fb4114 | 1247 | |
55d66f31 | 1248 | fOADBSet = kFALSE; |
1249 | fOADBForEMCAL = kTRUE ; | |
1250 | fOADBForPHOS = kFALSE; | |
1251 | ||
1252 | fOADBFilePathEMCAL = "$ALICE_ROOT/OADB/EMCAL" ; | |
1253 | fOADBFilePathPHOS = "$ALICE_ROOT/OADB/PHOS" ; | |
1254 | ||
9e536695 | 1255 | fImportGeometryFromFile = kTRUE; |
1256 | fImportGeometryFilePath = ""; | |
190f6f2d | 1257 | |
1258 | fNSuperModulesUsed = 22; | |
9e536695 | 1259 | |
e1d24b6a | 1260 | fMCECellClusFracCorrParam[0] = 0.78; |
1261 | fMCECellClusFracCorrParam[1] =-1.8; | |
1262 | fMCECellClusFracCorrParam[2] =-6.3; | |
1263 | fMCECellClusFracCorrParam[3] = 0.014; | |
1264 | ||
765d44e7 | 1265 | } |
1266 | ||
765d44e7 | 1267 | |
cb5780f4 | 1268 | //_____________________________________________________ |
1269 | void AliCalorimeterUtils::InitPHOSBadChannelStatusMap() | |
1270 | { | |
765d44e7 | 1271 | //Init PHOS bad channels map |
1272 | if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSBadChannelStatusMap()\n"); | |
1273 | //In order to avoid rewriting the same histograms | |
1274 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
1275 | TH1::AddDirectory(kFALSE); | |
7cc7d3f8 | 1276 | |
78219bac | 1277 | fPHOSBadChannelMap = new TObjArray(5); |
c5693f62 | 1278 | for (int i = 0; i < 5; i++)fPHOSBadChannelMap->Add(new TH2I(Form("PHOS_BadMap_mod%d",i),Form("PHOS_BadMap_mod%d",i), 64, 0, 64, 56, 0, 56)); |
7cc7d3f8 | 1279 | |
765d44e7 | 1280 | fPHOSBadChannelMap->SetOwner(kTRUE); |
1281 | fPHOSBadChannelMap->Compress(); | |
1282 | ||
1283 | //In order to avoid rewriting the same histograms | |
1284 | TH1::AddDirectory(oldStatus); | |
1285 | } | |
1286 | ||
cb5780f4 | 1287 | //______________________________________________________ |
1288 | void AliCalorimeterUtils::InitPHOSRecalibrationFactors() | |
1289 | { | |
09e819c9 | 1290 | //Init EMCAL recalibration factors |
1291 | if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSRecalibrationFactors()\n"); | |
1292 | //In order to avoid rewriting the same histograms | |
1293 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
1294 | TH1::AddDirectory(kFALSE); | |
7cc7d3f8 | 1295 | |
78219bac | 1296 | fPHOSRecalibrationFactors = new TObjArray(5); |
c5693f62 | 1297 | for (int i = 0; i < 5; i++)fPHOSRecalibrationFactors->Add(new TH2F(Form("PHOSRecalFactors_Mod%d",i),Form("PHOSRecalFactors_Mod%d",i), 64, 0, 64, 56, 0, 56)); |
09e819c9 | 1298 | //Init the histograms with 1 |
1299 | for (Int_t m = 0; m < 5; m++) { | |
1300 | for (Int_t i = 0; i < 56; i++) { | |
1301 | for (Int_t j = 0; j < 64; j++) { | |
c5693f62 | 1302 | SetPHOSChannelRecalibrationFactor(m,j,i,1.); |
09e819c9 | 1303 | } |
1304 | } | |
1305 | } | |
1306 | fPHOSRecalibrationFactors->SetOwner(kTRUE); | |
1307 | fPHOSRecalibrationFactors->Compress(); | |
1308 | ||
1309 | //In order to avoid rewriting the same histograms | |
1310 | TH1::AddDirectory(oldStatus); | |
1311 | } | |
1312 | ||
1313 | ||
55d66f31 | 1314 | //__________________________________________________________ |
1315 | void AliCalorimeterUtils::InitEMCALGeometry(Int_t runnumber) | |
765d44e7 | 1316 | { |
1317 | //Initialize EMCAL geometry if it did not exist previously | |
55d66f31 | 1318 | |
1319 | if (!fEMCALGeo) | |
1320 | { | |
1321 | if(fEMCALGeoName=="") | |
1322 | { | |
5408e59e | 1323 | if (runnumber < 140000 && |
1324 | runnumber >= 100000) fEMCALGeoName = "EMCAL_FIRSTYEARV1"; | |
1325 | else if(runnumber >= 140000 && | |
1326 | runnumber < 171000) fEMCALGeoName = "EMCAL_COMPLETEV1"; | |
1327 | else fEMCALGeoName = "EMCAL_COMPLETE12SMV1"; | |
55d66f31 | 1328 | printf("AliCalorimeterUtils::InitEMCALGeometry() - Set EMCAL geometry name to <%s> for run %d\n",fEMCALGeoName.Data(),runnumber); |
1329 | } | |
1330 | ||
a38a48f2 | 1331 | fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName); |
55d66f31 | 1332 | |
9e536695 | 1333 | // Init geometry, I do not like much to do it like this ... |
1334 | if(fImportGeometryFromFile && !gGeoManager) | |
1335 | { | |
1336 | if(fImportGeometryFilePath=="") // If not specified, set location depending on run number | |
1337 | { | |
1338 | // "$ALICE_ROOT/EVE/alice-data/default_geo.root" | |
1339 | if (runnumber < 140000 && | |
1340 | runnumber >= 100000) fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2010.root"; | |
1341 | if (runnumber >= 140000 && | |
1342 | runnumber < 171000) fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2011.root"; | |
1343 | else fImportGeometryFilePath = "$ALICE_ROOT/OADB/EMCAL/geometry_2012.root"; // 2012-2013 | |
1344 | ||
1345 | } | |
1346 | printf("AliCalorimeterUtils::InitEMCALGeometry() - Import %s\n",fImportGeometryFilePath.Data()); | |
1347 | TGeoManager::Import(fImportGeometryFilePath) ; // default need file "geometry.root" in local dir!!!! | |
1348 | } | |
1349 | ||
1350 | ||
55d66f31 | 1351 | if(fDebug > 0) |
1352 | { | |
1353 | printf("AliCalorimeterUtils::InitEMCALGeometry(run=%d)",runnumber); | |
765d44e7 | 1354 | if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices"); |
1355 | printf("\n"); | |
1356 | } | |
1357 | } | |
1358 | } | |
1359 | ||
55d66f31 | 1360 | //_________________________________________________________ |
1361 | void AliCalorimeterUtils::InitPHOSGeometry(Int_t runnumber) | |
765d44e7 | 1362 | { |
1363 | //Initialize PHOS geometry if it did not exist previously | |
55d66f31 | 1364 | |
1365 | if (!fPHOSGeo) | |
1366 | { | |
1367 | if(fPHOSGeoName=="") fPHOSGeoName = "PHOSgeo"; | |
1368 | ||
765d44e7 | 1369 | fPHOSGeo = new AliPHOSGeoUtils(fPHOSGeoName); |
55d66f31 | 1370 | |
1371 | if(fDebug > 0) | |
1372 | { | |
1373 | printf("AliCalorimeterUtils::InitPHOSGeometry(run=%d)",runnumber); | |
765d44e7 | 1374 | if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices"); |
1375 | printf("\n"); | |
1376 | } | |
1377 | } | |
1378 | } | |
1379 | ||
4eb65103 | 1380 | //_______________________________________________________________________________________________ |
9dcf63c2 | 1381 | Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, TParticle* particle) |
4eb65103 | 1382 | { |
1383 | // Check that a MC ESD is in the calorimeter acceptance | |
1384 | ||
9dcf63c2 | 1385 | if(!particle || (calo!=kEMCAL && calo!=kPHOS)) return kFALSE ; |
78c59849 | 1386 | |
9dcf63c2 | 1387 | if( (!IsPHOSGeoMatrixSet () && calo == kPHOS ) || |
1388 | (!IsEMCALGeoMatrixSet() && calo == kEMCAL) ) | |
4eb65103 | 1389 | { |
9dcf63c2 | 1390 | AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead \n",calo)); |
4eb65103 | 1391 | return kFALSE ; |
1392 | } | |
78c59849 | 1393 | |
9dcf63c2 | 1394 | if(calo == kPHOS ) |
4eb65103 | 1395 | { |
1396 | Int_t mod = 0 ; | |
1397 | Double_t x = 0, z = 0 ; | |
4eb65103 | 1398 | return GetPHOSGeometry()->ImpactOnEmc( particle, mod, z, x); |
1399 | } | |
9dcf63c2 | 1400 | else if(calo == kEMCAL) |
4eb65103 | 1401 | { |
1402 | Int_t absID = 0 ; | |
fb371b83 | 1403 | Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(),absID); |
1404 | if(ok) | |
1405 | { | |
1406 | Int_t icol = -1, irow = -1, iRCU = -1; | |
1407 | Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU); | |
1408 | Int_t status = GetEMCALChannelStatus(nModule,icol,irow); | |
1409 | if(status > 0) ok = kFALSE; | |
1410 | } | |
1411 | return ok ; | |
4eb65103 | 1412 | } |
1413 | ||
1414 | return kFALSE ; | |
1415 | } | |
1416 | ||
1417 | //______________________________________________________________________________________________________ | |
9dcf63c2 | 1418 | Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, AliAODMCParticle* particle) |
4eb65103 | 1419 | { |
1420 | // Check that a MC AOD is in the calorimeter acceptance | |
1421 | ||
9dcf63c2 | 1422 | if(!particle || (calo!=kEMCAL && calo!=kPHOS)) return kFALSE ; |
776d42c5 | 1423 | |
9dcf63c2 | 1424 | if( (!IsPHOSGeoMatrixSet () && calo == kPHOS ) || |
1425 | (!IsEMCALGeoMatrixSet() && calo == kEMCAL) ) | |
4eb65103 | 1426 | { |
9dcf63c2 | 1427 | AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead \n",calo)); |
4eb65103 | 1428 | return kFALSE ; |
1429 | } | |
1430 | ||
fb371b83 | 1431 | Float_t phi = particle->Phi(); |
1432 | if(phi < 0) phi+=TMath::TwoPi(); | |
1433 | ||
9dcf63c2 | 1434 | if(calo == kPHOS ) |
4eb65103 | 1435 | { |
1436 | Int_t mod = 0 ; | |
1437 | Double_t x = 0, z = 0 ; | |
4eb65103 | 1438 | Double_t vtx[]={ particle->Xv(), particle->Yv(), particle->Zv() } ; |
fb371b83 | 1439 | return GetPHOSGeometry()->ImpactOnEmc(vtx, particle->Theta(), phi, mod, z, x) ; |
4eb65103 | 1440 | } |
9dcf63c2 | 1441 | else if(calo == kEMCAL) |
4eb65103 | 1442 | { |
1443 | Int_t absID = 0 ; | |
fb371b83 | 1444 | Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(particle->Eta(),phi,absID); |
1445 | if(ok) | |
1446 | { | |
1447 | Int_t icol = -1, irow = -1, iRCU = -1; | |
1448 | Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU); | |
1449 | Int_t status = GetEMCALChannelStatus(nModule,icol,irow); | |
1450 | if(status > 0) ok = kFALSE; | |
1451 | } | |
1452 | return ok ; | |
1453 | } | |
1454 | ||
1455 | return kFALSE ; | |
1456 | } | |
1457 | ||
9dcf63c2 | 1458 | //_____________________________________________________________________________________________________ |
1459 | Bool_t AliCalorimeterUtils::IsMCParticleInCalorimeterAcceptance(Int_t calo, Float_t eta, Float_t theta, | |
1460 | Float_t phiOrg, Int_t & absID) | |
fb371b83 | 1461 | { |
1462 | // Check that a TLorentzVector is in the calorimeter acceptance, give the cell number where it hit | |
1463 | ||
9dcf63c2 | 1464 | if(calo!=kEMCAL && calo!=kPHOS) return kFALSE ; |
fb371b83 | 1465 | |
9dcf63c2 | 1466 | if( (!IsPHOSGeoMatrixSet () && calo == kPHOS ) || |
1467 | (!IsEMCALGeoMatrixSet() && calo == kEMCAL) ) | |
fb371b83 | 1468 | { |
9dcf63c2 | 1469 | AliFatal(Form("Careful Geo Matrix for calo <%d> is not set, use AliFidutialCut instead \n",calo)); |
fb371b83 | 1470 | return kFALSE ; |
1471 | } | |
1472 | ||
9dcf63c2 | 1473 | Float_t phi = phiOrg; |
fb371b83 | 1474 | if(phi < 0) phi+=TMath::TwoPi(); |
1475 | ||
9dcf63c2 | 1476 | if(calo == kPHOS ) |
fb371b83 | 1477 | { |
1478 | Int_t mod = 0 ; | |
1479 | Double_t x = 0, z = 0 ; | |
1480 | Double_t vtx[]={0,0,0} ; | |
9dcf63c2 | 1481 | return GetPHOSGeometry()->ImpactOnEmc(vtx, theta, phi, mod, z, x) ; |
fb371b83 | 1482 | } |
9dcf63c2 | 1483 | else if(calo == kEMCAL) |
fb371b83 | 1484 | { |
9dcf63c2 | 1485 | Bool_t ok = GetEMCALGeometry()->GetAbsCellIdFromEtaPhi(eta,phi,absID); |
fb371b83 | 1486 | if(ok) |
1487 | { | |
1488 | Int_t icol = -1, irow = -1, iRCU = -1; | |
1489 | Int_t nModule = GetModuleNumberCellIndexes(absID,calo, icol, irow, iRCU); | |
1490 | Int_t status = GetEMCALChannelStatus(nModule,icol,irow); | |
1491 | if(status > 0) ok = kFALSE; | |
1492 | } | |
1493 | return ok ; | |
4eb65103 | 1494 | } |
1495 | ||
1496 | return kFALSE ; | |
1497 | } | |
1498 | ||
8a2dbbff | 1499 | //_______________________________________________________________________ |
1500 | Bool_t AliCalorimeterUtils::MaskFrameCluster(Int_t iSM, Int_t ieta) const | |
55d66f31 | 1501 | { |
1502 | //Check if cell is in one of the regions where we have significant amount | |
1503 | //of material in front. Only EMCAL | |
1504 | ||
1505 | Int_t icol = ieta; | |
1506 | if(iSM%2) icol+=48; // Impair SM, shift index [0-47] to [48-96] | |
1507 | ||
1508 | if (fNMaskCellColumns && fMaskCellColumns) | |
1509 | { | |
1510 | for (Int_t imask = 0; imask < fNMaskCellColumns; imask++) | |
1511 | { | |
1512 | if(icol==fMaskCellColumns[imask]) return kTRUE; | |
1513 | } | |
1514 | } | |
1515 | ||
1516 | return kFALSE; | |
1517 | ||
1518 | } | |
1519 | ||
cb5780f4 | 1520 | //_________________________________________________________ |
765d44e7 | 1521 | void AliCalorimeterUtils::Print(const Option_t * opt) const |
1522 | { | |
7cc7d3f8 | 1523 | |
765d44e7 | 1524 | //Print some relevant parameters set for the analysis |
1525 | if(! opt) | |
1526 | return; | |
7cc7d3f8 | 1527 | |
765d44e7 | 1528 | printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ; |
1529 | printf("Remove Clusters with bad channels? %d\n",fRemoveBadChannels); | |
1530 | printf("Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n", | |
7cc7d3f8 | 1531 | fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(), fNCellsFromPHOSBorder); |
247abff4 | 1532 | if(fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) printf("Do not remove EMCAL clusters at Eta = 0\n"); |
7bf608c9 | 1533 | printf("Recalibrate Clusters? %d, run by run %d\n",fRecalibration,fRunDependentCorrection); |
9584c261 | 1534 | printf("Recalculate Clusters Position? %d\n",fRecalculatePosition); |
1535 | printf("Recalculate Clusters Energy? %d\n",fCorrectELinearity); | |
f2ccb5b8 | 1536 | printf("Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",fCutR,fCutZ); |
7cc7d3f8 | 1537 | |
7db7dcb6 | 1538 | printf("Loc. Max. E > %2.2f\n", fLocMaxCutE); |
1539 | printf("Loc. Max. E Diff > %2.2f\n", fLocMaxCutEDiff); | |
1540 | ||
765d44e7 | 1541 | printf(" \n") ; |
1542 | } | |
1543 | ||
8a2dbbff | 1544 | //_____________________________________________________________________________________________ |
9dcf63c2 | 1545 | void AliCalorimeterUtils::RecalibrateCellAmplitude(Float_t & amp, Int_t calo, Int_t id) const |
7db7dcb6 | 1546 | { |
1547 | //Recaculate cell energy if recalibration factor | |
1548 | ||
1549 | Int_t icol = -1; Int_t irow = -1; Int_t iRCU = -1; | |
1550 | Int_t nModule = GetModuleNumberCellIndexes(id,calo, icol, irow, iRCU); | |
1551 | ||
1552 | if (IsRecalibrationOn()) | |
1553 | { | |
9dcf63c2 | 1554 | if(calo == kPHOS) |
7db7dcb6 | 1555 | { |
1556 | amp *= GetPHOSChannelRecalibrationFactor(nModule,icol,irow); | |
1557 | } | |
1558 | else | |
1559 | { | |
1560 | amp *= GetEMCALChannelRecalibrationFactor(nModule,icol,irow); | |
1561 | } | |
1562 | } | |
1563 | } | |
1564 | ||
8a2dbbff | 1565 | //____________________________________________________________________________________________________ |
9dcf63c2 | 1566 | void AliCalorimeterUtils::RecalibrateCellTime(Double_t & time, Int_t calo, Int_t id, Int_t bc) const |
7db7dcb6 | 1567 | { |
1568 | // Recalculate time if time recalibration available for EMCAL | |
1569 | // not ready for PHOS | |
1570 | ||
9dcf63c2 | 1571 | if(calo == kEMCAL && GetEMCALRecoUtils()->IsTimeRecalibrationOn()) |
7db7dcb6 | 1572 | { |
1573 | GetEMCALRecoUtils()->RecalibrateCellTime(id,bc,time); | |
1574 | } | |
1575 | ||
1576 | } | |
1577 | ||
cb5780f4 | 1578 | //__________________________________________________________________________ |
1579 | Float_t AliCalorimeterUtils::RecalibrateClusterEnergy(AliVCluster * cluster, | |
1580 | AliVCaloCells * cells) | |
1581 | { | |
09e819c9 | 1582 | // Recalibrate the cluster energy, considering the recalibration map and the energy of the cells that compose the cluster. |
7cc7d3f8 | 1583 | |
898c9d44 | 1584 | //Initialize some used variables |
7db7dcb6 | 1585 | Float_t frac = 0., energy = 0.; |
898c9d44 | 1586 | |
7db7dcb6 | 1587 | if(cells) |
1588 | { | |
7cc7d3f8 | 1589 | //Get the cluster number of cells and list of absId, check what kind of cluster do we have. |
7db7dcb6 | 1590 | |
7cc7d3f8 | 1591 | UShort_t * index = cluster->GetCellsAbsId() ; |
1592 | Double_t * fraction = cluster->GetCellsAmplitudeFraction() ; | |
7db7dcb6 | 1593 | |
7cc7d3f8 | 1594 | Int_t ncells = cluster->GetNCells(); |
7db7dcb6 | 1595 | |
9dcf63c2 | 1596 | Int_t calo = kEMCAL; |
1597 | if(cluster->IsPHOS()) calo = kPHOS ; | |
7cc7d3f8 | 1598 | |
1599 | //Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy | |
1600 | for(Int_t icell = 0; icell < ncells; icell++){ | |
7db7dcb6 | 1601 | |
1602 | Int_t absId = index[icell]; | |
1603 | ||
7cc7d3f8 | 1604 | frac = fraction[icell]; |
1605 | if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used. | |
7db7dcb6 | 1606 | |
1607 | Float_t amp = cells->GetCellAmplitude(absId); | |
1608 | RecalibrateCellAmplitude(amp,calo, absId); | |
1609 | ||
7cc7d3f8 | 1610 | if(fDebug>2) |
9dcf63c2 | 1611 | printf("AliCalorimeterUtils::RecalibrateClusterEnergy() - recalibrate cell: calo <%d>, cell fraction %f, cell energy %f\n", |
1612 | calo,frac,cells->GetCellAmplitude(absId)); | |
7cc7d3f8 | 1613 | |
7db7dcb6 | 1614 | energy += amp*frac; |
7cc7d3f8 | 1615 | } |
1616 | ||
1617 | if(fDebug>1) | |
1618 | printf("AliCalorimeterUtils::RecalibrateClusterEnergy() - Energy before %f, after %f\n",cluster->E(),energy); | |
898c9d44 | 1619 | |
1620 | }// cells available | |
7db7dcb6 | 1621 | else |
1622 | { | |
898c9d44 | 1623 | Fatal("RecalibrateClusterEnergy()","Cells pointer does not exist!"); |
1624 | } | |
1625 | ||
09e819c9 | 1626 | return energy; |
09e819c9 | 1627 | } |
1628 | ||
e1d24b6a | 1629 | //__________________________________________________________________________ |
1630 | Float_t AliCalorimeterUtils::RecalibrateClusterEnergyWeightCell(AliVCluster * cluster, | |
1631 | AliVCaloCells * cells, Float_t energyOrg) | |
1632 | { | |
1633 | // Recalibrate the cluster energy, considering the recalibration map and the energy of the cells that compose the cluster. | |
1634 | // Also consider reweighting of cells energy | |
1635 | ||
1636 | //Initialize some used variables | |
1637 | Float_t frac = 0., energy = 0.; | |
1638 | ||
1639 | if(cells) | |
1640 | { | |
1641 | //Get the cluster number of cells and list of absId, check what kind of cluster do we have. | |
1642 | ||
1643 | UShort_t * index = cluster->GetCellsAbsId() ; | |
1644 | Double_t * fraction = cluster->GetCellsAmplitudeFraction() ; | |
1645 | ||
1646 | Int_t ncells = cluster->GetNCells(); | |
1647 | ||
9dcf63c2 | 1648 | Int_t calo = kEMCAL; |
1649 | if(cluster->IsPHOS()) calo = kPHOS ; | |
e1d24b6a | 1650 | |
1651 | //Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy | |
1652 | for(Int_t icell = 0; icell < ncells; icell++){ | |
1653 | ||
1654 | Int_t absId = index[icell]; | |
1655 | ||
1656 | frac = fraction[icell]; | |
1657 | if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used. | |
1658 | ||
1659 | Float_t amp = cells->GetCellAmplitude(absId); | |
1660 | RecalibrateCellAmplitude(amp,calo, absId); | |
1661 | ||
1662 | amp*=GetMCECellClusFracCorrection(amp,energyOrg); | |
1663 | ||
1664 | if(fDebug>2) | |
9dcf63c2 | 1665 | printf("AliCalorimeterUtils::RecalibrateClusterEnergy() - recalibrate cell: calo <%d>, cell fraction %f, cell energy %f\n", |
1666 | calo,frac,cells->GetCellAmplitude(absId)); | |
e1d24b6a | 1667 | |
1668 | energy += amp*frac; | |
1669 | } | |
1670 | ||
1671 | if(fDebug>1) | |
1672 | printf("AliCalorimeterUtils::RecalibrateClusterEnergy() - Energy before %f, after %f\n",cluster->E(),energy); | |
1673 | ||
1674 | }// cells available | |
1675 | else | |
1676 | { | |
1677 | Fatal("RecalibrateClusterEnergy()","Cells pointer does not exist!"); | |
1678 | } | |
1679 | ||
1680 | return energy; | |
1681 | } | |
1682 | ||
1683 | ||
cb5780f4 | 1684 | //__________________________________________________________________________________________ |
1685 | void AliCalorimeterUtils::RecalculateClusterPosition(AliVCaloCells* cells, AliVCluster* clu) | |
1686 | { | |
9584c261 | 1687 | |
1688 | //Recalculate EMCAL cluster position | |
1689 | ||
19db8f8c | 1690 | fEMCALRecoUtils->RecalculateClusterPosition((AliEMCALGeometry*)fEMCALGeo, cells,clu); |
7cc7d3f8 | 1691 | |
9584c261 | 1692 | } |
cb5780f4 | 1693 | |
55d66f31 | 1694 | //________________________________________________________________________________ |
1695 | void AliCalorimeterUtils::RecalculateClusterTrackMatching(AliVEvent * event, | |
1696 | TObjArray* clusterArray) | |
1697 | { | |
1698 | //Recalculate track matching | |
1699 | ||
1700 | if (fRecalculateMatching) | |
1701 | { | |
1702 | fEMCALRecoUtils->FindMatches(event,clusterArray,fEMCALGeo) ; | |
1703 | //AliESDEvent* esdevent = dynamic_cast<AliESDEvent*> (event); | |
1704 | //if(esdevent){ | |
1705 | // fEMCALRecoUtils->SetClusterMatchedToTrack(esdevent) ; | |
1706 | // fEMCALRecoUtils->SetTracksMatchedToCluster(esdevent) ; | |
1707 | //} | |
1708 | } | |
1709 | } | |
1710 | ||
3c1d9afb | 1711 | //___________________________________________________________________________ |
8a2dbbff | 1712 | void AliCalorimeterUtils::SplitEnergy(Int_t absId1, Int_t absId2, |
1713 | AliVCluster* cluster, | |
3c1d9afb | 1714 | AliVCaloCells* cells, |
1715 | //Float_t & e1, Float_t & e2, | |
1716 | AliAODCaloCluster* cluster1, | |
1717 | AliAODCaloCluster* cluster2, | |
8a2dbbff | 1718 | Int_t nMax, Int_t eventNumber) |
3c1d9afb | 1719 | { |
1720 | ||
1721 | // Split energy of cluster between the 2 local maxima, sum energy on 3x3, and if the 2 | |
1722 | // maxima are too close and have common cells, split the energy between the 2 | |
1723 | ||
1724 | TH2F* hClusterMap = 0 ; | |
1725 | TH2F* hClusterLocMax = 0 ; | |
1726 | TH2F* hCluster1 = 0 ; | |
1727 | TH2F* hCluster2 = 0 ; | |
1728 | ||
1729 | if(fPlotCluster) | |
1730 | { | |
1731 | hClusterMap = new TH2F("hClusterMap","Cluster Map",48,0,48,24,0,24); | |
1732 | hClusterLocMax = new TH2F("hClusterLocMax","Cluster 2 highest local maxima",48,0,48,24,0,24); | |
1733 | hCluster1 = new TH2F("hCluster1","Cluster 1",48,0,48,24,0,24); | |
1734 | hCluster2 = new TH2F("hCluster2","Cluster 2",48,0,48,24,0,24); | |
1735 | hClusterMap ->SetXTitle("column"); | |
1736 | hClusterMap ->SetYTitle("row"); | |
1737 | hClusterLocMax ->SetXTitle("column"); | |
1738 | hClusterLocMax ->SetYTitle("row"); | |
1739 | hCluster1 ->SetXTitle("column"); | |
1740 | hCluster1 ->SetYTitle("row"); | |
1741 | hCluster2 ->SetXTitle("column"); | |
1742 | hCluster2 ->SetYTitle("row"); | |
1743 | } | |
1744 | ||
9dcf63c2 | 1745 | Int_t calorimeter = kEMCAL; |
3c1d9afb | 1746 | if(cluster->IsPHOS()) |
1747 | { | |
9dcf63c2 | 1748 | calorimeter=kPHOS; |
3c1d9afb | 1749 | printf("AliCalorimeterUtils::SplitEnerg() Not supported for PHOS yet \n"); |
1750 | return; | |
1751 | } | |
1752 | ||
1753 | const Int_t ncells = cluster->GetNCells(); | |
1754 | Int_t absIdList[ncells]; | |
1755 | ||
1756 | Float_t e1 = 0, e2 = 0 ; | |
1757 | Int_t icol = -1, irow = -1, iRCU = -1, sm = -1; | |
1758 | Float_t eCluster = 0; | |
1759 | Float_t minCol = 100, minRow = 100, maxCol = -1, maxRow = -1; | |
1760 | for(Int_t iDigit = 0; iDigit < ncells; iDigit++ ) | |
1761 | { | |
1762 | absIdList[iDigit] = cluster->GetCellsAbsId()[iDigit]; | |
1763 | ||
1764 | Float_t ec = cells->GetCellAmplitude(absIdList[iDigit]); | |
1765 | RecalibrateCellAmplitude(ec,calorimeter, absIdList[iDigit]); | |
1766 | eCluster+=ec; | |
1767 | ||
1768 | if(fPlotCluster) | |
1769 | { | |
1770 | //printf("iDigit %d, absId %d, Ecell %f\n",iDigit,absIdList[iDigit], cells->GetCellAmplitude(absIdList[iDigit])); | |
1771 | sm = GetModuleNumberCellIndexes(absIdList[iDigit], calorimeter, icol, irow, iRCU) ; | |
8a871c4f | 1772 | if(sm > -1 && sm < 12) // just to avoid compilation warning |
1773 | { | |
1774 | if(icol > maxCol) maxCol = icol; | |
1775 | if(icol < minCol) minCol = icol; | |
1776 | if(irow > maxRow) maxRow = irow; | |
1777 | if(irow < minRow) minRow = irow; | |
1778 | hClusterMap->Fill(icol,irow,ec); | |
1779 | } | |
3c1d9afb | 1780 | } |
1781 | ||
1782 | } | |
1783 | ||
1784 | // Init counters and variables | |
1785 | Int_t ncells1 = 1 ; | |
1786 | UShort_t absIdList1[9] ; | |
1787 | Double_t fracList1 [9] ; | |
1788 | absIdList1[0] = absId1 ; | |
1789 | fracList1 [0] = 1. ; | |
1790 | ||
1791 | Float_t ecell1 = cells->GetCellAmplitude(absId1); | |
1792 | RecalibrateCellAmplitude(ecell1, calorimeter, absId1); | |
1793 | e1 = ecell1; | |
1794 | ||
1795 | Int_t ncells2 = 1 ; | |
1796 | UShort_t absIdList2[9] ; | |
1797 | Double_t fracList2 [9] ; | |
1798 | absIdList2[0] = absId2 ; | |
1799 | fracList2 [0] = 1. ; | |
1800 | ||
1801 | Float_t ecell2 = cells->GetCellAmplitude(absId2); | |
1802 | RecalibrateCellAmplitude(ecell2, calorimeter, absId2); | |
1803 | e2 = ecell2; | |
1804 | ||
1805 | if(fPlotCluster) | |
1806 | { | |
1807 | Int_t icol1 = -1, irow1 = -1, icol2 = -1, irow2 = -1; | |
1808 | sm = GetModuleNumberCellIndexes(absId1, calorimeter, icol1, irow1, iRCU) ; | |
1809 | hClusterLocMax->Fill(icol1,irow1,ecell1); | |
1810 | sm = GetModuleNumberCellIndexes(absId2, calorimeter, icol2, irow2, iRCU) ; | |
1811 | hClusterLocMax->Fill(icol2,irow2,ecell2); | |
1812 | } | |
1813 | ||
1814 | // Very rough way to share the cluster energy | |
1815 | Float_t eRemain = (eCluster-ecell1-ecell2)/2; | |
1816 | Float_t shareFraction1 = ecell1/eCluster+eRemain/eCluster; | |
1817 | Float_t shareFraction2 = ecell2/eCluster+eRemain/eCluster; | |
1818 | ||
1819 | for(Int_t iDigit = 0; iDigit < ncells; iDigit++) | |
1820 | { | |
1821 | Int_t absId = absIdList[iDigit]; | |
1822 | ||
1823 | if(absId==absId1 || absId==absId2 || absId < 0) continue; | |
1824 | ||
1825 | Float_t ecell = cells->GetCellAmplitude(absId); | |
1826 | RecalibrateCellAmplitude(ecell, calorimeter, absId); | |
1827 | ||
1828 | if(AreNeighbours(calorimeter, absId1,absId )) | |
1829 | { | |
1830 | absIdList1[ncells1]= absId; | |
1831 | ||
1832 | if(AreNeighbours(calorimeter, absId2,absId )) | |
1833 | { | |
1834 | fracList1[ncells1] = shareFraction1; | |
1835 | e1 += ecell*shareFraction1; | |
1836 | } | |
1837 | else | |
1838 | { | |
1839 | fracList1[ncells1] = 1.; | |
1840 | e1 += ecell; | |
1841 | } | |
1842 | ||
1843 | ncells1++; | |
1844 | ||
1845 | } // neigbour to cell1 | |
1846 | ||
1847 | if(AreNeighbours(calorimeter, absId2,absId )) | |
1848 | { | |
1849 | absIdList2[ncells2]= absId; | |
1850 | ||
1851 | if(AreNeighbours(calorimeter, absId1,absId )) | |
1852 | { | |
1853 | fracList2[ncells2] = shareFraction2; | |
1854 | e2 += ecell*shareFraction2; | |
1855 | } | |
1856 | else | |
1857 | { | |
1858 | fracList2[ncells2] = 1.; | |
1859 | e2 += ecell; | |
1860 | } | |
1861 | ||
1862 | ncells2++; | |
1863 | ||
1864 | } // neigbour to cell2 | |
1865 | ||
1866 | } | |
1867 | ||
715d1872 | 1868 | if(GetDebug() > 1) printf("AliCalorimeterUtils::SplitEnergy() - n Local Max %d, Cluster energy = %f, Ecell1 = %f, Ecell2 = %f, Enew1 = %f, Enew2 = %f, Remain %f, \n ncells %d, ncells1 %d, ncells2 %d, f1 %f, f2 %f, sum f12 = %f \n", |
3c1d9afb | 1869 | nMax, eCluster,ecell1,ecell2,e1,e2,eCluster-e1-e2,ncells,ncells1,ncells2,shareFraction1,shareFraction2,shareFraction1+shareFraction2); |
1870 | ||
1871 | cluster1->SetE(e1); | |
1872 | cluster2->SetE(e2); | |
1873 | ||
1874 | cluster1->SetNCells(ncells1); | |
1875 | cluster2->SetNCells(ncells2); | |
1876 | ||
1877 | cluster1->SetCellsAbsId(absIdList1); | |
1878 | cluster2->SetCellsAbsId(absIdList2); | |
1879 | ||
1880 | cluster1->SetCellsAmplitudeFraction(fracList1); | |
1881 | cluster2->SetCellsAmplitudeFraction(fracList2); | |
1882 | ||
715d1872 | 1883 | //Correct linearity |
1884 | CorrectClusterEnergy(cluster1) ; | |
1885 | CorrectClusterEnergy(cluster2) ; | |
1886 | ||
9dcf63c2 | 1887 | if(calorimeter==kEMCAL) |
3c1d9afb | 1888 | { |
1889 | GetEMCALRecoUtils()->RecalculateClusterPosition(GetEMCALGeometry(), cells, cluster1); | |
1890 | GetEMCALRecoUtils()->RecalculateClusterPosition(GetEMCALGeometry(), cells, cluster2); | |
1891 | } | |
1892 | ||
1893 | if(fPlotCluster) | |
1894 | { | |
1895 | //printf("Cells of cluster1: "); | |
1896 | for(Int_t iDigit = 0; iDigit < ncells1; iDigit++ ) | |
1897 | { | |
1898 | //printf(" %d ",absIdList1[iDigit]); | |
1899 | ||
1900 | sm = GetModuleNumberCellIndexes(absIdList1[iDigit], calorimeter, icol, irow, iRCU) ; | |
1901 | ||
8cf5a81b | 1902 | Float_t ecell = cells->GetCellAmplitude(absIdList1[iDigit]); |
1903 | RecalibrateCellAmplitude(ecell, calorimeter, absIdList1[iDigit]); | |
1904 | ||
1905 | if( AreNeighbours(calorimeter, absId2,absIdList1[iDigit]) && absId1!=absIdList1[iDigit]) | |
1906 | hCluster1->Fill(icol,irow,ecell*shareFraction1); | |
3c1d9afb | 1907 | else |
8cf5a81b | 1908 | hCluster1->Fill(icol,irow,ecell); |
3c1d9afb | 1909 | } |
1910 | ||
1911 | //printf(" \n "); | |
1912 | //printf("Cells of cluster2: "); | |
1913 | ||
1914 | for(Int_t iDigit = 0; iDigit < ncells2; iDigit++ ) | |
1915 | { | |
1916 | //printf(" %d ",absIdList2[iDigit]); | |
1917 | ||
1918 | sm = GetModuleNumberCellIndexes(absIdList2[iDigit], calorimeter, icol, irow, iRCU) ; | |
8cf5a81b | 1919 | |
1920 | Float_t ecell = cells->GetCellAmplitude(absIdList2[iDigit]); | |
1921 | RecalibrateCellAmplitude(ecell, calorimeter, absIdList2[iDigit]); | |
1922 | ||
1923 | if( AreNeighbours(calorimeter, absId1,absIdList2[iDigit]) && absId2!=absIdList2[iDigit]) | |
1924 | hCluster2->Fill(icol,irow,ecell*shareFraction2); | |
3c1d9afb | 1925 | else |
8cf5a81b | 1926 | hCluster2->Fill(icol,irow,ecell); |
3c1d9afb | 1927 | |
1928 | } | |
1929 | //printf(" \n "); | |
1930 | ||
1931 | gStyle->SetPadRightMargin(0.1); | |
1932 | gStyle->SetPadLeftMargin(0.1); | |
1933 | gStyle->SetOptStat(0); | |
1934 | gStyle->SetOptFit(000000); | |
1935 | ||
1936 | if(maxCol-minCol > maxRow-minRow) | |
1937 | { | |
1938 | maxRow+= maxCol-minCol; | |
1939 | } | |
1940 | else | |
1941 | { | |
1942 | maxCol+= maxRow-minRow; | |
1943 | } | |
1944 | ||
1945 | TCanvas * c= new TCanvas("canvas", "canvas", 4000, 4000) ; | |
1946 | c->Divide(2,2); | |
1947 | c->cd(1); | |
1948 | gPad->SetGridy(); | |
1949 | gPad->SetGridx(); | |
8cf5a81b | 1950 | gPad->SetLogz(); |
3c1d9afb | 1951 | hClusterMap ->SetAxisRange(minCol, maxCol,"X"); |
1952 | hClusterMap ->SetAxisRange(minRow, maxRow,"Y"); | |
8cf5a81b | 1953 | hClusterMap ->Draw("colz TEXT"); |
3c1d9afb | 1954 | c->cd(2); |
1955 | gPad->SetGridy(); | |
1956 | gPad->SetGridx(); | |
8cf5a81b | 1957 | gPad->SetLogz(); |
3c1d9afb | 1958 | hClusterLocMax ->SetAxisRange(minCol, maxCol,"X"); |
1959 | hClusterLocMax ->SetAxisRange(minRow, maxRow,"Y"); | |
8cf5a81b | 1960 | hClusterLocMax ->Draw("colz TEXT"); |
3c1d9afb | 1961 | c->cd(3); |
1962 | gPad->SetGridy(); | |
1963 | gPad->SetGridx(); | |
8cf5a81b | 1964 | gPad->SetLogz(); |
3c1d9afb | 1965 | hCluster1 ->SetAxisRange(minCol, maxCol,"X"); |
1966 | hCluster1 ->SetAxisRange(minRow, maxRow,"Y"); | |
8cf5a81b | 1967 | hCluster1 ->Draw("colz TEXT"); |
3c1d9afb | 1968 | c->cd(4); |
1969 | gPad->SetGridy(); | |
1970 | gPad->SetGridx(); | |
8cf5a81b | 1971 | gPad->SetLogz(); |
3c1d9afb | 1972 | hCluster2 ->SetAxisRange(minCol, maxCol,"X"); |
1973 | hCluster2 ->SetAxisRange(minRow, maxRow,"Y"); | |
8cf5a81b | 1974 | hCluster2 ->Draw("colz TEXT"); |
3c1d9afb | 1975 | |
1976 | if(eCluster > 6 )c->Print(Form("clusterFigures/Event%d_E%1.0f_nMax%d_NCell1_%d_NCell2_%d.eps", | |
1977 | eventNumber,cluster->E(),nMax,ncells1,ncells2)); | |
1978 | ||
1979 | delete c; | |
1980 | delete hClusterMap; | |
1981 | delete hClusterLocMax; | |
1982 | delete hCluster1; | |
1983 | delete hCluster2; | |
1984 | } | |
1985 | } | |
1986 |