CMS 3D CMS Logo

ApvLatencyAlgorithm Class Reference

Author:
M.
More...

#include <DQM/SiStripCommissioningAnalysis/interface/ApvLatencyAlgorithm.h>

Inheritance diagram for ApvLatencyAlgorithm:

CommissioningAlgorithm

List of all members.

Public Member Functions

 ApvLatencyAlgorithm (ApvLatencyAnalysis *const )
const Histohisto () const
virtual ~ApvLatencyAlgorithm ()

Private Member Functions

void analyse ()
 Performs histogram anaylsis.
 ApvLatencyAlgorithm ()
void extract (const std::vector< TH1 * > &)
 Extracts and organises histograms.

Private Attributes

Histo histo_
 APV latency histo.


Detailed Description

Author:
M.

Wingham, R.Bainbridge Algorithm for APV latency scan.

Definition at line 15 of file ApvLatencyAlgorithm.h.


Constructor & Destructor Documentation

ApvLatencyAlgorithm::ApvLatencyAlgorithm ( ApvLatencyAnalysis * const  anal  ) 

Definition at line 14 of file ApvLatencyAlgorithm.cc.

00015   : CommissioningAlgorithm(anal),
00016     histo_(0,"")
00017 {;}

virtual ApvLatencyAlgorithm::~ApvLatencyAlgorithm (  )  [inline, virtual]

Definition at line 21 of file ApvLatencyAlgorithm.h.

00021 {;}

ApvLatencyAlgorithm::ApvLatencyAlgorithm (  )  [inline, private]

Definition at line 27 of file ApvLatencyAlgorithm.h.

00027 {;}


Member Function Documentation

void ApvLatencyAlgorithm::analyse (  )  [private, virtual]

Performs histogram anaylsis.

Implements CommissioningAlgorithm.

Definition at line 62 of file ApvLatencyAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), count, histo(), histo_, combine::histos, k, ApvLatencyAnalysis::latency_, sistrip::mlCommissioning_, sistrip::nullPtr_, python::multivaluedict::sort(), funct::sqrt(), and tmp.

00062                                   { 
00063 
00064   if ( !anal() ) {
00065     edm::LogWarning(mlCommissioning_)
00066       << "[ApvLatencyAlgorithm::" << __func__ << "]"
00067       << " NULL pointer to base Analysis object!";
00068     return; 
00069   }
00070 
00071   CommissioningAnalysis* tmp = const_cast<CommissioningAnalysis*>( anal() );
00072   ApvLatencyAnalysis* anal = dynamic_cast<ApvLatencyAnalysis*>( tmp );
00073   if ( !anal ) {
00074     edm::LogWarning(mlCommissioning_)
00075       << "[ApvLatencyAlgorithm::" << __func__ << "]"
00076       << " NULL pointer to derived Analysis object!";
00077     return; 
00078   }
00079 
00080   // was in deprecated()
00081 
00082   std::vector<const TProfile*> histos; 
00083   std::vector<unsigned short> monitorables;
00084 
00085   // was in analysis()
00086   
00087   histos.clear();
00088   histos.push_back( const_cast<const TProfile*>( dynamic_cast<TProfile*>(histo_.first) ) );
00089   if ( !histos[0] ) {
00090     anal->addErrorCode(sistrip::nullPtr_);
00091     return;
00092   }
00093   
00094   monitorables.clear();
00095 
00096   //LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]";
00097   
00098   //extract root histogram
00099   //check 
00100   if (histos.size() != 1) { 
00101     //     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."; 
00102     monitorables.push_back(0);
00103     return; 
00104   }
00105   const TProfile* histo = histos[0];
00106 
00107   //monitorable
00108   unsigned short latency;
00109 
00110   std::vector<unsigned short> binContent; binContent.reserve((unsigned short)histo->GetNbinsX()); binContent.resize((unsigned short)histo->GetNbinsX(), 0);
00111 
00112   for (unsigned short k = 0; k < (unsigned short)histo->GetNbinsX(); k++) { // k is bin number
00113 
00114     //fill std::vector with histogram contents
00115     binContent.push_back((unsigned int)(histo->GetBinContent(k)));}
00116 
00117   //calculate median
00118   
00119   sort(binContent.begin(), binContent.end());
00120  
00121   //calculate mean and mean2 of the readout within cutoffs
00122  
00123   float meanNoise = 0.;//M.W method
00124   float mean2Noise = 0.;
00125  
00126   for (unsigned short k = (unsigned short)(binContent.size()*.1); k < (unsigned short)(binContent.size()*.9); k++) {
00127     meanNoise += binContent[k];
00128     mean2Noise += binContent[k]*binContent[k];;
00129   }
00130  
00131   meanNoise = meanNoise * binContent.size() * 0.8;
00132   mean2Noise = mean2Noise * binContent.size() * 0.8;
00133   float sigmaNoise = sqrt(fabs(meanNoise*meanNoise - mean2Noise));
00134  
00135   //loop to look for signal > 5* sigma_noise
00136   unsigned short count = 0;
00137   unsigned short maxlatency = 0;
00138   unsigned int maxhits = 0;
00139  
00140   for (unsigned short k = 1; k < ((unsigned short)histo->GetNbinsX() + 1); k++) { // k is bin number
00141     if (histo->GetBinContent((Int_t)k) > maxhits) maxlatency = k - 1;
00142     if ((float)histo->GetBinContent((Int_t)k) > (meanNoise + 5 * sigmaNoise)) { 
00143       latency = k - 1; count++;
00144     }
00145   }
00146  
00147   if (!count) {
00148     //   LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]: Warning: no signal found > mean + 5*sigma(noise). Returning latency of highest number of recorded hits.";
00149     latency = maxlatency;
00150   }
00151  
00152   if (count > 1) {
00153     //    LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]: Warning: more than one signal found > mean + 5*sigma(noise). Returning latency of highest number of recorded hits.";
00154     latency = maxlatency;
00155   }
00156 
00157   //set monitorables
00158   monitorables.clear();
00159   monitorables.push_back(latency);
00160 
00161   anal->latency_ = monitorables[0];
00162   
00163 }

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_.

00021                                                                  { 
00022 
00023   if ( !anal() ) {
00024     edm::LogWarning(mlCommissioning_)
00025       << "[ApvLatencyAlgorithm::" << __func__ << "]"
00026       << " NULL pointer to Analysis object!";
00027     return; 
00028   }
00029   
00030   // Check
00031   if ( histos.size() != 1 ) {
00032     anal()->addErrorCode(sistrip::numberOfHistos_);
00033   }
00034   
00035   // Extract FED key from histo title
00036   if ( !histos.empty() ) { anal()->fedKey( extractFedKey( histos.front() ) ); }
00037   
00038   // Extract histograms
00039   std::vector<TH1*>::const_iterator ihis = histos.begin();
00040   for ( ; ihis != histos.end(); ihis++ ) {
00041     
00042     // Check for NULL pointer
00043     if ( !(*ihis) ) { continue; }
00044     
00045     // Check name
00046     SiStripHistoTitle title( (*ihis)->GetName() );
00047     if ( title.runType() != sistrip::APV_LATENCY ) {
00048       anal()->addErrorCode(sistrip::unexpectedTask_);
00049       continue;
00050     }
00051     
00052     // Extract timing histo
00053     histo_.first = *ihis;
00054     histo_.second = (*ihis)->GetName();
00055     
00056   }
00057  
00058 }

const ApvLatencyAlgorithm::Histo & ApvLatencyAlgorithm::histo (  )  const [inline]

Definition at line 40 of file ApvLatencyAlgorithm.h.

References histo_.

Referenced by analyse().

00040 { return histo_; }


Member Data Documentation

Histo ApvLatencyAlgorithm::histo_ [private]

APV latency histo.

Definition at line 36 of file ApvLatencyAlgorithm.h.

Referenced by analyse(), extract(), and histo().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:14:46 2009 for CMSSW by  doxygen 1.5.4