diff --git a/config/LecroyScope_v12.config b/config/LecroyScope_v12.config index f850064..a08deaf 100644 --- a/config/LecroyScope_v12.config +++ b/config/LecroyScope_v12.config @@ -9,5 +9,5 @@ z_DUT -15, -12, -9, -6, -3, 0, 3, 6, 9, 12 3 +. 0.05 0.15 0. 0. LP2+G40 0. 4 +. 0.05 0.15 0. 0. LP2+G40 0. 5 +. 0.05 0.15 0. 0. LP2+G40 0. -6 +. 0.05 0.15 0. 0. LP2+G40 0. -7 +. 0.05 0.15 0. 0. LP2+G40 0. \ No newline at end of file +6 + 0.05 0.15 0. 0. Re+G40 0. +7 +. 0.05 0.15 0. 0. LP2+G40 0. diff --git a/include/DatAnalyzer.hh b/include/DatAnalyzer.hh index 7350563..ac79bb9 100644 --- a/include/DatAnalyzer.hh +++ b/include/DatAnalyzer.hh @@ -9,6 +9,7 @@ // SYS includes #include #include +#include // ROOT INCLUDES #include "TFile.h" @@ -70,6 +71,7 @@ class DatAnalyzer { virtual void Analyze(); float GetPulseIntegral(float *a, float *t, unsigned int i_st, unsigned int i_stop); //returns charge in pC asssuming 50 Ohm termination + int GetMinIndex(float* array); unsigned int GetIdxClosest(float value, float* v, unsigned int i_st, int direction=+1); unsigned int GetIdxFirstCross(float value, float* v, unsigned int i_st, int direction=+1); void AnalyticalPolinomialSolver(unsigned int Np, float* in_x, float* in_y, unsigned int deg, float* &out_coeff, float* err = 0); diff --git a/setup_cmslpc_python3.sh b/setup_cmslpc_python3.sh new file mode 100755 index 0000000..d63c6d6 --- /dev/null +++ b/setup_cmslpc_python3.sh @@ -0,0 +1,15 @@ +#!/bin/bash +echo Setting up CMS TimingDAQ. + +source /cvmfs/sft.cern.ch/lcg/releases/LCG_103/Python/3.9.12/x86_64-ubuntu2004-gcc9-opt/Python-env.sh +source /cvmfs/sft.cern.ch/lcg/releases/LCG_103/ROOT/6.28.00/x86_64-ubuntu2004-gcc9-opt/ROOT-env.sh +source /cvmfs/sft.cern.ch/lcg/releases/LCG_103/scipy/1.8.0/x86_64-ubuntu2004-gcc9-opt/scipy-env.sh + + +# source /cvmfs/sft.cern.ch/lcg/releases/LCG_88/gcc/4.9.3/x86_64-slc6/setup.sh +# source /cvmfs/sft.cern.ch/lcg/releases/LCG_96python3/Python/3.6.5/x86_64-slc6-gcc8-opt/Python-env.sh +# source /cvmfs/sft.cern.ch/lcg/releases/LCG_88/ROOT/6.08.06/x86_64-slc6-gcc49-opt/bin/thisroot.sh + +# source /cvmfs/sft.cern.ch/lcg/releases/LCG_96python3/Python/3.6.5/x86_64-slc6-gcc8-opt/Python-env.sh +# source /cvmfs/sft.cern.ch/lcg/releases/LCG_88/ROOT/6.08.06/x86_64-slc6-gcc49-opt/ROOT-env.sh +# source /cvmfs/sft.cern.ch/lcg/releases/LCG_88/scipy/0.18.1/x86_64-slc6-gcc49-opt/scipy-env.sh diff --git a/src/DatAnalyzer.cc b/src/DatAnalyzer.cc index dc15d9f..d9bc2c9 100644 --- a/src/DatAnalyzer.cc +++ b/src/DatAnalyzer.cc @@ -263,11 +263,16 @@ void DatAnalyzer::Analyze(){ /******************************* // -------------- Do linear fit ********************************/ - if( config->channels[i].algorithm.Contains("Re") ) { - unsigned int i_min = GetIdxFirstCross(config->channels[i].re_bounds[0]*amp, channel[i], idx_min, -1); - unsigned int i_max = GetIdxFirstCross(config->channels[i].re_bounds[1]*amp, channel[i], i_min, +1); + if(config->channels[i].algorithm.Contains("Re") ) { + // cout<channels[i].re_bounds[0]*amp, channel[i], idx_min, -1); config->channels[i].re_bounds[0]*amp + unsigned int i_min = GetIdxFirstCross(config->channels[i].re_bounds[0]*amp, channel[i], idx_min, -1); // GetIdxClosest(min(channel[i]), channel[i], idx_min, -1); + unsigned int i_max = GetIdxFirstCross(config->channels[i].re_bounds[1]*amp, channel[i], i_min , +1); float t_min = time[GetTimeIndex(i)][i_min]; float t_max = time[GetTimeIndex(i)][i_max]; + // cout<SetLineColor(2); @@ -278,14 +283,61 @@ void DatAnalyzer::Analyze(){ pulse->Fit("flinear"+name, opt); Re_slope = flinear->GetParameter(0); Re_b = flinear->GetParameter(1); - + // cout<<"==========================================="<channels[i].algorithm<constant_fraction ) { - var[Form("linear_RE_%d", (int)(100*f))][i] = (f*amp-Re_b)/Re_slope; + var[Form("linear_RE_%d", (int)(100*f))][i] = (f*amp-Re_b)/Re_slope + myTimeOffset; } + // cout<constant_threshold ) { - var[Form("linear_RE__%dmV", (int)(fabs(thr)))][i] = (thr-Re_b)/Re_slope; + var[Form("linear_RE__%dmV", (int)(fabs(thr)))][i] = (thr-Re_b)/Re_slope + myTimeOffset; + } + cout<<"==========================================="< 0 && i_evt < 10) { // Plotting the clock and the fitted line. + TCanvas * c = new TCanvas(Form("fit_results%d", i_evt), Form("fit_results%d", i_evt)); + // pulse->Draw(Form("channels[%d]:time", i), Form("event==%d", i_evt)); + const int bins = NUM_SAMPLES; // round(sizeof(channel[i])/sizeof(int)); + if (var[Form("linear_RE_%d", (int)(100*0.2))][i] == 0) { + cout<<"Clock time stamp is 0: "<<0.2*amp<<" "<SetLineColor(2); + line_plot->SetLineWidth(2); + clock_plot->SetLineColor(4); + clock_plot->SetLineWidth(2); + + clock_plot->Draw(""); + line_plot->Draw("same"); + + c->SaveAs(Form("/home/daq/ETROC2_Test_Stand/module_test_sw/analysis/FIT_PLOTS_TEST/fit_results%d.png", i_evt)); + delete clock_plot; + delete line_plot; + delete c; + + // } delete flinear; } @@ -1288,15 +1340,14 @@ unsigned int DatAnalyzer::GetIdxClosest(float value, float* v, unsigned int i_st unsigned int DatAnalyzer::GetIdxFirstCross(float value, float* v, unsigned int i_st, int direction) { unsigned int idx_end = direction>0 ? NUM_SAMPLES-1 : 0; + bool rising = value > v[i_st]? true : false; // Check if the given max value is greater than the given waveform amplitude at a given start time (i_st). - bool rising = value > v[i_st]? true : false; - + // if it is: the value of the waveform needs to rise and otherwise it doesn't need so the function will return the i_st. unsigned int i = i_st; - - while( i != idx_end ) { - if(rising && v[i] > value) break; - else if( !rising && v[i] < value) break; - i += direction; + while( (i != idx_end)) { // loop over the time bins + if(rising && v[i] > value) break; // check if the rising variable is true and if the waveform value is going higher than the given amplitude value. And stops the loop. + else if( !rising && v[i] < value) break; // check if the rising variable is false and if the waveform value is still lower than the given amplitude value. And stops the loop. + i += direction; // Otherwise it moves to the next time bin. } return i; @@ -1437,6 +1488,21 @@ int DatAnalyzer::TimeOverThreshold(Interpolator *voltage, double tThresh, double }; +int DatAnalyzer::GetMinIndex(float* array) { + float min = 10000; + int index = 10000; + for (int i = 0; i < (sizeof(array) / sizeof(array[0])); i++) { + if (array[i] < min) { + min = array[i]; + cout<