CMS 3D CMS Logo

LumiMonitor.cc
Go to the documentation of this file.
1 #include <string>
2 
18 
19 namespace {
22  struct MEbinning {
23  int nbins;
24  double xmin;
25  double xmax;
26  };
27 
28  struct Histograms {
29  dqm::reco::MonitorElement* numberOfPixelClustersVsLS;
30  dqm::reco::MonitorElement* numberOfPixelClustersVsLumi;
31  dqm::reco::MonitorElement* lumiVsLS;
33  dqm::reco::MonitorElement* pixelLumiVsLS;
34  dqm::reco::MonitorElement* pixelLumiVsLumi;
35  };
36 } // namespace
37 
38 //
39 // class declaration
40 //
41 
42 class LumiMonitor : public DQMGlobalEDAnalyzer<Histograms> {
43 public:
45  ~LumiMonitor() override = default;
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
50  int const nbins,
51  double const xmin,
52  double const xmax);
54 
55 private:
56  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
57  void dqmAnalyze(edm::Event const&, edm::EventSetup const&, Histograms const&) const override;
58 
59  static MEbinning getHistoPSet(const edm::ParameterSet& pset);
60  static MEbinning getHistoLSPSet(const edm::ParameterSet& pset);
61 
63 
66  MEbinning const lumi_binning_;
67  MEbinning const pu_binning_;
68  MEbinning const ls_binning_;
69 
70  bool const doPixelLumi_;
73  bool const useBPixLayer1_;
76  MEbinning const pixelCluster_binning_;
77  MEbinning const pixellumi_binning_;
78  float const lumi_factor_per_bx_;
79 };
80 
81 // -----------------------------
82 // constructors and destructor
83 // -----------------------------
84 
86  : folderName_(config.getParameter<std::string>("folderName")),
87  lumiScalersToken_(consumes(config.getParameter<edm::InputTag>("scalers"))),
88  onlineMetaDataDigisToken_(consumes(config.getParameter<edm::InputTag>("onlineMetaDataDigis"))),
89  lumi_binning_(getHistoPSet(
90  config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lumiPSet"))),
91  pu_binning_(
92  getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("puPSet"))),
93  ls_binning_(getHistoLSPSet(
94  config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lsPSet"))),
95  doPixelLumi_(config.getParameter<bool>("doPixelLumi")),
96  trkTopoToken_(doPixelLumi_ ? esConsumes<TrackerTopology, TrackerTopologyRcd>()
98  pixelClustersToken_(doPixelLumi_ ? consumes<edmNew::DetSetVector<SiPixelCluster>>(
99  config.getParameter<edm::InputTag>("pixelClusters"))
100  : edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster>>()),
101  useBPixLayer1_(doPixelLumi_ ? config.getParameter<bool>("useBPixLayer1") : false),
102  minNumberOfPixelsPerCluster_(doPixelLumi_ ? config.getParameter<int>("minNumberOfPixelsPerCluster") : -1),
103  minPixelClusterCharge_(doPixelLumi_ ? config.getParameter<double>("minPixelClusterCharge") : -1.),
104  pixelCluster_binning_(doPixelLumi_ ? getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet")
105  .getParameter<edm::ParameterSet>("pixelClusterPSet"))
106  : MEbinning{}),
107  pixellumi_binning_(doPixelLumi_ ? getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet")
108  .getParameter<edm::ParameterSet>("pixellumiPSet"))
109  : MEbinning{}),
110  lumi_factor_per_bx_(useBPixLayer1_
113 
115  return MEbinning{
116  pset.getParameter<int32_t>("nbins"),
117  pset.getParameter<double>("xmin"),
118  pset.getParameter<double>("xmax"),
119  };
120 }
121 
123  return MEbinning{pset.getParameter<int32_t>("nbins"), -0.5, pset.getParameter<int32_t>("nbins") - 0.5};
124 }
125 
127  edm::Run const& run,
128  edm::EventSetup const& setup,
129  Histograms& histograms) const {
131 
132  if (doPixelLumi_) {
133  auto me = booker.book1D("numberOfPixelClustersVsLS",
134  "number of pixel clusters vs lumisection",
135  ls_binning_.nbins,
136  ls_binning_.xmin,
137  ls_binning_.xmax);
138  me->setAxisTitle("lumisection", 1);
139  me->setAxisTitle("number of pixel clusters", 2);
140  histograms.numberOfPixelClustersVsLS = me;
141 
142  me = booker.bookProfile("numberOfPixelClustersVsLumi",
143  "number of pixel clusters vs online lumi",
144  lumi_binning_.nbins,
145  lumi_binning_.xmin,
146  lumi_binning_.xmax,
148  pixelCluster_binning_.xmax);
149  me->setAxisTitle("online inst lumi E30 [Hz cm^{-2}]", 1);
150  me->setAxisTitle("number of pixel clusters", 2);
151  histograms.numberOfPixelClustersVsLumi = me;
152 
153  me = booker.bookProfile("pixelLumiVsLS",
154  "pixel-lumi vs lumisection",
155  ls_binning_.nbins,
156  ls_binning_.xmin,
157  ls_binning_.xmax,
158  pixellumi_binning_.xmin,
159  pixellumi_binning_.xmax);
160  me->setAxisTitle("lumisection", 1);
161  me->setAxisTitle("pixel-based inst lumi E30 [Hz cm^{-2}]", 2);
162  histograms.pixelLumiVsLS = me;
163 
164  me = booker.bookProfile("pixelLumiVsLumi",
165  "pixel-lumi vs online lumi",
166  lumi_binning_.nbins,
167  lumi_binning_.xmin,
168  lumi_binning_.xmax,
169  pixellumi_binning_.xmin,
170  lumi_binning_.xmax);
171  me->setAxisTitle("online inst lumi E30 [Hz cm^{-2}]", 1);
172  me->setAxisTitle("pixel-based inst lumi E30 [Hz cm^{-2}]", 2);
173  histograms.pixelLumiVsLumi = me;
174  }
175 
176  auto me = booker.bookProfile("lumiVsLS",
177  "online lumi vs lumisection",
178  ls_binning_.nbins,
179  ls_binning_.xmin,
180  ls_binning_.xmax,
181  lumi_binning_.xmin,
182  lumi_binning_.xmax);
183  me->setAxisTitle("lumisection", 1);
184  me->setAxisTitle("online inst lumi E30 [Hz cm^{-2}]", 2);
185  histograms.lumiVsLS = me;
186 
187  me = booker.bookProfile("puVsLS",
188  "online pileup vs lumisection",
189  ls_binning_.nbins,
190  ls_binning_.xmin,
191  ls_binning_.xmax,
192  pu_binning_.xmin,
193  pu_binning_.xmax);
194  me->setAxisTitle("lumisection", 1);
195  me->setAxisTitle("online pileup", 2);
196  histograms.puVsLS = me;
197 }
198 
200  edm::EventSetup const& setup,
201  Histograms const& histograms) const {
202  int const ls = event.id().luminosityBlock();
203 
204  float online_lumi = -1.f;
205  float online_pu = -1.f;
206  auto const lumiScalersHandle = event.getHandle(lumiScalersToken_);
207  auto const onlineMetaDataDigisHandle = event.getHandle(onlineMetaDataDigisToken_);
208  if (lumiScalersHandle.isValid() and not lumiScalersHandle->empty()) {
209  auto const scalit = lumiScalersHandle->begin();
210  online_lumi = scalit->instantLumi();
211  online_pu = scalit->pileup();
212  } else if (onlineMetaDataDigisHandle.isValid()) {
213  online_lumi = onlineMetaDataDigisHandle->instLumi();
214  online_pu = onlineMetaDataDigisHandle->avgPileUp();
215  }
216  histograms.lumiVsLS->Fill(ls, online_lumi);
217  histograms.puVsLS->Fill(ls, online_pu);
218 
219  if (doPixelLumi_) {
220  size_t pixel_clusters = 0;
221  float pixel_lumi = -1.f;
223  event.getByToken(pixelClustersToken_, pixelClusters);
224  if (pixelClusters.isValid()) {
225  auto const& tTopo = setup.getData(trkTopoToken_);
226 
227  // Count the number of clusters with at least a minimum
228  // number of pixels per cluster and at least a minimum charge.
229  for (auto pixCluDet = pixelClusters->begin(); pixCluDet != pixelClusters->end(); ++pixCluDet) {
230  DetId detid = pixCluDet->detId();
231  size_t subdetid = detid.subdetId();
232  if (subdetid == (int)PixelSubdetector::PixelBarrel) {
233  if (tTopo.layer(detid) == 1) {
234  continue;
235  }
236  }
237 
238  for (auto pixClu = pixCluDet->begin(); pixClu != pixCluDet->end(); ++pixClu) {
239  if ((pixClu->size() >= minNumberOfPixelsPerCluster_) and (pixClu->charge() >= minPixelClusterCharge_)) {
240  ++pixel_clusters;
241  }
242  }
243  }
244  pixel_lumi = lumi_factor_per_bx_ * pixel_clusters / GetLumi::CM2_TO_NANOBARN; // ?!?!
245  } else {
246  pixel_lumi = -1.;
247  }
248 
249  histograms.numberOfPixelClustersVsLS->Fill(ls, pixel_clusters);
250  histograms.numberOfPixelClustersVsLumi->Fill(online_lumi, pixel_clusters);
251  histograms.pixelLumiVsLS->Fill(ls, pixel_lumi);
252  histograms.pixelLumiVsLumi->Fill(online_lumi, pixel_lumi);
253  }
254 }
255 
257  int const nbins,
258  double const xmin,
259  double const xmax) {
260  pset.add<int>("nbins", nbins);
261  pset.add<double>("xmin", xmin);
262  pset.add<double>("xmax", xmax);
263 }
264 
266  pset.add<int>("nbins", nbins);
267 }
268 
271  desc.add<edm::InputTag>("pixelClusters", edm::InputTag("hltSiPixelClusters"));
272  desc.add<edm::InputTag>("scalers", edm::InputTag("hltScalersRawToDigi"));
273  desc.add<edm::InputTag>("onlineMetaDataDigis", edm::InputTag("hltOnlineMetaDataDigis"));
274  desc.add<std::string>("folderName", "HLT/LumiMonitoring");
275  desc.add<bool>("doPixelLumi", false);
276  desc.add<bool>("useBPixLayer1", false);
277  desc.add<int>("minNumberOfPixelsPerCluster", 2); // from DQM/PixelLumi/python/PixelLumiDQM_cfi.py
278  desc.add<double>("minPixelClusterCharge", 15000.);
279 
281 
285 
287  fillHistoPSetDescription(puPSet, 130, 0, 130);
289 
291  fillHistoPSetDescription(lumiPSet, 5000, 0, 20000);
293 
297 
299  fillHistoPSetDescription(pixelClusterPSet, 200, -0.5, 19999.5);
300  histoPSet.add("pixelClusterPSet", pixelClusterPSet);
301 
302  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
303 
304  descriptions.add("lumiMonitor", desc);
305 }
306 
307 // Define this as a plug-in
MEbinning const pixelCluster_binning_
Definition: LumiMonitor.cc:76
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > const trkTopoToken_
Definition: LumiMonitor.cc:71
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:114
std::string const folderName_
Definition: LumiMonitor.cc:62
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > const pixelClustersToken_
Definition: LumiMonitor.cc:72
int const minNumberOfPixelsPerCluster_
Definition: LumiMonitor.cc:74
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Definition: LumiMonitor.cc:126
~LumiMonitor() override=default
Definition: config.py:1
static constexpr double FREQ_ORBIT
Definition: GetLumi.h:23
float const minPixelClusterCharge_
Definition: LumiMonitor.cc:75
MEbinning const pu_binning_
Definition: LumiMonitor.cc:67
dqm::reco::DQMStore DQMStore
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: LumiMonitor.cc:269
static constexpr double SECONDS_PER_LS
Definition: GetLumi.h:24
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
bool const doPixelLumi_
Definition: LumiMonitor.cc:70
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset, int const nbins, double const xmin, double const xmax)
Definition: LumiMonitor.cc:256
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset, int const nbins)
Definition: LumiMonitor.cc:265
Definition: DetId.h:17
def ls(path, rec=False)
Definition: eostools.py:349
dqm::legacy::MonitorElement MonitorElement
static MEbinning getHistoLSPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:122
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< LumiScalersCollection > const lumiScalersToken_
Definition: LumiMonitor.cc:64
Pixel cluster – collection of neighboring pixels above threshold.
MEbinning const ls_binning_
Definition: LumiMonitor.cc:68
static constexpr double rXSEC_PIXEL_CLUSTER
Definition: GetLumi.h:37
HLT enums.
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms const &) const override
Definition: LumiMonitor.cc:199
static constexpr double CM2_TO_NANOBARN
Definition: GetLumi.h:39
float const lumi_factor_per_bx_
Definition: LumiMonitor.cc:78
MEbinning const pixellumi_binning_
Definition: LumiMonitor.cc:77
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static constexpr double XSEC_PIXEL_CLUSTER
Definition: GetLumi.h:33
MEbinning const lumi_binning_
Definition: LumiMonitor.cc:66
bool const useBPixLayer1_
Definition: LumiMonitor.cc:73
Definition: event.py:1
Definition: Run.h:45
LumiMonitor(const edm::ParameterSet &)
Definition: LumiMonitor.cc:85
edm::EDGetTokenT< OnlineLuminosityRecord > const onlineMetaDataDigisToken_
Definition: LumiMonitor.cc:65