diff --git a/Software/AttenuationScan/AttenuationScan.C b/Software/AttenuationScan/AttenuationScan.C index 192b04d..b5e4c5c 100644 --- a/Software/AttenuationScan/AttenuationScan.C +++ b/Software/AttenuationScan/AttenuationScan.C @@ -10,7 +10,9 @@ The attenuation scan data taking is identified by the following information: - , that is, the type of sensor (Hans410, ...); -- , that is, the filename excluding the attenuation value and the run type. +- , that is, the filename excluding the attenuation value and the run type; +- , that is, the lower attenuation value; +- , that is, the higher attenuation value. */ #include "../Tools/Lib.C" @@ -21,7 +23,7 @@ #include "../Tools/FindStrip.C" #include "../Tools/Par.C" -void AttenuationScan(char *sensor, char *filename, char *externalPath = 0); +void AttenuationScan(char *sensor, char *filename, const Float_t mindB, const Float_t maxdB, char *externalPath = 0); int main(int argc, char *argv[]) { @@ -32,23 +34,33 @@ { cout << "**************************************************" << endl; - cout << "Some comments." << endl; + cout << "AttenuationScan reads all the ROOT files of a given attenuation scan data taking, call FindStrip to find the Beetle channel corresponding to the strip hit by the laser, and creates a ROOT file with the following information:" << endl; + cout << "- a graph with the mean ADC count on the strip hit by the laser as a function of the attenuation;" << endl; + cout << "- a graph with the mean of the sum of the ADC counts of four adjacent strips around that hit by the laser as a function of the attenuation." << endl; + + cout << "The attenuation scan data taking is identified by the following information:" << endl; + cout << "- , that is, the type of sensor (Hans410, ...);" << endl; + cout << "- , that is, the filename excluding the attenuation value and the run type;" << endl; + cout << "- , that is, the lower attenuation value;" << endl; + cout << "- , that is, the higher attenuation value." << endl; cout << "**************************************************" << endl; return 0; } - else if (argc < 3) + else if (argc < 5) { cout << "**************************************************" << endl; - cout << "Error! Type of sensor or filename missing..." << endl; + cout << "Error! Parameters missing..." << endl; cout << "Please use the following format:" << endl; - cout << "./AttenuationScan [1] [2] [3]" << endl; + cout << "./AttenuationScan [1] [2] [3] [4] [5]" << endl; cout << "with:" << endl; cout << "[1] = Type of sensor (Hans410, ...);" << endl; cout << "[2] = Filename, excluding the attenuation value and the run type;" << endl; - cout << "[3] = Additional folder, optional." << endl; + cout << "[3] = Lower attenuation value;" << endl; + cout << "[4] = Higher attenuation value;" << endl; + cout << "[5] = Additional folder, optional." << endl; cout << "Type ./AttenuationScan --info for more information." << endl; cout << "**************************************************" << endl; @@ -59,10 +71,12 @@ { cout << "Type of sensor: " << argv[1] << endl; cout << "Filename: " << argv[2] << endl; - if (argc == 3) - AttenuationScan(argv[1],argv[2]); - else if (argc == 4) - AttenuationScan(argv[1],argv[2],argv[3]); + cout << "Lower attenuation value:" << argv[3] << endl; + cout << "Higher attenuation value: " << argv[4] << endl; + if (argc == 5) + AttenuationScan(argv[1],argv[2],atof(argv[3]),atof(argv[4])); + else if (argc == 6) + AttenuationScan(argv[1],argv[2],atof(argv[3]),atof(argv[4]),argv[5]); else { cout << "Error! Too many arguments given..." << endl; @@ -74,13 +88,7 @@ } } -/* - If we execute AttenuationScan with ./AttenuationScan we are calling the following input and output files: - Input: /home/hep/flionett/TestStand/Data//AttenuationScan/RootFiles/-dB-las.root - Output: /home/hep/flionett/TestStand/AnalysisResults//AttenuationScan/AttenuationScan-.root -*/ - -void AttenuationScan(char *sensor, char *filename, char *externalPath) +void AttenuationScan(char *sensor, char *filename, const Float_t mindB, const Float_t maxdB, char *externalPath) { cout << "**************************************************" << endl; cout << "Performing attenuation scan..." << endl; @@ -113,8 +121,8 @@ int strip; string direction; - string inputFindStrip = inputDirectory+"/"+filename+"-15.5dB-las.root"; - string outputFindStrip = outputDirectory+"/FindStrip-"+filename+"-15.5dB-las.root"; + string inputFindStrip = inputDirectory+"/"+filename+(string)"-21.0dB-las.root"; + string outputFindStrip = outputDirectory+"/FindStrip-"+filename+"-21.0dB-las.root"; FindStrip(inputFindStrip,outputFindStrip,path_to_figures,&strip,&direction); @@ -122,8 +130,8 @@ string input_ROOT; string output_ROOT = outputDirectory+"/AttenuationScan-"+filename+".root"; - const Float_t mindB = 10.0; - const Float_t maxdB = 20.0; + // const Float_t mindB = 15.0; + // const Float_t maxdB = 21.0; const Float_t stepdB = 0.5; const Int_t steps = (Int_t)((maxdB-mindB)/stepdB+1); Float_t dB[steps]; @@ -182,14 +190,14 @@ TGraph *gattenuationScan = new TGraph(steps,dB,meanADC); InitGraph(gattenuationScan,"Attenuation scan - 1 strip","Attenuation (dB)","ADC counts"); TCanvas *cattenuationScan = new TCanvas(Form("cattenuationScan-%s",filename),"",400,300); - DrawGraph(cattenuationScan,gattenuationScan,"AB1",path_to_figures); + DrawGraph(cattenuationScan,gattenuationScan,"APC",path_to_figures); // DrawGraph(cattenuationScan,gattenuationScan,"APC",path_to_figures); // Four adjacent strips. TGraph *gattenuationScan4 = new TGraph(steps,dB,mean4ADC); InitGraph(gattenuationScan4,"Attenuation scan - 4 adjacent strips","Attenuation (dB)","ADC counts"); TCanvas *cattenuationScan4 = new TCanvas(Form("cattenuationScan4-%s",filename),"",400,300); - DrawGraph(cattenuationScan4,gattenuationScan4,"AB1",path_to_figures); + DrawGraph(cattenuationScan4,gattenuationScan4,"APC",path_to_figures); // DrawGraph(cattenuationScan4,gattenuationScan4,"APC",path_to_figures); // Write output ROOT file. diff --git a/Software/BiasVoltageScan/BiasVoltageScan b/Software/BiasVoltageScan/BiasVoltageScan new file mode 100755 index 0000000..7c82942 --- /dev/null +++ b/Software/BiasVoltageScan/BiasVoltageScan Binary files differ diff --git a/Software/BiasVoltageScan/BiasVoltageScan.C b/Software/BiasVoltageScan/BiasVoltageScan.C new file mode 100644 index 0000000..894138e --- /dev/null +++ b/Software/BiasVoltageScan/BiasVoltageScan.C @@ -0,0 +1,201 @@ +//************************************************ +// Author: Federica Lionetto +// Created on: 14/11/2014 +//************************************************ + +/* +BiasVoltageScan reads all the ROOT files of a given bias voltage scan data taking, call FindStrip to find the Beetle channel corresponding to the strip hit by the laser, and creates a ROOT file with the following information: +- a graph with the mean ADC count on the strip hit by the laser as a function of the bias voltage; +- a graph with the mean of the sum of the ADC counts of four adjacent strips around that hit by the laser as a function of the bias voltage. + +The bias voltage scan data taking is identified by the following information: +- , that is, the type of sensor (Hans410, ...); +- , that is, the filename excluding the bias voltage value and the run type. +*/ + +#include "../Tools/Lib.C" +#include "../Tools/lhcbStyle.C" +#include "../Tools/Style.C" +#include "../Tools/Useful.C" + +#include "../Tools/FindStrip.C" +#include "../Tools/Par.C" + +void BiasVoltageScan(char *sensor, char *filename, char *externalPath = 0); + +int main(int argc, char *argv[]) +{ + getLHCbStyle(); + PersonalStyle(); + + if ((argc == 2) && (string(argv[1]) == "--info")) + { + cout << "**************************************************" << endl; + + cout << "Some comments." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else if (argc < 3) + { + cout << "**************************************************" << endl; + + cout << "Error! Type of sensor or filename missing..." << endl; + cout << "Please use the following format:" << endl; + cout << "./BiasVoltageScan [1] [2] [3]" << endl; + cout << "with:" << endl; + cout << "[1] = Type of sensor (Hans410, ...);" << endl; + cout << "[2] = Filename, excluding the bias voltage value and the run type;" << endl; + cout << "[3] = Additional folder, optional." << endl; + cout << "Type ./BiasVoltageScan --info for more information." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else + { + cout << "Type of sensor: " << argv[1] << endl; + cout << "Filename: " << argv[2] << endl; + if (argc == 3) + BiasVoltageScan(argv[1],argv[2]); + else if (argc == 4) + BiasVoltageScan(argv[1],argv[2],argv[3]); + else + { + cout << "Error! Too many arguments given..." << endl; + + return 0; + } + + return 0; + } +} + +void BiasVoltageScan(char *sensor, char *filename, char *externalPath) +{ + cout << "**************************************************" << endl; + cout << "Performing bias voltage scan..." << endl; + cout << "**************************************************" << endl; + + // Do not comment this line. + gROOT->ProcessLine("#include "); + + // Do some fanciness to get the directory right. + string inputDirectory = "~/TestStand/AnalysisResults/"+string(sensor)+"/BiasVoltageScan"; + string outputDirectory = "~/TestStand/AnalysisResults/"+string(sensor)+"/BiasVoltageScan"; + if (externalPath!=0) + outputDirectory = string(outputDirectory+"/"+externalPath); + cout << "The input directory is: " << inputDirectory << endl; + cout << "The output directory is: " << outputDirectory << endl; + + // Create the outputDirectory directory if it does not exist. + string path_to_make = "mkdir -p "+outputDirectory; + system(path_to_make.c_str()); + + cout << "Figures stored in: " << outputDirectory+"/Figures/"+filename << endl; + + // Create a directory named Figures inside the directory named outputDirectory if it does not exist. + string path_to_make_figures = "mkdir -p "+outputDirectory+"/Figures/"+filename; + system(path_to_make_figures.c_str()); + + TString path_to_figures = (string(path_to_make_figures)).substr((string(path_to_make_figures)).find_last_of(' ')+1); + + // Execute findStrip. + int strip; + string direction; + + string inputFindStrip = inputDirectory+"/"+filename+"-150V-las.root"; + string outputFindStrip = outputDirectory+"/FindStrip-"+filename+"-150V-las.root"; + + FindStrip(inputFindStrip,outputFindStrip,path_to_figures,&strip,&direction); + + char char_input_ROOT[200]; + string input_ROOT; + string output_ROOT = outputDirectory+"/BiasVoltageScan-"+filename+".root"; + + const Float_t minV = 10.; + const Float_t maxV = 350.; + const Float_t stepV = 10.; + const Int_t steps = (Int_t)((maxV-minV)/stepV+1); + Float_t V[steps]; + Float_t meanADC[steps]; + Float_t mean4ADC[steps]; + + // Open output ROOT file. + TFile *output = TFile::Open(TString(output_ROOT),"RECREATE"); + + for (Int_t step=0;stepGet(Form("hADCPedSub%d",strip)); + meanADC[step] = hist->GetMean(); + + cout << "Histograms: " << endl; + cout << Form("hADCPedSub%d",strip) << endl; + cout << Form("hADCPedSub%d",strip+NSkip) << endl; + cout << Form("hADCPedSub%d",strip-NSkip) << endl; + cout << Form("hADCPedSub%d",strip-2*NSkip) << endl; + cout << Form("hADCPedSub%d",strip+2*NSkip) << endl; + + // Four adjacent strips. + TH1D *hist1 = (TH1D *)input->Get(Form("hADCPedSub%d",strip)); + TH1D *hist2 = (TH1D *)input->Get(Form("hADCPedSub%d",strip+NSkip)); + TH1D *hist3 = (TH1D *)input->Get(Form("hADCPedSub%d",strip-NSkip)); + TH1D *hist4; + if (direction == "left") + hist4 = (TH1D *)input->Get(Form("hADCPedSub%d",strip-2*NSkip)); + else if (direction == "right") + hist4 = (TH1D *)input->Get(Form("hADCPedSub%d",strip+2*NSkip)); + mean4ADC[step] = hist1->GetMean()+hist2->GetMean()+hist3->GetMean()+hist4->GetMean(); + + // Close input data ROOT files. + input->Close(); + } + + output->cd(); + + // Only one strip. + TGraph *gbiasVoltageScan = new TGraph(steps,V,meanADC); + InitGraph(gbiasVoltageScan,"Bias voltage scan - 1 strip","Bias voltage (V)","ADC counts"); + TCanvas *cbiasVoltageScan = new TCanvas(Form("cbiasVoltageScan-%s",filename),"",400,300); + DrawGraph(cbiasVoltageScan,gbiasVoltageScan,"APC",path_to_figures); + + // Four adjacent strips. + TGraph *gbiasVoltageScan4 = new TGraph(steps,V,mean4ADC); + InitGraph(gbiasVoltageScan4,"Bias voltage scan - 4 adjacent strips","Bias voltage (V)","ADC counts"); + TCanvas *cbiasVoltageScan4 = new TCanvas(Form("cbiasVoltageScan4-%s",filename),"",400,300); + DrawGraph(cbiasVoltageScan4,gbiasVoltageScan4,"APC",path_to_figures); + + // Write output ROOT file. + output->Write(); + + // Close output ROOT file. + output->Close(); + + return; +} diff --git a/Software/BiasVoltageScan/BiasVoltageScan.C~ b/Software/BiasVoltageScan/BiasVoltageScan.C~ new file mode 100644 index 0000000..723474a --- /dev/null +++ b/Software/BiasVoltageScan/BiasVoltageScan.C~ @@ -0,0 +1,194 @@ +//************************************************ +// Author: Federica Lionetto +// Created on: 14/11/2014 +//************************************************ + +/* +BiasVoltageScan reads all the ROOT files of a given bias voltage scan data taking, call FindStrip to find the Beetle channel corresponding to the strip hit by the laser, and creates a ROOT file with the following information: +- a graph with the mean ADC count on the strip hit by the laser as a function of the bias voltage; +- a graph with the mean of the sum of the ADC counts of four adjacent strips around that hit by the laser as a function of the bias voltage. + +The bias voltage scan data taking is identified by the following information: +- , that is, the type of sensor (Hans410, ...); +- , that is, the filename excluding the bias voltage value and the run type. +*/ + +#include "../Tools/Lib.C" +#include "../Tools/lhcbStyle.C" +#include "../Tools/Style.C" +#include "../Tools/Useful.C" + +#include "../Tools/FindStrip.C" +#include "../Tools/Par.C" + +void BiasVoltageScan(char *sensor, char *filename, char *externalPath = 0); + +int main(int argc, char *argv[]) +{ + getLHCbStyle(); + PersonalStyle(); + + if ((argc == 2) && (string(argv[1]) == "--info")) + { + cout << "**************************************************" << endl; + + cout << "Some comments." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else if (argc < 3) + { + cout << "**************************************************" << endl; + + cout << "Error! Type of sensor or filename missing..." << endl; + cout << "Please use the following format:" << endl; + cout << "./BiasVoltageScan [1] [2] [3]" << endl; + cout << "with:" << endl; + cout << "[1] = Type of sensor (Hans410, ...);" << endl; + cout << "[2] = Filename, excluding the bias voltage value and the run type;" << endl; + cout << "[3] = Additional folder, optional." << endl; + cout << "Type ./BiasVoltageScan --info for more information." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else + { + cout << "Type of sensor: " << argv[1] << endl; + cout << "Filename: " << argv[2] << endl; + if (argc == 3) + BiasVoltageScan(argv[1],argv[2]); + else if (argc == 4) + BiasVoltageScan(argv[1],argv[2],argv[3]); + else + { + cout << "Error! Too many arguments given..." << endl; + + return 0; + } + + return 0; + } +} + +void BiasVoltageScan(char *sensor, char *filename, char *externalPath) +{ + cout << "**************************************************" << endl; + cout << "Performing bias voltage scan..." << endl; + cout << "**************************************************" << endl; + + // Do not comment this line. + gROOT->ProcessLine("#include "); + + // Do some fanciness to get the directory right. + string inputDirectory = "~/TestStand/AnalysisResults/"+string(sensor)+"/BiasVoltageScan"; + string outputDirectory = "~/TestStand/AnalysisResults/"+string(sensor)+"/BiasVoltageScan"; + if (externalPath!=0) + outputDirectory = string(outputDirectory+"/"+externalPath); + cout << "The input directory is: " << inputDirectory << endl; + cout << "The output directory is: " << outputDirectory << endl; + + // Create the outputDirectory directory if it does not exist. + string path_to_make = "mkdir -p "+outputDirectory; + system(path_to_make.c_str()); + + cout << "Figures stored in: " << outputDirectory+"/Figures/"+filename << endl; + + // Create a directory named Figures inside the directory named outputDirectory if it does not exist. + string path_to_make_figures = "mkdir -p "+outputDirectory+"/Figures/"+filename; + system(path_to_make_figures.c_str()); + + TString path_to_figures = (string(path_to_make_figures)).substr((string(path_to_make_figures)).find_last_of(' ')+1); + + // Execute findStrip. + int strip; + string direction; + + string inputFindStrip = inputDirectory+"/"+filename+"-150V-las.root"; + string outputFindStrip = outputDirectory+"/FindStrip-"+filename+"-150V-las.root"; + + FindStrip(inputFindStrip,outputFindStrip,path_to_figures,&strip,&direction); + + char char_input_ROOT[200]; + string input_ROOT; + string output_ROOT = outputDirectory+"/BiasVoltageScan-"+filename+".root"; + + const Float_t minV = 10.; + const Float_t maxV = 350.; + const Float_t stepV = 10.; + const Int_t steps = (Int_t)((maxV-minV)/stepV+1); + Float_t V[steps]; + Float_t meanADC[steps]; + Float_t mean4ADC[steps]; + + // Open output ROOT file. + TFile *output = TFile::Open(TString(output_ROOT),"RECREATE"); + + for (Int_t step=0;stepGet(Form("hADCPedSub%d",strip)); + meanADC[step] = hist->GetMean(); + + // Four adjacent strips. + TH1D *hist1 = (TH1D *)input->Get(Form("hADCPedSub%d",strip)); + TH1D *hist2 = (TH1D *)input->Get(Form("hADCPedSub%d",strip+NSkip)); + TH1D *hist3 = (TH1D *)input->Get(Form("hADCPedSub%d",strip-NSkip)); + TH1D *hist4; + if (direction == "left") + hist4 = (TH1D *)input->Get(Form("hADCPedSub%d",strip-2*NSkip)); + else if (direction == "right") + hist4 = (TH1D *)input->Get(Form("hADCPedSub%d",strip+2*NSkip)); + mean4ADC[step] = hist1->GetMean()+hist2->GetMean()+hist3->GetMean()+hist4->GetMean(); + + // Close input data ROOT files. + input->Close(); + } + + output->cd(); + + // Only one strip. + TGraph *gbiasVoltageScan = new TGraph(steps,V,meanADC); + InitGraph(gbiasVoltageScan,"Bias voltage scan - 1 strip","Bias voltage (V)","ADC counts"); + TCanvas *cbiasVoltageScan = new TCanvas(Form("cbiasVoltageScan-%s",filename),"",400,300); + DrawGraph(cbiasVoltageScan,gbiasVoltageScan,"APC",path_to_figures); + + // Four adjacent strips. + TGraph *gbiasVoltageScan4 = new TGraph(steps,V,mean4ADC); + InitGraph(gbiasVoltageScan4,"Bias voltage scan - 4 adjacent strips","Bias voltage (V)","ADC counts"); + TCanvas *cbiasVoltageScan4 = new TCanvas(Form("cbiasVoltageScan4-%s",filename),"",400,300); + DrawGraph(cbiasVoltageScan4,gbiasVoltageScan4,"APC",path_to_figures); + + // Write output ROOT file. + output->Write(); + + // Close output ROOT file. + output->Close(); + + return; +} diff --git a/Software/BiasVoltageScan/Makefile b/Software/BiasVoltageScan/Makefile new file mode 100755 index 0000000..0792467 --- /dev/null +++ b/Software/BiasVoltageScan/Makefile @@ -0,0 +1,33 @@ +# +CC=$(CXX) +glib_cflags=$(shell pkg-config --cflags glib-2.0 gio-2.0) +glib_libs=$(shell pkg-config --libs glib-2.0 gio-2.0) + +ROOTC=$(shell root-config --cflags) +ROOTL=$(shell root-config --libs) +OPT=-g -fno-inline #-std=c++11 +CppFLAGS=$(OPT) -I. $(glib_cflags) +CXXFLAGS=-fPIC $(CppFLAGS) + +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + SO=so + SO_FLAGS=-shared + CXXFLAGS += -D LINUX +endif +ifeq ($(UNAME_S),Darwin) + SO=dylib + SO_FLAGS=-dynamiclib -undefined dynamic_lookup -install_name @rpath/$@ + CXXFLAGS += -D OSX +endif + +all: BiasVoltageScan + +BiasVoltageScan: BiasVoltageScan.C + c++ -I$(OPT) $(CXXFLAGS) $(ROOTC) -o $@ $^ $(LDLIBS) $(ROOTL) $(gliblibs) + + +clean: + rm -f *.o BiasVoltageScan + rm -rf *.dSYM + diff --git a/Software/CheckBaselineShift/CheckBaselineShift b/Software/CheckBaselineShift/CheckBaselineShift new file mode 100755 index 0000000..ef9943a --- /dev/null +++ b/Software/CheckBaselineShift/CheckBaselineShift Binary files differ diff --git a/Software/CheckBaselineShift/CheckBaselineShift.C b/Software/CheckBaselineShift/CheckBaselineShift.C new file mode 100644 index 0000000..d7ffa0a --- /dev/null +++ b/Software/CheckBaselineShift/CheckBaselineShift.C @@ -0,0 +1,278 @@ +//************************************************ +// Author: Federica Lionetto +// Created on: 11/11/2014 +//********************************************** + +/* +CheckBaselineShift checks the baseline shift between data acquisitions in pedestal run mode and data acquisitions in laser run mode. +It shows the distribution of the observables dPed=ped(ped run 2)-ped(ped run 1), dMix=ped(las run 2)-ped(ped run 1), and dLas=ped(las run 2)-ped(las run 1) (TH1F *hdPedBeetle, TH1F *hdMixBeetle, and TH1F *hdLasBeetle, respectively) and the 2D distribution of the observables ped(ped run 2) and ped(las run 2) (TH2F *h2pedLasBeetle), where ={1,2}. +It shows the same distributions as above, but for Beetle channels connected to silicon and Beetle channels not connected to silicon, instead of Beetle 1 and Beetle 2 (TH1F *hdPedConn, TH1F *hdMixConn, TH1F *hdLasConn, TH2F *h2pedLasConn, TH1F *hdPedNotConn, TH1F *hdMixNotConn, TH1F *hdLasNotConn, and TH2F *h2pedLasNotConn). +It shows the dMix as a function of the Beetle channel (TH1F *hdMixvsstrip). + +Compile with: + +make + +Run with: + +./CheckBaselineShift [additional folder] + +where: +- [additional folder] is the optional additional folder where the output will be saved. +*/ + +#include "../Tools/Lib.C" +#include "../Tools/lhcbStyle.C" +#include "../Tools/Style.C" +#include "../Tools/Useful.C" + +#include "../Tools/Par.C" + +void CheckBaselineShift(char *externalPath=0); + +int main(int argc, char *argv[]) +{ + getLHCbStyle(); + PersonalStyle(); + + if ((argc ==2) && (string(argv[1]) == "--info")) + { + cout << "**************************************************" << endl; + + cout << "Some comments." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else if (argc==1) + { + CheckBaselineShift(); + + return 0; + } + else if (argc==2) + { + CheckBaselineShift(argv[1]); + + return 0; + } + else + { + cout << "Error! Too many arguments given..." << endl; + + return 0; + } +} + +void CheckBaselineShift(char *externalPath) +{ + cout << "**************************************************" << endl; + cout << "Checking baseline shift between pedestal run mode and laser run mode..." << endl; + cout << "**************************************************" << endl; + + // Do some fanciness to get the directory right. + string analysis = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift"; + if (externalPath!=0) + analysis = string(analysis+"/"+externalPath); + string figures = analysis+"/Figures"; + + // Create the folder. Do not worry, nothing bad is going to happen if the folder already exists. + string path_to_make = "mkdir -p "+analysis; + system(path_to_make.c_str()); + cout << "Setting output to: " << path_to_make << endl; + + // Create a folder named Figures inside the folder named . + string path_to_make_figures = "mkdir "+figures; + system(path_to_make_figures.c_str()); + cout << "Setting figures to: " << path_to_make_figures << endl; + + TString path_to_figures = (string(path_to_make_figures)).substr((string(path_to_make_figures)).find_last_of(' ')+1); + + cout << path_to_figures << endl; + + // Input pedestal text files. + /* + string inputPed1Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift/ComputePedestals-20141110-ped.dat"; + string inputPed2Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift/ComputePedestals-20141110-2-ped.dat"; + string inputLas1Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift/ComputePedestals-20141112-laserOffSensor-las.dat"; + string inputLas2Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift/ComputePedestals-20141112-2-laserOffSensor-las.dat"; + */ + + string inputPed1Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift/ComputePedestals-20141113-ped.dat"; + string inputPed2Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift/ComputePedestals-20141113-2-ped.dat"; + string inputLas1Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift/ComputePedestals-20141113-laserOffSensor-las.dat"; + string inputLas2Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift/ComputePedestals-20141113-2-laserOffSensor-las.dat"; + + cout << "First pedestal run: " << inputPed1Filename << endl; + cout << "Second pedestal run: " << inputPed2Filename << endl; + + cout << "First laser run: " << inputLas1Filename << endl; + cout << "Second laser run: " << inputLas2Filename << endl; + + // Open input pedestal text files. + FILE *inputPed1 = fopen(TString(inputPed1Filename),"r"); + FILE *inputPed2 = fopen(TString(inputPed2Filename),"r"); + FILE *inputLas1 = fopen(TString(inputLas1Filename),"r"); + FILE *inputLas2 = fopen(TString(inputLas2Filename),"r"); + + // Read pedestals. + float ped1[N]; + float ped2[N]; + float las1[N]; + float las2[N]; + + for (int iChannel=0; iChannelFill(ped2[iChannel]-ped1[iChannel]); + hdMixBeetle1->Fill(las2[iChannel]-ped1[iChannel]); + hdLasBeetle1->Fill(las2[iChannel]-las1[iChannel]); + h2pedLasBeetle1->Fill(ped2[iChannel],las2[iChannel]); + } + + DrawHistCompare3(cdBeetle1,hdPedBeetle1,hdMixBeetle1,hdLasBeetle1,legd,path_to_figures); + DrawHist2(cpedLasBeetle1,h2pedLasBeetle1,"colz",path_to_figures); + + + + // Beetle 2. + + TH1F *hdPedBeetle2 = new TH1F("hdPedBeetle2","",60,-30,30); + TH1F *hdMixBeetle2 = new TH1F("hdMixBeetle2","",60,-30,30); + TH1F *hdLasBeetle2 = new TH1F("hdLasBeetle2","",60,-30,30); + TH2F *h2pedLasBeetle2 = new TH2F("h2pedLasBeetle2","",150,450,600,150,450,600); + + InitHist(hdPedBeetle2, "Shift in pedestals - Beetle 2","ADC counts",""); + InitHist(hdMixBeetle2,"Shift in pedestals - Beetle 2","ADC counts",""); + InitHist(hdLasBeetle2,"Shift in pedestals - Beetle 2","ADC counts",""); + InitHist2(h2pedLasBeetle2,"Pedestals - Beetle 2","pedestal run (ADC counts)","laser run (ADC counts)",""); + + TCanvas *cdBeetle2 = new TCanvas("cdBeetle2","",400,300); + TCanvas *cpedLasBeetle2 = new TCanvas("cpedLasBeetle2","",400,300); + + for (int iChannel=NBeetle;iChannelFill(ped2[iChannel]-ped1[iChannel]); + hdMixBeetle2->Fill(las2[iChannel]-ped1[iChannel]); + hdLasBeetle2->Fill(las2[iChannel]-las1[iChannel]); + h2pedLasBeetle2->Fill(ped2[iChannel],las2[iChannel]); + } + + DrawHistCompare3(cdBeetle2,hdPedBeetle2,hdMixBeetle2,hdLasBeetle2,legd,path_to_figures); + DrawHist2(cpedLasBeetle2,h2pedLasBeetle2,"colz",path_to_figures); + + + + // Strips connected to the silicon. + + TH1F *hdPedConn = new TH1F("hdPedConn","",60,-30,30); + TH1F *hdMixConn = new TH1F("hdMixConn","",60,-30,30); + TH1F *hdLasConn = new TH1F("hdLasConn","",60,-30,30); + TH2F *h2pedLasConn = new TH2F("h2pedLasConn","",150,450,600,150,450,600); + + InitHist(hdPedConn,"Shift in pedestals - connected to Si","ADC counts",""); + InitHist(hdMixConn,"Shift in pedestals - connected to Si","ADC counts",""); + InitHist(hdLasConn,"Shift in pedestals - connected to Si","ADC counts",""); + InitHist2(h2pedLasConn,"Pedestals - connected to Si","pedestal run (ADC counts)","laser run (ADC counts)",""); + + TCanvas *cdConn = new TCanvas("cdConn","",400,300); + TCanvas *cpedLasConn = new TCanvas("cpedLasConn","",400,300); + + for (int iChannel=0;iChannelFill(ped2[iChannel]-ped1[iChannel]); + hdMixConn->Fill(las2[iChannel]-ped1[iChannel]); + hdLasConn->Fill(las2[iChannel]-las1[iChannel]); + h2pedLasConn->Fill(ped2[iChannel],las2[iChannel]); + } + } + + DrawHistCompare3(cdConn,hdPedConn,hdMixConn,hdLasConn,legd,path_to_figures); + DrawHist2(cpedLasConn,h2pedLasConn,"colz",path_to_figures); + + + + // Strips not connected to the silicon. + + TH1F *hdPedNotConn = new TH1F("hdPedNotConn","",60,-30,30); + TH1F *hdMixNotConn = new TH1F("hdMixNotConn","",60,-30,30); + TH1F *hdLasNotConn = new TH1F("hdLasNotConn","",60,-30,30); + TH2F *h2pedLasNotConn = new TH2F("h2pedLasNotConn","",150,450,600,150,450,600); + + InitHist(hdPedNotConn,"Shift in pedestals - not connected to Si","ADC counts",""); + InitHist(hdMixNotConn,"Shift in pedestals - not connected to Si","ADC counts",""); + InitHist(hdLasNotConn,"Shift in pedestals - not connected to Si","ADC counts",""); + InitHist2(h2pedLasNotConn,"Pedestals - not connected to Si","pedestal run (ADC counts)","laser run (ADC counts)",""); + + TCanvas *cdNotConn = new TCanvas("cdNotConn","",400,300); + TCanvas *cpedLasNotConn = new TCanvas("cpedLasNotConn","",400,300); + + for (int iChannel=0;iChannelFill(ped2[iChannel]-ped1[iChannel]); + hdMixNotConn->Fill(las2[iChannel]-ped1[iChannel]); + hdLasNotConn->Fill(las2[iChannel]-las1[iChannel]); + h2pedLasNotConn->Fill(ped2[iChannel],las2[iChannel]); + } + } + + DrawHistCompare3(cdNotConn,hdPedNotConn,hdMixNotConn,hdLasNotConn,legd,path_to_figures); + DrawHist2(cpedLasNotConn,h2pedLasNotConn,"colz",path_to_figures); + + + + // dMix as a function of the Beetle channel (TH1F *hdMixvsstrip). + float strip[N]; + for (int iChannel=0;iChannelFill(iChannel,las2[iChannel]-ped2[iChannel]); + } + hdMixvsstrip->SetMinimum(-30); + hdMixvsstrip->SetMaximum(30); + TCanvas *cdMixvsstrip = new TCanvas("cdMixvsstrip","",400,300); + DrawHist(cdMixvsstrip,hdMixvsstrip,"",path_to_figures); + + // Write output ROOT file. + output->Write(); + + // Close output ROOT files. + output->Close(); + + return; +} diff --git a/Software/CheckBaselineShift/CheckBaselineShift.C~ b/Software/CheckBaselineShift/CheckBaselineShift.C~ new file mode 100644 index 0000000..2c56d2c --- /dev/null +++ b/Software/CheckBaselineShift/CheckBaselineShift.C~ @@ -0,0 +1,276 @@ +//************************************************ +// Author: Federica Lionetto +// Created on: 11/11/2014 +//********************************************** + +/* +CheckBaselineShift checks the baseline shift between data acquisitions in pedestal run mode and data acquisitions in laser run mode. +It shows the distribution of the observables dPed=ped(ped run 2)-ped(ped run 1), dMix=ped(las run 2)-ped(ped run 1), and dLas=ped(las run 2)-ped(las run 1) (TH1F *hdPedBeetle, TH1F *hdMixBeetle, and TH1F *hdLasBeetle, respectively) and the 2D distribution of the observables ped(ped run 2) and ped(las run 2) (TH2F *h2pedLasBeetle), where ={1,2}. +It shows the same distributions as above, but for Beetle channels connected to silicon and Beetle channels not connected to silicon, instead of Beetle 1 and Beetle 2 (TH1F *hdPedConn, TH1F *hdMixConn, TH1F *hdLasConn, TH2F *h2pedLasConn, TH1F *hdPedNotConn, TH1F *hdMixNotConn, TH1F *hdLasNotConn, and TH2F *h2pedLasNotConn). +It shows the dMix as a function of the Beetle channel (TH1F *hdMixvsstrip). + +Compile with: + +make + +Run with: + +./CheckBaselineShift [additional folder] + +where: +- [additional folder] is the optional additional folder where the output will be saved. +*/ + +#include "../Tools/Lib.C" +#include "../Tools/lhcbStyle.C" +#include "../Tools/Style.C" +#include "../Tools/Useful.C" + +#include "../Tools/Par.C" + +void CheckBaselineShift(char *externalPath=0); + +int main(int argc, char *argv[]) +{ + getLHCbStyle(); + PersonalStyle(); + + if ((argc ==2) && (string(argv[1]) == "--info")) + { + cout << "**************************************************" << endl; + + cout << "Some comments." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else if (argc==1) + { + CheckBaselineShift(); + + return 0; + } + else if (argc==2) + { + CheckBaselineShift(argv[1]); + + return 0; + } + else + { + cout << "Error! Too many arguments given..." << endl; + + return 0; + } +} + +void CheckBaselineShift(char *externalPath) +{ + cout << "**************************************************" << endl; + cout << "Checking baseline shift between pedestal run mode and laser run mode..." << endl; + cout << "**************************************************" << endl; + + // Do some fanciness to get the directory right. + string analysis = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/CheckBaselineShift"; + if (externalPath!=0) + analysis = string(analysis+"/"+externalPath); + string figures = analysis+"/Figures"; + + // Create the folder. Do not worry, nothing bad is going to happen if the folder already exists. + string path_to_make = "mkdir -p "+analysis; + system(path_to_make.c_str()); + cout << "Setting output to: " << path_to_make << endl; + + // Create a folder named Figures inside the folder named . + string path_to_make_figures = "mkdir "+figures; + system(path_to_make_figures.c_str()); + cout << "Setting figures to: " << path_to_make_figures << endl; + + TString path_to_figures = (string(path_to_make_figures)).substr((string(path_to_make_figures)).find_last_of(' ')+1); + + cout << path_to_figures << endl; + + // Input pedestal text files. + // string inputPed1Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/AttenuationScan/ComputePedestals-20141110-ped.dat"; + // string inputPed2Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/AttenuationScan/ComputePedestals-20141110-2-ped.dat"; + // string inputLas1Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/AttenuationScan/ComputePedestals-20141112-laserOffSensor-las.dat"; + // string inputLas2Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/AttenuationScan/ComputePedestals-20141112-2-laserOffSensor-las.dat"; + + string inputPed1Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/AttenuationScan/ComputePedestals-20141113-ped.dat"; + string inputPed2Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/AttenuationScan/ComputePedestals-20141113-2-ped.dat"; + string inputLas1Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/AttenuationScan/ComputePedestals-20141113-laserOffSensor-las.dat"; + string inputLas2Filename = "/home/hep/flionett/TestStand/AnalysisResults/Hans410/AttenuationScan/ComputePedestals-20141113-2-laserOffSensor-las.dat"; + + cout << "First pedestal run: " << inputPed1Filename << endl; + cout << "Second pedestal run: " << inputPed2Filename << endl; + + cout << "First laser run: " << inputLas1Filename << endl; + cout << "Second laser run: " << inputLas2Filename << endl; + + // Open input pedestal text files. + FILE *inputPed1 = fopen(TString(inputPed1Filename),"r"); + FILE *inputPed2 = fopen(TString(inputPed2Filename),"r"); + FILE *inputLas1 = fopen(TString(inputLas1Filename),"r"); + FILE *inputLas2 = fopen(TString(inputLas2Filename),"r"); + + // Read pedestals. + float ped1[N]; + float ped2[N]; + float las1[N]; + float las2[N]; + + for (int iChannel=0; iChannelFill(ped2[iChannel]-ped1[iChannel]); + hdMixBeetle1->Fill(las2[iChannel]-ped1[iChannel]); + hdLasBeetle1->Fill(las2[iChannel]-las1[iChannel]); + h2pedLasBeetle1->Fill(ped2[iChannel],las2[iChannel]); + } + + DrawHistCompare3(cdBeetle1,hdPedBeetle1,hdMixBeetle1,hdLasBeetle1,legd,path_to_figures); + DrawHist2(cpedLasBeetle1,h2pedLasBeetle1,"colz",path_to_figures); + + + + // Beetle 2. + + TH1F *hdPedBeetle2 = new TH1F("hdPedBeetle2","",60,-30,30); + TH1F *hdMixBeetle2 = new TH1F("hdMixBeetle2","",60,-30,30); + TH1F *hdLasBeetle2 = new TH1F("hdLasBeetle2","",60,-30,30); + TH2F *h2pedLasBeetle2 = new TH2F("h2pedLasBeetle2","",150,450,600,150,450,600); + + InitHist(hdPedBeetle2, "Shift in pedestals - Beetle 2","ADC counts",""); + InitHist(hdMixBeetle2,"Shift in pedestals - Beetle 2","ADC counts",""); + InitHist(hdLasBeetle2,"Shift in pedestals - Beetle 2","ADC counts",""); + InitHist2(h2pedLasBeetle2,"Pedestals - Beetle 2","pedestal run (ADC counts)","laser run (ADC counts)",""); + + TCanvas *cdBeetle2 = new TCanvas("cdBeetle2","",400,300); + TCanvas *cpedLasBeetle2 = new TCanvas("cpedLasBeetle2","",400,300); + + for (int iChannel=NBeetle;iChannelFill(ped2[iChannel]-ped1[iChannel]); + hdMixBeetle2->Fill(las2[iChannel]-ped1[iChannel]); + hdLasBeetle2->Fill(las2[iChannel]-las1[iChannel]); + h2pedLasBeetle2->Fill(ped2[iChannel],las2[iChannel]); + } + + DrawHistCompare3(cdBeetle2,hdPedBeetle2,hdMixBeetle2,hdLasBeetle2,legd,path_to_figures); + DrawHist2(cpedLasBeetle2,h2pedLasBeetle2,"colz",path_to_figures); + + + + // Strips connected to the silicon. + + TH1F *hdPedConn = new TH1F("hdPedConn","",60,-30,30); + TH1F *hdMixConn = new TH1F("hdMixConn","",60,-30,30); + TH1F *hdLasConn = new TH1F("hdLasConn","",60,-30,30); + TH2F *h2pedLasConn = new TH2F("h2pedLasConn","",150,450,600,150,450,600); + + InitHist(hdPedConn,"Shift in pedestals - connected to Si","ADC counts",""); + InitHist(hdMixConn,"Shift in pedestals - connected to Si","ADC counts",""); + InitHist(hdLasConn,"Shift in pedestals - connected to Si","ADC counts",""); + InitHist2(h2pedLasConn,"Pedestals - connected to Si","pedestal run (ADC counts)","laser run (ADC counts)",""); + + TCanvas *cdConn = new TCanvas("cdConn","",400,300); + TCanvas *cpedLasConn = new TCanvas("cpedLasConn","",400,300); + + for (int iChannel=0;iChannelFill(ped2[iChannel]-ped1[iChannel]); + hdMixConn->Fill(las2[iChannel]-ped1[iChannel]); + hdLasConn->Fill(las2[iChannel]-las1[iChannel]); + h2pedLasConn->Fill(ped2[iChannel],las2[iChannel]); + } + } + + DrawHistCompare3(cdConn,hdPedConn,hdMixConn,hdLasConn,legd,path_to_figures); + DrawHist2(cpedLasConn,h2pedLasConn,"colz",path_to_figures); + + + + // Strips not connected to the silicon. + + TH1F *hdPedNotConn = new TH1F("hdPedNotConn","",60,-30,30); + TH1F *hdMixNotConn = new TH1F("hdMixNotConn","",60,-30,30); + TH1F *hdLasNotConn = new TH1F("hdLasNotConn","",60,-30,30); + TH2F *h2pedLasNotConn = new TH2F("h2pedLasNotConn","",150,450,600,150,450,600); + + InitHist(hdPedNotConn,"Shift in pedestals - not connected to Si","ADC counts",""); + InitHist(hdMixNotConn,"Shift in pedestals - not connected to Si","ADC counts",""); + InitHist(hdLasNotConn,"Shift in pedestals - not connected to Si","ADC counts",""); + InitHist2(h2pedLasNotConn,"Pedestals - not connected to Si","pedestal run (ADC counts)","laser run (ADC counts)",""); + + TCanvas *cdNotConn = new TCanvas("cdNotConn","",400,300); + TCanvas *cpedLasNotConn = new TCanvas("cpedLasNotConn","",400,300); + + for (int iChannel=0;iChannelFill(ped2[iChannel]-ped1[iChannel]); + hdMixNotConn->Fill(las2[iChannel]-ped1[iChannel]); + hdLasNotConn->Fill(las2[iChannel]-las1[iChannel]); + h2pedLasNotConn->Fill(ped2[iChannel],las2[iChannel]); + } + } + + DrawHistCompare3(cdNotConn,hdPedNotConn,hdMixNotConn,hdLasNotConn,legd,path_to_figures); + DrawHist2(cpedLasNotConn,h2pedLasNotConn,"colz",path_to_figures); + + + + // dMix as a function of the Beetle channel (TH1F *hdMixvsstrip). + float strip[N]; + for (int iChannel=0;iChannelFill(iChannel,las2[iChannel]-ped2[iChannel]); + } + hdMixvsstrip->SetMinimum(-30); + hdMixvsstrip->SetMaximum(30); + TCanvas *cdMixvsstrip = new TCanvas("cdMixvsstrip","",400,300); + DrawHist(cdMixvsstrip,hdMixvsstrip,"",path_to_figures); + + // Write output ROOT file. + output->Write(); + + // Close output ROOT files. + output->Close(); + + return; +} diff --git a/Software/CheckBaselineShift/Makefile b/Software/CheckBaselineShift/Makefile new file mode 100755 index 0000000..b47d5fe --- /dev/null +++ b/Software/CheckBaselineShift/Makefile @@ -0,0 +1,34 @@ +# +CC=$(CXX) +glib_cflags=$(shell pkg-config --cflags glib-2.0 gio-2.0) +glib_libs=$(shell pkg-config --libs glib-2.0 gio-2.0) + +ROOTC=$(shell root-config --cflags) +ROOTL=$(shell root-config --libs) +OPT=-g -fno-inline #-std=c++11 +CppFLAGS=$(OPT) -I. $(glib_cflags) +CXXFLAGS=-fPIC $(CppFLAGS) + + +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + SO=so + SO_FLAGS=-shared + CXXFLAGS += -D LINUX +endif +ifeq ($(UNAME_S),Darwin) + SO=dylib + SO_FLAGS=-dynamiclib -undefined dynamic_lookup -install_name @rpath/$@ + CXXFLAGS += -D OSX +endif + +all: CheckBaselineShift + +CheckBaselineShift: CheckBaselineShift.C + c++ -I$(OPT) $(CXXFLAGS) $(ROOTC) -o $@ $^ $(LDLIBS) $(ROOTL) $(gliblibs) + + +clean: + rm -f *.o CheckBaselineShift + rm -rf *.dSYM + diff --git a/Software/CheckBaselineShift/Makefile~ b/Software/CheckBaselineShift/Makefile~ new file mode 100755 index 0000000..685aba4 --- /dev/null +++ b/Software/CheckBaselineShift/Makefile~ @@ -0,0 +1,34 @@ +# +CC=$(CXX) +glib_cflags=$(shell pkg-config --cflags glib-2.0 gio-2.0) +glib_libs=$(shell pkg-config --libs glib-2.0 gio-2.0) + +ROOTC=$(shell root-config --cflags) +ROOTL=$(shell root-config --libs) +OPT=-g -fno-inline #-std=c++11 +CppFLAGS=$(OPT) -I. $(glib_cflags) +CXXFLAGS=-fPIC $(CppFLAGS) + + +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + SO=so + SO_FLAGS=-shared + CXXFLAGS += -D LINUX +endif +ifeq ($(UNAME_S),Darwin) + SO=dylib + SO_FLAGS=-dynamiclib -undefined dynamic_lookup -install_name @rpath/$@ + CXXFLAGS += -D OSX +endif + +all: ProcessRawData + +ProcessRawData: ProcessRawData.C + c++ -I$(OPT) $(CXXFLAGS) $(ROOTC) -o $@ $^ $(LDLIBS) $(ROOTL) $(gliblibs) + + +clean: + rm -f *.o ProcessRawData + rm -rf *.dSYM + diff --git a/Software/ComputePedestals/ComputePedestals.C b/Software/ComputePedestals/ComputePedestals.C index caf3d66..5da17e2 100644 --- a/Software/ComputePedestals/ComputePedestals.C +++ b/Software/ComputePedestals/ComputePedestals.C @@ -221,11 +221,11 @@ // Open output pedestal text file. FILE *output_text = fopen(analysis+"/ComputePedestals-"+TString(filename_as_string_no_path_no_extension)+".dat","w"); - TH1F *hADCBeetle1 = new TH1F("hADCBeetle1","",200,400,600); // Modify it. + TH1F *hADCBeetle1 = new TH1F("hADCBeetle1","",200,400,600); TCanvas *cADCBeetle1 = new TCanvas("cADCBeetle1","",400,300); InitHist(hADCBeetle1,"Raw ADC counts on Beetle 1","ADC counts",""); - TH1F *hADCBeetle2 = new TH1F("hADCBeetle2","",200,400,600); // Modify it. + TH1F *hADCBeetle2 = new TH1F("hADCBeetle2","",200,400,600); TCanvas *cADCBeetle2 = new TCanvas("cADCBeetle2","",400,300); InitHist(hADCBeetle2,"Raw ADC counts on Beetle 2","ADC counts",""); @@ -234,11 +234,11 @@ EventInfo->GetEntry(iEvent); for (int ch=0; chFill(ADC->at(ch)); + hADCBeetle1->Fill((float)ADC->at(ch)); } for (int ch=NBeetle; chFill(ADC->at(ch)); + hADCBeetle2->Fill((float)ADC->at(ch)); } } @@ -246,10 +246,10 @@ DrawHist(cADCBeetle2,hADCBeetle2,"",path_to_figures); // Remove potential outliers. Use the mean and the RMS of the hADCTemp histograms and exclude everything that is outside times the RMS. - double mean[N]; - double rms[N]; + float mean[N]; + float rms[N]; - double factor = 5.; // Entries further than factor*rms from the mean are excluded from the pedestal calculation. + float factor = 3.; // Entries further than factor*rms from the mean are excluded from the pedestal calculation. // Fill histograms, necessary to remove potential outliers. TH1F *hADCTemp[N]; @@ -260,15 +260,13 @@ // Fill histograms. for (int iEvent=0;iEventGetEntry(iEvent); - hADCTemp[ch]->Fill(ADC->at(ch)); + hADCTemp[ch]->Fill((float)ADC->at(ch)); if (ADC->at(ch) > 1024.) cout << "Error! ADC counts of Beetle channel " << ch << ": " << ADC->at(ch) << endl; } TF1 *fGaussian = new TF1("fGaussian","gaus",400,600); hADCTemp[ch]->Fit("fGaussian","R"); - // mean[ch] = hADCTemp[ch]->GetMean(); - // rms[ch] = hADCTemp[ch]->GetMean(); mean[ch] = fGaussian->GetParameter(1); rms[ch] = fGaussian->GetParameter(2); } @@ -278,8 +276,8 @@ // TPaveStats *sADC[N]; TCanvas *cADC[N]; - double pedestal[N]; - double noise[N]; + float pedestal[N]; + float noise[N]; for (int ch=0;chGetEntry(iEvent); - if (abs(ADC->at(ch)-mean[ch])Fill(ADC->at(ch)); + if ((abs((float)ADC->at(ch)-mean[ch]))<(factor*rms[ch])) + hADC[ch]->Fill((float)ADC->at(ch)); if (ADC->at(ch) > 1024.) cout << "Error! ADC counts of Beetle channel " << ch << ": " << ADC->at(ch) << endl; } @@ -306,9 +304,9 @@ } // Mean and RMS as a function of the strip number. - double strip[N]; + float strip[N]; for (int ch=0;chFill(ch,pedestal[ch]); - hnoisevsstrip->Fill(ch,noise[ch]); + hpedestalvsstrip->Fill((float)ch,pedestal[ch]); + hnoisevsstrip->Fill((float)ch,noise[ch]); } // Define range. - hpedestalvsstrip->SetMinimum(450.); - hpedestalvsstrip->SetMaximum(550.); + hpedestalvsstrip->SetMinimum(400.); + hpedestalvsstrip->SetMaximum(600.); hnoisevsstrip->SetMinimum(0.); - hnoisevsstrip->SetMaximum(70.); + hnoisevsstrip->SetMaximum(30.); TCanvas *cpedestalvsstrip = new TCanvas("cpedestalvsstrip","",400,300); TCanvas *cnoisevsstrip = new TCanvas("cnoisevsstrip","",400,300); @@ -341,10 +339,10 @@ // Distributions of mean and RMS. TH1F *hpedestalBeetle1 = new TH1F("hpedestalBeetle1","",100,400,600); - TH1F *hnoiseBeetle1 = new TH1F("hnoiseBeetle1","",40,5,15); + TH1F *hnoiseBeetle1 = new TH1F("hnoiseBeetle1","",30,0,30); TH1F *hpedestalBeetle2 = new TH1F("hpedestalBeetle2","",100,400,600); - TH1F *hnoiseBeetle2 = new TH1F("hnoiseBeetle2","",40,5,15); + TH1F *hnoiseBeetle2 = new TH1F("hnoiseBeetle2","",30,0,30); InitHist(hpedestalBeetle1,"Pedestals","ADC counts",""); InitHist(hnoiseBeetle1,"Noise","ADC counts",""); diff --git a/Software/LaserDelayScan/LaserDelayScan b/Software/LaserDelayScan/LaserDelayScan new file mode 100755 index 0000000..02bfaa5 --- /dev/null +++ b/Software/LaserDelayScan/LaserDelayScan Binary files differ diff --git a/Software/LaserDelayScan/LaserDelayScan.C b/Software/LaserDelayScan/LaserDelayScan.C new file mode 100644 index 0000000..ee020ef --- /dev/null +++ b/Software/LaserDelayScan/LaserDelayScan.C @@ -0,0 +1,103 @@ +//************************************************ +// Author: Federica Lionetto +// Created on: 19/11/2014 +//************************************************ + +/* +LaserDelayScan reads a text file (containing the laser delay in ns and the average ADC signal in ADC counts) and creates a ROOT file with the following information: +- average ADC signal as a function of the laser delay, fit with a Gaussian function. + +Compile with: + +make + +Run with: + +./LaserDelayScan [input text file] [additional folder] + +where + +- [input text file] is the complete path, including the folder and the filename, of the text file one wants to process; +- [additional folder] is the optional additional folder where the output will be saved. +*/ + +#include "../Tools/Lib.C" +#include "../Tools/lhcbStyle.C" +#include "../Tools/Style.C" +#include "../Tools/Useful.C" + +#include "../Tools/Par.C" + +void LaserDelayScan(char *filename, char *externalPath=0); + +int main(int argc, char *argv[]) +{ + getLHCbStyle(); + PersonalStyle(); + + if ((argc ==2) && (string(argv[1]) == "--info")) + { + cout << "**************************************************" << endl; + + cout << "Some comments." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else if (argc < 2) + { + cout << "**************************************************" << endl; + + cout << "Error! Input file missing..." << endl; + cout << "Please use the following format:" << endl; + cout << "./LaserDelayScan [1] [2]" << endl; + cout << "with:" << endl; + cout << "[1] = Input text file, complete path;" << endl; + cout << "[2] = Additional folder, optional." << endl; + cout << "Type ./LaserDelayScan --info for more information." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else + { + cout << "File to process: " << argv[1] << endl; + if (argc == 2) + LaserDelayScan(argv[1]); + else if (argc == 3) + LaserDelayScan(argv[1],argv[2]); + else + { + cout << "Error! Too many arguments given..." << endl; + + return 0; + } + + return 0; + } +} + +void LaserDelayScan(char *filename, char *externalPath) +{ + cout << "**************************************************" << endl; + cout << "Working on the laser delay scan..." << endl; + cout << "**************************************************" << endl; + + // Do not comment this line. + gROOT->ProcessLine("#include "); + + // Do some fanciness to get the directory right. + + + + + + + + + + + return; +} diff --git a/Software/LaserDelayScan/LaserDelayScan.C~ b/Software/LaserDelayScan/LaserDelayScan.C~ new file mode 100644 index 0000000..429bdcb --- /dev/null +++ b/Software/LaserDelayScan/LaserDelayScan.C~ @@ -0,0 +1,89 @@ +//************************************************ +// Author: Federica Lionetto +// Created on: 19/11/2014 +//************************************************ + +/* +LaserDelayScan reads a text file (containing the laser delay in ns and the average ADC signal in ADC counts) and creates a ROOT file with the following information: +- average ADC signal as a function of the laser delay, fit with a Gaussian function. + +Compile with: + +make + +Run with: + +./LaserDelayScan [input text file] [additional folder] + +where + +- [input text file] is the complete path, including the folder and the filename, of the text file one wants to process; +- [additional folder] is the optional additional folder where the output will be saved. +*/ + +#include "../Tools/Lib.C" +#include "../Tools/lhcbStyle.C" +#include "../Tools/Style.C" +#include "../Tools/Useful.C" + +#include "../Tools/Par.C" + +void LaserDelayScan(char *filename, char *externalPath=0); + +int main(int argc, char *argv[]) +{ + getLHCbStyle(); + PersonalStyle(); + + if ((argc ==2) && (string(argv[1]) == "--info")) + { + cout << "**************************************************" << endl; + + cout << "Some comments." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else if (argc < 2) + { + cout << "**************************************************" << endl; + + cout << "Error! Input file missing..." << endl; + cout << "Please use the following format:" << endl; + cout << "./LaserDelayScan [1] [2]" << endl; + cout << "with:" << endl; + cout << "[1] = Input text file, complete path;" << endl; + cout << "[2] = Additional folder, optional." << endl; + cout << "Type ./LaserDelayScan --info for more information." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else + { + cout << "File to process: " << argv[1] << endl; + if (argc == 2) + LaserDelayScan(argv[1]); + else if (argc == 3) + LaserDelayScan(argv[1],argv[2]); + else + { + cout << "Error! Too many arguments given..." << endl; + + return 0; + } + + return 0; + } +} + +void LaserDelayScan(char *filename, char *externalPath) +{ + cout << "**************************************************" << endl; + cout << "Working on the laser delay scan..." << endl; + cout << "**************************************************" << endl; + + return; +} diff --git a/Software/LaserDelayScan/Makefile b/Software/LaserDelayScan/Makefile new file mode 100755 index 0000000..0d01a36 --- /dev/null +++ b/Software/LaserDelayScan/Makefile @@ -0,0 +1,34 @@ +# +CC=$(CXX) +glib_cflags=$(shell pkg-config --cflags glib-2.0 gio-2.0) +glib_libs=$(shell pkg-config --libs glib-2.0 gio-2.0) + +ROOTC=$(shell root-config --cflags) +ROOTL=$(shell root-config --libs) +OPT=-g -fno-inline #-std=c++11 +CppFLAGS=$(OPT) -I. $(glib_cflags) +CXXFLAGS=-fPIC $(CppFLAGS) + + +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + SO=so + SO_FLAGS=-shared + CXXFLAGS += -D LINUX +endif +ifeq ($(UNAME_S),Darwin) + SO=dylib + SO_FLAGS=-dynamiclib -undefined dynamic_lookup -install_name @rpath/$@ + CXXFLAGS += -D OSX +endif + +all: LaserDelayScan + +LaserDelayScan: LaserDelayScan.C + c++ -I$(OPT) $(CXXFLAGS) $(ROOTC) -o $@ $^ $(LDLIBS) $(ROOTL) $(gliblibs) + + +clean: + rm -f *.o LaserDelayScan + rm -rf *.dSYM + diff --git a/Software/LaserDelayScan/Makefile~ b/Software/LaserDelayScan/Makefile~ new file mode 100755 index 0000000..a212d07 --- /dev/null +++ b/Software/LaserDelayScan/Makefile~ @@ -0,0 +1,34 @@ +# +CC=$(CXX) +glib_cflags=$(shell pkg-config --cflags glib-2.0 gio-2.0) +glib_libs=$(shell pkg-config --libs glib-2.0 gio-2.0) + +ROOTC=$(shell root-config --cflags) +ROOTL=$(shell root-config --libs) +OPT=-g -fno-inline #-std=c++11 +CppFLAGS=$(OPT) -I. $(glib_cflags) +CXXFLAGS=-fPIC $(CppFLAGS) + + +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + SO=so + SO_FLAGS=-shared + CXXFLAGS += -D LINUX +endif +ifeq ($(UNAME_S),Darwin) + SO=dylib + SO_FLAGS=-dynamiclib -undefined dynamic_lookup -install_name @rpath/$@ + CXXFLAGS += -D OSX +endif + +all: ComputePedestals + +ComputePedestals: ComputePedestals.C + c++ -I$(OPT) $(CXXFLAGS) $(ROOTC) -o $@ $^ $(LDLIBS) $(ROOTL) $(gliblibs) + + +clean: + rm -f *.o ComputePedestals + rm -rf *.dSYM + diff --git a/Software/ProcessRawData/ProcessRawData.C b/Software/ProcessRawData/ProcessRawData.C index 5a704a5..5cc9669 100644 --- a/Software/ProcessRawData/ProcessRawData.C +++ b/Software/ProcessRawData/ProcessRawData.C @@ -9,8 +9,8 @@ - all branches in the EventInfo tree, one per event; - string InputFilename, the complete path to the input file (ROOT file); - string PedFilename, the complete path to the pedestal file (text file); -- std::vector Ped, the pedestals calculated by ComputePedestals; -- std::vector ADCProcessed, one per event (ADC after pedestal subtraction); +- std::vector Ped, the pedestals calculated by ComputePedestals; +- std::vector ADCProcessed, one per event (ADC after pedestal subtraction); - distribution of the ADC counts of each Beetle (TH1F *hADCBeetle1 and TH1F *hADCBeetle2, before pedestal subtraction, and TH1F *hADCPedSubBeetle1 and TH1F *hADCPedSubBeetle2, after pedestal subtraction); - distribution of the ADC counts of each Beetle channel (TH1F *hADC[N], before pedestal subtraction, and TH1F *hADCPedSub[N], after pedestal subtraction); - ADC counts as a function of the Beetle channel (event-by-event, displayed only for one particular event, TH1F *hADCvsStripBeetle1 and TH1F *hADCvsStripBeetle2, before pedestal subtraction, and TH1F *hADCPedSubvsStripBeetle1 and TH1F *hADCPedSubvsStripBeetle2, after pedestal subtraction). @@ -177,10 +177,10 @@ FILE *inputText = fopen(TString(filenamePed),"r"); // Read pedestals. - double ped[N]; + float ped[N]; for (int iChannel=0; iChannel Ped; + std::vector Ped; InputFilename = string(filename); PedFilename = string(filenamePed); @@ -212,26 +212,26 @@ int sample = 970; // Modify it. // Copy the EventInfo tree to the output data ROOT file and add some more information. - std::vector ADCProcessed; // Raw ADC - pedestal. + std::vector ADCProcessed; // Raw ADC - pedestal. TTree *EventInfoProcessed = EventInfo->CloneTree(0); EventInfoProcessed->Branch("ADCProcessed",&ADCProcessed); // Distribution of the ADC counts of each Beetle (TH1F *hADCBeetle1 and TH1F *hADCBeetle2, before pedestal subtraction, and TH1F *hADCPedSubBeetle1 and TH1F *hADCPedSubBeetle2, after pedestal subtraction); - TH1F *hADCBeetle1 = new TH1F("hADCBeetle1","",200,200,800); // Modify it. + TH1F *hADCBeetle1 = new TH1F("hADCBeetle1","",400,300,700); // Modify it. TCanvas *cADCBeetle1 = new TCanvas("cADCBeetle1","",400,300); InitHist(hADCBeetle1,"Raw ADC counts on Beetle 1","ADC counts",""); - TH1F *hADCPedSubBeetle1 = new TH1F("hADCPedSubBeetle1","",200,-200,200); // Modify it. + TH1F *hADCPedSubBeetle1 = new TH1F("hADCPedSubBeetle1","",200,-100,100); // Modify it. TCanvas *cADCPedSubBeetle1 = new TCanvas("cADCPedSubBeetle1","",400,300); InitHist(hADCPedSubBeetle1,"Pedestal subtracted ADC counts on Beetle 1","ADC counts",""); - TH1F *hADCBeetle2 = new TH1F("hADCBeetle2","",200,200,800); // Modify it. + TH1F *hADCBeetle2 = new TH1F("hADCBeetle2","",400,300,700); // Modify it. TCanvas *cADCBeetle2 = new TCanvas("cADCBeetle2","",400,300); InitHist(hADCBeetle2,"Raw ADC counts on Beetle 2","ADC counts",""); - TH1F *hADCPedSubBeetle2 = new TH1F("hADCPedSubBeetle2","",200,-200,200); // Modify it. + TH1F *hADCPedSubBeetle2 = new TH1F("hADCPedSubBeetle2","",200,-100,100); // Modify it. TCanvas *cADCPedSubBeetle2 = new TCanvas("cADCPedSubBeetle2","",400,300); InitHist(hADCPedSubBeetle2,"Pedestal subtracted ADC counts on Beetle 2","ADC counts",""); @@ -280,18 +280,18 @@ // Style and range for Beetle 1 plots. hADCvsStripBeetle1->SetFillColor(kAzure); hADCPedSubvsStripBeetle1->SetFillColor(kAzure); - hADCvsStripBeetle1->SetMinimum(-1200); + hADCvsStripBeetle1->SetMinimum(0); hADCvsStripBeetle1->SetMaximum(1200); - hADCPedSubvsStripBeetle1->SetMinimum(-500); - hADCPedSubvsStripBeetle1->SetMaximum(500); + hADCPedSubvsStripBeetle1->SetMinimum(-150); + hADCPedSubvsStripBeetle1->SetMaximum(900); // Style and range for Beetle 2 plots. hADCvsStripBeetle2->SetFillColor(kRed); hADCPedSubvsStripBeetle2->SetFillColor(kRed); - hADCvsStripBeetle2->SetMinimum(-1200); + hADCvsStripBeetle2->SetMinimum(0); hADCvsStripBeetle2->SetMaximum(1200); - hADCPedSubvsStripBeetle2->SetMinimum(-500); - hADCPedSubvsStripBeetle2->SetMaximum(500); + hADCPedSubvsStripBeetle2->SetMinimum(-150); + hADCPedSubvsStripBeetle2->SetMaximum(900); // Fill histograms. for (int iEvent=0;iEventat(iChannel) > 1024.) cout << "Error! ADC counts of Beetle channel " << iChannel << ": " << ADC->at(iChannel) << endl; - ADCProcessed.push_back(ADC->at(iChannel)-ped[iChannel]); + ADCProcessed.push_back((float)ADC->at(iChannel)-ped[iChannel]); if ((iChannel>=0) && (iChannelFill(ADC->at(iChannel)); - hADCPedSubBeetle1->Fill(ADC->at(iChannel)-ped[iChannel]); + hADCBeetle1->Fill((float)ADC->at(iChannel)); + hADCPedSubBeetle1->Fill((float)ADC->at(iChannel)-ped[iChannel]); if (iEvent == sample) { - hADCvsStripBeetle1->Fill(iChannel,ADC->at(iChannel)); - hADCPedSubvsStripBeetle1->Fill(iChannel,ADC->at(iChannel)-ped[iChannel]); + hADCvsStripBeetle1->Fill(iChannel,(float)ADC->at(iChannel)); + hADCPedSubvsStripBeetle1->Fill(iChannel,(float)ADC->at(iChannel)-ped[iChannel]); } } else if ((iChannel>=NBeetle) && (iChannelFill(ADC->at(iChannel)); - hADCPedSubBeetle2->Fill(ADC->at(iChannel)-ped[iChannel]); + hADCBeetle2->Fill((float)ADC->at(iChannel)); + hADCPedSubBeetle2->Fill((float)ADC->at(iChannel)-ped[iChannel]); if (iEvent == sample) { - hADCvsStripBeetle2->Fill(iChannel,ADC->at(iChannel)); - hADCPedSubvsStripBeetle2->Fill(iChannel,ADC->at(iChannel)-ped[iChannel]); + hADCvsStripBeetle2->Fill(iChannel,(float)ADC->at(iChannel)); + hADCPedSubvsStripBeetle2->Fill(iChannel,(float)ADC->at(iChannel)-ped[iChannel]); } } - hADC[iChannel]->Fill(ADC->at(iChannel)); - hADCPedSub[iChannel]->Fill(ADC->at(iChannel)-ped[iChannel]); + hADC[iChannel]->Fill((float)ADC->at(iChannel)); + hADCPedSub[iChannel]->Fill((float)ADC->at(iChannel)-ped[iChannel]); } EventInfoProcessed->Fill(); diff --git a/Software/Tools/Style.C b/Software/Tools/Style.C index 168dcc1..0b767b5 100644 --- a/Software/Tools/Style.C +++ b/Software/Tools/Style.C @@ -210,6 +210,8 @@ hist->GetZaxis()->SetTitle(Form("Entries / (%g*%g)",hist->GetXaxis()->GetBinWidth(1),hist->GetYaxis()->GetBinWidth(1))); else hist->GetZaxis()->SetTitle(z); + hist->SetLabelOffset(0.005,"Z"); + hist->SetTitleOffset(0.65,"Z"); return; } @@ -288,16 +290,17 @@ hist1->SetLineColor(kMagenta); hist2->SetLineColor(kOrange); hist3->SetLineColor(kRed); + hist3->SetMarkerStyle(3); if (hist1->GetMaximum() > hist2->GetMaximum()) { if (hist1->GetMaximum() > hist3->GetMaximum()) { hist1->Draw("E"); hist2->Draw("SAME"); - hist3->Draw("SAME"); + hist3->Draw("ESAME"); } else { - hist3->Draw(""); + hist3->Draw("E"); hist1->Draw("ESAME"); hist2->Draw("SAME"); } @@ -308,11 +311,11 @@ { hist2->Draw(""); hist1->Draw("ESAME"); - hist3->Draw("SAME"); + hist3->Draw("ESAME"); } else { - hist3->Draw(""); + hist3->Draw("E"); hist1->Draw("ESAME"); hist2->Draw("SAME"); } @@ -424,7 +427,7 @@ TLegend *leg = new TLegend(x1,y1,x2,y2); leg->AddEntry(obj1,lab1,option.Data()); leg->AddEntry(obj2,lab2,option.Data()); - leg->SetTextSize(.02); + // leg->SetTextSize(.02); if(option.Contains("w")) leg->SetFillColor(kWhite); @@ -441,7 +444,7 @@ leg->AddEntry(obj1,lab1,option.Data()); leg->AddEntry(obj2,lab2,option.Data()); leg->AddEntry(obj3,lab3,option.Data()); - leg->SetTextSize(.02); + // leg->SetTextSize(.02); if(option.Contains("w")) leg->SetFillColor(kWhite); @@ -459,7 +462,7 @@ leg->AddEntry(obj2,lab2,option.Data()); leg->AddEntry(obj3,lab3,option.Data()); leg->AddEntry(obj4,lab4,option.Data()); - leg->SetTextSize(.02); + // leg->SetTextSize(.02); if(option.Contains("w")) leg->SetFillColor(kWhite);