correct Hash in TMap, reading channel names
[u/mrichter/AliRoot.git] / T0 / AliT0SetCDB.C
CommitLineData
dc7ca31d 1/* $Id$ */
2
3// Script to create calibration parameters and store them into CDB
4// Two sets of calibration parameters can be created:
5// 1) equal parameters
6// 2) randomly distributed parameters for decalibrated detector silumations
7
8#if !defined(__CINT__)
9#include "TControlBar.h"
10#include "TString.h"
11#include "TRandom.h"
12#include "TH1F.h"
13#include "TF1.h"
14#include "TCanvas.h"
15
16#include "AliRun.h"
17#include "AliT0CalibData.h"
18#include "AliT0AlignData.h"
19#include "AliCDBMetaData.h"
20#include "AliCDBId.h"
21#include "AliCDBEntry.h"
22#include "AliCDBManager.h"
23#include "AliCDBStorage.h"
24#endif
25
26
27void AliT0SetCDB()
28{
29 TControlBar *menu = new TControlBar("vertical","T0 CDB");
c41ceaac 30 menu->AddButton("Set time delay","SetTimeDelay()",
31 "Set time dalay");
32 menu->AddButton("Set walk","SetWalk()",
33 "Set slewing coorection");
5325480c 34 menu->AddButton("Set Align","SetAC()",
dc7ca31d 35 "Set alignment coefficients");
6ba20b30 36 menu->AddButton("Set LookUpTable","SetLookUp()",
37 "Set LookUp table");
c41ceaac 38 menu->AddButton("Read time delay","GetTimeDelay()",
39 "Read time delay");
5325480c 40 menu->AddButton("Read walk","GetWalk()",
c41ceaac 41 "Read amplitude-time correction");
dc7ca31d 42 menu->AddButton("Read alignment CC","GetAC()",
43 "Read face detector position ");
6ba20b30 44 menu->AddButton("Read Lookup","GetLookUp()",
45 "Read Lookup table ");
dc7ca31d 46 menu->Show();
47}
48
49
50//------------------------------------------------------------------------
51void SetAC()
52{
53 // Writing alignment coefficients into the Condition DB
54 // Arguments:
55
56 TString DBFolder;
57 Int_t firstRun = 0;
58 Int_t lastRun = 10;
59 Int_t beamPeriod = 1;
60 char* objFormat = "";
61
62 DBFolder ="local://Align";
63 firstRun = 0;
64 lastRun = 10;
65 objFormat = "T0 array Z positions";
66
67
68 AliT0AlignData *alignda=new AliT0AlignData("T0");
69 alignda-> SetZposition (67.9,373);
70 alignda->Print();
71
72 //Store calibration data into database
73 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
74 AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
75
76 AliCDBMetaData md;
77 md.SetComment(objFormat);
78 md.SetBeamPeriod(beamPeriod);
79 md.SetResponsible("Alla");
80 TString fPath="T0/Align/Positions";
81
82
83 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
84 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
6ba20b30 85 if(storage) {
dc7ca31d 86 AliCDBId id(fPath.Data(),firstRun,lastRun);
87
88 storage->Put(alignda, id, &md);
89 }
90}
91//------------------------------------------------------------------------
c41ceaac 92void SetTimeDelay()
dc7ca31d 93{
94 // Writing calibration coefficients into the Calibration DB
95 // Arguments:
96
97 TString DBFolder;
98 Int_t firstRun = 0;
99 Int_t lastRun = 10;
100 Int_t beamPeriod = 1;
101 char* objFormat = "";
102
103 DBFolder ="local://Calib";
104 firstRun = 0;
105 lastRun = 10;
c41ceaac 106 objFormat = "T0 initial time delay";
dc7ca31d 107
108 AliT0CalibData *calibda=new AliT0CalibData("T0");
109
c41ceaac 110 Float_t fTimeDelay = 1000;
d530f23a 111
112 //for timeDelayDA now we are using Int mean time (+-3RMS fit)
113 //in number of channel for time in each chanel for
114 //1000 Hijingpara nparticles=500 & zvertex=0 produced by readDigits.C
115 // this is way to simulate time positon for vertex=0
116 //with unknown time delay in channel
117 /*
118 Int_t timedelayDA[24] = {501, 509, 511,510 ,510, 510, 509, 509, 510,
119 510, 509, 508, 511, 510, 509, 508,510,
120 510, 511, 510, 510, 510, 509, 510};
121
122 */
c41ceaac 123 for(Int_t ipmt=0; ipmt<24; ipmt++) {
124 calibda->SetTimeDelayCFD(fTimeDelay+ipmt*100,ipmt);
d530f23a 125 // calibda->SetTimeDelayLED(fTimeDelay,ipmt);
126// calibda->SetTimeDelayDA(timedelayDA[ipmt],ipmt);
127 calibda->SetTimeDelayDA(500,ipmt);
c41ceaac 128 }
d530f23a 129 calibda->SetMeanT0(499);
c41ceaac 130 calibda->Print();
131 //Store calibration data into database
132 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
133
134 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
135
136 AliCDBMetaData md;
137 md.SetComment(objFormat);
138 md.SetBeamPeriod(beamPeriod);
139 md.SetResponsible("Alla");
140 TString fPath="T0/Calib/TimeDelay";
141
142
143 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
144 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
145 if(storage) {
146 AliCDBId id(fPath.Data(),firstRun,lastRun);
147 storage->Put(calibda, id, &md);
148 }
149}
150
151//------------------------------------------------------------------------
152void SetWalk()
153{
154 // Writing calibration coefficients into the Calibration DB
155 // Arguments:
156
157 TString DBFolder;
158 Int_t firstRun = 0;
159 Int_t lastRun = 10;
160 Int_t beamPeriod = 1;
161 char* objFormat = "";
162
163 DBFolder ="local://Calib";
164 firstRun = 0;
165 lastRun = 10;
166 objFormat = "T0 initial slewnig correction";
167
168 AliT0CalibData *calibda=new AliT0CalibData("T0");
169
170
dc7ca31d 171 TRandom rn;
172
173 for(Int_t ipmt=0; ipmt<24; ipmt++) {
5325480c 174 calibda->SetWalk(ipmt);
29d3e0eb 175 calibda->SetAmpLEDRec(ipmt);
dc7ca31d 176 }
dc7ca31d 177 //Store calibration data into database
178 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
179
180 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
181
182 AliCDBMetaData md;
183 md.SetComment(objFormat);
184 md.SetBeamPeriod(beamPeriod);
185 md.SetResponsible("Alla");
c41ceaac 186 TString fPath="T0/Calib/Slewing_Walk";
dc7ca31d 187
188
189 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
190 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
191 if(storage) {
192 AliCDBId id(fPath.Data(),firstRun,lastRun);
193 storage->Put(calibda, id, &md);
194 }
195}
196
197//------------------------------------------------------------------------
c41ceaac 198void GetTimeDelay()
dc7ca31d 199{
200 // Read calibration coefficients into the Calibration DB
201 // Arguments:
202
203 TString DBFolder;
204
205 DBFolder ="local://Calib";
206 Int_t nRun=gAlice->GetRunNumber();
207
c41ceaac 208 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT");
209 AliCDBEntry* entry = stor->Get("T0/Calib/TimeDelay",0);
210
dc7ca31d 211 AliT0CalibData *clb = (AliT0CalibData*)entry->GetObject();
212 clb->Print();
d530f23a 213 for (Int_t i=0; i<24; i++) {
214 cout<<clb->GetTimeDelayCFD(i)<<" "<<clb->GetTimeDelayDA(i)<<endl;
215 cout<<" equalizing CFD "<<(clb->GetTimeDelayCFD(i)-clb->GetTimeDelayCFD(0))<<endl;
216 cout<<" equalizing DA "<<(clb->GetTimeDelayDA(i)-clb->GetTimeDelayDA(0))<<endl;
217 }
218
dc7ca31d 219}
220//------------------------------------------------------------------------
c41ceaac 221void GetWalk()
222{
223 // Read calibration coefficients into the Calibration DB
224 // Arguments:
225
226 TString DBFolder;
227
228 DBFolder ="local://Calib";
229 Int_t nRun=gAlice->GetRunNumber();
230
231 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT");
232 AliCDBEntry* entry = stor->Get("T0/Calib/Slewing_Walk",0);
233
234 AliT0CalibData *clb = (AliT0CalibData*)entry->GetObject();
235 Int_t ipmt=0;
236 // cin>>" enter channel number">>ipmt;
29d3e0eb 237 TGraph *gr = clb->GetAmpLEDRec(ipmt);
c41ceaac 238 gr->Draw("AP");
239}
240//------------------------------------------------------------------------
dc7ca31d 241void GetAC()
242{
243 // Read align coefficients into the Calibration DB
244 // Arguments:
245
246 TString DBFolder;
247
248 DBFolder ="local://Align";
249 Int_t nRun=gAlice->GetRunNumber();
250
251 AliCDBManager *man = AliCDBManager::Instance();
252 AliCDBStorage *stor2 = man->GetStorage("local://Align");
253 AliCDBEntry *entry;
254 entry = stor2->Get("T0/Align/Positions", nRun);
255
256 AliT0AlignData *aln = (AliT0AlignData*)entry->GetObject();
257 aln->Print();
258}
6ba20b30 259//------------------------------------------------------------------------
260void SetLookUp()
261{
262 // Writing Lookup table into the Calibration DB
263 // Arguments:
264
265 TString DBFolder;
266 Int_t firstRun = 0;
267 Int_t lastRun = 10;
268 Int_t beamPeriod = 1;
269 char* objFormat = "";
270
271 DBFolder ="local://Calib";
272 firstRun = 0;
273 lastRun = 10;
274 objFormat = "T0 Lookup Table";
275
276 AliT0CalibData *calibda=new AliT0CalibData("T0");
277
278 calibda->ReadAsciiLookup("lookUpTable.txt");
5325480c 279
6ba20b30 280 //Store calibration data into database
281 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
282
283 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
284
285 AliCDBMetaData md;
286 md.SetComment(objFormat);
287 md.SetBeamPeriod(beamPeriod);
288 md.SetResponsible("Alla");
289 TString fPath="T0/Calib/LookUp_Table";
290
291
292 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
293 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
294 if(storage) {
295 AliCDBId id(fPath.Data(),firstRun,lastRun);
296 storage->Put(calibda, id, &md);
297 }
298}
299//------------------------------------------------------------------------
300void GetLookUp()
301{
302 // Read calibration coefficients into the Calibration DB
303 // Arguments:
304
305 TString DBFolder;
306
307 // DBFolder ="local://Calib";
308 // Int_t nRun=gAlice->GetRunNumber();
309 AliCDBManager* cdb = AliCDBManager::Instance();
310 AliCDBStorage *stor = cdb->GetStorage("local://$ALICE_ROOT");
311 // cout<<" GetLookUp :: "<<stor<<endl;
312 AliCDBEntry *entry;
313 //entry = stor->Get("T0/Calib/LookUp_Table",2,0,0);
314 entry = stor->Get("T0/Calib/LookUp_Table",1);
315 //cout<<"entry="<<entry<<endl;
316 cout<<" AliT0CalibData ::GetLookUp :: "<<entry<<endl;
317 AliT0CalibData *clb = (AliT0CalibData*)entry->GetObject();
318 cout<<" AliT0CalibData *clb "<<clb <<endl;
319 //cout<<"clb->a="<<clb->GetA()<<endl;
320 // clb->Dump();
d530f23a 321 for (Int_t i=0; i<20; i++)
322 clb->PrintLookupNames("all",i);
6ba20b30 323
324}