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