]>
Commit | Line | Data |
---|---|---|
89504c57 | 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 | ||
27bad386 | 16 | // This class derives from AliEMCALClustrerizer |
89504c57 | 17 | |
27bad386 | 18 | // --- Root --- |
89504c57 | 19 | #include <TMath.h> |
20 | #include <TMinuit.h> | |
21 | #include <TTree.h> | |
22 | #include <TBenchmark.h> | |
23 | #include <TBrowser.h> | |
24 | #include <TROOT.h> | |
25 | #include <TClonesArray.h> | |
26 | #include <TH1I.h> | |
27 | ||
27bad386 | 28 | // --- AliRoot --- |
89504c57 | 29 | #include "AliLog.h" |
30 | #include "AliEMCALRecPoint.h" | |
31 | #include "AliEMCALDigit.h" | |
32 | #include "AliEMCALGeometry.h" | |
33 | #include "AliCaloCalibPedestal.h" | |
34 | #include "AliEMCALCalibData.h" | |
35 | #include "AliESDCaloCluster.h" | |
36 | #include "AliEMCALUnfolding.h" | |
89504c57 | 37 | |
27bad386 | 38 | #include "AliEMCALClusterizerFixedWindow.h" |
39 | ||
89504c57 | 40 | ClassImp(AliEMCALClusterizerFixedWindow) |
41 | ||
27bad386 | 42 | //__________________________________________________________________________________________ |
06ca320f | 43 | AliEMCALClusterizerFixedWindow::AliEMCALClusterizerFixedWindow() |
44 | : AliEMCALClusterizer(), | |
45 | fNphi(4), | |
46 | fNeta(4), | |
47 | fShiftPhi(2), | |
48 | fShiftEta(2), | |
49 | fTRUshift(0), | |
50 | fClustersArray(0) | |
89504c57 | 51 | { |
06ca320f | 52 | // Constructor |
89504c57 | 53 | } |
54 | ||
27bad386 | 55 | //__________________________________________________________________________________________ |
89504c57 | 56 | AliEMCALClusterizerFixedWindow::AliEMCALClusterizerFixedWindow(AliEMCALGeometry* geometry) |
27bad386 | 57 | : AliEMCALClusterizer(geometry), |
58 | fNphi(4), | |
59 | fNeta(4), | |
60 | fShiftPhi(2), | |
61 | fShiftEta(2), | |
62 | fTRUshift(0), | |
27bad386 | 63 | fClustersArray(0) |
89504c57 | 64 | { |
27bad386 | 65 | // Constructor |
89504c57 | 66 | } |
67 | ||
27bad386 | 68 | //__________________________________________________________________________________________ |
89504c57 | 69 | AliEMCALClusterizerFixedWindow::AliEMCALClusterizerFixedWindow(AliEMCALGeometry* geometry, AliEMCALCalibData * calib, AliCaloCalibPedestal * caloped) |
27bad386 | 70 | : AliEMCALClusterizer(geometry, calib, caloped), |
71 | fNphi(4), | |
72 | fNeta(4), | |
73 | fShiftPhi(2), | |
74 | fShiftEta(2), | |
75 | fTRUshift(0), | |
27bad386 | 76 | fClustersArray(0) |
89504c57 | 77 | { |
27bad386 | 78 | // Constructor |
89504c57 | 79 | } |
80 | ||
27bad386 | 81 | //__________________________________________________________________________________________ |
89504c57 | 82 | AliEMCALClusterizerFixedWindow::~AliEMCALClusterizerFixedWindow() |
83 | { | |
06ca320f | 84 | // Destructor |
27bad386 | 85 | |
27bad386 | 86 | delete fClustersArray; |
87 | } | |
88 | ||
89 | //__________________________________________________________________________________________ | |
90 | void AliEMCALClusterizerFixedWindow::SetNphi (Int_t n) | |
91 | { | |
92 | // Set fNphi; if clusterizer already initialized gives a warning and does nothing | |
93 | ||
94 | if (fClustersArray) | |
95 | AliWarning("Clusterizer already initialized. Unable to change the parameters."); | |
96 | else | |
97 | fNphi = n; | |
98 | } | |
99 | ||
100 | //__________________________________________________________________________________________ | |
101 | void AliEMCALClusterizerFixedWindow::SetNeta (Int_t n) | |
102 | { | |
103 | // Set fNeta; if clusterizer already initialized gives a warning and does nothing | |
104 | ||
105 | if (fClustersArray) | |
106 | AliWarning("Clusterizer already initialized. Unable to change the parameters."); | |
107 | else | |
108 | fNeta = n; | |
109 | } | |
110 | ||
111 | //__________________________________________________________________________________________ | |
112 | void AliEMCALClusterizerFixedWindow::SetShiftPhi (Int_t s) | |
113 | { | |
114 | // Set fShiftPhi; if clusterizer already initialized gives a warning and does nothing | |
115 | ||
116 | if (fClustersArray) | |
117 | AliWarning("Clusterizer already initialized. Unable to change the parameters."); | |
118 | else | |
119 | fShiftPhi = s; | |
120 | } | |
121 | ||
122 | //__________________________________________________________________________________________ | |
123 | void AliEMCALClusterizerFixedWindow::SetShiftEta (Int_t s) | |
124 | { | |
125 | // Set fShiftEta; if clusterizer already initialized gives a warning and does nothing | |
126 | ||
127 | if (fClustersArray) | |
128 | AliWarning("Clusterizer already initialized. Unable to change the parameters."); | |
129 | else | |
130 | fShiftEta = s; | |
131 | } | |
132 | ||
133 | //__________________________________________________________________________________________ | |
134 | void AliEMCALClusterizerFixedWindow::SetTRUshift(Bool_t b) | |
135 | { | |
136 | // Set fTRUshift; if clusterizer already initialized gives a warning and does nothing | |
137 | ||
138 | if (fClustersArray) | |
139 | AliWarning("Clusterizer already initialized. Unable to change the parameters."); | |
140 | else | |
141 | fTRUshift = b; | |
89504c57 | 142 | } |
143 | ||
27bad386 | 144 | |
145 | //__________________________________________________________________________________________ | |
89504c57 | 146 | void AliEMCALClusterizerFixedWindow::Digits2Clusters(Option_t * option) |
147 | { | |
06ca320f | 148 | // Steering method to perform clusterization for the current event |
89504c57 | 149 | |
06ca320f | 150 | if (strstr(option,"tim")) |
151 | gBenchmark->Start("EMCALClusterizer"); | |
89504c57 | 152 | |
06ca320f | 153 | if (strstr(option,"print")) |
154 | Print(""); | |
89504c57 | 155 | |
06ca320f | 156 | //Get calibration parameters from file or digitizer default values. |
157 | GetCalibrationParameters(); | |
89504c57 | 158 | |
06ca320f | 159 | //Get dead channel map from file or digitizer default values. |
160 | GetCaloCalibPedestal(); | |
89504c57 | 161 | |
06ca320f | 162 | MakeClusters(); //only the real clusters |
89504c57 | 163 | |
06ca320f | 164 | if (fToUnfold) { |
165 | fClusterUnfolding->SetInput(fNumberOfECAClusters,fRecPoints,fDigitsArr); | |
166 | fClusterUnfolding->MakeUnfolding(); | |
167 | } | |
89504c57 | 168 | |
06ca320f | 169 | //Evaluate position, dispersion and other RecPoint properties for EC section |
170 | for (Int_t index = 0; index < fRecPoints->GetEntries(); index++) { | |
171 | AliEMCALRecPoint * rp = dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index)); | |
172 | if (rp) { | |
173 | rp->EvalAll(fECAW0,fDigitsArr,fJustClusters); | |
174 | AliDebug(5, Form("MAX INDEX %d ", rp->GetMaximalEnergyIndex())); | |
175 | //For each rec.point set the distance to the nearest bad crystal | |
176 | if (fCaloPed) | |
177 | rp->EvalDistanceToBadChannels(fCaloPed); | |
178 | } | |
179 | } | |
6265e793 | 180 | |
181 | fRecPoints->Sort(); | |
89504c57 | 182 | |
06ca320f | 183 | for (Int_t index = 0; index < fRecPoints->GetEntries(); index++) { |
184 | AliEMCALRecPoint *rp = dynamic_cast<AliEMCALRecPoint *>(fRecPoints->At(index)); | |
185 | if (rp) { | |
186 | rp->SetIndexInList(index); | |
187 | } | |
188 | else AliFatal("RecPoint NULL!!"); | |
189 | } | |
89504c57 | 190 | |
06ca320f | 191 | if (fTreeR) |
192 | fTreeR->Fill(); | |
89504c57 | 193 | |
06ca320f | 194 | if (strstr(option,"deb") || strstr(option,"all")) |
195 | PrintRecPoints(option); | |
89504c57 | 196 | |
06ca320f | 197 | AliDebug(1,Form("EMCAL Clusterizer found %d Rec Points",fRecPoints->GetEntriesFast())); |
89504c57 | 198 | |
06ca320f | 199 | if (strstr(option,"tim")) { |
200 | gBenchmark->Stop("EMCALClusterizer"); | |
201 | printf("Exec took %f seconds for Clusterizing", | |
202 | gBenchmark->GetCpuTime("EMCALClusterizer")); | |
203 | } | |
89504c57 | 204 | } |
205 | ||
27bad386 | 206 | //__________________________________________________________________________________________ |
89504c57 | 207 | void AliEMCALClusterizerFixedWindow::MakeClusters() |
208 | { | |
06ca320f | 209 | // Make clusters |
89504c57 | 210 | |
06ca320f | 211 | if (fGeom == 0) |
212 | AliFatal("Did not get geometry from EMCALLoader"); | |
89504c57 | 213 | |
06ca320f | 214 | fNumberOfECAClusters = 0; |
215 | fRecPoints->Delete(); | |
89504c57 | 216 | |
06ca320f | 217 | Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0, iphi=0, ieta=0; |
89504c57 | 218 | |
06ca320f | 219 | // Defining geometry and clusterization parameter |
220 | Int_t nEtaDigitsSupMod = fGeom->GetNEta() * fGeom->GetNETAdiv(); // always 48?; | |
221 | Int_t nPhiDigitsSupMod = fGeom->GetNPhi() * fGeom->GetNPHIdiv(); // always 24?; | |
89504c57 | 222 | |
223 | Int_t nTRUPhi = 1; | |
224 | Int_t nTRUEta = 1; | |
225 | ||
226 | Int_t nEtaDigits = nEtaDigitsSupMod * fGeom->GetNumberOfSuperModules() / fGeom->GetNPhiSuperModule(); | |
227 | Int_t nPhiDigits = nPhiDigitsSupMod * fGeom->GetNPhiSuperModule(); | |
228 | ||
27bad386 | 229 | if (fTRUshift){ |
89504c57 | 230 | nTRUPhi = fGeom->GetNPhiSuperModule() * 3; |
231 | nTRUEta = fGeom->GetNumberOfSuperModules() / fGeom->GetNPhiSuperModule(); | |
232 | nEtaDigits /= nTRUEta; | |
233 | nPhiDigits /= nTRUPhi; | |
234 | } | |
235 | ||
236 | // Check if clusterizer parameter are compatible with calorimeter geometry | |
27bad386 | 237 | if (nEtaDigits < fNeta){ |
06ca320f | 238 | AliFatal(Form("Error: fNeta = %d is greater than nEtaDigits = %d.",fNeta,nEtaDigits)); |
239 | return; | |
240 | } | |
241 | if (nPhiDigits < fNphi){ | |
242 | AliFatal(Form("Error: fNphi = %d is greater than nPhiDigits = %d.",fNphi,nPhiDigits)); | |
243 | return; | |
244 | } | |
245 | if (nEtaDigits % fShiftEta != 0){ | |
246 | AliFatal(Form("Error: fShiftEta = %d is such that clusters cannot slide the whole calorimeter (nEtaDigits = %d).",fShiftEta,nEtaDigits)); | |
247 | return; | |
248 | } | |
249 | if (nPhiDigits % fShiftPhi != 0){ | |
250 | AliFatal(Form("Error: fShiftPhi = %d is such that clusters cannot slide the whole calorimeter (nPhiDigits = %d).",fShiftPhi,nPhiDigits)); | |
251 | return; | |
252 | } | |
253 | if (fNeta % fShiftEta != 0){ | |
254 | AliFatal(Form("Error: fShiftEta = %d is not divisor of fNeta = %d.",fShiftEta,fNeta)); | |
255 | return; | |
256 | } | |
257 | if (fNphi % fShiftPhi != 0){ | |
258 | AliFatal(Form("Error: fShiftPhi = %d is not divisor of fNphi = %d).",fShiftPhi,fNphi)); | |
259 | return; | |
260 | } | |
89504c57 | 261 | |
27bad386 | 262 | Int_t maxiShiftPhi = fNphi / fShiftPhi; |
263 | Int_t maxiShiftEta = fNeta / fShiftEta; | |
89504c57 | 264 | |
06ca320f | 265 | Int_t nDigitsCluster = fNphi * fNeta; |
89504c57 | 266 | |
27bad386 | 267 | Int_t nClusEtaNoShift = nEtaDigits / fNeta; |
268 | Int_t nClusPhiNoShift = nPhiDigits / fNphi; | |
89504c57 | 269 | |
270 | Int_t nClusters = nClusEtaNoShift * nClusPhiNoShift * nTRUEta * nTRUPhi; | |
271 | ||
272 | Int_t nTotalClus = nClusters * maxiShiftEta * maxiShiftPhi; | |
273 | ||
e93ec1f7 | 274 | if (!fClustersArray) { |
27bad386 | 275 | fClustersArray = new AliEMCALDigit**[nTotalClus]; |
89504c57 | 276 | for (Int_t i = 0; i < nTotalClus; i++) |
277 | { | |
27bad386 | 278 | fClustersArray[i] = NULL; |
89504c57 | 279 | } |
280 | } | |
281 | ||
e93ec1f7 | 282 | // Set up TObjArray with pointers to digits to work on calibrated digits |
283 | TObjArray *digitsC = new TObjArray(); | |
284 | AliEMCALDigit *digit; | |
285 | Float_t dEnergyCalibrated = 0.0, ehs = 0.0, time = 0.0; | |
286 | TIter nextdigit(fDigitsArr); | |
287 | while ((digit = dynamic_cast<AliEMCALDigit*>(nextdigit()))) { // calibrate and clean up digits | |
288 | dEnergyCalibrated = digit->GetAmplitude(); | |
289 | time = digit->GetTime(); | |
290 | Calibrate(dEnergyCalibrated, time, digit->GetId()); | |
291 | digit->SetCalibAmp(dEnergyCalibrated); | |
292 | digit->SetTime(time); | |
293 | if (dEnergyCalibrated < fMinECut) { | |
294 | continue; | |
295 | } | |
296 | else if (!fGeom->CheckAbsCellId(digit->GetId())) { | |
297 | continue; | |
298 | } | |
299 | else { | |
300 | ehs += dEnergyCalibrated; | |
301 | digitsC->AddLast(digit); | |
302 | } | |
303 | } | |
89504c57 | 304 | |
e93ec1f7 | 305 | AliDebug(1,Form("MakeClusters: Number of digits %d -> (e %f), ehs %f\n", |
306 | fDigitsArr->GetEntries(),fMinECut,ehs)); | |
307 | ||
27bad386 | 308 | for (Int_t ishiftPhi = 0; ishiftPhi < maxiShiftPhi; ishiftPhi++){ |
309 | Int_t nClusPhi = (nPhiDigits - fShiftPhi * ishiftPhi) / fNphi; | |
89504c57 | 310 | |
e93ec1f7 | 311 | for (Int_t ishiftEta = 0; ishiftEta < maxiShiftEta; ishiftEta++) { |
89504c57 | 312 | |
27bad386 | 313 | Int_t nClusEta = (nEtaDigits - fShiftEta * ishiftEta) / fNeta; |
89504c57 | 314 | |
315 | Int_t iTotalClus = nClusters * (ishiftPhi * maxiShiftEta + ishiftEta); | |
316 | ||
e93ec1f7 | 317 | TIter nextdigitC(digitsC); |
318 | while ((digit = dynamic_cast<AliEMCALDigit*>(nextdigitC()))) { // scan over the list of digitsC | |
319 | ||
89504c57 | 320 | fGeom->GetCellIndex (digit->GetId(), nSupMod, nModule, nIphi, nIeta); |
321 | fGeom->GetCellPhiEtaIndexInSModule (nSupMod, nModule, nIphi, nIeta, iphi, ieta); | |
322 | ||
27bad386 | 323 | Int_t iphi_eff = iphi - fShiftPhi * ishiftPhi + nPhiDigitsSupMod * (nSupMod / 2); // N supermodules along phi |
89504c57 | 324 | |
325 | Int_t iTRUphi = iphi_eff / nPhiDigits; | |
326 | ||
327 | iphi_eff -= iTRUphi * nPhiDigits; | |
328 | ||
27bad386 | 329 | Int_t iClusPhi = iphi_eff / fNphi; |
89504c57 | 330 | |
331 | if (iphi_eff < 0 || iClusPhi >= nClusPhi) | |
332 | continue; | |
333 | ||
27bad386 | 334 | Int_t ieta_eff = ieta - fShiftEta * ishiftEta + nEtaDigitsSupMod * (nSupMod % 2); // 2 supermodules along eta |
89504c57 | 335 | |
336 | Int_t iTRUeta = ieta_eff / nEtaDigits; | |
337 | ||
338 | ieta_eff -= iTRUeta * nEtaDigits; | |
339 | ||
27bad386 | 340 | Int_t iClusEta = ieta_eff / fNeta; |
89504c57 | 341 | |
342 | if (ieta_eff < 0 || iClusEta >= nClusEta) | |
343 | continue; | |
344 | ||
345 | iphi_eff += iTRUphi * nPhiDigits; | |
27bad386 | 346 | iClusPhi = iphi_eff / fNphi; |
89504c57 | 347 | |
348 | ieta_eff += iTRUeta * nEtaDigits; | |
27bad386 | 349 | iClusEta = ieta_eff / fNeta; |
89504c57 | 350 | |
351 | Int_t iCluster = iClusPhi + iClusEta * nClusPhiNoShift * nTRUPhi; | |
27bad386 | 352 | Int_t iDigit = iphi_eff % fNphi + (ieta_eff % fNeta) * fNphi; |
89504c57 | 353 | |
27bad386 | 354 | if (iCluster >= nClusters){ |
355 | AliWarning(Form("iCluster out of range! iCluster = %d, nClusters = %d", iCluster, nClusters)); | |
89504c57 | 356 | return; |
357 | } | |
358 | ||
359 | iCluster += iTotalClus; | |
360 | ||
27bad386 | 361 | if (fClustersArray[iCluster] == NULL){ |
89504c57 | 362 | fNumberOfECAClusters++; |
27bad386 | 363 | fClustersArray[iCluster] = new AliEMCALDigit*[nDigitsCluster]; |
364 | for (Int_t i = 0; i < nDigitsCluster; i++){ | |
365 | fClustersArray[iCluster][i] = NULL; | |
89504c57 | 366 | } |
89504c57 | 367 | } |
368 | ||
27bad386 | 369 | if (fClustersArray[iCluster][iDigit] != NULL){ |
370 | AliWarning("Digit already added!"); | |
89504c57 | 371 | return; |
372 | } | |
373 | ||
27bad386 | 374 | fClustersArray[iCluster][iDigit] = digit; |
89504c57 | 375 | |
376 | } // loop on digit | |
377 | ||
378 | } // loop on eta shift | |
379 | ||
06ca320f | 380 | } // loop on phi shift |
89504c57 | 381 | |
641122eb | 382 | if(fNumberOfECAClusters >= fRecPoints->GetSize()) |
383 | fRecPoints->Expand(fNumberOfECAClusters+1); | |
384 | ||
89504c57 | 385 | Int_t iRecPoint = 0; |
641122eb | 386 | for (Int_t iCluster = 0; iCluster < nTotalClus; iCluster++) { |
89504c57 | 387 | |
641122eb | 388 | if (fClustersArray[iCluster] == NULL) |
389 | continue; | |
390 | ||
06ca320f | 391 | (*fRecPoints)[iRecPoint] = new AliEMCALRecPoint(""); |
392 | AliEMCALRecPoint *recPoint = dynamic_cast<AliEMCALRecPoint*> (fRecPoints->At(iRecPoint)); | |
89504c57 | 393 | |
06ca320f | 394 | if (recPoint) { |
395 | iRecPoint++; | |
396 | recPoint->SetClusterType(AliVCluster::kEMCALClusterv1); | |
397 | recPoint->SetUniqueID(iCluster); | |
27bad386 | 398 | |
06ca320f | 399 | for (Int_t iDigit = 0; iDigit < nDigitsCluster; iDigit++){ |
400 | if (fClustersArray[iCluster][iDigit] == NULL) continue; | |
401 | digit = fClustersArray[iCluster][iDigit]; | |
e93ec1f7 | 402 | recPoint->AddDigit(*digit, digit->GetCalibAmp(), kFALSE); //Time or TimeR? |
27bad386 | 403 | fClustersArray[iCluster][iDigit] = NULL; |
06ca320f | 404 | } |
405 | } | |
89504c57 | 406 | |
27bad386 | 407 | delete[] fClustersArray[iCluster]; |
408 | fClustersArray[iCluster] = NULL; | |
06ca320f | 409 | } |
39779e58 | 410 | |
411 | delete digitsC; | |
06ca320f | 412 | AliDebug(1, Form("MakeClusters: Number of digits %d -> (e %f)\n", fDigitsArr->GetEntries(),fMinECut)); |
06ca320f | 413 | AliDebug(1, Form("total no of clusters %d from %d digits", fNumberOfECAClusters, fDigitsArr->GetEntriesFast())); |
89504c57 | 414 | } |