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; |
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(); |
206 |
for(Int_t kk = 0; kk<nevents; kk++){ |
for(Int_t kk = 0; kk<nevents; kk++){ |
207 |
headBr->GetEntry(kk); |
headBr->GetEntry(kk); |
208 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
209 |
cout<<"OrbitalTime()"<<ph->GetOrbitalTime()<<"\n"; |
//cout<<"OrbitalTime()"<<ph->GetOrbitalTime()<<"\n"; |
210 |
if(obmin >= ph->GetOrbitalTime())obmin=ph->GetOrbitalTime(); |
if(obmin >= ph->GetOrbitalTime())obmin=ph->GetOrbitalTime(); |
211 |
if(obmax <= ph->GetOrbitalTime())obmax=ph->GetOrbitalTime(); |
if(obmax <= ph->GetOrbitalTime())obmax=ph->GetOrbitalTime(); |
212 |
} |
} |
213 |
limitdown=obmin; |
limitdown=obmin; |
214 |
limitup=obmax; |
limitup=obmax; |
215 |
} |
} |
216 |
|
//------------- Create and fill histograms -------------------------------------------// |
217 |
|
stringstream oss1; |
218 |
|
oss1.str(""); |
219 |
|
oss1 << "S4 Calibration: "<< filename.Data(); |
220 |
|
TH1F *calibS4_1 =new TH1F("S4-1", oss1.str().c_str(), channels, 0, channels); |
221 |
|
TH1F *calibS4_2 =new TH1F("S4-2", oss1.str().c_str(), channels, 0, channels); |
222 |
|
TH1F *calibS4_4 =new TH1F("S4-3", oss1.str().c_str(), channels, 0, channels); |
223 |
|
|
224 |
stringstream oss; |
stringstream oss; |
225 |
oss.str(""); |
oss.str(""); |
226 |
oss << "S4_Calibration_QL: "<< filename.Data(); |
oss << "S4_Calibration_QL: "<< filename.Data(); |
227 |
|
const Int_t size = nevents; |
228 |
|
//cout<<"size "<<size <<"\n"; |
229 |
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); |
230 |
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); |
231 |
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); |
241 |
switch (j) { |
switch (j) { |
242 |
case 0 :{ |
case 0 :{ |
243 |
calibS4_1->Fill(s4Record->S4_DATA); |
calibS4_1->Fill(s4Record->S4_DATA); |
244 |
|
calib_1 = calib_1+s4Record->S4_DATA; |
245 |
break; |
break; |
246 |
} |
} |
247 |
case 1 :{ |
case 1 :{ |
248 |
calibS4_2->Fill(s4Record->S4_DATA); |
calibS4_2->Fill(s4Record->S4_DATA); |
249 |
|
calib_2 = calib_2+s4Record->S4_DATA; |
250 |
break; |
break; |
251 |
} |
} |
252 |
case 3 :{ |
case 3 :{ |
253 |
calibS4_4->Fill(s4Record->S4_DATA); |
calibS4_4->Fill(s4Record->S4_DATA); |
254 |
|
calib_4 = calib_4+s4Record->S4_DATA; |
255 |
break; |
break; |
256 |
} |
} |
257 |
} |
} |
259 |
} |
} |
260 |
|
|
261 |
//obt=ph->GetOrbitalTime(); |
//obt=ph->GetOrbitalTime(); |
262 |
calib_1=calibS4_1->GetMean(1); |
calib_1_MEAN=calib_1/128; |
263 |
//calib_1_RMS=calibS4_1->GetRMS(1); |
//calib_1_RMS=calibS4_1->GetRMS(1); |
264 |
calib_2=calibS4_2->GetMean(1); |
calib_2_MEAN=calib_2/128; |
265 |
//calib_2_RMS=calibS4_2->GetRMS(1); |
//calib_2_RMS=calibS4_2->GetRMS(1); |
266 |
calib_4=calibS4_4->GetMean(1); |
calib_4_MEAN=calib_4/128; |
267 |
//calib_4_RMS=calibS4_4->GetRMS(1); |
//calib_4_RMS=calibS4_4->GetRMS(1); |
268 |
cal1->Fill(ph->GetOrbitalTime(),calib_1); |
cal1->Fill(ph->GetOrbitalTime(),calib_1_MEAN); |
269 |
cal2->Fill(ph->GetOrbitalTime(),calib_2); |
cal2->Fill(ph->GetOrbitalTime(),calib_2_MEAN); |
270 |
cal4->Fill(ph->GetOrbitalTime(),calib_4); |
cal4->Fill(ph->GetOrbitalTime(),calib_4_MEAN); |
271 |
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"; |
|
272 |
|
|
273 |
} |
} |
274 |
|
|
275 |
//----------------- Create and draw canvas -----------------------------------------// |
//----------------- Create and draw canvas -----------------------------------------// |
276 |
TCanvas *finalCanv = new TCanvas("S4Calib","Calibration_QL", 1280, 1024); |
TCanvas *finalCanv = new TCanvas("S4Calib","Calibration_QL", 1280, 1024); |
277 |
finalCanv->SetFillColor(10); |
finalCanv->SetFillColor(10); |
278 |
|
finalCanv->Divide(2,2); |
279 |
|
|
280 |
finalCanv->cd(); |
finalCanv->cd(1); |
281 |
gPad->SetLogy(); |
gPad->SetLogy(); |
|
|
|
282 |
cal1->SetStats(kFALSE); |
cal1->SetStats(kFALSE); |
283 |
cal1->SetMarkerSize(.5); |
cal1->SetMarkerSize(.5); |
284 |
cal1->SetMarkerStyle(21); |
cal1->SetMarkerStyle(21); |
402 |
func6->Draw("same"); |
func6->Draw("same"); |
403 |
} |
} |
404 |
|
|
405 |
TPad *pad = new TPad("pad","pad", .75, .93, .99, .99); |
//TPad *pad = new TPad("pad","pad", .75, .93, .99, .99); |
406 |
|
TPad *pad = new TPad("pad","pad", .58, .85, .92, .94); |
407 |
pad->SetFillColor(10); |
pad->SetFillColor(10); |
408 |
pad->Draw(); |
pad->Draw(); |
409 |
pad->cd(); |
pad->cd(); |
410 |
TLatex *l = new TLatex(); |
TLatex *l = new TLatex(); |
411 |
l->SetTextAlign(12); |
l->SetTextAlign(12); |
412 |
l->SetTextSize(0.35); |
l->SetTextSize(0.4); |
413 |
l->SetTextColor(8); |
l->SetTextColor(kRed); |
414 |
l->DrawLatex(0.05, 0.65, status.Data()); |
l->DrawLatex(0.05, 0.65, status.Data()); |
415 |
|
|
416 |
|
|
417 |
|
finalCanv->cd(2); |
418 |
|
gPad->SetLogy(); |
419 |
|
gStyle->SetOptStat("nemrou"); |
420 |
|
calibS4_1->SetLineColor(kBlack); |
421 |
|
calibS4_1->SetFillColor(kRed); |
422 |
|
calibS4_1->GetYaxis()->SetTitle("Number of events"); |
423 |
|
calibS4_1->GetYaxis()->SetTitleSize(0.03); |
424 |
|
calibS4_1->GetYaxis()->SetTitleOffset(1); |
425 |
|
calibS4_1->GetYaxis()->CenterTitle(); |
426 |
|
calibS4_1->GetYaxis()->SetLabelSize(0.02); |
427 |
|
calibS4_1->GetXaxis()->CenterTitle(); |
428 |
|
calibS4_1->GetXaxis()->SetTitleSize(0.03); |
429 |
|
calibS4_1->GetXaxis()->SetTitleOffset(1); |
430 |
|
calibS4_1->GetXaxis()->SetLabelSize(0.02); |
431 |
|
calibS4_1->GetXaxis()->SetTitle("ADC (ch)"); |
432 |
|
calibS4_1->SetAxisRange(0,200); |
433 |
|
calibS4_1->Draw(); |
434 |
|
|
435 |
|
finalCanv->cd(3); |
436 |
|
gPad->SetLogy(); |
437 |
|
gStyle->SetOptStat("nemrou"); |
438 |
|
calibS4_2->SetLineColor(kBlack); |
439 |
|
calibS4_2->SetFillColor(kRed); |
440 |
|
calibS4_2->GetYaxis()->SetTitle("Number of events"); |
441 |
|
calibS4_2->GetYaxis()->SetTitleSize(0.03); |
442 |
|
calibS4_2->GetYaxis()->SetTitleOffset(1); |
443 |
|
calibS4_2->GetYaxis()->CenterTitle(); |
444 |
|
calibS4_2->GetYaxis()->SetLabelSize(0.02); |
445 |
|
calibS4_2->GetXaxis()->CenterTitle(); |
446 |
|
calibS4_2->GetXaxis()->SetTitleSize(0.03); |
447 |
|
calibS4_2->GetXaxis()->SetTitleOffset(1); |
448 |
|
calibS4_2->GetXaxis()->SetLabelSize(0.02); |
449 |
|
calibS4_2->GetXaxis()->SetTitle("ADC (ch)"); |
450 |
|
calibS4_2->SetAxisRange(50,250); |
451 |
|
calibS4_2->Draw(); |
452 |
|
|
453 |
|
finalCanv->cd(4); |
454 |
|
gPad->SetLogy(); |
455 |
|
gStyle->SetOptStat("nemrou"); |
456 |
|
calibS4_4->SetLineColor(kBlack); |
457 |
|
calibS4_4->SetFillColor(kRed); |
458 |
|
calibS4_4->GetYaxis()->SetTitle("Number of events"); |
459 |
|
calibS4_4->GetYaxis()->SetTitleSize(0.03); |
460 |
|
calibS4_4->GetYaxis()->SetTitleOffset(1); |
461 |
|
calibS4_4->GetYaxis()->CenterTitle(); |
462 |
|
calibS4_4->GetYaxis()->SetLabelSize(0.02); |
463 |
|
calibS4_4->GetXaxis()->CenterTitle(); |
464 |
|
calibS4_4->GetXaxis()->SetTitleSize(0.03); |
465 |
|
calibS4_4->GetXaxis()->SetTitleOffset(1); |
466 |
|
calibS4_4->GetXaxis()->SetLabelSize(0.02); |
467 |
|
calibS4_4->GetXaxis()->SetTitle("ADC (ch)"); |
468 |
|
calibS4_4->SetAxisRange(500,2500); |
469 |
|
calibS4_4->Draw(); |
470 |
|
|
471 |
oss.str(""); |
oss.str(""); |
472 |
if (outDir == "./") { |
if (outDir == "./") { |
473 |
oss << filename.Data() << "_S4_Calibration_QL." << format.Data(); |
oss << filename.Data() << "_S4_Calibration_QL." << format.Data(); |
474 |
} else { |
} else { |
475 |
oss << outDir.Data() << filename.Data() << "_S4_Calibration_QL." << format.Data(); |
oss << outDir.Data() << filename.Data() << "_S4_Calibration_QL." << format.Data(); |
476 |
} |
} |
477 |
finalCanv->SaveAs(oss.str().c_str()); |
finalCanv->SaveAs(oss.str().c_str()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
} |
} |
479 |
|
|
480 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |