1 /* $Id: AliT0SetCDB.C 22796 2007-12-06 11:32:28Z alla $ */
3 // Script to create calibration parameters and store them into CDB
4 // Two sets of calibration parameters can be created:
6 // 2) randomly distributed parameters for decalibrated detector silumations
9 #include "TControlBar.h"
17 #include "AliT0CalibData.h"
18 //#include "AliT0AlignData.h"
19 #include "AliT0Align.h"
20 #include "AliCDBMetaData.h"
22 #include "AliCDBEntry.h"
23 #include "AliCDBManager.h"
24 #include "AliCDBStorage.h"
28 void AliT0SetCDBcosmic()
30 TControlBar *menu = new TControlBar("vertical","T0 CDB");
31 menu->AddButton("Set time delay","SetTimeDelay()",
33 menu->AddButton("Set walk","SetWalk()",
34 "Set slewing coorection");
35 menu->AddButton("Set LookUpTable","SetLookUp()",
37 menu->AddButton("Read time delay","GetTimeDelay()",
39 menu->AddButton("Read walk","GetWalk()",
40 "Read amplitude-time correction");
41 menu->AddButton("Read Lookup","GetLookUp()",
42 "Read Lookup table ");
43 menu->AddButton("SetLatency","setLat()",
45 menu->AddButton("ReadLatency","readLat()",
51 //------------------------------------------------------------------------
52 //------------------------------------------------------------------------
55 // Writing calibration coefficients into the Calibration DB
61 char* objFormat = "T0 initial time delay";
63 DBFolder ="local://Calib";
65 // Int_t shift[24] = {0, 0,0,0,0,0,0,0,0,0,0,0,
66 // 0, 0,0,0,0,0,0,0,0,0,0,0};
67 // Int_t shift[24] = {0, };
69 // Int_t shift[24] = {-17, 0, 14, 48, 36, 35, 16 , -23, , 72, 50, 44,-15,
70 // 0, 13, -32, -19, 32, -2, 20, 43, 20, 78, 43, 118};
72 // Int_t shift[24] = {-17, 0, 14, 50, 36, 34, 14, -22, 72, 50, 42, -15,
73 // 0, 13, -32, -19, 32, -2, 20, 43, 20, 78, 43, 118};
75 // Int_t shift[24] = {-17, 0, 14, 50, 36, 34, 14, -22, 72, 50, 42, -15,
76 // 0, 13, -32, -19, 32, -2, 20, 43, 40, 78, 43, 118};
78 // Int_t shift[24] = {0, 0, 14, 50, 37, 35, 16, -22, 72, 52, 42, -14,
79 // 0, 14, -32, -19, 31, -1, 20, 43, 37, 79, 42, 119};
81 // Int_t shift[24] = {0, 0, 14, 5, 37, 34, 15, -22, 72, 50, 42, -15,
82 // 0, 14, -32, -19, 31, -1, 20, 43, 37, 79, 42, 119};
84 // Int_t shift[24] = { 17, 0, 14, 47, 34 , 33, 18, -21, 72, 51, 42, -15,
85 // -15, 0, -47, -36, 22, -15, 9, 26, 1, 60, 23, 106};
87 // Int_t shift[24] = {18, 0, 16, 49, 36, 34, 22, -22, 71, 51, 43, -14,
88 // -15, 0, -48, -37, 19, -17, 9, 30, 4, 62, 24, 103};
91 // Int_t shift[24] = {19,0,16,51,36,37,24,-15,74,54,43,-13,
92 // -18,0,-42,-34,16,-16,8,27,4,57,24,104};
95 // Int_t shift[24] = {14,0,13,48,34,35,22,-20,73,52,40,-14,
96 // 0, 16,-27,-16, 32,0,20,45,19,72,40,121};
98 // Int_t shift[24] = {34,0,11,51,37,35,21,-20,70,47,40,-12,
99 // 0, 16,-27,-16, 32,0,20,45,19,72,40,119};
102 // Int_t shift[24] = {0, 0, 15, 50, 36, 35, 23, -20, 83, 53, 44, -11,
103 // 0 , 20 , -26 , -8 , 36 , 4 , 21 , 47 , 20 , 78 , 52 , 123};
105 // Int_t shift[24] = {20, 0 ,15, 50, 37, 36, 23, -20, 77, 54, 44, -12,
106 // 0, 19, -25, -13, 35, 1, 23, 46, 20, 77, 50, 122};
109 // Int_t shift[24] = {0, 0, 15, 51, 36, 34, 26, -20, 81, 53, 44, -12,
110 // 0 , 20 , -26 , -7 , 36 , 4 , 22 , 48 , 18 , 79 , 50 , 121};
114 Float_t shift[24]={8,0, 16, 50, 36, 34, 25, -20, 78, 54, 42, -11,
115 0, 21, -21, -7, 38, 5, 27, 50, 20, 78, 53, 124};
118 // Float_t shift[24]={16, 0, 2, 2, 30, 3, -5, -8, 5, -4, 16, -5,
119 // 0, 10, 10, 12, 13, -24, 15, 26, -2, 17, 10, -30};
121 // Float_t shift[24]={16, 0, 1, 3, 32, 4, -2, -8, 5, -3, 15, -5,
122 // 0, 10, 9, 12, 14, -23, 16, 26, 0, 19, 9, -31};
127 // Float_t shift[24]={16, 0, 1, 4, 33, 4, 0, -7, 6, -3, 15, -4,
128 // 0 , 10, 10, 13, 13, -23, 16, 28, 0, 19, 11, -29};
130 //for ( Int_t indexfile=filestart; indexfile < filestop+1;indexfile++ )
132 AliT0CalibTimeEq *calibda=new AliT0CalibTimeEq("T0");
133 // calibda-> ComputeOnlineParams("t0treeDA08000025762005.10.root");
135 for(Int_t ipmt=0; ipmt<24; ipmt++) {
136 calibda->SetTimeEq(ipmt,shift[ipmt]);
141 //Store calibration data into database
142 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
143 AliCDBManager::Instance()->SetDefaultStorage("local:///scratch/alla/alice/Jun10/TestCDB/");
145 md.SetComment(objFormat);
146 md.SetBeamPeriod(beamPeriod);
147 md.SetResponsible("Alla");
148 TString fPath="T0/Calib/TimeDelay";
149 //TString fPath="TimeDelay";
150 cout<<fPath.Data()<<endl;
152 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
153 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
155 // AliCDBId id(fPath.Data(),firstRun,AliCDBRunRange::Infinity() );
156 AliCDBId id(fPath.Data(),firstRun, lastRun );
157 storage->Put(calibda, id, &md);
161 //------------------------------------------------------------------------
164 // Writing calibration coefficients into the Calibration DB
168 Int_t firstRun = 1000;
169 Int_t lastRun = 999999999;
170 Int_t beamPeriod = 1;
171 char* objFormat = "";
173 DBFolder ="local://Calib";
174 objFormat = "T0 initial slewnig correction";
176 AliT0CalibWalk *calibda=new AliT0CalibWalk("T0");
177 // cout<<"AliT0CalibWalk "<< calibda<<endl;
179 const char *filename="amphist616.root";
180 calibda->MakeWalkCorrGraph(filename);
183 //Store calibTestCDB/T0/Calib/Slewing_Walk/ration data into database
184 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
185 AliCDBManager::Instance()->SetDefaultStorage("local:///home/alla/alice/Mar10/TestCDB/");
187 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
192 md.SetComment(objFormat);
193 md.SetBeamPeriod(beamPeriod);
194 md.SetResponsible("Alla");
195 TString fPath="T0/Calib/Slewing_Walk";
198 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
199 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
201 AliCDBId id(fPath.Data(),firstRun,lastRun);
202 storage->Put(calibda, id, &md);
207 //------------------------------------------------------------------------
210 // Read calibration coefficients into the Calibration DB
215 DBFolder ="local://Calib";
216 // Int_t nRun=gAlice->GetRunNumber();
218 // AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB");
219 // AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://");
220 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local:///scratch/alla/alice/Jun10/TestCDB/");
221 AliCDBEntry* entry = stor->Get("T0/Calib/TimeDelay",125095);
223 AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entry->GetObject();
225 for (Int_t i=0; i<24; i++) {
226 cout<<" "<<clb->GetTimeEq(i)<<" ";
227 // cout<<" equalizing CFD "<<(clb->GetTimeDelayCFD(i)-clb->GetTimeDelayCFD(0))<<endl;
232 //------------------------------------------------------------------------
235 // Read calibration coefficients into the Calibration DB
240 DBFolder ="local://Calib";
241 Int_t runNumber=127001;
242 // Int_t nRun=gAlice->GetRunNumber();
243 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local:///scratch/alla/alice/Jun10/TestCDB/");
244 // AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local:///home/alla/alice/May10/TestCDB/");
246 // AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB");
247 AliCDBEntry* entry = stor->Get("T0/Calib/Slewing_Walk",runNumber);
249 // AliT0Parameters* param = AliT0Parameters::Instance();
253 AliT0CalibWalk *clb = (AliT0CalibWalk*)entry->GetObject();
254 // cin>>" enter channel number">>ipmt;
256 TCanvas *c1 = new TCanvas("c1", "LED-CFD C side",0,48,1280,951);
258 for (Int_t i=0; i<12; i++) {
260 TGraph *gr = clb->GetAmpLED(i);
262 gr->GetXaxis()->SetTitle("led-cfd");
263 gr->GetYaxis()->SetTitle("MIPs");
264 gr->SetMarkerStyle(20);
268 buf3 = Form("ampplots/ampLEDminCFD_C_%i.png",runNumber);
272 TCanvas *c2 = new TCanvas("c2", "LED-CFD A side",0,48,1280,951);
274 for (Int_t i=12; i<24; i++) {
276 TGraph *gr = clb->GetAmpLED(i);
277 gr->GetXaxis()->SetTitle("led-cfd");
278 gr->GetYaxis()->SetTitle("MIPs");
279 gr->SetMarkerStyle(20);
282 buf3 = Form("ampplots/ampLEDminCFD_A_%i.png",runNumber);
286 TCanvas *c3 = new TCanvas("c3", "QTC C side",0,48,1280,951);
288 for (Int_t i=0; i<12; i++) {
290 TGraph *gr = clb->GetQTC(i);
292 gr->SetTitle(Form("PMT%i",i));
293 gr->GetXaxis()->SetTitle("qtc");
294 gr->GetYaxis()->SetTitle("MIPs");
295 gr->SetMarkerStyle(20);
299 buf3 = Form("ampplots/ampQTC_C_%i.png",runNumber);
303 TCanvas *c4 = new TCanvas("c4", "QTC A side",0,48,1280,951);
305 for (Int_t i=12; i<24; i++) {
307 TGraph *gr = clb->GetQTC(i);
308 // TGraph *gr = clb->GetWalk(i);
310 // TGraph *gr = clb->GetAmpLEDRec(i);
311 gr->SetTitle(Form("PMT%i",i));
312 gr->GetXaxis()->SetTitle("qtc");
313 gr->GetYaxis()->SetTitle("MIPs");
314 gr->SetMarkerStyle(20);
315 // gr->SetMarkerSize(20);
318 buf3 = Form("ampplots/ampQTC_A_%i.png",runNumber);
322 TCanvas *c5 = new TCanvas("c5", "walk LED-CFD C side",0,48,1280,951);
324 for (Int_t i=0; i<12; i++) {
326 TGraph *gr = clb->GetAmpLEDRec(i);
329 gr->SetTitle(Form("PMT%i",i));
330 gr->GetXaxis()->SetTitle("led-cfd");
331 gr->GetYaxis()->SetTitle("walk");
332 gr->SetMarkerStyle(20);
334 if(i==0) gr->Print();
338 buf3 = Form("ampplots/walkLEDminCFD_C_%i.png",runNumber);
341 TCanvas *c6 = new TCanvas("c6", "walk LED-CFD A side",0,48,1280,951);
343 for (Int_t i=12; i<24; i++) {
345 TGraph *gr = clb->GetAmpLEDRec(i);
346 gr->SetTitle(Form("PMT%i",i));
347 gr->GetXaxis()->SetTitle("led-cfd");
348 gr->GetYaxis()->SetTitle("walk");
349 gr->SetMarkerStyle(20);
354 buf3 = Form("ampplots/walkLEDminCFD_A_%i.png",runNumber);
357 TCanvas *c7 = new TCanvas("c7", "walk QTC C side",0,48,1280,951);
359 for (Int_t i=0; i<12; i++) {
361 TGraph *gr = clb->GetWalk(i);
364 gr->SetTitle(Form("PMT%i",i));
365 gr->GetXaxis()->SetTitle("qtc");
366 gr->GetYaxis()->SetTitle("walk");
367 gr->SetMarkerStyle(20);
369 if(i==0) gr->Print();
372 buf3 = Form("ampplots/walkQTC_C_%i.png",runNumber);
375 TCanvas *c8 = new TCanvas("c8", "walk QTC A side",0,48,1280,951);
377 for (Int_t i=12; i<24; i++) {
379 TGraph *gr = clb->GetWalk(i);
380 gr->SetTitle(Form("PMT%i",i));
381 gr->GetXaxis()->SetTitle("qtc");
382 gr->GetYaxis()->SetTitle("walk");
383 gr->SetMarkerStyle(20);
386 buf3 = Form("ampplots/walkQTC_A_%i.png",runNumber);
393 //------------------------------------------------------------------------
396 // Writing Lookup table into the Calibration DB
401 Int_t lastRun = 9999999;
402 Int_t beamPeriod = 1;
403 char* objFormat = "T0 Lookup Table";
405 AliT0CalibData *calibda=new AliT0CalibData("T0");
407 // calibda->ReadAsciiLookup("lookUpTable.txt");
408 calibda->ReadAsciiLookup("lookUpTable_tanay.txt");
410 //Store calibration data into database
411 AliCDBManager::Instance()->SetDefaultStorage("local:///home/alla/alice/testOct09/TestCDB");
413 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
416 md.SetComment(objFormat);
417 md.SetBeamPeriod(beamPeriod);
418 md.SetResponsible("Alla");
419 TString fPath="T0/Calib/LookUp_Table";
422 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
423 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
425 AliCDBId id(fPath.Data(),firstRun,lastRun);
426 storage->Put(calibda, id, &md);
429 //------------------------------------------------------------------------
432 // Read calibration coefficients into the Calibration DB
437 // DBFolder ="local://Calib";
438 // Int_t nRun=gAlice->GetRunNumber();
439 AliCDBManager* cdb = AliCDBManager::Instance();
440 AliCDBStorage *stor = cdb->GetStorage("local://$ALICE_ROOT/OCDB");
441 // cout<<" GetLookUp :: "<<stor<<endl;
443 //entry = stor->Get("T0/Calib/LookUp_Table",2,0,0);
444 entry = stor->Get("T0/Calib/LookUp_Table",1);
445 //cout<<"entry="<<entry<<endl;
446 cout<<" AliT0CalibData ::GetLookUp :: "<<entry<<endl;
447 AliT0CalibData *clb = (AliT0CalibData*)entry->GetObject();
448 cout<<" AliT0CalibData *clb "<<clb <<endl;
449 //cout<<"clb->a="<<clb->GetA()<<endl;
451 for (Int_t i=0; i<20; i++)
452 clb->PrintLookupNames("all",i);
455 //--------------------------------------------------------
460 AliCDBMetaData metaData;
461 metaData.SetBeamPeriod(0);
462 metaData.SetResponsible("Alla");
463 metaData.SetComment("Latency");
464 //Store calibration data into database
466 AliT0CalibLatency *calibda=new AliT0CalibLatency("T0");
468 calibda->SetLatencyHPTDC(9000);
471 // calibda-> SetLatencyL1(8.91358e+03);
472 // calibda-> SetLatencyL1A(8.91352e+03);
473 // calibda-> SetLatencyL1C(8.91361e+03);
476 calibda-> SetLatencyL1 (8.91406e+03) ;
477 calibda-> SetLatencyL1A( 8.91401e+03);
478 calibda-> SetLatencyL1C (8.91412e+03) ;
481 /// calibda-> SetLatencyL1(8.914520e+03) ;
482 // calibda-> SetLatencyL1A( 8.914860e+03) ;
483 // calibda-> SetLatencyL1C(8.914180e+03);
485 // calibda-> SetLatencyL1(8.91306e+03);
486 // calibda-> SetLatencyL1A (8.91338e+03);
487 // calibda-> SetLatencyL1C (8.91274e+03);
489 // calibda-> SetLatencyL1 (8.91345e+03);
490 /// calibda->SetLatencyL1A (8.91378e+03);
491 // calibda->SetLatencyL1C (8.91311e+03);
494 Int_t beamPeriod = 1;
495 char* objFormat = "T0 initial time delay";
497 md.SetComment(objFormat);
498 md.SetBeamPeriod(beamPeriod);
499 md.SetResponsible("Alla");
501 TString fPath="T0/Calib/Latency";
503 AliCDBManager::Instance()->SetDefaultStorage("local:///scratch/alla/alice/Jun10/TestCDB");
504 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
506 // AliCDBId id(fPath.Data(), 126401 ,AliCDBRunRange::Infinity());
507 AliCDBId id(fPath.Data(), 125001 , 125200);
508 storage->Put(calibda, id, &metaData);
513 //--------------------------------------------------------
518 AliCDBMetaData metaData;
519 metaData.SetBeamPeriod(0);
520 metaData.SetResponsible("Alla");
521 metaData.SetComment("Latency");
522 //Store calibration data into database
523 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local:///scratch/alla/alice/Jun10/TestCDB/");
524 AliCDBEntry* entry = stor->Get("T0/Calib/Latency",124401);
526 AliT0CalibLatency *calibda=(AliT0CalibLatency*)entry->GetObject();