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 "AliMUONTriggerEfficiencyCells.h"
25 #include "AliMUONTriggerLut.h"
26 #include "AliMUONVStore.h"
27 #include "AliMUONVStore.h"
28 #include "AliMUONVCalibParam.h"
29 #include "AliMUONGlobalCrateConfig.h"
30 #include "AliMUONRegionalTriggerConfig.h"
32 #include <Riostream.h>
36 //-----------------------------------------------------------------------------
37 /// \class AliMUONCalibrationData
39 /// For the moment, this class stores pedestals, gains, hv (for tracker)
40 /// and lut, masks and efficiencies (for trigger) that are fetched from the CDB.
42 /// This class is to be considered as a convenience class.
43 /// Its aim is to ease retrieval of calibration data from the
44 /// condition database.
46 /// It acts as a "facade" to a bunch of underlying
47 /// containers/calibration classes.
49 /// \author Laurent Aphecetche
50 //-----------------------------------------------------------------------------
53 ClassImp(AliMUONCalibrationData)
56 //_____________________________________________________________________________
57 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
58 Bool_t deferredInitialization)
61 fRunNumber(runNumber),
66 fLocalTriggerBoardMasks(0x0),
67 fRegionalTriggerConfig(0x0),
68 fGlobalTriggerCrateConfig(0x0),
70 fTriggerEfficiency(0x0),
76 // If deferredInitialization is false, we read *all* calibrations
78 // So when using this class to access only one kind of calibrations (e.g.
79 // only pedestals), you should put deferredInitialization to kTRUE, which
80 // will instruct this object to fetch the data only when neeeded.
82 if ( deferredInitialization == kFALSE )
88 LocalTriggerBoardMasks(0);
89 RegionalTriggerConfig();
90 GlobalTriggerCrateConfig();
98 //_____________________________________________________________________________
99 AliMUONCalibrationData::~AliMUONCalibrationData()
101 /// Destructor. Note that we're the owner of our pointers.
102 //PH The owner of the objects is CDB, do not delete them!
106 //_____________________________________________________________________________
108 AliMUONCalibrationData::Capacitances() const
110 /// Create (if needed) and return the internal store for capacitances.
114 fCapacitances = CreateCapacitances(fRunNumber);
116 return fCapacitances;
119 //_____________________________________________________________________________
121 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
123 /// Create capa store from OCDB for a given run
125 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
128 //_____________________________________________________________________________
130 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
132 /// Create a new gain store from the OCDB for a given run
133 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
136 //_____________________________________________________________________________
137 AliMUONGlobalCrateConfig*
138 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
140 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
142 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
147 //_____________________________________________________________________________
149 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
151 /// Create a new HV map from the OCDB for a given run
152 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
155 //_____________________________________________________________________________
157 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
159 /// Create a new Trigger HV and curent map from the OCDB for a given run
160 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
163 //_____________________________________________________________________________
165 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
167 /// Get the internal store for LocalTriggerBoardMasks from OCDB
169 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
172 //_____________________________________________________________________________
174 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
176 /// Create a neighbour store from the OCDB for a given run
177 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
180 //_____________________________________________________________________________
182 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
184 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
185 /// and return the corresponding TObject.
187 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
189 AliCDBManager* man = AliCDBManager::Instance();
191 AliCDBEntry* entry = man->Get(path,runNumber);
195 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
197 TObject* object = entry->GetObject();
198 entry->SetOwner(kFALSE);
199 if (!(man->GetCacheFlag())) delete entry;
204 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
210 //_____________________________________________________________________________
212 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
214 /// Create a new pedestal store from the OCDB for a given run
215 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
219 //_____________________________________________________________________________
220 AliMUONRegionalTriggerConfig*
221 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
223 /// Create the internal store for RegionalTriggerConfig from OCDB
225 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
228 //_____________________________________________________________________________
229 AliMUONTriggerEfficiencyCells*
230 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
232 /// Create trigger efficiency object from OCBD
234 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
237 //_____________________________________________________________________________
239 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
241 /// Create trigger LUT from OCDB
243 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
246 //_____________________________________________________________________________
248 AliMUONCalibrationData::Gains() const
250 /// Create (if needed) and return the internal store for gains.
253 fGains = CreateGains(fRunNumber);
258 //_____________________________________________________________________________
260 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
262 /// Return the gains for a given (detElemId, manuId) pair
263 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
264 /// error (meaning that we should get gains for all channels).
266 AliMUONVStore* gains = Gains();
272 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
275 //_____________________________________________________________________________
276 AliMUONGlobalCrateConfig*
277 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
279 /// Return the config for the global trigger board.
281 if (!fGlobalTriggerCrateConfig)
283 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
285 return fGlobalTriggerCrateConfig;
289 //_____________________________________________________________________________
291 AliMUONCalibrationData::HV() const
293 /// Return the calibration for a given (detElemId, manuId) pair
297 fHV = CreateHV(fRunNumber);
302 //_____________________________________________________________________________
304 AliMUONCalibrationData::TriggerDCS() const
306 /// Return the calibration for a given (detElemId, manuId) pair
310 fTriggerDCS = CreateTriggerDCS(fRunNumber);
315 //_____________________________________________________________________________
317 AliMUONCalibrationData::Neighbours() const
319 /// Create (if needed) and return the internal store for neighbours.
322 fNeighbours = CreateNeighbours(fRunNumber);
327 //_____________________________________________________________________________
329 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
331 /// Return the masks for a given trigger local board.
333 if (!fLocalTriggerBoardMasks)
335 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
338 if ( fLocalTriggerBoardMasks )
340 AliMUONVCalibParam* ltbm =
341 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
344 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
351 //_____________________________________________________________________________
353 AliMUONCalibrationData::Pedestals() const
358 fPedestals = CreatePedestals(fRunNumber);
363 //_____________________________________________________________________________
365 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
367 /// Return the pedestals for a given (detElemId, manuId) pair.
368 /// A return value of 0x0 is considered an error, meaning we should get
369 /// pedestals for all channels.
371 AliMUONVStore* pedestals = Pedestals();
377 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
380 //_____________________________________________________________________________
382 AliMUONCalibrationData::Print(Option_t*) const
384 /// A very basic dump of our guts.
386 cout << "RunNumber " << RunNumber()
387 << " fGains=" << fGains
388 << " fPedestals=" << fPedestals
390 << " fTriggerDCS=" << fTriggerDCS
391 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
392 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
393 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
394 << " fTriggerLut=" << fTriggerLut
399 //_____________________________________________________________________________
400 AliMUONRegionalTriggerConfig*
401 AliMUONCalibrationData::RegionalTriggerConfig() const
403 /// Return the config for the regional trigger board.
405 if (!fRegionalTriggerConfig)
407 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
409 return fRegionalTriggerConfig;
413 //_____________________________________________________________________________
414 AliMUONTriggerEfficiencyCells*
415 AliMUONCalibrationData::TriggerEfficiency() const
417 /// Return the trigger efficiency.
419 if (!fTriggerEfficiency)
421 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
423 return fTriggerEfficiency;
427 //_____________________________________________________________________________
429 AliMUONCalibrationData::TriggerLut() const
431 /// Return the trigger look up table.
435 fTriggerLut = CreateTriggerLut(fRunNumber);
440 //_____________________________________________________________________________
442 AliMUONCalibrationData::Reset()
454 delete fLocalTriggerBoardMasks;
455 fLocalTriggerBoardMasks = 0x0;
456 delete fRegionalTriggerConfig;
457 fRegionalTriggerConfig = 0x0;
458 delete fGlobalTriggerCrateConfig;
459 fGlobalTriggerCrateConfig = 0x0;
463 delete fTriggerEfficiency;
464 fTriggerEfficiency = 0x0;
465 delete fCapacitances;
471 //_____________________________________________________________________________
473 AliMUONCalibrationData::Check(Int_t runNumber)
475 /// Self-check to see if we can read all data for a given run
476 /// from the current OCDB...
478 if ( ! CreateCapacitances(runNumber) )
480 AliErrorClass("Could not read capacitances");
484 AliInfoClass("Capacitances read OK");
487 if ( ! CreateGains(runNumber) )
489 AliErrorClass("Could not read gains");
493 AliInfoClass("Gains read OK");
496 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
498 AliErrorClass("Could not read Trigger Crate Config");
502 AliInfoClass("TriggerBoardMasks read OK");
505 if ( ! CreateHV(runNumber) )
507 AliErrorClass("Could not read HV");
511 AliInfoClass("HV read OK");
514 if ( ! CreateTriggerDCS(runNumber) )
516 AliErrorClass("Could not read Trigger HV and Currents");
520 AliInfoClass("Trigger HV and Currents read OK");
523 if ( ! CreateNeighbours(runNumber) )
525 AliErrorClass("Could not read Neighbours");
529 AliInfoClass("Neighbours read OK");
532 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
534 AliErrorClass("Could not read LocalTriggerBoardMasks");
538 AliInfoClass("LocalTriggerBoardMasks read OK");
541 if ( ! CreatePedestals(runNumber) )
543 AliErrorClass("Could not read pedestals");
547 AliInfoClass("Pedestals read OK");
550 if ( ! CreateRegionalTriggerConfig(runNumber) )
552 AliErrorClass("Could not read RegionalTriggerConfig");
556 AliInfoClass("RegionalTriggerBoardMasks read OK");
559 if ( ! CreateTriggerLut(runNumber) )
561 AliErrorClass("Could not read TriggerLut");
565 AliInfoClass("TriggerLut read OK");
568 if ( ! CreateTriggerEfficiency(runNumber) )
570 AliErrorClass("Could not read TriggerEfficiency");
574 AliInfoClass("TriggerEfficiency read OK");