temporary fix of bug from Savannah report 54512
[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
28void AliT0SetCDB()
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 ");
43 menu->Show();
44}
45
46
47//------------------------------------------------------------------------
48//------------------------------------------------------------------------
49void SetTimeDelay()
50{
51 // Writing calibration coefficients into the Calibration DB
52 // Arguments:
53
54 TString DBFolder;
55 Int_t firstRun = 0;
56 Int_t lastRun = 99999;
57 Int_t beamPeriod = 1;
58 char* objFormat = "";
59
60 DBFolder ="local://Calib";
61 firstRun = 0;
62 lastRun = 999999;
63 objFormat = "T0 initial time delay";
64
65 AliT0CalibTimeEq *calibda=new AliT0CalibTimeEq("T0");
66 calibda-> ComputeOnlineParams("t0treeDA08000025762005.10.root");
67 /*
68 Float_t fTimeDelay = 1000;
69 for(Int_t ipmt=0; ipmt<24; ipmt++) {
70 calibda->SetTimeEq(ipmt,fTimeDelay+ipmt*100);
71
72 }
73 */
74 calibda->Print();
75 //Store calibration data into database
162637e4 76 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
7bc07e21 77 //AliCDBManager::Instance()->SetDefaultStorage("local:///home/alla/alice/testFeb08/OCDB/");
78
79 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
80
81 AliCDBMetaData md;
82 md.SetComment(objFormat);
83 md.SetBeamPeriod(beamPeriod);
84 md.SetResponsible("Alla");
85 TString fPath="T0/Calib/TimeDelay";
86 //TString fPath="TimeDelay";
87 cout<<fPath.Data()<<endl;
88
89 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
90 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
91 if(storage) {
92 AliCDBId id(fPath.Data(),firstRun,lastRun);
93 storage->Put(calibda, id, &md);
94 }
95}
96
97//------------------------------------------------------------------------
98void SetWalk()
99{
100 // Writing calibration coefficients into the Calibration DB
101 // Arguments:
102
103 TString DBFolder;
104 Int_t firstRun = 0;
105 Int_t lastRun = 999999;
106 Int_t beamPeriod = 1;
107 char* objFormat = "";
108
109 DBFolder ="local://Calib";
110 firstRun = 0;
111 lastRun = 9999999;
112 objFormat = "T0 initial slewnig correction";
113
114 AliT0CalibWalk *calibda=new AliT0CalibWalk("T0");
115 // cout<<"AliT0CalibWalk "<< calibda<<endl;
116 // calibda->Dump();
117 const char *filename="t0tree08000025765005.10.root";
118 calibda->MakeWalkCorrGraph(filename);
119
120
121 /*
122 TRandom rn;
123
124 for(Int_t ipmt=0; ipmt<24; ipmt++) {
125 calibda->SetWalk(ipmt);
126 calibda->SetAmpLEDRec(ipmt);
127 }
128 */
129
130
131 //Store calibration data into database
162637e4 132 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
7bc07e21 133 //AliCDBManager::Instance()->SetDefaultStorage("local:///home/alla/alice/testFeb08/OCDB/");
134
135 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
136
137 AliCDBMetaData md;
138 md.SetComment(objFormat);
139 md.SetBeamPeriod(beamPeriod);
140 md.SetResponsible("Alla");
141 TString fPath="T0/Calib/Slewing_Walk";
142
143
144 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
145 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
146 if(storage) {
147 AliCDBId id(fPath.Data(),firstRun,lastRun);
148 storage->Put(calibda, id, &md);
149 }
150}
151
152//------------------------------------------------------------------------
153void GetTimeDelay()
154{
155 // Read calibration coefficients into the Calibration DB
156 // Arguments:
157
158 TString DBFolder;
159
160 DBFolder ="local://Calib";
161 Int_t nRun=gAlice->GetRunNumber();
162
162637e4 163 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB");
7bc07e21 164 // AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local:///home/alla/alice/testFeb08/OCDB/");
165 AliCDBEntry* entry = stor->Get("T0/Calib/TimeDelay",25068);
166
167 AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entry->GetObject();
168 // clb->Print();
169 for (Int_t i=0; i<24; i++) {
170 cout<<i<<" "<<clb->GetTimeEq(i)<<endl;
171 // cout<<" equalizing CFD "<<(clb->GetTimeDelayCFD(i)-clb->GetTimeDelayCFD(0))<<endl;
172
173 }
174
175}
176//------------------------------------------------------------------------
177void GetWalk()
178{
179 // Read calibration coefficients into the Calibration DB
180 // Arguments:
181
182 TString DBFolder;
183
184 DBFolder ="local://Calib";
185 Int_t nRun=gAlice->GetRunNumber();
186 // AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local:///home/alla/alice/testFeb08/OCDB/");
187
162637e4 188 AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT/OCDB");
7bc07e21 189 AliCDBEntry* entry = stor->Get("T0/Calib/Slewing_Walk",25081);
190
191 // AliT0Parameters* param = AliT0Parameters::Instance();
192 //param->Init();
193
194
195 AliT0CalibWalk *clb = (AliT0CalibWalk*)entry->GetObject();
196 // cin>>" enter channel number">>ipmt;
197
198 TCanvas *c1 = new TCanvas("c1", "CFD C side",0,48,1280,951);
199 c1->Divide(4,3);
200 for (Int_t i=0; i<12; i++) {
201 c1->cd(i+1);
202 // TGraph* fu = param ->GetWalk(ipmt);
203 // TGraph *gr = clb->GetWalk(i);
204 TGraph *gr = clb->GetAmpLEDRec(i);
205 // cout<<" "<<gr<<endl;
206 if(gr) {
207 gr->SetMarkerStyle(7);
208 gr->Draw("AP");
209 }
210 }
211 TCanvas *c2 = new TCanvas("c2", "CFD A side",0,48,1280,951);
212 c2->Divide(4,3);
213 for (Int_t i=12; i<24; i++) {
214 c2->cd(i+1-12);
215 // if(i==15) continue;
216 // TGraph *gr = clb->GetWalk(i);
217 // cout<<i<<" "<<gr->GetN()<<" "<<endl;
218 TGraph *gr = clb->GetAmpLEDRec(i);
219 // TGraph* fu = param ->GetWalk(pmt+12);
220 cout<<i<<" "<<gr->GetN()<<" "<<endl;
221
222 gr->SetMarkerStyle(7);
223 // gr->SetMarkerSize(20);
224 gr->Draw("AP");
225 }
226
227}
228//------------------------------------------------------------------------
229void SetLookUp()
230{
231 // Writing Lookup table into the Calibration DB
232 // Arguments:
233
234 TString DBFolder;
235 Int_t firstRun = 0;
236 Int_t lastRun = 10;
237 Int_t beamPeriod = 1;
238 char* objFormat = "";
239
240 DBFolder ="local://Calib";
241 firstRun = 0;
242 lastRun = 10;
243 objFormat = "T0 Lookup Table";
244
245 AliT0CalibData *calibda=new AliT0CalibData("T0");
246
247// calibda->ReadAsciiLookup("lookUpTable.txt");
248 calibda->ReadAsciiLookup("lookUpTable_tanay.txt");
249
250 //Store calibration data into database
162637e4 251 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
7bc07e21 252
253 // AliCDBManager::Instance()->SetSpecificStorage("T0",DBFolder.Data());
254
255 AliCDBMetaData md;
256 md.SetComment(objFormat);
257 md.SetBeamPeriod(beamPeriod);
258 md.SetResponsible("Alla");
259 TString fPath="T0/Calib/LookUp_Table";
260
261
262 // AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("T0");
263 AliCDBStorage* storage = AliCDBManager::Instance()->GetDefaultStorage();
264 if(storage) {
265 AliCDBId id(fPath.Data(),firstRun,lastRun);
266 storage->Put(calibda, id, &md);
267 }
268}
269//------------------------------------------------------------------------
270void GetLookUp()
271{
272 // Read calibration coefficients into the Calibration DB
273 // Arguments:
274
275 TString DBFolder;
276
277 // DBFolder ="local://Calib";
278 // Int_t nRun=gAlice->GetRunNumber();
279 AliCDBManager* cdb = AliCDBManager::Instance();
162637e4 280 AliCDBStorage *stor = cdb->GetStorage("local://$ALICE_ROOT/OCDB");
7bc07e21 281 // cout<<" GetLookUp :: "<<stor<<endl;
282 AliCDBEntry *entry;
283 //entry = stor->Get("T0/Calib/LookUp_Table",2,0,0);
284 entry = stor->Get("T0/Calib/LookUp_Table",1);
285 //cout<<"entry="<<entry<<endl;
286 cout<<" AliT0CalibData ::GetLookUp :: "<<entry<<endl;
287 AliT0CalibData *clb = (AliT0CalibData*)entry->GetObject();
288 cout<<" AliT0CalibData *clb "<<clb <<endl;
289 //cout<<"clb->a="<<clb->GetA()<<endl;
290 // clb->Dump();
291 for (Int_t i=0; i<20; i++)
292 clb->PrintLookupNames("all",i);
293
294}