CMS 3D CMS Logo

LumiMonitor.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <map>
4 
23 
24 namespace {
25  struct MEbinning {
26  int nbins;
27  double xmin;
28  double xmax;
29  };
30 
31  struct Histograms {
32  ConcurrentMonitorElement numberOfPixelClustersVsLS;
33  ConcurrentMonitorElement numberOfPixelClustersVsLumi;
34  ConcurrentMonitorElement lumiVsLS;
36  ConcurrentMonitorElement pixelLumiVsLS;
37  ConcurrentMonitorElement pixelLumiVsLumi;
38  };
39 }
40 
41 //
42 // class declaration
43 //
44 
45 class LumiMonitor : public DQMGlobalEDAnalyzer<Histograms>
46 {
47 public:
49  ~LumiMonitor() override = default;
50  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
51  static void fillHistoPSetDescription(edm::ParameterSetDescription & pset);
52  static void fillHistoLSPSetDescription(edm::ParameterSetDescription & pset);
53 
54 private:
55  void bookHistograms(DQMStore::ConcurrentBooker &, 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 
78 
80 
81 };
82 
83 
84 // -----------------------------
85 // constructors and destructor
86 // -----------------------------
87 
89  folderName_ ( config.getParameter<std::string>("FolderName") )
90  , lumiScalersToken_ ( consumes<LumiScalersCollection>(config.getParameter<edm::InputTag>("scalers") ) )
91  , lumi_binning_ ( getHistoPSet (config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lumiPSet")) )
92  , pu_binning_ ( getHistoPSet (config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("puPSet")) )
93  , ls_binning_ ( getHistoLSPSet(config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("lsPSet")) )
94  , doPixelLumi_ ( config.getParameter<bool>("doPixelLumi") )
95  , pixelClustersToken_ ( doPixelLumi_ ? consumes<edmNew::DetSetVector<SiPixelCluster>>(config.getParameter<edm::InputTag>("pixelClusters") ) : 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").getParameter<edm::ParameterSet>("pixelClusterPSet")) : MEbinning {} )
100  , pixellumi_binning_ ( doPixelLumi_ ? getHistoPSet(config.getParameter<edm::ParameterSet>("histoPSet").getParameter<edm::ParameterSet>("pixellumiPSet")) : MEbinning {} )
101 {
102  if(useBPixLayer1_) {
104  } else {
106  }
107 }
108 
110 {
111  return MEbinning{
112  pset.getParameter<int32_t>("nbins"),
113  pset.getParameter<double>("xmin"),
114  pset.getParameter<double>("xmax"),
115  };
116 }
117 
119 {
120  return MEbinning{
121  pset.getParameter<int32_t>("nbins"),
122  -0.5,
123  pset.getParameter<int32_t>("nbins") - 0.5
124  };
125 }
126 
128 {
130 
131  if (doPixelLumi_) {
132  histograms.numberOfPixelClustersVsLS = booker.book1D(
133  "numberOfPixelClustersVsLS",
134  "number of pixel clusters vs LS",
135  ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax);
136  histograms.numberOfPixelClustersVsLS.setAxisTitle("LS", 1);
137  histograms.numberOfPixelClustersVsLS.setAxisTitle("number of pixel clusters", 2);
138 
139  histograms.numberOfPixelClustersVsLumi = booker.bookProfile(
140  "numberOfPixelClustersVsLumi",
141  "number of pixel clusters vs scal lumi",
142  lumi_binning_.nbins, lumi_binning_.xmin, lumi_binning_.xmax,
144  histograms.numberOfPixelClustersVsLumi.setAxisTitle("scal inst lumi E30 [Hz cm^{-2}]", 1);
145  histograms.numberOfPixelClustersVsLumi.setAxisTitle("number of pixel clusters", 2);
146 
147  histograms.pixelLumiVsLS = booker.bookProfile(
148  "pixelLumiVsLS",
149  "pixel-lumi vs LS",
150  ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax,
152  histograms.pixelLumiVsLS.setAxisTitle("LS", 1);
153  histograms.pixelLumiVsLS.setAxisTitle("pixel-based inst lumi E30 [Hz cm^{-2}]", 2);
154 
155  histograms.pixelLumiVsLumi = booker.bookProfile(
156  "pixelLumiVsLumi",
157  "pixel-lumi vs scal lumi",
158  lumi_binning_.nbins, lumi_binning_.xmin, lumi_binning_.xmax,
159  pixellumi_binning_.xmin, lumi_binning_.xmax);
160  histograms.pixelLumiVsLumi.setAxisTitle("scal inst lumi E30 [Hz cm^{-2}]", 1);
161  histograms.pixelLumiVsLumi.setAxisTitle("pixel-based inst lumi E30 [Hz cm^{-2}]", 2);
162  }
163 
164  histograms.lumiVsLS = booker.bookProfile(
165  "lumiVsLS",
166  "scal lumi vs LS",
167  ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax,
168  lumi_binning_.xmin, lumi_binning_.xmax);
169  histograms.lumiVsLS.setAxisTitle("LS", 1);
170  histograms.lumiVsLS.setAxisTitle("scal inst lumi E30 [Hz cm^{-2}]", 2);
171 
172  histograms.puVsLS = booker.bookProfile(
173  "puVsLS",
174  "scal PU vs LS",
175  ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax,
176  pu_binning_.xmin, pu_binning_.xmax);
177  histograms.puVsLS.setAxisTitle("LS", 1);
178  histograms.puVsLS.setAxisTitle("scal PU", 2);
179 
180 }
181 
182 void LumiMonitor::dqmAnalyze(edm::Event const& event, edm::EventSetup const& setup, Histograms const& histograms) const
183 {
184  int ls = event.id().luminosityBlock();
185 
186  float scal_lumi = -1.;
187  float scal_pu = -1.;
189  event.getByToken(lumiScalersToken_, lumiScalers);
190  if (lumiScalers.isValid() and not lumiScalers->empty()) {
191  auto scalit = lumiScalers->begin();
192  scal_lumi = scalit->instantLumi();
193  scal_pu = scalit->pileup();
194  } else {
195  scal_lumi = -1.;
196  scal_pu = -1.;
197  }
198  histograms.lumiVsLS.fill(ls, scal_lumi);
199  histograms.puVsLS.fill(ls, scal_pu);
200 
201  if (doPixelLumi_) {
202  size_t pixel_clusters = 0;
203  float pixel_lumi = -1.;
205  event.getByToken(pixelClustersToken_, pixelClusters);
206  if (pixelClusters.isValid()) {
207  auto const& tTopo = edm::get<TrackerTopology, TrackerTopologyRcd>(setup);
208 
209  // Count the number of clusters with at least a minimum
210  // number of pixels per cluster and at least a minimum charge.
211  size_t tot = 0;
212  for (auto pixCluDet = pixelClusters->begin(); pixCluDet != pixelClusters->end(); ++pixCluDet) {
213 
214  DetId detid = pixCluDet->detId();
215  size_t subdetid = detid.subdetId();
216  if (subdetid == (int) PixelSubdetector::PixelBarrel) {
217  if (tTopo.layer(detid)==1) {
218  continue;
219  }
220  }
221 
222  for (auto pixClu = pixCluDet->begin(); pixClu != pixCluDet->end(); ++pixClu) {
223  ++tot;
224  if ((pixClu->size() >= minNumberOfPixelsPerCluster_) and
225  (pixClu->charge() >= minPixelClusterCharge_ )) {
226  ++pixel_clusters;
227  }
228  }
229  }
230  pixel_lumi = lumi_factor_per_bx_ * pixel_clusters / GetLumi::CM2_TO_NANOBARN ; // ?!?!
231  } else {
232  pixel_lumi = -1.;
233  }
234 
235  histograms.numberOfPixelClustersVsLS.fill(ls, pixel_clusters);
236  histograms.numberOfPixelClustersVsLumi.fill(scal_lumi, pixel_clusters);
237  histograms.pixelLumiVsLS.fill(ls, pixel_lumi);
238  histograms.pixelLumiVsLumi.fill(scal_lumi, pixel_lumi);
239  }
240 
241 }
242 
244 {
245  pset.add<int> ( "nbins");
246  pset.add<double>( "xmin" );
247  pset.add<double>( "xmax" );
248 }
249 
251 {
252  pset.add<int> ( "nbins", 2500);
253 }
254 
256 {
258  desc.add<edm::InputTag>( "pixelClusters", edm::InputTag("hltSiPixelClusters") );
259  desc.add<edm::InputTag>( "scalers", edm::InputTag("hltScalersRawToDigi"));
260  desc.add<std::string> ( "FolderName", "HLT/LumiMonitoring" );
261  desc.add<bool> ( "doPixelLumi", false );
262  desc.add<bool> ( "useBPixLayer1", false );
263  desc.add<int> ( "minNumberOfPixelsPerCluster", 2 ); // from DQM/PixelLumi/python/PixelLumiDQM_cfi.py
264  desc.add<double> ( "minPixelClusterCharge", 15000. );
265 
267  edm::ParameterSetDescription pixelClusterPSet;
268  LumiMonitor::fillHistoPSetDescription(pixelClusterPSet);
269  histoPSet.add("pixelClusterPSet", pixelClusterPSet);
270 
272  fillHistoPSetDescription(lumiPSet);
273  histoPSet.add<edm::ParameterSetDescription>("lumiPSet", lumiPSet);
274 
276  fillHistoPSetDescription(puPSet);
277  histoPSet.add<edm::ParameterSetDescription>("puPSet", puPSet);
278 
279  edm::ParameterSetDescription pixellumiPSet;
280  fillHistoPSetDescription(pixellumiPSet);
281  histoPSet.add<edm::ParameterSetDescription>("pixellumiPSet", pixellumiPSet);
282 
285  histoPSet.add<edm::ParameterSetDescription>("lsPSet", lsPSet);
286 
287  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
288 
289  descriptions.add("lumiMonitor", desc);
290 }
291 
292 // Define this as a plug-in
T getParameter(std::string const &) const
ConcurrentMonitorElement bookProfile(Args &&...args)
Definition: DQMStore.h:167
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, Histograms const &) const override
Definition: LumiMonitor.cc:182
bool useBPixLayer1_
Definition: LumiMonitor.cc:70
static MEbinning getHistoPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:109
MEbinning pu_binning_
Definition: LumiMonitor.cc:65
float minPixelClusterCharge_
Definition: LumiMonitor.cc:72
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
Definition: config.py:1
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClustersToken_
Definition: LumiMonitor.cc:69
static double XSEC_PIXEL_CLUSTER
Definition: GetLumi.h:41
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Definition: LumiMonitor.cc:127
edm::EDGetTokenT< LumiSummary > lumiSummaryToken_
Definition: LumiMonitor.cc:76
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: LumiMonitor.cc:255
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::string folderName_
Definition: LumiMonitor.cc:61
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
Definition: LumiMonitor.cc:63
MEbinning pixellumi_binning_
Definition: LumiMonitor.cc:74
example_global void dqmAnalyze(edm::Event const &,@example_global edm::EventSetup const &,@example_global Histograms___class__ const &) const override
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
ConcurrentMonitorElement book1D(Args &&...args)
Definition: DQMStore.h:160
static void fillHistoLSPSetDescription(edm::ParameterSetDescription &pset)
Definition: LumiMonitor.cc:250
static double CM2_TO_NANOBARN
Definition: GetLumi.h:47
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset)
Definition: LumiMonitor.cc:243
Definition: DetId.h:18
def ls(path, rec=False)
Definition: eostools.py:349
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static MEbinning getHistoLSPSet(const edm::ParameterSet &pset)
Definition: LumiMonitor.cc:118
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static double rXSEC_PIXEL_CLUSTER
Definition: GetLumi.h:45
bool doPixelLumi_
Definition: LumiMonitor.cc:68
MEbinning pixelCluster_binning_
Definition: LumiMonitor.cc:73
Pixel cluster – collection of neighboring pixels above threshold.
HLT enums.
float lumi_factor_per_bx_
Definition: LumiMonitor.cc:79
int minNumberOfPixelsPerCluster_
Definition: LumiMonitor.cc:71
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:160
MEbinning lumi_binning_
Definition: LumiMonitor.cc:64
static double FREQ_ORBIT
Definition: GetLumi.h:32
MEbinning ls_binning_
Definition: LumiMonitor.cc:66
Definition: event.py:1
Definition: Run.h:45
LumiMonitor(const edm::ParameterSet &)
Definition: LumiMonitor.cc:88
static double SECONDS_PER_LS
Definition: GetLumi.h:33