CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
DQMRivetClient Class Reference

#include <DQMRivetClient.h>

Inheritance diagram for DQMRivetClient:
edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  LumiOption
 
struct  NormOption
 
struct  ScaleFactorOption
 

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
 DQMRivetClient (const edm::ParameterSet &pset)
 
void endJob () override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
void normalizeToIntegral (const std::string &startDir, const std::string &histName, const std::string &normHistName)
 
void normalizeToLumi (const std::string &startDir, const std::string &histName, const std::string &normHistName, double xsection)
 
void scaleByFactor (const std::string &startDir, const std::string &histName, double factor)
 
 ~DQMRivetClient () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::vector< LumiOptionlumiOptions_
 
std::vector< NormOptionnormOptions_
 
std::string outputFileName_
 
std::vector< ScaleFactorOptionscaleOptions_
 
std::vector< std::string > subDirs_
 
DQMStoretheDQM
 
unsigned int verbose_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 12 of file DQMRivetClient.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 14 of file DQMRivetClient.h.

◆ MonitorElement

Definition at line 15 of file DQMRivetClient.h.

Constructor & Destructor Documentation

◆ DQMRivetClient()

DQMRivetClient::DQMRivetClient ( const edm::ParameterSet pset)

Definition at line 29 of file DQMRivetClient.cc.

References writedatasetfile::args, runTheMatrix::opt, or, muonDTDigis_cfi::pset, and HistogramManager_cfi::VPSet().

29  {
30  typedef std::vector<edm::ParameterSet> VPSet;
31  typedef std::vector<std::string> vstring;
32  typedef boost::escaped_list_separator<char> elsc;
33 
34  usesResource("DQMStore");
35 
36  elsc commonEscapes("\\", " \t", "\'");
37 
38  // Parse Normalization commands
39  vstring normCmds = pset.getUntrackedParameter<vstring>("normalizationToIntegral", vstring());
40  for (vstring::const_iterator normCmd = normCmds.begin(); normCmd != normCmds.end(); ++normCmd) {
41  if (normCmd->empty())
42  continue;
43  boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
44 
45  vector<string> args;
46  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
47  if (iToken->empty())
48  continue;
49  args.push_back(*iToken);
50  }
51 
52  if (args.empty() or args.size() > 2) {
53  LogInfo("DQMRivetClient") << "Wrong input to normCmds\n";
54  continue;
55  }
56 
57  NormOption opt;
58  opt.name = args[0];
59  opt.normHistName = args.size() == 2 ? args[1] : args[0];
60 
61  normOptions_.push_back(opt);
62  }
63 
64  VPSet normSets = pset.getUntrackedParameter<VPSet>("normalizationToIntegralSets", VPSet());
65  for (VPSet::const_iterator normSet = normSets.begin(); normSet != normSets.end(); ++normSet) {
66  NormOption opt;
67  opt.name = normSet->getUntrackedParameter<string>("name");
68  opt.normHistName = normSet->getUntrackedParameter<string>("normalizedTo", opt.name);
69 
70  normOptions_.push_back(opt);
71  }
72 
73  //normalize to lumi
74  vstring lumiCmds = pset.getUntrackedParameter<vstring>("normalizationToLumi", vstring());
75  for (vstring::const_iterator lumiCmd = lumiCmds.begin(); lumiCmd != lumiCmds.end(); ++lumiCmd) {
76  if (lumiCmd->empty())
77  continue;
78  boost::tokenizer<elsc> tokens(*lumiCmd, commonEscapes);
79 
80  vector<string> args;
81  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
82  if (iToken->empty())
83  continue;
84  args.push_back(*iToken);
85  }
86 
87  if (args.size() != 2) {
88  LogInfo("DQMRivetClient") << "Wrong input to lumiCmds\n";
89  continue;
90  }
91 
93  opt.name = args[0];
94  opt.normHistName = args[1];
95  opt.xsection = pset.getUntrackedParameter<double>("xsection", -1.);
96  //opt.xsection = atof(args[2].c_str());
97 
98  //std::cout << opt.name << " " << opt.normHistName << " " << opt.xsection << std::endl;
99  lumiOptions_.push_back(opt);
100  }
101 
102  //multiply by a number
103  vstring scaleCmds = pset.getUntrackedParameter<vstring>("scaleBy", vstring());
104  for (vstring::const_iterator scaleCmd = scaleCmds.begin(); scaleCmd != scaleCmds.end(); ++scaleCmd) {
105  if (scaleCmd->empty())
106  continue;
107  boost::tokenizer<elsc> tokens(*scaleCmd, commonEscapes);
108 
109  vector<string> args;
110  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
111  if (iToken->empty())
112  continue;
113  args.push_back(*iToken);
114  }
115 
116  if (args.empty() or args.size() > 2) {
117  LogInfo("DQMRivetClient") << "Wrong input to normCmds\n";
118  continue;
119  }
120 
121  ScaleFactorOption opt;
122  opt.name = args[0];
123  opt.scale = atof(args[1].c_str());
124  scaleOptions_.push_back(opt);
125  }
126 
127  outputFileName_ = pset.getUntrackedParameter<string>("outputFileName", "");
128  subDirs_ = pset.getUntrackedParameter<vstring>("subDirs");
129 }
std::vector< ScaleFactorOption > scaleOptions_
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< NormOption > normOptions_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::string outputFileName_
Log< level::Info, false > LogInfo
std::vector< LumiOption > lumiOptions_
std::vector< std::string > subDirs_

◆ ~DQMRivetClient()

DQMRivetClient::~DQMRivetClient ( )
inlineoverride

Definition at line 21 of file DQMRivetClient.h.

21 {};

Member Function Documentation

◆ analyze()

void DQMRivetClient::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
inlineoverridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 23 of file DQMRivetClient.h.

23 {};

◆ beginRun()

void DQMRivetClient::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
inlineoverride

Definition at line 27 of file DQMRivetClient.h.

27 {}

◆ endJob()

void DQMRivetClient::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 191 of file DQMRivetClient.cc.

References LogTrace.

191  {
192  // Update 2009-09-23
193  // Migrated all code from here to endRun
194 
195  LogTrace("DQMRivetClient") << "inside of ::endJob()" << endl;
196 }
#define LogTrace(id)

◆ endRun()

void DQMRivetClient::endRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 131 of file DQMRivetClient.cc.

References TrackerOfflineValidation_Dqm_cff::dirName, PostProcessor_cff::normalizeToIntegral, PostProcessor_cff::normalizeToLumi, Utilities::operator, and PostProcessorHcalIsoTrack_cfi::subDir.

131  {
132  typedef vector<string> vstring;
133 
134  // Update 2009-09-23
135  // Migrated all code from endJob to this function
136  // endJob is not necessarily called in the proper sequence
137  // and does not necessarily book histograms produced in
138  // that step.
139  // It more robust to do the histogram manipulation in
140  // this endRun function
141 
142  theDQM = nullptr;
144 
145  if (!theDQM) {
146  LogInfo("DQMRivetClient") << "Cannot create DQMStore instance\n";
147  return;
148  }
149 
150  // Process wildcard in the sub-directory
151  set<string> subDirSet;
152 
153  for (vstring::const_iterator iSubDir = subDirs_.begin(); iSubDir != subDirs_.end(); ++iSubDir) {
154  string subDir = *iSubDir;
155 
156  if (subDir[subDir.size() - 1] == '/')
157  subDir.erase(subDir.size() - 1);
158 
159  subDirSet.insert(subDir);
160  }
161 
162  for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
163  const string& dirName = *iSubDir;
164  for (vector<NormOption>::const_iterator normOption = normOptions_.begin(); normOption != normOptions_.end();
165  ++normOption) {
166  normalizeToIntegral(dirName, normOption->name, normOption->normHistName);
167  }
168  }
169 
170  for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
171  const string& dirName = *iSubDir;
172  for (vector<LumiOption>::const_iterator lumiOption = lumiOptions_.begin(); lumiOption != lumiOptions_.end();
173  ++lumiOption) {
174  normalizeToLumi(dirName, lumiOption->name, lumiOption->normHistName, lumiOption->xsection);
175  }
176  }
177 
178  for (set<string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
179  const string& dirName = *iSubDir;
180  for (vector<ScaleFactorOption>::const_iterator scaleOption = scaleOptions_.begin();
181  scaleOption != scaleOptions_.end();
182  ++scaleOption) {
183  scaleByFactor(dirName, scaleOption->name, scaleOption->scale);
184  }
185  }
186 
187  if (!outputFileName_.empty())
189 }
std::vector< ScaleFactorOption > scaleOptions_
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< NormOption > normOptions_
void scaleByFactor(const std::string &startDir, const std::string &histName, double factor)
std::string outputFileName_
void normalizeToIntegral(const std::string &startDir, const std::string &histName, const std::string &normHistName)
Log< level::Info, false > LogInfo
std::vector< LumiOption > lumiOptions_
DQMStore * theDQM
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:801
std::vector< std::string > subDirs_
void normalizeToLumi(const std::string &startDir, const std::string &histName, const std::string &normHistName, double xsection)

◆ normalizeToIntegral()

void DQMRivetClient::normalizeToIntegral ( const std::string &  startDir,
const std::string &  histName,
const std::string &  normHistName 
)

Definition at line 198 of file DQMRivetClient.cc.

References gpuVertexFinder::hist.

200  {
201  if (!theDQM->dirExists(startDir)) {
202  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
203  << "Cannot find sub-directory " << startDir << endl;
204  return;
205  }
206 
207  theDQM->cd();
208 
209  ME* element = theDQM->get(startDir + "/" + histName);
210  ME* normME = theDQM->get(startDir + "/" + normHistName);
211 
212  if (!element) {
213  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
214  << "No such element '" << histName << "' found\n";
215  return;
216  }
217 
218  if (!normME) {
219  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
220  << "No such element '" << normHistName << "' found\n";
221  return;
222  }
223 
224  TH1F* hist = element->getTH1F();
225  if (!hist) {
226  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
227  << "Cannot create TH1F from ME\n";
228  return;
229  }
230 
231  TH1F* normHist = normME->getTH1F();
232  if (!normHist) {
233  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
234  << "Cannot create TH1F from ME\n";
235  return;
236  }
237 
238  const double entries = normHist->Integral();
239  if (entries != 0) {
240  hist->Scale(1. / entries, "width");
241  } else {
242  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
243  << "Zero entries in histogram\n";
244  }
245 
246  return;
247 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
Definition: ME.h:11
__shared__ Hist hist
Log< level::Info, false > LogInfo
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
DQMStore * theDQM

◆ normalizeToLumi()

void DQMRivetClient::normalizeToLumi ( const std::string &  startDir,
const std::string &  histName,
const std::string &  normHistName,
double  xsection 
)

Definition at line 249 of file DQMRivetClient.cc.

References gpuVertexFinder::hist, PostProcessor_cff::normalizeToIntegral, and PostProcessor_cff::xsection.

252  {
253  normalizeToIntegral(startDir, histName, normHistName);
254  theDQM->cd();
255  ME* element = theDQM->get(startDir + "/" + histName);
256  TH1F* hist = element->getTH1F();
257  if (!hist) {
258  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
259  << "Cannot create TH1F from ME\n";
260  return;
261  }
262  hist->Scale(xsection);
263  return;
264 }
Definition: ME.h:11
void normalizeToIntegral(const std::string &startDir, const std::string &histName, const std::string &normHistName)
__shared__ Hist hist
Log< level::Info, false > LogInfo
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
DQMStore * theDQM

◆ scaleByFactor()

void DQMRivetClient::scaleByFactor ( const std::string &  startDir,
const std::string &  histName,
double  factor 
)

Definition at line 266 of file DQMRivetClient.cc.

References DQMScaleToClient_cfi::factor, and gpuVertexFinder::hist.

266  {
267  if (!theDQM->dirExists(startDir)) {
268  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
269  << "Cannot find sub-directory " << startDir << endl;
270  return;
271  }
272 
273  theDQM->cd();
274 
275  ME* element = theDQM->get(startDir + "/" + histName);
276 
277  if (!element) {
278  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
279  << "No such element '" << histName << "' found\n";
280  return;
281  }
282 
283  TH1F* hist = element->getTH1F();
284  if (!hist) {
285  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
286  << "Cannot create TH1F from ME\n";
287  return;
288  }
289  hist->Scale(factor);
290 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:747
Definition: ME.h:11
__shared__ Hist hist
Log< level::Info, false > LogInfo
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:690
DQMStore * theDQM

Member Data Documentation

◆ lumiOptions_

std::vector<LumiOption> DQMRivetClient::lumiOptions_
private

Definition at line 55 of file DQMRivetClient.h.

◆ normOptions_

std::vector<NormOption> DQMRivetClient::normOptions_
private

Definition at line 54 of file DQMRivetClient.h.

◆ outputFileName_

std::string DQMRivetClient::outputFileName_
private

Definition at line 52 of file DQMRivetClient.h.

◆ scaleOptions_

std::vector<ScaleFactorOption> DQMRivetClient::scaleOptions_
private

Definition at line 56 of file DQMRivetClient.h.

◆ subDirs_

std::vector<std::string> DQMRivetClient::subDirs_
private

Definition at line 51 of file DQMRivetClient.h.

◆ theDQM

DQMStore* DQMRivetClient::theDQM
private

Definition at line 50 of file DQMRivetClient.h.

◆ verbose_

unsigned int DQMRivetClient::verbose_
private

Definition at line 48 of file DQMRivetClient.h.