...
 
Commits (5)
...@@ -7,35 +7,38 @@ void cal1ePeaks() ...@@ -7,35 +7,38 @@ void cal1ePeaks()
{ {
TString location = "../data/WPT_tests"; TString location = "../data/WPT_tests";
// TString suffix = "_nonLin";
TString suffix = "";
//name of input root file //name of input root file
TString iFile; 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/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()); // 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 //name of file with calibration parameters
TString oFile = "cal1e_HV1000.par"; TString oFile = "parameters/cal1e_HV1000_nonLin.par";
// TString oFile = "cal1e_HV950.par"; TString oFile = "parameters/cal1e_HV950_nonLin.par";
// TString oFile = "cal1e_HV900.par"; // TString oFile = "cal1e_HV900.par";
//name of file with peak ranges //name of file with peak ranges
TString pFile = "peaksRange1000HV.par"; // TString pFile = "../parameters/peaksRange1000HV.par";
// TString pFile = "../parameters/peaksRange950HV.par"; TString pFile = "../parameters/peaksRange950HV.par";
// TString pFile = ""; // TString pFile = "";
//2D histogram to be calibrated
// TString histName = "adcAllWoBaseline";
TString histName = "fhAdcAllWoBaselineNLcorr";
ofstream calFile; ofstream calFile;
calFile.open(oFile.Data()); calFile.open(oFile.Data());
if (calFile.is_open()) { 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 { } else {
Error("calPeaks", "File %s was not open.", oFile.Data()); Error("cal1ePeaks.cxx", "File %s was not open.", oFile.Data());
return; return;
} }
//2D histogram to be calibrated
TString histName = "adcAllWoBaseline";
//xaxis range //xaxis range
const Double_t xmin = 0; const Double_t xmin = 0;
const Double_t xmax = 600.; const Double_t xmax = 600.;
...@@ -47,7 +50,7 @@ void cal1ePeaks() ...@@ -47,7 +50,7 @@ void cal1ePeaks()
if (useParFile) { if (useParFile) {
parFile.open(pFile.Data()); parFile.open(pFile.Data());
if (!parFile.is_open()) { 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; return;
} }
Info("calPeaks", "File with peak ranges %s will be loaded.", pFile.Data()); Info("calPeaks", "File with peak ranges %s will be loaded.", pFile.Data());
...@@ -56,6 +59,10 @@ void cal1ePeaks() ...@@ -56,6 +59,10 @@ void cal1ePeaks()
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TFile *fr = new TFile(iFile.Data()); 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()); TH2D *h2 = (TH2D*)fr->Get(histName.Data());
...@@ -115,6 +122,11 @@ void cal1ePeaks() ...@@ -115,6 +122,11 @@ void cal1ePeaks()
cWork[cNumber]->cd(i-pads*cNumber+1); cWork[cNumber]->cd(i-pads*cNumber+1);
hTemp->Draw(); hTemp->Draw();
hTemp->GetXaxis()->SetRangeUser(xmin, xmax); hTemp->GetXaxis()->SetRangeUser(xmin, xmax);
hTemp->GetXaxis()->CenterTitle();
hTemp->GetXaxis()->SetTitle("A*");
hTemp->GetXaxis()->SetTitleSize(0.06);
hTemp->GetXaxis()->SetTitleOffset(0.75);
hTemp->GetYaxis()->SetTitle("counts");
if (useParFile) { if (useParFile) {
std::getline(parFile, line); std::getline(parFile, line);
std::istringstream(line,ios_base::in) >> ch >> min >> max; std::istringstream(line,ios_base::in) >> ch >> min >> max;
...@@ -127,6 +139,8 @@ void cal1ePeaks() ...@@ -127,6 +139,8 @@ void cal1ePeaks()
calFile.close(); calFile.close();
// cWork[0]->SaveAs("figures/cal1e.png");
} }
void fillParFilePreliminary(Int_t noChannels, Int_t min, Int_t max) { void fillParFilePreliminary(Int_t noChannels, Int_t min, Int_t max) {
......
...@@ -2,15 +2,19 @@ ...@@ -2,15 +2,19 @@
#include <vector> // std::vector #include <vector> // std::vector
#include <algorithm> #include <algorithm>
using namespace std;
void calPeaksVoltage() void calPeaksVoltage()
{ {
TString inFile = "histOutput680.root"; TString inFile = "objects/histOutput680.root";
// TString inFile = "histOutput.root"; // TString inFile = "histOutput.root";
TString outFile = "calGraphs680.root"; TString outFile = "objects/calGraphs680.root";
// TString outFile = "calGraphs.root"; // TString outFile = "calGraphs.root";
TString outPeaksFile = "parameters/halfVoltPositions680.par";
TFile *fr = new TFile(inFile.Data()); TFile *fr = new TFile(inFile.Data());
if (fr->IsZombie()) { if (fr->IsZombie()) {
Error("calPeaksVoltage.cxx", "File %s was not open correctly.", inFile.Data()); Error("calPeaksVoltage.cxx", "File %s was not open correctly.", inFile.Data());
...@@ -42,7 +46,14 @@ void calPeaksVoltage() ...@@ -42,7 +46,14 @@ void calPeaksVoltage()
cWork[i]->cd(1); 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"); TFile fw(outFile.Data(), "RECREATE");
if (fw.IsZombie()) { if (fw.IsZombie()) {
...@@ -51,6 +62,8 @@ void calPeaksVoltage() ...@@ -51,6 +62,8 @@ void calPeaksVoltage()
} }
TString gName; TString gName;
Double_t x, y;
for (Int_t i = 0; i < 64; i++) { for (Int_t i = 0; i < 64; i++) {
hch[i]->GetXaxis()->SetRangeUser(100, 2000); hch[i]->GetXaxis()->SetRangeUser(100, 2000);
Int_t cNumber = i/6; Int_t cNumber = i/6;
...@@ -60,6 +73,10 @@ void calPeaksVoltage() ...@@ -60,6 +73,10 @@ void calPeaksVoltage()
if (i == 42) { if (i == 42) {
gr[i] = searchPeaks(hch[i], 0.08); 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(); fw.cd();
gName.Form("gcal%d", i); gName.Form("gcal%d", i);
gr[i]->SetName(gName.Data()); gr[i]->SetName(gName.Data());
...@@ -68,6 +85,8 @@ void calPeaksVoltage() ...@@ -68,6 +85,8 @@ void calPeaksVoltage()
fw.Close(); fw.Close();
calFile.close();
return; return;
} }
......
#include <iostream>
#include <vector> // std::vector
#include <algorithm>
using namespace std;
void calTransition47()
{
//input files
TString inHistFile = "../parameters/histOutput47.root";
TString inHalfVoltPosFile = "../parameters/halfVoltPositions680.par";
// TString inCalParFile = "../parameters/cal1e_HV1000_nonLin.par";
TString inCalParFile = "../parameters/cal1e_HV950_nonLin.par";
//output files
TString outPosFile = "parameters/threeVoltPositions47.par";
// TString outCalFile = "parameters/cal1e_47_HV1000_nonLin.par";
TString outCalFile = "parameters/cal1e_47_HV950_nonLin.par";
TFile *fr = new TFile(inHistFile.Data());
if (fr->IsZombie()) {
Error("calTransition47.cxx", "File %s was not open correctly.", inHistFile.Data());
return;
}
ifstream inCalFile;
inCalFile.open(inCalParFile.Data());
if (!inCalFile.is_open()) {
Error("calTransition47.cxx", "File with input parameters %s was not open.", inCalParFile.Data());
return;
}
Info("calTransition47.cxx", "File with 680 pF calpars %s will be loaded.", inCalParFile.Data());
ifstream inHalfVoltFile;
inHalfVoltFile.open(inHalfVoltPosFile.Data());
if (!inHalfVoltFile.is_open()) {
Error("cal1ePeaks.cxx", "File with input parameters %s was not open.", inHalfVoltPosFile.Data());
return;
}
Info("calTransition47.cxx", "File with 0.5 V positions at 680 pF %s will be loaded.", inHalfVoltPosFile.Data());
//output files
ofstream calPosFile;
calPosFile.open(outPosFile.Data());
if (calPosFile.is_open()) {
Info("calTransition47.cxx", "Positions of 3.0V peak at 4.7 pF will be saved in %s.", outPosFile.Data());
} else {
Error("calTransition47.cxx", "File %s was not open.", outPosFile.Data());
return;
}
ofstream calFile;
calFile.open(outCalFile.Data());
if (calFile.is_open()) {
Info("calTransition47.cxx", "Calibration parameters for 4.7 nF will be saved in %s.", outCalFile.Data());
} else {
Error("calTransition47.cxx", "File %s was not open.", outCalFile.Data());
return;
}
TH1D *hch[64];
TGraph *gr[64];
TString hName;
for (Int_t i = 0; i <64; i++) {
hName.Form("ch%d", i);
hch[i] = (TH1D*)fr->Get(hName.Data());
}
TString cName;
TString cTitle;
TCanvas *cWork[11];
for (Int_t i = 0; i < 11; i++) {
cWork[i] = new TCanvas();
cName.Form("can%d", i);
cTitle.Form("canvas %d", i);
cWork[i]->SetName(cName.Data());
cWork[i]->SetTitle(cTitle.Data());
cWork[i]->Divide(2, 3);
cWork[i]->cd(1);
}
Double_t x, y;
Double_t relHight = 0.5;
string line;
Int_t ch = 0;
Double_t calPar = 0.;
Double_t halfVoltPos = 0.;
for (Int_t i = 0; i < 64; i++) {
hch[i]->GetXaxis()->SetRangeUser(100, 800);
Int_t cNumber = i/6;
cWork[cNumber]->cd(i-6*cNumber+1);
hch[i]->Draw();
hch[i]->ShowPeaks(2., "", relHight);
TList *functions = hch[i]->GetListOfFunctions();
TPolyMarker *pm = (TPolyMarker*)functions->FindObject("TPolyMarker");
const Int_t noPeaks = pm->GetN();
if (noPeaks != 1) {
Error("calTransition47.cxx", "%d peaks found in hist %s", noPeaks, hch[i]->GetName());
continue;
}
// Info("calTransition47.cxx", "%d peak found in hist %s", noPeaks, hch[i]->GetName());
Double_t *energy = pm->GetX();
calPosFile << i << "\t" << energy[0] << endl;
std::getline(inCalFile, line);
std::istringstream(line,ios_base::in) >> ch >> calPar;
std::getline(inHalfVoltFile, line);
std::istringstream(line,ios_base::in) >> ch >> halfVoltPos;
// cout << i << "\t" << energy[0] << "\t" << calPar << "\t\t" << halfVoltPos << "\t" << energy[0]*calPar / (6*halfVoltPos) << endl;
// cout << energy[0]*calPar / (6*halfVoltPos) << endl;
calFile << i << "\t" << energy[0]*calPar / (6*halfVoltPos) << endl;
}
calFile.close();
inCalFile.close();
inHalfVoltFile.close();
// fr->Close();
return;
}
...@@ -3,17 +3,20 @@ void extract1DHists() ...@@ -3,17 +3,20 @@ void extract1DHists()
//output in channel units //output in channel units
// TString outputFile = "histOutput.root"; // TString outputFile = "histOutput.root";
// TString outputFile = "histOutput680.root"; // TString outputFile = "objects/histOutput680.root";
TString outputFile = "objects/histHalfVolts680.root";
//output in 1e units //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 = "adcAllWoBaseline"; TString histName = "fhAdcAllWoBaselineNLcorr";
// TString histName = "cal1eAdcAllWoBaseline";
TString location = "../data/WPT_tests"; TString location = "../data/WPT_tests";
// TString suffix = ""; TString suffix = "";
TString suffix = "_HV1000"; // TString suffix = "_HV1000";
TString f0, f1, f2, f3, f4, TString f0, f1, f2, f3, f4,
f10, f11, f12, f13, f10, f11, f12, f13,
...@@ -70,6 +73,14 @@ void extract1DHists() ...@@ -70,6 +73,14 @@ void extract1DHists()
TH2D *hraw20 = (TH2D*)fr20->Get(histName.Data()); TH2D *hraw20 = (TH2D*)fr20->Get(histName.Data());
TH2D *hraw21 = (TH2D*)fr21->Get(histName.Data()); TH2D *hraw21 = (TH2D*)fr21->Get(histName.Data());
TH2D *hraw22 = (TH2D*)fr22->Get(histName.Data()); TH2D *hraw22 = (TH2D*)fr22->Get(histName.Data());
if (!hraw0 || !hraw1 || !hraw2 || !hraw3 || !hraw4
|| !hraw10 || !hraw11 || !hraw12 || !hraw13
|| !hraw20 || !hraw21 || !hraw22) {
Error("extract1DHists.cxx", "At least one of histograms was not found.");
return;
}
TH2D *hSum2 = new TH2D(*hraw20); TH2D *hSum2 = new TH2D(*hraw20);
hSum2->Add(hraw21); hSum2->Add(hraw21);
hSum2->Add(hraw22); hSum2->Add(hraw22);
......
void extract1DHists47()
{
//output in channel units
TString outputFile = "objects/histOutput47.root";
TString histName = "fhAdcAllWoBaselineNLcorr";
TString location = "../data/WPT_tests";
// TString suffix = "";
//// TString suffix = "_HV1000";
TString f0, f1;
f0.Form("%s/4.7nF_11okt_chargeCalib/TestTriggerMode_chargeCalib_3V_100ns_4.7nF_11oct_0000.root", location.Data());
f1.Form("%s/4.7nF_11okt_chargeCalib/TestTriggerMode_chargeCalib_3V_100ns_4.7nF_11oct_0001.root", location.Data());
TFile *fr0 = new TFile(f0.Data());
TFile *fr1 = new TFile(f1.Data());
if (fr0->IsZombie() || fr1->IsZombie()) {
Error("extract1DHists47.cxx", "One of files was not open.");
return;
}
TH2D *hraw0 = (TH2D*)fr0->Get(histName.Data());
TH2D *hraw1 = (TH2D*)fr1->Get(histName.Data());
if (!hraw0 || !hraw1) {
Error("extract1DHists47.cxx", "At least one of histograms was not found.");
return;
}
TH2D *hSum = new TH2D(*hraw0);
hSum->Add(hraw1);
TCanvas *c1 = new TCanvas();
c1->Divide(2,2);
c1->cd(1);
hSum->GetXaxis()->SetRangeUser(0, 64);
hSum->Draw();
c1->cd(2);
TFile *fw = new TFile(outputFile.Data(), "RECREATE");
TH1D *hch[64];
for (Int_t i = 0; i < 64; i++) {
hch[i] = extractHist(hSum, i);
fw->cd();
hch[i]->Write();
}
fw->Close();
return;
}
TH1D* extractHist(TH2D *hInput, Int_t channel) {
TH1D *hTemp;
TString hName;
TString hTitle;
hName.Form("ch%d", channel);
hTitle.Form("channel %d", channel);
hTemp = hInput->ProjectionY(hName.Data(), channel+1, channel+1);
hTemp->SetTitle(hTitle.Data());
return hTemp;
}
//#include "TMarker.h"
using namespace std;
void figures()
{
const Bool_t pedestals = 0;
const Bool_t nlCorr = 0;
const Bool_t pedCorr = 0;
const Bool_t calDemonstration = 0;
const Bool_t pedTest = 1;
if (pedestals) {
TFile *frPed = new TFile("../data/WPT_tests/680pF_7okt/raw_data/TestTriggerMode_680pF_10minutes_7okt_0000.root");
TH2D *hPedRaw = (TH2D*)frPed->Get("adcAll");
TH2D *hPedA = (TH2D*)frPed->Get("adcAllWoBaseline");
TCanvas *c1 = new TCanvas("c1", "Pedestals raw");
hPedRaw->GetXaxis()->SetRangeUser(0, 64);
hPedRaw->GetXaxis()->SetTitle("PMT pixel");
hPedRaw->GetYaxis()->SetTitle("A_{raw}");
hPedRaw->GetYaxis()->SetTitleOffset(1.38);
hPedRaw->Draw();
c1->SaveAs("figures/pedestalsRaw.png");
TCanvas *c2 = new TCanvas("c2", "Pedestals");
hPedA->GetXaxis()->SetRangeUser(0, 64);
hPedA->GetXaxis()->SetTitle("PMT pixel");
hPedA->GetYaxis()->SetTitle("A");
hPedA->GetYaxis()->SetTitleOffset(1.38);
hPedA->Draw();
c2->SaveAs("figures/pedestalsCorr.png");
}
if (nlCorr) {
TFile *frCorr = new TFile("objects/histOutput680.root");
TH1D *hPeaks = (TH1D*)frCorr->Get("ch15");
TCanvas *c3 = new TCanvas("c3", "Voltage on 680pF");
hPeaks->SetAxisRange(100, 2000);
hPeaks->SetXTitle("A");
hPeaks->SetTitleSize(0.06);
hPeaks->SetTitleOffset(0.73);
hPeaks->GetXaxis()->CenterTitle();
hPeaks->SetYTitle("Events");
hPeaks->Draw();
c3->SaveAs("figures/voltageAmplitudes.png");
TFile *frGraph = new TFile("objects/calGraphs680.root");
TGraph *gCorr = (TGraph*)frGraph->Get("gcal15");
TCanvas *c4 = new TCanvas("c4", "Dimensionless correction");
gCorr->GetXaxis()->SetRangeUser(-100, 1800);
gCorr->GetXaxis()->CenterTitle();
gCorr->GetXaxis()->SetTitle("A");
gCorr->GetXaxis()->SetTitleSize(0.06);
gCorr->GetXaxis()->SetTitleOffset(0.76);
gCorr->GetYaxis()->CenterTitle();
gCorr->GetYaxis()->SetTitle("A'");
gCorr->GetYaxis()->SetTitleSize(0.06);
gCorr->GetYaxis()->SetTitleOffset(0.76);
gCorr->SetLineColor(kBlue);
gCorr->SetLineWidth(4);
gCorr->Draw();
c4->SaveAs("figures/calGraph.png");
}
if (pedCorr) {
TFile *frPed = new TFile("../data/WPT_tests/680pF_7okt/raw_data/TestTriggerMode_680pF_10minutes_7okt_0000.root");
TH2D *hPedAnl = (TH2D*)frPed->Get("fhAdcAllWoBaselineNonLinear");
TH2D *hPedAnlCorr = (TH2D*)frPed->Get("fhAdcAllWoBaselineNLcorr");
TCanvas *c5 = new TCanvas("c5", "Position of corrected pedestals");
hPedAnl->GetXaxis()->SetRangeUser(0, 64);
hPedAnl->GetXaxis()->SetTitle("PMT pixel");
hPedAnl->GetXaxis()->CenterTitle();
hPedAnl->GetYaxis()->SetRangeUser(-50, 200);
hPedAnl->GetYaxis()->SetTitle("A'");
hPedAnl->GetYaxis()->SetTitleSize(0.06);
hPedAnl->GetYaxis()->SetTitleOffset(0.8);
hPedAnl->GetYaxis()->CenterTitle();
hPedAnl->Draw("col");
c5->SaveAs("figures/pedestalsNL.png");
TCanvas *c6 = new TCanvas("c6", "Corrected non-linear pedestals ");
// hPedAnlCorr->GetXaxis()->SetRangeUser(0, 64);
hPedAnlCorr->GetXaxis()->SetTitle("PMT pixel");
hPedAnlCorr->GetYaxis()->SetRangeUser(-50, 200);
hPedAnlCorr->GetYaxis()->SetTitle("A*");
hPedAnlCorr->GetYaxis()->SetTitleSize(0.06);
hPedAnlCorr->GetYaxis()->SetTitleOffset(0.8);
hPedAnlCorr->GetYaxis()->CenterTitle();
hPedAnlCorr->Draw("col");
c6->SaveAs("figures/pedestalsNLcorr.png");
}
if (calDemonstration) {
TFile *frCal680 = new TFile("../data/WPT_tests/680pF_11okt_measure_with_opt_grease/HV1000_Sci_mounted_Am241in_front_10cm_thr32_nxtrim1_11oct_30min_0000_cal.root");
TH1D *hRaw = (TH1D*)frCal680->Get("adcAllSum");
TH1D *hCal = (TH1D*)frCal680->Get("calAdcAllSum");
TH1D *hCorr1 = (TH1D*)frCal680->Get("fhAdcAllSumWoBaselineNonLinear");
TH1D *hCorr2 = (TH1D*)frCal680->Get("fhAdcAllSumWoBaselineNLcorr");
TCanvas *c7 = new TCanvas("c7", "Demonstration of calibration");
c7->Divide(2, 2);
c7->cd(1);
hCorr1->Draw();
c7->cd(2);
hRaw->Draw();
c7->cd(3);
hCorr2->Draw();
c7->cd(4);
hCal->Draw();
}
if (pedTest) {
TFile *frGraph = new TFile("../parameters/calGraphs680.root");
ifstream iPeds;
iPeds.open("parameters/correctedPedsPositions.par");
//canvases for calibration
TString cName;
TString cTitle;
const Int_t pads = 9;
const Int_t noCanvas = 64/pads+1;
TCanvas *cWork[noCanvas];
for (Int_t i = 0; i < noCanvas; i++) {
cName.Form("can%d", i);
cTitle.Form("canvas %d", i);
cWork[i] = new TCanvas(cName.Data(), cTitle.Data(), 0, 0, 960, 700);
// cWork[i]->SetName(cName.Data());
// cWork[i]->SetTitle(cTitle.Data());
if (pads == 6) cWork[i]->Divide(2, 3);
if (pads == 9) cWork[i]->Divide(3, 3);
cWork[i]->cd(1);
}
Int_t pixel = -1, ped = 0;
TString gName;
// TGraph *gr[64];
TGraph *gr;
for (Int_t i = 0; i < 64; i++) {
iPeds >> pixel >> ped;
Int_t cNumber = i/pads;
cWork[cNumber]->cd(i-pads*cNumber+1);
gName.Form("gcal%d", i);
gr = (TGraph*)frGraph->Get(gName.Data());
gr->GetXaxis()->SetRangeUser(-30, 30);
gr->GetXaxis()->SetTitle("A");
gr->GetXaxis()->CenterTitle();
gr->GetXaxis()->SetTitleSize(0.08);
gr->GetXaxis()->SetTitleOffset(0.5);
gr->GetYaxis()->SetRangeUser(0, 50);
gr->GetYaxis()->SetTitle("A'");
gr->GetYaxis()->CenterTitle();
gr->GetYaxis()->SetTitleSize(0.08);
gr->GetYaxis()->SetTitleOffset(0.6);
gr->Draw();
TMarker *point = new TMarker(0, ped, 3);
point->SetMarkerSize(3);
point->SetMarkerColor(kRed);
point->Draw();
// cout << pixel << "\t" << gName.Data() << endl;
}
cWork[2]->SaveAs("figures/pedestalsTest.png");
}
}
#include <iostream>
#include <vector> // std::vector
#include <algorithm>
using namespace std;
void halfVoltPositions680()
{
TString inFile = "objects/histHalfVolts680.root";
TString outPeaksFile = "parameters/halfVoltPositions680.par";
TFile *fr = new TFile(inFile.Data());
if (fr->IsZombie()) {
Error("halfVoltPositions680.cxx", "File %s was not open correctly.", inFile.Data());
return;
}
TH1D *hch[64];
TGraph *gr[64];
TString hName;
for (Int_t i = 0; i <64; i++) {
hName.Form("ch%d", i);
hch[i] = (TH1D*)fr->Get(hName.Data());
}
TString cName;
TString cTitle;
TCanvas *cWork[11];
for (Int_t i = 0; i < 11; i++) {
cWork[i] = new TCanvas();
cName.Form("can%d", i);
cTitle.Form("canvas %d", i);
cWork[i]->SetName(cName.Data());
cWork[i]->SetTitle(cTitle.Data());
cWork[i]->Divide(2, 3);
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;
}
Double_t x, y;
for (Int_t i = 0; i < 64; i++) {
Int_t cNumber = i/6;
cWork[cNumber]->cd(i-6*cNumber+1);
hch[i]->Draw();
if (i!=42 && i!=21 && i!=11 && i!=41) gr[i] = searchPeaks(hch[i]);
if (i == 11) {
gr[i] = searchPeaks(hch[i], 0.2);
}
if (i == 21) {
gr[i] = searchPeaks(hch[i], 0.08);
}
if (i == 41) {
gr[i] = searchPeaks(hch[i], 0.08);
}
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;
}
calFile.close();
return;
}
TGraph* searchPeaks(TH1D *hInput, Double_t relHight = 0.05) {
Double_t voltage[] = {0.5, 1., 1.5, 1.75, 2., 2.25, 2.5, 2.75, 3., 3.25, 0.};
// const Double_t corr1e = 1.18;
// const Double_t corr1e = 1.;
hInput->GetXaxis()->SetRangeUser(150., 1000.);
hInput->ShowPeaks(6., "", relHight);
TList *functions = hInput->GetListOfFunctions();
TPolyMarker *pm = (TPolyMarker*)functions->FindObject("TPolyMarker");
const Int_t noPeaks = pm->GetN();
Double_t *energy = pm->GetX();
std::vector<Double_t> vEnergy;
for (Int_t i = 0; i < pm->GetN(); i++) {
vEnergy.push_back(energy[i]);
}
std::sort(vEnergy.begin(), vEnergy.end());
TGraph *gr = new TGraph(noPeaks+1);
const Double_t delta_vEnergy = 2*vEnergy[0] - vEnergy[1];
vEnergy.push_back(delta_vEnergy);
gr->SetPoint(0, vEnergy[10], voltage[10]/voltage[0]*(vEnergy[0]-delta_vEnergy));
if (noPeaks == 2) Info("searchPeaks", "%d peaks found in hist %s", noPeaks, hInput->GetName());
else Error("searchPeaks", "%d peaks found in hist %s", noPeaks, hInput->GetName());
for (Int_t i = 0; i < noPeaks; i++) {
if (i>=10) break;
gr->SetPoint(i+1, vEnergy[i], voltage[i]/voltage[0]*(vEnergy[0]-delta_vEnergy));
}
return gr;
}
#include <iostream>
using namespace std;
void pedestalsCorrection()
{
TString outPosFile = "parameters/correctedPedsPositions.par";
TString histName = "fhAdcAllWoBaselineNonLinear";
TString location = "../data/WPT_tests";
TString fIn;
fIn.Form("%s/680pF_7okt/raw_data/TestTriggerMode_680pF_10minutes_7okt_0000.root", location.Data());
TFile *fr = new TFile(fIn.Data());
if (fr->IsZombie()) {
Error("pedestalsCorrection.cxx", "Files %s was not open.", fIn.Data());
return;
}
//output files
ofstream calPosFile;
calPosFile.open(outPosFile.Data());
if (calPosFile.is_open()) {
Info("calTransition47.cxx", "Positions of 0.5V peak will be saved in %s.", outPosFile.Data());
} else {
Error("calTransition47.cxx", "File %s was not open.", outPosFile.Data());
return;
}
TH2D *hA = (TH2D*)fr->Get(histName.Data());
TCanvas *c1 = new TCanvas();
c1->Divide(2,2);
c1->cd(1);
hA->GetXaxis()->SetRangeUser(0, 64);
hA->Draw();
c1->cd(2);
TString cName;
TString cTitle;
TCanvas *cWork[11];
for (Int_t i = 0; i < 11; i++) {
cWork[i] = new TCanvas();
cName.Form("can%d", i);
cTitle.Form("canvas %d", i);
cWork[i]->SetName(cName.Data());
cWork[i]->SetTitle(cTitle.Data());
cWork[i]->Divide(2, 3);
cWork[i]->cd(1);
}
TH1D *hch[64];
Double_t x, y;
Double_t relHight = 0.5;
for (Int_t i = 0; i < 64; i++) {
hch[i] = extractHist(hA, i);
hch[i]->GetXaxis()->SetRangeUser(-100, 500);
Int_t cNumber = i/6;
cWork[cNumber]->cd(i-6*cNumber+1);
hch[i]->Draw();
hch[i]->ShowPeaks(2., "", relHight);
TList *functions = hch[i]->GetListOfFunctions();
TPolyMarker *pm = (TPolyMarker*)functions->FindObject("TPolyMarker");
const Int_t noPeaks = pm->GetN();
if (noPeaks != 1) {
Error("calTransition47.cxx", "%d peaks found in hist %s", noPeaks, hch[i]->GetName());
continue;
}
Double_t *energy = pm->GetX();
calPosFile << i << "\t" << energy[0] << endl;
}
calPosFile.close();
return;
}
TH1D* extractHist(TH2D *hInput, Int_t channel) {
TH1D *hTemp;
TString hName;
TString hTitle;
hName.Form("ch%d", channel);
hTitle.Form("channel %d", channel);
hTemp = hInput->ProjectionY(hName.Data(), channel+1, channel+1);
hTemp->SetTitle(hTitle.Data());
return hTemp;
}
void rootlogon()
{
Info("rootlogon.c", "This settings are used to make large canvases");
//gStyle choice
// gROOT->SetStyle("Default");
// gROOT->SetStyle("Plain");
// gROOT->SetStyle("Bold");
// gROOT->SetStyle("Video");
gStyle->SetOptStat("n");
gStyle->SetOptStat("ne");
// gStyle->SetOptStat("");
//canvas size and position
//one panel pictures
// gStyle->SetCanvasDefW(900);
// gStyle->SetCanvasDefH(600);
// gStyle->SetCanvasDefX(800);
// gStyle->SetCanvasDefY(300);
gStyle->SetCanvasDefH(700);
gStyle->SetCanvasDefW(960);
gStyle->SetCanvasDefX(0);
gStyle->SetCanvasDefY(0);
//marker attributes
gStyle->SetMarkerStyle(20);
gStyle->SetMarkerSize(0.1);
gStyle->SetMarkerColor(1);
// gStyle->SetTitleFont(62, "X");
//line attributes
gStyle->SetHistLineWidth(1);
// gStyle->SetHistLineWidth(2);
// gStyle->SetHistLineWidth(3);
gStyle->SetTitleBorderSize(0);
return;
gStyle->SetTitleXSize(0.06);
gStyle->SetTitleYSize(0.06);
return;
gStyle->SetTitleFont(132, "X");
gStyle->SetTitleFont(132, "Y");
gStyle->SetLabelFont(132, "X");
gStyle->SetLabelFont(132, "Y");
gStyle->SetPadTopMargin(0.04);
gStyle->SetPadBottomMargin(0.13);
gStyle->SetPadLeftMargin(0.13);
gStyle->SetPadRightMargin(0.03);
// gStyle->SetTitleOffset(1.3, "Y");
// gStyle->SetLabelSize(0.05, "X");
// gStyle->SetLabelSize(0.05, "Y");
// gStyle->SetTitleSize(0.06, "X");
// gStyle->SetTitleSize(0.06, "Y");
return;
//parameters used for pictures in EXON paper
// gStyle->SetStatBorderSize(0);
// gStyle->SetTitleBorderSize(0);
// gStyle->SetTitleAlign(12);
// gStyle->SetTitleX(0.83);
// gStyle->SetTitleY(0.85);
gStyle->SetTitleX(0.83); //for Fig2
gStyle->SetTitleY(0.9); //for Fig2
gStyle->SetTitleFontSize(0.08);
// gStyle->SetTitleFillColor(0);
// gStyle->SetLineWidth(1);
// gStyle->SetHistLineWidth(1);
gStyle->SetHistLineWidth(3);
gStyle->SetPadTopMargin(0.05);
gStyle->SetPadBottomMargin(0.13);
gStyle->SetPadLeftMargin(0.14);
gStyle->SetPadRightMargin(0.05);
gStyle->SetTitleOffset(1.3, "Y");
gStyle->SetLabelSize(0.05, "X");
gStyle->SetLabelSize(0.05, "Y");
gStyle->SetTitleSize(0.06, "X");
gStyle->SetTitleSize(0.06, "Y");
// gStyle->SetAxisColor(1);
gStyle->SetLabelColor(1, "X");
gStyle->SetLabelColor(1, "Y");
}
void showHistOutput() 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]; TH1D *hch[64];
TString histName; TString histName;
...@@ -17,9 +37,6 @@ void showHistOutput() ...@@ -17,9 +37,6 @@ void showHistOutput()
const Int_t pads = 9; const Int_t pads = 9;
const Int_t noCanvas = 64/pads+1; const Int_t noCanvas = 64/pads+1;
const Double_t xmin = 100;
const Double_t xmax = 2000.;
TCanvas *cWork[noCanvas]; TCanvas *cWork[noCanvas];
for (Int_t i = 0; i < noCanvas; i++) { for (Int_t i = 0; i < noCanvas; i++) {
cName.Form("can%d", i); cName.Form("can%d", i);
......
//#include "TString.h"
void showHists47()
{
TString location = "../data/WPT_tests";
TString f0, f1;
f0.Form("%s/4.7nF_11okt_chargeCalib/TestTriggerMode_chargeCalib_3V_100ns_4.7nF_11oct_0000.root", location.Data());
f1.Form("%s/4.7nF_11okt_chargeCalib/TestTriggerMode_chargeCalib_3V_100ns_4.7nF_11oct_0001.root", location.Data());
TFile *fr0 = new TFile(f0.Data());
TFile *fr1 = new TFile(f1.Data());
// TH2D *hraw0 = (TH2D*)fr0->Get("cal1eAdcAllWoBaseline");
// TH2D *hraw1 = (TH2D*)fr1->Get("cal1eAdcAllWoBaseline");
TH2D *hraw0 = (TH2D*)fr0->Get("fhAdcAllWoBaselineNLcorr");
TH2D *hraw1 = (TH2D*)fr1->Get("fhAdcAllWoBaselineNLcorr");
if (!hraw0 || !hraw1) {
Error("showHists47.cxx", "At least one of histograms was not found.");
return;
}
TCanvas *c1 = new TCanvas();
c1->Divide(2,2);
c1->cd(1);
hraw0->GetXaxis()->SetRangeUser(0, 64);
hraw0->Draw();
c1->cd(2);
hraw1->GetXaxis()->SetRangeUser(0, 64);
hraw1->Draw();
c1->cd(3);
TH2D *hSum = new TH2D(*hraw1);
hSum->Add(hraw0);;
hSum->Draw();
}
0 250.224
1 234.803
2 212.7
3 228.989
4 207.828
5 224.488
6 242.961
7 244.58
8 241.896
9 206.945
10 193.228
11 191.32
12 188.937
13 201.941
14 200.874
15 227.183
16 236.455
17 179.004
18 171.202
19 172.143
20 177.724
21 177.79
22 191.61
23 221.702
24 249.257
25 167.18
26 163.221
27 174.419
28 171.764
29 170.55
30 171.808
31 235.391
32 243.463
33 172.731
34 169.331
35 177.392
36 169.903
37 168.754
38 163.863
39 237.992
40 237.303
41 190.115
42 179.871
43 184.84
44 174.743
45 187.286
46 187.371
47 250.739
48 236.477
49 202.113
50 193.959
51 197.986
52 183.895
53 196.057
54 205.173
55 270.846
56 247.799
57 245.399
58 228.826
59 242.476
60 218.873
61 237.101
62 254.529
63 303.237
0 168.213
1 167.066
2 145.451
3 157.991
4 141.739
5 158.667
6 168.177
7 168.755
8 162.544
9 141.519
10 130.707
11 131.491
12 128.49
13 142.168
14 137.331
15 157.019
16 163.181
17 121.835
18 115.362
19 117.457
20 117.81
21 119.746
22 132.532
23 155.034
24 172.359
25 112.462
26 110.662
27 119.862
28 118.738
29 116.875
30 118.622
31 162.08
32 166.008
33 116.133
34 114.867
35 121.561
36 114.808
37 115.922
38 114.838
39 166.183
40 163.388
41 130.816
42 123.951
43 127.703
44 120.02
45 130.232
46 128.395
47 176.005
48 162.068
49 138.907
50 135.335
51 140.091
52 127.922
53 137.763
54 143.362
55 192.877
56 172.495
57 170.495
58 161.366
59 172.769
60 149.291
61 165.546
62 177.779
63 208.267
0 185 370
1 170 370
2 150 370
3 170 370
4 145 370
5 135 370
6 175 370
7 180 370
8 180 370
9 125 330
10 125 310
11 135 300
12 135 330
13 130 330
14 130 325
15 175 400
16 180 400
17 115 300
18 110 300
19 110 300
20 115 300
21 115 300
22 130 310
23 150 330
24 190 400
25 105 270
26 105 280
27 120 300
28 110 300
29 110 300
30 110 300
31 160 400
32 175 400
33 115 280
34 105 300
35 110 300
36 110 300
37 115 300
38 110 300
39 160 350
40 160 340
41 120 310
42 120 300
43 120 300
44 120 310
45 120 350
46 120 310
47 180 400
48 160 360
49 140 330
50 140 320
51 130 350
52 130 350
53 140 350
54 140 340
55 200 400
56 190 400
57 180 400
58 150 350
59 170 360
60 170 330
61 170 350
62 175 400
63 220 450
0 110 250
1 120 250
2 100 250
3 100 250
4 100 250
5 110 250
6 120 250
7 120 250
8 110 250
9 80 250
10 85 230
11 90 230
12 80 220
13 90 250
14 90 230
15 110 230
16 110 250
17 70 210
18 75 200
19 75 200
20 75 200
21 80 200
22 80 200
23 100 250
24 120 250
25 65 200
26 60 200
27 80 200
28 80 200
29 80 200
30 80 200
31 110 250
32 110 250
33 75 200
34 70 200
35 80 200
36 70 200
37 75 200
38 80 180
39 110 250
40 110 250
41 80 200
42 80 200
43 80 200
44 80 200
45 80 210
46 80 210
47 120 270
48 110 260
49 90 230
50 85 230
51 80 220
52 80 220
53 80 240
54 85 240
55 140 280
56 120 260
57 120 260
58 120 260
59 120 260
60 100 240
61 120 240
62 120 260
63 140 300