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 **************************************************************************/
16 #include <TClonesArray.h>
17 #include <TObjArray.h>
19 #include "AliCDBManager.h"
20 #include "AliCDBEntry.h"
23 #include "AliEMCALTriggerDCSConfigDB.h"
24 #include "AliEMCALTriggerDCSConfig.h"
25 #include "AliEMCALTriggerSTUDCSConfig.h"
26 #include "AliEMCALTriggerTRUDCSConfig.h"
28 ClassImp(AliEMCALTriggerDCSConfigDB)
30 AliEMCALTriggerDCSConfigDB* AliEMCALTriggerDCSConfigDB::fgInstance = 0;
31 Bool_t AliEMCALTriggerDCSConfigDB::fgTerminated = kFALSE;
33 //_____________________________________________________________________________
34 AliEMCALTriggerDCSConfigDB* AliEMCALTriggerDCSConfigDB::Instance()
37 // Singleton implementation
38 // Returns an instance of this class, it is created if neccessary
41 if (fgTerminated != kFALSE)
48 fgInstance = new AliEMCALTriggerDCSConfigDB();
54 //_____________________________________________________________________________
55 void AliEMCALTriggerDCSConfigDB::Terminate()
58 // Singleton implementation
59 // Deletes the instance of this class and sets the terminated flag,
60 // instances cannot be requested anymore
61 // This function can be called several times.
73 //_____________________________________________________________________________
74 AliEMCALTriggerDCSConfigDB::AliEMCALTriggerDCSConfigDB() : TObject()
78 // Default constructor
80 // TODO Default runnumber is set to 0, this should be changed later
81 // to an invalid value (e.g. -1) to prevent
82 // TODO invalid calibration data to be used.
85 for (Int_t i = 0; i < kCDBCacheSize; ++i)
92 //_____________________________________________________________________________
93 AliEMCALTriggerDCSConfigDB::AliEMCALTriggerDCSConfigDB(const AliEMCALTriggerDCSConfigDB &c) : TObject(c)
97 // Copy constructor (not that it make any sense for a singleton...)
100 for (Int_t i = 0; i < kCDBCacheSize; ++i)
107 //_____________________________________________________________________________
108 AliEMCALTriggerDCSConfigDB &AliEMCALTriggerDCSConfigDB::operator=(const AliEMCALTriggerDCSConfigDB &c)
111 // Assignment operator (same as above ...)
115 AliFatal("No assignment operator defined");
121 //_____________________________________________________________________________
122 AliEMCALTriggerDCSConfigDB::~AliEMCALTriggerDCSConfigDB()
130 //_____________________________________________________________________________
131 const TObject *AliEMCALTriggerDCSConfigDB::GetCachedCDBObject(Int_t id)
134 // Retrieves a cdb object with the given id. The objects are cached as
135 // long as the run number is not changed.
137 // Put together the available objects here by using the lines
138 // a) For usual calibration objects:
140 // return CacheCDBEntry(kID<Name>,"TRD/Calib/<Path>");
142 // See function CacheCDBEntry for details.
144 // b) For calibration data which depends on two objects: One containing
145 // a value per detector and one the local fluctuations per pad:
147 // return CacheMergeCDBEntry(kID<Name>,"TRD/Calib/<padPath>","TRD/Calib/<chamberPath>");
149 // See function CacheMergeCDBEntry for details.
154 // Parameters defined per pad and chamber
155 case kIDTriggerConfig :
156 return CacheCDBEntry(kIDTriggerConfig, "EMCAL/Calib/Trigger");
159 AliError("Object not found!");
166 //_____________________________________________________________________________
167 AliCDBEntry* AliEMCALTriggerDCSConfigDB::GetCDBEntry(const char *cdbPath)
170 // Retrieves an entry with path <cdbPath> from the CDB.
172 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
176 AliError(Form("Failed to get entry: %s",cdbPath));
183 //_____________________________________________________________________________
184 const TObject *AliEMCALTriggerDCSConfigDB::CacheCDBEntry(Int_t id, const char *cdbPath)
187 // Caches the entry <id> with cdb path <cdbPath>
192 fCDBEntries[id] = GetCDBEntry(cdbPath);
194 if (fCDBEntries[id]) fCDBCache[id] = fCDBEntries[id]->GetObject();
197 return fCDBCache[id];
200 //_____________________________________________________________________________
201 void AliEMCALTriggerDCSConfigDB::SetRun(Long64_t run)
204 // Sets current run number. Calibration data is read from the corresponding file.
205 // When the run number changes the caching is invalidated.
208 if (fRun == run) return;
215 //_____________________________________________________________________________
216 void AliEMCALTriggerDCSConfigDB::Invalidate()
219 // Invalidates cache (when run number is changed).
221 for (Int_t i = 0; i < kCDBCacheSize; ++i)
225 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE)
227 if ((fCDBEntries[i]->IsOwner() == kFALSE) && (fCDBCache[i])) delete fCDBCache[i];
229 delete fCDBEntries[i];
238 //_____________________________________________________________________________
239 const AliEMCALTriggerDCSConfig* AliEMCALTriggerDCSConfigDB::GetTriggerDCSConfig()
244 const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
248 AliError("Trigger DCS configuration not found!");
255 //_____________________________________________________________________________
256 void AliEMCALTriggerDCSConfigDB::GetSTUSegmentation(Int_t ss[], Int_t sp[])
261 const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
263 AliEMCALTriggerSTUDCSConfig* stuConf = dcsConf->GetSTUDCSConfig();
265 Int_t fw = stuConf->GetFw();
276 AliError("Firmware version do not match!");
281 //_____________________________________________________________________________
282 Int_t AliEMCALTriggerDCSConfigDB::GetTRUGTHRL0(Int_t iTRU)
287 const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
289 AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(iTRU);
291 return truConf->GetGTHRL0();