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 }
void analysis(const std::vector< TH1 * > &)
Analyses & data(bool getMaskedData=false)
const uint16_t & fecRing() const
const edm::ParameterSet & pset() const
const float & refTime() const
Analysis for timing run using APV tick marks.
static const char mlDqmClient_[]
const uint16_t & lldChan() const
const uint16_t & fecSlot() const
static const uint16_t valid_
Definition: Constants.h:17
sistrip classes
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
void histoAnalysis(bool debug) override
bool isValid() const override
T min(T a, T b)
Definition: MathUtil.h:58
const float & time() const
#define LogTrace(id)
ii
Definition: cuy.py:590
const uint16_t & fecCrate() const
int extract(std::vector< int > *output, const std::string &dati)
#define debug
Definition: HDRShower.cc:19
std::unique_ptr< Factory > factory_
const uint16_t & ccuAddr() const
static const uint16_t invalid_
Definition: Constants.h:16
#define begin
Definition: vmac.h:32
HLT enums.
const uint16_t & ccuChan() const
Analysis for timing run using APV tick marks.
const VString & getErrorCodes() const
bool foundTickMark() const
ApvTimingHistograms(const edm::ParameterSet &pset, DQMStore *)
const HistosMap & histos() const