CMS 3D CMS Logo

DQMLumiMonitor.cc
Go to the documentation of this file.
1 /*
2  * \file DQMLumiMonitor.cc
3  * \author S. Dutta
4  * Last Update:
5  *
6  * Description: Pixel Luminosity Monitoring
7  *
8 */
9 #include <string>
10 #include <vector>
11 #include <map>
12 
25 
26 #include "TPRegexp.h"
27 
28 //
29 // class declaration
30 //
31 
32 class DQMLumiMonitor : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
33 public:
37  ~DQMLumiMonitor() override = default;
38 
39 protected:
40  void beginJob() override;
41  void beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) override;
42  void analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
43  void beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& eSetup) override;
44  void endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& eSetup) override;
45  void endRun(edm::Run const& iRun, edm::EventSetup const& iSetup) override;
46 
47 private:
48  void bookHistograms();
49 
51 
56 
58 
63 
64  float intLumi_;
65  int nLumi_;
66  unsigned long long m_cacheID_;
67 };
68 
69 // -----------------------------
70 // constructors and destructor
71 // -----------------------------
72 
73 DQMLumiMonitor::DQMLumiMonitor(const edm::ParameterSet& ps) : parameters_(ps) {
77  consumes<edmNew::DetSetVector<SiPixelCluster> >(parameters_.getParameter<edm::InputTag>("PixelClusterInputTag"));
78  lumiRecordName_ = consumes<LumiSummary, edm::InLumi>(parameters_.getParameter<std::string>("LumiRecordName"));
79 
80  nClusME_ = nullptr;
81  nClusVsLSME_ = nullptr;
82  intLumiVsLSME_ = nullptr;
83  corrIntLumiAndClusVsLSME_ = nullptr;
84 }
85 
87  edm::ParameterSet ClusHistoPar = parameters_.getParameter<edm::ParameterSet>("TH1ClusPar");
88  edm::ParameterSet LumiHistoPar = parameters_.getParameter<edm::ParameterSet>("TH1LumiPar");
89  edm::ParameterSet LumiSecHistoPar = parameters_.getParameter<edm::ParameterSet>("TH1LSPar");
90 
91  std::string currentFolder = moduleName_ + "/" + folderName_;
92  dbe_->setCurrentFolder(currentFolder);
93 
94  if (nClusME_ == nullptr)
95  nClusME_ = dbe_->book1D("nPlxClus",
96  " Number of Pixel Clusters ",
97  ClusHistoPar.getParameter<int32_t>("Xbins"),
98  ClusHistoPar.getParameter<double>("Xmin"),
99  ClusHistoPar.getParameter<double>("Xmax"));
100  else
101  nClusME_->Reset();
102  if (nClusVsLSME_ == nullptr)
103  nClusVsLSME_ = dbe_->bookProfile("nClusVsLS",
104  " Number of Pixel Cluster Vs LS number",
105  LumiSecHistoPar.getParameter<int32_t>("Xbins"),
106  LumiSecHistoPar.getParameter<double>("Xmin"),
107  LumiSecHistoPar.getParameter<double>("Xmax"),
108  0.0,
109  0.0,
110  "");
111  else
112  nClusVsLSME_->Reset();
113  if (intLumiVsLSME_ == nullptr)
114  intLumiVsLSME_ = dbe_->bookProfile("intLumiVsLS",
115  " Integrated Luminosity Vs LS number",
116  LumiSecHistoPar.getParameter<int32_t>("Xbins"),
117  LumiSecHistoPar.getParameter<double>("Xmin"),
118  LumiSecHistoPar.getParameter<double>("Xmax"),
119  0.0,
120  0.0,
121  "");
122  else
124 
125  if (corrIntLumiAndClusVsLSME_ == nullptr)
126  corrIntLumiAndClusVsLSME_ = dbe_->bookProfile2D("corrIntLumiAndClusVsLS",
127  " Correlation of nCluster and Integrated Luminosity Vs LS number",
128  LumiSecHistoPar.getParameter<int32_t>("Xbins"),
129  LumiSecHistoPar.getParameter<double>("Xmin"),
130  LumiSecHistoPar.getParameter<double>("Xmax"),
131  LumiHistoPar.getParameter<int32_t>("Xbins"),
132  LumiHistoPar.getParameter<double>("Xmin"),
133  LumiHistoPar.getParameter<double>("Xmax"),
134  0.0,
135  0.0);
136  else
138 }
141  intLumi_ = -1.0;
142  nLumi_ = -1;
143 }
144 
145 void DQMLumiMonitor::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) { bookHistograms(); }
147  //Access Pixel Clusters
150 
151  if (!siPixelClusters.isValid()) {
152  edm::LogError("PixelLumiMonotor") << "Could not find Cluster Collection ";
153  return;
154  }
155  unsigned int nClusterPix = (*siPixelClusters).dataSize();
156  nClusME_->Fill(nClusterPix);
157  if (nLumi_ != -1)
158  nClusVsLSME_->Fill(nLumi_, nClusterPix);
159  if (intLumi_ != -1 || nLumi_ != -1)
161 }
162 
164 
166  edm::LogInfo("PixelLumiMonotor") << " Run Number " << lumiBlock.run() << " Lumi Section Numnber "
167  << lumiBlock.luminosityBlock();
168 
169  nLumi_ = lumiBlock.luminosityBlock();
170 
171  // Access Lumi Summary
172  edm::Handle<LumiSummary> lumiSummary_;
173  lumiBlock.getByToken(lumiRecordName_, lumiSummary_);
174  if (lumiSummary_->isValid()) {
175  intLumi_ = lumiSummary_->intgDelLumi();
176  edm::LogInfo("PixelLumiMonotor") << " Luminosity in this Lumi Section " << intLumi_;
178  } else {
179  edm::LogError("PixelLumiMonotor") << "No valid data found!";
180  }
181  /*
182  // Access Lumi Details
183  Handle<LumiDetails> lumiDetails;
184  lumiBlock.getByLabel("expressLumiProducer", lumiDetails);
185  if(lumiDetails->isValid()){
186  std::cout<<"valid detail"<<std::endl;
187  }else{
188  std::cout << "no valid lumi detail data" <<std::endl;
189  } */
190 }
191 
192 void DQMLumiMonitor::endRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
193 
194 // Define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool isValid() const
Definition: LumiSummary.cc:50
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:485
edm::EDGetTokenT< LumiSummary > lumiRecordName_
MonitorElement * corrIntLumiAndClusVsLSME_
void endRun(edm::Run const &iRun, edm::EventSetup const &iSetup) override
edm::ParameterSet parameters_
dqm::legacy::DQMStore DQMStore
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
DQMStore * dbe_
float intgDelLumi() const
Definition: LumiSummary.cc:16
edm::EDGetTokenT< edmNew::DetSetVector< SiPixelCluster > > pixelClusterInputTag_
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:656
Log< level::Error, false > LogError
void Fill(long long x)
dqm::legacy::MonitorElement MonitorElement
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &eSetup) override
int iEvent
Definition: GenABIO.cc:224
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:408
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void beginRun(edm::Run const &iRun, edm::EventSetup const &iSetup) override
MonitorElement * nClusVsLSME_
Log< level::Info, false > LogInfo
DQMLumiMonitor(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::string moduleName_
~DQMLumiMonitor() override=default
void beginJob() override
MonitorElement * nClusME_
std::string folderName_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * intLumiVsLSME_
Definition: Run.h:45
unsigned long long m_cacheID_