New method to get the ratio between the expected and actual cluster shape. Will be...
[u/mrichter/AliRoot.git] / STEER / AliDCSGenDB.cxx
CommitLineData
45f03c4d 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
17///////////////////////////////////////////////////////////////////////////////
18// //
19// Class to generate DCS data base entries //
20// Author: Haavard Helstrup //
21// //
22///////////////////////////////////////////////////////////////////////////////
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
820e68e8 32// db->Init(run,"TPC/Config/Pressure","TPC/*/*")
33// db->MakeCalib("PressureSensor.txt","DCSMap.root",startTime,endTime,firstRun,lastRun,"TPC/Calib/Pressure")
45f03c4d 34
35
36#include "AliDCSGenDB.h"
820e68e8 37#include "AliLog.h"
45f03c4d 38
39const char *kDefaultStorage="local:///afs/cern.ch/alice/tpctest/AliRoot/HEAD";
40const char *kSpecificStorage="local:///afs/cern.ch/alice/tpctest/Calib/";
41const char *kSensorClass = "AliDCSSensorArray";
42const Int_t kBeamPeriod=2;
43
44ClassImp(AliDCSGenDB)
45
46//______________________________________________________________________________________________
47
48AliDCSGenDB::AliDCSGenDB():
49 fFirstRun(0),
50 fLastRun(0),
51 fSpecificStorage(kSpecificStorage),
52 fDefaultStorage(kDefaultStorage),
53 fSensor(0),
54 fStorLoc(0),
45f03c4d 55 fMetaData(0),
56 fConfTree(0)
57//
58// standard constructor
59//
60{}
61
62//______________________________________________________________________________________________
63
64AliDCSGenDB::AliDCSGenDB(const AliDCSGenDB& org):
65 TObject(org),
66 fFirstRun(org.fFirstRun),
67 fLastRun(org.fLastRun),
68 fSpecificStorage(org.fSpecificStorage),
69 fDefaultStorage(org.fDefaultStorage),
70 fSensor(0),
71 fStorLoc(0),
45f03c4d 72 fMetaData(0),
73 fConfTree(0)
74{
75//
76// Copy constructor
77//
78
820e68e8 79 AliError("copy constructor not implemented");
80
45f03c4d 81}
82
83//______________________________________________________________________________________________
84AliDCSGenDB::~AliDCSGenDB(){
85//
86// destructor
87//
45f03c4d 88 delete fSensor;
89 delete fMetaData;
90 delete fConfTree;
91}
92
93//______________________________________________________________________________________________
94AliDCSGenDB& AliDCSGenDB::operator= (const AliDCSGenDB& org )
95{
96 //
97 // assignment operator
98 //
820e68e8 99 AliError("assignment operator not implemented");
45f03c4d 100 return *this;
101}
102
103//______________________________________________________________________________________________
45f03c4d 104
45f03c4d 105void AliDCSGenDB::MakeCalib(const char *list, const char *mapDCS,
106 const TTimeStamp& startTime,
107 const TTimeStamp& endTime,
108 Int_t firstRun, Int_t lastRun, const char *calibDir )
109{
110 // The Terminate() function is the last function to be called during
111 // a query. It always runs on the client, it can be used to present
112 // the results graphically or save the results to file.
113
114 TClonesArray *arr = ReadList(list);
115 AliDCSSensorArray *fSensor = new AliDCSSensorArray(arr);
116 fSensor->SetStartTime(startTime);
117 fSensor->SetEndTime(endTime);
118 TMap* map = SetGraphFile(mapDCS);
119 if (map) {
120 fSensor->MakeSplineFit(map);
121 }
122 delete map;
123 map=0;
124 mapDCS=0;
125
126 SetFirstRun(firstRun);
127 SetLastRun(lastRun);
128
129 StoreObject(calibDir, fSensor, fMetaData);
130}
131
132//______________________________________________________________________________________________
133void AliDCSGenDB::MakeConfig(const char *file, Int_t firstRun, Int_t lastRun, const char *confDir )
134{
135 //
136 // Store Configuration file to OCDB
137 //
138
139 TTree *tree = ReadListTree(file);
140 SetConfTree(tree);
141 SetFirstRun(firstRun);
142 SetLastRun(lastRun);
143
144 StoreObject(confDir, fConfTree, fMetaData);
145}
146
147
148
149
150//______________________________________________________________________________________________
151AliCDBMetaData* AliDCSGenDB::CreateMetaObject(const char* objectClassName)
152{
153 AliCDBMetaData *md1= new AliCDBMetaData();
154 md1->SetObjectClassName(objectClassName);
155 md1->SetResponsible("Haavard Helstrup");
156 md1->SetBeamPeriod(kBeamPeriod);
157 md1->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
158
159 return md1;
160}
161
162//______________________________________________________________________________________________
163void AliDCSGenDB::StoreObject(const char* cdbPath, TObject* object, AliCDBMetaData* metaData)
164{
165
166 AliCDBId id1(cdbPath, fFirstRun, fLastRun);
167 if (fStorLoc) fStorLoc->Put(object, id1, metaData);
168}
169
170//______________________________________________________________________________________________
171void AliDCSGenDB::Init(Int_t run, const char *configDir, const char *specificDir)
172{
173
174 fMetaData = CreateMetaObject(kSensorClass);
175 AliCDBManager *man = AliCDBManager::Instance();
176 man->SetDefaultStorage(fDefaultStorage);
177 man->SetRun(run);
178 man->SetSpecificStorage(specificDir,fSpecificStorage);
179 AliCDBEntry *config = man->Get(configDir);
180 if (config) fConfTree = (TTree*)config->GetObject();
181 fStorLoc = man->GetStorage(fSpecificStorage);
182 if (!fStorLoc) return;
183
820e68e8 184 Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
185 AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
186
45f03c4d 187
188}
189
190//______________________________________________________________________________________________
191
192
193//_____________________________________________________________________________
194TMap* AliDCSGenDB::SetGraphFile(const char *fname)
195{
196 //
197 // Read DCS maps from file given by fname
198 //
199 TFile file(fname);
200 TMap * map = (TMap*)file.Get("DCSMap");
201 return map;
202}
203
204//______________________________________________________________________________________________
205
206TClonesArray * AliDCSGenDB::ReadList(const char *fname, const char *title) {
207 //
208 // read values from ascii file
209 //
210 TTree* tree = new TTree(title,title);
211 tree->ReadFile(fname,"");
212 TClonesArray *arr = AliDCSSensor::ReadTree(tree);
213 delete tree;
214 return arr;
215}
216
217//______________________________________________________________________________________________
218
219TTree * AliDCSGenDB::ReadListTree(const char *fname, const char *title) {
220 //
221 // read values from ascii file
222 //
223 TTree* tree = new TTree(title,title);
224 tree->ReadFile(fname,"");
225 TClonesArray *arr = AliDCSSensor::ReadTree(tree);
226 arr->Delete();
227 delete arr;
228 return tree;
229}
230
231
232