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),
77 // If deferredInitialization is false, we read *all* calibrations
79 // So when using this class to access only one kind of calibrations (e.g.
80 // only pedestals), you should put deferredInitialization to kTRUE, which
81 // will instruct this object to fetch the data only when neeeded.
83 if ( deferredInitialization == kFALSE )
90 LocalTriggerBoardMasks(0);
91 RegionalTriggerConfig();
92 GlobalTriggerCrateConfig();
100 //_____________________________________________________________________________
101 AliMUONCalibrationData::~AliMUONCalibrationData()
103 /// Destructor. Note that we're the owner of our pointers.
104 //PH The owner of the objects is CDB, do not delete them!
108 //_____________________________________________________________________________
110 AliMUONCalibrationData::Capacitances() const
112 /// Create (if needed) and return the internal store for capacitances.
116 fCapacitances = CreateCapacitances(fRunNumber);
118 return fCapacitances;
121 //_____________________________________________________________________________
123 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
125 /// Create capa store from OCDB for a given run
127 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
130 //_____________________________________________________________________________
132 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
134 /// Create a new gain store from the OCDB for a given run
135 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
138 //_____________________________________________________________________________
139 AliMUONGlobalCrateConfig*
140 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
142 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
144 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
149 //_____________________________________________________________________________
151 AliMUONCalibrationData::CreateHV(Int_t runNumber, Int_t* startOfValidity)
153 /// Create a new HV map from the OCDB for a given run
154 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
157 //_____________________________________________________________________________
159 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
161 /// Create a new Trigger HV and curent map from the OCDB for a given run
162 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
165 //_____________________________________________________________________________
167 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
169 /// Get the internal store for LocalTriggerBoardMasks from OCDB
171 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
174 //_____________________________________________________________________________
176 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
178 /// Create a neighbour store from the OCDB for a given run
179 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
182 //_____________________________________________________________________________
184 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
186 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
187 /// and return the corresponding TObject.
189 AliCodeTimerAutoClass(Form("%d : %s",runNumber,path));
191 AliCDBManager* man = AliCDBManager::Instance();
193 AliCDBEntry* entry = man->Get(path,runNumber);
197 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
199 TObject* object = entry->GetObject();
200 entry->SetOwner(kFALSE);
201 if (!(man->GetCacheFlag())) delete entry;
206 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
212 //_____________________________________________________________________________
214 AliMUONCalibrationData::CreateOccupancyMap(Int_t runNumber, Int_t* startOfValidity)
216 /// Create a new occupancy map store from the OCDB for a given run
217 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/OccupancyMap",startOfValidity));
220 //_____________________________________________________________________________
222 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
224 /// Create a new pedestal store from the OCDB for a given run
225 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
229 //_____________________________________________________________________________
230 AliMUONRegionalTriggerConfig*
231 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
233 /// Create the internal store for RegionalTriggerConfig from OCDB
235 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
238 //_____________________________________________________________________________
239 AliMUONTriggerEfficiencyCells*
240 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
242 /// Create trigger efficiency object from OCBD
244 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
247 //_____________________________________________________________________________
249 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
251 /// Create trigger LUT from OCDB
253 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
256 //_____________________________________________________________________________
258 AliMUONCalibrationData::Gains() const
260 /// Create (if needed) and return the internal store for gains.
263 fGains = CreateGains(fRunNumber);
268 //_____________________________________________________________________________
270 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
272 /// Return the gains for a given (detElemId, manuId) pair
273 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
274 /// error (meaning that we should get gains for all channels).
276 AliMUONVStore* gains = Gains();
282 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
285 //_____________________________________________________________________________
286 AliMUONGlobalCrateConfig*
287 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
289 /// Return the config for the global trigger board.
291 if (!fGlobalTriggerCrateConfig)
293 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
295 return fGlobalTriggerCrateConfig;
299 //_____________________________________________________________________________
301 AliMUONCalibrationData::HV() const
303 /// Return the calibration for a given (detElemId, manuId) pair
307 fHV = CreateHV(fRunNumber);
312 //_____________________________________________________________________________
314 AliMUONCalibrationData::TriggerDCS() const
316 /// Return the calibration for a given (detElemId, manuId) pair
320 fTriggerDCS = CreateTriggerDCS(fRunNumber);
325 //_____________________________________________________________________________
327 AliMUONCalibrationData::Neighbours() const
329 /// Create (if needed) and return the internal store for neighbours.
332 fNeighbours = CreateNeighbours(fRunNumber);
337 //_____________________________________________________________________________
339 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
341 /// Return the masks for a given trigger local board.
343 if (!fLocalTriggerBoardMasks)
345 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
348 if ( fLocalTriggerBoardMasks )
350 AliMUONVCalibParam* ltbm =
351 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
354 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
361 //_____________________________________________________________________________
363 AliMUONCalibrationData::OccupancyMap() const
365 /// Get occupancy map
368 fOccupancyMap = CreateOccupancyMap(fRunNumber);
370 return fOccupancyMap;
373 //_____________________________________________________________________________
375 AliMUONCalibrationData::Pedestals() const
380 fPedestals = CreatePedestals(fRunNumber);
385 //_____________________________________________________________________________
387 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
389 /// Return the pedestals for a given (detElemId, manuId) pair.
390 /// A return value of 0x0 is considered an error, meaning we should get
391 /// pedestals for all channels.
393 AliMUONVStore* pedestals = Pedestals();
399 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
402 //_____________________________________________________________________________
404 AliMUONCalibrationData::Print(Option_t*) const
406 /// A very basic dump of our guts.
408 cout << "RunNumber " << RunNumber()
409 << " fGains=" << fGains
410 << " fPedestals=" << fPedestals
412 << " fTriggerDCS=" << fTriggerDCS
413 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
414 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
415 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
416 << " fTriggerLut=" << fTriggerLut
421 //_____________________________________________________________________________
422 AliMUONRegionalTriggerConfig*
423 AliMUONCalibrationData::RegionalTriggerConfig() const
425 /// Return the config for the regional trigger board.
427 if (!fRegionalTriggerConfig)
429 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
431 return fRegionalTriggerConfig;
435 //_____________________________________________________________________________
436 AliMUONTriggerEfficiencyCells*
437 AliMUONCalibrationData::TriggerEfficiency() const
439 /// Return the trigger efficiency.
441 if (!fTriggerEfficiency)
443 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
445 return fTriggerEfficiency;
449 //_____________________________________________________________________________
451 AliMUONCalibrationData::TriggerLut() const
453 /// Return the trigger look up table.
457 fTriggerLut = CreateTriggerLut(fRunNumber);
462 //_____________________________________________________________________________
464 AliMUONCalibrationData::Reset()
476 delete fLocalTriggerBoardMasks;
477 fLocalTriggerBoardMasks = 0x0;
478 delete fRegionalTriggerConfig;
479 fRegionalTriggerConfig = 0x0;
480 delete fGlobalTriggerCrateConfig;
481 fGlobalTriggerCrateConfig = 0x0;
485 delete fTriggerEfficiency;
486 fTriggerEfficiency = 0x0;
487 delete fCapacitances;
493 //_____________________________________________________________________________
495 AliMUONCalibrationData::Check(Int_t runNumber)
497 /// Self-check to see if we can read all data for a given run
498 /// from the current OCDB...
500 if ( ! CreateCapacitances(runNumber) )
502 AliErrorClass("Could not read capacitances");
506 AliInfoClass("Capacitances read OK");
509 if ( ! CreateGains(runNumber) )
511 AliErrorClass("Could not read gains");
515 AliInfoClass("Gains read OK");
518 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
520 AliErrorClass("Could not read Trigger Crate Config");
524 AliInfoClass("TriggerBoardMasks read OK");
527 if ( ! CreateHV(runNumber) )
529 AliErrorClass("Could not read HV");
533 AliInfoClass("HV read OK");
536 if ( ! CreateTriggerDCS(runNumber) )
538 AliErrorClass("Could not read Trigger HV and Currents");
542 AliInfoClass("Trigger HV and Currents read OK");
545 if ( ! CreateNeighbours(runNumber) )
547 AliErrorClass("Could not read Neighbours");
551 AliInfoClass("Neighbours read OK");
554 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
556 AliErrorClass("Could not read LocalTriggerBoardMasks");
560 AliInfoClass("LocalTriggerBoardMasks read OK");
563 if ( ! CreatePedestals(runNumber) )
565 AliErrorClass("Could not read pedestals");
569 AliInfoClass("Pedestals read OK");
572 if ( ! CreateRegionalTriggerConfig(runNumber) )
574 AliErrorClass("Could not read RegionalTriggerConfig");
578 AliInfoClass("RegionalTriggerBoardMasks read OK");
581 if ( ! CreateTriggerLut(runNumber) )
583 AliErrorClass("Could not read TriggerLut");
587 AliInfoClass("TriggerLut read OK");
590 if ( ! CreateTriggerEfficiency(runNumber) )
592 AliErrorClass("Could not read TriggerEfficiency");
596 AliInfoClass("TriggerEfficiency read OK");