CMS 3D CMS Logo

RPCLinkSynchroHistoMaker.cc
Go to the documentation of this file.
4 
5 #include <sstream>
6 #include "TH1F.h"
7 #include "TH2F.h"
8 #include <algorithm>
9 #include <iostream>
10 
11 struct OrderLbSpread {
12  bool operator()(const std::pair<double, unsigned int>& lb1, const std::pair<double, unsigned int>& lb2) {
13  return lb1.first > lb2.first;
14  }
15 };
16 struct OrderLbOccup {
17  bool operator()(const std::pair<unsigned int, unsigned int>& lb1, const std::pair<unsigned int, unsigned int>& lb2) {
18  return lb1.first > lb2.first;
19  }
20 };
21 
22 void RPCLinkSynchroHistoMaker::fill(TH1F* hDelay, TH2F* hDelaySpread, TH2F* hTopOccup, TH2F* hTopSpread) const {
23  hDelay->Reset();
24  hDelaySpread->Reset();
25  hTopOccup->Reset();
26  hTopSpread->Reset();
27 
28  typedef std::vector<std::pair<unsigned int, unsigned int> > TopOccup;
29  typedef std::vector<std::pair<double, unsigned int> > TopSpread;
30  TopOccup topOccup(10, std::make_pair(0, 0));
31  TopSpread topSpread(10, std::make_pair(0., 0));
32 
33  for (unsigned int idx = 0; idx < theLinkStat.theLinkStatMap.size(); ++idx) {
35 
36  int sum = bc.second.sum();
37  double rms = bc.second.rms();
38 
39  hDelaySpread->Fill(bc.second.mean() - 3., bc.second.rms());
40 
41  if (sum == 0)
42  continue;
43  for (int i = 0; i <= 7; ++i)
44  hDelay->Fill(i - 3, bc.second.counts()[i]);
45 
46  std::pair<unsigned int, unsigned int> canOccup = std::make_pair(sum, idx);
47  std::pair<double, unsigned int> canSpread = std::make_pair(rms, idx);
48  TopOccup::iterator io = upper_bound(topOccup.begin(), topOccup.end(), canOccup, OrderLbOccup());
49  TopSpread::iterator is = upper_bound(topSpread.begin(), topSpread.end(), canSpread, OrderLbSpread());
50  if (io != topOccup.end()) {
51  topOccup.insert(io, canOccup);
52  topOccup.erase(topOccup.end() - 1);
53  }
54  if (is != topSpread.end()) {
55  topSpread.insert(is, canSpread);
56  topSpread.erase(topSpread.end() - 1);
57  }
58  }
59 
60  for (int itop = 0; itop < 10; itop++) {
61  const RPCLinkSynchroStat::BoardAndCounts& occup = theLinkStat.theLinkStatMap[topOccup[itop].second];
62  const RPCLinkSynchroStat::BoardAndCounts& spread = theLinkStat.theLinkStatMap[topSpread[itop].second];
63  hTopOccup->GetYaxis()->SetBinLabel(itop + 1, occup.first.name().c_str());
64  hTopSpread->GetYaxis()->SetBinLabel(itop + 1, spread.first.name().c_str());
65  for (unsigned int icount = 0; icount < occup.second.counts().size(); icount++) {
66  hTopOccup->SetBinContent(icount + 1, itop + 1, float(occup.second.counts()[icount]));
67  hTopSpread->SetBinContent(icount + 1, itop + 1, float(spread.second.counts()[icount]));
68  }
69  }
70  // for (int j=0; j<10; j++) { cout <<"topSpread["<<j<<"] = "<<topSpread[j].first<<endl; }
71  // for (int j=0; j<10; j++) { cout <<"topOccup["<<j<<"] = "<<topOccup[j].first<<endl; }
72 }
mps_fire.i
i
Definition: mps_fire.py:355
RPCReadOutMapping.h
charmTagsComputerCvsB_cfi.idx
idx
Definition: charmTagsComputerCvsB_cfi.py:108
RPCLinkSynchroHistoMaker.h
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
OrderLbSpread::operator()
bool operator()(const std::pair< double, unsigned int > &lb1, const std::pair< double, unsigned int > &lb2)
Definition: RPCLinkSynchroHistoMaker.cc:12
cuda_std::upper_bound
__host__ constexpr __device__ RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:45
RPCLinkSynchroHistoMaker::fill
void fill(TH1F *hDelay, TH2F *hDelaySpread, TH2F *hTopOccup, TH2F *hTopSpread) const
Definition: RPCLinkSynchroHistoMaker.cc:22
RPCLinkSynchroStat::BoardAndCounts
std::pair< LinkBoard, SynchroCounts > BoardAndCounts
Definition: RPCLinkSynchroStat.h:69
RPCLinkSynchroStat::theLinkStatMap
std::vector< BoardAndCounts > theLinkStatMap
Definition: RPCLinkSynchroStat.h:90
OrderLbOccup
Definition: RPCLinkSynchroHistoMaker.cc:16
RPCRawSynchro.h
OrderLbSpread
Definition: RPCLinkSynchroHistoMaker.cc:11
OrderLbOccup::operator()
bool operator()(const std::pair< unsigned int, unsigned int > &lb1, const std::pair< unsigned int, unsigned int > &lb2)
Definition: RPCLinkSynchroHistoMaker.cc:17
RPCLinkSynchroHistoMaker::theLinkStat
const RPCLinkSynchroStat & theLinkStat
Definition: RPCLinkSynchroHistoMaker.h:21