CMS 3D CMS Logo

ApvTimingHistograms.cc
Go to the documentation of this file.
8 #include "TProfile.h"
9 #include <iostream>
10 #include <sstream>
11 #include <iomanip>
12 
13 using namespace std;
14 using namespace sistrip;
15 
16 // -----------------------------------------------------------------------------
19  : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("ApvTimingParameters"), bei, sistrip::APV_TIMING) {
20  factory_ = unique_ptr<ApvTimingSummaryFactory>(new ApvTimingSummaryFactory);
21  LogTrace(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
22  << " Constructing object...";
23 }
24 
25 // -----------------------------------------------------------------------------
28  LogTrace(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
29  << " Destructing object...";
30 }
31 
32 // -----------------------------------------------------------------------------
35  LogTrace(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]";
36 
37  // Some initialisation
38  uint16_t valid = 0;
39  HistosMap::const_iterator iter;
40  Analyses::iterator ianal;
41  std::map<std::string, uint16_t> errors;
42 
43  // Clear map holding analysis objects
44  for (ianal = data().begin(); ianal != data().end(); ianal++) {
45  if (ianal->second) {
46  delete ianal->second;
47  }
48  }
49  data().clear();
50 
51  // Reset minimum / maximum delays
52  float time_min = 1. * sistrip::invalid_;
53  float time_max = -1. * sistrip::invalid_;
54  uint32_t device_min = sistrip::invalid_;
55  uint32_t device_max = sistrip::invalid_;
56 
57  // Iterate through map containing histograms
58  for (iter = histos().begin(); iter != histos().end(); iter++) {
59  // Check vector of histos is not empty
60  if (iter->second.empty()) {
61  edm::LogWarning(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
62  << " Zero histograms found!";
63  continue;
64  }
65 
66  // Retrieve pointers to histos
67  std::vector<TH1*> profs;
68  Histos::const_iterator ihis = iter->second.begin();
69  for (; ihis != iter->second.end(); ihis++) {
70  TProfile* prof = ExtractTObject<TProfile>().extract((*ihis)->me_);
71  if (prof) {
72  profs.push_back(prof);
73  }
74  }
75 
76  // Perform histo analysis
77  ApvTimingAnalysis* anal = new ApvTimingAnalysis(iter->first);
78  ApvTimingAlgorithm algo(this->pset(), anal);
79  algo.analysis(profs);
80  data()[iter->first] = anal;
81 
82  // Check if tick mark found
83  if (!anal->foundTickMark()) {
84  continue;
85  }
86 
87  // Find maximum time
88  if (anal->time() > time_max) {
89  time_max = anal->time();
90  device_max = iter->first;
91  }
92 
93  // Find minimum time
94  if (anal->time() < time_min) {
95  time_min = anal->time();
96  device_min = iter->first;
97  }
98  }
99 
100  // Adjust maximum (and minimum) delay(s) to find optimum sampling point(s)
101  if (time_max > sistrip::valid_ || time_max < -1. * sistrip::valid_) {
102  edm::LogWarning(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
103  << " Unable to set maximum time! Found unexpected value: " << time_max;
104 
105  } else {
106  SiStripFecKey min(device_min);
107  edm::LogVerbatim(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
108  << " Crate/FEC/Ring/CCU/module/channel: " << min.fecCrate() << "/" << min.fecSlot()
109  << "/" << min.fecRing() << "/" << min.ccuAddr() << "/" << min.ccuChan() << "/"
110  << min.lldChan() << " has minimum time for tick mark rising edge [ns]: " << time_min;
111 
112  SiStripFecKey max(device_max);
113  edm::LogVerbatim(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
114  << " Crate/FEC/Ring/CCU/module/channel: " << max.fecCrate() << "/" << max.fecSlot()
115  << "/" << max.fecRing() << "/" << max.ccuAddr() << "/" << max.ccuChan() << "/"
116  << max.lldChan() << " has maximum time for tick mark rising edge [ns]: " << time_max;
117 
118  edm::LogVerbatim(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
119  << " Difference b/w minimum and maximum times"
120  << " for tick mark rising edges [ns] is: " << (time_max - time_min);
121  }
122 
123  // Set reference time for all analysis objects
124  for (ianal = data().begin(); ianal != data().end(); ianal++) {
125  ApvTimingAnalysis* anal = dynamic_cast<ApvTimingAnalysis*>(ianal->second);
126  if (!anal) {
127  continue;
128  }
129  anal->refTime(time_max, this->pset().getParameter<int>("TargetDelay"));
130  if (anal->isValid()) {
131  valid++;
132  }
133  if (!anal->getErrorCodes().empty()) {
134  errors[anal->getErrorCodes()[0]]++;
135  }
136  }
137 
138  if (!histos().empty()) {
139  edm::LogVerbatim(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
140  << " Analyzed histograms for " << histos().size() << " FED channels, of which "
141  << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
142  } else {
143  edm::LogWarning(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
144  << " No histograms to analyze!";
145  }
146 
147  if (!histos().empty()) {
148  edm::LogVerbatim(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
149  << " Analyzed histograms for " << histos().size() << " FED channels, of which "
150  << valid << " (" << 100 * valid / histos().size() << "%) are valid.";
151  if (!errors.empty()) {
152  uint16_t count = 0;
153  std::stringstream ss;
154  ss << std::endl;
155  std::map<std::string, uint16_t>::const_iterator ii;
156  for (ii = errors.begin(); ii != errors.end(); ++ii) {
157  ss << " " << ii->first << ": " << ii->second << std::endl;
158  count += ii->second;
159  }
160  edm::LogWarning(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
161  << " Found " << count << " errors (" << 100 * count / histos().size()
162  << "%): " << ss.str();
163  }
164  } else {
165  edm::LogWarning(mlDqmClient_) << "[ApvTimingHistograms::" << __func__ << "]"
166  << " No histograms to analyze!";
167  }
168 }
MessageLogger.h
ApvTimingAlgorithm.h
sistrip::APV_TIMING
Definition: ConstantsForRunType.h:75
CommissioningHistograms::pset
const edm::ParameterSet & pset() const
Definition: CommissioningHistograms.h:163
min
T min(T a, T b)
Definition: MathUtil.h:58
edm
HLT enums.
Definition: AlignableModifier.h:19
MessageLogger_cfi.errors
errors
Definition: MessageLogger_cfi.py:18
ExtractTObject.h
ApvTimingHistograms::~ApvTimingHistograms
~ApvTimingHistograms() override
Definition: ApvTimingHistograms.cc:27
CommissioningHistograms::data
Analyses & data(bool getMaskedData=false)
Definition: CommissioningHistograms.cc:718
ExtractTObject
Definition: ExtractTObject.h:9
sistrip::mlDqmClient_
static const char mlDqmClient_[]
Definition: ConstantsForLogger.h:19
validateGeometry_cfg.valid
valid
Definition: validateGeometry_cfg.py:21
sistrip::valid_
static const uint16_t valid_
Definition: Constants.h:17
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
cmsdt::algo
algo
Definition: constants.h:164
debug
#define debug
Definition: HDRShower.cc:19
dqm::legacy::DQMStore
Definition: DQMStore.h:727
errors
Definition: errors.py:1
CommissioningHistograms::factory_
std::unique_ptr< Factory > factory_
Definition: CommissioningHistograms.h:129
SiStripFecKey
Utility class that identifies a position within the strip tracker control structure,...
Definition: SiStripFecKey.h:45
edm::LogWarning
Definition: MessageLogger.h:141
SiStripConstants.h
edm::ParameterSet
Definition: ParameterSet.h:36
ApvTimingHistograms::histoAnalysis
void histoAnalysis(bool debug) override
Definition: ApvTimingHistograms.cc:34
ParameterSet
Definition: Functions.h:16
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
ApvTimingAnalysis
Analysis for timing run using APV tick marks.
Definition: ApvTimingAnalysis.h:15
ApvTimingAlgorithm
Analysis for timing run using APV tick marks.
Definition: ApvTimingAlgorithm.h:16
edm::LogVerbatim
Definition: MessageLogger.h:297
ExtractTObject::extract
static T * extract(MonitorElement *me)
Definition: ExtractTObject.cc:21
sistrip::invalid_
static const uint16_t invalid_
Definition: Constants.h:16
ApvTimingHistograms::ApvTimingHistograms
ApvTimingHistograms(const edm::ParameterSet &pset, DQMStore *)
Definition: ApvTimingHistograms.cc:18
CommissioningHistograms
Definition: CommissioningHistograms.h:23
std
Definition: JetResolutionObject.h:76
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
CommissioningHistograms::histos
const HistosMap & histos() const
Definition: CommissioningHistograms.h:161
ApvTimingSummaryFactory
Definition: ApvTimingSummaryFactory.h:6
ApvTimingAnalysis.h
ApvTimingHistograms.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
conversion_template_cfg.anal
anal
Definition: conversion_template_cfg.py:16
cuy.ii
ii
Definition: cuy.py:590
begin
#define begin
Definition: vmac.h:32
ApvTimingSummaryFactory.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27