]>
Commit | Line | Data |
---|---|---|
6d67b5a7 | 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 | **************************************************************************/ | |
15 | ||
6d67b5a7 | 16 | /////////////////////////////////////////////////////////////////////////////// |
17 | // // | |
dd8e12d1 | 18 | // EMCAL tender, apply corrections to EMCAL clusters and do track matching. // |
19 | // // | |
766cc9de | 20 | // Author: Deepa Thomas (Utrecht University) // |
c05ffa77 | 21 | // Later mods/rewrite: Jiri Kral (University of Jyvaskyla) // |
dd8e12d1 | 22 | // S. Aiola, C. Loizides : Make it work for AODs // |
6d67b5a7 | 23 | // // |
24 | /////////////////////////////////////////////////////////////////////////////// | |
25 | ||
766cc9de | 26 | #include <TROOT.h> |
27 | #include <TFile.h> | |
28 | #include <TTree.h> | |
29 | #include <TInterpreter.h> | |
30 | #include <TObjArray.h> | |
31 | #include <TClonesArray.h> | |
32 | #include <TGeoGlobalMagField.h> | |
b20bc239 | 33 | #include "AliEMCALAfterBurnerUF.h" |
dd8e12d1 | 34 | #include "AliEMCALClusterizer.h" |
b20bc239 | 35 | #include "AliEMCALClusterizerNxN.h" |
36 | #include "AliEMCALClusterizerv1.h" | |
37 | #include "AliEMCALClusterizerv2.h" | |
38 | #include "AliEMCALDigit.h" | |
dd8e12d1 | 39 | #include "AliEMCALGeometry.h" |
40 | #include "AliEMCALRecParam.h" | |
4d3c549c | 41 | #include "AliEMCALRecParam.h" |
dd8e12d1 | 42 | #include "AliEMCALRecPoint.h" |
43 | #include "AliEMCALRecoUtils.h" | |
44 | #include "AliEMCALTenderSupply.h" | |
45 | #include "AliESDCaloCluster.h" | |
46 | #include "AliMagF.h" | |
47 | #include "AliOADBContainer.h" | |
48 | #include "AliAODEvent.h" | |
49 | #include "AliAnalysisManager.h" | |
50 | #include "AliESDEvent.h" | |
51 | #include "AliLog.h" | |
52 | #include "AliTender.h" | |
6d67b5a7 | 53 | |
3b7d451e | 54 | ClassImp(AliEMCALTenderSupply) |
55 | ||
6d67b5a7 | 56 | AliEMCALTenderSupply::AliEMCALTenderSupply() : |
6b7df55d | 57 | AliTenderSupply() |
dd8e12d1 | 58 | ,fTask(0) |
59 | ,fRun(0) | |
6b7df55d | 60 | ,fEMCALGeo(0x0) |
98e8eede | 61 | ,fEMCALGeoName("") |
6b7df55d | 62 | ,fEMCALRecoUtils(0) |
63 | ,fConfigName("") | |
64 | ,fDebugLevel(0) | |
50b7a951 | 65 | ,fNonLinearFunc(-1) |
66 | ,fNonLinearThreshold(-1) | |
67 | ,fReCalibCluster(kFALSE) | |
acf53135 | 68 | ,fUpdateCell(kFALSE) |
50b7a951 | 69 | ,fCalibrateEnergy(kFALSE) |
70 | ,fCalibrateTime(kFALSE) | |
71 | ,fDoNonLinearity(kFALSE) | |
72 | ,fBadCellRemove(kFALSE) | |
73 | ,fRejectExoticCells(kFALSE) | |
74 | ,fRejectExoticClusters(kFALSE) | |
75 | ,fClusterBadChannelCheck(kFALSE) | |
6b7df55d | 76 | ,fRecalClusPos(kFALSE) |
77 | ,fFiducial(kFALSE) | |
50b7a951 | 78 | ,fNCellsFromEMCALBorder(-1) |
79 | ,fRecalDistToBadChannels(kFALSE) | |
80 | ,fRecalShowerShape(kFALSE) | |
81 | ,fInputTree(0) | |
6b7df55d | 82 | ,fInputFile(0) |
f660c2d6 | 83 | ,fGetPassFromFileName(kTRUE) |
6b7df55d | 84 | ,fFilepass(0) |
50b7a951 | 85 | ,fMass(-1) |
86 | ,fStep(-1) | |
6b7df55d | 87 | ,fCutEtaPhiSum(kTRUE) |
88 | ,fCutEtaPhiSeparate(kFALSE) | |
50b7a951 | 89 | ,fRcut(-1) |
90 | ,fEtacut(-1) | |
91 | ,fPhicut(-1) | |
acf53135 | 92 | ,fBasePath("") |
6b7df55d | 93 | ,fReClusterize(kFALSE) |
94 | ,fClusterizer(0) | |
95 | ,fGeomMatrixSet(kFALSE) | |
96 | ,fLoadGeomMatrices(kFALSE) | |
acf53135 | 97 | ,fRecParam(0x0) |
50b7a951 | 98 | ,fDoTrackMatch(kFALSE) |
a0beb012 | 99 | ,fDoUpdateOnly(kFALSE) |
6b7df55d | 100 | ,fUnfolder(0) |
101 | ,fDigitsArr(0) | |
102 | ,fClusterArr(0) | |
50b7a951 | 103 | ,fMisalignSurvey(kdefault) |
104 | ,fExoticCellFraction(-1) | |
105 | ,fExoticCellDiffTime(-1) | |
106 | ,fExoticCellMinAmplitude(-1) | |
6e6de0c3 | 107 | ,fSetCellMCLabelFromCluster(kFALSE) |
6d67b5a7 | 108 | { |
766cc9de | 109 | // Default constructor. |
98e8eede | 110 | |
111 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ; | |
6d67b5a7 | 112 | } |
113 | ||
114 | //_____________________________________________________ | |
115 | AliEMCALTenderSupply::AliEMCALTenderSupply(const char *name, const AliTender *tender) : | |
6b7df55d | 116 | AliTenderSupply(name,tender) |
dd8e12d1 | 117 | ,fTask(0) |
118 | ,fRun(0) | |
119 | ,fEMCALGeo(0x0) | |
98e8eede | 120 | ,fEMCALGeoName("") |
dd8e12d1 | 121 | ,fEMCALRecoUtils(0) |
122 | ,fConfigName("") | |
123 | ,fDebugLevel(0) | |
124 | ,fNonLinearFunc(-1) | |
125 | ,fNonLinearThreshold(-1) | |
126 | ,fReCalibCluster(kFALSE) | |
127 | ,fUpdateCell(kFALSE) | |
128 | ,fCalibrateEnergy(kFALSE) | |
129 | ,fCalibrateTime(kFALSE) | |
130 | ,fDoNonLinearity(kFALSE) | |
131 | ,fBadCellRemove(kFALSE) | |
132 | ,fRejectExoticCells(kFALSE) | |
133 | ,fRejectExoticClusters(kFALSE) | |
134 | ,fClusterBadChannelCheck(kFALSE) | |
135 | ,fRecalClusPos(kFALSE) | |
136 | ,fFiducial(kFALSE) | |
137 | ,fNCellsFromEMCALBorder(-1) | |
138 | ,fRecalDistToBadChannels(kFALSE) | |
139 | ,fRecalShowerShape(kFALSE) | |
140 | ,fInputTree(0) | |
141 | ,fInputFile(0) | |
2b0653b9 | 142 | ,fGetPassFromFileName(kTRUE) |
143 | ,fFilepass("") | |
dd8e12d1 | 144 | ,fMass(-1) |
145 | ,fStep(-1) | |
146 | ,fCutEtaPhiSum(kTRUE) | |
147 | ,fCutEtaPhiSeparate(kFALSE) | |
148 | ,fRcut(-1) | |
149 | ,fEtacut(-1) | |
150 | ,fPhicut(-1) | |
151 | ,fBasePath("") | |
152 | ,fReClusterize(kFALSE) | |
153 | ,fClusterizer(0) | |
154 | ,fGeomMatrixSet(kFALSE) | |
155 | ,fLoadGeomMatrices(kFALSE) | |
156 | ,fRecParam(0x0) | |
157 | ,fDoTrackMatch(kFALSE) | |
158 | ,fDoUpdateOnly(kFALSE) | |
159 | ,fUnfolder(0) | |
160 | ,fDigitsArr(0) | |
161 | ,fClusterArr(0) | |
162 | ,fMisalignSurvey(kdefault) | |
163 | ,fExoticCellFraction(-1) | |
164 | ,fExoticCellDiffTime(-1) | |
165 | ,fExoticCellMinAmplitude(-1) | |
6e6de0c3 | 166 | ,fSetCellMCLabelFromCluster(kFALSE) |
dd8e12d1 | 167 | { |
168 | // Named constructor | |
169 | ||
98e8eede | 170 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ; |
dd8e12d1 | 171 | } |
172 | ||
173 | //_____________________________________________________ | |
174 | AliEMCALTenderSupply::AliEMCALTenderSupply(const char *name, AliAnalysisTaskSE *task) : | |
175 | AliTenderSupply(name) | |
176 | ,fTask(task) | |
177 | ,fRun(0) | |
6b7df55d | 178 | ,fEMCALGeo(0x0) |
98e8eede | 179 | ,fEMCALGeoName("") |
6b7df55d | 180 | ,fEMCALRecoUtils(0) |
50b7a951 | 181 | ,fConfigName("") |
6b7df55d | 182 | ,fDebugLevel(0) |
50b7a951 | 183 | ,fNonLinearFunc(-1) |
184 | ,fNonLinearThreshold(-1) | |
185 | ,fReCalibCluster(kFALSE) | |
acf53135 | 186 | ,fUpdateCell(kFALSE) |
50b7a951 | 187 | ,fCalibrateEnergy(kFALSE) |
188 | ,fCalibrateTime(kFALSE) | |
189 | ,fDoNonLinearity(kFALSE) | |
190 | ,fBadCellRemove(kFALSE) | |
191 | ,fRejectExoticCells(kFALSE) | |
192 | ,fRejectExoticClusters(kFALSE) | |
193 | ,fClusterBadChannelCheck(kFALSE) | |
6b7df55d | 194 | ,fRecalClusPos(kFALSE) |
195 | ,fFiducial(kFALSE) | |
50b7a951 | 196 | ,fNCellsFromEMCALBorder(-1) |
197 | ,fRecalDistToBadChannels(kFALSE) | |
198 | ,fRecalShowerShape(kFALSE) | |
199 | ,fInputTree(0) | |
6b7df55d | 200 | ,fInputFile(0) |
2b0653b9 | 201 | ,fGetPassFromFileName(kTRUE) |
202 | ,fFilepass("") | |
50b7a951 | 203 | ,fMass(-1) |
204 | ,fStep(-1) | |
6b7df55d | 205 | ,fCutEtaPhiSum(kTRUE) |
206 | ,fCutEtaPhiSeparate(kFALSE) | |
50b7a951 | 207 | ,fRcut(-1) |
208 | ,fEtacut(-1) | |
209 | ,fPhicut(-1) | |
acf53135 | 210 | ,fBasePath("") |
6b7df55d | 211 | ,fReClusterize(kFALSE) |
212 | ,fClusterizer(0) | |
213 | ,fGeomMatrixSet(kFALSE) | |
214 | ,fLoadGeomMatrices(kFALSE) | |
acf53135 | 215 | ,fRecParam(0x0) |
50b7a951 | 216 | ,fDoTrackMatch(kFALSE) |
a0beb012 | 217 | ,fDoUpdateOnly(kFALSE) |
6b7df55d | 218 | ,fUnfolder(0) |
219 | ,fDigitsArr(0) | |
220 | ,fClusterArr(0) | |
50b7a951 | 221 | ,fMisalignSurvey(kdefault) |
222 | ,fExoticCellFraction(-1) | |
223 | ,fExoticCellDiffTime(-1) | |
224 | ,fExoticCellMinAmplitude(-1) | |
6e6de0c3 | 225 | ,fSetCellMCLabelFromCluster(kFALSE) |
6d67b5a7 | 226 | { |
98e8eede | 227 | // Named constructor. |
6b7df55d | 228 | |
98e8eede | 229 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ; |
6d67b5a7 | 230 | } |
231 | ||
232 | //_____________________________________________________ | |
233 | AliEMCALTenderSupply::~AliEMCALTenderSupply() | |
234 | { | |
766cc9de | 235 | //Destructor |
6b7df55d | 236 | |
17e31bf2 | 237 | if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) |
238 | { | |
239 | delete fEMCALRecoUtils; | |
240 | delete fRecParam; | |
241 | delete fUnfolder; | |
242 | if (!fClusterizer) | |
243 | { | |
244 | fDigitsArr->Clear("C"); | |
245 | delete fDigitsArr; | |
246 | } else | |
247 | { | |
248 | delete fClusterizer; | |
249 | fDigitsArr = 0; | |
250 | } | |
766cc9de | 251 | } |
6d67b5a7 | 252 | } |
253 | ||
98e8eede | 254 | //_____________________________________________________ |
255 | void AliEMCALTenderSupply::SetDefaults() | |
256 | { | |
257 | // Set default settings. | |
258 | ||
259 | SwitchOnBadCellRemove(); | |
260 | SwitchOnExoticCellRemove(); | |
261 | SwitchOnCalibrateEnergy(); | |
262 | SwitchOnCalibrateTime(); | |
263 | SwitchOnUpdateCell(); | |
264 | SwitchOnReclustering(); | |
265 | SwitchOnClusterBadChannelCheck(); | |
266 | SwitchOnClusterExoticChannelCheck(); | |
267 | SwitchOnTrackMatch(); | |
268 | } | |
269 | ||
dd8e12d1 | 270 | //_____________________________________________________ |
271 | Bool_t AliEMCALTenderSupply::RunChanged() const | |
272 | { | |
98e8eede | 273 | // Get run number. |
274 | ||
dd8e12d1 | 275 | return (fTender && fTender->RunChanged()) || (fTask && fRun != fTask->InputEvent()->GetRunNumber()); |
276 | } | |
277 | ||
6d67b5a7 | 278 | //_____________________________________________________ |
279 | void AliEMCALTenderSupply::Init() | |
280 | { | |
766cc9de | 281 | // Initialise EMCAL tender. |
acf53135 | 282 | |
766cc9de | 283 | if (fDebugLevel>0) |
886d4ff1 | 284 | AliWarning("Init EMCAL Tender supply"); |
6b7df55d | 285 | |
a0beb012 | 286 | if (fConfigName.Length()>0 && gROOT->LoadMacro(fConfigName) >=0) { |
766cc9de | 287 | AliDebug(1, Form("Loading settings from macro %s", fConfigName.Data())); |
288 | AliEMCALTenderSupply *tender = (AliEMCALTenderSupply*)gInterpreter->ProcessLine("ConfigEMCALTenderSupply()"); | |
289 | fDebugLevel = tender->fDebugLevel; | |
290 | fEMCALGeoName = tender->fEMCALGeoName; | |
766cc9de | 291 | fEMCALRecoUtils = tender->fEMCALRecoUtils; |
292 | fConfigName = tender->fConfigName; | |
293 | fNonLinearFunc = tender->fNonLinearFunc; | |
294 | fNonLinearThreshold = tender->fNonLinearThreshold; | |
295 | fReCalibCluster = tender->fReCalibCluster; | |
50b7a951 | 296 | fUpdateCell = tender->fUpdateCell; |
766cc9de | 297 | fRecalClusPos = tender->fRecalClusPos; |
50b7a951 | 298 | fCalibrateEnergy = tender->fCalibrateEnergy; |
299 | fCalibrateTime = tender->fCalibrateTime; | |
300 | fFiducial = tender->fFiducial; | |
766cc9de | 301 | fNCellsFromEMCALBorder = tender->fNCellsFromEMCALBorder; |
302 | fRecalDistToBadChannels = tender->fRecalDistToBadChannels; | |
50b7a951 | 303 | fRecalShowerShape = tender->fRecalShowerShape; |
304 | fClusterBadChannelCheck = tender->fClusterBadChannelCheck; | |
305 | fBadCellRemove = tender->fBadCellRemove; | |
306 | fRejectExoticCells = tender->fRejectExoticCells; | |
307 | fRejectExoticClusters = tender->fRejectExoticClusters; | |
766cc9de | 308 | fMass = tender->fMass; |
309 | fStep = tender->fStep; | |
50b7a951 | 310 | fCutEtaPhiSum = tender->fCutEtaPhiSum; |
311 | fCutEtaPhiSeparate = tender->fCutEtaPhiSeparate; | |
766cc9de | 312 | fRcut = tender->fRcut; |
313 | fEtacut = tender->fEtacut; | |
314 | fPhicut = tender->fPhicut; | |
315 | fReClusterize = tender->fReClusterize; | |
316 | fLoadGeomMatrices = tender->fLoadGeomMatrices; | |
317 | fRecParam = tender->fRecParam; | |
50b7a951 | 318 | fDoNonLinearity = tender->fDoNonLinearity; |
319 | fDoTrackMatch = tender->fDoTrackMatch; | |
320 | fDoUpdateOnly = tender->fDoUpdateOnly; | |
321 | fMisalignSurvey = tender->fMisalignSurvey; | |
322 | fExoticCellFraction = tender->fExoticCellFraction; | |
323 | fExoticCellDiffTime = tender->fExoticCellDiffTime; | |
324 | fExoticCellMinAmplitude = tender->fExoticCellMinAmplitude; | |
325 | ||
98e8eede | 326 | for(Int_t i = 0; i < 12; i++) |
766cc9de | 327 | fEMCALMatrix[i] = tender->fEMCALMatrix[i] ; |
328 | } | |
886d4ff1 | 329 | |
330 | if (fDebugLevel>0){ | |
331 | AliInfo( "Emcal Tender settings: ======================================" ); | |
332 | AliInfo( "------------ Switches --------------------------" ); | |
333 | AliInfo( Form( "BadCellRemove : %d", fBadCellRemove )); | |
334 | AliInfo( Form( "ExoticCellRemove : %d", fRejectExoticCells )); | |
335 | AliInfo( Form( "CalibrateEnergy : %d", fCalibrateEnergy )); | |
336 | AliInfo( Form( "CalibrateTime : %d", fCalibrateTime )); | |
337 | AliInfo( Form( "UpdateCell : %d", fUpdateCell )); | |
338 | AliInfo( Form( "DoUpdateOnly : %d", fDoUpdateOnly )); | |
339 | AliInfo( Form( "Reclustering : %d", fReClusterize )); | |
340 | AliInfo( Form( "ClusterBadChannelCheck : %d", fClusterBadChannelCheck )); | |
341 | AliInfo( Form( "ClusterExoticChannelCheck : %d", fRejectExoticClusters )); | |
342 | AliInfo( Form( "CellFiducialRegion : %d", fFiducial )); | |
343 | AliInfo( Form( "ReCalibrateCluster : %d", fReCalibCluster )); | |
344 | AliInfo( Form( "RecalculateClusPos : %d", fRecalClusPos )); | |
345 | AliInfo( Form( "RecalShowerShape : %d", fRecalShowerShape )); | |
346 | AliInfo( Form( "NonLinearityCorrection : %d", fDoNonLinearity )); | |
347 | AliInfo( Form( "RecalDistBadChannel : %d", fRecalDistToBadChannels )); | |
348 | AliInfo( Form( "TrackMatch : %d", fDoTrackMatch )); | |
349 | AliInfo( "------------ Variables -------------------------" ); | |
350 | AliInfo( Form( "DebugLevel : %d", fDebugLevel )); | |
351 | AliInfo( Form( "BasePath : %s", fBasePath.Data() )); | |
352 | AliInfo( Form( "ConfigFileName : %s", fConfigName.Data() )); | |
353 | AliInfo( Form( "EMCALGeometryName : %s", fEMCALGeoName.Data() )); | |
354 | AliInfo( Form( "NonLinearityFunction : %d", fNonLinearFunc )); | |
355 | AliInfo( Form( "NonLinearityThreshold : %d", fNonLinearThreshold )); | |
356 | AliInfo( Form( "MisalignmentMatrixSurvey : %d", fMisalignSurvey )); | |
357 | AliInfo( Form( "NumberOfCellsFromEMCALBorder : %d", fNCellsFromEMCALBorder )); | |
358 | AliInfo( Form( "RCut : %f", fRcut )); | |
359 | AliInfo( Form( "Mass : %f", fMass )); | |
360 | AliInfo( Form( "Step : %f", fStep )); | |
361 | AliInfo( Form( "EtaCut : %f", fEtacut )); | |
362 | AliInfo( Form( "PhiCut : %f", fPhicut )); | |
363 | AliInfo( Form( "ExoticCellFraction : %f", fExoticCellFraction )); | |
364 | AliInfo( Form( "ExoticCellDiffTime : %f", fExoticCellDiffTime )); | |
365 | AliInfo( Form( "ExoticCellMinAmplitude : %f", fExoticCellMinAmplitude )); | |
366 | AliInfo( "=============================================================" ); | |
367 | } | |
a0beb012 | 368 | |
98e8eede | 369 | // init reco utils |
5b6de4be | 370 | |
371 | if(!fEMCALRecoUtils) | |
372 | fEMCALRecoUtils = new AliEMCALRecoUtils; | |
98e8eede | 373 | |
374 | // init geometry if requested | |
375 | if (fEMCALGeoName.Length()>0) | |
376 | fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ; | |
886d4ff1 | 377 | |
378 | // digits array | |
379 | fDigitsArr = new TClonesArray("AliEMCALDigit",1000); | |
380 | ||
98e8eede | 381 | // initialising non-linearity parameters |
50b7a951 | 382 | if( fNonLinearThreshold != -1 ) |
383 | fEMCALRecoUtils->SetNonLinearityThreshold(fNonLinearThreshold); | |
384 | if( fNonLinearFunc != -1 ) | |
385 | fEMCALRecoUtils->SetNonLinearityFunction(fNonLinearFunc); | |
386 | ||
387 | // missalignment function | |
388 | fEMCALRecoUtils->SetPositionAlgorithm(AliEMCALRecoUtils::kPosTowerGlobal); | |
389 | ||
390 | // fiducial cut | |
391 | // do not do the eta0 fiducial cut | |
392 | if( fNCellsFromEMCALBorder != -1 ) | |
393 | fEMCALRecoUtils->SetNumberOfCellsFromEMCALBorder(fNCellsFromEMCALBorder); | |
394 | fEMCALRecoUtils->SwitchOnNoFiducialBorderInEMCALEta0(); | |
395 | ||
396 | // exotic cell rejection | |
397 | if( fExoticCellFraction != -1 ) | |
398 | fEMCALRecoUtils->SetExoticCellFractionCut( fExoticCellFraction ); | |
399 | if( fExoticCellDiffTime != -1 ) | |
400 | fEMCALRecoUtils->SetExoticCellDiffTimeCut( fExoticCellDiffTime ); | |
401 | if( fExoticCellMinAmplitude != -1 ) | |
402 | fEMCALRecoUtils->SetExoticCellMinAmplitudeCut( fExoticCellMinAmplitude ); | |
403 | ||
98e8eede | 404 | // setting track matching parameters ... mass, step size and residual cut |
50b7a951 | 405 | if( fMass != -1 ) |
406 | fEMCALRecoUtils->SetMass(fMass); | |
407 | if( fStep != -1 ) | |
408 | fEMCALRecoUtils->SetStep(fStep); | |
6b7df55d | 409 | |
50b7a951 | 410 | // spatial cut based on separate eta/phi or common processing |
766cc9de | 411 | if(fCutEtaPhiSum){ |
412 | fEMCALRecoUtils->SwitchOnCutEtaPhiSum(); | |
50b7a951 | 413 | if( fRcut != -1 ) |
414 | fEMCALRecoUtils->SetCutR(fRcut); | |
766cc9de | 415 | } else if (fCutEtaPhiSeparate) { |
416 | fEMCALRecoUtils->SwitchOnCutEtaPhiSeparate(); | |
50b7a951 | 417 | if( fEtacut != -1 ) |
418 | fEMCALRecoUtils->SetCutEta(fEtacut); | |
419 | if( fPhicut != -1 ) | |
420 | fEMCALRecoUtils->SetCutPhi(fPhicut); | |
766cc9de | 421 | } |
6d67b5a7 | 422 | } |
423 | ||
dd8e12d1 | 424 | //_____________________________________________________ |
425 | AliVEvent* AliEMCALTenderSupply::GetEvent() | |
426 | { | |
98e8eede | 427 | // Return the event pointer. |
dd8e12d1 | 428 | |
429 | if (fTender) { | |
430 | return fTender->GetEvent(); | |
431 | } | |
432 | else if (fTask) { | |
433 | return fTask->InputEvent(); | |
434 | } | |
435 | ||
436 | return 0; | |
dd8e12d1 | 437 | } |
438 | ||
6d67b5a7 | 439 | //_____________________________________________________ |
440 | void AliEMCALTenderSupply::ProcessEvent() | |
441 | { | |
766cc9de | 442 | // Event loop. |
b524daab | 443 | |
dd8e12d1 | 444 | AliVEvent *event = GetEvent(); |
6b7df55d | 445 | |
766cc9de | 446 | if (!event) { |
dd8e12d1 | 447 | AliError("Event ptr = 0, returning"); |
766cc9de | 448 | return; |
449 | } | |
8b775c10 | 450 | |
b524daab | 451 | // Initialising parameters once per run number |
dd8e12d1 | 452 | if (RunChanged()) { |
453 | ||
98e8eede | 454 | AliWarning( "Run changed, initializing parameters" ); |
dd8e12d1 | 455 | fRun = event->GetRunNumber(); |
456 | ||
98e8eede | 457 | // init geometry if not already done |
458 | if (fEMCALGeoName.Length()==0) { | |
459 | fEMCALGeoName = "EMCAL_FIRSTYEARV1"; | |
460 | if (fRun>139517) { | |
461 | fEMCALGeoName = "EMCAL_COMPLETEV1"; | |
462 | } | |
463 | if (fRun>170593) { | |
464 | fEMCALGeoName = "EMCAL_COMPLETE12SMV1"; | |
465 | } | |
466 | fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName); | |
467 | if (!fEMCALGeo) { | |
468 | AliFatal(Form("Can not create geometry: %s", fEMCALGeoName.Data())); | |
469 | return; | |
470 | } | |
471 | } | |
a0beb012 | 472 | |
50b7a951 | 473 | // get pass |
2b0653b9 | 474 | if (fGetPassFromFileName) |
475 | GetPass(); | |
a0beb012 | 476 | |
50b7a951 | 477 | // define what recalib parameters are needed for various switches |
478 | // this is based on implementation in AliEMCALRecoUtils | |
c05ffa77 | 479 | Bool_t needRecoParam = fReClusterize; |
50b7a951 | 480 | Bool_t needBadChannels = fBadCellRemove | fClusterBadChannelCheck | fRecalDistToBadChannels | fReClusterize; |
481 | Bool_t needRecalib = fCalibrateEnergy | fReClusterize; | |
482 | Bool_t needTimecalib = fCalibrateTime | fReClusterize; | |
483 | Bool_t needMisalign = fRecalClusPos | fReClusterize; | |
484 | Bool_t needClusterizer = fReClusterize; | |
a0beb012 | 485 | |
dd8e12d1 | 486 | // initiate reco params with some defaults |
487 | // will not overwrite, if those have been provided by user | |
c05ffa77 | 488 | if( needRecoParam ){ |
489 | Int_t initRC = InitRecParam(); | |
490 | ||
491 | if( initRC == 0 ) | |
dd8e12d1 | 492 | AliInfo("Defaults reco params loaded."); |
c05ffa77 | 493 | if( initRC > 1 ) |
dd8e12d1 | 494 | AliWarning("User defined reco params."); |
c05ffa77 | 495 | } |
496 | ||
dd8e12d1 | 497 | // init bad channels |
c05ffa77 | 498 | if( needBadChannels ){ |
50b7a951 | 499 | Int_t fInitBC = InitBadChannels(); |
500 | if (fInitBC==0) | |
50b7a951 | 501 | AliError("InitBadChannels returned false, returning"); |
50b7a951 | 502 | if (fInitBC==1) |
886d4ff1 | 503 | AliWarning("InitBadChannels OK"); |
50b7a951 | 504 | if (fInitBC>1) |
886d4ff1 | 505 | AliWarning(Form("No external hot channel set: %d - %s", event->GetRunNumber(), fFilepass.Data())); |
8b775c10 | 506 | } |
a0beb012 | 507 | |
50b7a951 | 508 | // init recalibration factors |
7bf608c9 | 509 | if( needRecalib ) |
510 | { | |
a0beb012 | 511 | Int_t fInitRecalib = InitRecalib(); |
acf53135 | 512 | if (fInitRecalib==0) |
8b775c10 | 513 | AliError("InitRecalib returned false, returning"); |
50b7a951 | 514 | if (fInitRecalib==1) |
886d4ff1 | 515 | AliWarning("InitRecalib OK"); |
a0beb012 | 516 | if (fInitRecalib>1) |
886d4ff1 | 517 | AliWarning(Form("No recalibration available: %d - %s", event->GetRunNumber(), fFilepass.Data())); |
7bf608c9 | 518 | |
519 | Int_t fInitRunDepRecalib = InitRunDepRecalib(); | |
520 | if (fInitRunDepRecalib==0) | |
521 | AliError("InitrunDepRecalib returned false, returning"); | |
522 | if (fInitRunDepRecalib==1) | |
523 | AliWarning("InitRecalib OK"); | |
524 | if (fInitRunDepRecalib>1) | |
525 | AliWarning(Form("No Temperature recalibration available: %d - %s", event->GetRunNumber(), fFilepass.Data())); | |
526 | ||
766cc9de | 527 | } |
8b775c10 | 528 | |
7bf608c9 | 529 | |
530 | ||
50b7a951 | 531 | // init time calibration |
c05ffa77 | 532 | if( needTimecalib ){ |
50b7a951 | 533 | Int_t initTC = InitTimeCalibration(); |
534 | if ( !initTC ) | |
50b7a951 | 535 | AliError("InitTimeCalibration returned false, returning"); |
50b7a951 | 536 | if (initTC==1) |
886d4ff1 | 537 | AliWarning("InitTimeCalib OK"); |
50b7a951 | 538 | if( initTC > 1 ) |
886d4ff1 | 539 | AliWarning(Form("No external time calibration set: %d - %s", event->GetRunNumber(), fFilepass.Data())); |
50b7a951 | 540 | } |
541 | ||
542 | // init misalignment matrix | |
c05ffa77 | 543 | if( needMisalign ) { |
544 | if (!InitMisalignMatrix()) | |
766cc9de | 545 | AliError("InitMisalignmentMatrix returned false, returning"); |
50b7a951 | 546 | else |
886d4ff1 | 547 | AliWarning("InitMisalignMatrix OK"); |
766cc9de | 548 | } |
8b775c10 | 549 | |
50b7a951 | 550 | // init clusterizer |
c05ffa77 | 551 | if( needClusterizer ) { |
50b7a951 | 552 | if (!InitClusterization()) |
766cc9de | 553 | AliError("InitClusterization returned false, returning"); |
50b7a951 | 554 | else |
886d4ff1 | 555 | AliWarning("InitClusterization OK"); |
766cc9de | 556 | } |
6b7df55d | 557 | |
766cc9de | 558 | if(fDebugLevel>1) |
559 | fEMCALRecoUtils->Print(""); | |
560 | } | |
8b775c10 | 561 | |
50b7a951 | 562 | // disable implied switches ------------------------------------------------- |
563 | // AliEMCALRecoUtils or clusterizer functions alredy include some | |
564 | // recalibration so based on those implied callibration te switches | |
565 | // here are disabled to avoid duplication | |
566 | ||
567 | // clusterizer does cluster energy recalibration, position recomputation | |
568 | // and shower shape | |
c05ffa77 | 569 | if( fReClusterize ){ |
50b7a951 | 570 | fReCalibCluster = kFALSE; |
571 | fRecalClusPos = kFALSE; | |
572 | fRecalShowerShape = kFALSE; | |
573 | } | |
574 | ||
575 | // CONFIGURE THE RECO UTILS ------------------------------------------------- | |
576 | // configure the reco utils | |
577 | // this option does energy recalibration | |
578 | if( fCalibrateEnergy ) | |
579 | fEMCALRecoUtils->SwitchOnRecalibration(); | |
580 | else | |
581 | fEMCALRecoUtils->SwitchOffRecalibration(); | |
582 | ||
583 | // allows time calibration | |
584 | if( fCalibrateTime ) | |
585 | fEMCALRecoUtils->SwitchOnTimeRecalibration(); | |
586 | else | |
587 | fEMCALRecoUtils->SwitchOffTimeRecalibration(); | |
588 | ||
589 | // allows to zero bad cells | |
590 | if( fBadCellRemove ) | |
591 | fEMCALRecoUtils->SwitchOnBadChannelsRemoval(); | |
592 | else | |
593 | fEMCALRecoUtils->SwitchOffBadChannelsRemoval(); | |
594 | ||
595 | // distance to bad channel recalibration | |
596 | if( fRecalDistToBadChannels ) | |
597 | fEMCALRecoUtils->SwitchOnDistToBadChannelRecalculation(); | |
598 | else | |
599 | fEMCALRecoUtils->SwitchOffDistToBadChannelRecalculation(); | |
600 | ||
601 | // exclude exotic cells | |
602 | if( fRejectExoticCells ) | |
603 | fEMCALRecoUtils->SwitchOnRejectExoticCell(); | |
604 | else | |
605 | fEMCALRecoUtils->SwitchOffRejectExoticCell(); | |
606 | ||
607 | // exclude clusters with exotic cells | |
608 | if( fRejectExoticClusters ) | |
609 | fEMCALRecoUtils->SwitchOnRejectExoticCluster(); | |
610 | else | |
611 | fEMCALRecoUtils->SwitchOffRejectExoticCluster(); | |
612 | ||
613 | // TODO: not implemented switches | |
614 | // SwitchOnClusterEnergySmearing | |
615 | // SwitchOnRunDepCorrection | |
616 | ||
617 | // START PROCESSING --------------------------------------------------------- | |
766cc9de | 618 | // Test if cells present |
dd8e12d1 | 619 | AliVCaloCells *cells= event->GetEMCALCells(); |
50b7a951 | 620 | if (cells->GetNumberOfCells()<=0) |
621 | { | |
8b775c10 | 622 | if(fDebugLevel>1) |
623 | AliWarning(Form("Number of EMCAL cells = %d, returning", cells->GetNumberOfCells())); | |
766cc9de | 624 | return; |
625 | } | |
6b7df55d | 626 | |
a0beb012 | 627 | if (fDebugLevel>2) |
8b775c10 | 628 | AliInfo(Form("Re-calibrate cluster %d\n",fReCalibCluster)); |
50b7a951 | 629 | |
630 | // mark the cells not recalibrated in case of selected | |
631 | // time, energy recalibration or bad channel removal | |
632 | if( fCalibrateEnergy || fCalibrateTime || fBadCellRemove ) | |
633 | fEMCALRecoUtils->ResetCellsCalibrated(); | |
634 | ||
b524daab | 635 | // CELL RECALIBRATION ------------------------------------------------------- |
50b7a951 | 636 | // cell objects will be updated |
637 | // the cell calibrations are also processed locally any time those are needed | |
638 | // in case that the cell objects are not to be updated here for later use | |
639 | if( fUpdateCell ) | |
8b775c10 | 640 | { |
50b7a951 | 641 | // do the update |
642 | // includes exotic cell check in the UpdateCells function - is not provided | |
643 | // by the reco utils | |
8b775c10 | 644 | UpdateCells(); |
50b7a951 | 645 | |
646 | // switch off recalibrations so those are not done multiple times | |
647 | // this is just for safety, the recalibrated flag of cell object | |
648 | // should not allow for farther processing anyways | |
649 | fEMCALRecoUtils->SwitchOffRecalibration(); | |
650 | fEMCALRecoUtils->SwitchOffTimeRecalibration(); | |
651 | ||
a0beb012 | 652 | if (fDoUpdateOnly) |
653 | return; | |
8b775c10 | 654 | } |
a0beb012 | 655 | |
50b7a951 | 656 | // RECLUSTERIZATION --------------------------------------------------------- |
a0beb012 | 657 | if (fReClusterize) |
8b775c10 | 658 | { |
659 | FillDigitsArray(); | |
660 | Clusterize(); | |
661 | UpdateClusters(); | |
662 | } | |
b524daab | 663 | |
766cc9de | 664 | // Store good clusters |
665 | TClonesArray *clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters")); | |
666 | if (!clusArr) | |
667 | clusArr = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters")); | |
668 | if (!clusArr) { | |
669 | AliWarning(Form("No cluster array, number of cells in event = %d, returning", cells->GetNumberOfCells())); | |
670 | return; | |
671 | } | |
50b7a951 | 672 | |
673 | // PROCESS SINGLE CLUSTER RECALIBRATION ------------------------------------- | |
674 | // now go through clusters one by one and process separate correction | |
675 | // as those were defined or not | |
766cc9de | 676 | Int_t nclusters = clusArr->GetEntriesFast(); |
50b7a951 | 677 | for (Int_t icluster=0; icluster < nclusters; ++icluster) |
678 | { | |
766cc9de | 679 | AliVCluster *clust = static_cast<AliVCluster*>(clusArr->At(icluster)); |
680 | if (!clust) | |
681 | continue; | |
682 | if (!clust->IsEMCAL()) | |
683 | continue; | |
50b7a951 | 684 | |
685 | // REMOVE CLUSTERS WITH BAD CELLS ----------------------------- | |
686 | if( fClusterBadChannelCheck ) | |
687 | { | |
688 | // careful, the the ClusterContainsBadChannel is dependent on | |
689 | // SwitchOnBadChannelsRemoval, switching it ON automatically | |
690 | // and returning to original value after processing | |
691 | Bool_t badRemoval = fEMCALRecoUtils->IsBadChannelsRemovalSwitchedOn(); | |
692 | fEMCALRecoUtils->SwitchOnBadChannelsRemoval(); | |
693 | ||
694 | Bool_t badResult = fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo, clust->GetCellsAbsId(), clust->GetNCells()); | |
695 | ||
696 | // switch the bad channels removal back | |
697 | if( ! badRemoval ) | |
698 | fEMCALRecoUtils->SwitchOffBadChannelsRemoval(); | |
699 | ||
700 | if( badResult ) | |
701 | { | |
702 | delete clusArr->RemoveAt(icluster); | |
703 | continue; //TODO is it really needed to remove it? Or should we flag it? | |
704 | } | |
705 | } | |
706 | ||
707 | // REMOVE EXOTIC CLUSTERS ------------------------------------- | |
708 | // does process local cell recalibration energy and time without replacing | |
709 | // the global cell values, in case of no cell recalib done yet | |
710 | if( fRejectExoticClusters ) | |
711 | { | |
712 | // careful, the IsExoticCluster is dependent on | |
713 | // SwitchOnRejectExoticCell, switching it ON automatically | |
714 | // and returning to original value after processing | |
715 | Bool_t exRemoval = fEMCALRecoUtils->IsRejectExoticCell(); | |
716 | fEMCALRecoUtils->SwitchOnRejectExoticCell(); | |
717 | ||
718 | // get bunch crossing | |
dd8e12d1 | 719 | Int_t bunchCrossNo = event->GetBunchCrossNumber(); |
50b7a951 | 720 | |
721 | Bool_t exResult = fEMCALRecoUtils->IsExoticCluster(clust, cells, bunchCrossNo ); | |
722 | ||
723 | // switch the exotic channels removal back | |
724 | if( ! exRemoval ) | |
725 | fEMCALRecoUtils->SwitchOffRejectExoticCell(); | |
726 | ||
727 | if( exResult ) | |
728 | { | |
729 | delete clusArr->RemoveAt(icluster); | |
730 | continue; //TODO is it really needed to remove it? Or should we flag it? | |
731 | } | |
766cc9de | 732 | } |
6b7df55d | 733 | |
50b7a951 | 734 | // FIDUCIAL CUT ----------------------------------------------- |
735 | if (fFiducial) | |
736 | { | |
737 | // depends on SetNumberOfCellsFromEMCALBorder | |
738 | // SwitchOnNoFiducialBorderInEMCALEta0 | |
766cc9de | 739 | if (!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, clust, cells)){ |
740 | delete clusArr->RemoveAt(icluster); | |
50b7a951 | 741 | continue; //TODO it would be nice to store the distance |
766cc9de | 742 | } |
743 | } | |
6b7df55d | 744 | |
50b7a951 | 745 | // CLUSTER ENERGY --------------------------------------------- |
746 | // does process local cell recalibration energy and time without replacing | |
747 | // the global cell values, in case of no cell recalib done yet | |
8c80b40c | 748 | if( fReCalibCluster ) { |
766cc9de | 749 | fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, clust, cells); |
8c80b40c | 750 | if (clust->E() < 1e-9) { |
751 | delete clusArr->RemoveAt(icluster); | |
752 | continue; | |
753 | } | |
754 | } | |
755 | ||
50b7a951 | 756 | // CLUSTER POSITION ------------------------------------------- |
757 | // does process local cell energy recalibration, if enabled and cells | |
98e8eede | 758 | // not calibrated yet |
50b7a951 | 759 | if( fRecalClusPos ) |
766cc9de | 760 | fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, cells, clust); |
57131575 | 761 | |
50b7a951 | 762 | // SHOWER SHAPE ----------------------------------------------- |
763 | if( fRecalShowerShape ) | |
764 | fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, cells, clust); | |
765 | ||
766 | // NONLINEARITY ----------------------------------------------- | |
767 | if( fDoNonLinearity ) | |
768 | { | |
769 | Float_t correctedEnergy = fEMCALRecoUtils->CorrectClusterEnergyLinearity(clust); | |
770 | clust->SetE(correctedEnergy); | |
771 | } | |
772 | ||
773 | // DISTANCE TO BAD CHANNELS ----------------------------------- | |
774 | if( fRecalDistToBadChannels ) | |
775 | fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, cells, clust); | |
766cc9de | 776 | } |
57131575 | 777 | |
766cc9de | 778 | clusArr->Compress(); |
a0beb012 | 779 | |
780 | if (!fDoTrackMatch) | |
781 | return; | |
782 | ||
50b7a951 | 783 | // TRACK MATCHING ----------------------------------------------------------- |
dd8e12d1 | 784 | if (!TGeoGlobalMagField::Instance()->GetField()) { |
785 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event); | |
786 | if (esd) | |
787 | esd->InitMagneticField(); | |
788 | else { | |
789 | AliAODEvent *aod = dynamic_cast<AliAODEvent*>(event); | |
790 | Double_t curSol = 30000*aod->GetMagneticField()/5.00668; | |
791 | Double_t curDip = 6000 *aod->GetMuonMagFieldScale(); | |
792 | AliMagF *field = AliMagF::CreateFieldMap(curSol,curDip); | |
793 | TGeoGlobalMagField::Instance()->SetField(field); | |
794 | } | |
766cc9de | 795 | } |
dd8e12d1 | 796 | |
766cc9de | 797 | fEMCALRecoUtils->FindMatches(event,0x0,fEMCALGeo); |
57131575 | 798 | fEMCALRecoUtils->SetClusterMatchedToTrack(event); |
799 | fEMCALRecoUtils->SetTracksMatchedToCluster(event); | |
6d67b5a7 | 800 | } |
801 | ||
802 | //_____________________________________________________ | |
803 | Bool_t AliEMCALTenderSupply::InitMisalignMatrix() | |
804 | { | |
766cc9de | 805 | // Initialising misalignment matrices |
98e8eede | 806 | |
dd8e12d1 | 807 | AliVEvent *event = GetEvent(); |
6b7df55d | 808 | |
766cc9de | 809 | if (!event) |
810 | return kFALSE; | |
6b7df55d | 811 | |
50b7a951 | 812 | if (fGeomMatrixSet) |
813 | { | |
814 | AliInfo("Misalignment matrix already set"); | |
766cc9de | 815 | return kTRUE; |
816 | } | |
6b7df55d | 817 | |
766cc9de | 818 | if (fDebugLevel>0) |
50b7a951 | 819 | AliInfo("Initialising misalignment matrix"); |
6b7df55d | 820 | |
766cc9de | 821 | if (fLoadGeomMatrices) { |
50b7a951 | 822 | for(Int_t mod=0; mod < fEMCALGeo->GetNumberOfSuperModules(); ++mod) |
823 | { | |
766cc9de | 824 | if (fEMCALMatrix[mod]){ |
825 | if(fDebugLevel > 2) | |
826 | fEMCALMatrix[mod]->Print(); | |
827 | fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod); | |
828 | } | |
829 | } | |
830 | fGeomMatrixSet = kTRUE; | |
831 | return kTRUE; | |
832 | } | |
6b7df55d | 833 | |
766cc9de | 834 | Int_t runGM = event->GetRunNumber(); |
6b7df55d | 835 | TObjArray *mobj = 0; |
acf53135 | 836 | |
98e8eede | 837 | if(fMisalignSurvey == kdefault) |
838 | { //take default alignment corresponding to run no | |
acf53135 | 839 | AliOADBContainer emcalgeoCont(Form("emcal")); |
840 | emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo")); | |
841 | mobj=(TObjArray*)emcalgeoCont.GetObject(runGM,"EmcalMatrices"); | |
acf53135 | 842 | } |
98e8eede | 843 | |
844 | if(fMisalignSurvey == kSurveybyS) | |
845 | { //take alignment at sector level | |
846 | if (runGM <= 140000) { //2010 data | |
847 | AliOADBContainer emcalgeoCont(Form("emcal2010")); | |
848 | emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo")); | |
849 | mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10"); | |
850 | } | |
851 | else if (runGM>140000) | |
852 | { // 2011 LHC11a pass1 data | |
853 | AliOADBContainer emcalgeoCont(Form("emcal2011")); | |
854 | emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo")); | |
855 | mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byS"); | |
856 | } | |
857 | } | |
acf53135 | 858 | |
98e8eede | 859 | if(fMisalignSurvey == kSurveybyM) |
860 | { //take alignment at module level | |
861 | if (runGM <= 140000) { //2010 data | |
862 | AliOADBContainer emcalgeoCont(Form("emcal2010")); | |
863 | emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo")); | |
864 | mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey10"); | |
865 | } | |
866 | else if (runGM>140000) | |
867 | { // 2011 LHC11a pass1 data | |
868 | AliOADBContainer emcalgeoCont(Form("emcal2011")); | |
869 | emcalgeoCont.InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root",Form("AliEMCALgeo")); | |
870 | mobj=(TObjArray*)emcalgeoCont.GetObject(100,"survey11byM"); | |
871 | } | |
766cc9de | 872 | } |
acf53135 | 873 | |
50b7a951 | 874 | if(!mobj) |
875 | { | |
4d3c549c | 876 | AliFatal("Geometry matrix array not found"); |
877 | return kFALSE; | |
878 | } | |
879 | ||
98e8eede | 880 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++) |
881 | { | |
882 | fEMCALMatrix[mod] = (TGeoHMatrix*) mobj->At(mod); | |
883 | fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod); | |
884 | fEMCALMatrix[mod]->Print(); | |
885 | } | |
4d3c549c | 886 | |
766cc9de | 887 | return kTRUE; |
6d67b5a7 | 888 | } |
889 | ||
890 | //_____________________________________________________ | |
acf53135 | 891 | Int_t AliEMCALTenderSupply::InitBadChannels() |
6d67b5a7 | 892 | { |
766cc9de | 893 | // Initialising bad channel maps |
dd8e12d1 | 894 | |
895 | AliVEvent *event = GetEvent(); | |
896 | ||
766cc9de | 897 | if (!event) |
acf53135 | 898 | return 0; |
6b7df55d | 899 | |
766cc9de | 900 | if (fDebugLevel>0) |
901 | AliInfo("Initialising Bad channel map"); | |
6b7df55d | 902 | |
50b7a951 | 903 | // init default maps first |
904 | if( !fEMCALRecoUtils->GetEMCALBadChannelStatusMapArray() ) | |
905 | fEMCALRecoUtils->InitEMCALBadChannelStatusMap() ; | |
6b7df55d | 906 | |
766cc9de | 907 | Int_t runBC = event->GetRunNumber(); |
6b7df55d | 908 | |
a0beb012 | 909 | AliOADBContainer *contBC = new AliOADBContainer(""); |
50b7a951 | 910 | if (fBasePath!="") |
911 | { //if fBasePath specified in the ->SetBasePath() | |
acf53135 | 912 | if (fDebugLevel>0) AliInfo(Form("Loading Bad Channels OADB from given path %s",fBasePath.Data())); |
4d3c549c | 913 | |
acf53135 | 914 | TFile *fbad=new TFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"read"); |
50b7a951 | 915 | if (!fbad || fbad->IsZombie()) |
916 | { | |
4d3c549c | 917 | AliFatal(Form("EMCALBadChannels.root was not found in the path provided: %s",fBasePath.Data())); |
acf53135 | 918 | return 0; |
919 | } | |
4d3c549c | 920 | |
a0beb012 | 921 | if (fbad) delete fbad; |
4d3c549c | 922 | |
acf53135 | 923 | contBC->InitFromFile(Form("%s/EMCALBadChannels.root",fBasePath.Data()),"AliEMCALBadChannels"); |
50b7a951 | 924 | } |
925 | else | |
926 | { // Else choose the one in the $ALICE_ROOT directory | |
a0beb012 | 927 | if (fDebugLevel>0) AliInfo("Loading Bad Channels OADB from $ALICE_ROOT/OADB/EMCAL"); |
928 | ||
929 | TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","read"); | |
50b7a951 | 930 | if (!fbad || fbad->IsZombie()) |
931 | { | |
a0beb012 | 932 | AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root was not found"); |
933 | return 0; | |
934 | } | |
4d3c549c | 935 | |
a0beb012 | 936 | if (fbad) delete fbad; |
937 | ||
938 | contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALBadChannels.root","AliEMCALBadChannels"); | |
939 | } | |
acf53135 | 940 | |
941 | TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC); | |
50b7a951 | 942 | if (!arrayBC) |
943 | { | |
acf53135 | 944 | AliError(Form("No external hot channel set for run number: %d", runBC)); |
945 | return 2; | |
766cc9de | 946 | } |
acf53135 | 947 | |
948 | Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules(); | |
50b7a951 | 949 | for (Int_t i=0; i<sms; ++i) |
950 | { | |
acf53135 | 951 | TH2I *h = fEMCALRecoUtils->GetEMCALChannelStatusMap(i); |
952 | if (h) | |
953 | delete h; | |
dd8e12d1 | 954 | h=(TH2I*)arrayBC->FindObject(Form("EMCALBadChannelMap_Mod%d",i)); |
acf53135 | 955 | |
50b7a951 | 956 | if (!h) |
957 | { | |
acf53135 | 958 | AliError(Form("Can not get EMCALBadChannelMap_Mod%d",i)); |
959 | continue; | |
960 | } | |
961 | h->SetDirectory(0); | |
962 | fEMCALRecoUtils->SetEMCALChannelStatusMap(i,h); | |
766cc9de | 963 | } |
acf53135 | 964 | return 1; |
6d67b5a7 | 965 | } |
966 | ||
967 | //_____________________________________________________ | |
acf53135 | 968 | Int_t AliEMCALTenderSupply::InitRecalib() |
6d67b5a7 | 969 | { |
766cc9de | 970 | // Initialising recalibration factors. |
6b7df55d | 971 | |
dd8e12d1 | 972 | AliVEvent *event = GetEvent(); |
973 | ||
766cc9de | 974 | if (!event) |
acf53135 | 975 | return 0; |
6b7df55d | 976 | |
766cc9de | 977 | if (fDebugLevel>0) |
978 | AliInfo("Initialising recalibration factors"); | |
6b7df55d | 979 | |
50b7a951 | 980 | // init default maps first |
981 | if( !fEMCALRecoUtils->GetEMCALRecalibrationFactorsArray() ) | |
982 | fEMCALRecoUtils->InitEMCALRecalibrationFactors() ; | |
983 | ||
766cc9de | 984 | Int_t runRC = event->GetRunNumber(); |
acf53135 | 985 | |
986 | AliOADBContainer *contRF=new AliOADBContainer(""); | |
50b7a951 | 987 | if (fBasePath!="") |
988 | { //if fBasePath specified in the ->SetBasePath() | |
989 | if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data())); | |
4d3c549c | 990 | |
acf53135 | 991 | TFile *fRecalib= new TFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"read"); |
50b7a951 | 992 | if (!fRecalib || fRecalib->IsZombie()) |
993 | { | |
4d3c549c | 994 | AliFatal(Form("EMCALRecalib.root not found in %s",fBasePath.Data())); |
acf53135 | 995 | return 0; |
766cc9de | 996 | } |
4d3c549c | 997 | |
a0beb012 | 998 | if (fRecalib) delete fRecalib; |
4d3c549c | 999 | |
acf53135 | 1000 | contRF->InitFromFile(Form("%s/EMCALRecalib.root",fBasePath.Data()),"AliEMCALRecalib"); |
1001 | } | |
98e8eede | 1002 | else |
1003 | { // Else choose the one in the $ALICE_ROOT directory | |
1004 | if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL"); | |
1005 | ||
1006 | TFile *fRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","read"); | |
1007 | if (!fRecalib || fRecalib->IsZombie()) | |
1008 | { | |
1009 | AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root was not found"); | |
1010 | return 0; | |
766cc9de | 1011 | } |
98e8eede | 1012 | |
1013 | if (fRecalib) delete fRecalib; | |
1014 | ||
1015 | contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALRecalib.root","AliEMCALRecalib"); | |
1016 | } | |
acf53135 | 1017 | |
dd8e12d1 | 1018 | TObjArray *recal=(TObjArray*)contRF->GetObject(runRC); |
50b7a951 | 1019 | if (!recal) |
1020 | { | |
acf53135 | 1021 | AliError(Form("No Objects for run: %d",runRC)); |
1022 | return 2; | |
1023 | } | |
1024 | ||
1025 | TObjArray *recalpass=(TObjArray*)recal->FindObject(fFilepass); | |
50b7a951 | 1026 | if (!recalpass) |
1027 | { | |
acf53135 | 1028 | AliError(Form("No Objects for run: %d - %s",runRC,fFilepass.Data())); |
1029 | return 2; | |
1030 | } | |
1031 | ||
1032 | TObjArray *recalib=(TObjArray*)recalpass->FindObject("Recalib"); | |
50b7a951 | 1033 | if (!recalib) |
1034 | { | |
acf53135 | 1035 | AliError(Form("No Recalib histos found for %d - %s",runRC,fFilepass.Data())); |
1036 | return 2; | |
1037 | } | |
1038 | ||
a0beb012 | 1039 | if (fDebugLevel>0) recalib->Print(); |
acf53135 | 1040 | |
1041 | Int_t sms = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules(); | |
50b7a951 | 1042 | for (Int_t i=0; i<sms; ++i) |
1043 | { | |
acf53135 | 1044 | TH2F *h = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactors(i); |
1045 | if (h) | |
1046 | delete h; | |
1047 | h = (TH2F*)recalib->FindObject(Form("EMCALRecalFactors_SM%d",i)); | |
50b7a951 | 1048 | if (!h) |
1049 | { | |
acf53135 | 1050 | AliError(Form("Could not load EMCALRecalFactors_SM%d",i)); |
1051 | continue; | |
766cc9de | 1052 | } |
acf53135 | 1053 | h->SetDirectory(0); |
1054 | fEMCALRecoUtils->SetEMCALChannelRecalibrationFactors(i,h); | |
766cc9de | 1055 | } |
acf53135 | 1056 | return 1; |
c958a2f7 | 1057 | } |
1058 | ||
7bf608c9 | 1059 | //_____________________________________________________ |
1060 | Int_t AliEMCALTenderSupply::InitRunDepRecalib() | |
1061 | { | |
1062 | // Initialising recalibration factors. | |
1063 | ||
1064 | AliVEvent *event = GetEvent(); | |
1065 | ||
1066 | if (!event) | |
1067 | return 0; | |
1068 | ||
1069 | if (fDebugLevel>0) | |
1070 | AliInfo("Initialising recalibration factors"); | |
1071 | ||
1072 | // init default maps first | |
1073 | if( !fEMCALRecoUtils->GetEMCALRecalibrationFactorsArray() ) | |
1074 | fEMCALRecoUtils->InitEMCALRecalibrationFactors() ; | |
1075 | ||
1076 | Int_t runRC = event->GetRunNumber(); | |
1077 | ||
1078 | AliOADBContainer *contRF=new AliOADBContainer(""); | |
1079 | if (fBasePath!="") | |
1080 | { //if fBasePath specified in the ->SetBasePath() | |
1081 | if (fDebugLevel>0) AliInfo(Form("Loading Recalib OADB from given path %s",fBasePath.Data())); | |
1082 | ||
1083 | TFile *fRunDepRecalib= new TFile(Form("%s/EMCALTemperatureCorrCalib.root",fBasePath.Data()),"read"); | |
1084 | if (!fRunDepRecalib || fRunDepRecalib->IsZombie()) | |
1085 | { | |
1086 | AliFatal(Form("EMCALTemperatureCorrCalib.root not found in %s",fBasePath.Data())); | |
1087 | return 0; | |
1088 | } | |
1089 | ||
1090 | if (fRunDepRecalib) delete fRunDepRecalib; | |
1091 | ||
1092 | contRF->InitFromFile(Form("%s/EMCALTemperatureCorrCalib.root",fBasePath.Data()),"AliEMCALRunDepTempCalibCorrections"); | |
1093 | } | |
1094 | else | |
1095 | { // Else choose the one in the $ALICE_ROOT directory | |
1096 | if (fDebugLevel>0) AliInfo("Loading Recalib OADB from $ALICE_ROOT/OADB/EMCAL"); | |
1097 | ||
1098 | TFile *fRunDepRecalib= new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root","read"); | |
1099 | if (!fRunDepRecalib || fRunDepRecalib->IsZombie()) | |
1100 | { | |
1101 | AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root was not found"); | |
1102 | return 0; | |
1103 | } | |
1104 | ||
1105 | if (fRunDepRecalib) delete fRunDepRecalib; | |
1106 | ||
1107 | contRF->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALTemperatureCorrCalib.root","AliEMCALRunDepTempCalibCorrections"); | |
1108 | } | |
1109 | ||
1110 | TH1S *rundeprecal=(TH1S*)contRF->GetObject(runRC); | |
1111 | if (!rundeprecal) | |
1112 | { | |
a39628b1 | 1113 | AliWarning(Form("No TemperatureCorrCalib Objects for run: %d",runRC)); |
1114 | // let's get the closest runnumber instead then.. | |
1115 | Int_t lower = 0; | |
1116 | Int_t ic = 0; | |
1117 | Int_t maxEntry = contRF->GetNumberOfEntries(); | |
1118 | ||
1119 | while ( (ic < maxEntry) && (contRF->UpperLimit(ic) < runRC) ) { | |
1120 | lower = ic; | |
1121 | ic++; | |
1122 | } | |
1123 | ||
1124 | Int_t closest = lower; | |
1125 | if ( (ic<maxEntry) && | |
1126 | (contRF->LowerLimit(ic)-runRC) < (runRC - contRF->UpperLimit(lower)) ) { | |
1127 | closest = ic; | |
1128 | } | |
1129 | ||
1130 | AliWarning(Form("TemperatureCorrCalib Objects found closest id %d from run: %d", closest, contRF->LowerLimit(closest))); | |
1131 | rundeprecal = (TH1S*) contRF->GetObjectByIndex(closest); | |
7bf608c9 | 1132 | } |
1133 | ||
1134 | if (fDebugLevel>0) rundeprecal->Print(); | |
1135 | ||
1136 | Int_t nSM = fEMCALGeo->GetEMCGeometry()->GetNumberOfSuperModules(); | |
1137 | ||
1138 | for (Int_t ism=0; ism<nSM; ++ism) | |
1139 | { | |
1140 | for (Int_t icol=0; icol<48; ++icol) | |
1141 | { | |
1142 | for (Int_t irow=0; irow<24; ++irow) | |
1143 | { | |
1144 | Float_t factor = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(ism,icol,irow); | |
1145 | ||
1146 | Int_t absID = fEMCALGeo->GetAbsCellIdFromCellIndexes(ism, irow, icol); // original calibration factor | |
1147 | factor *= rundeprecal->GetBinContent(absID) / 10000. ; // correction dependent on T | |
1148 | //printf("\t ism %d, icol %d, irow %d,absID %d, corrA %2.3f, corrB %2.3f, corrAB %2.3f\n",ism, icol, irow, absID, | |
1149 | // GetEMCALChannelRecalibrationFactor(ism,icol,irow) , rundeprecal->GetBinContent(absID) / 10000., factor); | |
1150 | fEMCALRecoUtils->SetEMCALChannelRecalibrationFactor(ism,icol,irow,factor); | |
1151 | } // columns | |
1152 | } // rows | |
1153 | } // SM loop | |
1154 | ||
1155 | return 1; | |
1156 | } | |
1157 | ||
1158 | ||
50b7a951 | 1159 | //_____________________________________________________ |
1160 | Int_t AliEMCALTenderSupply::InitTimeCalibration() | |
1161 | { | |
1162 | // Initialising bad channel maps | |
dd8e12d1 | 1163 | AliVEvent *event = GetEvent(); |
1164 | ||
50b7a951 | 1165 | if (!event) |
1166 | return 0; | |
1167 | ||
1168 | if (fDebugLevel>0) | |
1169 | AliInfo("Initialising time calibration map"); | |
1170 | ||
1171 | // init default maps first | |
98e8eede | 1172 | if ( !fEMCALRecoUtils->GetEMCALTimeRecalibrationFactorsArray() ) |
50b7a951 | 1173 | fEMCALRecoUtils->InitEMCALTimeRecalibrationFactors() ; |
1174 | ||
1175 | Int_t runBC = event->GetRunNumber(); | |
1176 | ||
1177 | AliOADBContainer *contBC = new AliOADBContainer(""); | |
1178 | if (fBasePath!="") | |
1179 | { //if fBasePath specified in the ->SetBasePath() | |
1180 | if (fDebugLevel>0) AliInfo(Form("Loading time calibration OADB from given path %s",fBasePath.Data())); | |
1181 | ||
1182 | TFile *fbad=new TFile(Form("%s/EMCALTimeCalib.root",fBasePath.Data()),"read"); | |
1183 | if (!fbad || fbad->IsZombie()) | |
1184 | { | |
1185 | AliFatal(Form("EMCALTimeCalib.root was not found in the path provided: %s",fBasePath.Data())); | |
1186 | return 0; | |
1187 | } | |
1188 | ||
1189 | if (fbad) delete fbad; | |
1190 | ||
1191 | contBC->InitFromFile(Form("%s/EMCALTimeCalib.root",fBasePath.Data()),"AliEMCALTimeCalib"); | |
1192 | } | |
1193 | else | |
1194 | { // Else choose the one in the $ALICE_ROOT directory | |
1195 | if (fDebugLevel>0) AliInfo("Loading time calibration OADB from $ALICE_ROOT/OADB/EMCAL"); | |
1196 | ||
1197 | TFile *fbad=new TFile("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root","read"); | |
1198 | if (!fbad || fbad->IsZombie()) | |
1199 | { | |
1200 | AliFatal("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root was not found"); | |
1201 | return 0; | |
1202 | } | |
1203 | ||
1204 | if (fbad) delete fbad; | |
1205 | ||
1206 | contBC->InitFromFile("$ALICE_ROOT/OADB/EMCAL/EMCALTimeCalib.root","AliEMCALTimeCalib"); | |
1207 | } | |
1208 | ||
1209 | TObjArray *arrayBC=(TObjArray*)contBC->GetObject(runBC); | |
1210 | if (!arrayBC) | |
1211 | { | |
1212 | AliError(Form("No external time calibration set for run number: %d", runBC)); | |
1213 | return 2; | |
1214 | } | |
1215 | ||
dd8e12d1 | 1216 | // Here, it looks for a specific pass |
1217 | TObjArray *arrayBCpass=(TObjArray*)arrayBC->FindObject(fFilepass); | |
50b7a951 | 1218 | if (!arrayBCpass) |
1219 | { | |
1220 | AliError(Form("No external time calibration set for: %d -%s", runBC,fFilepass.Data())); | |
1221 | return 2; | |
1222 | } | |
1223 | ||
1224 | if (fDebugLevel>0) arrayBCpass->Print(); | |
1225 | ||
1226 | for( Int_t i = 0; i < 4; i++ ) | |
1227 | { | |
1228 | TH1F *h = fEMCALRecoUtils->GetEMCALChannelTimeRecalibrationFactors( i ); | |
1229 | if( h ) | |
1230 | delete h; | |
1231 | ||
1232 | h = (TH1F*)arrayBCpass->FindObject(Form("hAllTimeAvBC%d",i)); | |
1233 | ||
1234 | if (!h) | |
1235 | { | |
1236 | AliError(Form("Can not get hAllTimeAvBC%d",i)); | |
1237 | continue; | |
1238 | } | |
1239 | h->SetDirectory(0); | |
1240 | fEMCALRecoUtils->SetEMCALChannelTimeRecalibrationFactors(i,h); | |
1241 | } | |
1242 | return 1; | |
1243 | } | |
1244 | ||
acf53135 | 1245 | //_____________________________________________________ |
1246 | void AliEMCALTenderSupply::UpdateCells() | |
1247 | { | |
8b775c10 | 1248 | //Remove bad cells from the cell list |
1249 | //Recalibrate energy and time cells | |
acf53135 | 1250 | //This is required for later reclusterization |
1251 | ||
dd8e12d1 | 1252 | AliVEvent *event = GetEvent(); |
1253 | ||
87acb7a7 | 1254 | if(!event) return ; |
1255 | ||
dd8e12d1 | 1256 | AliVCaloCells *cells = event->GetEMCALCells(); |
1257 | Int_t bunchCrossNo = event->GetBunchCrossNumber(); | |
acf53135 | 1258 | |
50b7a951 | 1259 | fEMCALRecoUtils->RecalibrateCells(cells, bunchCrossNo); |
1260 | ||
1261 | // remove exotic cells - loop through cells and zero the exotic ones | |
1262 | // just like with bad cell rejection in reco utils (inside RecalibrateCells) | |
1263 | if( fRejectExoticCells ) | |
1264 | { | |
b524daab | 1265 | Short_t absId =-1; |
1266 | Double_t ecell = 0; | |
1267 | Double_t tcell = 0; | |
1268 | Double_t efrac = 0; | |
1269 | Short_t mclabel = -1; | |
50b7a951 | 1270 | Bool_t isExot = kFALSE; |
1271 | ||
1272 | // loop through cells | |
1273 | Int_t nEMcell = cells->GetNumberOfCells() ; | |
1274 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) | |
1275 | { | |
b524daab | 1276 | cells->GetCell( iCell, absId, ecell, tcell, mclabel, efrac ); |
50b7a951 | 1277 | |
1278 | isExot = fEMCALRecoUtils->IsExoticCell( absId, cells, bunchCrossNo ); | |
1279 | // zero if exotic | |
1280 | if( isExot ) | |
b524daab | 1281 | cells->SetCell( iCell, absId, 0.0, -1.0, mclabel, efrac ); |
50b7a951 | 1282 | } // cell loop |
1283 | } // reject exotic cells | |
a0beb012 | 1284 | |
1285 | cells->Sort(); | |
8b775c10 | 1286 | } |
acf53135 | 1287 | |
1288 | //_____________________________________________________ | |
dd8e12d1 | 1289 | TString AliEMCALTenderSupply::GetBeamType() |
acf53135 | 1290 | { |
dd8e12d1 | 1291 | // Get beam type : pp-AA-pA |
98e8eede | 1292 | // ESDs have it directly, AODs get it from hardcoded run number ranges |
e768f43c | 1293 | |
dd8e12d1 | 1294 | AliVEvent *event = GetEvent(); |
1295 | ||
1296 | if (!event) { | |
1297 | AliError("Couldn't retrieve event!"); | |
1298 | return ""; | |
c05ffa77 | 1299 | } |
1300 | ||
dd8e12d1 | 1301 | TString beamType; |
1302 | ||
98e8eede | 1303 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(event); |
1304 | if (esd) { | |
dd8e12d1 | 1305 | const AliESDRun *run = esd->GetESDRun(); |
1306 | beamType = run->GetBeamType(); | |
1307 | } | |
98e8eede | 1308 | else |
1309 | { | |
dd8e12d1 | 1310 | Int_t runNumber = event->GetRunNumber(); |
1311 | if ((runNumber >= 136851 && runNumber <= 139517) // LHC10h | |
b524daab | 1312 | || (runNumber >= 166529 && runNumber <= 170593)) // LHC11h |
98e8eede | 1313 | { |
1314 | beamType = "A-A"; | |
1315 | } | |
c05ffa77 | 1316 | else |
98e8eede | 1317 | { |
1318 | beamType = "p-p"; | |
1319 | } | |
a0beb012 | 1320 | } |
dd8e12d1 | 1321 | |
1322 | return beamType; | |
1323 | } | |
1324 | ||
1325 | //_____________________________________________________ | |
1326 | Int_t AliEMCALTenderSupply::InitRecParam() | |
1327 | { | |
98e8eede | 1328 | // Init reco params if not yet exist (probably shipped by the user already) |
1329 | ||
dd8e12d1 | 1330 | if( fRecParam != 0 ) |
1331 | return 2; | |
1332 | ||
1333 | TString beamType = GetBeamType(); | |
1334 | ||
1335 | // set some default reco params | |
1336 | fRecParam = new AliEMCALRecParam(); | |
1337 | fRecParam->SetClusteringThreshold(0.100); | |
1338 | fRecParam->SetMinECut(0.050); | |
1339 | fRecParam->SetTimeCut(250); | |
1340 | fRecParam->SetTimeMin(425); | |
1341 | fRecParam->SetTimeMax(825); | |
1342 | if ( beamType == "A-A") { | |
1343 | fRecParam->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv2); | |
1344 | } | |
1345 | else { | |
1346 | fRecParam->SetClusterizerFlag(AliEMCALRecParam::kClusterizerv1); | |
1347 | } | |
1348 | ||
1349 | return 0; | |
acf53135 | 1350 | } |
1351 | ||
b20bc239 | 1352 | //_____________________________________________________ |
766cc9de | 1353 | Bool_t AliEMCALTenderSupply::InitClusterization() |
b20bc239 | 1354 | { |
766cc9de | 1355 | // Initialing clusterization/unfolding algorithm and set all the needed parameters. |
6b7df55d | 1356 | |
dd8e12d1 | 1357 | AliVEvent *event = GetEvent(); |
1358 | ||
766cc9de | 1359 | if (!event) |
1360 | return kFALSE; | |
6b7df55d | 1361 | |
766cc9de | 1362 | if (fDebugLevel>0) |
a0beb012 | 1363 | AliInfo(Form("Initialising reclustering parameters: Clusterizer type: %d",fRecParam->GetClusterizerFlag())); |
6b7df55d | 1364 | |
766cc9de | 1365 | //---setup clusterizer |
1366 | delete fClusterizer; | |
1367 | if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1) | |
1368 | fClusterizer = new AliEMCALClusterizerv1 (fEMCALGeo); | |
a0beb012 | 1369 | else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv2) |
766cc9de | 1370 | fClusterizer = new AliEMCALClusterizerv2(fEMCALGeo); |
50b7a951 | 1371 | else if (fRecParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerNxN) |
1372 | { | |
766cc9de | 1373 | AliEMCALClusterizerNxN *clusterizer = new AliEMCALClusterizerNxN(fEMCALGeo); |
1374 | clusterizer->SetNRowDiff(fRecParam->GetNRowDiff()); | |
1375 | clusterizer->SetNColDiff(fRecParam->GetNColDiff()); | |
1376 | fClusterizer = clusterizer; | |
50b7a951 | 1377 | } |
1378 | else | |
1379 | { | |
766cc9de | 1380 | AliFatal(Form("Clusterizer < %d > not available", fRecParam->GetClusterizerFlag())); |
1381 | return kFALSE; | |
1382 | } | |
6b7df55d | 1383 | |
766cc9de | 1384 | // Set the clustering parameters |
1385 | fClusterizer->SetECAClusteringThreshold( fRecParam->GetClusteringThreshold() ); | |
1386 | fClusterizer->SetECALogWeight ( fRecParam->GetW0() ); | |
1387 | fClusterizer->SetMinECut ( fRecParam->GetMinECut() ); | |
1388 | fClusterizer->SetUnfolding ( fRecParam->GetUnfold() ); | |
1389 | fClusterizer->SetECALocalMaxCut ( fRecParam->GetLocMaxCut() ); | |
1390 | fClusterizer->SetTimeCut ( fRecParam->GetTimeCut() ); | |
1391 | fClusterizer->SetTimeMin ( fRecParam->GetTimeMin() ); | |
1392 | fClusterizer->SetTimeMax ( fRecParam->GetTimeMax() ); | |
1393 | fClusterizer->SetInputCalibrated ( kTRUE ); | |
1394 | fClusterizer->SetJustClusters ( kTRUE ); | |
6b7df55d | 1395 | |
766cc9de | 1396 | // In case of unfolding after clusterization is requested, set the corresponding parameters |
50b7a951 | 1397 | if (fRecParam->GetUnfold()) |
1398 | { | |
1399 | for (Int_t i = 0; i < 8; ++i) | |
1400 | { | |
766cc9de | 1401 | fClusterizer->SetSSPars(i, fRecParam->GetSSPars(i)); |
1402 | } | |
50b7a951 | 1403 | for (Int_t i = 0; i < 3; ++i) |
1404 | { | |
766cc9de | 1405 | fClusterizer->SetPar5 (i, fRecParam->GetPar5(i)); |
1406 | fClusterizer->SetPar6 (i, fRecParam->GetPar6(i)); | |
1407 | } | |
1408 | fClusterizer->InitClusterUnfolding(); | |
1409 | } | |
6b7df55d | 1410 | |
766cc9de | 1411 | fClusterizer->SetDigitsArr(fDigitsArr); |
1412 | fClusterizer->SetOutput(0); | |
1413 | fClusterArr = const_cast<TObjArray *>(fClusterizer->GetRecPoints()); | |
1414 | return kTRUE; | |
b20bc239 | 1415 | } |
766cc9de | 1416 | |
b20bc239 | 1417 | //_____________________________________________________ |
1418 | void AliEMCALTenderSupply::FillDigitsArray() | |
1419 | { | |
766cc9de | 1420 | // Fill digits from cells to a TClonesArray. |
6b7df55d | 1421 | |
dd8e12d1 | 1422 | AliVEvent *event = GetEvent(); |
1423 | ||
b524daab | 1424 | if (!event) |
766cc9de | 1425 | return; |
6e6de0c3 | 1426 | |
1427 | // In case of MC productions done before aliroot tag v5-02-Rev09 | |
1428 | // assing the cluster label to all the cells belonging to this cluster | |
1429 | // very rough | |
1430 | Int_t cellLabels[12672]; | |
1431 | if(fSetCellMCLabelFromCluster) | |
1432 | { | |
1433 | for (Int_t i = 0; i < 12672; i++) cellLabels[i] = 0; | |
1434 | ||
1435 | Int_t nClusters = event->GetNumberOfCaloClusters(); | |
1436 | for (Int_t i = 0; i < nClusters; i++) | |
1437 | { | |
1438 | AliVCluster *clus = event->GetCaloCluster(i); | |
1439 | ||
1440 | if(!clus) continue; | |
1441 | ||
1442 | if(!clus->IsEMCAL()) continue ; | |
1443 | ||
1444 | Int_t label = clus->GetLabel(); | |
1445 | UShort_t * index = clus->GetCellsAbsId() ; | |
1446 | ||
1447 | for(Int_t icell=0; icell < clus->GetNCells(); icell++ ) | |
1448 | cellLabels[index[icell]] = label; | |
1449 | ||
1450 | }// cluster loop | |
1451 | } | |
6b7df55d | 1452 | |
766cc9de | 1453 | fDigitsArr->Clear("C"); |
dd8e12d1 | 1454 | AliVCaloCells *cells = event->GetEMCALCells(); |
766cc9de | 1455 | Int_t ncells = cells->GetNumberOfCells(); |
50b7a951 | 1456 | for (Int_t icell = 0, idigit = 0; icell < ncells; ++icell) |
1457 | { | |
77e93dc2 | 1458 | Double_t cellAmplitude=0, cellTime=0, efrac = 0; |
1459 | Short_t cellNumber=0, mcLabel=-1; | |
a0beb012 | 1460 | |
77e93dc2 | 1461 | if (cells->GetCell(icell, cellNumber, cellAmplitude, cellTime, mcLabel, efrac) != kTRUE) |
766cc9de | 1462 | break; |
94f7c836 | 1463 | |
9b811f75 | 1464 | // Do not add if energy already too low (some cells set to 0 if bad channels) |
1465 | if (cellAmplitude < fRecParam->GetMinECut()) | |
94f7c836 | 1466 | continue; |
a0beb012 | 1467 | |
1468 | // If requested, do not include exotic cells | |
1469 | if (fEMCALRecoUtils->IsExoticCell(cellNumber,cells,event->GetBunchCrossNumber())) | |
94f7c836 | 1470 | continue; |
9b811f75 | 1471 | |
6e6de0c3 | 1472 | if(fSetCellMCLabelFromCluster) mcLabel = cellLabels[cellNumber]; |
1473 | ||
9b811f75 | 1474 | new((*fDigitsArr)[idigit]) AliEMCALDigit(mcLabel, mcLabel, cellNumber, |
1475 | (Float_t)cellAmplitude, (Float_t)cellTime, | |
1476 | AliEMCALDigit::kHG,idigit, 0, 0, 1); | |
766cc9de | 1477 | idigit++; |
1478 | } | |
b20bc239 | 1479 | } |
1480 | ||
1481 | //_____________________________________________________ | |
1482 | void AliEMCALTenderSupply::Clusterize() | |
1483 | { | |
766cc9de | 1484 | // Clusterize. |
6b7df55d | 1485 | |
766cc9de | 1486 | fClusterizer->Digits2Clusters(""); |
b20bc239 | 1487 | } |
1488 | ||
1489 | //_____________________________________________________ | |
1490 | void AliEMCALTenderSupply::UpdateClusters() | |
1491 | { | |
766cc9de | 1492 | // Update ESD cluster list. |
6b7df55d | 1493 | |
dd8e12d1 | 1494 | AliVEvent *event = GetEvent(); |
1495 | ||
766cc9de | 1496 | if (!event) |
1497 | return; | |
6b7df55d | 1498 | |
766cc9de | 1499 | TClonesArray *clus = dynamic_cast<TClonesArray*>(event->FindListObject("caloClusters")); |
1500 | if (!clus) | |
1501 | clus = dynamic_cast<TClonesArray*>(event->FindListObject("CaloClusters")); | |
50b7a951 | 1502 | if (!clus) |
1503 | { | |
6b7df55d | 1504 | AliError(" Null pointer to calo clusters array, returning"); |
766cc9de | 1505 | return; |
1506 | } | |
6b7df55d | 1507 | |
766cc9de | 1508 | Int_t nents = clus->GetEntriesFast(); |
50b7a951 | 1509 | for (Int_t i=0; i < nents; ++i) |
1510 | { | |
98e8eede | 1511 | AliVCluster *c = dynamic_cast<AliVCluster*>(clus->At(i)); |
766cc9de | 1512 | if (!c) |
1513 | continue; | |
1514 | if (c->IsEMCAL()) | |
1515 | delete clus->RemoveAt(i); | |
1516 | } | |
50b7a951 | 1517 | |
766cc9de | 1518 | clus->Compress(); |
50b7a951 | 1519 | |
766cc9de | 1520 | RecPoints2Clusters(clus); |
b20bc239 | 1521 | } |
1522 | ||
1523 | //_____________________________________________________ | |
1524 | void AliEMCALTenderSupply::RecPoints2Clusters(TClonesArray *clus) | |
1525 | { | |
98e8eede | 1526 | // Convert AliEMCALRecoPoints to AliESDCaloClusters/AliAODCaloClusters. |
766cc9de | 1527 | // Cluster energy, global position, cells and their amplitude fractions are restored. |
1528 | ||
dd8e12d1 | 1529 | AliVEvent *event = GetEvent(); |
1530 | ||
766cc9de | 1531 | if (!event) |
1532 | return; | |
94f7c836 | 1533 | |
766cc9de | 1534 | Int_t ncls = fClusterArr->GetEntriesFast(); |
50b7a951 | 1535 | for(Int_t i=0, nout=clus->GetEntriesFast(); i < ncls; ++i) |
1536 | { | |
766cc9de | 1537 | AliEMCALRecPoint *recpoint = static_cast<AliEMCALRecPoint*>(fClusterArr->At(i)); |
1538 | ||
4d3c549c | 1539 | Int_t ncellsTrue = 0; |
766cc9de | 1540 | const Int_t ncells = recpoint->GetMultiplicity(); |
1541 | UShort_t absIds[ncells]; | |
1542 | Double32_t ratios[ncells]; | |
1543 | Int_t *dlist = recpoint->GetDigitsList(); | |
1544 | Float_t *elist = recpoint->GetEnergiesList(); | |
50b7a951 | 1545 | for (Int_t c = 0; c < ncells; ++c) |
1546 | { | |
766cc9de | 1547 | AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(fDigitsArr->At(dlist[c])); |
4d3c549c | 1548 | absIds[ncellsTrue] = digit->GetId(); |
1549 | ratios[ncellsTrue] = elist[c]/digit->GetAmplitude(); | |
1550 | if (ratios[ncellsTrue] < 0.001) | |
766cc9de | 1551 | continue; |
4d3c549c | 1552 | ++ncellsTrue; |
766cc9de | 1553 | } |
1554 | ||
50b7a951 | 1555 | if (ncellsTrue < 1) |
1556 | { | |
766cc9de | 1557 | AliWarning("Skipping cluster with no cells"); |
1558 | continue; | |
1559 | } | |
1560 | ||
1561 | // calculate new cluster position | |
1562 | TVector3 gpos; | |
1563 | recpoint->GetGlobalPosition(gpos); | |
1564 | Float_t g[3]; | |
1565 | gpos.GetXYZ(g); | |
1566 | ||
98e8eede | 1567 | AliVCluster *c = static_cast<AliVCluster*>(clus->New(nout++)); |
94f7c836 | 1568 | c->SetID(nout-1); |
766cc9de | 1569 | c->SetType(AliVCluster::kEMCALClusterv1); |
1570 | c->SetE(recpoint->GetEnergy()); | |
1571 | c->SetPosition(g); | |
4d3c549c | 1572 | c->SetNCells(ncellsTrue); |
766cc9de | 1573 | c->SetDispersion(recpoint->GetDispersion()); |
1574 | c->SetEmcCpvDistance(-1); //not yet implemented | |
1575 | c->SetChi2(-1); //not yet implemented | |
1576 | c->SetTOF(recpoint->GetTime()) ; //time-of-flight | |
1577 | c->SetNExMax(recpoint->GetNExMax()); //number of local maxima | |
1578 | Float_t elipAxis[2]; | |
1579 | recpoint->GetElipsAxis(elipAxis); | |
1580 | c->SetM02(elipAxis[0]*elipAxis[0]) ; | |
1581 | c->SetM20(elipAxis[1]*elipAxis[1]) ; | |
98e8eede | 1582 | c->SetCellsAbsId(absIds); |
1583 | c->SetCellsAmplitudeFraction(ratios); | |
db065c22 | 1584 | |
1585 | //MC | |
1586 | AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(c); | |
1587 | if (esdClus) { | |
1588 | Int_t parentMult = 0; | |
1589 | Int_t *parentList = recpoint->GetParents(parentMult); | |
1590 | if (parentMult > 0) { | |
1591 | TArrayI parents(parentMult, parentList); | |
1592 | esdClus->AddLabels(parents); | |
1593 | } | |
1594 | } | |
1595 | else { | |
1596 | AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(c); | |
f660c2d6 | 1597 | if (aodClus) { |
1598 | Int_t parentMult = 0; | |
1599 | Int_t *parentList = recpoint->GetParents(parentMult); | |
1600 | aodClus->SetLabel(parentList, parentMult); | |
1601 | } | |
db065c22 | 1602 | } |
766cc9de | 1603 | } |
1604 | } | |
b20bc239 | 1605 | |
766cc9de | 1606 | //_____________________________________________________ |
1607 | void AliEMCALTenderSupply::GetPass() | |
1608 | { | |
2b0653b9 | 1609 | // Get passx from filename |
6b7df55d | 1610 | |
766cc9de | 1611 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); |
1612 | fInputTree = mgr->GetTree(); | |
6b7df55d | 1613 | |
50b7a951 | 1614 | if (!fInputTree) |
1615 | { | |
6b7df55d | 1616 | AliError("Pointer to tree = 0, returning"); |
766cc9de | 1617 | return; |
1618 | } | |
6b7df55d | 1619 | |
766cc9de | 1620 | fInputFile = fInputTree->GetCurrentFile(); |
1621 | if (!fInputFile) { | |
6b7df55d | 1622 | AliError("Null pointer input file, returning"); |
766cc9de | 1623 | return; |
1624 | } | |
6b7df55d | 1625 | |
766cc9de | 1626 | TString fname(fInputFile->GetName()); |
a0beb012 | 1627 | if (fname.Contains("pass1")) fFilepass = TString("pass1"); |
1628 | else if (fname.Contains("pass2")) fFilepass = TString("pass2"); | |
1629 | else if (fname.Contains("pass3")) fFilepass = TString("pass3"); | |
b8fd68cf | 1630 | else if (fname.Contains("pass4")) fFilepass = TString("pass4"); |
50b7a951 | 1631 | else |
1632 | { | |
766cc9de | 1633 | AliError(Form("Pass number string not found: %s", fname.Data())); |
1634 | return; | |
1635 | } | |
b20bc239 | 1636 | } |