CMS 3D CMS Logo

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