]>
Commit | Line | Data |
---|---|---|
765d44e7 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | /* $Id: $ */ | |
16 | ||
17 | //_________________________________________________________________________ | |
18 | // Class utility for Calorimeter specific selection methods /// | |
19 | // | |
20 | // | |
21 | // | |
22 | //-- Author: Gustavo Conesa (LPSC-Grenoble) | |
23 | ////////////////////////////////////////////////////////////////////////////// | |
24 | ||
25 | ||
26 | // --- ROOT system --- | |
27 | #include "TGeoManager.h" | |
28 | ||
29 | //---- ANALYSIS system ---- | |
30 | #include "AliCalorimeterUtils.h" | |
4b892846 | 31 | #include "AliESDEvent.h" |
46a3cde6 | 32 | #include "AliMCEvent.h" |
33 | #include "AliStack.h" | |
765d44e7 | 34 | #include "AliAODPWG4Particle.h" |
c8fe2783 | 35 | #include "AliVCluster.h" |
36 | #include "AliVCaloCells.h" | |
37 | #include "AliMixedEvent.h" | |
765d44e7 | 38 | |
39 | ClassImp(AliCalorimeterUtils) | |
40 | ||
41 | ||
42 | //____________________________________________________________________________ | |
43 | AliCalorimeterUtils::AliCalorimeterUtils() : | |
44 | TObject(), fDebug(0), | |
7e4e67ab | 45 | fEMCALGeoName("EMCAL_COMPLETEV1"),fPHOSGeoName("PHOSgeo"), |
9e8998b1 | 46 | fEMCALGeo(0x0), fPHOSGeo(0x0), |
47 | fEMCALGeoMatrixSet(kFALSE), fPHOSGeoMatrixSet(kFALSE), | |
48 | fLoadEMCALMatrices(kFALSE), fLoadPHOSMatrices(kFALSE), | |
49 | fRemoveBadChannels(kFALSE), fPHOSBadChannelMap(0x0), | |
a5fb4114 | 50 | fNCellsFromPHOSBorder(0), |
9e8998b1 | 51 | fNMaskCellColumns(0), fMaskCellColumns(0x0), |
52 | fRecalibration(kFALSE), fPHOSRecalibrationFactors(), | |
247abff4 | 53 | fEMCALRecoUtils(new AliEMCALRecoUtils), |
9e8998b1 | 54 | fRecalculatePosition(kFALSE), fCorrectELinearity(kFALSE), |
55 | fRecalculateMatching(kFALSE), | |
56 | fCutR(20), fCutZ(20), | |
57 | fCutEta(20), fCutPhi(20) | |
765d44e7 | 58 | { |
59 | //Ctor | |
60 | ||
61 | //Initialize parameters | |
62 | InitParameters(); | |
3b13c34c | 63 | for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ; |
64 | for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ; | |
7cc7d3f8 | 65 | |
765d44e7 | 66 | } |
765d44e7 | 67 | |
68 | //_________________________________ | |
69 | AliCalorimeterUtils::~AliCalorimeterUtils() { | |
70 | //Dtor | |
71 | ||
4df35693 | 72 | //if(fPHOSGeo) delete fPHOSGeo ; |
765d44e7 | 73 | if(fEMCALGeo) delete fEMCALGeo ; |
7cc7d3f8 | 74 | |
765d44e7 | 75 | if(fPHOSBadChannelMap) { |
76 | fPHOSBadChannelMap->Clear(); | |
77 | delete fPHOSBadChannelMap; | |
78 | } | |
79 | ||
09e819c9 | 80 | if(fPHOSRecalibrationFactors) { |
78219bac | 81 | fPHOSRecalibrationFactors->Clear(); |
82 | delete fPHOSRecalibrationFactors; | |
09e819c9 | 83 | } |
84 | ||
a5fb4114 | 85 | if(fEMCALRecoUtils) delete fEMCALRecoUtils ; |
86 | if(fNMaskCellColumns) delete [] fMaskCellColumns; | |
9584c261 | 87 | |
765d44e7 | 88 | } |
89 | ||
90 | //_______________________________________________________________ | |
c8fe2783 | 91 | Bool_t AliCalorimeterUtils::CheckCellFiducialRegion(AliVCluster* cluster, AliVCaloCells* cells, AliVEvent * event, Int_t iev) const { |
7cc7d3f8 | 92 | |
765d44e7 | 93 | // Given the list of AbsId of the cluster, get the maximum cell and |
94 | // check if there are fNCellsFromBorder from the calorimeter border | |
95 | ||
7cc7d3f8 | 96 | //If the distance to the border is 0 or negative just exit accept all clusters |
247abff4 | 97 | if(cells->GetType()==AliVCaloCells::kEMCALCell && fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder() <= 0 ) return kTRUE; |
c8fe2783 | 98 | if(cells->GetType()==AliVCaloCells::kPHOSCell && fNCellsFromPHOSBorder <= 0 ) return kTRUE; |
7cc7d3f8 | 99 | |
c8fe2783 | 100 | Int_t absIdMax = -1; |
765d44e7 | 101 | Float_t ampMax = -1; |
c8fe2783 | 102 | |
103 | AliMixedEvent * mixEvent = dynamic_cast<AliMixedEvent*> (event); | |
104 | Int_t nMixedEvents = 0 ; | |
105 | Int_t * cellsCumul = NULL ; | |
106 | Int_t numberOfCells = 0 ; | |
107 | if (mixEvent){ | |
108 | nMixedEvents = mixEvent->GetNumberOfEvents() ; | |
109 | if (cells->GetType()==AliVCaloCells::kEMCALCell) { | |
110 | cellsCumul = mixEvent->GetEMCALCellsCumul() ; | |
111 | numberOfCells = mixEvent->GetNumberOfEMCALCells() ; | |
112 | } | |
7cc7d3f8 | 113 | |
c8fe2783 | 114 | else if (cells->GetType()==AliVCaloCells::kPHOSCell) { |
115 | cellsCumul = mixEvent->GetPHOSCellsCumul() ; | |
116 | numberOfCells = mixEvent->GetNumberOfPHOSCells() ; | |
117 | } | |
898c9d44 | 118 | |
119 | if(cellsCumul){ | |
120 | ||
121 | Int_t startCell = cellsCumul[iev] ; | |
122 | Int_t endCell = (iev+1 < nMixedEvents)?cellsCumul[iev+1]:numberOfCells; | |
c8fe2783 | 123 | //Find cells with maximum amplitude |
898c9d44 | 124 | for(Int_t i = 0; i < cluster->GetNCells() ; i++){ |
125 | Int_t absId = cluster->GetCellAbsId(i) ; | |
126 | for (Int_t j = startCell; j < endCell ; j++) { | |
127 | Short_t cellNumber; | |
128 | Double_t amp ; | |
129 | Double_t time; | |
130 | cells->GetCell(j, cellNumber, amp, time) ; | |
131 | if (absId == cellNumber) { | |
132 | if(amp > ampMax){ | |
133 | ampMax = amp; | |
134 | absIdMax = absId; | |
135 | } | |
136 | } | |
c8fe2783 | 137 | } |
898c9d44 | 138 | }//loop on cluster cells |
139 | }// cells cumul available | |
140 | else { | |
141 | printf("AliCalorimeterUtils::CheckCellFiducialRegion() - CellsCumul is NULL!!!\n"); | |
142 | abort(); | |
c8fe2783 | 143 | } |
898c9d44 | 144 | } else {//Normal SE Events |
c8fe2783 | 145 | for(Int_t i = 0; i < cluster->GetNCells() ; i++){ |
146 | Int_t absId = cluster->GetCellAbsId(i) ; | |
147 | Float_t amp = cells->GetCellAmplitude(absId); | |
148 | if(amp > ampMax){ | |
149 | ampMax = amp; | |
150 | absIdMax = absId; | |
151 | } | |
152 | } | |
153 | } | |
765d44e7 | 154 | |
155 | if(fDebug > 1) | |
280e6766 | 156 | printf("AliCalorimeterUtils::CheckCellFiducialRegion() - Cluster Max AbsId %d, Cell Energy %2.2f, Cluster Energy %2.2f\n", |
7cc7d3f8 | 157 | absIdMax, ampMax, cluster->E()); |
765d44e7 | 158 | |
159 | if(absIdMax==-1) return kFALSE; | |
160 | ||
161 | //Check if the cell is close to the borders: | |
162 | Bool_t okrow = kFALSE; | |
163 | Bool_t okcol = kFALSE; | |
7cc7d3f8 | 164 | |
c8fe2783 | 165 | if(cells->GetType()==AliVCaloCells::kEMCALCell){ |
7cc7d3f8 | 166 | |
765d44e7 | 167 | Int_t iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1, iSM = -1; |
168 | fEMCALGeo->GetCellIndex(absIdMax,iSM,iTower,iIphi,iIeta); | |
169 | fEMCALGeo->GetCellPhiEtaIndexInSModule(iSM,iTower,iIphi, iIeta,iphi,ieta); | |
280e6766 | 170 | if(iSM < 0 || iphi < 0 || ieta < 0 ) { |
171 | Fatal("CheckCellFidutialRegion","Negative value for super module: %d, or cell ieta: %d, or cell iphi: %d, check EMCAL geometry name\n",iSM,ieta,iphi); | |
172 | } | |
7cc7d3f8 | 173 | |
765d44e7 | 174 | //Check rows/phi |
247abff4 | 175 | Int_t nborder = fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(); |
765d44e7 | 176 | if(iSM < 10){ |
247abff4 | 177 | if(iphi >= nborder && iphi < 24-nborder) okrow =kTRUE; |
7cc7d3f8 | 178 | } |
765d44e7 | 179 | else{ |
247abff4 | 180 | if(iphi >= nborder && iphi < 12-nborder) okrow =kTRUE; |
765d44e7 | 181 | } |
182 | ||
247abff4 | 183 | //Check columns/eta |
184 | if(!fEMCALRecoUtils->IsEMCALNoBorderAtEta0()){ | |
185 | if(ieta > nborder && ieta < 48-nborder) okcol =kTRUE; | |
765d44e7 | 186 | } |
187 | else{ | |
188 | if(iSM%2==0){ | |
247abff4 | 189 | if(ieta >= nborder) okcol = kTRUE; |
765d44e7 | 190 | } |
191 | else { | |
247abff4 | 192 | if(ieta < 48-nborder) okcol = kTRUE; |
765d44e7 | 193 | } |
194 | }//eta 0 not checked | |
195 | if(fDebug > 1) | |
196 | { | |
280e6766 | 197 | printf("AliCalorimeterUtils::CheckCellFiducialRegion() - EMCAL Cluster in %d cells fiducial volume: ieta %d, iphi %d, SM %d ?", |
7cc7d3f8 | 198 | nborder, ieta, iphi, iSM); |
765d44e7 | 199 | if (okcol && okrow ) printf(" YES \n"); |
200 | else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow); | |
201 | } | |
202 | }//EMCAL | |
c8fe2783 | 203 | else if(cells->GetType()==AliVCaloCells::kPHOSCell){ |
765d44e7 | 204 | Int_t relId[4]; |
205 | Int_t irow = -1, icol = -1; | |
206 | fPHOSGeo->AbsToRelNumbering(absIdMax,relId); | |
207 | irow = relId[2]; | |
208 | icol = relId[3]; | |
209 | //imod = relId[0]-1; | |
210 | if(irow >= fNCellsFromPHOSBorder && irow < 64-fNCellsFromPHOSBorder) okrow =kTRUE; | |
211 | if(icol >= fNCellsFromPHOSBorder && icol < 56-fNCellsFromPHOSBorder) okcol =kTRUE; | |
212 | if(fDebug > 1) | |
213 | { | |
280e6766 | 214 | printf("AliCalorimeterUtils::CheckCellFiducialRegion() - PHOS Cluster in %d cells fiducial volume: icol %d, irow %d, Module %d?", |
7cc7d3f8 | 215 | fNCellsFromPHOSBorder, icol, irow, relId[0]-1); |
765d44e7 | 216 | if (okcol && okrow ) printf(" YES \n"); |
217 | else printf(" NO: column ok? %d, row ok? %d \n",okcol,okrow); | |
218 | } | |
219 | }//PHOS | |
220 | ||
221 | if (okcol && okrow) return kTRUE; | |
222 | else return kFALSE; | |
223 | ||
224 | } | |
225 | ||
765d44e7 | 226 | //_________________________________________________________________________________________________________ |
227 | Bool_t AliCalorimeterUtils::ClusterContainsBadChannel(TString calorimeter,UShort_t* cellList, Int_t nCells){ | |
228 | // Check that in the cluster cells, there is no bad channel of those stored | |
229 | // in fEMCALBadChannelMap or fPHOSBadChannelMap | |
230 | ||
231 | if (!fRemoveBadChannels) return kFALSE; | |
36037088 | 232 | //printf("fEMCALBadChannelMap %p, fPHOSBadChannelMap %p \n",fEMCALBadChannelMap,fPHOSBadChannelMap); |
247abff4 | 233 | if(calorimeter == "EMCAL" && !fEMCALRecoUtils->GetEMCALChannelStatusMap(0)) return kFALSE; |
78219bac | 234 | if(calorimeter == "PHOS" && !fPHOSBadChannelMap) return kFALSE; |
7cc7d3f8 | 235 | |
765d44e7 | 236 | Int_t icol = -1; |
237 | Int_t irow = -1; | |
238 | Int_t imod = -1; | |
239 | for(Int_t iCell = 0; iCell<nCells; iCell++){ | |
7cc7d3f8 | 240 | |
765d44e7 | 241 | //Get the column and row |
242 | if(calorimeter == "EMCAL"){ | |
247abff4 | 243 | return fEMCALRecoUtils->ClusterContainsBadChannel((AliEMCALGeometry*)fEMCALGeo,cellList,nCells); |
765d44e7 | 244 | } |
245 | else if(calorimeter=="PHOS"){ | |
246 | Int_t relId[4]; | |
247 | fPHOSGeo->AbsToRelNumbering(cellList[iCell],relId); | |
248 | irow = relId[2]; | |
249 | icol = relId[3]; | |
250 | imod = relId[0]-1; | |
251 | if(fPHOSBadChannelMap->GetEntries() <= imod)continue; | |
252 | if(GetPHOSChannelStatus(imod, icol, irow)) return kTRUE; | |
253 | } | |
254 | else return kFALSE; | |
255 | ||
256 | }// cell cluster loop | |
7cc7d3f8 | 257 | |
765d44e7 | 258 | return kFALSE; |
7cc7d3f8 | 259 | |
765d44e7 | 260 | } |
261 | ||
9584c261 | 262 | //____________________________________________________________________________________________________________________________________________________ |
263 | void AliCalorimeterUtils::CorrectClusterEnergy(AliVCluster *clus){ | |
264 | // Correct cluster energy non linearity | |
13cd2872 | 265 | |
9584c261 | 266 | clus->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(clus)); |
13cd2872 | 267 | |
268 | } | |
269 | ||
270 | //____________________________________________________________________________________________________________________________________________________ | |
271 | Int_t AliCalorimeterUtils::GetMaxEnergyCell(AliVCaloCells* cells, AliVCluster* clu, Float_t & clusterFraction) const { | |
272 | ||
273 | //For a given CaloCluster gets the absId of the cell | |
274 | //with maximum energy deposit. | |
275 | ||
276 | if( !clu || !cells ){ | |
277 | AliInfo("Cluster or cells pointer is null!"); | |
278 | return -1; | |
279 | } | |
280 | ||
281 | Double_t eMax =-1.; | |
282 | Double_t eTot = 0.; | |
283 | Double_t eCell =-1.; | |
284 | Float_t fraction = 1.; | |
285 | Float_t recalFactor = 1.; | |
286 | Int_t cellAbsId =-1 , absId =-1 ; | |
287 | Int_t iSupMod =-1 , ieta =-1 , iphi = -1, iRCU = -1; | |
288 | ||
289 | TString calo = "EMCAL"; | |
290 | if(clu->IsPHOS()) calo = "PHOS"; | |
291 | ||
292 | for (Int_t iDig=0; iDig< clu->GetNCells(); iDig++) { | |
293 | ||
294 | cellAbsId = clu->GetCellAbsId(iDig); | |
295 | ||
296 | fraction = clu->GetCellAmplitudeFraction(iDig); | |
297 | if(fraction < 1e-4) fraction = 1.; // in case unfolding is off | |
298 | ||
b08dd6d5 | 299 | iSupMod = GetModuleNumberCellIndexes(cellAbsId, calo, ieta, iphi, iRCU); |
13cd2872 | 300 | |
301 | if(IsRecalibrationOn()) { | |
302 | if(calo=="EMCAL") recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi); | |
303 | else recalFactor = GetPHOSChannelRecalibrationFactor(iSupMod,ieta,iphi); | |
304 | } | |
305 | ||
306 | eCell = cells->GetCellAmplitude(cellAbsId)*fraction*recalFactor; | |
307 | ||
308 | if(eCell > eMax) { | |
309 | eMax = eCell; | |
310 | absId = cellAbsId; | |
311 | } | |
312 | ||
313 | eTot+=eCell; | |
314 | ||
315 | }// cell loop | |
316 | ||
317 | clusterFraction = (eTot-eMax)/eTot; //Do not use cluster energy in case it was corrected for non linearity. | |
318 | ||
319 | return absId; | |
320 | ||
9584c261 | 321 | } |
322 | ||
765d44e7 | 323 | //____________________________________________________________________________________________________________________________________________________ |
324 | Int_t AliCalorimeterUtils::GetModuleNumber(AliAODPWG4Particle * particle, AliVEvent * inputEvent) const | |
325 | { | |
326 | //Get the EMCAL/PHOS module number that corresponds to this particle | |
327 | ||
328 | Int_t absId = -1; | |
329 | if(particle->GetDetector()=="EMCAL"){ | |
330 | fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId); | |
331 | if(fDebug > 2) | |
332 | printf("AliCalorimeterUtils::GetModuleNumber(PWG4AOD) - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n", | |
7cc7d3f8 | 333 | particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId)); |
765d44e7 | 334 | return fEMCALGeo->GetSuperModuleNumber(absId) ; |
335 | }//EMCAL | |
336 | else if(particle->GetDetector()=="PHOS"){ | |
46a3cde6 | 337 | // In case we use the MC reader, the input are TParticles, |
338 | // in this case use the corresponing method in PHOS Geometry to get the particle. | |
339 | if(strcmp(inputEvent->ClassName(), "AliMCEvent") == 0 ) | |
340 | { | |
341 | Int_t mod =-1; | |
342 | Double_t z = 0., x=0.; | |
343 | TParticle* primary = 0x0; | |
344 | AliStack * stack = ((AliMCEvent*)inputEvent)->Stack(); | |
345 | if(stack) { | |
346 | primary = stack->Particle(particle->GetCaloLabel(0)); | |
347 | } | |
348 | else { | |
280e6766 | 349 | Fatal("GetModuleNumber(PWG4AOD)", "Stack not available, stop!"); |
46a3cde6 | 350 | } |
898c9d44 | 351 | |
352 | if(primary){ | |
353 | fPHOSGeo->ImpactOnEmc(primary,mod,z,x) ; | |
354 | } | |
355 | else{ | |
356 | Fatal("GetModuleNumber(PWG4AOD)", "Primary not available, stop!"); | |
357 | } | |
46a3cde6 | 358 | return mod; |
359 | } | |
360 | // Input are ESDs or AODs, get the PHOS module number like this. | |
361 | else{ | |
2206e918 | 362 | //FIXME |
363 | //AliVCluster *cluster = inputEvent->GetCaloCluster(particle->GetCaloLabel(0)); | |
364 | //return GetModuleNumber(cluster); | |
365 | //MEFIX | |
366 | return -1; | |
46a3cde6 | 367 | } |
765d44e7 | 368 | }//PHOS |
369 | ||
370 | return -1; | |
371 | } | |
372 | ||
373 | //____________________________________________________________________________________________________________________________________________________ | |
c8fe2783 | 374 | Int_t AliCalorimeterUtils::GetModuleNumber(AliVCluster * cluster) const |
765d44e7 | 375 | { |
280e6766 | 376 | //Get the EMCAL/PHOS module number that corresponds to this cluster |
765d44e7 | 377 | TLorentzVector lv; |
378 | Double_t v[]={0.,0.,0.}; //not necessary to pass the real vertex. | |
9cbbc28b | 379 | if(!cluster){ |
380 | if(fDebug > 1) printf("AliCalorimeterUtils::GetModuleNumber() - NUL Cluster, please check!!!"); | |
381 | return -1; | |
382 | } | |
765d44e7 | 383 | cluster->GetMomentum(lv,v); |
384 | Float_t phi = lv.Phi(); | |
385 | if(phi < 0) phi+=TMath::TwoPi(); | |
386 | Int_t absId = -1; | |
c8fe2783 | 387 | if(cluster->IsEMCAL()){ |
765d44e7 | 388 | fEMCALGeo->GetAbsCellIdFromEtaPhi(lv.Eta(),phi, absId); |
389 | if(fDebug > 2) | |
280e6766 | 390 | printf("AliCalorimeterUtils::GetModuleNumber() - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n", |
7cc7d3f8 | 391 | lv.Eta(), phi*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId)); |
765d44e7 | 392 | return fEMCALGeo->GetSuperModuleNumber(absId) ; |
393 | }//EMCAL | |
c8fe2783 | 394 | else if(cluster->IsPHOS()) { |
765d44e7 | 395 | Int_t relId[4]; |
396 | if ( cluster->GetNCells() > 0) { | |
397 | absId = cluster->GetCellAbsId(0); | |
398 | if(fDebug > 2) | |
280e6766 | 399 | printf("AliCalorimeterUtils::GetModuleNumber() - PHOS: cluster eta %f, phi %f, e %f, absId %d\n", |
7cc7d3f8 | 400 | lv.Eta(), phi*TMath::RadToDeg(), lv.E(), absId); |
765d44e7 | 401 | } |
402 | else return -1; | |
403 | ||
404 | if ( absId >= 0) { | |
405 | fPHOSGeo->AbsToRelNumbering(absId,relId); | |
406 | if(fDebug > 2) | |
280e6766 | 407 | printf("AliCalorimeterUtils::GetModuleNumber() - PHOS: Module %d\n",relId[0]-1); |
765d44e7 | 408 | return relId[0]-1; |
409 | } | |
410 | else return -1; | |
411 | }//PHOS | |
412 | ||
413 | return -1; | |
414 | } | |
415 | ||
765d44e7 | 416 | //_____________________________________________________________________________________________________________ |
417 | Int_t AliCalorimeterUtils::GetModuleNumberCellIndexes(const Int_t absId, const TString calo, Int_t & icol, Int_t & irow, Int_t & iRCU) const | |
418 | { | |
419 | //Get the EMCAL/PHOS module, columns, row and RCU number that corresponds to this absId | |
420 | Int_t imod = -1; | |
421 | if ( absId >= 0) { | |
422 | if(calo=="EMCAL"){ | |
423 | Int_t iTower = -1, iIphi = -1, iIeta = -1; | |
424 | fEMCALGeo->GetCellIndex(absId,imod,iTower,iIphi,iIeta); | |
425 | fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,irow,icol); | |
280e6766 | 426 | if(imod < 0 || irow < 0 || icol < 0 ) { |
427 | Fatal("GetModuleNumberCellIndexes()","Negative value for super module: %d, or cell icol: %d, or cell irow: %d, check EMCAL geometry name\n",imod,icol,irow); | |
428 | } | |
429 | ||
765d44e7 | 430 | //RCU0 |
431 | if (0<=irow&&irow<8) iRCU=0; // first cable row | |
432 | else if (8<=irow&&irow<16 && 0<=icol&&icol<24) iRCU=0; // first half; | |
433 | //second cable row | |
434 | //RCU1 | |
435 | else if(8<=irow&&irow<16 && 24<=icol&&icol<48) iRCU=1; // second half; | |
436 | //second cable row | |
437 | else if(16<=irow&&irow<24) iRCU=1; // third cable row | |
438 | ||
439 | if (imod%2==1) iRCU = 1 - iRCU; // swap for odd=C side, to allow us to cable both sides the same | |
440 | if (iRCU<0) { | |
280e6766 | 441 | Fatal("GetModuleNumberCellIndexes()","Wrong EMCAL RCU number = %d\n", iRCU); |
765d44e7 | 442 | } |
443 | ||
444 | return imod ; | |
445 | }//EMCAL | |
446 | else{//PHOS | |
447 | Int_t relId[4]; | |
448 | fPHOSGeo->AbsToRelNumbering(absId,relId); | |
449 | irow = relId[2]; | |
450 | icol = relId[3]; | |
451 | imod = relId[0]-1; | |
452 | iRCU= (Int_t)(relId[2]-1)/16 ; | |
453 | //Int_t iBranch= (Int_t)(relid[3]-1)/28 ; //0 to 1 | |
454 | if (iRCU >= 4) { | |
280e6766 | 455 | Fatal("GetModuleNumberCellIndexes()","Wrong PHOS RCU number = %d\n", iRCU); |
765d44e7 | 456 | } |
457 | return imod; | |
458 | }//PHOS | |
459 | } | |
460 | ||
461 | return -1; | |
462 | } | |
463 | ||
464 | //_______________________________________________________________ | |
465 | //void AliCalorimeterUtils::Init() | |
466 | //{ | |
467 | // //Init reader. Method to be called in AliAnaPartCorrMaker | |
468 | // | |
469 | // fEMCALBadChannelMap->SetName(Form("EMCALBadMap_%s",fTaskName.Data())); | |
470 | // fPHOSBadChannelMap->SetName(Form("PHOSBadMap_%s",fTaskName.Data())); | |
471 | //} | |
472 | ||
473 | //_______________________________________________________________ | |
474 | void AliCalorimeterUtils::InitParameters() | |
475 | { | |
476 | //Initialize the parameters of the analysis. | |
7cc7d3f8 | 477 | fEMCALGeoName = "EMCAL_COMPLETEV1"; |
478 | fPHOSGeoName = "PHOSgeo"; | |
479 | fEMCALGeoMatrixSet = kFALSE; | |
480 | fPHOSGeoMatrixSet = kFALSE; | |
481 | fRemoveBadChannels = kFALSE; | |
482 | fNCellsFromPHOSBorder = 0; | |
a5fb4114 | 483 | |
7cc7d3f8 | 484 | // fMaskCellColumns = new Int_t[fNMaskCellColumns]; |
485 | // fMaskCellColumns[0] = 6 ; fMaskCellColumns[1] = 7 ; fMaskCellColumns[2] = 8 ; | |
486 | // fMaskCellColumns[3] = 35; fMaskCellColumns[4] = 36; fMaskCellColumns[5] = 37; | |
487 | // fMaskCellColumns[6] = 12+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[7] = 13+AliEMCALGeoParams::fgkEMCALCols; | |
488 | // fMaskCellColumns[8] = 40+AliEMCALGeoParams::fgkEMCALCols; fMaskCellColumns[9] = 41+AliEMCALGeoParams::fgkEMCALCols; | |
489 | // fMaskCellColumns[10]= 42+AliEMCALGeoParams::fgkEMCALCols; | |
a5fb4114 | 490 | |
765d44e7 | 491 | } |
492 | ||
765d44e7 | 493 | |
494 | //________________________________________________________________ | |
495 | void AliCalorimeterUtils::InitPHOSBadChannelStatusMap(){ | |
496 | //Init PHOS bad channels map | |
497 | if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSBadChannelStatusMap()\n"); | |
498 | //In order to avoid rewriting the same histograms | |
499 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
500 | TH1::AddDirectory(kFALSE); | |
7cc7d3f8 | 501 | |
78219bac | 502 | fPHOSBadChannelMap = new TObjArray(5); |
765d44e7 | 503 | for (int i = 0; i < 5; i++)fPHOSBadChannelMap->Add(new TH2I(Form("PHOSBadChannelMap_Mod%d",i),Form("PHOSBadChannelMap_Mod%d",i), 56, 0, 56, 64, 0, 64)); |
7cc7d3f8 | 504 | |
765d44e7 | 505 | fPHOSBadChannelMap->SetOwner(kTRUE); |
506 | fPHOSBadChannelMap->Compress(); | |
507 | ||
508 | //In order to avoid rewriting the same histograms | |
509 | TH1::AddDirectory(oldStatus); | |
510 | } | |
511 | ||
09e819c9 | 512 | //________________________________________________________________ |
513 | void AliCalorimeterUtils::InitPHOSRecalibrationFactors(){ | |
514 | //Init EMCAL recalibration factors | |
515 | if(fDebug > 0 )printf("AliCalorimeterUtils::InitPHOSRecalibrationFactors()\n"); | |
516 | //In order to avoid rewriting the same histograms | |
517 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
518 | TH1::AddDirectory(kFALSE); | |
7cc7d3f8 | 519 | |
78219bac | 520 | fPHOSRecalibrationFactors = new TObjArray(5); |
09e819c9 | 521 | for (int i = 0; i < 5; i++)fPHOSRecalibrationFactors->Add(new TH2F(Form("PHOSRecalFactors_Mod%d",i),Form("PHOSRecalFactors_Mod%d",i), 56, 0, 56, 64, 0, 64)); |
522 | //Init the histograms with 1 | |
523 | for (Int_t m = 0; m < 5; m++) { | |
524 | for (Int_t i = 0; i < 56; i++) { | |
525 | for (Int_t j = 0; j < 64; j++) { | |
526 | SetPHOSChannelRecalibrationFactor(m,i,j,1.); | |
527 | } | |
528 | } | |
529 | } | |
530 | fPHOSRecalibrationFactors->SetOwner(kTRUE); | |
531 | fPHOSRecalibrationFactors->Compress(); | |
532 | ||
533 | //In order to avoid rewriting the same histograms | |
534 | TH1::AddDirectory(oldStatus); | |
535 | } | |
536 | ||
537 | ||
765d44e7 | 538 | //________________________________________________________________ |
539 | void AliCalorimeterUtils::InitEMCALGeometry() | |
540 | { | |
541 | //Initialize EMCAL geometry if it did not exist previously | |
542 | if (!fEMCALGeo){ | |
a38a48f2 | 543 | fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName); |
765d44e7 | 544 | if(fDebug > 0){ |
545 | printf("AliCalorimeterUtils::InitEMCALGeometry()"); | |
546 | if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices"); | |
547 | printf("\n"); | |
548 | } | |
549 | } | |
550 | } | |
551 | ||
552 | //________________________________________________________________ | |
553 | void AliCalorimeterUtils::InitPHOSGeometry() | |
554 | { | |
555 | //Initialize PHOS geometry if it did not exist previously | |
556 | if (!fPHOSGeo){ | |
557 | fPHOSGeo = new AliPHOSGeoUtils(fPHOSGeoName); | |
558 | if(fDebug > 0){ | |
559 | printf("AliCalorimeterUtils::InitPHOSGeometry()"); | |
560 | if (!gGeoManager) printf(" - Careful!, gGeoManager not loaded, load misalign matrices"); | |
561 | printf("\n"); | |
562 | } | |
563 | } | |
564 | } | |
565 | ||
566 | //________________________________________________________________ | |
567 | void AliCalorimeterUtils::Print(const Option_t * opt) const | |
568 | { | |
7cc7d3f8 | 569 | |
765d44e7 | 570 | //Print some relevant parameters set for the analysis |
571 | if(! opt) | |
572 | return; | |
7cc7d3f8 | 573 | |
765d44e7 | 574 | printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ; |
575 | printf("Remove Clusters with bad channels? %d\n",fRemoveBadChannels); | |
576 | printf("Remove Clusters with max cell at less than %d cells from EMCAL border and %d cells from PHOS border\n", | |
7cc7d3f8 | 577 | fEMCALRecoUtils->GetNumberOfCellsFromEMCALBorder(), fNCellsFromPHOSBorder); |
247abff4 | 578 | if(fEMCALRecoUtils->IsEMCALNoBorderAtEta0()) printf("Do not remove EMCAL clusters at Eta = 0\n"); |
09e819c9 | 579 | printf("Recalibrate Clusters? %d\n",fRecalibration); |
9584c261 | 580 | printf("Recalculate Clusters Position? %d\n",fRecalculatePosition); |
581 | printf("Recalculate Clusters Energy? %d\n",fCorrectELinearity); | |
f2ccb5b8 | 582 | printf("Matching criteria: dR < %2.2f[cm], dZ < %2.2f[cm]\n",fCutR,fCutZ); |
7cc7d3f8 | 583 | |
765d44e7 | 584 | printf(" \n") ; |
585 | } | |
586 | ||
a5fb4114 | 587 | //__________________________________________________ |
588 | Bool_t AliCalorimeterUtils::MaskFrameCluster(const Int_t iSM, const Int_t ieta) const { | |
589 | //Check if cell is in one of the regions where we have significant amount | |
590 | //of material in front. Only EMCAL | |
591 | ||
592 | Int_t icol = ieta; | |
593 | if(iSM%2) icol+=48; // Impair SM, shift index [0-47] to [48-96] | |
594 | ||
595 | if (fNMaskCellColumns && fMaskCellColumns) { | |
596 | for (Int_t imask = 0; imask < fNMaskCellColumns; imask++) { | |
597 | if(icol==fMaskCellColumns[imask]) return kTRUE; | |
598 | } | |
599 | } | |
600 | ||
601 | return kFALSE; | |
602 | ||
603 | } | |
604 | ||
605 | ||
09e819c9 | 606 | //________________________________________________________________ |
c8fe2783 | 607 | Float_t AliCalorimeterUtils::RecalibrateClusterEnergy(AliVCluster * cluster, AliVCaloCells * cells){ |
09e819c9 | 608 | // Recalibrate the cluster energy, considering the recalibration map and the energy of the cells that compose the cluster. |
7cc7d3f8 | 609 | |
898c9d44 | 610 | //Initialize some used variables |
611 | Float_t energy = 0; | |
612 | Int_t absId = -1; | |
613 | Int_t icol = -1, irow = -1, iRCU = -1, module=1; | |
614 | Float_t factor = 1, frac = 0; | |
615 | ||
616 | if(cells) { | |
7cc7d3f8 | 617 | |
618 | //Get the cluster number of cells and list of absId, check what kind of cluster do we have. | |
619 | UShort_t * index = cluster->GetCellsAbsId() ; | |
620 | Double_t * fraction = cluster->GetCellsAmplitudeFraction() ; | |
621 | Int_t ncells = cluster->GetNCells(); | |
622 | TString calo = "EMCAL"; | |
623 | if(cluster->IsPHOS()) calo = "PHOS"; | |
624 | ||
625 | //Loop on the cells, get the cell amplitude and recalibration factor, multiply and and to the new energy | |
626 | for(Int_t icell = 0; icell < ncells; icell++){ | |
627 | absId = index[icell]; | |
628 | frac = fraction[icell]; | |
629 | if(frac < 1e-3) frac = 1; //in case of EMCAL, this is set as 0, not used. | |
630 | module = GetModuleNumberCellIndexes(absId,calo,icol,irow,iRCU); | |
631 | if(cluster->IsPHOS()) factor = GetPHOSChannelRecalibrationFactor (module,icol,irow); | |
632 | else factor = GetEMCALChannelRecalibrationFactor(module,icol,irow); | |
633 | if(fDebug>2) | |
634 | printf("AliCalorimeterUtils::RecalibrateClusterEnergy() - recalibrate cell: %s, module %d, col %d, row %d, cell fraction %f, recalibration factor %f, cell energy %f\n", | |
635 | calo.Data(),module,icol,irow,frac,factor,cells->GetCellAmplitude(absId)); | |
636 | ||
637 | energy += cells->GetCellAmplitude(absId)*factor*frac; | |
638 | } | |
639 | ||
640 | if(fDebug>1) | |
641 | printf("AliCalorimeterUtils::RecalibrateClusterEnergy() - Energy before %f, after %f\n",cluster->E(),energy); | |
898c9d44 | 642 | |
643 | }// cells available | |
644 | else{ | |
645 | Fatal("RecalibrateClusterEnergy()","Cells pointer does not exist!"); | |
646 | } | |
647 | ||
09e819c9 | 648 | return energy; |
09e819c9 | 649 | } |
650 | ||
765d44e7 | 651 | //________________________________________________________________ |
652 | void AliCalorimeterUtils::SetGeometryTransformationMatrices(AliVEvent* inputEvent) | |
653 | { | |
654 | //Set the calorimeters transformation matrices | |
7cc7d3f8 | 655 | |
765d44e7 | 656 | //Get the EMCAL transformation geometry matrices from ESD |
3b13c34c | 657 | if(!fEMCALGeoMatrixSet && fEMCALGeo){ |
658 | if(fLoadEMCALMatrices){ | |
659 | printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load user defined geometry matrices\n"); | |
660 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ | |
661 | if(fEMCALMatrix[mod]){ | |
662 | if(fDebug > 1) | |
663 | fEMCALMatrix[mod]->Print(); | |
664 | fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ; | |
665 | } | |
666 | }//SM loop | |
667 | fEMCALGeoMatrixSet = kTRUE;//At least one, so good | |
668 | ||
669 | }//Load matrices | |
670 | else if (!gGeoManager) { | |
7cc7d3f8 | 671 | |
3b13c34c | 672 | if(fDebug > 1) |
673 | printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load EMCAL misalignment matrices. \n"); | |
674 | if(!strcmp(inputEvent->GetName(),"AliESDEvent")) { | |
675 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ | |
7cc7d3f8 | 676 | //printf("Load ESD matrix %d, %p\n",mod,((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod)); |
4b892846 | 677 | if(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod)) { |
678 | fEMCALGeo->SetMisalMatrix(((AliESDEvent*)inputEvent)->GetEMCALMatrix(mod),mod) ; | |
3b13c34c | 679 | } |
680 | }// loop over super modules | |
681 | fEMCALGeoMatrixSet = kTRUE;//At least one, so good | |
682 | ||
683 | }//ESD as input | |
684 | else { | |
685 | if(fDebug > 1) | |
686 | printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n"); | |
687 | }//AOD as input | |
688 | }//Get matrix from data | |
04131edb | 689 | else if(gGeoManager){ |
690 | fEMCALGeoMatrixSet = kTRUE; | |
691 | } | |
765d44e7 | 692 | }//EMCAL geo && no geoManager |
693 | ||
694 | //Get the PHOS transformation geometry matrices from ESD | |
3b13c34c | 695 | if(!fPHOSGeoMatrixSet && fPHOSGeo){ |
696 | if(fLoadPHOSMatrices){ | |
697 | printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load user defined geometry matrices\n"); | |
698 | for(Int_t mod=0; mod < 5; mod++){ | |
699 | if(fPHOSMatrix[mod]){ | |
700 | if(fDebug > 1) | |
701 | fPHOSMatrix[mod]->Print(); | |
702 | fPHOSGeo->SetMisalMatrix(fPHOSMatrix[mod],mod) ; | |
703 | } | |
704 | }//SM loop | |
705 | fPHOSGeoMatrixSet = kTRUE;//At least one, so good | |
706 | }//Load matrices | |
707 | else if (!gGeoManager) { | |
708 | if(fDebug > 1) | |
709 | printf(" AliCalorimeterUtils::SetGeometryTransformationMatrices() - Load PHOS misalignment matrices. \n"); | |
765d44e7 | 710 | if(!strcmp(inputEvent->GetName(),"AliESDEvent")) { |
711 | for(Int_t mod=0; mod < 5; mod++){ | |
4b892846 | 712 | if( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod)) { |
765d44e7 | 713 | //printf("PHOS: mod %d, matrix %p\n",mod, ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod)); |
4b892846 | 714 | fPHOSGeo->SetMisalMatrix( ((AliESDEvent*)inputEvent)->GetPHOSMatrix(mod),mod) ; |
765d44e7 | 715 | } |
3b13c34c | 716 | }// loop over modules |
717 | fPHOSGeoMatrixSet = kTRUE; //At least one so good | |
765d44e7 | 718 | }//ESD as input |
719 | else { | |
720 | if(fDebug > 1) | |
721 | printf("AliCalorimeterUtils::SetGeometryTransformationMatrices() - Setting of EMCAL transformation matrixes for AODs not implemented yet. \n Import geometry.root file\n"); | |
3b13c34c | 722 | }//AOD as input |
723 | }// get matrix from data | |
04131edb | 724 | else if(gGeoManager){ |
725 | fPHOSGeoMatrixSet = kTRUE; | |
726 | } | |
765d44e7 | 727 | }//PHOS geo and geoManager was not set |
765d44e7 | 728 | } |
729 | ||
9584c261 | 730 | //________________________________________________________________ |
731 | void AliCalorimeterUtils::RecalculateClusterPosition(AliVCaloCells* cells, AliVCluster* clu){ | |
732 | ||
733 | //Recalculate EMCAL cluster position | |
734 | ||
19db8f8c | 735 | fEMCALRecoUtils->RecalculateClusterPosition((AliEMCALGeometry*)fEMCALGeo, cells,clu); |
7cc7d3f8 | 736 | |
9584c261 | 737 | } |