CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LumiMonitor.cc
Go to the documentation of this file.
1 #include <string>
2 
19 
20 namespace {
23  struct MEbinning {
24  int nbins;
25  double xmin;
26  double xmax;
27  };
28 
29  struct Histograms {
30  dqm::reco::MonitorElement* numberOfPixelClustersVsLS;
31  dqm::reco::MonitorElement* numberOfPixelClustersVsLumi;
32  dqm::reco::MonitorElement* lumiVsLS;
34  dqm::reco::MonitorElement* pixelLumiVsLS;
35  dqm::reco::MonitorElement* pixelLumiVsLumi;
36  };
37 } // namespace
38 
39 //
40 // class declaration
41 //
42 
43 class LumiMonitor : public DQMGlobalEDAnalyzer<Histograms> {
44 public:
46  ~LumiMonitor() override = default;
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50 
51 private:
52  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
53  void dqmAnalyze(edm::Event const&, edm::EventSetup const&, Histograms const&) const override;
54 
55  static MEbinning getHistoPSet(const edm::ParameterSet& pset);
56  static MEbinning getHistoLSPSet(const edm::ParameterSet& pset);
57 
59 
61 
63  MEbinning lumi_binning_;
64  MEbinning pu_binning_;
65  MEbinning ls_binning_;
66 
73  MEbinning pixellumi_binning_;
74 
76 
78 };
79 
80 // -----------------------------
81 // constructors and destructor
82 // -----------------------------
83 
85  : trkTopoToken_{esConsumes()},
86  folderName_(config.getParameter<std::string>("FolderName")),
87  lumiScalersToken_(consumes<LumiScalersCollection>(config.getParameter<edm::InputTag>("scalers"))),
88  lumi_binning_(getHistoPSet(
89  config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lumiPSet"))),
90  pu_binning_(
91  getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("puPSet"))),
92  ls_binning_(getHistoLSPSet(
93  config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lsPSet"))),
94  doPixelLumi_(config.getParameter<bool>("doPixelLumi")),
95  pixelClustersToken_(doPixelLumi_ ? consumes<edmNew::DetSetVector<SiPixelCluster>>(
96  config.getParameter<edm::InputTag>("pixelClusters"))
98  useBPixLayer1_(doPixelLumi_ ? config.getParameter<bool>("useBPixLayer1") : false),
99  minNumberOfPixelsPerCluster_(doPixelLumi_ ? config.getParameter<int>("minNumberOfPixelsPerCluster") : -1),
100  minPixelClusterCharge_(doPixelLumi_ ? config.getParameter<double>("minPixelClusterCharge") : -1.),
101  pixelCluster_binning_(doPixelLumi_ ? getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet")
102  .getParameter<edm::ParameterSet>("pixelClusterPSet"))
103  : MEbinning{}),
104  pixellumi_binning_(doPixelLumi_ ? getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet")
105  .getParameter<edm::ParameterSet>("pixellumiPSet"))
106  : MEbinning{}) {
107  if (useBPixLayer1_) {
109  } else {
111  }
112 }
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 LS",
135  ls_binning_.nbins,
136  ls_binning_.xmin,
137  ls_binning_.xmax);
138  me->setAxisTitle("LS", 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 scal lumi",
144  lumi_binning_.nbins,
145  lumi_binning_.xmin,
146  lumi_binning_.xmax,
148  pixelCluster_binning_.xmax);
149  me->setAxisTitle("scal 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 LS",
155  ls_binning_.nbins,
156  ls_binning_.xmin,
157  ls_binning_.xmax,
158  pixellumi_binning_.xmin,
159  pixellumi_binning_.xmax);
160  me->setAxisTitle("LS", 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 scal lumi",
166  lumi_binning_.nbins,
167  lumi_binning_.xmin,
168  lumi_binning_.xmax,
169  pixellumi_binning_.xmin,
170  lumi_binning_.xmax);
171  me->setAxisTitle("scal 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  "scal lumi vs LS",
178  ls_binning_.nbins,
179  ls_binning_.xmin,
180  ls_binning_.xmax,
181  lumi_binning_.xmin,
182  lumi_binning_.xmax);
183  me->setAxisTitle("LS", 1);
184  me->setAxisTitle("scal inst lumi E30 [Hz cm^{-2}]", 2);
185  histograms.lumiVsLS = me;
186 
187  me = booker.bookProfile("puVsLS",
188  "scal PU vs LS",
189  ls_binning_.nbins,
190  ls_binning_.xmin,
191  ls_binning_.xmax,
192  pu_binning_.xmin,
193  pu_binning_.xmax);
194  me->setAxisTitle("LS", 1);
195  me->setAxisTitle("scal PU", 2);
196  histograms.puVsLS = me;
197 }
198 
200  edm::EventSetup const& setup,
201  Histograms const& histograms) const {
202  int ls = event.id().luminosityBlock();
203 
204  float scal_lumi = -1.;
205  float scal_pu = -1.;
207  event.getByToken(lumiScalersToken_, lumiScalers);
208  if (lumiScalers.isValid() and not lumiScalers->empty()) {
209  auto scalit = lumiScalers->begin();
210  scal_lumi = scalit->instantLumi();
211  scal_pu = scalit->pileup();
212  } else {
213  scal_lumi = -1.;
214  scal_pu = -1.;
215  }
216  histograms.lumiVsLS->Fill(ls, scal_lumi);
217  histograms.puVsLS->Fill(ls, scal_pu);
218 
219  if (doPixelLumi_) {
220  size_t pixel_clusters = 0;
221  float pixel_lumi = -1.;
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  size_t tot = 0;
230  for (auto pixCluDet = pixelClusters->begin(); pixCluDet != pixelClusters->end(); ++pixCluDet) {
231  DetId detid = pixCluDet->detId();
232  size_t subdetid = detid.subdetId();
233  if (subdetid == (int)PixelSubdetector::PixelBarrel) {
234  if (tTopo.layer(detid) == 1) {
235  continue;
236  }
237  }
238 
239  for (auto pixClu = pixCluDet->begin(); pixClu != pixCluDet->end(); ++pixClu) {
240  ++tot;
241  if ((pixClu->size() >= minNumberOfPixelsPerCluster_) and (pixClu->charge() >= minPixelClusterCharge_)) {
242  ++pixel_clusters;
243  }
244  }
245  }
246  pixel_lumi = lumi_factor_per_bx_ * pixel_clusters / GetLumi::CM2_TO_NANOBARN; // ?!?!
247  } else {
248  pixel_lumi = -1.;
249  }
250 
251  histograms.numberOfPixelClustersVsLS->Fill(ls, pixel_clusters);
252  histograms.numberOfPixelClustersVsLumi->Fill(scal_lumi, pixel_clusters);
253  histograms.pixelLumiVsLS->Fill(ls, pixel_lumi);
254  histograms.pixelLumiVsLumi->Fill(scal_lumi, pixel_lumi);
255  }
256 }
257 
259  pset.add<int>("nbins");
260  pset.add<double>("xmin");
261  pset.add<double>("xmax");
262 }
263 
265 
268  desc.add<edm::InputTag>("pixelClusters", edm::InputTag("hltSiPixelClusters"));
269  desc.add<edm::InputTag>("scalers", edm::InputTag("hltScalersRawToDigi"));
270  desc.add<std::string>("FolderName", "HLT/LumiMonitoring");
271  desc.add<bool>("doPixelLumi", false);
272  desc.add<bool>("useBPixLayer1", false);
273  desc.add<int>("minNumberOfPixelsPerCluster", 2); // from DQM/PixelLumi/python/PixelLumiDQM_cfi.py
274  desc.add<double>("minPixelClusterCharge", 15000.);
275 
278  LumiMonitor::fillHistoPSetDescription(pixelClusterPSet);
279  histoPSet.add("pixelClusterPSet", pixelClusterPSet);
280 
282  fillHistoPSetDescription(lumiPSet);
283  histoPSet.add<edm::ParameterSetDescription>("lumiPSet", lumiPSet);
284 
286  fillHistoPSetDescription(puPSet);
287  histoPSet.add<edm::ParameterSetDescription>("puPSet", puPSet);
288 
290  fillHistoPSetDescription(pixellumiPSet);
291  histoPSet.add<edm::ParameterSetDescription>("pixellumiPSet", pixellumiPSet);
292 
295  histoPSet.add<edm::ParameterSetDescription>("lsPSet", lsPSet);
296 
297  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
298 
299  descriptions.add("lumiMonitor", desc);
300 }
301 
302 // Define this as a plug-in
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > const trkTopoToken_
Definition: LumiMonitor.cc:58
bool useBPixLayer1_
Definition: LumiMonitor.cc:69
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:114
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:126
MEbinning pu_binning_
Definition: LumiMonitor.cc:64
~LumiMonitor() override=default
float minPixelClusterCharge_
Definition: LumiMonitor.cc:71
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
def ls
Definition: eostools.py:349
ls_binning_(getHistoPSet(iConfig.getParameter< edm::ParameterSet >("histoPSet").getParameter< edm::ParameterSet >("lsPSet")))
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
Definition: LumiMonitor.cc:68
static constexpr double FREQ_ORBIT
Definition: GetLumi.h:26
dqm::reco::DQMStore DQMStore
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::EDGetTokenT< LumiSummary > lumiSummaryToken_
Definition: LumiMonitor.cc:75
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: LumiMonitor.cc:266
static constexpr double SECONDS_PER_LS
Definition: GetLumi.h:27
std::string folderName_
Definition: LumiMonitor.cc:60
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
Definition: LumiMonitor.cc:62
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:322
MEbinning pixellumi_binning_
Definition: LumiMonitor.cc:73
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 fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
Definition: LumiMonitor.cc:264
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:70
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
Definition: LumiMonitor.cc:258
Definition: DetId.h:17
dqm::legacy::MonitorElement MonitorElement
static MEbinning getHistoLSPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:122
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool doPixelLumi_
Definition: LumiMonitor.cc:67
MEbinning pixelCluster_binning_
Definition: LumiMonitor.cc:72
tuple config
parse the configuration file
static constexpr double rXSEC_PIXEL_CLUSTER
Definition: GetLumi.h:40
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:42
float lumi_factor_per_bx_
Definition: LumiMonitor.cc:77
int minNumberOfPixelsPerCluster_
Definition: LumiMonitor.cc:70
MEbinning lumi_binning_
Definition: LumiMonitor.cc:63
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:36
MEbinning ls_binning_
Definition: LumiMonitor.cc:65
Definition: Run.h:45
LumiMonitor(const edm::ParameterSet &)
Definition: LumiMonitor.cc:84