1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONCalibrationData.h"
20 #include "AliCDBEntry.h"
21 #include "AliCDBManager.h"
22 #include "AliCodeTimer.h"
24 #include "AliMUONRejectList.h"
25 #include "AliMUONTriggerEfficiencyCells.h"
26 #include "AliMUONTriggerLut.h"
27 #include "AliMUONVStore.h"
28 #include "AliMUONVStore.h"
29 #include "AliMUONVCalibParam.h"
30 #include "AliMUONGlobalCrateConfig.h"
31 #include "AliMUONRegionalTriggerConfig.h"
33 #include <Riostream.h>
37 //-----------------------------------------------------------------------------
38 /// \class AliMUONCalibrationData
40 /// For the moment, this class stores pedestals, gains, hv (for tracker)
41 /// and lut, masks and efficiencies (for trigger) that are fetched from the CDB.
43 /// This class is to be considered as a convenience class.
44 /// Its aim is to ease retrieval of calibration data from the
45 /// condition database.
47 /// It acts as a "facade" to a bunch of underlying
48 /// containers/calibration classes.
50 /// \author Laurent Aphecetche
51 //-----------------------------------------------------------------------------
54 ClassImp(AliMUONCalibrationData)
57 AliMUONVStore* AliMUONCalibrationData::fBypassPedestals(0x0);
58 AliMUONVStore* AliMUONCalibrationData::fBypassGains(0x0);
60 //_____________________________________________________________________________
61 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
62 Bool_t deferredInitialization)
65 fRunNumber(runNumber),
70 fLocalTriggerBoardMasks(0x0),
71 fRegionalTriggerConfig(0x0),
72 fGlobalTriggerCrateConfig(0x0),
74 fTriggerEfficiency(0x0),
83 // If deferredInitialization is false, we read *all* calibrations
85 // So when using this class to access only one kind of calibrations (e.g.
86 // only pedestals), you should put deferredInitialization to kTRUE, which
87 // will instruct this object to fetch the data only when neeeded.
89 if ( deferredInitialization == kFALSE )
97 LocalTriggerBoardMasks(0);
98 RegionalTriggerConfig();
99 GlobalTriggerCrateConfig();
108 //_____________________________________________________________________________
109 AliMUONCalibrationData::~AliMUONCalibrationData()
111 /// Destructor. Note that we're the owner of our pointers.
112 //PH The owner of the objects is CDB, do not delete them!
116 //_____________________________________________________________________________
118 AliMUONCalibrationData::Capacitances() const
120 /// Create (if needed) and return the internal store for capacitances.
124 fCapacitances = CreateCapacitances(fRunNumber);
126 return fCapacitances;
129 //_____________________________________________________________________________
131 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
133 /// Create capa store from OCDB for a given run
135 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
138 //_____________________________________________________________________________
140 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
142 /// Create a new gain store from the OCDB for a given run
143 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
146 //_____________________________________________________________________________
147 AliMUONGlobalCrateConfig*
148 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
150 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
152 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
157 //_____________________________________________________________________________
159 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
161 /// Create a new HV map from the OCDB for a given run
162 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
165 //_____________________________________________________________________________
167 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
169 /// Create a new Trigger HV and curent map from the OCDB for a given run
170 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
173 //_____________________________________________________________________________
175 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
177 /// Get the internal store for LocalTriggerBoardMasks from OCDB
179 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
182 //_____________________________________________________________________________
184 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
186 /// Create a neighbour store from the OCDB for a given run
187 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
190 //_____________________________________________________________________________
192 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
194 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
195 /// and return the corresponding TObject.
197 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path),0);
199 AliCDBManager* man = AliCDBManager::Instance();
201 AliCDBEntry* entry = man->Get(path,runNumber);
205 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
207 TObject* object = entry->GetObject();
208 entry->SetOwner(kFALSE);
209 if (!(man->GetCacheFlag())) delete entry;
214 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
219 AliCodeTimerAutoClass(Form("Failed to get %s for run %d",path,runNumber),1);
226 //_____________________________________________________________________________
228 AliMUONCalibrationData::CreateOccupancyMap(Int_t runNumber, Int_t* startOfValidity)
230 /// Create a new occupancy map store from the OCDB for a given run
231 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/OccupancyMap",startOfValidity));
234 //_____________________________________________________________________________
236 AliMUONCalibrationData::CreateRejectList(Int_t runNumber, Int_t* startOfValidity)
238 /// Create a new rejectlist store from the OCDB for a given run
239 return dynamic_cast<AliMUONRejectList*>(CreateObject(runNumber,"MUON/Calib/RejectList",startOfValidity));
242 //_____________________________________________________________________________
244 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
246 /// Create a new pedestal store from the OCDB for a given run
247 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
250 //_____________________________________________________________________________
252 AliMUONCalibrationData::CreateConfig(Int_t runNumber, Int_t* startOfValidity)
254 /// Create a new config store from the OCDB for a given run
255 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Config",startOfValidity));
259 //_____________________________________________________________________________
260 AliMUONRegionalTriggerConfig*
261 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
263 /// Create the internal store for RegionalTriggerConfig from OCDB
265 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
268 //_____________________________________________________________________________
269 AliMUONTriggerEfficiencyCells*
270 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
272 /// Create trigger efficiency object from OCBD
274 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
277 //_____________________________________________________________________________
279 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
281 /// Create trigger LUT from OCDB
283 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
286 //_____________________________________________________________________________
288 AliMUONCalibrationData::Gains() const
290 /// Create (if needed) and return the internal store for gains.
291 if (fBypassGains) return fBypassGains;
295 fGains = CreateGains(fRunNumber);
300 //_____________________________________________________________________________
302 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
304 /// Return the gains for a given (detElemId, manuId) pair
305 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
306 /// error (meaning that we should get gains for all channels).
308 AliMUONVStore* gains = Gains();
314 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
317 //_____________________________________________________________________________
318 AliMUONGlobalCrateConfig*
319 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
321 /// Return the config for the global trigger board.
323 if (!fGlobalTriggerCrateConfig)
325 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
327 return fGlobalTriggerCrateConfig;
331 //_____________________________________________________________________________
333 AliMUONCalibrationData::HV() const
335 /// Return the calibration for a given (detElemId, manuId) pair
339 fHV = CreateHV(fRunNumber);
344 //_____________________________________________________________________________
346 AliMUONCalibrationData::TriggerDCS() const
348 /// Return the calibration for a given (detElemId, manuId) pair
352 fTriggerDCS = CreateTriggerDCS(fRunNumber);
357 //_____________________________________________________________________________
359 AliMUONCalibrationData::Neighbours() const
361 /// Create (if needed) and return the internal store for neighbours.
364 fNeighbours = CreateNeighbours(fRunNumber);
369 //_____________________________________________________________________________
371 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
373 /// Return the masks for a given trigger local board.
375 if (!fLocalTriggerBoardMasks)
377 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
380 if ( fLocalTriggerBoardMasks )
382 AliMUONVCalibParam* ltbm =
383 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
386 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
393 //_____________________________________________________________________________
395 AliMUONCalibrationData::OccupancyMap() const
397 /// Get occupancy map
400 fOccupancyMap = CreateOccupancyMap(fRunNumber);
402 return fOccupancyMap;
405 //_____________________________________________________________________________
407 AliMUONCalibrationData::RejectList() const
412 fRejectList = CreateRejectList(fRunNumber);
417 //_____________________________________________________________________________
419 AliMUONCalibrationData::BypassStores(AliMUONVStore* ped, AliMUONVStore* gain)
421 /// Force the use of those pedestals and gains
422 fBypassPedestals = ped;
427 //_____________________________________________________________________________
429 AliMUONCalibrationData::Pedestals() const
433 if (fBypassPedestals) return fBypassPedestals;
437 fPedestals = CreatePedestals(fRunNumber);
442 //_____________________________________________________________________________
444 AliMUONCalibrationData::Config() const
450 fConfig = CreateConfig(fRunNumber);
455 //_____________________________________________________________________________
457 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
459 /// Return the pedestals for a given (detElemId, manuId) pair.
460 /// A return value of 0x0 is considered an error, meaning we should get
461 /// pedestals for all channels.
463 AliMUONVStore* pedestals = Pedestals();
469 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
472 //_____________________________________________________________________________
474 AliMUONCalibrationData::Print(Option_t*) const
476 /// A very basic dump of our guts.
478 cout << "RunNumber " << RunNumber()
479 << " fGains=" << fGains
480 << " fPedestals=" << fPedestals
481 << " fConfig=" << fConfig
483 << " fTriggerDCS=" << fTriggerDCS
484 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
485 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
486 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
487 << " fTriggerLut=" << fTriggerLut
492 //_____________________________________________________________________________
493 AliMUONRegionalTriggerConfig*
494 AliMUONCalibrationData::RegionalTriggerConfig() const
496 /// Return the config for the regional trigger board.
498 if (!fRegionalTriggerConfig)
500 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
502 return fRegionalTriggerConfig;
506 //_____________________________________________________________________________
507 AliMUONTriggerEfficiencyCells*
508 AliMUONCalibrationData::TriggerEfficiency() const
510 /// Return the trigger efficiency.
512 if (!fTriggerEfficiency)
514 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
516 return fTriggerEfficiency;
520 //_____________________________________________________________________________
522 AliMUONCalibrationData::TriggerLut() const
524 /// Return the trigger look up table.
528 fTriggerLut = CreateTriggerLut(fRunNumber);
533 //_____________________________________________________________________________
535 AliMUONCalibrationData::Reset()
549 delete fLocalTriggerBoardMasks;
550 fLocalTriggerBoardMasks = 0x0;
551 delete fRegionalTriggerConfig;
552 fRegionalTriggerConfig = 0x0;
553 delete fGlobalTriggerCrateConfig;
554 fGlobalTriggerCrateConfig = 0x0;
558 delete fTriggerEfficiency;
559 fTriggerEfficiency = 0x0;
560 delete fCapacitances;
566 //_____________________________________________________________________________
568 AliMUONCalibrationData::Check(Int_t runNumber)
570 /// Self-check to see if we can read all data for a given run
571 /// from the current OCDB...
573 if ( ! CreateCapacitances(runNumber) )
575 AliErrorClass("Could not read capacitances");
579 AliInfoClass("Capacitances read OK");
582 if ( ! CreateGains(runNumber) )
584 AliErrorClass("Could not read gains");
588 AliInfoClass("Gains read OK");
591 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
593 AliErrorClass("Could not read Trigger Crate Config");
597 AliInfoClass("TriggerBoardMasks read OK");
600 if ( ! CreateHV(runNumber) )
602 AliErrorClass("Could not read HV");
606 AliInfoClass("HV read OK");
609 if ( ! CreateTriggerDCS(runNumber) )
611 AliErrorClass("Could not read Trigger HV and Currents");
615 AliInfoClass("Trigger HV and Currents read OK");
618 if ( ! CreateNeighbours(runNumber) )
620 AliErrorClass("Could not read Neighbours");
624 AliInfoClass("Neighbours read OK");
627 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
629 AliErrorClass("Could not read LocalTriggerBoardMasks");
633 AliInfoClass("LocalTriggerBoardMasks read OK");
636 if ( ! CreatePedestals(runNumber) )
638 AliErrorClass("Could not read pedestals");
642 AliInfoClass("Pedestals read OK");
645 if ( ! CreateConfig(runNumber) )
647 AliErrorClass("Could not read config");
651 AliInfoClass("Config read OK");
654 if ( ! CreateRegionalTriggerConfig(runNumber) )
656 AliErrorClass("Could not read RegionalTriggerConfig");
660 AliInfoClass("RegionalTriggerBoardMasks read OK");
663 if ( ! CreateTriggerLut(runNumber) )
665 AliErrorClass("Could not read TriggerLut");
669 AliInfoClass("TriggerLut read OK");
672 if ( ! CreateTriggerEfficiency(runNumber) )
674 AliErrorClass("Could not read TriggerEfficiency");
678 AliInfoClass("TriggerEfficiency read OK");