diff --git a/Software/AutomatedMeasurements/ElectronicMonkeyCCEScan.py b/Software/AutomatedMeasurements/ElectronicMonkeyCCEScan.py index cbccd1f..26a3ea5 100644 --- a/Software/AutomatedMeasurements/ElectronicMonkeyCCEScan.py +++ b/Software/AutomatedMeasurements/ElectronicMonkeyCCEScan.py @@ -51,7 +51,7 @@ import time -import pylab as pl +import numpy as np parser = argparse.ArgumentParser(description='Define the parameters of the automated measurement for CCE scan.') @@ -140,7 +140,7 @@ # Take a pedestal run. if not os.path.exists(folder+"/Hans410/"+measurement): os.makedirs(folder+"/Hans410/"+measurement) - filename = folder+"/Hans410/"+measurement+"/"+str(yyyymmdd)+"-216-"+"ped.ali" +filename = folder+"/Hans410/"+measurement+"/"+str(yyyymmdd)+"-216-"+"ped.ali" configped = config+"/FocusingConfig" printcommand = "echo alibava-gui --no-gui --nevts="+str(nevents)+" --out="+filename+" --pedestal "+configped @@ -150,7 +150,7 @@ subprocess.call(command,shell=True) # Perform the measurement. -for pospar in pl.frange(firstpar,lastpar,steppar) : +for pospar in np.linspace(firstpar,lastpar,(lastpar-firstpar)/steppar+1) : # If the measurement is of type "CCEDelayScan" we need a different configuration file for each value of the delay. All these files are in "CCEDelayScanConfig" folder. if (measurement == "CCEDelayScan") : configlas = config+"/CCEDelayScanConfig/"+"CCEDelayScanConfig"+str(int(pospar))+"ns" diff --git a/Software/CCEDelayScan/CCEDelayScan.C b/Software/CCEDelayScan/CCEDelayScan.C new file mode 100644 index 0000000..d654f03 --- /dev/null +++ b/Software/CCEDelayScan/CCEDelayScan.C @@ -0,0 +1,254 @@ +//************************************************ +// Author: Federica Lionetto +// Created on: 05/03/2015 +//************************************************ + +/* +CCEDelayScan reads all the ROOT files of a given CCE delay data taking and shows how the mu and sigma of the charge sharing coefficient eta vary as a function of the delay. + +The CCE delay data taking is identified by the following information: +- , that is, the type of sensor (Hans410, ...); +- , that is, the date when the measurement was taken; +- , that is, the position along z; +- , that is, the first value of the delay; +- , that is, the last value of the delay; +- , that is, the step between two subsequent data acquisitions. + +Compile with: + +make + +Run with: + +./CCEDelayScan [sensor] [date] [z] [firstd] [lastd] [stepd] [additional folder] + +For example: + +./CCEDelayScan Hans410 20141121 176 67 75 1 + +A folder named AnalysisResults will be created in a fixed location and a ROOT file will be saved in there. A folder named Figures will be created inside the folder named AnalysisResults, with some monitoring plots. + +If needed, an additional folder can be specified, that will be created inside the folder named AnalysisResults. +*/ + +#include "../Tools/Lib.C" +#include "../Tools/lhcbStyle.C" +#include "../Tools/Style.C" + +#include "../Tools/Par.C" + +void CCEDelayScan(char *sensor, char *date, char *z, const Float_t firstd, const Float_t lastd, const Float_t stepd, char *externalPath=0); + +int main(int argc, char *argv[]) +{ + getLHCbStyle(); + PersonalStyle(); + + if ((argc == 2) && (string(argv[1]) == "--info")) + { + cout << "**************************************************" << endl; + + cout << "CCEDelayScan reads all the ROOT files of a given CCE delay data taking and shows how the mu and sigma of the charge sharing coefficient eta vary as a function of the delay." << endl; + + cout << "The CCE delay data taking is identified by the following information:" << endl; + cout << "- , that is, the type of sensor (Hans410, ...);" << endl; + cout << "- , that is, the date when the measurement was taken;" << endl; + cout << "- , that is, the position along z;" << endl; + cout << "- , that is, the first value of the delay;" << endl; + cout << "- , that is, the last value of the delay;" << endl; + cout << "- , that is, the step between two subsequent data acquisitions." << endl; + + cout << "Compile with:" << endl; + + cout << "make" << endl; + + cout << "Run with:" << endl; + + cout << "./CCEDelayScan [sensor] [date] [z] [firstd] [lastd] [stepd] [additional folder]" << endl; + + cout << "For example:" << endl; + + cout << "./CCEDelayScan Hans410 20141121 176 67 75 1" << endl; + + cout << "A folder named AnalysisResults will be created in a fixed location and a ROOT file will be saved in there. A folder named Figures will be created inside the folder named AnalysisResults, with some monitoring plots." << endl; + + cout << "If needed, an additional folder can be specified, that will be created inside the folder named AnalysisResults." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else if (argc < 7) + { + cout << "**************************************************" << endl; + + cout << "Error! Arguments missing..." << endl; + cout << "Please use the following format:" << endl; + cout << "./CCEDelayScan [1] [2] [3] [4] [5] [6]" << endl; + cout << "with:" << endl; + cout << "[1] = Type of sensor (Hans410, ...);" << endl; + cout << "[2] = Date;" << endl; + cout << "[3] = Position along z;" << endl; + cout << "[4] = First value of the delay;" << endl; + cout << "[5] = Last value of the delay" << endl; + cout << "[6] = Step between two subsequent data acquisitions;" << endl; + cout << "[7] = Additional folder, optional." << endl; + cout << "Type ./CCEDelayScan --info for more information." << endl; + + cout << "**************************************************" << endl; + + return 0; + } + else + { + cout << "Type of sensor: " << argv[1] << endl; + cout << "Date: " << argv[2] << endl; + cout << "Position along z: " << argv[3] << endl; + cout << "First value of the delay: " << argv[4] << endl; + cout << "Last value of the delay: " << argv[5] << endl; + cout << "Step between two subsequent data acquisitions: " << argv[6] << endl; + if (argc == 7) + CCEDelayScan(argv[1],argv[2],argv[3],atoi(argv[4]),atoi(argv[5]),atoi(argv[6])); + else if (argc == 8) + CCEDelayScan(argv[1],argv[2],argv[3],atoi(argv[4]),atoi(argv[5]),atoi(argv[6]),argv[7]); + else + { + cout << "Error! Too many arguments given..." << endl; + + return 0; + } + + return 0; + } +} + +void CCEDelayScan(char *sensor, char *date, char *z, const Float_t firstd, const Float_t lastd, const Float_t stepd, char *externalPath) +{ + cout << "**************************************************" << endl; + cout << "Delay scan of charge sharing coefficient..." << endl; + cout << "**************************************************" << endl; + + // Do not comment this line. + gROOT->ProcessLine("#include "); + + // Do some fanciness to get the directory right. + string inputDirectory = "/disk/groups/hep/flionett/TestStand/AnalysisResults/"+string(sensor)+"/CCEDelayScan"; + string outputDirectory = "/disk/groups/hep/flionett/TestStand/AnalysisResults/"+string(sensor)+"/CCEDelayScan"; + 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/"+"CCE-ProcessRawData-"+date+"-216-"+z+"z" << 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/"+"CCE-ProcessRawData-"+date+"-216-"+z+"z"; + 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); + + char char_input_ROOT[200]; + string input_ROOT; + string output_ROOT; + + const Int_t steps = (Int_t)((lastd-firstd)/stepd+1); + Float_t d[steps]; + Float_t ud[steps]; + + Float_t muEtaSignalOverNoise[steps]; + Float_t sigmaEtaSignalOverNoise[steps]; + + Float_t umuEtaSignalOverNoise[steps]; + Float_t usigmaEtaSignalOverNoise[steps]; + + // Get information from tree. + Float_t muEtaSignalOverNoise1; + Float_t sigmaEtaSignalOverNoise1; + + Float_t umuEtaSignalOverNoise1; + Float_t usigmaEtaSignalOverNoise1; + + TBranch *b_muEtaSignalOverNoise1 = 0; + TBranch *b_sigmaEtaSignalOverNoise1 = 0; + + TBranch *b_umuEtaSignalOverNoise1 = 0; + TBranch *b_usigmaEtaSignalOverNoise1 = 0; + + // Open output ROOT file. + output_ROOT = outputDirectory+"/CCEDelayScan-"+date+"-216-"+z+"z"+".root"; + TFile *output = TFile::Open(TString(output_ROOT),"RECREATE"); + + for (Int_t step=0;stepGet("tFitResults"); + int Events = tFitResults->GetEntries(); + if (Events != 1) + { + cout << "Error! The ROOT file has been corrupted..." << endl; + + return ; + } + else + { + tFitResults->SetBranchAddress("muEtaSignalOverNoise",&muEtaSignalOverNoise1,&b_muEtaSignalOverNoise1); + tFitResults->SetBranchAddress("sigmaEtaSignalOverNoise",&sigmaEtaSignalOverNoise1,&b_sigmaEtaSignalOverNoise1); + tFitResults->SetBranchAddress("umuEtaSignalOverNoise",&umuEtaSignalOverNoise1,&b_umuEtaSignalOverNoise1); + tFitResults->SetBranchAddress("usigmaEtaSignalOverNoise",&usigmaEtaSignalOverNoise1,&b_usigmaEtaSignalOverNoise1); + + tFitResults->GetEntry(); + } + + muEtaSignalOverNoise[step] = muEtaSignalOverNoise1; + sigmaEtaSignalOverNoise[step] = sigmaEtaSignalOverNoise1; + umuEtaSignalOverNoise[step] = umuEtaSignalOverNoise1; + usigmaEtaSignalOverNoise[step] = usigmaEtaSignalOverNoise1; + + // Close input data ROOT files. + input->Close(); + } + + output->cd(); + + // Plot mu. + TGraphErrors *gMuEtaSignalOverNoiseVSd = new TGraphErrors(steps,d,muEtaSignalOverNoise,ud,umuEtaSignalOverNoise); + InitGraphErrors(gMuEtaSignalOverNoiseVSd,"Charge sharing coefficient - #mu","delay (ns)","#mu (#mum)"); + + TCanvas *cMuEtaSignalOverNoiseVSd = new TCanvas(Form("cMuEtaSignalOverNoiseVSd-%s",date),"",550,300); + DrawGraphErrors(cMuEtaSignalOverNoiseVSd,gMuEtaSignalOverNoiseVSd,"AP",path_to_figures); + + // Plot sigma. + TGraphErrors *gSigmaEtaSignalOverNoiseVSd = new TGraphErrors(steps,d,sigmaEtaSignalOverNoise,ud,usigmaEtaSignalOverNoise); + InitGraphErrors(gSigmaEtaSignalOverNoiseVSd,"Charge sharing coefficient - #sigma","delay (ns)","#sigma (#mum)"); + + TCanvas *cSigmaEtaSignalOverNoiseVSd = new TCanvas(Form("cSigmaEtaSignalOverNoiseVSd-%s",date),"",550,300); + DrawGraphErrors(cSigmaEtaSignalOverNoiseVSd,gSigmaEtaSignalOverNoiseVSd,"AP",path_to_figures); + + // Write output ROOT file. + output->Write(); + + // Close output ROOT file. + output->Close(); + + return; +} diff --git a/Software/CCEDelayScan/Makefile b/Software/CCEDelayScan/Makefile new file mode 100755 index 0000000..4811acb --- /dev/null +++ b/Software/CCEDelayScan/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: CCEDelayScan + +CCEDelayScan: CCEDelayScan.C + c++ -I$(OPT) $(CXXFLAGS) $(ROOTC) -o $@ $^ $(LDLIBS) $(ROOTL) $(gliblibs) + + +clean: + rm -f *.o CCEDelayScan + rm -rf *.dSYM + diff --git a/Software/Tools/SCurve.C b/Software/Tools/SCurve.C index dec2cb6..a2bff2d 100644 --- a/Software/Tools/SCurve.C +++ b/Software/Tools/SCurve.C @@ -404,7 +404,7 @@ - else if ((filename == "ProcessRawData-201502253-216") || (filename == "ProcessRawData-20150226-216") || (filename == "ProcessRawData-201502262-216") || (filename == "ProcessRawData-20150226-100V-216") || (filename == "ProcessRawData-20150226-120V-216") || (filename == "ProcessRawData-20150226-140V-216") || (filename == "ProcessRawData-20150226-160V-216") || (filename == "ProcessRawData-20150226-180V-216") || (filename == "ProcessRawData-20150226-200V-216") || (filename == "ProcessRawData-20150227-21.0dB-216") || (filename == "ProcessRawData-20150227-21.5dB-216") || (filename == "ProcessRawData-20150227-22.0dB-216") || (filename == "ProcessRawData-20150227-22.5dB-216") || (filename == "ProcessRawData-20150227-23.0dB-216") || (filename == "ProcessRawData-20150227-23.5dB-216") || (filename == "ProcessRawData-20150227-24.0dB-216") || (filename == "ProcessRawData-20150227-24.5dB-216") || (filename == "ProcessRawData-20150227-25.0dB-216") || (filename == "ProcessRawData-20150305-67ns-216") || (filename == "ProcessRawData-20150305-68ns-216") || (filename == "ProcessRawData-20150305-69ns-216") ||(filename == "ProcessRawData-20150305-70ns-216") || (filename == "ProcessRawData-20150305-71ns-216") || (filename == "ProcessRawData-20150305-72ns-216") || (filename == "ProcessRawData-20150305-73ns-216") || (filename == "ProcessRawData-20150305-74ns-216") || (filename == "ProcessRawData-20150305-75ns-216")) { + else if ((filename == "ProcessRawData-201502253-216") || (filename == "ProcessRawData-20150226-216") || (filename == "ProcessRawData-201502262-216") || (filename == "ProcessRawData-20150226-100V-216") || (filename == "ProcessRawData-20150226-120V-216") || (filename == "ProcessRawData-20150226-140V-216") || (filename == "ProcessRawData-20150226-160V-216") || (filename == "ProcessRawData-20150226-180V-216") || (filename == "ProcessRawData-20150226-200V-216") || (filename == "ProcessRawData-20150227-21.0dB-216") || (filename == "ProcessRawData-20150227-21.5dB-216") || (filename == "ProcessRawData-20150227-22.0dB-216") || (filename == "ProcessRawData-20150227-22.5dB-216") || (filename == "ProcessRawData-20150227-23.0dB-216") || (filename == "ProcessRawData-20150227-23.5dB-216") || (filename == "ProcessRawData-20150227-24.0dB-216") || (filename == "ProcessRawData-20150227-24.5dB-216") || (filename == "ProcessRawData-20150227-25.0dB-216") || (filename == "ProcessRawData-20150309-67ns-216") || (filename == "ProcessRawData-20150309-68ns-216") || (filename == "ProcessRawData-20150309-69ns-216") ||(filename == "ProcessRawData-20150309-70ns-216") || (filename == "ProcessRawData-20150309-71ns-216") || (filename == "ProcessRawData-20150309-72ns-216") || (filename == "ProcessRawData-20150309-73ns-216") || (filename == "ProcessRawData-20150309-74ns-216") || (filename == "ProcessRawData-20150309-75ns-216") || (filename == "ProcessRawData-20150315-67ns-216") || (filename == "ProcessRawData-20150315-68ns-216") || (filename == "ProcessRawData-20150315-69ns-216") ||(filename == "ProcessRawData-20150315-70ns-216") || (filename == "ProcessRawData-20150315-71ns-216") || (filename == "ProcessRawData-20150315-72ns-216") || (filename == "ProcessRawData-20150315-73ns-216") || (filename == "ProcessRawData-20150315-74ns-216") || (filename == "ProcessRawData-20150315-75ns-216")) { // Right. *minRight = 30.; *maxRight = 140.; @@ -576,7 +576,7 @@ // - Float_t parEta[], the array containing the parameters of the erf function; // - Float_t lengthParEta, the length of the array containing the parameters of the erf function. void assignParInfoEta(string filename, Float_t parEta[], Int_t lengthParEta) { - if ((filename == "ProcessRawData-201502262-216") || (filename == "ProcessRawData-20150226-100V-216") || (filename == "ProcessRawData-20150226-120V-216") || (filename == "ProcessRawData-20150226-140V-216") || (filename == "ProcessRawData-20150226-160V-216") || (filename == "ProcessRawData-20150226-180V-216") || (filename == "ProcessRawData-20150226-200V-216") || (filename == "ProcessRawData-20150227-21.0dB-216") || (filename == "ProcessRawData-20150227-21.5dB-216") || (filename == "ProcessRawData-20150227-22.0dB-216") || (filename == "ProcessRawData-20150227-22.5dB-216") || (filename == "ProcessRawData-20150227-23.0dB-216") || (filename == "ProcessRawData-20150227-23.5dB-216") || (filename == "ProcessRawData-20150227-24.0dB-216") || (filename == "ProcessRawData-20150227-24.5dB-216") || (filename == "ProcessRawData-20150227-25.0dB-216") || (filename == "ProcessRawData-20150305-67ns-216") || (filename == "ProcessRawData-20150305-68ns-216") || (filename == "ProcessRawData-20150305-69ns-216") ||(filename == "ProcessRawData-20150305-70ns-216") || (filename == "ProcessRawData-20150305-71ns-216") || (filename == "ProcessRawData-20150305-72ns-216") || (filename == "ProcessRawData-20150305-73ns-216") || (filename == "ProcessRawData-20150305-74ns-216") || (filename == "ProcessRawData-20150305-75ns-216")) { + if ((filename == "ProcessRawData-201502262-216") || (filename == "ProcessRawData-20150226-100V-216") || (filename == "ProcessRawData-20150226-120V-216") || (filename == "ProcessRawData-20150226-140V-216") || (filename == "ProcessRawData-20150226-160V-216") || (filename == "ProcessRawData-20150226-180V-216") || (filename == "ProcessRawData-20150226-200V-216") || (filename == "ProcessRawData-20150227-21.0dB-216") || (filename == "ProcessRawData-20150227-21.5dB-216") || (filename == "ProcessRawData-20150227-22.0dB-216") || (filename == "ProcessRawData-20150227-22.5dB-216") || (filename == "ProcessRawData-20150227-23.0dB-216") || (filename == "ProcessRawData-20150227-23.5dB-216") || (filename == "ProcessRawData-20150227-24.0dB-216") || (filename == "ProcessRawData-20150227-24.5dB-216") || (filename == "ProcessRawData-20150227-25.0dB-216") || (filename == "ProcessRawData-20150309-67ns-216") || (filename == "ProcessRawData-20150309-68ns-216") || (filename == "ProcessRawData-20150309-69ns-216") ||(filename == "ProcessRawData-20150309-70ns-216") || (filename == "ProcessRawData-20150309-71ns-216") || (filename == "ProcessRawData-20150309-72ns-216") || (filename == "ProcessRawData-20150309-73ns-216") || (filename == "ProcessRawData-20150309-74ns-216") || (filename == "ProcessRawData-20150309-75ns-216") || (filename == "ProcessRawData-20150315-67ns-216") || (filename == "ProcessRawData-20150315-68ns-216") || (filename == "ProcessRawData-20150315-69ns-216") ||(filename == "ProcessRawData-20150315-70ns-216") || (filename == "ProcessRawData-20150315-71ns-216") || (filename == "ProcessRawData-20150315-72ns-216") || (filename == "ProcessRawData-20150315-73ns-216") || (filename == "ProcessRawData-20150315-74ns-216") || (filename == "ProcessRawData-20150315-75ns-216")) { parEta[0] = 1.5; parEta[1] = 140.; parEta[2] = 5.;