20 targetGain_(pset.getParameter<double>(
"TargetGain"))
23 <<
"[PedestalsAlgorithm::" << __func__ <<
"]" 33 <<
"[OptoScanAlgorithm::" << __func__ <<
"]" 34 <<
" NULL pointer to Analysis object!";
39 if ( histos.size() != 12 ) {
47 std::vector<TH1*>::const_iterator ihis = histos.begin();
48 for ( ; ihis != histos.end(); ihis++ ) {
51 if ( !(*ihis) ) {
continue; }
73 bool baseline_rms =
false;
82 }
else if ( baseline_rms ) {
102 <<
"[OptoScanAlgorithm::" << __func__ <<
"]" 103 <<
" NULL pointer to base Analysis object!";
111 <<
"[OptoScanAlgorithm::" << __func__ <<
"]" 112 <<
" NULL pointer to derived Analysis object!";
117 for ( uint16_t igain = 0; igain < 4; igain++ ) {
120 TH1* base_his =
histos_[igain][0].first;
121 TH1* peak_his =
histos_[igain][1].first;
122 TH1* noise_his =
histos_[igain][2].first;
139 TProfile* base_histo =
dynamic_cast<TProfile*
>(base_his);
145 TProfile* peak_histo =
dynamic_cast<TProfile*
>(peak_his);
151 TProfile* noise_histo =
dynamic_cast<TProfile*
>(noise_his);
152 if ( !noise_histo ) {
158 uint16_t
nbins =
static_cast<uint16_t
>( peak_histo->GetNbinsX() );
159 if ( static_cast<uint16_t>( base_histo->GetNbinsX() ) != nbins ) {
161 if ( static_cast<uint16_t>( base_histo->GetNbinsX() ) < nbins ) {
162 nbins =
static_cast<uint16_t
>( base_histo->GetNbinsX() );
167 std::vector<float> peak_contents(0);
168 std::vector<float> peak_errors(0);
169 std::vector<float> peak_entries(0);
170 std::vector<float> base_contents(0);
171 std::vector<float> base_errors(0);
172 std::vector<float> base_entries(0);
173 std::vector<float> noise_contents(0);
174 std::vector<float> noise_errors(0);
175 std::vector<float> noise_entries(0);
184 for ( uint16_t ibin = 0; ibin <
nbins; ibin++ ) {
187 peak_contents.push_back( peak_histo->GetBinContent(ibin+1) );
188 peak_errors.push_back( peak_histo->GetBinError(ibin+1) );
189 peak_entries.push_back( peak_histo->GetBinEntries(ibin+1) );
190 if ( peak_entries[ibin] ) {
191 if ( peak_contents[ibin] > peak_max ) { peak_max = peak_contents[ibin]; }
192 if ( peak_contents[ibin] < peak_min && ibin ) { peak_min = peak_contents[ibin]; }
196 base_contents.push_back( base_histo->GetBinContent(ibin+1) );
197 base_errors.push_back( base_histo->GetBinError(ibin+1) );
198 base_entries.push_back( base_histo->GetBinEntries(ibin+1) );
199 if ( base_entries[ibin] ) {
200 if ( base_contents[ibin] > base_max ) { base_max = base_contents[ibin]; }
201 if ( base_contents[ibin] < base_min && ibin ) { base_min = base_contents[ibin]; }
205 noise_contents.push_back( noise_histo->GetBinContent(ibin+1) );
206 noise_errors.push_back( noise_histo->GetBinError(ibin+1) );
207 noise_entries.push_back( noise_histo->GetBinEntries(ibin+1) );
208 if ( noise_entries[ibin] ) {
209 if ( noise_contents[ibin] > noise_max ) { noise_max = noise_contents[ibin]; }
210 if ( noise_contents[ibin] < noise_min && ibin ) { noise_min = noise_contents[ibin]; }
220 for ( uint16_t ibin = 0; ibin <
nbins; ibin++ ) {
221 if ( base_entries[ibin] ) {
222 zero_light_level = base_contents[ibin];
223 zero_light_error = base_errors[ibin];
231 zero_light_thres = zero_light_level + 5. * zero_light_error;
233 std::stringstream ss;
240 float base_range = base_max - base_min;
243 float max = peak_max < base_max ? peak_max : base_max;
244 float min = peak_min > base_min ? peak_min : base_min;
245 float range = max -
min;
248 std::vector<bool> above_zero_light;
249 above_zero_light.resize(3,
true);
257 uint16_t peak_bin = 0;
258 uint16_t base_bin = 0;
259 uint16_t low_bin = 0;
260 for ( uint16_t ibin = 0; ibin <
nbins; ibin++ ) {
263 if ( base_entries[ibin] ) {
264 above_zero_light.erase( above_zero_light.begin() );
265 if ( base_contents[ibin] > zero_light_thres ) { above_zero_light.push_back(
true ); }
266 else { above_zero_light.push_back(
false ); }
267 if ( above_zero_light.size() != 3 ) { above_zero_light.resize(3,
false); }
271 if ( peak_entries[ibin] &&
272 peak_contents[ibin] > ( min + 0.2*range ) &&
273 peak_contents[ibin] < ( min + 0.8*range ) ) {
274 if ( !peak_bin ) { peak_bin = ibin; }
275 if ( ( ibin - peak_bin ) < 10 ) {
276 peak_high.
add( ibin, peak_contents[ibin] );
280 if ( base_entries[ibin] &&
281 base_contents[ibin] > ( min + 0.2*range ) &&
282 base_contents[ibin] < ( min + 0.8*range ) ) {
283 if ( !base_bin ) { base_bin = ibin; }
284 if ( ( ibin - base_bin ) < 10 ) {
285 base_high.
add( ibin, base_contents[ibin] );
289 if ( base_entries[ibin] &&
291 base_contents[ibin] > ( base_min + 0.2*base_range ) &&
292 base_contents[ibin] < ( base_min + 0.6*base_range ) ) {
293 if ( !low_bin ) { low_bin = ibin; }
294 if ( ( ibin - low_bin ) < 10 ) {
295 base_low.
add( ibin, base_contents[ibin] );
302 float mid = min + 0.5*range;
305 peak_high.
fit( peak_params );
306 base_high.
fit( base_params );
311 if ( peak_params.
b_ > 0. ) {
312 peak_pos = ( mid - peak_params.
a_ ) / peak_params.
b_;
314 if ( base_params.
b_ > 0. ) {
315 base_pos = ( mid - base_params.
a_ ) / base_params.
b_;
319 width = base_pos - peak_pos;
324 base_low.
fit( low_params );
326 if ( low_params.
b_ > 0. ) {
327 lift_off = ( zero_light_level - low_params.
a_ ) / low_params.
b_;
333 if ( low_params.
b_ > 0. ) {
339 anal->
bias_[igain] =
static_cast<uint16_t
>( lift_off ) + 2;
344 anal->
liftOff_[igain] = 0.45 * lift_off;
349 anal->
threshold_[igain] = 0.45 * ( lift_off - width/2. );
362 bin_number = (uint16_t) (lift_off + width / 3.);
365 if ( bin_number < noise_contents.size() ) {
366 anal->
linkNoise_[igain] = noise_contents[bin_number];
387 for ( uint16_t igain = 0; igain < 4; igain++ ) {
393 if ( fabs( anal->
measGain_[igain] - target_gain ) < diff_in_gain ) {
395 diff_in_gain = fabs( anal->
measGain_[igain] - target_gain );
408 const uint16_t& digital_level )
const {
409 if ( gain <= 3 && digital_level <= 1 ) {
return histos_[
gain][digital_level]; }
410 else {
return Histo(0,
""); }
Histogram-based analysis for opto bias/gain scan.
std::vector< std::vector< Histo > > histos_
static const char unexpectedTask_[]
const uint32_t & fedKey() const
Histo histo(const uint16_t &gain, const uint16_t &digital_level) const
Utility class that holds histogram title.
std::pair< TH1 *, std::string > Histo
static const char numberOfHistos_[]
static const char unexpectedExtraInfo_[]
static const uint16_t valid_
void extract(const std::vector< TH1 * > &)
static const char numberOfBins_[]
static const float fedAdcGain_
static const char mlCommissioning_[]
uint32_t extractFedKey(const TH1 *const )
static const uint16_t maximum_
virtual void addErrorCode(const std::string &error)
void add(const float &value_x, const float &value_y)
static const uint16_t defaultBiasSetting_
static const uint16_t invalid_
std::vector< std::vector< double > > tmp
Abstract base for derived classes that provide analysis of commissioning histograms.
static const uint16_t defaultGainSetting_
void fit(Params &fit_params)
static const char unexpectedBinNumber_[]
CommissioningAnalysis *const anal() const
static const char nullPtr_[]
static const char invalidZeroLightLevel_[]