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 **************************************************************************/
22 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
25 #include <TClonesArray.h>
26 #include <TObjArray.h>
28 #include "AliCDBManager.h"
29 #include "AliCDBEntry.h"
32 #include "AliEMCALTriggerDCSConfigDB.h"
33 #include "AliEMCALTriggerDCSConfig.h"
34 #include "AliEMCALTriggerSTUDCSConfig.h"
35 #include "AliEMCALTriggerTRUDCSConfig.h"
37 ClassImp(AliEMCALTriggerDCSConfigDB)
39 AliEMCALTriggerDCSConfigDB* AliEMCALTriggerDCSConfigDB::fgInstance = 0;
40 Bool_t AliEMCALTriggerDCSConfigDB::fgTerminated = kFALSE;
42 //_____________________________________________________________________________
43 AliEMCALTriggerDCSConfigDB* AliEMCALTriggerDCSConfigDB::Instance()
46 // Singleton implementation
47 // Returns an instance of this class, it is created if neccessary
50 if (fgTerminated != kFALSE)
57 fgInstance = new AliEMCALTriggerDCSConfigDB();
63 //_____________________________________________________________________________
64 void AliEMCALTriggerDCSConfigDB::Terminate()
67 // Singleton implementation
68 // Deletes the instance of this class and sets the terminated flag,
69 // instances cannot be requested anymore
70 // This function can be called several times.
82 //_____________________________________________________________________________
83 AliEMCALTriggerDCSConfigDB::AliEMCALTriggerDCSConfigDB() : TObject()
87 // Default constructor
89 // TODO Default runnumber is set to 0, this should be changed later
90 // to an invalid value (e.g. -1) to prevent
91 // TODO invalid calibration data to be used.
94 for (Int_t i = 0; i < kCDBCacheSize; ++i)
101 //_____________________________________________________________________________
102 AliEMCALTriggerDCSConfigDB::AliEMCALTriggerDCSConfigDB(const AliEMCALTriggerDCSConfigDB &c) : TObject(c)
106 // Copy constructor (not that it make any sense for a singleton...)
109 for (Int_t i = 0; i < kCDBCacheSize; ++i)
116 //_____________________________________________________________________________
117 AliEMCALTriggerDCSConfigDB &AliEMCALTriggerDCSConfigDB::operator=(const AliEMCALTriggerDCSConfigDB &c)
120 // Assignment operator (same as above ...)
124 AliFatal("No assignment operator defined");
130 //_____________________________________________________________________________
131 AliEMCALTriggerDCSConfigDB::~AliEMCALTriggerDCSConfigDB()
139 //_____________________________________________________________________________
140 const TObject *AliEMCALTriggerDCSConfigDB::GetCachedCDBObject(Int_t id)
143 // Retrieves a cdb object with the given id. The objects are cached as
144 // long as the run number is not changed.
148 // Parameters defined per pad and chamber
149 case kIDTriggerConfig :
150 return CacheCDBEntry(kIDTriggerConfig, "EMCAL/Calib/Trigger");
153 AliError("Object not found!");
160 //_____________________________________________________________________________
161 AliCDBEntry* AliEMCALTriggerDCSConfigDB::GetCDBEntry(const char *cdbPath)
164 // Retrieves an entry with path <cdbPath> from the CDB.
166 AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
170 AliError(Form("Failed to get entry: %s",cdbPath));
177 //_____________________________________________________________________________
178 const TObject *AliEMCALTriggerDCSConfigDB::CacheCDBEntry(Int_t id, const char *cdbPath)
181 // Caches the entry <id> with cdb path <cdbPath>
186 fCDBEntries[id] = GetCDBEntry(cdbPath);
188 if (fCDBEntries[id]) fCDBCache[id] = fCDBEntries[id]->GetObject();
191 return fCDBCache[id];
194 //_____________________________________________________________________________
195 void AliEMCALTriggerDCSConfigDB::SetRun(Long64_t run)
198 // Sets current run number. Calibration data is read from the corresponding file.
199 // When the run number changes the caching is invalidated.
202 if (fRun == run) return;
209 //_____________________________________________________________________________
210 void AliEMCALTriggerDCSConfigDB::Invalidate()
213 // Invalidates cache (when run number is changed).
215 for (Int_t i = 0; i < kCDBCacheSize; ++i)
219 if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE)
221 if ((fCDBEntries[i]->IsOwner() == kFALSE) && (fCDBCache[i])) delete fCDBCache[i];
223 delete fCDBEntries[i];
232 //_____________________________________________________________________________
233 const AliEMCALTriggerDCSConfig* AliEMCALTriggerDCSConfigDB::GetTriggerDCSConfig()
238 const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
242 AliError("Trigger DCS configuration not found!");
249 //_____________________________________________________________________________
250 void AliEMCALTriggerDCSConfigDB::GetSTUSegmentation(Int_t ssg[], Int_t spg[], Int_t ssj[], Int_t spj[])
255 const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
257 AliEMCALTriggerSTUDCSConfig* stuConf = dcsConf->GetSTUDCSConfig();
259 Int_t fw = stuConf->GetFw();
275 AliError("Firmware version do not match!");
280 AliError("STUDCSConfig is null!");
284 AliError("DCSConfig is null!");
289 //_____________________________________________________________________________
290 Int_t AliEMCALTriggerDCSConfigDB::GetTRUSegmentation(Int_t iTRU)
293 const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
295 AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(iTRU);
297 Int_t sel = truConf->GetL0SEL();
303 } else AliError("TRUDCSConf Null!") ;
304 }else AliError("TriggerDCSConf Null!") ;
309 //_____________________________________________________________________________
310 Int_t AliEMCALTriggerDCSConfigDB::GetTRUGTHRL0(Int_t iTRU)
315 const AliEMCALTriggerDCSConfig* dcsConf = dynamic_cast<const AliEMCALTriggerDCSConfig*>(GetCachedCDBObject(kIDTriggerConfig));
317 AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(iTRU);
319 return truConf->GetGTHRL0();
320 } else AliError("TRUDCSConf Null!") ;
321 }else AliError("TriggerDCSConf Null!") ;