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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // Class to generate DCS data base entries //
20 // Author: Haavard Helstrup //
22 ///////////////////////////////////////////////////////////////////////////////
28 // TTimeStamp startTime(2006,10,18,0,0,0,0,kFALSE)
29 // TTimeStamp endTime(2006,10,19,0,0,0,0,kFALSE)
32 // db->SetDefaultStorage("local:///afs/cern.ch/alice/tpctest/AliRoot/HEAD");
33 // db->SetSpecificStorage("local:///afs/cern.ch/alice/tpctest/Calib/");
34 // db->Init(run,"TPC/Config/Pressure","TPC/*/*")
35 // db->MakeCalib("PressureSensor.txt","DCSMap.root",startTime,endTime,firstRun,lastRun,"TPC/Calib/Pressure")
38 #include "AliDCSGenDB.h"
40 #include "ARVersion.h"
42 const Int_t kBeamPeriod=2;
46 //______________________________________________________________________________________________
48 AliDCSGenDB::AliDCSGenDB():
58 // standard constructor
62 //______________________________________________________________________________________________
64 AliDCSGenDB::AliDCSGenDB(const char* defaultStorage, const char* specificStorage):
67 fSpecificStorage(specificStorage),
68 fDefaultStorage(defaultStorage),
74 // special constructor
78 //______________________________________________________________________________________________
80 AliDCSGenDB::AliDCSGenDB(const AliDCSGenDB& org):
82 fFirstRun(org.fFirstRun),
83 fLastRun(org.fLastRun),
84 fSpecificStorage(org.fSpecificStorage),
85 fDefaultStorage(org.fDefaultStorage),
95 AliError("copy constructor not implemented");
99 //______________________________________________________________________________________________
100 AliDCSGenDB::~AliDCSGenDB(){
109 //______________________________________________________________________________________________
110 AliDCSGenDB& AliDCSGenDB::operator= (const AliDCSGenDB& /*org*/ )
113 // assignment operator
115 AliError("assignment operator not implemented");
120 //______________________________________________________________________________________________
122 void AliDCSGenDB::MakeCalib(const char *list, const char *mapDCS,
123 const TTimeStamp& startTime,
124 const TTimeStamp& endTime,
125 Int_t firstRun, Int_t lastRun, const char *calibDir )
128 // Generate calibration entry from DCS map
129 // Configuration read from ASCII file specified by list
131 TClonesArray *arr = ReadList(list);
132 fSensor = new AliDCSSensorArray(arr);
133 fSensor->SetStartTime(startTime);
134 fSensor->SetEndTime(endTime);
135 TMap* map = SetGraphFile(mapDCS);
137 fSensor->MakeSplineFit(map);
143 SetFirstRun(firstRun);
146 StoreObject(calibDir, fSensor, fMetaData);
149 //______________________________________________________________________________________________
150 void AliDCSGenDB::MakeConfig(const char *file, Int_t firstRun, Int_t lastRun, const char *confDir )
153 // Store Configuration file to OCDB
156 TTree *tree = ReadListTree(file);
158 SetFirstRun(firstRun);
161 StoreObject(confDir, fConfTree, fMetaData);
167 //______________________________________________________________________________________________
168 AliCDBMetaData* AliDCSGenDB::CreateMetaObject(const char* objectClassName)
170 AliCDBMetaData *md1= new AliCDBMetaData();
171 md1->SetObjectClassName(objectClassName);
172 md1->SetResponsible("Haavard Helstrup");
173 md1->SetBeamPeriod(kBeamPeriod);
174 md1->SetAliRootVersion(ALIROOT_SVN_BRANCH);
179 //______________________________________________________________________________________________
180 void AliDCSGenDB::StoreObject(const char* cdbPath, TObject* object, AliCDBMetaData* metaData)
183 AliCDBId id1(cdbPath, fFirstRun, fLastRun);
184 if (fStorLoc) fStorLoc->Put(object, id1, metaData);
187 //______________________________________________________________________________________________
188 void AliDCSGenDB::Init(Int_t run, const char *configDir,
189 const char *specificDir,
190 const char *sensorClass)
193 fMetaData = CreateMetaObject(sensorClass);
194 AliCDBManager *man = AliCDBManager::Instance();
195 man->SetDefaultStorage(fDefaultStorage);
197 man->SetSpecificStorage(specificDir,fSpecificStorage);
198 AliCDBEntry *config = man->Get(configDir);
199 if (config) fConfTree = (TTree*)config->GetObject();
200 fStorLoc = man->GetStorage(fSpecificStorage);
201 if (!fStorLoc) return;
203 /*Bool_t cdbCache = */AliCDBManager::Instance()->GetCacheFlag(); // save cache status
204 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
209 //______________________________________________________________________________________________
212 //_____________________________________________________________________________
213 TMap* AliDCSGenDB::SetGraphFile(const char *fname)
216 // Read DCS maps from file given by fname
219 TMap * map = (TMap*)file.Get("DCSMap");
223 //______________________________________________________________________________________________
225 TClonesArray * AliDCSGenDB::ReadList(const char *fname, const char *title) {
227 // read values from ascii file
229 TTree* tree = new TTree(title,title);
230 tree->ReadFile(fname,"");
231 TClonesArray *arr = AliDCSSensor::ReadTree(tree);
236 //______________________________________________________________________________________________
238 TTree * AliDCSGenDB::ReadListTree(const char *fname, const char *title) {
240 // read values from ascii file
242 TTree* tree = new TTree(title,title);
243 tree->ReadFile(fname,"");
244 TClonesArray *arr = AliDCSSensor::ReadTree(tree);