CMS 3D CMS Logo

LumiMonitor.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <map>
4 
22 
23 namespace {
26  struct MEbinning {
27  int nbins;
28  double xmin;
29  double xmax;
30  };
31 
32  struct Histograms {
33  dqm::reco::MonitorElement* numberOfPixelClustersVsLS;
34  dqm::reco::MonitorElement* numberOfPixelClustersVsLumi;
35  dqm::reco::MonitorElement* lumiVsLS;
37  dqm::reco::MonitorElement* pixelLumiVsLS;
38  dqm::reco::MonitorElement* pixelLumiVsLumi;
39  };
40 } // namespace
41 
42 //
43 // class declaration
44 //
45 
46 class LumiMonitor : public DQMGlobalEDAnalyzer<Histograms> {
47 public:
49  ~LumiMonitor() override = default;
50  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
53 
54 private:
55  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
56  void dqmAnalyze(edm::Event const&, edm::EventSetup const&, Histograms const&) const override;
57 
58  static MEbinning getHistoPSet(const edm::ParameterSet& pset);
59  static MEbinning getHistoLSPSet(const edm::ParameterSet& pset);
60 
62 
64  MEbinning lumi_binning_;
65  MEbinning pu_binning_;
66  MEbinning ls_binning_;
67 
74  MEbinning pixellumi_binning_;
75 
77 
79 };
80 
81 // -----------------------------
82 // constructors and destructor
83 // -----------------------------
84 
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"))
97  : edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster>>()),
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 = edm::get<TrackerTopology, TrackerTopologyRcd>(setup);
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 
279  histoPSet.add("pixelClusterPSet", pixelClusterPSet);
280 
284 
288 
292 
296 
297  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
298 
299  descriptions.add("lumiMonitor", desc);
300 }
301 
302 // Define this as a plug-in
ConfigurationDescriptions.h
LumiMonitor::ls_binning_
MEbinning ls_binning_
Definition: LumiMonitor.cc:66
LumiMonitor::getHistoPSet
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:114
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
LumiScalers.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
MessageLogger.h
LumiMonitor_cff.pixelClusters
pixelClusters
Definition: LumiMonitor_cff.py:10
funct::false
false
Definition: Factorize.h:29
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
LumiMonitor::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Definition: LumiMonitor.cc:126
ESHandle.h
LumiMonitor
Definition: LumiMonitor.cc:46
LumiMonitor::minPixelClusterCharge_
float minPixelClusterCharge_
Definition: LumiMonitor.cc:72
edm::Run
Definition: Run.h:45
LumiMonitor::LumiMonitor
LumiMonitor(const edm::ParameterSet &)
Definition: LumiMonitor.cc:85
edm::EDGetTokenT< LumiScalersCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
GetLumi::CM2_TO_NANOBARN
static constexpr double CM2_TO_NANOBARN
Definition: GetLumi.h:42
V0Monitor_cfi.lumiScalers
lumiScalers
Definition: V0Monitor_cfi.py:9
SiPixelCluster.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
LumiMonitor::~LumiMonitor
~LumiMonitor() override=default
GetLumi::XSEC_PIXEL_CLUSTER
static constexpr double XSEC_PIXEL_CLUSTER
Definition: GetLumi.h:36
LumiMonitor_cff.puPSet
puPSet
Definition: LumiMonitor_cff.py:23
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:27
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edmNew
Definition: DetSet2RangeMap.h:11
LumiMonitor::pixelClustersToken_
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
Definition: LumiMonitor.cc:69
config
Definition: config.py:1
DetId
Definition: DetId.h:17
LumiMonitor::lumiSummaryToken_
edm::EDGetTokenT< LumiSummary > lumiSummaryToken_
Definition: LumiMonitor.cc:76
MakerMacros.h
TrackerTopology.h
LumiMonitor::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: LumiMonitor.cc:266
TrackerTopologyRcd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:727
LumiMonitor_cff.lsPSet
lsPSet
Definition: LumiMonitor_cff.py:33
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
LumiMonitor_cff.pixellumiPSet
pixellumiPSet
Definition: LumiMonitor_cff.py:28
LumiMonitor::folderName_
std::string folderName_
Definition: LumiMonitor.cc:61
LumiMonitor::lumiScalersToken_
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
Definition: LumiMonitor.cc:63
LumiMonitor::pixellumi_binning_
MEbinning pixellumi_binning_
Definition: LumiMonitor.cc:74
dqm::implementation::IBooker::bookProfile
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
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
GetLumi::FREQ_ORBIT
static constexpr double FREQ_ORBIT
Definition: GetLumi.h:26
LumiMonitor::fillHistoPSetDescription
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
Definition: LumiMonitor.cc:258
ParameterSetDescription.h
LumiMonitor_cff.lumiPSet
lumiPSet
Definition: LumiMonitor_cff.py:18
EDGetToken.h
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
LumiMonitor::fillHistoLSPSetDescription
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
Definition: LumiMonitor.cc:264
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
LumiDetails.h
LumiMonitor::getHistoLSPSet
static MEbinning getHistoLSPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:122
ParameterSet
Definition: Functions.h:16
LumiScalersCollection
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:144
createfilelist.int
int
Definition: createfilelist.py:10
LumiMonitor_cff.histoPSet
histoPSet
Definition: LumiMonitor_cff.py:12
edm::EventSetup
Definition: EventSetup.h:57
histograms
Definition: histograms.py:1
GetLumi::rXSEC_PIXEL_CLUSTER
static constexpr double rXSEC_PIXEL_CLUSTER
Definition: GetLumi.h:40
LumiMonitor::lumi_binning_
MEbinning lumi_binning_
Definition: LumiMonitor.cc:64
GetLumi.h
GetLumi::SECONDS_PER_LS
static constexpr double SECONDS_PER_LS
Definition: GetLumi.h:27
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
LumiMonitor::lumi_factor_per_bx_
float lumi_factor_per_bx_
Definition: LumiMonitor.cc:78
Frameworkfwd.h
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
phase2tkutil::DQMStore
dqm::reco::DQMStore DQMStore
Definition: TrackerPhase2DQMUtil.h:16
LumiMonitor_cff.pixelClusterPSet
pixelClusterPSet
Definition: LumiMonitor_cff.py:13
LumiSummary.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: SiPixelSCurveCalibrationAnalysis.h:55
dqm::implementation::IBooker
Definition: DQMStore.h:43
DQMGlobalEDAnalyzer
Definition: DQMGlobalEDAnalyzer.h:76
LumiMonitor::minNumberOfPixelsPerCluster_
int minNumberOfPixelsPerCluster_
Definition: LumiMonitor.cc:71
ParameterSet.h
LumiMonitor::useBPixLayer1_
bool useBPixLayer1_
Definition: LumiMonitor.cc:70
LumiMonitor::doPixelLumi_
bool doPixelLumi_
Definition: LumiMonitor.cc:68
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
LumiMonitor::pixelCluster_binning_
MEbinning pixelCluster_binning_
Definition: LumiMonitor.cc:73
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
LumiMonitor::dqmAnalyze
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms const &) const override
Definition: LumiMonitor.cc:199
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
DQMGlobalEDAnalyzer.h
LumiMonitor::pu_binning_
MEbinning pu_binning_
Definition: LumiMonitor.cc:65