Ensure vacuum inside the beam pipe for upgrade (Mario)
[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"
ec7c616e 18//#include "AliT0AlignData.h"
19#include "AliT0Align.h"
dc7ca31d 20#include "AliCDBMetaData.h"
21#include "AliCDBId.h"
22#include "AliCDBEntry.h"
23#include "AliCDBManager.h"
24#include "AliCDBStorage.h"
25#endif
26
27
28void AliT0SetCDB()
29{
30 TControlBar *menu = new TControlBar("vertical","T0 CDB");
c41ceaac 31 menu->AddButton("Set time delay","SetTimeDelay()",
5f9e5bd6 32 "Set time delay");
c41ceaac 33 menu->AddButton("Set walk","SetWalk()",
34 "Set slewing coorection");
5325480c 35 menu->AddButton("Set Align","SetAC()",
dc7ca31d 36 "Set alignment coefficients");
6ba20b30 37 menu->AddButton("Set LookUpTable","SetLookUp()",
38 "Set LookUp table");
c41ceaac 39 menu->AddButton("Read time delay","GetTimeDelay()",
40 "Read time delay");
5325480c 41 menu->AddButton("Read walk","GetWalk()",
c41ceaac 42 "Read amplitude-time correction");
dc7ca31d 43 menu->AddButton("Read alignment CC","GetAC()",
44 "Read face detector position ");
6ba20b30 45 menu->AddButton("Read Lookup","GetLookUp()",
46 "Read Lookup table ");
dc7ca31d 47 menu->Show();
48}
49
50
51//------------------------------------------------------------------------
52void SetAC()
53{
54 // Writing alignment coefficients into the Condition DB
55 // Arguments:
56
57 TString DBFolder;
58 Int_t firstRun = 0;
52475568 59 Int_t lastRun = 99999;
dc7ca31d 60 Int_t beamPeriod = 1;
61 char* objFormat = "";
62
63 DBFolder ="local://Align";
64 firstRun = 0;
52475568 65 lastRun = 99999;
ec7c616e 66 objFormat = "T0 array positions";
dc7ca31d 67
ec7c616e 68 AliT0Align *al = new AliT0Align(1,835615);
69 al->Run();
70
71 /*
dc7ca31d 72 AliT0AlignData *alignda=new AliT0AlignData("T0");
73 alignda-> SetZposition (67.9,373);
74 alignda->Print();
75
76 //Store calibration data into database
162637e4 77 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
dc7ca31d 78 AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
79
80 AliCDBMetaData md;
81 md.SetComment(objFormat);
82 md.SetBeamPeriod(beamPeriod);
83 md.SetResponsible("Alla");
84 TString fPath="T0/Align/Positions";
85
86
87 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
88 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
6ba20b30 89 if(storage) {
dc7ca31d 90 AliCDBId id(fPath.Data(),firstRun,lastRun);
91
92 storage->Put(alignda, id, &md);
93 }
ec7c616e 94 */
dc7ca31d 95}
96//------------------------------------------------------------------------
c41ceaac 97void SetTimeDelay()
dc7ca31d 98{
99 // Writing calibration coefficients into the Calibration DB
100 // Arguments:
101
102 TString DBFolder;
103 Int_t firstRun = 0;
52475568 104 Int_t lastRun = 99999;
dc7ca31d 105 Int_t beamPeriod = 1;
106 char* objFormat = "";
107
108 DBFolder ="local://Calib";
109 firstRun = 0;
52475568 110 lastRun = 999999;
c41ceaac 111 objFormat = "T0 initial time delay";
dc7ca31d 112
5f9e5bd6 113 AliT0CalibTimeEq *calibda=new AliT0CalibTimeEq("T0");
dc7ca31d 114
c41ceaac 115 Float_t fTimeDelay = 1000;
5f9e5bd6 116 for(Int_t ipmt=0; ipmt<24; ipmt++) {
117 calibda->SetTimeEq(ipmt,fTimeDelay+ipmt*100);
52475568 118
c41ceaac 119 }
52475568 120
c41ceaac 121 calibda->Print();
122 //Store calibration data into database
162637e4 123 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
c41ceaac 124
125 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
126
127 AliCDBMetaData md;
128 md.SetComment(objFormat);
129 md.SetBeamPeriod(beamPeriod);
130 md.SetResponsible("Alla");
131 TString fPath="T0/Calib/TimeDelay";
132
133
134 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
135 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
136 if(storage) {
137 AliCDBId id(fPath.Data(),firstRun,lastRun);
138 storage->Put(calibda, id, &md);
139 }
140}
141
142//------------------------------------------------------------------------
143void SetWalk()
144{
145 // Writing calibration coefficients into the Calibration DB
146 // Arguments:
147
148 TString DBFolder;
149 Int_t firstRun = 0;
52475568 150 Int_t lastRun = 999999;
c41ceaac 151 Int_t beamPeriod = 1;
152 char* objFormat = "";
153
154 DBFolder ="local://Calib";
155 firstRun = 0;
52475568 156 lastRun = 999999;
c41ceaac 157 objFormat = "T0 initial slewnig correction";
158
5f9e5bd6 159 AliT0CalibWalk *calibda=new AliT0CalibWalk("T0");
c41ceaac 160
161
dc7ca31d 162 TRandom rn;
163
164 for(Int_t ipmt=0; ipmt<24; ipmt++) {
5325480c 165 calibda->SetWalk(ipmt);
29d3e0eb 166 calibda->SetAmpLEDRec(ipmt);
dc7ca31d 167 }
dc7ca31d 168 //Store calibration data into database
162637e4 169 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
dc7ca31d 170
171 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
172
173 AliCDBMetaData md;
174 md.SetComment(objFormat);
175 md.SetBeamPeriod(beamPeriod);
176 md.SetResponsible("Alla");
c41ceaac 177 TString fPath="T0/Calib/Slewing_Walk";
dc7ca31d 178
179
180 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
181 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
182 if(storage) {
183 AliCDBId id(fPath.Data(),firstRun,lastRun);
184 storage->Put(calibda, id, &md);
185 }
186}
187
188//------------------------------------------------------------------------
c41ceaac 189void GetTimeDelay()
dc7ca31d 190{
191 // Read calibration coefficients into the Calibration DB
192 // Arguments:
193
194 TString DBFolder;
195
196 DBFolder ="local://Calib";
197 Int_t nRun=gAlice->GetRunNumber();
198
162637e4 199 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB");
c41ceaac 200 AliCDBEntry* entry = stor->Get("T0/Calib/TimeDelay",0);
201
5f9e5bd6 202 AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entry->GetObject();
dc7ca31d 203 clb->Print();
d530f23a 204 for (Int_t i=0; i<24; i++) {
5f9e5bd6 205 cout<<clb->GetTimeEq(i)<<endl;
206 // cout<<" equalizing CFD "<<(clb->GetTimeDelayCFD(i)-clb->GetTimeDelayCFD(0))<<endl;
207
d530f23a 208 }
209
dc7ca31d 210}
211//------------------------------------------------------------------------
c41ceaac 212void GetWalk()
213{
214 // Read calibration coefficients into the Calibration DB
215 // Arguments:
216
217 TString DBFolder;
218
219 DBFolder ="local://Calib";
220 Int_t nRun=gAlice->GetRunNumber();
221
162637e4 222 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB");
c41ceaac 223 AliCDBEntry* entry = stor->Get("T0/Calib/Slewing_Walk",0);
224
5f9e5bd6 225 AliT0CalibWalk *clb = (AliT0CalibWalk*)entry->GetObject();
c41ceaac 226 Int_t ipmt=0;
227 // cin>>" enter channel number">>ipmt;
29d3e0eb 228 TGraph *gr = clb->GetAmpLEDRec(ipmt);
c41ceaac 229 gr->Draw("AP");
230}
231//------------------------------------------------------------------------
dc7ca31d 232void GetAC()
233{
234 // Read align coefficients into the Calibration DB
235 // Arguments:
236
237 TString DBFolder;
238
239 DBFolder ="local://Align";
240 Int_t nRun=gAlice->GetRunNumber();
241
242 AliCDBManager *man = AliCDBManager::Instance();
243 AliCDBStorage *stor2 = man->GetStorage("local://Align");
244 AliCDBEntry *entry;
245 entry = stor2->Get("T0/Align/Positions", nRun);
246
247 AliT0AlignData *aln = (AliT0AlignData*)entry->GetObject();
248 aln->Print();
249}
6ba20b30 250//------------------------------------------------------------------------
251void SetLookUp()
252{
253 // Writing Lookup table into the Calibration DB
254 // Arguments:
255
256 TString DBFolder;
257 Int_t firstRun = 0;
258 Int_t lastRun = 10;
259 Int_t beamPeriod = 1;
260 char* objFormat = "";
261
262 DBFolder ="local://Calib";
263 firstRun = 0;
264 lastRun = 10;
265 objFormat = "T0 Lookup Table";
266
267 AliT0CalibData *calibda=new AliT0CalibData("T0");
268
ec7c616e 269// calibda->ReadAsciiLookup("lookUpTable.txt");
270 calibda->ReadAsciiLookup("lookUpTable_tanay.txt");
5325480c 271
6ba20b30 272 //Store calibration data into database
162637e4 273 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
6ba20b30 274
275 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
276
277 AliCDBMetaData md;
278 md.SetComment(objFormat);
279 md.SetBeamPeriod(beamPeriod);
280 md.SetResponsible("Alla");
281 TString fPath="T0/Calib/LookUp_Table";
282
283
284 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
285 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
286 if(storage) {
287 AliCDBId id(fPath.Data(),firstRun,lastRun);
288 storage->Put(calibda, id, &md);
289 }
290}
291//------------------------------------------------------------------------
292void GetLookUp()
293{
294 // Read calibration coefficients into the Calibration DB
295 // Arguments:
296
297 TString DBFolder;
298
299 // DBFolder ="local://Calib";
300 // Int_t nRun=gAlice->GetRunNumber();
301 AliCDBManager* cdb = AliCDBManager::Instance();
162637e4 302 AliCDBStorage *stor = cdb->GetStorage("local://$ALICE_ROOT/OCDB");
6ba20b30 303 // cout<<" GetLookUp :: "<<stor<<endl;
304 AliCDBEntry *entry;
305 //entry = stor->Get("T0/Calib/LookUp_Table",2,0,0);
306 entry = stor->Get("T0/Calib/LookUp_Table",1);
307 //cout<<"entry="<<entry<<endl;
308 cout<<" AliT0CalibData ::GetLookUp :: "<<entry<<endl;
309 AliT0CalibData *clb = (AliT0CalibData*)entry->GetObject();
310 cout<<" AliT0CalibData *clb "<<clb <<endl;
311 //cout<<"clb->a="<<clb->GetA()<<endl;
312 // clb->Dump();
d530f23a 313 for (Int_t i=0; i<20; i++)
314 clb->PrintLookupNames("all",i);
6ba20b30 315
316}