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