Algorithm for APV latency scan. More...
#include <ApvLatencyAlgorithm.h>
Public Member Functions | |
ApvLatencyAlgorithm (const edm::ParameterSet &pset, ApvLatencyAnalysis *const ) | |
const Histo & | histo () const |
virtual | ~ApvLatencyAlgorithm () |
Private Member Functions | |
void | analyse () |
ApvLatencyAlgorithm () | |
void | extract (const std::vector< TH1 * > &) |
Private Attributes | |
Histo | histo_ |
Algorithm for APV latency scan.
Definition at line 16 of file ApvLatencyAlgorithm.h.
ApvLatencyAlgorithm::ApvLatencyAlgorithm | ( | const edm::ParameterSet & | pset, |
ApvLatencyAnalysis * const | anal | ||
) |
Definition at line 14 of file ApvLatencyAlgorithm.cc.
: CommissioningAlgorithm(anal), histo_(0,"") {;}
virtual ApvLatencyAlgorithm::~ApvLatencyAlgorithm | ( | ) | [inline, virtual] |
Definition at line 22 of file ApvLatencyAlgorithm.h.
{;}
ApvLatencyAlgorithm::ApvLatencyAlgorithm | ( | ) | [inline, private] |
Definition at line 28 of file ApvLatencyAlgorithm.h.
{;}
void ApvLatencyAlgorithm::analyse | ( | ) | [private, virtual] |
Performs histogram anaylsis.
Implements CommissioningAlgorithm.
Definition at line 62 of file ApvLatencyAlgorithm.cc.
References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), prof2calltree::count, histo(), histo_, mergeVDriftHistosByStation::histos, gen::k, ApvLatencyAnalysis::latency_, sistrip::mlCommissioning_, sistrip::nullPtr_, python::multivaluedict::sort(), mathSSE::sqrt(), and tmp.
{ if ( !anal() ) { edm::LogWarning(mlCommissioning_) << "[ApvLatencyAlgorithm::" << __func__ << "]" << " NULL pointer to base Analysis object!"; return; } CommissioningAnalysis* tmp = const_cast<CommissioningAnalysis*>( anal() ); ApvLatencyAnalysis* anal = dynamic_cast<ApvLatencyAnalysis*>( tmp ); if ( !anal ) { edm::LogWarning(mlCommissioning_) << "[ApvLatencyAlgorithm::" << __func__ << "]" << " NULL pointer to derived Analysis object!"; return; } // was in deprecated() std::vector<const TProfile*> histos; std::vector<unsigned short> monitorables; // was in analysis() histos.clear(); histos.push_back( const_cast<const TProfile*>( dynamic_cast<TProfile*>(histo_.first) ) ); if ( !histos[0] ) { anal->addErrorCode(sistrip::nullPtr_); return; } monitorables.clear(); //LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]"; //extract root histogram //check if (histos.size() != 1) { // edm::LogWarning("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]: Requires \"const std::vector<const TH1F*>& \" argument to have size 1. Actual size: " << histos.size() << ". Monitorables set to 0."; monitorables.push_back(0); return; } const TProfile* histo = histos[0]; //monitorable unsigned short latency; std::vector<unsigned short> binContent; binContent.reserve((unsigned short)histo->GetNbinsX()); binContent.resize((unsigned short)histo->GetNbinsX(), 0); for (unsigned short k = 0; k < (unsigned short)histo->GetNbinsX(); k++) { // k is bin number //fill std::vector with histogram contents binContent.push_back((unsigned int)(histo->GetBinContent(k)));} //calculate median sort(binContent.begin(), binContent.end()); //calculate mean and mean2 of the readout within cutoffs float meanNoise = 0.;//M.W method float mean2Noise = 0.; for (unsigned short k = (unsigned short)(binContent.size()*.1); k < (unsigned short)(binContent.size()*.9); k++) { meanNoise += binContent[k]; mean2Noise += binContent[k]*binContent[k];; } meanNoise = meanNoise * binContent.size() * 0.8; mean2Noise = mean2Noise * binContent.size() * 0.8; float sigmaNoise = sqrt(fabs(meanNoise*meanNoise - mean2Noise)); //loop to look for signal > 5* sigma_noise unsigned short count = 0; unsigned short maxlatency = 0; unsigned int maxhits = 0; for (unsigned short k = 1; k < ((unsigned short)histo->GetNbinsX() + 1); k++) { // k is bin number if (histo->GetBinContent((Int_t)k) > maxhits) maxlatency = k - 1; if ((float)histo->GetBinContent((Int_t)k) > (meanNoise + 5 * sigmaNoise)) { latency = k - 1; count++; } } if (!count) { // LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]: Warning: no signal found > mean + 5*sigma(noise). Returning latency of highest number of recorded hits."; latency = maxlatency; } if (count > 1) { // LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]: Warning: more than one signal found > mean + 5*sigma(noise). Returning latency of highest number of recorded hits."; latency = maxlatency; } //set monitorables monitorables.clear(); monitorables.push_back(latency); anal->latency_ = monitorables[0]; }
void ApvLatencyAlgorithm::extract | ( | const std::vector< TH1 * > & | ) | [private, virtual] |
Extracts and organises histograms.
Implements CommissioningAlgorithm.
Definition at line 21 of file ApvLatencyAlgorithm.cc.
References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), sistrip::APV_LATENCY, CommissioningAlgorithm::extractFedKey(), CommissioningAnalysis::fedKey(), histo_, sistrip::mlCommissioning_, sistrip::numberOfHistos_, indexGen::title, and sistrip::unexpectedTask_.
{ if ( !anal() ) { edm::LogWarning(mlCommissioning_) << "[ApvLatencyAlgorithm::" << __func__ << "]" << " NULL pointer to Analysis object!"; return; } // Check if ( histos.size() != 1 ) { anal()->addErrorCode(sistrip::numberOfHistos_); } // Extract FED key from histo title if ( !histos.empty() ) { anal()->fedKey( extractFedKey( histos.front() ) ); } // Extract histograms std::vector<TH1*>::const_iterator ihis = histos.begin(); for ( ; ihis != histos.end(); ihis++ ) { // Check for NULL pointer if ( !(*ihis) ) { continue; } // Check name SiStripHistoTitle title( (*ihis)->GetName() ); if ( title.runType() != sistrip::APV_LATENCY ) { anal()->addErrorCode(sistrip::unexpectedTask_); continue; } // Extract timing histo histo_.first = *ihis; histo_.second = (*ihis)->GetName(); } }
const ApvLatencyAlgorithm::Histo & ApvLatencyAlgorithm::histo | ( | ) | const [inline] |
Definition at line 41 of file ApvLatencyAlgorithm.h.
References histo_.
Referenced by analyse().
{ return histo_; }
Histo ApvLatencyAlgorithm::histo_ [private] |
APV latency histo
Definition at line 37 of file ApvLatencyAlgorithm.h.