]>
Commit | Line | Data |
---|---|---|
2c780493 | 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 | ||
16 | // $Id$ | |
78649106 | 17 | |
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
2c780493 | 19 | /// \class AliMUONPadStatusMaker |
20 | /// | |
21 | /// Make a 2DStore of pad statuses, using different sources of information, | |
22 | /// like pedestal values, gain values, and HV values. | |
23 | /// | |
78649106 | 24 | /// \author Laurent Aphecetche |
3d1463c8 | 25 | //----------------------------------------------------------------------------- |
2c780493 | 26 | |
27 | #include "AliMUONPadStatusMaker.h" | |
28 | ||
29 | #include "AliMUON2DMap.h" | |
9044498f | 30 | #include "AliMUON2DStoreValidator.h" |
31 | #include "AliMUONCalibParamNI.h" | |
2c780493 | 32 | #include "AliMUONCalibrationData.h" |
411a502a | 33 | #include "AliMUONLogger.h" |
34 | #include "AliMUONRecoParam.h" | |
49e396d9 | 35 | #include "AliMUONStringIntMap.h" |
7eafe398 | 36 | #include "AliMUONTrackerData.h" |
411a502a | 37 | #include "AliMUONVCalibParam.h" |
2ce1c72b | 38 | |
2c780493 | 39 | #include "AliMpArea.h" |
49e396d9 | 40 | #include "AliMpArrayI.h" |
411a502a | 41 | #include "AliMpCDB.h" |
8d8e920c | 42 | #include "AliMpConstants.h" |
49e396d9 | 43 | #include "AliMpDDLStore.h" |
2c780493 | 44 | #include "AliMpDEManager.h" |
49e396d9 | 45 | #include "AliMpDetElement.h" |
49e110ec | 46 | #include "AliMpDCSNamer.h" |
411a502a | 47 | #include "AliMpManuIterator.h" |
49e396d9 | 48 | #include "AliMpManuUID.h" |
2ce1c72b | 49 | |
50 | #include "AliCDBEntry.h" | |
51 | #include "AliCDBManager.h" | |
52 | #include "AliCodeTimer.h" | |
53 | #include "AliDCSValue.h" | |
54 | #include "AliLog.h" | |
55 | ||
9044498f | 56 | #include <Riostream.h> |
49e396d9 | 57 | #include <TArrayI.h> |
58 | #include <TExMap.h> | |
004a9ccd | 59 | #include <TFile.h> |
60 | #include <TKey.h> | |
9044498f | 61 | #include <TMap.h> |
004a9ccd | 62 | #include <TROOT.h> |
9044498f | 63 | #include <TString.h> |
004a9ccd | 64 | #include <TSystem.h> |
2c780493 | 65 | |
78649106 | 66 | /// \cond CLASSIMP |
2c780493 | 67 | ClassImp(AliMUONPadStatusMaker) |
78649106 | 68 | /// \endcond |
2c780493 | 69 | |
70 | //_____________________________________________________________________________ | |
71 | AliMUONPadStatusMaker::AliMUONPadStatusMaker(const AliMUONCalibrationData& calibData) | |
72dae9ff | 72 | : fkCalibrationData(calibData), |
004a9ccd | 73 | fGainA1Limits(0,1E30), |
74 | fGainA2Limits(-1E-30,1E30), | |
75 | fGainThresLimits(0,4095), | |
76 | fHVSt12Limits(0,5000), | |
77 | fHVSt345Limits(0,5000), | |
78 | fPedMeanLimits(0,4095), | |
79 | fPedSigmaLimits(0,4095), | |
7eafe398 | 80 | fManuOccupancyLimits(0,1.0), |
411a502a | 81 | fBuspatchOccupancyLimits(0,1.0), |
7eafe398 | 82 | fDEOccupancyLimits(0,1.0), |
004a9ccd | 83 | fStatus(new AliMUON2DMap(true)), |
84 | fHV(new TExMap), | |
85 | fPedestals(calibData.Pedestals()), | |
86 | fGains(calibData.Gains()), | |
7eafe398 | 87 | fTrackerData(0x0) |
2c780493 | 88 | { |
004a9ccd | 89 | /// ctor |
7eafe398 | 90 | if ( calibData.OccupancyMap() ) |
004a9ccd | 91 | { |
7eafe398 | 92 | /// create a tracker data from the occupancy map |
93 | fTrackerData = new AliMUONTrackerData("OCC","OCC",*(calibData.OccupancyMap())); | |
411a502a | 94 | } |
95 | ||
2c780493 | 96 | } |
97 | ||
98 | //_____________________________________________________________________________ | |
99 | AliMUONPadStatusMaker::~AliMUONPadStatusMaker() | |
100 | { | |
71a2d3aa | 101 | /// dtor. |
411a502a | 102 | |
49e396d9 | 103 | delete fStatus; |
104 | delete fHV; | |
7eafe398 | 105 | delete fTrackerData; |
2c780493 | 106 | } |
107 | ||
108 | //_____________________________________________________________________________ | |
49e396d9 | 109 | TString |
110 | AliMUONPadStatusMaker::AsString(Int_t status) | |
2c780493 | 111 | { |
49e396d9 | 112 | /// return a human readable version of the integer status |
004a9ccd | 113 | |
49e396d9 | 114 | Int_t pedStatus; |
115 | Int_t gainStatus; | |
116 | Int_t hvStatus; | |
7eafe398 | 117 | Int_t occStatus; |
004a9ccd | 118 | |
7eafe398 | 119 | DecodeStatus(status,pedStatus,hvStatus,gainStatus,occStatus); |
004a9ccd | 120 | |
121 | TString s; | |
122 | ||
123 | if ( pedStatus & kPedMeanZero ) s += "& Ped Mean is Zero "; | |
124 | if ( pedStatus & kPedMeanTooLow ) s += "& Ped Mean Too Low "; | |
125 | if ( pedStatus & kPedMeanTooHigh ) s += "& Ped Mean Too High "; | |
126 | if ( pedStatus & kPedSigmaTooLow ) s += "& Ped Sigma Too Low "; | |
127 | if ( pedStatus & kPedSigmaTooHigh ) s += "& Ped Sigma Too High "; | |
128 | if ( pedStatus & kPedMissing ) s += "& Ped is missing "; | |
129 | ||
130 | if ( gainStatus & kGainA1TooLow ) s+="& Gain A1 is Too Low "; | |
131 | if ( gainStatus & kGainA1TooHigh ) s+="& Gain A1 is Too High "; | |
132 | if ( gainStatus & kGainA2TooLow ) s+="& Gain A2 is Too Low "; | |
133 | if ( gainStatus & kGainA2TooHigh ) s+="& Gain A2 is Too High "; | |
134 | if ( gainStatus & kGainThresTooLow ) s+="& Gain Thres is Too Low "; | |
135 | if ( gainStatus & kGainThresTooHigh ) s+="& Gain Thres is Too High "; | |
136 | if ( gainStatus & kGainMissing ) s+="& Gain is missing "; | |
137 | ||
138 | if ( hvStatus & kHVError ) s+="& HV is on error "; | |
139 | if ( hvStatus & kHVTooLow ) s+="& HV is Too Low "; | |
140 | if ( hvStatus & kHVTooHigh ) s+="& HV is Too High "; | |
141 | if ( hvStatus & kHVChannelOFF ) s+="& HV has channel OFF "; | |
142 | if ( hvStatus & kHVSwitchOFF ) s+="& HV has switch OFF "; | |
143 | if ( hvStatus & kHVMissing ) s+="& HV is missing "; | |
144 | ||
7eafe398 | 145 | if ( occStatus & kManuOccupancyTooHigh ) s+="& manu occupancy too high "; |
146 | if ( occStatus & kManuOccupancyTooLow ) s+="& manu occupancy too low "; | |
147 | if ( occStatus & kBusPatchOccupancyTooHigh ) s+="& bus patch occupancy too high "; | |
148 | if ( occStatus & kBusPatchOccupancyTooLow ) s+="& bus patch occupancy too low "; | |
149 | if ( occStatus & kDEOccupancyTooHigh ) s+="& DE occupancy too high "; | |
150 | if ( occStatus & kDEOccupancyTooLow ) s+="& DE occupancy too low "; | |
49e396d9 | 151 | |
004a9ccd | 152 | if ( s[0] == '&' ) s[0] = ' '; |
153 | ||
154 | return s; | |
155 | } | |
49e396d9 | 156 | |
004a9ccd | 157 | //_____________________________________________________________________________ |
158 | TString | |
159 | AliMUONPadStatusMaker::AsCondition(Int_t mask) | |
160 | { | |
161 | /// return a human readable version of the mask's equivalent condition | |
162 | ||
163 | TString s(AsString(mask)); | |
164 | ||
165 | s.ReplaceAll("&","|"); | |
166 | ||
49e396d9 | 167 | return s; |
2c780493 | 168 | } |
169 | ||
96199305 | 170 | //_____________________________________________________________________________ |
49e396d9 | 171 | Int_t |
172 | AliMUONPadStatusMaker::BuildStatus(Int_t pedStatus, | |
173 | Int_t hvStatus, | |
004a9ccd | 174 | Int_t gainStatus, |
7eafe398 | 175 | Int_t occStatus) |
96199305 | 176 | { |
49e396d9 | 177 | /// Build a complete status from specific parts (ped,hv,gain) |
8d8e920c | 178 | |
49e396d9 | 179 | return ( hvStatus & 0xFF ) | ( ( pedStatus & 0xFF ) << 8 ) | |
004a9ccd | 180 | ( ( gainStatus & 0xFF ) << 16 ) | |
7eafe398 | 181 | ( ( occStatus & 0xFF ) << 24 ) ; |
49e396d9 | 182 | } |
183 | ||
184 | //_____________________________________________________________________________ | |
185 | void | |
186 | AliMUONPadStatusMaker::DecodeStatus(Int_t status, | |
187 | Int_t& pedStatus, | |
188 | Int_t& hvStatus, | |
004a9ccd | 189 | Int_t& gainStatus, |
7eafe398 | 190 | Int_t& occStatus) |
49e396d9 | 191 | { |
192 | /// Decode complete status into specific parts (ped,hv,gain) | |
96199305 | 193 | |
7eafe398 | 194 | occStatus = ( status & 0xFF000000 ) >> 24; |
49e396d9 | 195 | gainStatus = ( status & 0xFF0000 ) >> 16; |
196 | pedStatus = ( status & 0xFF00 ) >> 8; | |
197 | hvStatus = (status & 0xFF); | |
96199305 | 198 | } |
199 | ||
2c780493 | 200 | //_____________________________________________________________________________ |
201 | Bool_t | |
49e396d9 | 202 | AliMUONPadStatusMaker::HVSt12Status(Int_t detElemId, Int_t sector, |
203 | Bool_t& hvChannelTooLow, | |
204 | Bool_t& hvChannelTooHigh, | |
205 | Bool_t& hvChannelON) const | |
2c780493 | 206 | { |
207 | /// Get HV status for one HV sector of St12 | |
208 | ||
209 | /// For a given PCB in a given DE, get the HV status (both the channel | |
210 | /// and the switch). | |
211 | /// Returns false if hv switch changed during the run. | |
212 | ||
49e396d9 | 213 | AliCodeTimerAuto("") |
214 | ||
2c780493 | 215 | Bool_t error = kFALSE; |
216 | hvChannelTooLow = kFALSE; | |
217 | hvChannelTooHigh = kFALSE; | |
218 | hvChannelON = kTRUE; | |
49e396d9 | 219 | |
49e110ec | 220 | AliMpDCSNamer hvNamer("TRACKER"); |
2c780493 | 221 | |
49e110ec | 222 | TString hvChannel(hvNamer.DCSChannelName(detElemId,sector)); |
2c780493 | 223 | |
72dae9ff | 224 | TMap* hvMap = fkCalibrationData.HV(); |
49e396d9 | 225 | TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data())); |
2c780493 | 226 | if (!hvPair) |
227 | { | |
228 | AliError(Form("Did not find expected alias (%s) for DE %d", | |
229 | hvChannel.Data(),detElemId)); | |
230 | error = kTRUE; | |
231 | } | |
232 | else | |
233 | { | |
234 | TObjArray* values = static_cast<TObjArray*>(hvPair->Value()); | |
235 | if (!values) | |
236 | { | |
237 | AliError(Form("Could not get values for alias %s",hvChannel.Data())); | |
238 | error = kTRUE; | |
239 | } | |
240 | else | |
241 | { | |
242 | // find out min and max value, and makes a cut | |
243 | Float_t hvMin(1E9); | |
244 | Float_t hvMax(0); | |
245 | TIter next(values); | |
246 | AliDCSValue* val; | |
247 | ||
248 | while ( ( val = static_cast<AliDCSValue*>(next()) ) ) | |
249 | { | |
250 | Float_t hv = val->GetFloat(); | |
251 | hvMin = TMath::Min(hv,hvMin); | |
252 | hvMax = TMath::Max(hv,hvMax); | |
253 | } | |
254 | ||
255 | float lowThreshold = fHVSt12Limits.X(); | |
256 | float highThreshold = fHVSt12Limits.Y(); | |
257 | ||
258 | if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE; | |
259 | if ( hvMax > highThreshold ) hvChannelTooHigh = kTRUE; | |
260 | if ( hvMin < 1 ) hvChannelON = kFALSE; | |
261 | } | |
262 | } | |
263 | ||
264 | return error; | |
265 | } | |
266 | ||
267 | //_____________________________________________________________________________ | |
268 | Bool_t | |
49e396d9 | 269 | AliMUONPadStatusMaker::HVSt345Status(Int_t detElemId, Int_t pcbIndex, |
270 | Bool_t& hvChannelTooLow, | |
271 | Bool_t& hvChannelTooHigh, | |
272 | Bool_t& hvChannelON, | |
273 | Bool_t& hvSwitchON) const | |
2c780493 | 274 | { |
275 | /// For a given PCB in a given DE, get the HV status (both the channel | |
276 | /// and the switch). | |
277 | /// Returns false if something goes wrong (in particular if | |
278 | /// hv switch changed during the run). | |
279 | ||
49e396d9 | 280 | AliCodeTimerAuto("") |
281 | ||
2c780493 | 282 | Bool_t error = kFALSE; |
283 | hvChannelTooLow = kFALSE; | |
284 | hvChannelTooHigh = kFALSE; | |
285 | hvSwitchON = kTRUE; | |
286 | hvChannelON = kTRUE; | |
287 | ||
49e110ec | 288 | AliMpDCSNamer hvNamer("TRACKER"); |
2c780493 | 289 | |
49e110ec | 290 | TString hvChannel(hvNamer.DCSChannelName(detElemId)); |
2c780493 | 291 | |
72dae9ff | 292 | TMap* hvMap = fkCalibrationData.HV(); |
49e396d9 | 293 | |
294 | TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data())); | |
2c780493 | 295 | if (!hvPair) |
296 | { | |
297 | AliError(Form("Did not find expected alias (%s) for DE %d", | |
298 | hvChannel.Data(),detElemId)); | |
299 | error = kTRUE; | |
300 | } | |
301 | else | |
302 | { | |
303 | TObjArray* values = static_cast<TObjArray*>(hvPair->Value()); | |
304 | if (!values) | |
305 | { | |
306 | AliError(Form("Could not get values for alias %s",hvChannel.Data())); | |
307 | error = kTRUE; | |
308 | } | |
309 | else | |
310 | { | |
311 | // find out min and max value, and makes a cut | |
312 | Float_t hvMin(1E9); | |
313 | Float_t hvMax(0); | |
314 | TIter next(values); | |
315 | AliDCSValue* val; | |
316 | ||
317 | while ( ( val = static_cast<AliDCSValue*>(next()) ) ) | |
318 | { | |
319 | Float_t hv = val->GetFloat(); | |
320 | hvMin = TMath::Min(hv,hvMin); | |
321 | hvMax = TMath::Max(hv,hvMax); | |
322 | } | |
323 | ||
324 | float lowThreshold = fHVSt345Limits.X(); | |
325 | float highThreshold = fHVSt345Limits.Y(); | |
326 | ||
327 | if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE; | |
49e396d9 | 328 | else if ( hvMax > highThreshold ) hvChannelTooHigh = kTRUE; |
2c780493 | 329 | if ( hvMin < 1 ) hvChannelON = kFALSE; |
330 | } | |
331 | } | |
332 | ||
49e110ec | 333 | TString hvSwitch(hvNamer.DCSSwitchName(detElemId,pcbIndex)); |
49e396d9 | 334 | TPair* switchPair = static_cast<TPair*>(hvMap->FindObject(hvSwitch.Data())); |
2c780493 | 335 | if (!switchPair) |
336 | { | |
337 | AliError(Form("Did not find expected alias (%s) for DE %d PCB %d", | |
338 | hvSwitch.Data(),detElemId,pcbIndex)); | |
339 | error = kTRUE; | |
340 | } | |
341 | else | |
342 | { | |
343 | TObjArray* values = static_cast<TObjArray*>(switchPair->Value()); | |
344 | if (!values) | |
345 | { | |
346 | AliError(Form("Could not get values for alias %s",hvSwitch.Data())); | |
347 | error = kTRUE; | |
348 | } | |
349 | else | |
350 | { | |
351 | // we'll count the number of ON/OFF for this pad, to insure | |
352 | // consistency (i.e. if status changed during the run, we should | |
353 | // at least notify this fact ;-) and hope it's not the norm) | |
354 | Int_t nTrue(0); | |
355 | Int_t nFalse(0); | |
356 | TIter next(values); | |
357 | AliDCSValue* val; | |
358 | ||
359 | while ( ( val = static_cast<AliDCSValue*>(next()) ) ) | |
360 | { | |
361 | if ( val->GetBool() ) | |
362 | { | |
363 | ++nTrue; | |
364 | } | |
365 | else | |
366 | { | |
367 | ++nFalse; | |
368 | } | |
369 | } | |
370 | ||
371 | if ( (nTrue>0 && nFalse>0) ) | |
372 | { | |
373 | AliWarning(Form("Status of HV Switch %s changed during this run nTrue=%d nFalse=%d! Will consider it OFF", | |
374 | hvSwitch.Data(),nTrue,nFalse)); | |
375 | error = kTRUE; | |
376 | } | |
377 | ||
378 | if ( nFalse ) hvSwitchON = kFALSE; | |
379 | } | |
380 | } | |
381 | return error; | |
382 | } | |
383 | ||
384 | //_____________________________________________________________________________ | |
49e396d9 | 385 | Int_t |
386 | AliMUONPadStatusMaker::HVStatus(Int_t detElemId, Int_t manuId) const | |
2c780493 | 387 | { |
49e396d9 | 388 | /// Get HV status of one manu |
2c780493 | 389 | |
49e396d9 | 390 | AliCodeTimerAuto("") |
2c780493 | 391 | |
72dae9ff | 392 | if ( !fkCalibrationData.HV() ) return kMissing; |
49e396d9 | 393 | |
394 | Long_t lint = fHV->GetValue(AliMpManuUID::BuildUniqueID(detElemId,manuId)); | |
2c780493 | 395 | |
49e396d9 | 396 | if ( lint ) |
397 | { | |
398 | return (Int_t)(lint - 1); | |
399 | } | |
400 | ||
401 | Int_t status(0); | |
2c780493 | 402 | |
49e110ec | 403 | AliMpDCSNamer hvNamer("TRACKER"); |
2c780493 | 404 | |
49e396d9 | 405 | switch ( AliMpDEManager::GetStationType(detElemId) ) |
2c780493 | 406 | { |
4e51cfd2 | 407 | case AliMp::kStation12: |
2c780493 | 408 | { |
49e396d9 | 409 | int sector = hvNamer.ManuId2Sector(detElemId,manuId); |
410 | if ( sector >= 0 ) | |
2c780493 | 411 | { |
49e396d9 | 412 | Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON; |
413 | Bool_t error = HVSt12Status(detElemId,sector, | |
414 | hvChannelTooLow, | |
415 | hvChannelTooHigh, | |
416 | hvChannelON); | |
417 | if ( error ) status |= kHVError; | |
418 | if ( hvChannelTooLow ) status |= kHVTooLow; | |
419 | if ( hvChannelTooHigh ) status |= kHVTooHigh; | |
420 | if ( !hvChannelON ) status |= kHVChannelOFF; | |
421 | // assign this status to all the other manus handled by the same HV channel | |
422 | SetHVStatus(detElemId,sector,status); | |
423 | } | |
424 | } | |
425 | break; | |
426 | case AliMp::kStation345: | |
427 | { | |
428 | int pcbIndex = hvNamer.ManuId2PCBIndex(detElemId,manuId); | |
429 | if ( pcbIndex >= 0 ) | |
430 | { | |
431 | Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON,hvSwitchON; | |
432 | Bool_t error = HVSt345Status(detElemId,pcbIndex, | |
433 | hvChannelTooLow,hvChannelTooHigh, | |
434 | hvChannelON,hvSwitchON); | |
435 | if ( error ) status |= kHVError; | |
436 | if ( hvChannelTooLow ) status |= kHVTooLow; | |
437 | if ( hvChannelTooHigh ) status |= kHVTooHigh; | |
438 | if ( !hvSwitchON ) status |= kHVSwitchOFF; | |
439 | if ( !hvChannelON) status |= kHVChannelOFF; | |
440 | // assign this status to all the other manus handled by the same HV channel | |
441 | SetHVStatus(detElemId,pcbIndex,status); | |
2c780493 | 442 | } |
2c780493 | 443 | } |
49e396d9 | 444 | break; |
445 | default: | |
446 | break; | |
2c780493 | 447 | } |
448 | ||
49e396d9 | 449 | return status; |
450 | } | |
451 | ||
452 | //_____________________________________________________________________________ | |
453 | AliMUONVCalibParam* | |
454 | AliMUONPadStatusMaker::Neighbours(Int_t detElemId, Int_t manuId) const | |
455 | { | |
456 | /// Get the neighbours parameters for a given manu | |
72dae9ff | 457 | AliMUONVStore* neighbourStore = fkCalibrationData.Neighbours(); |
49e396d9 | 458 | return static_cast<AliMUONVCalibParam*>(neighbourStore->FindObject(detElemId,manuId)); |
2c780493 | 459 | } |
460 | ||
461 | //_____________________________________________________________________________ | |
8d8e920c | 462 | AliMUONVStore* |
49e396d9 | 463 | AliMUONPadStatusMaker::NeighboursStore() const |
2c780493 | 464 | { |
49e396d9 | 465 | /// Return the store containing all the neighbours |
72dae9ff | 466 | return fkCalibrationData.Neighbours(); |
49e396d9 | 467 | } |
468 | ||
469 | //_____________________________________________________________________________ | |
470 | AliMUONVCalibParam* | |
471 | AliMUONPadStatusMaker::ComputeStatus(Int_t detElemId, Int_t manuId) const | |
472 | { | |
473 | /// Compute the status of a given manu, using all available information, | |
474 | /// i.e. pedestals, gains, and HV | |
2c780493 | 475 | |
49e396d9 | 476 | AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,-1); |
477 | fStatus->Add(param); | |
004a9ccd | 478 | |
49e396d9 | 479 | AliMUONVCalibParam* pedestals = static_cast<AliMUONVCalibParam*>(fPedestals->FindObject(detElemId,manuId)); |
480 | ||
481 | AliMUONVCalibParam* gains = static_cast<AliMUONVCalibParam*>(fGains->FindObject(detElemId,manuId)); | |
2c780493 | 482 | |
49e396d9 | 483 | Int_t hvStatus = HVStatus(detElemId,manuId); |
484 | ||
7eafe398 | 485 | Int_t occStatus = OccupancyStatus(detElemId,manuId); |
2c780493 | 486 | |
49e396d9 | 487 | for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel ) |
2c780493 | 488 | { |
49e396d9 | 489 | Int_t pedStatus(0); |
490 | ||
491 | if (pedestals) | |
2c780493 | 492 | { |
49e396d9 | 493 | Float_t pedMean = pedestals->ValueAsFloatFast(manuChannel,0); |
494 | Float_t pedSigma = pedestals->ValueAsFloatFast(manuChannel,1); | |
495 | if ( pedMean < fPedMeanLimits.X() ) pedStatus |= kPedMeanTooLow; | |
496 | else if ( pedMean > fPedMeanLimits.Y() ) pedStatus |= kPedMeanTooHigh; | |
497 | if ( pedSigma < fPedSigmaLimits.X() ) pedStatus |= kPedSigmaTooLow; | |
498 | else if ( pedSigma > fPedSigmaLimits.Y() ) pedStatus |= kPedSigmaTooHigh; | |
499 | if ( pedMean == 0 ) pedStatus |= kPedMeanZero; | |
500 | } | |
501 | else | |
502 | { | |
503 | pedStatus = kPedMissing; | |
504 | } | |
505 | ||
506 | Int_t gainStatus(0); | |
507 | ||
508 | if ( gains ) | |
509 | { | |
510 | Float_t a0 = gains->ValueAsFloatFast(manuChannel,0); | |
511 | Float_t a1 = gains->ValueAsFloatFast(manuChannel,1); | |
512 | Float_t thres = gains->ValueAsFloatFast(manuChannel,2); | |
513 | ||
004a9ccd | 514 | if ( a0 < fGainA1Limits.X() ) gainStatus |= kGainA1TooLow; |
515 | else if ( a0 > fGainA1Limits.Y() ) gainStatus |= kGainA1TooHigh; | |
516 | if ( a1 < fGainA2Limits.X() ) gainStatus |= kGainA2TooLow; | |
517 | else if ( a1 > fGainA2Limits.Y() ) gainStatus |= kGainA2TooHigh; | |
49e396d9 | 518 | if ( thres < fGainThresLimits.X() ) gainStatus |= kGainThresTooLow; |
519 | else if ( thres > fGainThresLimits.Y() ) gainStatus |= kGainThresTooHigh; | |
2c780493 | 520 | } |
49e396d9 | 521 | else |
522 | { | |
523 | gainStatus = kGainMissing; | |
524 | } | |
2b8a1212 | 525 | |
7eafe398 | 526 | Int_t status = BuildStatus(pedStatus,hvStatus,gainStatus,occStatus); |
49e396d9 | 527 | |
528 | param->SetValueAsIntFast(manuChannel,0,status); | |
2c780493 | 529 | } |
530 | ||
49e396d9 | 531 | return param; |
2c780493 | 532 | } |
533 | ||
004a9ccd | 534 | //_____________________________________________________________________________ |
535 | Int_t | |
7eafe398 | 536 | AliMUONPadStatusMaker::OccupancyStatus(Int_t detElemId, Int_t manuId) const |
004a9ccd | 537 | { |
538 | /// Get the "other" status for a given manu | |
7eafe398 | 539 | |
540 | Int_t rv(0); | |
541 | ||
004a9ccd | 542 | if ( fTrackerData ) |
543 | { | |
7eafe398 | 544 | const Int_t occIndex = 2; |
545 | ||
546 | Double_t occ = fTrackerData->DetectionElement(detElemId,occIndex); | |
547 | ||
548 | if ( occ <= fDEOccupancyLimits.X() ) | |
549 | { | |
550 | rv |= kDEOccupancyTooLow; | |
551 | } | |
552 | else if ( occ > fDEOccupancyLimits.Y() ) | |
004a9ccd | 553 | { |
7eafe398 | 554 | rv |= kDEOccupancyTooHigh; |
004a9ccd | 555 | } |
7eafe398 | 556 | |
557 | Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId); | |
558 | ||
559 | occ = fTrackerData->BusPatch(busPatchId,occIndex); | |
560 | ||
411a502a | 561 | if ( occ <= fBuspatchOccupancyLimits.X() ) |
7eafe398 | 562 | { |
563 | rv |= kBusPatchOccupancyTooLow; | |
564 | } | |
411a502a | 565 | else if ( occ > fBuspatchOccupancyLimits.Y() ) |
7eafe398 | 566 | { |
567 | rv |= kBusPatchOccupancyTooHigh; | |
568 | } | |
569 | ||
570 | occ = fTrackerData->Manu(detElemId,manuId,occIndex); | |
571 | ||
572 | if ( occ <= fManuOccupancyLimits.X() ) | |
573 | { | |
574 | rv |= kManuOccupancyTooLow; | |
575 | } | |
576 | else if ( occ > fManuOccupancyLimits.Y() ) | |
004a9ccd | 577 | { |
7eafe398 | 578 | rv |= kManuOccupancyTooHigh; |
004a9ccd | 579 | } |
580 | } | |
7eafe398 | 581 | return rv; |
004a9ccd | 582 | } |
583 | ||
2c780493 | 584 | //_____________________________________________________________________________ |
49e396d9 | 585 | AliMUONVCalibParam* |
586 | AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId) const | |
2c780493 | 587 | { |
004a9ccd | 588 | /// Get the status container for a given manu |
2c780493 | 589 | |
49e396d9 | 590 | AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId)); |
591 | if (!param) | |
96199305 | 592 | { |
49e396d9 | 593 | // not already there, so compute it now |
594 | AliCodeTimerAuto("ComputeStatus"); | |
595 | param = ComputeStatus(detElemId,manuId); | |
96199305 | 596 | } |
49e396d9 | 597 | return param; |
2c780493 | 598 | } |
599 | ||
600 | //_____________________________________________________________________________ | |
49e396d9 | 601 | Int_t |
602 | AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId, Int_t manuChannel) const | |
2c780493 | 603 | { |
49e396d9 | 604 | /// Get the status for a given channel |
2c780493 | 605 | |
49e396d9 | 606 | AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId)); |
607 | if (!param) | |
2c780493 | 608 | { |
49e396d9 | 609 | // not already there, so compute it now |
610 | param = ComputeStatus(detElemId,manuId); | |
611 | } | |
612 | return param->ValueAsInt(manuChannel,0); | |
2c780493 | 613 | } |
614 | ||
615 | //_____________________________________________________________________________ | |
616 | void | |
49e396d9 | 617 | AliMUONPadStatusMaker::SetHVStatus(Int_t detElemId, Int_t index, Int_t status) const |
2c780493 | 618 | { |
49e396d9 | 619 | /// Assign status to all manus in a given HV "zone" (defined by index, meaning |
620 | /// is different thing from St12 and St345) | |
621 | ||
622 | AliCodeTimerAuto("") | |
623 | ||
624 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
2c780493 | 625 | |
49e396d9 | 626 | const AliMpArrayI* manus = de->ManusForHV(index); |
2c780493 | 627 | |
49e396d9 | 628 | for ( Int_t i = 0; i < manus->GetSize(); ++ i ) |
2c780493 | 629 | { |
49e396d9 | 630 | Int_t manuId = manus->GetValue(i); |
631 | fHV->Add(AliMpManuUID::BuildUniqueID(detElemId,manuId),status + 1); | |
2c780493 | 632 | } |
633 | } | |
411a502a | 634 | |
635 | //_____________________________________________________________________________ | |
636 | void | |
637 | AliMUONPadStatusMaker::SetLimits(const AliMUONRecoParam& recoParams) | |
638 | { | |
639 | /// Set the limits from the recoparam | |
640 | ||
641 | SetHVSt12Limits(recoParams.HVSt12LowLimit(),recoParams.HVSt12HighLimit()); | |
642 | SetHVSt345Limits(recoParams.HVSt345LowLimit(),recoParams.HVSt345HighLimit()); | |
643 | ||
644 | SetPedMeanLimits(recoParams.PedMeanLowLimit(),recoParams.PedMeanHighLimit()); | |
645 | SetPedSigmaLimits(recoParams.PedSigmaLowLimit(),recoParams.PedSigmaHighLimit()); | |
646 | ||
647 | SetGainA1Limits(recoParams.GainA1LowLimit(),recoParams.GainA1HighLimit()); | |
648 | SetGainA2Limits(recoParams.GainA2LowLimit(),recoParams.GainA2HighLimit()); | |
649 | SetGainThresLimits(recoParams.GainThresLowLimit(),recoParams.GainThresHighLimit()); | |
650 | ||
651 | SetManuOccupancyLimits(recoParams.ManuOccupancyLowLimit(),recoParams.ManuOccupancyHighLimit()); | |
652 | SetBuspatchOccupancyLimits(recoParams.BuspatchOccupancyLowLimit(),recoParams.BuspatchOccupancyHighLimit()); | |
653 | SetDEOccupancyLimits(recoParams.DEOccupancyLowLimit(),recoParams.DEOccupancyHighLimit()); | |
654 | } | |
655 | ||
656 | //_____________________________________________________________________________ | |
657 | void | |
658 | AliMUONPadStatusMaker::Report(UInt_t mask) | |
659 | { | |
660 | /// Report the number of bad pads, according to the mask, | |
661 | /// and the various reasons why they are bad (with occurence rates) | |
662 | ||
663 | AliInfo(""); | |
664 | AliCodeTimerAuto(""); | |
665 | ||
666 | AliMUONLogger log(1064008); | |
667 | ||
668 | Int_t nBadPads(0); | |
669 | Int_t nPads(0); | |
670 | ||
671 | AliMpManuIterator it; | |
672 | ||
673 | Int_t detElemId, manuId; | |
674 | ||
675 | while ( it.Next(detElemId,manuId) ) | |
676 | { | |
677 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
678 | ||
679 | for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) | |
680 | { | |
681 | if ( de->IsConnectedChannel(manuId,i) ) | |
682 | { | |
683 | ++nPads; | |
684 | ||
685 | Int_t status = PadStatus(detElemId,manuId,i); | |
686 | ||
687 | if ( ( status & mask) || (!mask && status) ) | |
688 | { | |
689 | ++nBadPads; | |
690 | log.Log(AsString(status)); | |
691 | } | |
692 | } | |
693 | } | |
694 | } | |
695 | ||
696 | TString msg; | |
697 | Int_t ntimes; | |
698 | ||
699 | cout << Form("According to mask %x (human readable form below) %6d pads are bad (over a total of %6d, i.e. %7.2f %%)", | |
700 | mask,nBadPads,nPads,nPads ? nBadPads*100.0/nPads : 0.0) << endl; | |
701 | cout << AliMUONPadStatusMaker::AsCondition(mask) << endl; | |
702 | cout << "--------" << endl; | |
703 | ||
704 | while ( log.Next(msg,ntimes) ) | |
705 | { | |
706 | cout << Form("The message (%120s) occured %15d times (%7.4f %%)",msg.Data(),ntimes,ntimes*100.0/nPads) << endl; | |
707 | } | |
708 | ||
709 | } | |
710 |