Reading muon trigger scalers with the DA of the muon trigger and transfer
[u/mrichter/AliRoot.git] / T0 / AliT0SetCDBcosmic.C
CommitLineData
7bc07e21 1/* $Id: AliT0SetCDB.C 22796 2007-12-06 11:32:28Z alla $ */
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 "AliT0Align.h"
20#include "AliCDBMetaData.h"
21#include "AliCDBId.h"
22#include "AliCDBEntry.h"
23#include "AliCDBManager.h"
24#include "AliCDBStorage.h"
25#endif
26
27
1e69dc02 28void AliT0SetCDBcosmic()
7bc07e21 29{
30 TControlBar *menu = new TControlBar("vertical","T0 CDB");
31 menu->AddButton("Set time delay","SetTimeDelay()",
32 "Set time delay");
33 menu->AddButton("Set walk","SetWalk()",
34 "Set slewing coorection");
35 menu->AddButton("Set LookUpTable","SetLookUp()",
36 "Set LookUp table");
37 menu->AddButton("Read time delay","GetTimeDelay()",
38 "Read time delay");
39 menu->AddButton("Read walk","GetWalk()",
40 "Read amplitude-time correction");
41 menu->AddButton("Read Lookup","GetLookUp()",
42 "Read Lookup table ");
1e69dc02 43 menu->AddButton("SetLatency","setLat()",
44 "SetLatency ");
45 menu->AddButton("ReadLatency","readLat()",
46 "print Latency ");
7bc07e21 47 menu->Show();
48}
49
50
51//------------------------------------------------------------------------
52//------------------------------------------------------------------------
53void SetTimeDelay()
54{
55 // Writing calibration coefficients into the Calibration DB
56 // Arguments:
57
1e69dc02 58 firstRun = 125001;
59 lastRun = 125800;
7bc07e21 60 Int_t beamPeriod = 1;
1e69dc02 61 char* objFormat = "T0 initial time delay";
7bc07e21 62
63 DBFolder ="local://Calib";
1e69dc02 64
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, };
68 //run 114786
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};
71 //run 115318
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};
74 //run 116562
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};
77 // run 117118
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};
80 // run 117112
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};
83 // run 118000
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};
86 // run119163
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};
89
90 // run 120076
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};
93
94 // run 120244
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};
97 // run 120824
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};
100 //124187
101
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};
104 //124702
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};
107
108 //125085
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};
111//
112
113// 125097
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};
116
117 //125295
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};
120 //125842
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};
123
124
125
126 //126407
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};
129//
130 //for ( Int_t indexfile=filestart; indexfile < filestop+1;indexfile++ )
7bc07e21 131
132 AliT0CalibTimeEq *calibda=new AliT0CalibTimeEq("T0");
1e69dc02 133 // calibda-> ComputeOnlineParams("t0treeDA08000025762005.10.root");
134
135 for(Int_t ipmt=0; ipmt<24; ipmt++) {
136 calibda->SetTimeEq(ipmt,shift[ipmt]);
7bc07e21 137
138 }
1e69dc02 139
7bc07e21 140 calibda->Print();
141 //Store calibration data into database
1e69dc02 142 // AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
143 AliCDBManager::Instance()->SetDefaultStorage("local:///scratch/alla/alice/Jun10/TestCDB/");
7bc07e21 144 AliCDBMetaData md;
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;
151
152 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
153 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
154 if(storage) {
1e69dc02 155 // AliCDBId id(fPath.Data(),firstRun,AliCDBRunRange::Infinity() );
156 AliCDBId id(fPath.Data(),firstRun, lastRun );
7bc07e21 157 storage->Put(calibda, id, &md);
158 }
159}
160
161//------------------------------------------------------------------------
162void SetWalk()
163{
164 // Writing calibration coefficients into the Calibration DB
165 // Arguments:
166
167 TString DBFolder;
1e69dc02 168 Int_t firstRun = 1000;
169 Int_t lastRun = 999999999;
7bc07e21 170 Int_t beamPeriod = 1;
171 char* objFormat = "";
172
173 DBFolder ="local://Calib";
7bc07e21 174 objFormat = "T0 initial slewnig correction";
175
176 AliT0CalibWalk *calibda=new AliT0CalibWalk("T0");
177 // cout<<"AliT0CalibWalk "<< calibda<<endl;
178 // calibda->Dump();
1e69dc02 179 const char *filename="amphist616.root";
7bc07e21 180 calibda->MakeWalkCorrGraph(filename);
181
182
1e69dc02 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/");
7bc07e21 186
1e69dc02 187 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
7bc07e21 188
7bc07e21 189
7bc07e21 190
191 AliCDBMetaData md;
192 md.SetComment(objFormat);
193 md.SetBeamPeriod(beamPeriod);
194 md.SetResponsible("Alla");
195 TString fPath="T0/Calib/Slewing_Walk";
196
197
198 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
199 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
200 if(storage) {
201 AliCDBId id(fPath.Data(),firstRun,lastRun);
202 storage->Put(calibda, id, &md);
203 }
204}
205
1e69dc02 206
7bc07e21 207//------------------------------------------------------------------------
208void GetTimeDelay()
209{
210 // Read calibration coefficients into the Calibration DB
211 // Arguments:
212
213 TString DBFolder;
214
215 DBFolder ="local://Calib";
1e69dc02 216 // Int_t nRun=gAlice->GetRunNumber();
7bc07e21 217
1e69dc02 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);
7bc07e21 222
223 AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entry->GetObject();
224 // clb->Print();
225 for (Int_t i=0; i<24; i++) {
1e69dc02 226 cout<<" "<<clb->GetTimeEq(i)<<" ";
7bc07e21 227 // cout<<" equalizing CFD "<<(clb->GetTimeDelayCFD(i)-clb->GetTimeDelayCFD(0))<<endl;
7bc07e21 228 }
229
1e69dc02 230 cout<<endl;
7bc07e21 231}
232//------------------------------------------------------------------------
233void GetWalk()
234{
235 // Read calibration coefficients into the Calibration DB
236 // Arguments:
237
238 TString DBFolder;
239
240 DBFolder ="local://Calib";
1e69dc02 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/");
7bc07e21 245
1e69dc02 246 // AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB");
247 AliCDBEntry* entry = stor->Get("T0/Calib/Slewing_Walk",runNumber);
7bc07e21 248
249 // AliT0Parameters* param = AliT0Parameters::Instance();
250 //param->Init();
251
252
253 AliT0CalibWalk *clb = (AliT0CalibWalk*)entry->GetObject();
254 // cin>>" enter channel number">>ipmt;
1e69dc02 255 TString buf3;
256 TCanvas *c1 = new TCanvas("c1", "LED-CFD C side",0,48,1280,951);
7bc07e21 257 c1->Divide(4,3);
258 for (Int_t i=0; i<12; i++) {
259 c1->cd(i+1);
1e69dc02 260 TGraph *gr = clb->GetAmpLED(i);
7bc07e21 261 if(gr) {
1e69dc02 262 gr->GetXaxis()->SetTitle("led-cfd");
263 gr->GetYaxis()->SetTitle("MIPs");
264 gr->SetMarkerStyle(20);
7bc07e21 265 gr->Draw("AP");
266 }
267 }
1e69dc02 268 buf3 = Form("ampplots/ampLEDminCFD_C_%i.png",runNumber);
269 c1->Print(buf3);
270
271
272 TCanvas *c2 = new TCanvas("c2", "LED-CFD A side",0,48,1280,951);
7bc07e21 273 c2->Divide(4,3);
274 for (Int_t i=12; i<24; i++) {
275 c2->cd(i+1-12);
1e69dc02 276 TGraph *gr = clb->GetAmpLED(i);
277 gr->GetXaxis()->SetTitle("led-cfd");
278 gr->GetYaxis()->SetTitle("MIPs");
279 gr->SetMarkerStyle(20);
280 gr->Draw("AP");
281 }
282 buf3 = Form("ampplots/ampLEDminCFD_A_%i.png",runNumber);
283
284 c2->Print(buf3);
285
286 TCanvas *c3 = new TCanvas("c3", "QTC C side",0,48,1280,951);
287 c3->Divide(4,3);
288 for (Int_t i=0; i<12; i++) {
289 c3->cd(i+1);
290 TGraph *gr = clb->GetQTC(i);
291 if(gr) {
292 gr->SetTitle(Form("PMT%i",i));
293 gr->GetXaxis()->SetTitle("qtc");
294 gr->GetYaxis()->SetTitle("MIPs");
295 gr->SetMarkerStyle(20);
296 gr->Draw("AP");
297 }
298 }
299 buf3 = Form("ampplots/ampQTC_C_%i.png",runNumber);
300
301 c3->Print(buf3);
302
303 TCanvas *c4 = new TCanvas("c4", "QTC A side",0,48,1280,951);
304 c4->Divide(4,3);
305 for (Int_t i=12; i<24; i++) {
306 c4->cd(i+1-12);
307 TGraph *gr = clb->GetQTC(i);
308 // TGraph *gr = clb->GetWalk(i);
7bc07e21 309
1e69dc02 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);
7bc07e21 315 // gr->SetMarkerSize(20);
316 gr->Draw("AP");
317 }
1e69dc02 318 buf3 = Form("ampplots/ampQTC_A_%i.png",runNumber);
319
320 c4->Print(buf3);
321
322 TCanvas *c5 = new TCanvas("c5", "walk LED-CFD C side",0,48,1280,951);
323 c5->Divide(4,3);
324 for (Int_t i=0; i<12; i++) {
325 c5->cd(i+1);
326 TGraph *gr = clb->GetAmpLEDRec(i);
327
328 if(gr) {
329 gr->SetTitle(Form("PMT%i",i));
330 gr->GetXaxis()->SetTitle("led-cfd");
331 gr->GetYaxis()->SetTitle("walk");
332 gr->SetMarkerStyle(20);
333 gr->Draw("AP");
334 if(i==0) gr->Print();
335 }
336 }
337
338 buf3 = Form("ampplots/walkLEDminCFD_C_%i.png",runNumber);
339 c5->Print(buf3);
340
341 TCanvas *c6 = new TCanvas("c6", "walk LED-CFD A side",0,48,1280,951);
342 c6->Divide(4,3);
343 for (Int_t i=12; i<24; i++) {
344 c6->cd(i+1-12);
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);
350 gr->Draw("AP");
351
352 }
353
354 buf3 = Form("ampplots/walkLEDminCFD_A_%i.png",runNumber);
355 c6->Print(buf3);
356
357 TCanvas *c7 = new TCanvas("c7", "walk QTC C side",0,48,1280,951);
358 c7->Divide(4,3);
359 for (Int_t i=0; i<12; i++) {
360 c7->cd(i+1);
361 TGraph *gr = clb->GetWalk(i);
362
363 if(gr) {
364 gr->SetTitle(Form("PMT%i",i));
365 gr->GetXaxis()->SetTitle("qtc");
366 gr->GetYaxis()->SetTitle("walk");
367 gr->SetMarkerStyle(20);
368 gr->Draw("AP");
369 if(i==0) gr->Print();
370 }
371 }
372 buf3 = Form("ampplots/walkQTC_C_%i.png",runNumber);
373 c7->Print(buf3);
374
375 TCanvas *c8 = new TCanvas("c8", "walk QTC A side",0,48,1280,951);
376 c8->Divide(4,3);
377 for (Int_t i=12; i<24; i++) {
378 c8->cd(i+1-12);
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);
384 gr->Draw("AP");
385 }
386 buf3 = Form("ampplots/walkQTC_A_%i.png",runNumber);
387 c8->Print(buf3);
388
389
390
391
7bc07e21 392}
393//------------------------------------------------------------------------
394void SetLookUp()
395{
396 // Writing Lookup table into the Calibration DB
397 // Arguments:
398
399 TString DBFolder;
400 Int_t firstRun = 0;
1e69dc02 401 Int_t lastRun = 9999999;
7bc07e21 402 Int_t beamPeriod = 1;
1e69dc02 403 char* objFormat = "T0 Lookup Table";
7bc07e21 404
405 AliT0CalibData *calibda=new AliT0CalibData("T0");
406
407// calibda->ReadAsciiLookup("lookUpTable.txt");
408 calibda->ReadAsciiLookup("lookUpTable_tanay.txt");
409
410 //Store calibration data into database
1e69dc02 411 AliCDBManager::Instance()->SetDefaultStorage("local:///home/alla/alice/testOct09/TestCDB");
412
7bc07e21 413 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
414
415 AliCDBMetaData md;
416 md.SetComment(objFormat);
417 md.SetBeamPeriod(beamPeriod);
418 md.SetResponsible("Alla");
419 TString fPath="T0/Calib/LookUp_Table";
420
421
422 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
423 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
424 if(storage) {
425 AliCDBId id(fPath.Data(),firstRun,lastRun);
426 storage->Put(calibda, id, &md);
427 }
428}
429//------------------------------------------------------------------------
430void GetLookUp()
431{
432 // Read calibration coefficients into the Calibration DB
433 // Arguments:
434
435 TString DBFolder;
436
437 // DBFolder ="local://Calib";
438 // Int_t nRun=gAlice->GetRunNumber();
439 AliCDBManager* cdb = AliCDBManager::Instance();
162637e4 440 AliCDBStorage *stor = cdb->GetStorage("local://$ALICE_ROOT/OCDB");
7bc07e21 441 // cout<<" GetLookUp :: "<<stor<<endl;
442 AliCDBEntry *entry;
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;
450 // clb->Dump();
451 for (Int_t i=0; i<20; i++)
452 clb->PrintLookupNames("all",i);
453
454}
1e69dc02 455//--------------------------------------------------------
456void setLat()
457{
458 // Arguments:
459
460 AliCDBMetaData metaData;
461 metaData.SetBeamPeriod(0);
462 metaData.SetResponsible("Alla");
463 metaData.SetComment("Latency");
464 //Store calibration data into database
465
466 AliT0CalibLatency *calibda=new AliT0CalibLatency("T0");
467
468 calibda->SetLatencyHPTDC(9000);
469
470 //124702
471 // calibda-> SetLatencyL1(8.91358e+03);
472 // calibda-> SetLatencyL1A(8.91352e+03);
473 // calibda-> SetLatencyL1C(8.91361e+03);
474
475 //125097
476 calibda-> SetLatencyL1 (8.91406e+03) ;
477 calibda-> SetLatencyL1A( 8.91401e+03);
478 calibda-> SetLatencyL1C (8.91412e+03) ;
479
480 //run 125295
481 /// calibda-> SetLatencyL1(8.914520e+03) ;
482 // calibda-> SetLatencyL1A( 8.914860e+03) ;
483 // calibda-> SetLatencyL1C(8.914180e+03);
484 //125842
485 // calibda-> SetLatencyL1(8.91306e+03);
486 // calibda-> SetLatencyL1A (8.91338e+03);
487 // calibda-> SetLatencyL1C (8.91274e+03);
488 //126407
489 // calibda-> SetLatencyL1 (8.91345e+03);
490 /// calibda->SetLatencyL1A (8.91378e+03);
491 // calibda->SetLatencyL1C (8.91311e+03);
492
493
494 Int_t beamPeriod = 1;
495 char* objFormat = "T0 initial time delay";
496 AliCDBMetaData md;
497 md.SetComment(objFormat);
498 md.SetBeamPeriod(beamPeriod);
499 md.SetResponsible("Alla");
500
501 TString fPath="T0/Calib/Latency";
502
503 AliCDBManager::Instance()->SetDefaultStorage("local:///scratch/alla/alice/Jun10/TestCDB");
504 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
505 if(storage) {
506 // AliCDBId id(fPath.Data(), 126401 ,AliCDBRunRange::Infinity());
507 AliCDBId id(fPath.Data(), 125001 , 125200);
508 storage->Put(calibda, id, &metaData);
509 calibda->Print();
510
511 }
512}
513//--------------------------------------------------------
514void readLat()
515{
516 // Arguments:
517
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);
525
526 AliT0CalibLatency *calibda=(AliT0CalibLatency*)entry->GetObject();
527 calibda->Print();
528
529}