Include HLTTemperature OCDB entry to select temperature sensors to be handled by HLT
[u/mrichter/AliRoot.git] / TPC / AliTPCGenDBTemp.cxx
1
2 // TTimeStamp startTime(2006,10,18,0,0,0,0,kFALSE)
3 // TTimeStamp endTime(2006,10,19,0,0,0,0,kFALSE)
4 // Int_t run=2546
5 // AliTPCGenDBTemp db
6 // db->Init(run,"TPC/Config/Temperature","TPC/*/*")
7 // db->MakeCalib("TempSensor.txt","DCSMap.root",startTime,endTime,run)
8
9 //  Data base entry generation:
10   
11 //  AliTPCGenDBTemp db
12 //  db->SetDefaultStorage("local://$ALICE_ROOT");
13 //  db->SetSpecificStorage("local:///afs/cern.ch/alice/tpctest/Calib/");
14 //  db->Init(0,"TPC/Config/Temperature","TPC/*/*")
15 //  db->MakeConfig("TempSensor.txt",0,999999999,"TPC/Config/Temperature")
16
17   
18
19
20
21
22 #include "AliTPCGenDBTemp.h"
23 #include "AliLog.h"
24
25 ClassImp(AliTPCGenDBTemp)
26
27 const Int_t kValCut = 100;         // discard temperatures > 100 degrees
28 const Int_t kDiffCut = 5;          // discard temperature differences > 5 degrees
29
30 //______________________________________________________________________________________________
31
32 AliTPCGenDBTemp::AliTPCGenDBTemp():
33    AliDCSGenDB()
34 {
35 }
36
37 //______________________________________________________________________________________________
38
39 AliTPCGenDBTemp::AliTPCGenDBTemp(const char *defaultStorage, const char *specificStorage) :
40    AliDCSGenDB(defaultStorage,specificStorage)
41 {
42 }
43
44 //______________________________________________________________________________________________
45
46 AliTPCGenDBTemp::AliTPCGenDBTemp(const AliTPCGenDBTemp& org) : AliDCSGenDB(org)
47 {
48
49 //
50 //  Copy constructor
51 //
52  AliError("copy constructor not implemented");
53
54 }
55
56 //______________________________________________________________________________________________
57 AliTPCGenDBTemp::~AliTPCGenDBTemp(){
58 //
59 // destructor
60 //
61
62 }
63 //______________________________________________________________________________________________
64 AliTPCGenDBTemp& AliTPCGenDBTemp::operator= (const AliTPCGenDBTemp&  )
65 {
66  //
67  // assignment operator
68  //
69  AliError("assignment operator not implemented");
70  return *this;
71 }
72
73
74 //______________________________________________________________________________________________
75
76 void AliTPCGenDBTemp::MakeCalib(const char *fList, const char *fMap,
77                              const TTimeStamp& startTime,
78                              const TTimeStamp& endTime,
79                              Int_t run )
80 {
81    // The Terminate() function is the last function to be called during
82    // a query. It always runs on the client, it can be used to present
83    // the results graphically or save the results to file.
84
85    AliTPCSensorTempArray *temperature = new AliTPCSensorTempArray(fList);
86    temperature->SetStartTime(startTime);
87    temperature->SetEndTime(endTime);
88    temperature->SetValCut(kValCut);
89    temperature->SetDiffCut(kDiffCut);
90    TMap* map = SetGraphFile(fMap);
91    if (map) {
92      temperature->MakeSplineFit(map);
93    }
94    delete map;
95    map=0;
96    fMap=0;
97
98    SetFirstRun(run);
99    SetLastRun(run);
100    SetSensorArray(temperature);
101    StoreObject("TPC/Calib/Temperature",temperature, fMetaData);
102 }
103
104 //______________________________________________________________________________________________
105
106 TClonesArray * AliTPCGenDBTemp::ReadList(const char *fname, const char *title,
107                        const TString& amandaString) {
108   //
109   // read values from ascii file
110   //
111   TTree* tree = new TTree(title,title);
112   tree->ReadFile(fname,"");
113   TClonesArray *arr;
114   if ( amandaString.Length()== 0 ) {
115     arr = AliTPCSensorTemp::ReadTree(tree);
116   } else {
117     arr = AliTPCSensorTemp::ReadTree(tree,amandaString);
118   }
119   delete tree;
120   return arr;
121 }
122
123 //______________________________________________________________________________________________
124
125 TTree * AliTPCGenDBTemp::ReadListTree(const char *fname, const char *title,
126                          const TString& amandaString) {
127   //
128   // read values from ascii file
129   //
130   TTree* tree = new TTree(title,title);
131   tree->ReadFile(fname,"");
132   TClonesArray *arr;
133   if ( amandaString.Length()== 0 ) {
134     arr = AliTPCSensorTemp::ReadTree(tree);
135   } else {
136     arr = AliTPCSensorTemp::ReadTree(tree,amandaString);
137   }
138   arr->Delete();
139   delete arr;
140   return tree;
141 }
142 //______________________________________________________________________________________________
143 void AliTPCGenDBTemp::MakeConfig(const char *file, Int_t firstRun, Int_t lastRun, 
144                              const char *confDir, const TString& amandaString)
145 {
146    //
147    // Store Configuration file to OCDB
148    //
149
150    TTree *tree = ReadListTree(file,"tempConf",amandaString);
151    SetConfTree(tree);
152    SetFirstRun(firstRun);
153    SetLastRun(lastRun);
154
155    StoreObject(confDir, fConfTree, fMetaData);
156 }
157
158