AliRoot Core  3dc7879 (3dc7879)
AliDCSGenDB.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 
16 
18 // //
19 // Class to generate DCS data base entries //
20 // Author: Haavard Helstrup //
21 // //
23 
24 
25 
26 
27 
28 // TTimeStamp startTime(2006,10,18,0,0,0,0,kFALSE)
29 // TTimeStamp endTime(2006,10,19,0,0,0,0,kFALSE)
30 // Int_t run=2546
31 // AliDCSGenDB db
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")
36 
37 
38 #include "AliDCSGenDB.h"
39 #include "AliLog.h"
40 #include "ARVersion.h"
41 
42 const Int_t kBeamPeriod=2;
43 
44 ClassImp(AliDCSGenDB)
45 
46 //______________________________________________________________________________________________
47 
49  fFirstRun(0),
50  fLastRun(0),
51  fSpecificStorage(0),
52  fDefaultStorage(0),
53  fSensor(0),
54  fStorLoc(0),
55  fMetaData(0),
56  fConfTree(0)
57  //
58  // standard constructor
59  //
60 {}
61 
62 //______________________________________________________________________________________________
63 
64 AliDCSGenDB::AliDCSGenDB(const char* defaultStorage, const char* specificStorage):
65  fFirstRun(0),
66  fLastRun(0),
67  fSpecificStorage(specificStorage),
68  fDefaultStorage(defaultStorage),
69  fSensor(0),
70  fStorLoc(0),
71  fMetaData(0),
72  fConfTree(0)
73  //
74  // special constructor
75  //
76 {}
77 
78 //______________________________________________________________________________________________
79 
81  TObject(org),
82  fFirstRun(org.fFirstRun),
83  fLastRun(org.fLastRun),
86  fSensor(0),
87  fStorLoc(0),
88  fMetaData(0),
89  fConfTree(0)
90 {
91  //
92  // Copy constructor
93  //
94 
95  AliError("copy constructor not implemented");
96 
97 }
98 
99 //______________________________________________________________________________________________
101  //
102  // destructor
103  //
104  delete fSensor;
105  delete fMetaData;
106  delete fConfTree;
107 }
108 
109 //______________________________________________________________________________________________
111 {
112  //
113  // assignment operator
114  //
115  AliError("assignment operator not implemented");
116  return *this;
117 
118 }
119 
120 //______________________________________________________________________________________________
121 
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 )
126 {
127 
128  // Generate calibration entry from DCS map
129  // Configuration read from ASCII file specified by list
130 
131  TClonesArray *arr = ReadList(list);
132  fSensor = new AliDCSSensorArray(arr);
133  fSensor->SetStartTime(startTime);
134  fSensor->SetEndTime(endTime);
135  TMap* map = SetGraphFile(mapDCS);
136  if (map) {
137  fSensor->MakeSplineFit(map);
138  }
139  delete map;
140  map=0;
141  mapDCS=0;
142 
143  SetFirstRun(firstRun);
144  SetLastRun(lastRun);
145 
146  StoreObject(calibDir, fSensor, fMetaData);
147 }
148 
149 //______________________________________________________________________________________________
150 void AliDCSGenDB::MakeConfig(const char *file, Int_t firstRun, Int_t lastRun, const char *confDir )
151 {
152  //
153  // Store Configuration file to OCDB
154  //
155 
156  TTree *tree = ReadListTree(file);
157  SetConfTree(tree);
158  SetFirstRun(firstRun);
159  SetLastRun(lastRun);
160 
161  StoreObject(confDir, fConfTree, fMetaData);
162 }
163 
164 
165 
166 
167 //______________________________________________________________________________________________
168 AliCDBMetaData* AliDCSGenDB::CreateMetaObject(const char* objectClassName)
169 {
170  AliCDBMetaData *md1= new AliCDBMetaData();
171  md1->SetObjectClassName(objectClassName);
172  md1->SetResponsible("Haavard Helstrup");
174  md1->SetAliRootVersion(ALIROOT_VERSION);
175 
176  return md1;
177 }
178 
179 //______________________________________________________________________________________________
180 void AliDCSGenDB::StoreObject(const char* cdbPath, TObject* object, AliCDBMetaData* metaData)
181 {
182 
183  AliCDBId id1(cdbPath, fFirstRun, fLastRun);
184  if (fStorLoc) fStorLoc->Put(object, id1, metaData);
185 }
186 
187 //______________________________________________________________________________________________
188 void AliDCSGenDB::Init(Int_t run, const char *configDir,
189  const char *specificDir,
190  const char *sensorClass)
191 {
192 
193  fMetaData = CreateMetaObject(sensorClass);
196  man->SetRun(run);
197  man->SetSpecificStorage(specificDir,fSpecificStorage);
198  AliCDBEntry *config = man->Get(configDir);
199  if (config) fConfTree = (TTree*)config->GetObject();
201  if (!fStorLoc) return;
202 
203  /*Bool_t cdbCache = */AliCDBManager::Instance()->GetCacheFlag(); // save cache status
204  AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
205 
206 
207 }
208 
209 //______________________________________________________________________________________________
210 
211 
212 //_____________________________________________________________________________
214 {
215  //
216  // Read DCS maps from file given by fname
217  //
218  TFile file(fname);
219  TMap * map = (TMap*)file.Get("DCSMap");
220  return map;
221 }
222 
223 //______________________________________________________________________________________________
224 
225 TClonesArray * AliDCSGenDB::ReadList(const char *fname, const char *title) {
226  //
227  // read values from ascii file
228  //
229  TTree* tree = new TTree(title,title);
230  tree->ReadFile(fname,"");
231  TClonesArray *arr = AliDCSSensor::ReadTree(tree);
232  delete tree;
233  return arr;
234 }
235 
236 //______________________________________________________________________________________________
237 
238 TTree * AliDCSGenDB::ReadListTree(const char *fname, const char *title) {
239  //
240  // read values from ascii file
241  //
242  TTree* tree = new TTree(title,title);
243  tree->ReadFile(fname,"");
244  TClonesArray *arr = AliDCSSensor::ReadTree(tree);
245  arr->Delete();
246  delete arr;
247  return tree;
248 }
249 
250 
251 
void SetStartTime(const TTimeStamp &start)
AliDCSSensorArray * fSensor
Definition: AliDCSGenDB.h:77
Bool_t Put(TObject *object, AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", AliCDBManager::DataType type=AliCDBManager::kPrivate)
void SetEndTime(const TTimeStamp &end)
AliCDBMetaData * CreateMetaObject(const char *objectClassName)
void MakeSplineFit(TMap *map, Bool_t keepMap=kFALSE)
void MakeConfig(const char *file, Int_t firstRun, Int_t lastRun, const char *confDir)
void SetCacheFlag(Bool_t cacheFlag)
void SetResponsible(const char *yourName)
AliCDBStorage * fStorLoc
Definition: AliDCSGenDB.h:78
void MakeCalib(const char *file, const char *fMap, const TTimeStamp &startTime, const TTimeStamp &endTime, Int_t firstRun, Int_t lastRun, const char *calibDir)
TMap * SetGraphFile(const char *fname)
void SetConfTree(TTree *tree)
Definition: AliDCSGenDB.h:59
AliCDBEntry * Get(const AliCDBId &query, Bool_t forceCaching=kFALSE)
Int_t fLastRun
Definition: AliDCSGenDB.h:74
AliCDBMetaData * fMetaData
Definition: AliDCSGenDB.h:79
TObject * GetObject()
Definition: AliCDBEntry.h:56
TTree * fConfTree
Definition: AliDCSGenDB.h:80
TTree * tree
void Init(Int_t run, const char *configDir, const char *specificDir, const char *sensorClass="AliDCSSensorArray")
AliCDBStorage * GetStorage(const char *dbString)
void SetSpecificStorage(const char *calibType, const char *dbString, Int_t version=-1, Int_t subVersion=-1)
static TClonesArray * ReadTree(TTree *tree)
void SetBeamPeriod(UInt_t period)
TTimeStamp startTime(2009, 8, 7, 0, 0, 0)
Bool_t GetCacheFlag() const
static TTree * ReadListTree(const char *fname, const char *title="dcsConf")
void SetAliRootVersion(const char *version)
void SetRun(Int_t run)
TString fSpecificStorage
Definition: AliDCSGenDB.h:75
Definition: AliCDBEntry.h:18
TString fDefaultStorage
Definition: AliDCSGenDB.h:76
void SetDefaultStorage(const char *dbString)
void SetLastRun(Int_t lrun)
Definition: AliDCSGenDB.h:57
Int_t fFirstRun
Definition: AliDCSGenDB.h:73
AliDCSGenDB & operator=(const AliDCSGenDB &org)
void SetObjectClassName(const char *name)
static TClonesArray * ReadList(const char *fname, const char *title="dcsConf")
const Int_t kBeamPeriod
Definition: AliDCSGenDB.cxx:42
void SetFirstRun(Int_t frun)
Definition: AliDCSGenDB.h:56
#define AliError(message)
Definition: AliLog.h:591
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
char * fname
void StoreObject(const char *cdbPath, TObject *object, AliCDBMetaData *metaData)