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::EDAnalyzer 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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup) override
 
 DQMRivetClient (const edm::ParameterSet &pset)
 
void endJob () override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 EndRun. More...
 
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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
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::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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.

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  elsc commonEscapes("\\", " \t", "\'");
35 
36  // Parse Normalization commands
37  vstring normCmds = pset.getUntrackedParameter<vstring>("normalizationToIntegral", vstring());
38  for (vstring::const_iterator normCmd = normCmds.begin(); normCmd != normCmds.end(); ++normCmd) {
39  if (normCmd->empty())
40  continue;
41  boost::tokenizer<elsc> tokens(*normCmd, commonEscapes);
42 
43  vector<string> args;
44  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
45  if (iToken->empty())
46  continue;
47  args.push_back(*iToken);
48  }
49 
50  if (args.empty() or args.size() > 2) {
51  LogInfo("DQMRivetClient") << "Wrong input to normCmds\n";
52  continue;
53  }
54 
55  NormOption opt;
56  opt.name = args[0];
57  opt.normHistName = args.size() == 2 ? args[1] : args[0];
58 
59  normOptions_.push_back(opt);
60  }
61 
62  VPSet normSets = pset.getUntrackedParameter<VPSet>("normalizationToIntegralSets", VPSet());
63  for (VPSet::const_iterator normSet = normSets.begin(); normSet != normSets.end(); ++normSet) {
64  NormOption opt;
65  opt.name = normSet->getUntrackedParameter<string>("name");
66  opt.normHistName = normSet->getUntrackedParameter<string>("normalizedTo", opt.name);
67 
68  normOptions_.push_back(opt);
69  }
70 
71  //normalize to lumi
72  vstring lumiCmds = pset.getUntrackedParameter<vstring>("normalizationToLumi", vstring());
73  for (vstring::const_iterator lumiCmd = lumiCmds.begin(); lumiCmd != lumiCmds.end(); ++lumiCmd) {
74  if (lumiCmd->empty())
75  continue;
76  boost::tokenizer<elsc> tokens(*lumiCmd, commonEscapes);
77 
78  vector<string> args;
79  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
80  if (iToken->empty())
81  continue;
82  args.push_back(*iToken);
83  }
84 
85  if (args.size() != 2) {
86  LogInfo("DQMRivetClient") << "Wrong input to lumiCmds\n";
87  continue;
88  }
89 
91  opt.name = args[0];
92  opt.normHistName = args[1];
93  opt.xsection = pset.getUntrackedParameter<double>("xsection", -1.);
94  //opt.xsection = atof(args[2].c_str());
95 
96  //std::cout << opt.name << " " << opt.normHistName << " " << opt.xsection << std::endl;
97  lumiOptions_.push_back(opt);
98  }
99 
100  //multiply by a number
101  vstring scaleCmds = pset.getUntrackedParameter<vstring>("scaleBy", vstring());
102  for (vstring::const_iterator scaleCmd = scaleCmds.begin(); scaleCmd != scaleCmds.end(); ++scaleCmd) {
103  if (scaleCmd->empty())
104  continue;
105  boost::tokenizer<elsc> tokens(*scaleCmd, commonEscapes);
106 
107  vector<string> args;
108  for (boost::tokenizer<elsc>::const_iterator iToken = tokens.begin(); iToken != tokens.end(); ++iToken) {
109  if (iToken->empty())
110  continue;
111  args.push_back(*iToken);
112  }
113 
114  if (args.empty() or args.size() > 2) {
115  LogInfo("DQMRivetClient") << "Wrong input to normCmds\n";
116  continue;
117  }
118 
119  ScaleFactorOption opt;
120  opt.name = args[0];
121  opt.scale = atof(args[1].c_str());
122  scaleOptions_.push_back(opt);
123  }
124 
125  outputFileName_ = pset.getUntrackedParameter<string>("outputFileName", "");
126  subDirs_ = pset.getUntrackedParameter<vstring>("subDirs");
127 }

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

◆ ~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::EDAnalyzer.

Definition at line 23 of file DQMRivetClient.h.

23 {};

◆ endJob()

void DQMRivetClient::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 189 of file DQMRivetClient.cc.

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

References LogTrace.

◆ endRun()

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 129 of file DQMRivetClient.cc.

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

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

◆ normalizeToIntegral()

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

Definition at line 196 of file DQMRivetClient.cc.

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

References compare::hist.

◆ normalizeToLumi()

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

Definition at line 247 of file DQMRivetClient.cc.

250  {
251  normalizeToIntegral(startDir, histName, normHistName);
252  theDQM->cd();
253  ME* element = theDQM->get(startDir + "/" + histName);
254  TH1F* hist = element->getTH1F();
255  if (!hist) {
256  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
257  << "Cannot create TH1F from ME\n";
258  return;
259  }
260  hist->Scale(xsection);
261  return;
262 }

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

◆ scaleByFactor()

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

Definition at line 264 of file DQMRivetClient.cc.

264  {
265  if (!theDQM->dirExists(startDir)) {
266  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
267  << "Cannot find sub-directory " << startDir << endl;
268  return;
269  }
270 
271  theDQM->cd();
272 
273  ME* element = theDQM->get(startDir + "/" + histName);
274 
275  if (!element) {
276  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
277  << "No such element '" << histName << "' found\n";
278  return;
279  }
280 
281  TH1F* hist = element->getTH1F();
282  if (!hist) {
283  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
284  << "Cannot create TH1F from ME\n";
285  return;
286  }
287  hist->Scale(factor);
288 }

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

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.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
DQMRivetClient::lumiOptions_
std::vector< LumiOption > lumiOptions_
Definition: DQMRivetClient.h:55
DQMRivetClient::normOptions_
std::vector< NormOption > normOptions_
Definition: DQMRivetClient.h:54
DQMRivetClient::normalizeToLumi
void normalizeToLumi(const std::string &startDir, const std::string &histName, const std::string &normHistName, double xsection)
Definition: DQMRivetClient.cc:247
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
runTheMatrix.opt
opt
Definition: runTheMatrix.py:291
PostProcessorHcalIsoTrack_cfi.subDir
subDir
Definition: PostProcessorHcalIsoTrack_cfi.py:5
compare.hist
hist
Definition: compare.py:376
DQMRivetClient::subDirs_
std::vector< std::string > subDirs_
Definition: DQMRivetClient.h:51
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:761
DQMRivetClient::scaleByFactor
void scaleByFactor(const std::string &startDir, const std::string &histName, double factor)
Definition: DQMRivetClient.cc:264
DQMRivetClient::outputFileName_
std::string outputFileName_
Definition: DQMRivetClient.h:52
DQMRivetClient::theDQM
DQMStore * theDQM
Definition: DQMRivetClient.h:50
edm::Service
Definition: Service.h:30
DQMRivetClient::normalizeToIntegral
void normalizeToIntegral(const std::string &startDir, const std::string &histName, const std::string &normHistName)
Definition: DQMRivetClient.cc:196
DQMRivetClient::scaleOptions_
std::vector< ScaleFactorOption > scaleOptions_
Definition: DQMRivetClient.h:56
HistogramManager_cfi.VPSet
def VPSet(*args)
Definition: HistogramManager_cfi.py:401
ME
Definition: ME.h:11
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
TrackerOfflineValidation_Dqm_cff.dirName
dirName
Definition: TrackerOfflineValidation_Dqm_cff.py:55
or
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
vstring
vector< string > vstring
Definition: ExoticaDQM.cc:8
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
dqm::implementation::IGetter::dirExists
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:708
DQMRivetClient::LumiOption
Definition: DQMRivetClient.h:30
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqm::implementation::DQMStore::cd
void cd() override
Definition: DQMStore.h:564
PostProcessor_cff.xsection
xsection
Definition: PostProcessor_cff.py:228