12 using namespace sistrip;
27 <<
"[FedTimingAlgorithm::" << __func__ <<
"]"
28 <<
" NULL pointer to Analysis object!";
33 if ( histos.size() != 1 ) {
41 std::vector<TH1*>::const_iterator ihis = histos.begin();
42 for ( ; ihis != histos.end(); ihis++ ) {
45 if ( !(*ihis) ) {
continue; }
56 histo_.second = (*ihis)->GetName();
68 <<
"[FedTimingAlgorithm::" << __func__ <<
"]"
69 <<
" NULL pointer to base Analysis object!";
77 <<
"[FedTimingAlgorithm::" << __func__ <<
"]"
78 <<
" NULL pointer to derived Analysis object!";
88 uint16_t non_zero = 0;
91 uint16_t
nbins =
static_cast<uint16_t
>(
histo_.first->GetNbinsX() );
92 std::vector<float> bin_contents;
93 std::vector<float> bin_errors;
94 std::vector<float> bin_entries;
95 bin_contents.reserve( nbins );
96 bin_errors.reserve( nbins );
97 bin_entries.reserve( nbins );
98 for ( uint16_t ibin = 0; ibin <
nbins; ibin++ ) {
99 bin_contents.push_back(
histo_.first->GetBinContent(ibin+1) );
100 bin_errors.push_back(
histo_.first->GetBinError(ibin+1) );
102 if ( bin_entries[ibin] ) {
103 if ( bin_contents[ibin] > max ) { max = bin_contents[ibin]; }
104 if ( bin_contents[ibin] < min ) { min = bin_contents[ibin]; }
110 if ( bin_contents.size() < 100 ) {
116 float range = max -
min;
126 std::vector<float> tick;
127 std::vector<float>
base;
128 for ( uint16_t ibin = 0; ibin <
nbins; ibin++ ) {
129 if ( bin_entries[ibin] ) {
130 if ( bin_contents[ibin] < threshold ) {
131 base.push_back( bin_contents[ibin] );
133 tick.push_back( bin_contents[ibin] );
143 sort( tick.begin(), tick.end() );
144 sort( base.begin(), base.end() );
145 if ( !tick.empty() ) { tickmark = tick[ tick.size()%2 ? tick.size()/2 : tick.size()/2 ]; }
146 if ( !base.empty() ) { baseline = base[ base.size()%2 ? base.size()/2 : base.size()/2 ]; }
149 if ( (tickmark-baseline) < 50. ) {
157 for ( uint16_t ibin = 0; ibin < base.size(); ibin++ ) {
159 mean2 += base[ibin] * base[ibin];
161 if ( !base.empty() ) {
162 mean = mean / base.size();
163 mean2 = mean2 / base.size();
168 float baseline_rms = 0.;
169 if ( mean2 > mean*mean ) { baseline_rms =
sqrt( mean2 - mean*mean ); }
170 else { baseline_rms = 0.; }
174 std::map<uint16_t,float>
edges;
175 for ( uint16_t ibin = 1; ibin < nbins-1; ibin++ ) {
176 if ( bin_entries[ibin+1] &&
177 bin_entries[ibin-1] ) {
178 float derivative = bin_contents[ibin+1] - bin_contents[ibin-1];
179 if ( derivative > 5.*baseline_rms ) {
191 std::map<uint16_t,float>::iterator
iter = edges.begin();
192 while ( !found && iter != edges.end() ) {
196 for ( uint16_t
ii = 0;
ii < 50;
ii++ ) {
197 uint16_t
bin = iter->first +
ii;
200 float temp_deriv = 0;
201 if ( static_cast<uint32_t>(bin) < 1 ||
202 static_cast<uint32_t
>(bin+1) >= nbins ) {
continue; }
203 temp_deriv = bin_contents[bin+1] - bin_contents[bin-1];
206 if ( temp_deriv > max_deriv ) {
207 max_deriv = temp_deriv;
212 if (
ii > 10 &&
ii < 40 && bin_entries[bin] &&
213 bin_contents[bin] < baseline + 5*baseline_rms ) { valid =
false; }
218 if ( valid ) { found =
true; }
229 if ( !edges.empty() ) {
230 anal->
time_ = deriv_bin;
232 anal->
base_ = baseline;
233 anal->
peak_ = tickmark;
234 anal->
height_ = tickmark - baseline;
237 anal->
base_ = baseline;
238 anal->
peak_ = tickmark;
239 anal->
height_ = tickmark - baseline;
static const char unexpectedTask_[]
const uint32_t & fedKey() const
Derivative< X, A >::type derivative(const A &_)
Utility class that holds histogram title.
static const char numberOfHistos_[]
static const char numberOfBins_[]
static const char missingTickMark_[]
void extract(const std::vector< TH1 * > &)
static const char mlCommissioning_[]
uint32_t extractFedKey(const TH1 *const )
virtual void addErrorCode(const std::string &error)
Analysis for timing run using APV tick marks.
static const uint16_t invalid_
static const char smallDataRange_[]
std::vector< std::vector< double > > tmp
Abstract base for derived classes that provide analysis of commissioning histograms.
CommissioningAnalysis *const anal() const
static const char nullPtr_[]