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"
41 const Int_t kBeamPeriod=2;
45 //______________________________________________________________________________________________
47 AliDCSGenDB::AliDCSGenDB():
57 // standard constructor
61 //______________________________________________________________________________________________
63 AliDCSGenDB::AliDCSGenDB(const char* defaultStorage, const char* specificStorage):
66 fSpecificStorage(specificStorage),
67 fDefaultStorage(defaultStorage),
73 // special constructor
77 //______________________________________________________________________________________________
79 AliDCSGenDB::AliDCSGenDB(const AliDCSGenDB& org):
81 fFirstRun(org.fFirstRun),
82 fLastRun(org.fLastRun),
83 fSpecificStorage(org.fSpecificStorage),
84 fDefaultStorage(org.fDefaultStorage),
94 AliError("copy constructor not implemented");
98 //______________________________________________________________________________________________
99 AliDCSGenDB::~AliDCSGenDB(){
108 //______________________________________________________________________________________________
109 AliDCSGenDB& AliDCSGenDB::operator= (const AliDCSGenDB& org )
112 // assignment operator
114 AliError("assignment operator not implemented");
119 //______________________________________________________________________________________________
121 void AliDCSGenDB::MakeCalib(const char *list, const char *mapDCS,
122 const TTimeStamp& startTime,
123 const TTimeStamp& endTime,
124 Int_t firstRun, Int_t lastRun, const char *calibDir )
127 // Generate calibration entry from DCS map
128 // Configuration read from ASCII file specified by list
130 TClonesArray *arr = ReadList(list);
131 AliDCSSensorArray *fSensor = new AliDCSSensorArray(arr);
132 fSensor->SetStartTime(startTime);
133 fSensor->SetEndTime(endTime);
134 TMap* map = SetGraphFile(mapDCS);
136 fSensor->MakeSplineFit(map);
142 SetFirstRun(firstRun);
145 StoreObject(calibDir, fSensor, fMetaData);
148 //______________________________________________________________________________________________
149 void AliDCSGenDB::MakeConfig(const char *file, Int_t firstRun, Int_t lastRun, const char *confDir )
152 // Store Configuration file to OCDB
155 TTree *tree = ReadListTree(file);
157 SetFirstRun(firstRun);
160 StoreObject(confDir, fConfTree, fMetaData);
166 //______________________________________________________________________________________________
167 AliCDBMetaData* AliDCSGenDB::CreateMetaObject(const char* objectClassName)
169 AliCDBMetaData *md1= new AliCDBMetaData();
170 md1->SetObjectClassName(objectClassName);
171 md1->SetResponsible("Haavard Helstrup");
172 md1->SetBeamPeriod(kBeamPeriod);
173 md1->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
178 //______________________________________________________________________________________________
179 void AliDCSGenDB::StoreObject(const char* cdbPath, TObject* object, AliCDBMetaData* metaData)
182 AliCDBId id1(cdbPath, fFirstRun, fLastRun);
183 if (fStorLoc) fStorLoc->Put(object, id1, metaData);
186 //______________________________________________________________________________________________
187 void AliDCSGenDB::Init(Int_t run, const char *configDir,
188 const char *specificDir,
189 const char *sensorClass)
192 fMetaData = CreateMetaObject(sensorClass);
193 AliCDBManager *man = AliCDBManager::Instance();
194 man->SetDefaultStorage(fDefaultStorage);
196 man->SetSpecificStorage(specificDir,fSpecificStorage);
197 AliCDBEntry *config = man->Get(configDir);
198 if (config) fConfTree = (TTree*)config->GetObject();
199 fStorLoc = man->GetStorage(fSpecificStorage);
200 if (!fStorLoc) return;
202 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
203 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
208 //______________________________________________________________________________________________
211 //_____________________________________________________________________________
212 TMap* AliDCSGenDB::SetGraphFile(const char *fname)
215 // Read DCS maps from file given by fname
218 TMap * map = (TMap*)file.Get("DCSMap");
222 //______________________________________________________________________________________________
224 TClonesArray * AliDCSGenDB::ReadList(const char *fname, const char *title) {
226 // read values from ascii file
228 TTree* tree = new TTree(title,title);
229 tree->ReadFile(fname,"");
230 TClonesArray *arr = AliDCSSensor::ReadTree(tree);
235 //______________________________________________________________________________________________
237 TTree * AliDCSGenDB::ReadListTree(const char *fname, const char *title) {
239 // read values from ascii file
241 TTree* tree = new TTree(title,title);
242 tree->ReadFile(fname,"");
243 TClonesArray *arr = AliDCSSensor::ReadTree(tree);