diff --git a/Software/AutomatedMeasurements/ElectronicMonkeyFocusing.py b/Software/AutomatedMeasurements/ElectronicMonkeyFocusing.py index f8135f8..d816009 100644 --- a/Software/AutomatedMeasurements/ElectronicMonkeyFocusing.py +++ b/Software/AutomatedMeasurements/ElectronicMonkeyFocusing.py @@ -17,10 +17,10 @@ - , the step size along z. How to run it: -python ElectronicMonkeyFocusing.py --fx --lx --sx --fz --lz --sz --date +python ElectronicMonkeyFocusing.py --m --fx --lx --sx --fz --lz --sz --date For example: -python ElectronicMonkeyFocusing.py --fx 0 --lx 50 --sx 2 --fz -400 --lz -200 --sz 20 --date 20150106 +python ElectronicMonkeyFocusing.py --f Alignment --fx 0 --lx 50 --sx 2 --fz -400 --lz -200 --sz 20 --date 20150106 Arduino device ID: DEVICE ID 2341:0042 on Bus 001 Address 045, Communications Device (in hexadecimal) @@ -40,6 +40,7 @@ parser = argparse.ArgumentParser(description='Define the parameters of the automated measurement for focusing.') +parser.add_argument('--m',help='type of measurement') parser.add_argument('--fx',type=int,help='first x position') parser.add_argument('--lx',type=int,help='last x position') parser.add_argument('--sx',type=int,help='step size along x') @@ -53,6 +54,8 @@ args = parser.parse_args() # Parameters and configuration. +measurement = args.m + firstx = args.fx lastx = args.lx stepx = args.sx @@ -69,6 +72,8 @@ filename = '' config = '/home/hep/flionett/TestStand/Repository/TestStandRepository/Software/AutomatedMeasurements/FocusingConfig' +print 'Type of measurement: ', measurement + print 'First x position: %i steps' % firstx print 'Last x position: %i steps' % lastx print 'Step size along x: %i steps' % stepx @@ -109,7 +114,9 @@ time.sleep(1) # Take a pedestal run. -filename = folder+"/Hans410/Alignment/"+str(yyyymmdd)+"-216-"+"ped.ali" +if not os.path.exists(folder+"/Hans410/"+measurement): + os.makedirs(folder+"/Hans410/"+measurement) +filename = folder+"/Hans410/"+measurement+"/"+str(yyyymmdd)+"-216-"+"ped.ali" printcommand = "echo alibava-gui --no-gui --nevts="+str(nevents)+" --out="+filename+" --pedestal "+config command = "alibava-gui --no-gui --nevts="+str(nevents)+" --out="+filename+" --pedestal "+config print '***' @@ -121,7 +128,7 @@ for posx in range(firstx,lastx+stepx,stepx) : print 'Position along x: %i steps' % posx print 'Position along z: %i steps' % posz - filename = folder+"/Hans410/Alignment/"+str(yyyymmdd)+"-216-"+str(posx)+"x-"+str(posz)+"z-las.ali" + filename = folder+"/Hans410/"+measurement+"/"+str(yyyymmdd)+"-216-"+str(posx)+"x-"+str(posz)+"z-las.ali" printcommand = "echo alibava-gui --no-gui --nevts="+str(nevents)+" --out="+filename+" --laser "+config command = "alibava-gui --no-gui --nevts="+str(nevents)+" --out="+filename+" --laser "+config print '***' diff --git a/Software/CCE/CCE.C b/Software/CCE/CCE.C index 8d5ec99..e18b58a 100644 --- a/Software/CCE/CCE.C +++ b/Software/CCE/CCE.C @@ -110,9 +110,7 @@ gROOT->ProcessLine("#include "); // Do some fanciness to get the directory right. - // string inputDirectory = "/disk/groups/hep/flionett/TestStand/AnalysisResults/"+string(sensor)+"/CCE"; - // CHANGE inputDirectory!!! - string inputDirectory = "/disk/groups/hep/flionett/TestStand/AnalysisResults/"+string(sensor)+"/Alignment"; + string inputDirectory = "/disk/groups/hep/flionett/TestStand/AnalysisResults/"+string(sensor)+"/CCE"; string outputDirectory = "/disk/groups/hep/flionett/TestStand/AnalysisResults/"+string(sensor)+"/CCE"; if (externalPath!=0) outputDirectory = string(outputDirectory+"/"+externalPath); @@ -154,11 +152,16 @@ const Int_t steps = (Int_t)((lastx-firstx)/stepx+1); Float_t x[steps]; + + // CCE. Float_t signalOverNoise1Left[steps]; Float_t signalOverNoise1Right[steps]; Float_t signalOverNoise2[steps]; Float_t signalOverNoise4[steps]; + // Charge sharing coefficient eta. + Float_t etaSignalOverNoise[steps]; + // Parameters of the fitting functions. Float_t aLeft; Float_t bLeft; @@ -278,6 +281,7 @@ signalOverNoise2[step] = (hist1->GetMean())/noise[ch1]+(hist2->GetMean())/noise[ch2]; } signalOverNoise4[step] = (hist1->GetMean())/noise[ch1]+(hist2->GetMean())/noise[ch2]+(hist3->GetMean())/noise[ch3]+(hist4->GetMean())/noise[ch4]; + etaSignalOverNoise[step] = (signalOverNoise1Right[step]-signalOverNoise1Left[step])/(signalOverNoise1Right[step]+signalOverNoise1Left[step]); // Close input data ROOT files. input->Close(); @@ -365,15 +369,62 @@ gCCESignalOverNoise2->SetLineWidth(2); gCCESignalOverNoise4->SetLineWidth(2); - TLegend *legCCESignalOverNoise = CreateLegend4(gCCESignalOverNoise1Left,"left strip",gCCESignalOverNoise1Right,"right strip",gCCESignalOverNoise2,"2 strips",gCCESignalOverNoise4,"4 strips","lpw",0.72,0.62,0.92,0.92); + TLegend *legCCESignalOverNoise = CreateLegend4(gCCESignalOverNoise1Left,"left strip",gCCESignalOverNoise1Right,"right strip",gCCESignalOverNoise2,"2 strips",gCCESignalOverNoise4,"4 strips","lpw",0.79,0.62,0.92,0.92); mgCCESignalOverNoise->Add(gCCESignalOverNoise1Left); mgCCESignalOverNoise->Add(gCCESignalOverNoise1Right); mgCCESignalOverNoise->Add(gCCESignalOverNoise2); mgCCESignalOverNoise->Add(gCCESignalOverNoise4); + mgCCESignalOverNoise->SetMinimum(-1.); + mgCCESignalOverNoise->SetMaximum(20.); + DrawGraphCompare(cCCESignalOverNoise,mgCCESignalOverNoise,legCCESignalOverNoise,"CCE","x (#mum)","S/N","APCE",path_to_figures); + // Charge sharing coefficient eta. + // The charge sharing coefficient eta is defined as (S/N_i+1 - S/N_i)/(S/N_i+1 + S/N_i), where S/N is the signal over noise ratio on strip i (left) or i+1 (right). If the charge carriers are collected only by the strip on the left then eta = -1 while if the charge carriers are collected only by the strip on the right then eta = 1. + TCanvas *cEtaSignalOverNoise = new TCanvas(Form("cEtaSignalOverNoise-%s",filename),"",550,300); + TGraph *gEtaSignalOverNoise = new TGraph(steps,x,etaSignalOverNoise); + InitGraph(gEtaSignalOverNoise,"Charge sharing coefficient","x (#mum)","#eta S/N"); + + // Fit with the fRight function (which describes the rising s-curve). + TF1 *fEtaSignalOverNoise = new TF1("fEtaSignalOverNoise",fRight,minPosCCE,maxPosCCE,4); + + // Array of the parameters necessary for fitting with fitRight. + // The array contains par0, par1, par2, par3, par0low, par0high, par1low, par1high, par2low, par2high, par3low, par3high. + const Int_t lengthParEtaSignalOverNoise = 12; + Float_t parEtaSignalOverNoise[lengthParEtaSignalOverNoise]; + + assignParInfoEta(string(filename),parEtaSignalOverNoise,lengthParEtaSignalOverNoise); + + // Parameters of the fitting function. + Float_t aEtaSignalOverNoise; + Float_t muEtaSignalOverNoise; + Float_t sigmaEtaSignalOverNoise; + Float_t bEtaSignalOverNoise; + + // Uncertainties on the parameters of the fitting function. + // u = uncertainty. + Float_t uaEtaSignalOverNoise; + Float_t umuEtaSignalOverNoise; + Float_t usigmaEtaSignalOverNoise; + Float_t ubEtaSignalOverNoise; + + fitSCurve(r,gEtaSignalOverNoise,fEtaSignalOverNoise,parEtaSignalOverNoise,lengthParEtaSignalOverNoise,&aEtaSignalOverNoise,&muEtaSignalOverNoise,&sigmaEtaSignalOverNoise,&bEtaSignalOverNoise,&uaEtaSignalOverNoise,&umuEtaSignalOverNoise,&usigmaEtaSignalOverNoise,&ubEtaSignalOverNoise); + + // Show fit results. + gStyle->SetOptFit(1); + gStyle->SetStatX(0.9); + gStyle->SetStatY(0.55); + gStyle->SetStatW(0.16); + gStyle->SetStatH(0.23); + gStyle->SetFitFormat(".2g"); + + DrawGraphFunc(cEtaSignalOverNoise,gEtaSignalOverNoise,fEtaSignalOverNoise,"AP",path_to_figures); + + gStyle->SetOptFit(0); + gStyle->SetFitFormat("5.4g"); + // Write output ROOT file. output->Write(); diff --git a/Software/Focusing/Focusing.C b/Software/Focusing/Focusing.C index 27ff7b1..3d484d6 100644 --- a/Software/Focusing/Focusing.C +++ b/Software/Focusing/Focusing.C @@ -381,6 +381,14 @@ cout << "Left side, z = " << zcounter << ", a = " << aLeft[zcounter] << ", mu = " << muLeft[zcounter] << ", sigma = " << sigmaLeft[zcounter] << ", b = " << bLeft[zcounter] << endl; } + + // Show fit results for mu and sigma. + gStyle->SetOptFit(1); + gStyle->SetStatX(0.9); + gStyle->SetStatY(0.55); + gStyle->SetStatW(0.16); + gStyle->SetStatH(0.23); + gStyle->SetFitFormat(".2g"); // Mu - parameters. // y = p0+p1*x, with x = z position (microns) and y = mu (microns). @@ -407,12 +415,12 @@ // Mu - left edge. TGraphErrors *gmuLeft = new TGraphErrors(stepsz,z,muLeft,uz,umuLeft); - InitGraphErrors(gmuLeft,"Focusing - left side","z (#mum)","#mu_{left}"); + InitGraphErrors(gmuLeft,"Focusing - left side","z (#mum)","#mu_{left} (#mum)"); TCanvas *cmuLeft = new TCanvas("cmuLeft","",400,300); gmuLeft->GetXaxis()->SetLimits(z[0]-100.,z[stepsz-1]+100.); TF1 *fitMuLeft = new TF1("fitMuLeft","pol1",minMu,maxMu); - fitMuLeft->SetLineColor(kRed); + fitMuLeft->SetLineColor(kMagenta); gmuLeft->Fit(fitMuLeft,"BR"); p0Left = fitMuLeft->GetParameter(0); @@ -427,12 +435,12 @@ // Mu - right edge. TGraphErrors *gmuRight = new TGraphErrors(stepsz,z,muRight,uz,umuRight); - InitGraphErrors(gmuRight,"Focusing - right side","z (#mum)","#mu_{right}"); + InitGraphErrors(gmuRight,"Focusing - right side","z (#mum)","#mu_{right} (#mum)"); TCanvas *cmuRight = new TCanvas("cmuRight","",400,300); gmuRight->GetXaxis()->SetLimits(z[0]-100.,z[stepsz-1]+100.); TF1 *fitMuRight = new TF1("fitMuRight","pol1",minMu,maxMu); - fitMuRight->SetLineColor(kRed); + fitMuRight->SetLineColor(kMagenta); gmuRight->Fit(fitMuRight,"BR"); p0Right = fitMuRight->GetParameter(0); @@ -474,7 +482,7 @@ // Sigma - left edge. TGraphErrors *gsigmaLeft = new TGraphErrors(stepsz,z,sigmaLeft,uz,usigmaLeft); - InitGraphErrors(gsigmaLeft,"Focusing - left side","z (#mum)","#sigma_{left}"); + InitGraphErrors(gsigmaLeft,"Focusing - left side","z (#mum)","#sigma_{left} (#mum)"); gsigmaLeft->GetXaxis()->SetLimits(z[0]-100.,z[stepsz-1]+100.); TF1 *fitSigmaLeft = new TF1("fitSigmaLeft",fSigma,minSigma,maxSigma,3); @@ -485,7 +493,7 @@ // Sigma - right edge. TGraphErrors *gsigmaRight = new TGraphErrors(stepsz,z,sigmaRight,uz,usigmaRight); - InitGraphErrors(gsigmaRight,"Focusing - right side","z (#mum)","#sigma_{right}"); + InitGraphErrors(gsigmaRight,"Focusing - right side","z (#mum)","#sigma_{right} (#mum)"); gsigmaRight->GetXaxis()->SetLimits(z[0]-100.,z[stepsz-1]+100.); TF1 *fitSigmaRight = new TF1("fitSigmaRight",fSigma,minSigma,maxSigma,3); @@ -494,7 +502,8 @@ TCanvas *csigmaRight = new TCanvas("csigmaRight","",400,300); DrawGraphErrors(csigmaRight,gsigmaRight,"AP",path_to_figures); - + gStyle->SetOptFit(0); + gStyle->SetFitFormat("5.4g"); // Print parameters. cout << "**********************************" << endl; diff --git a/Software/Tools/SCurve.C b/Software/Tools/SCurve.C index df3db86..36922d9 100644 --- a/Software/Tools/SCurve.C +++ b/Software/Tools/SCurve.C @@ -10,6 +10,7 @@ - fSigma describes the sigma as a function of the z position; - assignParInfoSCurves sets the starting values and the limits of the parameters of the two erf functions describing the s-curves according to the filename of the measurement; - assignParInfoSigma sets the starting values and the limits of the parameters of the two sigma functions according to the filename of the measurement; +- assignParInfoEta sets the starting values and the limits of the parameters of the erf function describing the charge sharing coefficient according to the filename of the measurement; - fitSCurve fits the s-curve and returns the result of the fit; - fitSigma fits the sigma as a function of the z position and returns the result of the fit. */ @@ -35,6 +36,7 @@ void assignParInfoSCurves(string filename, Float_t zvalue, Float_t *minRight, Float_t *maxRight, Float_t *minLeft, Float_t *maxLeft, Float_t parSCurves[], Int_t lengthParSCurves); void assignParInfoSigma(string filename, Float_t parSigma[], Int_t lengthParSigma); +void assignParInfoEta(string filename, Float_t parEta[], Int_t lengthParEta); void fitSCurve(string edge, TGraph *graph, TF1 *f, Float_t parSCurves[], Int_t lengthParSCurves, Float_t *a, Float_t *mu, Float_t *sigma, Float_t *b, Float_t *ua, Float_t *umu, Float_t *usigma, Float_t *ub); @@ -399,19 +401,40 @@ - else if (filename == "ProcessRawData-201502253-216") { + else if ((filename == "ProcessRawData-201502253-216") || (filename == "ProcessRawData-20150226-216") || (filename == "ProcessRawData-201502262-216")) { // Right. *minRight = 30.; *maxRight = 140.; // Left. - *minLeft = 140.; - *maxLeft = 230.; - + if (zvalue < 150.) { + *minLeft = 140.; + *maxLeft = 235; + } + else if (zvalue < 230.) { + *minLeft = 140.; + *maxLeft = 240.; + } + else { + *minLeft = 140.; + *maxLeft = 230.; + } + // Right. - parSCurves[0] = 16.; - parSCurves[1] = 60.; - parSCurves[2] = 6.; + if (zvalue < 130.) + parSCurves[0] = 11.; + else + parSCurves[0] = 16.; + if (zvalue < 110.) + parSCurves[1] = 80.; + else if (zvalue < 150.) + parSCurves[1] = 70.; + else + parSCurves[1] = 60.; + if (zvalue<130.) + parSCurves[2] = 10.; + else + parSCurves[2] = 6.; parSCurves[3] = 10.; // parSCurves[4] = 10.; @@ -419,21 +442,27 @@ parSCurves[6] = 20.; parSCurves[7] = 100.; parSCurves[8] = 3.; - parSCurves[9] = 15.; + parSCurves[9] = 20.; // parSCurves[10] = 8.; // parSCurves[11] = 18.; // Left. - parSCurves[12] = 16.; + if (zvalue < 130.) + parSCurves[12] = 11.; + else + parSCurves[12] = 16.; parSCurves[13] = 190.; - parSCurves[14] = 6.; + if (zvalue < 130.) + parSCurves[14] = 10.; + else + parSCurves[14] = 6.; parSCurves[15] = 10.; // fitLeft->SetParLimits(0,90.,170.); parSCurves[18] = 170.; parSCurves[19] = 210.; parSCurves[20] = 3.; - parSCurves[21] = 15.; + parSCurves[21] = 20.; // fitLeft->SetParLimits(3,150.,220.); } @@ -506,10 +535,75 @@ // parSigma[17] = ?.; } + else if ((filename == "ProcessRawData-201502253-216") || (filename == "ProcessRawData-20150226-216")) { + // Sigma left. + parSigma[0] = 0.01; + parSigma[1] = 850.; + parSigma[2] = 5.; + + parSigma[3] = 0.001; + parSigma[4] = 1.; + + parSigma[5] = 800.; + parSigma[6] = 900.; + + // parSigma[7] = ?.; + // parSigma[8] = ?.; + + // Sigma right. + parSigma[9] = 0.01; + parSigma[10] = 850.; + parSigma[11] = 5.; + + parSigma[12] = 0.001; + parSigma[13] = 1.; + + parSigma[14] = 800.; + parSigma[15] = 900.; + + // parSigma[16] = ?.; + // parSigma[17] = ?.; + } + + return; +} + +// assignParInfoEta has the following parameters: +// - string filename, the filename of the measurement; +// - 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")) { + parEta[0] = 1.5; + parEta[1] = 140.; + parEta[2] = 5.; + parEta[3] = 0.; + + /* + parEta[4] = ; + parEta[5] = ; + + parEta[6] = ; + parEta[7] = ; + + parEta[8] = ; + parEta[9] = ; + + parEta[10] = ; + parEta[11] = ; + */ + } + return; } void fitSCurve(string edge, TGraph *graph, TF1 *f, Float_t parSCurves[], Int_t lengthParSCurves, Float_t *a, Float_t *mu, Float_t *sigma, Float_t *b, Float_t *ua, Float_t *umu, Float_t *usigma, Float_t *ub) { + // Set parameter names. + f->SetParName(0,"a"); + f->SetParName(1,"#mu"); + f->SetParName(2,"#sigma"); + f->SetParName(3,"b"); + // Set parameters and parameter limits. if (edge == "right") { f->SetParameter(0,parSCurves[0]); @@ -521,7 +615,7 @@ f->SetParLimits(2,parSCurves[8],parSCurves[9]); // f->SetParLimits(3,parSCurves[10],parSCurves[11]); } - else if (edge == "left") { + else if ((edge == "left") && (lengthParSCurves>12)) { f->SetParameter(0,parSCurves[12]); f->SetParameter(1,parSCurves[13]); f->SetParameter(2,parSCurves[14]); @@ -552,6 +646,11 @@ } void fitSigma(string edge, TGraph *graph, TF1 *f, Float_t parSigma[], Int_t lengthParSigma, Float_t *q0, Float_t *q1, Float_t *q2, Float_t *uq0, Float_t *uq1, Float_t *uq2) { + // Set parameter names. + f->SetParName(0,"{q}_0"); + f->SetParName(1,"{q}_1"); + f->SetParName(2,"{q}_2"); + // Set parameters and parameter limits. if (edge == "left") { f->SetParameter(0,parSigma[0]); diff --git a/Software/Tools/Style.C b/Software/Tools/Style.C index 2f409f7..5777485 100644 --- a/Software/Tools/Style.C +++ b/Software/Tools/Style.C @@ -507,7 +507,7 @@ func->Draw("SAME"); func->SetLineWidth(2); func->SetLineStyle(1); - func->SetLineColor(2); + func->SetLineColor(kMagenta); gPad->Modified(); canvas->Update(); canvas->Write();