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.
100 //PH The owner of the objects is CDB, do not delete them!
104 //_____________________________________________________________________________
106 AliMUONCalibrationData::Capacitances() const
108 /// Create (if needed) and return the internal store for capacitances.
112 fCapacitances = CreateCapacitances(fRunNumber);
114 return fCapacitances;
117 //_____________________________________________________________________________
119 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
121 /// Create capa store from OCDB for a given run
123 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
126 //_____________________________________________________________________________
128 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
130 /// Create a new gain store from the OCDB for a given run
131 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
134 //_____________________________________________________________________________
135 AliMUONGlobalCrateConfig*
136 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
138 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
140 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
145 //_____________________________________________________________________________
147 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
149 /// Create a new HV map from the OCDB for a given run
150 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
153 //_____________________________________________________________________________
155 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
157 /// Get the internal store for LocalTriggerBoardMasks from OCDB
159 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
162 //_____________________________________________________________________________
164 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
166 /// Create a neighbour store from the OCDB for a given run
167 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
170 //_____________________________________________________________________________
172 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
174 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
175 /// and return the corresponding TObject.
177 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
179 AliCDBManager* man = AliCDBManager::Instance();
181 AliCDBEntry* entry = man->Get(path,runNumber);
185 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
187 TObject* object = entry->GetObject();
188 entry->SetOwner(kFALSE);
189 if (!(man->GetCacheFlag())) delete entry;
194 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
200 //_____________________________________________________________________________
202 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
204 /// Create a new pedestal store from the OCDB for a given run
205 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
209 //_____________________________________________________________________________
210 AliMUONRegionalTriggerConfig*
211 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
213 /// Create the internal store for RegionalTriggerConfig from OCDB
215 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
218 //_____________________________________________________________________________
219 AliMUONTriggerEfficiencyCells*
220 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
222 /// Create trigger efficiency object from OCBD
224 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
227 //_____________________________________________________________________________
229 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
231 /// Create trigger LUT from OCDB
233 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
236 //_____________________________________________________________________________
238 AliMUONCalibrationData::Gains() const
240 /// Create (if needed) and return the internal store for gains.
243 fGains = CreateGains(fRunNumber);
248 //_____________________________________________________________________________
250 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
252 /// Return the gains for a given (detElemId, manuId) pair
253 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
254 /// error (meaning that we should get gains for all channels).
256 AliMUONVStore* gains = Gains();
262 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
265 //_____________________________________________________________________________
266 AliMUONGlobalCrateConfig*
267 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
269 /// Return the config for the global trigger board.
271 if (!fGlobalTriggerCrateConfig)
273 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
275 return fGlobalTriggerCrateConfig;
279 //_____________________________________________________________________________
281 AliMUONCalibrationData::HV() const
283 /// Return the calibration for a given (detElemId, manuId) pair
287 fHV = CreateHV(fRunNumber);
292 //_____________________________________________________________________________
294 AliMUONCalibrationData::Neighbours() const
296 /// Create (if needed) and return the internal store for neighbours.
299 fNeighbours = CreateNeighbours(fRunNumber);
304 //_____________________________________________________________________________
306 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
308 /// Return the masks for a given trigger local board.
310 if (!fLocalTriggerBoardMasks)
312 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
315 if ( fLocalTriggerBoardMasks )
317 AliMUONVCalibParam* ltbm =
318 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
321 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
328 //_____________________________________________________________________________
330 AliMUONCalibrationData::Pedestals() const
335 fPedestals = CreatePedestals(fRunNumber);
340 //_____________________________________________________________________________
342 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
344 /// Return the pedestals for a given (detElemId, manuId) pair.
345 /// A return value of 0x0 is considered an error, meaning we should get
346 /// pedestals for all channels.
348 AliMUONVStore* pedestals = Pedestals();
354 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
357 //_____________________________________________________________________________
359 AliMUONCalibrationData::Print(Option_t*) const
361 /// A very basic dump of our guts.
363 cout << "RunNumber " << RunNumber()
364 << " fGains=" << fGains
365 << " fPedestals=" << fPedestals
367 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
368 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
369 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
370 << " fTriggerLut=" << fTriggerLut
375 //_____________________________________________________________________________
376 AliMUONRegionalTriggerConfig*
377 AliMUONCalibrationData::RegionalTriggerConfig() const
379 /// Return the config for the regional trigger board.
381 if (!fRegionalTriggerConfig)
383 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
385 return fRegionalTriggerConfig;
389 //_____________________________________________________________________________
390 AliMUONTriggerEfficiencyCells*
391 AliMUONCalibrationData::TriggerEfficiency() const
393 /// Return the trigger efficiency.
395 if (!fTriggerEfficiency)
397 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
399 return fTriggerEfficiency;
403 //_____________________________________________________________________________
405 AliMUONCalibrationData::TriggerLut() const
407 /// Return the trigger look up table.
411 fTriggerLut = CreateTriggerLut(fRunNumber);
416 //_____________________________________________________________________________
418 AliMUONCalibrationData::Reset()
428 delete fLocalTriggerBoardMasks;
429 fLocalTriggerBoardMasks = 0x0;
430 delete fRegionalTriggerConfig;
431 fRegionalTriggerConfig = 0x0;
432 delete fGlobalTriggerCrateConfig;
433 fGlobalTriggerCrateConfig = 0x0;
437 delete fTriggerEfficiency;
438 fTriggerEfficiency = 0x0;
439 delete fCapacitances;
445 //_____________________________________________________________________________
447 AliMUONCalibrationData::Check(Int_t runNumber)
449 /// Self-check to see if we can read all data for a given run
450 /// from the current OCDB...
452 if ( ! CreateCapacitances(runNumber) )
454 AliErrorClass("Could not read capacitances");
458 AliInfoClass("Capacitances read OK");
461 if ( ! CreateGains(runNumber) )
463 AliErrorClass("Could not read gains");
467 AliInfoClass("Gains read OK");
470 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
472 AliErrorClass("Could not read Trigger Crate Config");
476 AliInfoClass("TriggerBoardMasks read OK");
479 if ( ! CreateHV(runNumber) )
481 AliErrorClass("Could not read HV");
485 AliInfoClass("HV read OK");
488 if ( ! CreateNeighbours(runNumber) )
490 AliErrorClass("Could not read Neighbours");
494 AliInfoClass("Neighbours read OK");
497 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
499 AliErrorClass("Could not read LocalTriggerBoardMasks");
503 AliInfoClass("LocalTriggerBoardMasks read OK");
506 if ( ! CreatePedestals(runNumber) )
508 AliErrorClass("Could not read pedestals");
512 AliInfoClass("Pedestals read OK");
515 if ( ! CreateRegionalTriggerConfig(runNumber) )
517 AliErrorClass("Could not read RegionalTriggerConfig");
521 AliInfoClass("RegionalTriggerBoardMasks read OK");
524 if ( ! CreateTriggerLut(runNumber) )
526 AliErrorClass("Could not read TriggerLut");
530 AliInfoClass("TriggerLut read OK");
533 if ( ! CreateTriggerEfficiency(runNumber) )
535 AliErrorClass("Could not read TriggerEfficiency");
539 AliInfoClass("TriggerEfficiency read OK");