CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FedTimingHistograms.cc
Go to the documentation of this file.
6 #include <iostream>
7 #include <sstream>
8 #include <iomanip>
9 
10 using namespace std;
11 
12 // -----------------------------------------------------------------------------
15  : CommissioningHistograms(pset.getParameter<edm::ParameterSet>("FedTimingParameters"), bei, sistrip::FED_TIMING),
16  factory_(new Factory),
17  optimumSamplingPoint_(15.),
18  minDelay_(sistrip::invalid_),
19  maxDelay_(-1. * sistrip::invalid_),
20  deviceWithMinDelay_(sistrip::invalid_),
21  deviceWithMaxDelay_(sistrip::invalid_) {
22  cout << "[" << __PRETTY_FUNCTION__ << "]"
23  << " Created object for APV TIMING histograms" << endl;
24 }
25 
26 // -----------------------------------------------------------------------------
28 FedTimingHistograms::~FedTimingHistograms() { cout << "[" << __PRETTY_FUNCTION__ << "]" << endl; }
29 
30 // -----------------------------------------------------------------------------
33  // Clear std::map holding analysis objects
34  data_.clear();
35 
36  // Reset minimum / maximum delays
37  float time_min = 1. * sistrip::invalid_;
38  float time_max = -1. * sistrip::invalid_;
39  uint32_t device_min = sistrip::invalid_;
40  uint32_t device_max = sistrip::invalid_;
41 
42  // // Iterate through std::map containing std::vectors of profile histograms
43  // CollationsMap::const_iterator iter = collations().begin();
44  // for ( ; iter != collations().end(); iter++ ) {
45 
46  // // Check std::vector of histos is not empty (should be 2 histos)
47  // if ( iter->second.empty() ) {
48  // cerr << "[" << __PRETTY_FUNCTION__ << "]"
49  // << " Zero collation histograms found!" << endl;
50  // continue;
51  // }
52 
53  // // Retrieve pointers to profile histos for this FED channel
54  // std::vector<TH1*> profs;
55  // Collations::const_iterator ihis = iter->second.begin();
56  // for ( ; ihis != iter->second.end(); ihis++ ) {
57  // OBSOLETE!!!
58  // TProfile* prof = ExtractTObject<TProfile>().extract( mui()->get( ihis->first ) );
59  // if ( prof ) { profs.push_back(prof); }
60  // }
61 
62  // // Perform histo analysis
63  // FedTimingAnalysis anal( iter->first );
64  // FedTimingAlgorithm algo( &anal );
65  // algo.analysis( profs );
66  // data_[iter->first] = anal;
67 
68  // // Check tick height is valid
69  // if ( anal.height() < 100. ) {
70  // cerr << "[" << __PRETTY_FUNCTION__ << "]"
71  // << " Tick mark height too small: " << anal.height() << endl;
72  // continue;
73  // }
74 
75  // // Check time of rising edge
76  // if ( anal.time() > sistrip::maximum_ ) { continue; }
77 
78  // // Find maximum time
79  // if ( anal.time() > time_max ) {
80  // time_max = anal.time();
81  // device_max = iter->first;
82  // }
83 
84  // // Find minimum time
85  // if ( anal.time() < time_min ) {
86  // time_min = anal.time();
87  // device_min = iter->first;
88  // }
89 
90  // }
91 
92  // cout << "[" << __PRETTY_FUNCTION__ << "]"
93  // << " Analyzed histograms for "
94  // << collations().size()
95  // << " FED channels" << endl;
96 
97  // Adjust maximum (and minimum) delay(s) to find optimum sampling point(s)
98  if (time_max > sistrip::maximum_ || time_max < -1. * sistrip::maximum_) {
99  cerr << "[" << __PRETTY_FUNCTION__ << "]"
100  << " Unable to set maximum time! Found unexpected value: " << time_max << endl;
101  return;
102  }
103 
104  SiStripFecKey max(device_max);
105  cout << " Device (FEC/slot/ring/CCU/module/channel) " << max.fecCrate() << "/" << max.fecSlot() << "/"
106  << max.fecRing() << "/" << max.ccuAddr() << "/" << max.ccuChan() << "/"
107  << " has maximum delay (rising edge) [ns]:" << time_max << endl;
108 
109  SiStripFecKey min(device_min);
110  cout << " Device (FEC/slot/ring/CCU/module/channel): " << min.fecCrate() << "/" << min.fecSlot() << "/"
111  << min.fecRing() << "/" << min.ccuAddr() << "/" << min.ccuChan() << "/"
112  << " has minimum delay (rising edge) [ns]:" << time_min << endl;
113 
114  // Set maximum time for all analysis objects
115  std::map<uint32_t, FedTimingAnalysis>::iterator ianal = data_.begin();
116  for (; ianal != data_.end(); ianal++) {
117  ianal->second.max(time_max);
118  static uint16_t cntr = 0;
119  if (debug) {
120  std::stringstream ss;
121  ianal->second.print(ss);
122  cout << ss.str() << endl;
123  cntr++;
124  }
125  }
126 }
127 
128 // -----------------------------------------------------------------------------
132  const std::string& directory,
133  const sistrip::Granularity& gran) {
134  cout << "[" << __PRETTY_FUNCTION__ << "]" << endl;
135 
136  // Check view
138  if (view == sistrip::UNKNOWN_VIEW) {
139  return;
140  }
141 
142  // Analyze histograms
143  histoAnalysis(false);
144 
145  // Extract data to be histogrammed
146  factory_->init(histo, type, view, directory, gran);
147  uint32_t xbins = factory_->extract(data_);
148 
149  // Create summary histogram (if it doesn't already exist)
150  TH1* summary = histogram(histo, type, view, directory, xbins);
151 
152  // Fill histogram with data
153  factory_->fill(*summary);
154 }
TH1 * histogram(const sistrip::Monitorable &, const sistrip::Presentation &, const sistrip::View &, const std::string &directory, const uint32_t &xbins, const float &xlow=1.*sistrip::invalid_, const float &xhigh=1.*sistrip::invalid_)
const double xbins[]
const uint16_t & fecRing() const
std::map< uint32_t, FedTimingAnalysis > data_
FedTimingHistograms(const edm::ParameterSet &pset, DQMStore *)
const uint16_t & fecSlot() const
void createSummaryHisto(const sistrip::Monitorable &, const sistrip::Presentation &, const std::string &top_level_dir, const sistrip::Granularity &) override
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
static std::string view(const sistrip::View &)
static const uint16_t maximum_
Definition: Constants.h:20
void histoAnalysis(bool debug) override
const uint16_t & fecCrate() const
#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
const uint16_t & ccuChan() const
tuple cout
Definition: gather_cfg.py:144