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  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
49 
50 private:
51  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
52  void dqmAnalyze(edm::Event const&, edm::EventSetup const&, Histograms const&) const override;
53 
54  static MEbinning getHistoPSet(const edm::ParameterSet& pset);
55  static MEbinning getHistoLSPSet(const edm::ParameterSet& pset);
56 
58 
61  MEbinning const lumi_binning_;
62  MEbinning const pu_binning_;
63  MEbinning const ls_binning_;
64 
65  bool const doPixelLumi_;
68  bool const useBPixLayer1_;
71  MEbinning const pixelCluster_binning_;
72  MEbinning const pixellumi_binning_;
73  float const lumi_factor_per_bx_;
74 };
75 
76 // -----------------------------
77 // constructors and destructor
78 // -----------------------------
79 
81  : folderName_(config.getParameter<std::string>("FolderName")),
82  lumiScalersToken_(consumes(config.getParameter<edm::InputTag>("scalers"))),
83  onlineMetaDataDigisToken_(consumes(config.getParameter<edm::InputTag>("onlineMetaDataDigis"))),
84  lumi_binning_(getHistoPSet(
85  config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lumiPSet"))),
86  pu_binning_(
87  getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("puPSet"))),
88  ls_binning_(getHistoLSPSet(
89  config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lsPSet"))),
90  doPixelLumi_(config.getParameter<bool>("doPixelLumi")),
91  trkTopoToken_(doPixelLumi_ ? esConsumes<TrackerTopology, TrackerTopologyRcd>()
93  pixelClustersToken_(doPixelLumi_ ? consumes<edmNew::DetSetVector<SiPixelCluster>>(
94  config.getParameter<edm::InputTag>("pixelClusters"))
95  : edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster>>()),
96  useBPixLayer1_(doPixelLumi_ ? config.getParameter<bool>("useBPixLayer1") : false),
97  minNumberOfPixelsPerCluster_(doPixelLumi_ ? config.getParameter<int>("minNumberOfPixelsPerCluster") : -1),
98  minPixelClusterCharge_(doPixelLumi_ ? config.getParameter<double>("minPixelClusterCharge") : -1.),
99  pixelCluster_binning_(doPixelLumi_ ? getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet")
100  .getParameter<edm::ParameterSet>("pixelClusterPSet"))
101  : MEbinning{}),
102  pixellumi_binning_(doPixelLumi_ ? getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet")
103  .getParameter<edm::ParameterSet>("pixellumiPSet"))
104  : MEbinning{}),
105  lumi_factor_per_bx_(useBPixLayer1_
108 
110  return MEbinning{
111  pset.getParameter<int32_t>("nbins"),
112  pset.getParameter<double>("xmin"),
113  pset.getParameter<double>("xmax"),
114  };
115 }
116 
118  return MEbinning{pset.getParameter<int32_t>("nbins"), -0.5, pset.getParameter<int32_t>("nbins") - 0.5};
119 }
120 
122  edm::Run const& run,
123  edm::EventSetup const& setup,
124  Histograms& histograms) const {
126 
127  if (doPixelLumi_) {
128  auto me = booker.book1D("numberOfPixelClustersVsLS",
129  "number of pixel clusters vs lumisection",
130  ls_binning_.nbins,
131  ls_binning_.xmin,
132  ls_binning_.xmax);
133  me->setAxisTitle("lumisection", 1);
134  me->setAxisTitle("number of pixel clusters", 2);
135  histograms.numberOfPixelClustersVsLS = me;
136 
137  me = booker.bookProfile("numberOfPixelClustersVsLumi",
138  "number of pixel clusters vs online lumi",
139  lumi_binning_.nbins,
140  lumi_binning_.xmin,
141  lumi_binning_.xmax,
143  pixelCluster_binning_.xmax);
144  me->setAxisTitle("online inst lumi E30 [Hz cm^{-2}]", 1);
145  me->setAxisTitle("number of pixel clusters", 2);
146  histograms.numberOfPixelClustersVsLumi = me;
147 
148  me = booker.bookProfile("pixelLumiVsLS",
149  "pixel-lumi vs lumisection",
150  ls_binning_.nbins,
151  ls_binning_.xmin,
152  ls_binning_.xmax,
153  pixellumi_binning_.xmin,
154  pixellumi_binning_.xmax);
155  me->setAxisTitle("lumisection", 1);
156  me->setAxisTitle("pixel-based inst lumi E30 [Hz cm^{-2}]", 2);
157  histograms.pixelLumiVsLS = me;
158 
159  me = booker.bookProfile("pixelLumiVsLumi",
160  "pixel-lumi vs online lumi",
161  lumi_binning_.nbins,
162  lumi_binning_.xmin,
163  lumi_binning_.xmax,
164  pixellumi_binning_.xmin,
165  lumi_binning_.xmax);
166  me->setAxisTitle("online inst lumi E30 [Hz cm^{-2}]", 1);
167  me->setAxisTitle("pixel-based inst lumi E30 [Hz cm^{-2}]", 2);
168  histograms.pixelLumiVsLumi = me;
169  }
170 
171  auto me = booker.bookProfile("lumiVsLS",
172  "online lumi vs lumisection",
173  ls_binning_.nbins,
174  ls_binning_.xmin,
175  ls_binning_.xmax,
176  lumi_binning_.xmin,
177  lumi_binning_.xmax);
178  me->setAxisTitle("lumisection", 1);
179  me->setAxisTitle("online inst lumi E30 [Hz cm^{-2}]", 2);
180  histograms.lumiVsLS = me;
181 
182  me = booker.bookProfile("puVsLS",
183  "online pileup vs lumisection",
184  ls_binning_.nbins,
185  ls_binning_.xmin,
186  ls_binning_.xmax,
187  pu_binning_.xmin,
188  pu_binning_.xmax);
189  me->setAxisTitle("lumisection", 1);
190  me->setAxisTitle("online pileup", 2);
191  histograms.puVsLS = me;
192 }
193 
195  edm::EventSetup const& setup,
196  Histograms const& histograms) const {
197  int const ls = event.id().luminosityBlock();
198 
199  float online_lumi = -1.f;
200  float online_pu = -1.f;
201  auto const lumiScalersHandle = event.getHandle(lumiScalersToken_);
202  auto const onlineMetaDataDigisHandle = event.getHandle(onlineMetaDataDigisToken_);
203  if (lumiScalersHandle.isValid() and not lumiScalersHandle->empty()) {
204  auto const scalit = lumiScalersHandle->begin();
205  online_lumi = scalit->instantLumi();
206  online_pu = scalit->pileup();
207  } else if (onlineMetaDataDigisHandle.isValid()) {
208  online_lumi = onlineMetaDataDigisHandle->instLumi();
209  online_pu = onlineMetaDataDigisHandle->avgPileUp();
210  }
211  histograms.lumiVsLS->Fill(ls, online_lumi);
212  histograms.puVsLS->Fill(ls, online_pu);
213 
214  if (doPixelLumi_) {
215  size_t pixel_clusters = 0;
216  float pixel_lumi = -1.f;
218  event.getByToken(pixelClustersToken_, pixelClusters);
219  if (pixelClusters.isValid()) {
220  auto const& tTopo = setup.getData(trkTopoToken_);
221 
222  // Count the number of clusters with at least a minimum
223  // number of pixels per cluster and at least a minimum charge.
224  size_t tot = 0;
225  for (auto pixCluDet = pixelClusters->begin(); pixCluDet != pixelClusters->end(); ++pixCluDet) {
226  DetId detid = pixCluDet->detId();
227  size_t subdetid = detid.subdetId();
228  if (subdetid == (int)PixelSubdetector::PixelBarrel) {
229  if (tTopo.layer(detid) == 1) {
230  continue;
231  }
232  }
233 
234  for (auto pixClu = pixCluDet->begin(); pixClu != pixCluDet->end(); ++pixClu) {
235  ++tot;
236  if ((pixClu->size() >= minNumberOfPixelsPerCluster_) and (pixClu->charge() >= minPixelClusterCharge_)) {
237  ++pixel_clusters;
238  }
239  }
240  }
241  pixel_lumi = lumi_factor_per_bx_ * pixel_clusters / GetLumi::CM2_TO_NANOBARN; // ?!?!
242  } else {
243  pixel_lumi = -1.;
244  }
245 
246  histograms.numberOfPixelClustersVsLS->Fill(ls, pixel_clusters);
247  histograms.numberOfPixelClustersVsLumi->Fill(online_lumi, pixel_clusters);
248  histograms.pixelLumiVsLS->Fill(ls, pixel_lumi);
249  histograms.pixelLumiVsLumi->Fill(online_lumi, pixel_lumi);
250  }
251 }
252 
254  pset.add<int>("nbins");
255  pset.add<double>("xmin");
256  pset.add<double>("xmax");
257 }
258 
260 
263  desc.add<edm::InputTag>("pixelClusters", edm::InputTag("hltSiPixelClusters"));
264  desc.add<edm::InputTag>("scalers", edm::InputTag("hltScalersRawToDigi"));
265  desc.add<edm::InputTag>("onlineMetaDataDigis", edm::InputTag("hltOnlineMetaDataDigis"));
266  desc.add<std::string>("FolderName", "HLT/LumiMonitoring");
267  desc.add<bool>("doPixelLumi", false);
268  desc.add<bool>("useBPixLayer1", false);
269  desc.add<int>("minNumberOfPixelsPerCluster", 2); // from DQM/PixelLumi/python/PixelLumiDQM_cfi.py
270  desc.add<double>("minPixelClusterCharge", 15000.);
271 
275  histoPSet.add("pixelClusterPSet", pixelClusterPSet);
276 
280 
284 
288 
292 
293  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
294 
295  descriptions.add("lumiMonitor", desc);
296 }
297 
298 // Define this as a plug-in
MEbinning const pixelCluster_binning_
Definition: LumiMonitor.cc:71
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > const trkTopoToken_
Definition: LumiMonitor.cc:66
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:109
std::string const folderName_
Definition: LumiMonitor.cc:57
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > const pixelClustersToken_
Definition: LumiMonitor.cc:67
int const minNumberOfPixelsPerCluster_
Definition: LumiMonitor.cc:69
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Definition: LumiMonitor.cc:121
~LumiMonitor() override=default
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Definition: config.py:1
static constexpr double FREQ_ORBIT
Definition: GetLumi.h:23
float const minPixelClusterCharge_
Definition: LumiMonitor.cc:70
MEbinning const pu_binning_
Definition: LumiMonitor.cc:62
dqm::reco::DQMStore DQMStore
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: LumiMonitor.cc:261
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:65
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
Definition: LumiMonitor.cc:259
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)
Definition: LumiMonitor.cc:253
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:117
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< LumiScalersCollection > const lumiScalersToken_
Definition: LumiMonitor.cc:59
Pixel cluster – collection of neighboring pixels above threshold.
MEbinning const ls_binning_
Definition: LumiMonitor.cc:63
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:194
static constexpr double CM2_TO_NANOBARN
Definition: GetLumi.h:39
float const lumi_factor_per_bx_
Definition: LumiMonitor.cc:73
MEbinning const pixellumi_binning_
Definition: LumiMonitor.cc:72
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:61
bool const useBPixLayer1_
Definition: LumiMonitor.cc:68
Definition: event.py:1
Definition: Run.h:45
LumiMonitor(const edm::ParameterSet &)
Definition: LumiMonitor.cc:80
edm::EDGetTokenT< OnlineLuminosityRecord > const onlineMetaDataDigisToken_
Definition: LumiMonitor.cc:60