CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ApvLatencyAlgorithm Class Reference

Algorithm for APV latency scan. More...

#include <ApvLatencyAlgorithm.h>

Inheritance diagram for ApvLatencyAlgorithm:
CommissioningAlgorithm

Public Member Functions

 ApvLatencyAlgorithm (const edm::ParameterSet &pset, ApvLatencyAnalysis *const )
 
const Histohisto () const
 
 ~ApvLatencyAlgorithm () override
 
- Public Member Functions inherited from CommissioningAlgorithm
void analysis (const std::vector< TH1 * > &)
 
 CommissioningAlgorithm (CommissioningAnalysis *const )
 
 CommissioningAlgorithm ()
 
virtual ~CommissioningAlgorithm ()
 

Private Member Functions

void analyse () override
 
 ApvLatencyAlgorithm ()
 
void extract (const std::vector< TH1 * > &) override
 

Private Attributes

Histo histo_
 

Additional Inherited Members

- Public Types inherited from CommissioningAlgorithm
typedef std::pair< TH1 *, std::string > Histo
 
- Protected Member Functions inherited from CommissioningAlgorithm
CommissioningAnalysis *const anal () const
 
uint32_t extractFedKey (const TH1 *const )
 

Detailed Description

Algorithm for APV latency scan.

Author
M. Wingham, R.Bainbridge

Definition at line 16 of file ApvLatencyAlgorithm.h.

Constructor & Destructor Documentation

ApvLatencyAlgorithm::ApvLatencyAlgorithm ( const edm::ParameterSet pset,
ApvLatencyAnalysis * const  anal 
)

Definition at line 14 of file ApvLatencyAlgorithm.cc.

15  : CommissioningAlgorithm(anal),
16  histo_(nullptr,"")
17 {;}
ApvLatencyAlgorithm::~ApvLatencyAlgorithm ( )
inlineoverride

Definition at line 22 of file ApvLatencyAlgorithm.h.

References histo().

22 {;}
ApvLatencyAlgorithm::ApvLatencyAlgorithm ( )
inlineprivate

Definition at line 28 of file ApvLatencyAlgorithm.h.

References analyse(), and extract().

28 {;}

Member Function Documentation

void ApvLatencyAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaylsis.

Implements CommissioningAlgorithm.

Definition at line 62 of file ApvLatencyAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), KineDebug3::count(), histo(), histo_, plotFactory::histos, gen::k, hcaltpdigi_cfi::latency, ApvLatencyAnalysis::latency_, sistrip::mlCommissioning_, sistrip::nullPtr_, mathSSE::sqrt(), and tmp.

Referenced by ApvLatencyAlgorithm().

62  {
63 
64  if ( !anal() ) {
66  << "[ApvLatencyAlgorithm::" << __func__ << "]"
67  << " NULL pointer to base Analysis object!";
68  return;
69  }
70 
72  ApvLatencyAnalysis* anal = dynamic_cast<ApvLatencyAnalysis*>( tmp );
73  if ( !anal ) {
75  << "[ApvLatencyAlgorithm::" << __func__ << "]"
76  << " NULL pointer to derived Analysis object!";
77  return;
78  }
79 
80  // was in deprecated()
81 
82  std::vector<const TProfile*> histos;
83  std::vector<unsigned short> monitorables;
84 
85  // was in analysis()
86 
87  histos.clear();
88  histos.push_back( const_cast<const TProfile*>( dynamic_cast<TProfile*>(histo_.first) ) );
89  if ( !histos[0] ) {
91  return;
92  }
93 
94  monitorables.clear();
95 
96  //LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]";
97 
98  //extract root histogram
99  //check
100  if (histos.size() != 1) {
101  // 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.";
102  monitorables.push_back(0);
103  return;
104  }
105  const TProfile* histo = histos[0];
106 
107  //monitorable
108  unsigned short latency;
109 
110  std::vector<unsigned short> binContent; binContent.reserve((unsigned short)histo->GetNbinsX()); binContent.resize((unsigned short)histo->GetNbinsX(), 0);
111 
112  for (unsigned short k = 0; k < (unsigned short)histo->GetNbinsX(); k++) { // k is bin number
113 
114  //fill std::vector with histogram contents
115  binContent.push_back((unsigned int)(histo->GetBinContent(k)));}
116 
117  //calculate median
118 
119  sort(binContent.begin(), binContent.end());
120 
121  //calculate mean and mean2 of the readout within cutoffs
122 
123  float meanNoise = 0.;//M.W method
124  float mean2Noise = 0.;
125 
126  for (unsigned short k = (unsigned short)(binContent.size()*.1); k < (unsigned short)(binContent.size()*.9); k++) {
127  meanNoise += binContent[k];
128  mean2Noise += binContent[k]*binContent[k];;
129  }
130 
131  meanNoise = meanNoise * binContent.size() * 0.8;
132  mean2Noise = mean2Noise * binContent.size() * 0.8;
133  float sigmaNoise = sqrt(fabs(meanNoise*meanNoise - mean2Noise));
134 
135  //loop to look for signal > 5* sigma_noise
136  unsigned short count = 0;
137  unsigned short maxlatency = 0;
138  unsigned int maxhits = 0;
139 
140  for (unsigned short k = 1; k < ((unsigned short)histo->GetNbinsX() + 1); k++) { // k is bin number
141  if (histo->GetBinContent((Int_t)k) > maxhits) maxlatency = k - 1;
142  if ((float)histo->GetBinContent((Int_t)k) > (meanNoise + 5 * sigmaNoise)) {
143  latency = k - 1; count++;
144  }
145  }
146 
147  if (!count) {
148  // LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]: Warning: no signal found > mean + 5*sigma(noise). Returning latency of highest number of recorded hits.";
149  latency = maxlatency;
150  }
151 
152  if (count > 1) {
153  // LogDebug("Commissioning|Algorithm") << "[ApvLatencyAlgorithm::analysis]: Warning: more than one signal found > mean + 5*sigma(noise). Returning latency of highest number of recorded hits.";
154  latency = maxlatency;
155  }
156 
157  //set monitorables
158  monitorables.clear();
159  monitorables.push_back(latency);
160 
161  anal->latency_ = monitorables[0];
162 
163 }
const Histo & histo() const
static const char mlCommissioning_[]
T sqrt(T t)
Definition: SSEVec.h:18
virtual void addErrorCode(const std::string &error)
Analysis for APV latency scan.
int k[5][pyjets_maxn]
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Abstract base for derived classes that provide analysis of commissioning histograms.
latency
hardware algo
CommissioningAnalysis *const anal() const
static const char nullPtr_[]
void ApvLatencyAlgorithm::extract ( const std::vector< TH1 * > &  )
overrideprivatevirtual

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_, runGCPTkAlMap::title, and sistrip::unexpectedTask_.

Referenced by ApvLatencyAlgorithm().

21  {
22 
23  if ( !anal() ) {
25  << "[ApvLatencyAlgorithm::" << __func__ << "]"
26  << " NULL pointer to Analysis object!";
27  return;
28  }
29 
30  // Check
31  if ( histos.size() != 1 ) {
33  }
34 
35  // Extract FED key from histo title
36  if ( !histos.empty() ) { anal()->fedKey( extractFedKey( histos.front() ) ); }
37 
38  // Extract histograms
39  std::vector<TH1*>::const_iterator ihis = histos.begin();
40  for ( ; ihis != histos.end(); ihis++ ) {
41 
42  // Check for NULL pointer
43  if ( !(*ihis) ) { continue; }
44 
45  // Check name
46  SiStripHistoTitle title( (*ihis)->GetName() );
47  if ( title.runType() != sistrip::APV_LATENCY ) {
49  continue;
50  }
51 
52  // Extract timing histo
53  histo_.first = *ihis;
54  histo_.second = (*ihis)->GetName();
55 
56  }
57 
58 }
static const char unexpectedTask_[]
const uint32_t & fedKey() const
Utility class that holds histogram title.
static const char numberOfHistos_[]
static const char mlCommissioning_[]
uint32_t extractFedKey(const TH1 *const )
virtual void addErrorCode(const std::string &error)
CommissioningAnalysis *const anal() const
const ApvLatencyAlgorithm::Histo & ApvLatencyAlgorithm::histo ( ) const
inline

Definition at line 41 of file ApvLatencyAlgorithm.h.

References histo_.

Referenced by analyse(), and ~ApvLatencyAlgorithm().

41 { return histo_; }

Member Data Documentation

Histo ApvLatencyAlgorithm::histo_
private

APV latency histo

Definition at line 37 of file ApvLatencyAlgorithm.h.

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