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