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),
65 fLocalTriggerBoardMasks(0x0),
66 fRegionalTriggerConfig(0x0),
67 fGlobalTriggerCrateConfig(0x0),
69 fTriggerEfficiency(0x0),
75 // If deferredInitialization is false, we read *all* calibrations
77 // So when using this class to access only one kind of calibrations (e.g.
78 // only pedestals), you should put deferredInitialization to kTRUE, which
79 // will instruct this object to fetch the data only when neeeded.
81 if ( deferredInitialization == kFALSE )
86 LocalTriggerBoardMasks(0);
87 RegionalTriggerConfig();
88 GlobalTriggerCrateConfig();
96 //_____________________________________________________________________________
97 AliMUONCalibrationData::~AliMUONCalibrationData()
99 /// Destructor. Note that we're the owner of our pointers.
103 //_____________________________________________________________________________
105 AliMUONCalibrationData::Capacitances() const
107 /// Create (if needed) and return the internal store for capacitances.
111 fCapacitances = CreateCapacitances(fRunNumber);
113 return fCapacitances;
116 //_____________________________________________________________________________
118 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
120 /// Create capa store from OCDB for a given run
122 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
125 //_____________________________________________________________________________
127 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
129 /// Create a new gain store from the OCDB for a given run
130 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
133 //_____________________________________________________________________________
134 AliMUONGlobalCrateConfig*
135 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
137 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
139 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
144 //_____________________________________________________________________________
146 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
148 /// Create a new HV map from the OCDB for a given run
149 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
152 //_____________________________________________________________________________
154 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
156 /// Get the internal store for LocalTriggerBoardMasks from OCDB
158 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
161 //_____________________________________________________________________________
163 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
165 /// Create a neighbour store from the OCDB for a given run
166 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
169 //_____________________________________________________________________________
171 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
173 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
174 /// and return the corresponding TObject.
176 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
178 AliCDBManager* man = AliCDBManager::Instance();
180 AliCDBEntry* entry = man->Get(path,runNumber);
184 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
186 TObject* object = entry->GetObject();
187 entry->SetOwner(kFALSE);
188 if (!(man->GetCacheFlag())) delete entry;
193 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
199 //_____________________________________________________________________________
201 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
203 /// Create a new pedestal store from the OCDB for a given run
204 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
208 //_____________________________________________________________________________
209 AliMUONRegionalTriggerConfig*
210 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
212 /// Create the internal store for RegionalTriggerConfig from OCDB
214 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
217 //_____________________________________________________________________________
218 AliMUONTriggerEfficiencyCells*
219 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
221 /// Create trigger efficiency object from OCBD
223 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
226 //_____________________________________________________________________________
228 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
230 /// Create trigger LUT from OCDB
232 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
235 //_____________________________________________________________________________
237 AliMUONCalibrationData::Gains() const
239 /// Create (if needed) and return the internal store for gains.
242 fGains = CreateGains(fRunNumber);
247 //_____________________________________________________________________________
249 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
251 /// Return the gains for a given (detElemId, manuId) pair
252 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
253 /// error (meaning that we should get gains for all channels).
255 AliMUONVStore* gains = Gains();
261 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
264 //_____________________________________________________________________________
265 AliMUONGlobalCrateConfig*
266 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
268 /// Return the config for the global trigger board.
270 if (!fGlobalTriggerCrateConfig)
272 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
274 return fGlobalTriggerCrateConfig;
278 //_____________________________________________________________________________
280 AliMUONCalibrationData::HV() const
282 /// Return the calibration for a given (detElemId, manuId) pair
286 fHV = CreateHV(fRunNumber);
291 //_____________________________________________________________________________
293 AliMUONCalibrationData::Neighbours() const
295 /// Create (if needed) and return the internal store for neighbours.
298 fNeighbours = CreateNeighbours(fRunNumber);
303 //_____________________________________________________________________________
305 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
307 /// Return the masks for a given trigger local board.
309 if (!fLocalTriggerBoardMasks)
311 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
314 if ( fLocalTriggerBoardMasks )
316 AliMUONVCalibParam* ltbm =
317 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
320 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
327 //_____________________________________________________________________________
329 AliMUONCalibrationData::Pedestals() const
334 fPedestals = CreatePedestals(fRunNumber);
339 //_____________________________________________________________________________
341 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
343 /// Return the pedestals for a given (detElemId, manuId) pair.
344 /// A return value of 0x0 is considered an error, meaning we should get
345 /// pedestals for all channels.
347 AliMUONVStore* pedestals = Pedestals();
353 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
356 //_____________________________________________________________________________
358 AliMUONCalibrationData::Print(Option_t*) const
360 /// A very basic dump of our guts.
362 cout << "RunNumber " << RunNumber()
363 << " fGains=" << fGains
364 << " fPedestals=" << fPedestals
366 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
367 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
368 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
369 << " fTriggerLut=" << fTriggerLut
374 //_____________________________________________________________________________
375 AliMUONRegionalTriggerConfig*
376 AliMUONCalibrationData::RegionalTriggerConfig() const
378 /// Return the config for the regional trigger board.
380 if (!fRegionalTriggerConfig)
382 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
384 return fRegionalTriggerConfig;
388 //_____________________________________________________________________________
389 AliMUONTriggerEfficiencyCells*
390 AliMUONCalibrationData::TriggerEfficiency() const
392 /// Return the trigger efficiency.
394 if (!fTriggerEfficiency)
396 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
398 return fTriggerEfficiency;
402 //_____________________________________________________________________________
404 AliMUONCalibrationData::TriggerLut() const
406 /// Return the trigger look up table.
410 fTriggerLut = CreateTriggerLut(fRunNumber);
415 //_____________________________________________________________________________
417 AliMUONCalibrationData::Reset()
427 delete fLocalTriggerBoardMasks;
428 fLocalTriggerBoardMasks = 0x0;
429 delete fRegionalTriggerConfig;
430 fRegionalTriggerConfig = 0x0;
431 delete fGlobalTriggerCrateConfig;
432 fGlobalTriggerCrateConfig = 0x0;
436 delete fTriggerEfficiency;
437 fTriggerEfficiency = 0x0;
438 delete fCapacitances;
444 //_____________________________________________________________________________
446 AliMUONCalibrationData::Check(Int_t runNumber)
448 /// Self-check to see if we can read all data for a given run
449 /// from the current OCDB...
451 if ( ! CreateCapacitances(runNumber) )
453 AliErrorClass("Could not read capacitances");
457 AliInfoClass("Capacitances read OK");
460 if ( ! CreateGains(runNumber) )
462 AliErrorClass("Could not read gains");
466 AliInfoClass("Gains read OK");
469 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
471 AliErrorClass("Could not read Trigger Crate Config");
475 AliInfoClass("TriggerBoardMasks read OK");
478 if ( ! CreateHV(runNumber) )
480 AliErrorClass("Could not read HV");
484 AliInfoClass("HV read OK");
487 if ( ! CreateNeighbours(runNumber) )
489 AliErrorClass("Could not read Neighbours");
493 AliInfoClass("Neighbours read OK");
496 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
498 AliErrorClass("Could not read LocalTriggerBoardMasks");
502 AliInfoClass("LocalTriggerBoardMasks read OK");
505 if ( ! CreatePedestals(runNumber) )
507 AliErrorClass("Could not read pedestals");
511 AliInfoClass("Pedestals read OK");
514 if ( ! CreateRegionalTriggerConfig(runNumber) )
516 AliErrorClass("Could not read RegionalTriggerConfig");
520 AliInfoClass("RegionalTriggerBoardMasks read OK");
523 if ( ! CreateTriggerLut(runNumber) )
525 AliErrorClass("Could not read TriggerLut");
529 AliInfoClass("TriggerLut read OK");
532 if ( ! CreateTriggerEfficiency(runNumber) )
534 AliErrorClass("Could not read TriggerEfficiency");
538 AliInfoClass("TriggerEfficiency read OK");