--- quicklook/QLflightS4_ND/S4_Calibration_QL.cpp 2006/08/22 09:06:35 1.3 +++ quicklook/QLflightS4_ND/S4_Calibration_QL.cpp 2007/03/12 14:34:12 1.5 @@ -57,15 +57,23 @@ //--------------- Variables initialization -----------------------------------// const Int_t channels = 4096; - Double_t calib_1; - Double_t calib_2; - Double_t calib_4; + Double_t calib_1_MEAN; + Double_t calib_2_MEAN; + Double_t calib_4_MEAN; Double_t calib_1_RMS; Double_t calib_2_RMS; Double_t calib_4_RMS; + Double_t calib_1=0, calib_2=0, calib_4=0; Double_t obt; TString status; Int_t IPM1status, IPM2status; + ULong_t lastime, firstime, obt1, utile; + double obmin=0.; + double obmax=0.; + double limitdown=0; + double limitup=0; + + //------------------------- Open data file -------------------------------------// TFile *file =new TFile(base.Data()) ; TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); @@ -133,58 +141,50 @@ } //---------------Look for configuration hot or cold -----------------------// - Int_t recordstot=0; - for (Int_t i = 0; i < neventstmtc; i++){ - tmtcBr->GetEntry(i); - Long64_t tmpSizetmtc = tme->Records->GetEntries(); - recordstot=recordstot+tmpSizetmtc; - } - const Int_t lungmax=16*recordstot; - Double_t xrecordobtcc[lungmax], yccdiagacq[lungmax], xrecordobtcc_1[lungmax], yccdiagacq_1[lungmax]; - recordstot=0; - for (Int_t i = 0; i < neventstmtc; i++){ - tmtcBr->GetEntry(i); - Long64_t tmpSizetmtc = tme->Records->GetEntries(); - Int_t size_b = tmpSizetmtc; - for (Int_t j = 0; j < size_b; j++){ - tmr = (pamela::TmtcRecord*)tme->Records->At(j); - for (Int_t k =0; k <16; k++){ - yccdiagacq[16*recordstot+16*j+k] = (((tmr->TM_DIAG_AND_BILEVEL_ACQ)>>(15-k))&0x0001); - xrecordobtcc[16*recordstot+16*j+k] = tmr->TM_RECORD_OBT; + if(neventstmtc!=0){ + Int_t recordstot=0; + for (Int_t i = 0; i < neventstmtc; i++){ + tmtcBr->GetEntry(i); + Long64_t tmpSizetmtc = tme->Records->GetEntries(); + recordstot=recordstot+tmpSizetmtc; + } + const Int_t lungmax=16*recordstot; + Double_t xrecordobtcc[lungmax], yccdiagacq[lungmax], xrecordobtcc_1[lungmax], yccdiagacq_1[lungmax]; + recordstot=0; + for (Int_t i = 0; i < neventstmtc; i++){ + tmtcBr->GetEntry(i); + Long64_t tmpSizetmtc = tme->Records->GetEntries(); + Int_t size_b = tmpSizetmtc; + for (Int_t j = 0; j < size_b; j++){ + tmr = (pamela::TmtcRecord*)tme->Records->At(j); + for (Int_t k =0; k <16; k++){ + yccdiagacq[16*recordstot+16*j+k] = (((tmr->TM_DIAG_AND_BILEVEL_ACQ)>>(15-k))&0x0001); + xrecordobtcc[16*recordstot+16*j+k] = tmr->TM_RECORD_OBT; + } } + recordstot=recordstot+tmpSizetmtc; } - recordstot=recordstot+tmpSizetmtc; - } - Int_t riftime = recordstot/2; - //CC (0=IPM1=hot; 1=IPM2=cold for S4 calibration) - for (Int_t k =0; k<16; k++){ - for (Int_t i = 0; i < recordstot; i++){ - yccdiagacq_1[i]= yccdiagacq[16*i+k]; - xrecordobtcc_1[i]= xrecordobtcc[16*i+k]; + Int_t riftime = recordstot/2; + //CC (0=IPM1=hot; 1=IPM2=cold for S4 calibration) + for (Int_t k =0; k<16; k++){ + for (Int_t i = 0; i < recordstot; i++){ + yccdiagacq_1[i]= yccdiagacq[16*i+k]; + xrecordobtcc_1[i]= xrecordobtcc[16*i+k]; + } + if (k==0) IPM1status=(Int_t)yccdiagacq_1[riftime]; + if (k==1) IPM2status=(Int_t)yccdiagacq_1[riftime]; } - if (k==0) IPM1status=(Int_t)yccdiagacq_1[riftime]; - if (k==1) IPM2status=(Int_t)yccdiagacq_1[riftime]; - } - if (IPM1status==0 && IPM2status==1){ - status="CONFIGURATION: HOT"; - } - if (IPM1status==1 && IPM2status==0){ - status="CONFIGURATION: COLD"; + if (IPM1status==0 && IPM2status==1){ + status="CONFIGURATION: HOT"; + } + if (IPM1status==1 && IPM2status==0){ + status="CONFIGURATION: COLD"; + } + }else{ + status=" No info about kind of calibration (hot or cold)"; } - //------------- Create and fill histograms -------------------------------------------// - - 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 "<GetEntry(0); ph = eh->GetPscuHeader(); firstime = ph->GetOrbitalTime(); @@ -197,8 +197,9 @@ for(Int_t kk = 0; kkGetEntry(kk); ph = eh->GetPscuHeader(); - if(obmin >= ph->GetOrbitalTime())obmin=ph->GetOrbitalTime(); - if(obmax <= ph->GetOrbitalTime())obmax=ph->GetOrbitalTime(); + utile=ph->GetOrbitalTime(); + if(obmin >= utile)obmin=utile; + if(obmax <= utile)obmax=utile; } limitdown= obmin - 1000000; limitup= obmax + 1000000; @@ -206,16 +207,27 @@ for(Int_t kk = 0; kkGetEntry(kk); ph = eh->GetPscuHeader(); - cout<<"OrbitalTime()"<GetOrbitalTime()<<"\n"; - if(obmin >= ph->GetOrbitalTime())obmin=ph->GetOrbitalTime(); - if(obmax <= ph->GetOrbitalTime())obmax=ph->GetOrbitalTime(); + utile=ph->GetOrbitalTime(); + //cout<<"OrbitalTime()"<GetOrbitalTime()<<"\n"; + if(obmin >= utile)obmin=utile; + if(obmax <= utile)obmax=utile; } limitdown=obmin; limitup=obmax; } + //------------- Create and fill histograms -------------------------------------------// + stringstream oss1; + oss1.str(""); + oss1 << "S4 Calibration: "<< filename.Data(); + TH1F *calibS4_1 =new TH1F("S4-1", oss1.str().c_str(), channels, 0, channels); + TH1F *calibS4_2 =new TH1F("S4-2", oss1.str().c_str(), channels, 0, channels); + TH1F *calibS4_4 =new TH1F("S4-3", oss1.str().c_str(), channels, 0, channels); + stringstream oss; oss.str(""); oss << "S4_Calibration_QL: "<< filename.Data(); + const Int_t size = nevents; + //cout<<"size "<Fill(s4Record->S4_DATA); + calib_1 = calib_1+s4Record->S4_DATA; break; } case 1 :{ calibS4_2->Fill(s4Record->S4_DATA); + calib_2 = calib_2+s4Record->S4_DATA; break; } case 3 :{ calibS4_4->Fill(s4Record->S4_DATA); + calib_4 = calib_4+s4Record->S4_DATA; break; } } } } - + utile=ph->GetOrbitalTime(); //obt=ph->GetOrbitalTime(); - calib_1=calibS4_1->GetMean(1); + calib_1_MEAN=calib_1/128; //calib_1_RMS=calibS4_1->GetRMS(1); - calib_2=calibS4_2->GetMean(1); + calib_2_MEAN=calib_2/128; //calib_2_RMS=calibS4_2->GetRMS(1); - calib_4=calibS4_4->GetMean(1); + calib_4_MEAN=calib_4/128; //calib_4_RMS=calibS4_4->GetRMS(1); - cal1->Fill(ph->GetOrbitalTime(),calib_1); - cal2->Fill(ph->GetOrbitalTime(),calib_2); - cal4->Fill(ph->GetOrbitalTime(),calib_4); - cout<<"k"<Fill(utile,calib_1_MEAN); + cal2->Fill(utile,calib_2_MEAN); + cal4->Fill(utile,calib_4_MEAN); + calib_1=calib_2=calib_4=0; } //----------------- Create and draw canvas -----------------------------------------// TCanvas *finalCanv = new TCanvas("S4Calib","Calibration_QL", 1280, 1024); - finalCanv->SetFillColor(10); + finalCanv->SetFillColor(10); + finalCanv->Divide(2,2); - finalCanv->cd(); + finalCanv->cd(1); gPad->SetLogy(); - cal1->SetStats(kFALSE); cal1->SetMarkerSize(.5); cal1->SetMarkerStyle(21); @@ -393,28 +404,79 @@ func6->Draw("same"); } - TPad *pad = new TPad("pad","pad", .75, .93, .99, .99); + //TPad *pad = new TPad("pad","pad", .75, .93, .99, .99); + TPad *pad = new TPad("pad","pad", .58, .85, .92, .94); pad->SetFillColor(10); pad->Draw(); pad->cd(); TLatex *l = new TLatex(); l->SetTextAlign(12); - l->SetTextSize(0.35); - l->SetTextColor(8); + l->SetTextSize(0.4); + l->SetTextColor(kRed); l->DrawLatex(0.05, 0.65, status.Data()); + + finalCanv->cd(2); + gPad->SetLogy(); + gStyle->SetOptStat("nemrou"); + calibS4_1->SetLineColor(kBlack); + calibS4_1->SetFillColor(kRed); + calibS4_1->GetYaxis()->SetTitle("Number of events"); + calibS4_1->GetYaxis()->SetTitleSize(0.03); + calibS4_1->GetYaxis()->SetTitleOffset(1); + calibS4_1->GetYaxis()->CenterTitle(); + calibS4_1->GetYaxis()->SetLabelSize(0.02); + calibS4_1->GetXaxis()->CenterTitle(); + calibS4_1->GetXaxis()->SetTitleSize(0.03); + calibS4_1->GetXaxis()->SetTitleOffset(1); + calibS4_1->GetXaxis()->SetLabelSize(0.02); + calibS4_1->GetXaxis()->SetTitle("ADC (ch)"); + calibS4_1->SetAxisRange(0,200); + calibS4_1->Draw(); + + finalCanv->cd(3); + gPad->SetLogy(); + gStyle->SetOptStat("nemrou"); + calibS4_2->SetLineColor(kBlack); + calibS4_2->SetFillColor(kRed); + calibS4_2->GetYaxis()->SetTitle("Number of events"); + calibS4_2->GetYaxis()->SetTitleSize(0.03); + calibS4_2->GetYaxis()->SetTitleOffset(1); + calibS4_2->GetYaxis()->CenterTitle(); + calibS4_2->GetYaxis()->SetLabelSize(0.02); + calibS4_2->GetXaxis()->CenterTitle(); + calibS4_2->GetXaxis()->SetTitleSize(0.03); + calibS4_2->GetXaxis()->SetTitleOffset(1); + calibS4_2->GetXaxis()->SetLabelSize(0.02); + calibS4_2->GetXaxis()->SetTitle("ADC (ch)"); + calibS4_2->SetAxisRange(50,250); + calibS4_2->Draw(); + + finalCanv->cd(4); + gPad->SetLogy(); + gStyle->SetOptStat("nemrou"); + calibS4_4->SetLineColor(kBlack); + calibS4_4->SetFillColor(kRed); + calibS4_4->GetYaxis()->SetTitle("Number of events"); + calibS4_4->GetYaxis()->SetTitleSize(0.03); + calibS4_4->GetYaxis()->SetTitleOffset(1); + calibS4_4->GetYaxis()->CenterTitle(); + calibS4_4->GetYaxis()->SetLabelSize(0.02); + calibS4_4->GetXaxis()->CenterTitle(); + calibS4_4->GetXaxis()->SetTitleSize(0.03); + calibS4_4->GetXaxis()->SetTitleOffset(1); + calibS4_4->GetXaxis()->SetLabelSize(0.02); + calibS4_4->GetXaxis()->SetTitle("ADC (ch)"); + calibS4_4->SetAxisRange(500,2500); + calibS4_4->Draw(); + oss.str(""); if (outDir == "./") { oss << filename.Data() << "_S4_Calibration_QL." << format.Data(); } else { oss << outDir.Data() << filename.Data() << "_S4_Calibration_QL." << format.Data(); } - finalCanv->SaveAs(oss.str().c_str()); - - - - - + finalCanv->SaveAs(oss.str().c_str()); } int main(int argc, char* argv[]){