From bab4d184a6391fec2a4ee8158066ac0a14fa5346 Mon Sep 17 00:00:00 2001 From: Vratislav Chudoba Date: Fri, 17 Feb 2017 15:45:51 +0300 Subject: [PATCH] Some scripts changed. Probably also optimized. --- macros_W/cal1ePeaks.cxx | 24 +++++++++++++++--------- macros_W/calPeaksVoltage.cxx | 25 ++++++++++++++++++++++--- macros_W/extract1DHists.cxx | 11 ++++++----- macros_W/showHistOutput.cxx | 25 +++++++++++++++++++++---- 4 files changed, 64 insertions(+), 21 deletions(-) diff --git a/macros_W/cal1ePeaks.cxx b/macros_W/cal1ePeaks.cxx index cc0a981..8be4563 100644 --- a/macros_W/cal1ePeaks.cxx +++ b/macros_W/cal1ePeaks.cxx @@ -7,35 +7,37 @@ void cal1ePeaks() { TString location = "../data/WPT_tests"; + TString suffix = "_nonLin"; //name of input root file TString iFile; - iFile.Form("%s/680pF_11okt_measure_with_opt_grease/HV1000_Sci_mounted_Am241in_front_10cm_thr32_nxtrim1_11oct_30min_0000.root", location.Data()); + iFile.Form("%s/680pF_11okt_measure_with_opt_grease/HV1000_Sci_mounted_Am241in_front_10cm_thr32_nxtrim1_11oct_30min_0000%s.root", location.Data(), suffix.Data()); // iFile.Form("%s/680pF_11okt_measure_with_opt_grease/HV950_Sci_mounted_Am241in_front_10cm_thr32_nxtrim1_11oct_30min_0000.root", location.Data()); // iFile.Form("%s/680pF_11okt_measure_with_opt_grease/HV900_Sci_mounted_Am241in_front_10cm_thr28_nxtrim1_11oct_30min_0000.root", location.Data()); //name of file with calibration parameters - TString oFile = "cal1e_HV1000.par"; + TString oFile = "cal1e_HV1000_nonLin.par"; // TString oFile = "cal1e_HV950.par"; // TString oFile = "cal1e_HV900.par"; //name of file with peak ranges - TString pFile = "peaksRange1000HV.par"; + TString pFile = "../parameters/peaksRange1000HV.par"; // TString pFile = "../parameters/peaksRange950HV.par"; // TString pFile = ""; + //2D histogram to be calibrated +// TString histName = "adcAllWoBaseline"; + TString histName = "fhCalAdcAllWoBaselineNonLinear"; + ofstream calFile; calFile.open(oFile.Data()); if (calFile.is_open()) { - Info("calPeaks", "Calibration parameters will be saved in %s.", oFile.Data()); + Info("cal1ePeaks.cxx", "Calibration parameters will be saved in %s.", oFile.Data()); } else { - Error("calPeaks", "File %s was not open.", oFile.Data()); + Error("cal1ePeaks.cxx", "File %s was not open.", oFile.Data()); return; } - //2D histogram to be calibrated - TString histName = "adcAllWoBaseline"; - //xaxis range const Double_t xmin = 0; const Double_t xmax = 600.; @@ -47,7 +49,7 @@ void cal1ePeaks() if (useParFile) { parFile.open(pFile.Data()); if (!parFile.is_open()) { - Error("calPeaks", "File with input parameters %s was not open.", pFile.Data()); + Error("cal1ePeaks.cxx", "File with input parameters %s was not open.", pFile.Data()); return; } Info("calPeaks", "File with peak ranges %s will be loaded.", pFile.Data()); @@ -56,6 +58,10 @@ void cal1ePeaks() /////////////////////////////////////////////////////////// TFile *fr = new TFile(iFile.Data()); + if (fr->IsZombie()) { + Error("cal1ePeaks.cxx", "Files %s was not open.", iFile.Data()); + return; + } TH2D *h2 = (TH2D*)fr->Get(histName.Data()); diff --git a/macros_W/calPeaksVoltage.cxx b/macros_W/calPeaksVoltage.cxx index 03f54b6..605bdb2 100644 --- a/macros_W/calPeaksVoltage.cxx +++ b/macros_W/calPeaksVoltage.cxx @@ -2,15 +2,19 @@ #include // std::vector #include +using namespace std; + void calPeaksVoltage() { - TString inFile = "histOutput680.root"; + TString inFile = "parameters/histOutput680.root"; // TString inFile = "histOutput.root"; - TString outFile = "calGraphs680.root"; + TString outFile = "../parameters/calGraphs680.root"; // TString outFile = "calGraphs.root"; + TString outPeaksFile = "parameters/halfVoltPositions680.par"; + TFile *fr = new TFile(inFile.Data()); if (fr->IsZombie()) { Error("calPeaksVoltage.cxx", "File %s was not open correctly.", inFile.Data()); @@ -42,7 +46,14 @@ void calPeaksVoltage() cWork[i]->cd(1); } - + ofstream calFile; + calFile.open(outPeaksFile.Data()); + if (calFile.is_open()) { + Info("calPeaksVoltage.cxx", "Positions of 0.5V peak will be saved in %s.", outPeaksFile.Data()); + } else { + Error("calPeaksVoltage.cxx", "File %s was not open.", outPeaksFile.Data()); + return; + } TFile fw(outFile.Data(), "RECREATE"); if (fw.IsZombie()) { @@ -51,6 +62,8 @@ void calPeaksVoltage() } TString gName; + Double_t x, y; + for (Int_t i = 0; i < 64; i++) { hch[i]->GetXaxis()->SetRangeUser(100, 2000); Int_t cNumber = i/6; @@ -60,6 +73,10 @@ void calPeaksVoltage() if (i == 42) { gr[i] = searchPeaks(hch[i], 0.08); } + //take a peak corresponding to 0.5 V for 680 pF + gr[i]->GetPoint(1, x, y); + calFile << i << "\t" << x << endl; +// cout << i << "\t" << x << endl; fw.cd(); gName.Form("gcal%d", i); gr[i]->SetName(gName.Data()); @@ -68,6 +85,8 @@ void calPeaksVoltage() fw.Close(); + calFile.close(); + return; } diff --git a/macros_W/extract1DHists.cxx b/macros_W/extract1DHists.cxx index d8622c6..6b1fc90 100644 --- a/macros_W/extract1DHists.cxx +++ b/macros_W/extract1DHists.cxx @@ -3,17 +3,18 @@ void extract1DHists() //output in channel units // TString outputFile = "histOutput.root"; -// TString outputFile = "histOutput680.root"; + TString outputFile = "parameters/histOutput680.root"; //output in 1e units - TString outputFile = "histOutput1e.root"; +// TString outputFile = "histOutput1e_HV1000.root"; +// TString outputFile = "histOutput1e_HV950.root"; -// TString histName = "adcAllWoBaseline"; TString histName = "adcAllWoBaseline"; +// TString histName = "cal1eAdcAllWoBaseline"; TString location = "../data/WPT_tests"; -// TString suffix = ""; - TString suffix = "_HV1000"; + TString suffix = ""; +// TString suffix = "_HV1000"; TString f0, f1, f2, f3, f4, f10, f11, f12, f13, diff --git a/macros_W/showHistOutput.cxx b/macros_W/showHistOutput.cxx index 9e0ff7e..b798c67 100644 --- a/macros_W/showHistOutput.cxx +++ b/macros_W/showHistOutput.cxx @@ -1,6 +1,26 @@ void showHistOutput() { - TFile *fr = new TFile("histOutput.root"); + + //channel units + //TString fName = "histOutput.root"; +// TString fName = "histOutput680.root"; + TString fName = "histOutput47.root"; + + const Double_t xmin = 100.; + const Double_t xmax = 2000.; + + //1e units +// TString fName = "histOutput1e_HV1000.root"; + //TString fName = "histOutput1e_HV950.root"; + +// const Double_t xmin = 0.5; +// const Double_t xmax = 12.; + + TFile *fr = new TFile(fName.Data()); + if (fr->IsZombie()) { + Error("showHistOutput.cxx", "Files %s was not open.", fName.Data()); + return; + } TH1D *hch[64]; TString histName; @@ -17,9 +37,6 @@ void showHistOutput() const Int_t pads = 9; const Int_t noCanvas = 64/pads+1; - const Double_t xmin = 100; - const Double_t xmax = 2000.; - TCanvas *cWork[noCanvas]; for (Int_t i = 0; i < noCanvas; i++) { cName.Form("can%d", i); -- 2.18.1