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() [1/2]

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

Definition at line 14 of file ApvLatencyAlgorithm.cc.

15  : CommissioningAlgorithm(anal), histo_(nullptr, "") {
16  ;
17 }
CommissioningAnalysis *const anal() const

◆ ~ApvLatencyAlgorithm()

ApvLatencyAlgorithm::~ApvLatencyAlgorithm ( )
inlineoverride

Definition at line 20 of file ApvLatencyAlgorithm.h.

20 { ; }

◆ ApvLatencyAlgorithm() [2/2]

ApvLatencyAlgorithm::ApvLatencyAlgorithm ( )
inlineprivate

Definition at line 25 of file ApvLatencyAlgorithm.h.

25 { ; }

Member Function Documentation

◆ analyse()

void ApvLatencyAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaylsis.

Implements CommissioningAlgorithm.

Definition at line 61 of file ApvLatencyAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), submitPVResolutionJobs::count, histo(), histo_, combine::histos, dqmdumpme::k, config_102169_raw_cff::latency, sistrip::mlCommissioning_, sistrip::nullPtr_, jetUpdater_cfi::sort, mathSSE::sqrt(), and createJobs::tmp.

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

◆ extract()

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

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

◆ histo()

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

Definition at line 36 of file ApvLatencyAlgorithm.h.

References histo_.

Referenced by analyse().

36 { return histo_; }

Member Data Documentation

◆ histo_

Histo ApvLatencyAlgorithm::histo_
private

APV latency histo

Definition at line 33 of file ApvLatencyAlgorithm.h.

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