57 |
|
|
58 |
//--------------- Variables initialization -----------------------------------// |
//--------------- Variables initialization -----------------------------------// |
59 |
const Int_t channels = 4096; |
const Int_t channels = 4096; |
60 |
Double_t calib_1; |
Double_t calib_1_MEAN; |
61 |
Double_t calib_2; |
Double_t calib_2_MEAN; |
62 |
Double_t calib_4; |
Double_t calib_4_MEAN; |
63 |
Double_t calib_1_RMS; |
Double_t calib_1_RMS; |
64 |
Double_t calib_2_RMS; |
Double_t calib_2_RMS; |
65 |
Double_t calib_4_RMS; |
Double_t calib_4_RMS; |
66 |
|
Double_t calib_1=0, calib_2=0, calib_4=0; |
67 |
Double_t obt; |
Double_t obt; |
68 |
TString status; |
TString status; |
69 |
Int_t IPM1status, IPM2status; |
Int_t IPM1status, IPM2status; |
70 |
|
ULong_t lastime, firstime, obt1, utile; |
71 |
|
double obmin=0.; |
72 |
|
double obmax=0.; |
73 |
|
double limitdown=0; |
74 |
|
double limitup=0; |
75 |
|
|
76 |
|
|
77 |
//------------------------- Open data file -------------------------------------// |
//------------------------- Open data file -------------------------------------// |
78 |
TFile *file =new TFile(base.Data()) ; |
TFile *file =new TFile(base.Data()) ; |
79 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
141 |
} |
} |
142 |
|
|
143 |
//---------------Look for configuration hot or cold -----------------------// |
//---------------Look for configuration hot or cold -----------------------// |
144 |
Int_t recordstot=0; |
if(neventstmtc!=0){ |
145 |
for (Int_t i = 0; i < neventstmtc; i++){ |
Int_t recordstot=0; |
146 |
tmtcBr->GetEntry(i); |
for (Int_t i = 0; i < neventstmtc; i++){ |
147 |
Long64_t tmpSizetmtc = tme->Records->GetEntries(); |
tmtcBr->GetEntry(i); |
148 |
recordstot=recordstot+tmpSizetmtc; |
Long64_t tmpSizetmtc = tme->Records->GetEntries(); |
149 |
} |
recordstot=recordstot+tmpSizetmtc; |
150 |
const Int_t lungmax=16*recordstot; |
} |
151 |
Double_t xrecordobtcc[lungmax], yccdiagacq[lungmax], xrecordobtcc_1[lungmax], yccdiagacq_1[lungmax]; |
const Int_t lungmax=16*recordstot; |
152 |
recordstot=0; |
Double_t xrecordobtcc[lungmax], yccdiagacq[lungmax], xrecordobtcc_1[lungmax], yccdiagacq_1[lungmax]; |
153 |
for (Int_t i = 0; i < neventstmtc; i++){ |
recordstot=0; |
154 |
tmtcBr->GetEntry(i); |
for (Int_t i = 0; i < neventstmtc; i++){ |
155 |
Long64_t tmpSizetmtc = tme->Records->GetEntries(); |
tmtcBr->GetEntry(i); |
156 |
Int_t size_b = tmpSizetmtc; |
Long64_t tmpSizetmtc = tme->Records->GetEntries(); |
157 |
for (Int_t j = 0; j < size_b; j++){ |
Int_t size_b = tmpSizetmtc; |
158 |
tmr = (pamela::TmtcRecord*)tme->Records->At(j); |
for (Int_t j = 0; j < size_b; j++){ |
159 |
for (Int_t k =0; k <16; k++){ |
tmr = (pamela::TmtcRecord*)tme->Records->At(j); |
160 |
yccdiagacq[16*recordstot+16*j+k] = (((tmr->TM_DIAG_AND_BILEVEL_ACQ)>>(15-k))&0x0001); |
for (Int_t k =0; k <16; k++){ |
161 |
xrecordobtcc[16*recordstot+16*j+k] = tmr->TM_RECORD_OBT; |
yccdiagacq[16*recordstot+16*j+k] = (((tmr->TM_DIAG_AND_BILEVEL_ACQ)>>(15-k))&0x0001); |
162 |
|
xrecordobtcc[16*recordstot+16*j+k] = tmr->TM_RECORD_OBT; |
163 |
|
} |
164 |
} |
} |
165 |
|
recordstot=recordstot+tmpSizetmtc; |
166 |
} |
} |
167 |
recordstot=recordstot+tmpSizetmtc; |
Int_t riftime = recordstot/2; |
168 |
} |
//CC (0=IPM1=hot; 1=IPM2=cold for S4 calibration) |
169 |
Int_t riftime = recordstot/2; |
for (Int_t k =0; k<16; k++){ |
170 |
//CC (0=IPM1=hot; 1=IPM2=cold for S4 calibration) |
for (Int_t i = 0; i < recordstot; i++){ |
171 |
for (Int_t k =0; k<16; k++){ |
yccdiagacq_1[i]= yccdiagacq[16*i+k]; |
172 |
for (Int_t i = 0; i < recordstot; i++){ |
xrecordobtcc_1[i]= xrecordobtcc[16*i+k]; |
173 |
yccdiagacq_1[i]= yccdiagacq[16*i+k]; |
} |
174 |
xrecordobtcc_1[i]= xrecordobtcc[16*i+k]; |
if (k==0) IPM1status=(Int_t)yccdiagacq_1[riftime]; |
175 |
|
if (k==1) IPM2status=(Int_t)yccdiagacq_1[riftime]; |
176 |
} |
} |
177 |
if (k==0) IPM1status=(Int_t)yccdiagacq_1[riftime]; |
if (IPM1status==0 && IPM2status==1){ |
178 |
if (k==1) IPM2status=(Int_t)yccdiagacq_1[riftime]; |
status="CONFIGURATION: HOT"; |
179 |
} |
} |
180 |
if (IPM1status==0 && IPM2status==1){ |
if (IPM1status==1 && IPM2status==0){ |
181 |
status="CONFIGURATION: HOT"; |
status="CONFIGURATION: COLD"; |
182 |
} |
} |
183 |
if (IPM1status==1 && IPM2status==0){ |
}else{ |
184 |
status="CONFIGURATION: COLD"; |
status=" No info about kind of calibration (hot or cold)"; |
185 |
} |
} |
186 |
|
|
187 |
//------------- Create and fill histograms -------------------------------------------// |
//----------- search max and min OBT -----------------------------------------------------// |
|
|
|
|
TH1F *calibS4_1 =new TH1F("calibS4_1", "calibS4_1", channels, 0, channels); |
|
|
TH1F *calibS4_2 =new TH1F("calibS4_2", "calibS4_2", channels, 0, channels); |
|
|
TH1F *calibS4_4 =new TH1F("calibS4_4", "calibS4_4", channels, 0, channels); |
|
|
ULong_t lastime, firstime, obt1; |
|
|
double obmin=0.; |
|
|
double obmax=0.; |
|
|
double limitdown=0; |
|
|
double limitup=0; |
|
|
const Int_t size = nevents; |
|
|
cout<<"size "<<size <<"\n"; |
|
|
|
|
188 |
headBr->GetEntry(0); |
headBr->GetEntry(0); |
189 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
190 |
firstime = ph->GetOrbitalTime(); |
firstime = ph->GetOrbitalTime(); |
197 |
for(Int_t kk = 0; kk<nevents; kk++){ |
for(Int_t kk = 0; kk<nevents; kk++){ |
198 |
headBr->GetEntry(kk); |
headBr->GetEntry(kk); |
199 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
200 |
if(obmin >= ph->GetOrbitalTime())obmin=ph->GetOrbitalTime(); |
utile=ph->GetOrbitalTime(); |
201 |
if(obmax <= ph->GetOrbitalTime())obmax=ph->GetOrbitalTime(); |
if(obmin >= utile)obmin=utile; |
202 |
|
if(obmax <= utile)obmax=utile; |
203 |
} |
} |
204 |
limitdown= obmin - 1000000; |
limitdown= obmin - 1000000; |
205 |
limitup= obmax + 1000000; |
limitup= obmax + 1000000; |
207 |
for(Int_t kk = 0; kk<nevents; kk++){ |
for(Int_t kk = 0; kk<nevents; kk++){ |
208 |
headBr->GetEntry(kk); |
headBr->GetEntry(kk); |
209 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
210 |
cout<<"OrbitalTime()"<<ph->GetOrbitalTime()<<"\n"; |
utile=ph->GetOrbitalTime(); |
211 |
if(obmin >= ph->GetOrbitalTime())obmin=ph->GetOrbitalTime(); |
//cout<<"OrbitalTime()"<<ph->GetOrbitalTime()<<"\n"; |
212 |
if(obmax <= ph->GetOrbitalTime())obmax=ph->GetOrbitalTime(); |
if(obmin >= utile)obmin=utile; |
213 |
|
if(obmax <= utile)obmax=utile; |
214 |
} |
} |
215 |
limitdown=obmin; |
limitdown=obmin; |
216 |
limitup=obmax; |
limitup=obmax; |
217 |
} |
} |
218 |
|
//------------- Create and fill histograms -------------------------------------------// |
219 |
|
stringstream oss1; |
220 |
|
oss1.str(""); |
221 |
|
oss1 << "S4 Calibration: "<< filename.Data(); |
222 |
|
TH1F *calibS4_1 =new TH1F("S4-1", oss1.str().c_str(), channels, 0, channels); |
223 |
|
TH1F *calibS4_2 =new TH1F("S4-2", oss1.str().c_str(), channels, 0, channels); |
224 |
|
TH1F *calibS4_4 =new TH1F("S4-3", oss1.str().c_str(), channels, 0, channels); |
225 |
|
|
226 |
stringstream oss; |
stringstream oss; |
227 |
oss.str(""); |
oss.str(""); |
228 |
oss << "S4_Calibration_QL: "<< filename.Data(); |
oss << "S4_Calibration_QL: "<< filename.Data(); |
229 |
|
const Int_t size = nevents; |
230 |
|
//cout<<"size "<<size <<"\n"; |
231 |
TH1F *cal1 =new TH1F("calibS4_1", oss.str().c_str(), size, obmin-1000000, obmax+ 1000000); |
TH1F *cal1 =new TH1F("calibS4_1", oss.str().c_str(), size, obmin-1000000, obmax+ 1000000); |
232 |
TH1F *cal2 =new TH1F("calibS4_2", oss.str().c_str(), size, obmin-1000000, obmax+ 1000000); |
TH1F *cal2 =new TH1F("calibS4_2", oss.str().c_str(), size, obmin-1000000, obmax+ 1000000); |
233 |
TH1F *cal4 =new TH1F("calibS4_4", oss.str().c_str(), size, obmin-1000000, obmax+ 1000000); |
TH1F *cal4 =new TH1F("calibS4_4", oss.str().c_str(), size, obmin-1000000, obmax+ 1000000); |
243 |
switch (j) { |
switch (j) { |
244 |
case 0 :{ |
case 0 :{ |
245 |
calibS4_1->Fill(s4Record->S4_DATA); |
calibS4_1->Fill(s4Record->S4_DATA); |
246 |
|
calib_1 = calib_1+s4Record->S4_DATA; |
247 |
break; |
break; |
248 |
} |
} |
249 |
case 1 :{ |
case 1 :{ |
250 |
calibS4_2->Fill(s4Record->S4_DATA); |
calibS4_2->Fill(s4Record->S4_DATA); |
251 |
|
calib_2 = calib_2+s4Record->S4_DATA; |
252 |
break; |
break; |
253 |
} |
} |
254 |
case 3 :{ |
case 3 :{ |
255 |
calibS4_4->Fill(s4Record->S4_DATA); |
calibS4_4->Fill(s4Record->S4_DATA); |
256 |
|
calib_4 = calib_4+s4Record->S4_DATA; |
257 |
break; |
break; |
258 |
} |
} |
259 |
} |
} |
260 |
} |
} |
261 |
} |
} |
262 |
|
utile=ph->GetOrbitalTime(); |
263 |
//obt=ph->GetOrbitalTime(); |
//obt=ph->GetOrbitalTime(); |
264 |
calib_1=calibS4_1->GetMean(1); |
calib_1_MEAN=calib_1/128; |
265 |
//calib_1_RMS=calibS4_1->GetRMS(1); |
//calib_1_RMS=calibS4_1->GetRMS(1); |
266 |
calib_2=calibS4_2->GetMean(1); |
calib_2_MEAN=calib_2/128; |
267 |
//calib_2_RMS=calibS4_2->GetRMS(1); |
//calib_2_RMS=calibS4_2->GetRMS(1); |
268 |
calib_4=calibS4_4->GetMean(1); |
calib_4_MEAN=calib_4/128; |
269 |
//calib_4_RMS=calibS4_4->GetRMS(1); |
//calib_4_RMS=calibS4_4->GetRMS(1); |
270 |
cal1->Fill(ph->GetOrbitalTime(),calib_1); |
cal1->Fill(utile,calib_1_MEAN); |
271 |
cal2->Fill(ph->GetOrbitalTime(),calib_2); |
cal2->Fill(utile,calib_2_MEAN); |
272 |
cal4->Fill(ph->GetOrbitalTime(),calib_4); |
cal4->Fill(utile,calib_4_MEAN); |
273 |
cout<<"k"<<k<<"\n"; |
calib_1=calib_2=calib_4=0; |
|
//cout<<calib_1_RMS<<"\n"; |
|
|
//cout<<calib_2_RMS<<"\n"; |
|
|
//cout<<calib_4_RMS<<"\n"; |
|
|
//cout<<k<<" "<<obt<<" \n "<<calib_1<<" "<<calib_2<<" "<<calib_4<<"\n"; |
|
274 |
|
|
275 |
} |
} |
276 |
|
|
277 |
//----------------- Create and draw canvas -----------------------------------------// |
//----------------- Create and draw canvas -----------------------------------------// |
278 |
TCanvas *finalCanv = new TCanvas("S4Calib","Calibration_QL", 1280, 1024); |
TCanvas *finalCanv = new TCanvas("S4Calib","Calibration_QL", 1280, 1024); |
279 |
finalCanv->SetFillColor(10); |
finalCanv->SetFillColor(10); |
280 |
|
finalCanv->Divide(2,2); |
281 |
|
|
282 |
finalCanv->cd(); |
finalCanv->cd(1); |
283 |
gPad->SetLogy(); |
gPad->SetLogy(); |
|
|
|
284 |
cal1->SetStats(kFALSE); |
cal1->SetStats(kFALSE); |
285 |
cal1->SetMarkerSize(.5); |
cal1->SetMarkerSize(.5); |
286 |
cal1->SetMarkerStyle(21); |
cal1->SetMarkerStyle(21); |
404 |
func6->Draw("same"); |
func6->Draw("same"); |
405 |
} |
} |
406 |
|
|
407 |
TPad *pad = new TPad("pad","pad", .75, .93, .99, .99); |
//TPad *pad = new TPad("pad","pad", .75, .93, .99, .99); |
408 |
|
TPad *pad = new TPad("pad","pad", .58, .85, .92, .94); |
409 |
pad->SetFillColor(10); |
pad->SetFillColor(10); |
410 |
pad->Draw(); |
pad->Draw(); |
411 |
pad->cd(); |
pad->cd(); |
412 |
TLatex *l = new TLatex(); |
TLatex *l = new TLatex(); |
413 |
l->SetTextAlign(12); |
l->SetTextAlign(12); |
414 |
l->SetTextSize(0.35); |
l->SetTextSize(0.4); |
415 |
l->SetTextColor(8); |
l->SetTextColor(kRed); |
416 |
l->DrawLatex(0.05, 0.65, status.Data()); |
l->DrawLatex(0.05, 0.65, status.Data()); |
417 |
|
|
418 |
|
|
419 |
|
finalCanv->cd(2); |
420 |
|
gPad->SetLogy(); |
421 |
|
gStyle->SetOptStat("nemrou"); |
422 |
|
calibS4_1->SetLineColor(kBlack); |
423 |
|
calibS4_1->SetFillColor(kRed); |
424 |
|
calibS4_1->GetYaxis()->SetTitle("Number of events"); |
425 |
|
calibS4_1->GetYaxis()->SetTitleSize(0.03); |
426 |
|
calibS4_1->GetYaxis()->SetTitleOffset(1); |
427 |
|
calibS4_1->GetYaxis()->CenterTitle(); |
428 |
|
calibS4_1->GetYaxis()->SetLabelSize(0.02); |
429 |
|
calibS4_1->GetXaxis()->CenterTitle(); |
430 |
|
calibS4_1->GetXaxis()->SetTitleSize(0.03); |
431 |
|
calibS4_1->GetXaxis()->SetTitleOffset(1); |
432 |
|
calibS4_1->GetXaxis()->SetLabelSize(0.02); |
433 |
|
calibS4_1->GetXaxis()->SetTitle("ADC (ch)"); |
434 |
|
calibS4_1->SetAxisRange(0,200); |
435 |
|
calibS4_1->Draw(); |
436 |
|
|
437 |
|
finalCanv->cd(3); |
438 |
|
gPad->SetLogy(); |
439 |
|
gStyle->SetOptStat("nemrou"); |
440 |
|
calibS4_2->SetLineColor(kBlack); |
441 |
|
calibS4_2->SetFillColor(kRed); |
442 |
|
calibS4_2->GetYaxis()->SetTitle("Number of events"); |
443 |
|
calibS4_2->GetYaxis()->SetTitleSize(0.03); |
444 |
|
calibS4_2->GetYaxis()->SetTitleOffset(1); |
445 |
|
calibS4_2->GetYaxis()->CenterTitle(); |
446 |
|
calibS4_2->GetYaxis()->SetLabelSize(0.02); |
447 |
|
calibS4_2->GetXaxis()->CenterTitle(); |
448 |
|
calibS4_2->GetXaxis()->SetTitleSize(0.03); |
449 |
|
calibS4_2->GetXaxis()->SetTitleOffset(1); |
450 |
|
calibS4_2->GetXaxis()->SetLabelSize(0.02); |
451 |
|
calibS4_2->GetXaxis()->SetTitle("ADC (ch)"); |
452 |
|
calibS4_2->SetAxisRange(50,250); |
453 |
|
calibS4_2->Draw(); |
454 |
|
|
455 |
|
finalCanv->cd(4); |
456 |
|
gPad->SetLogy(); |
457 |
|
gStyle->SetOptStat("nemrou"); |
458 |
|
calibS4_4->SetLineColor(kBlack); |
459 |
|
calibS4_4->SetFillColor(kRed); |
460 |
|
calibS4_4->GetYaxis()->SetTitle("Number of events"); |
461 |
|
calibS4_4->GetYaxis()->SetTitleSize(0.03); |
462 |
|
calibS4_4->GetYaxis()->SetTitleOffset(1); |
463 |
|
calibS4_4->GetYaxis()->CenterTitle(); |
464 |
|
calibS4_4->GetYaxis()->SetLabelSize(0.02); |
465 |
|
calibS4_4->GetXaxis()->CenterTitle(); |
466 |
|
calibS4_4->GetXaxis()->SetTitleSize(0.03); |
467 |
|
calibS4_4->GetXaxis()->SetTitleOffset(1); |
468 |
|
calibS4_4->GetXaxis()->SetLabelSize(0.02); |
469 |
|
calibS4_4->GetXaxis()->SetTitle("ADC (ch)"); |
470 |
|
calibS4_4->SetAxisRange(500,2500); |
471 |
|
calibS4_4->Draw(); |
472 |
|
|
473 |
oss.str(""); |
oss.str(""); |
474 |
if (outDir == "./") { |
if (outDir == "./") { |
475 |
oss << filename.Data() << "_S4_Calibration_QL." << format.Data(); |
oss << filename.Data() << "_S4_Calibration_QL." << format.Data(); |
476 |
} else { |
} else { |
477 |
oss << outDir.Data() << filename.Data() << "_S4_Calibration_QL." << format.Data(); |
oss << outDir.Data() << filename.Data() << "_S4_Calibration_QL." << format.Data(); |
478 |
} |
} |
479 |
finalCanv->SaveAs(oss.str().c_str()); |
finalCanv->SaveAs(oss.str().c_str()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
} |
} |
481 |
|
|
482 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |