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  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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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< DQMGenericClient::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 wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 13 of file DQMRivetClient.h.

Member Typedef Documentation

Definition at line 15 of file DQMRivetClient.h.

Definition at line 16 of file DQMRivetClient.h.

Constructor & Destructor Documentation

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

Definition at line 32 of file DQMRivetClient.cc.

References writedatasetfile::args, edm::ParameterSet::getUntrackedParameter(), DQMRivetClient::LumiOption::name, DQMRivetClient::ScaleFactorOption::name, DQMGenericClient::NormOption::name, DQMRivetClient::LumiOption::normHistName, DQMGenericClient::NormOption::normHistName, runTheMatrix::opt, or, DQMRivetClient::ScaleFactorOption::scale, HistogramManager_cfi::VPSet(), and DQMRivetClient::LumiOption::xsection.

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

Definition at line 19 of file DQMRivetClient.h.

19 {};

Member Function Documentation

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

Definition at line 21 of file DQMRivetClient.h.

References HltBtagPostValidation_cff::c, endJob(), endRun(), and alignCSCRings::r.

21 {};
void DQMRivetClient::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 193 of file DQMRivetClient.cc.

References LogTrace.

Referenced by analyze().

193  {
194  // Update 2009-09-23
195  // Migrated all code from here to endRun
196 
197  LogTrace("DQMRivetClient") << "inside of DQMGenericClient::endJob()" << endl;
198 }
#define LogTrace(id)
void DQMRivetClient::endRun ( const edm::Run r,
const edm::EventSetup c 
)
override

EndRun.

Definition at line 132 of file DQMRivetClient.cc.

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

Referenced by analyze().

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

Definition at line 200 of file DQMRivetClient.cc.

References compare::hist.

202  {
203  if (!theDQM->dirExists(startDir)) {
204  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
205  << "Cannot find sub-directory " << startDir << endl;
206  return;
207  }
208 
209  theDQM->cd();
210 
211  ME* element = theDQM->get(startDir + "/" + histName);
212  ME* normME = theDQM->get(startDir + "/" + normHistName);
213 
214  if (!element) {
215  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
216  << "No such element '" << histName << "' found\n";
217  return;
218  }
219 
220  if (!normME) {
221  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
222  << "No such element '" << normHistName << "' found\n";
223  return;
224  }
225 
226  TH1F* hist = element->getTH1F();
227  if (!hist) {
228  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
229  << "Cannot create TH1F from ME\n";
230  return;
231  }
232 
233  TH1F* normHist = normME->getTH1F();
234  if (!normHist) {
235  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
236  << "Cannot create TH1F from ME\n";
237  return;
238  }
239 
240  const double entries = normHist->Integral();
241  if (entries != 0) {
242  hist->Scale(1. / entries, "width");
243  } else {
244  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
245  << "Zero entries in histogram\n";
246  }
247 
248  return;
249 }
void cd()
go to top directory (ie. root)
Definition: DQMStore.cc:621
Definition: ME.h:11
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1509
DQMStore * theDQM
bool dirExists(std::string const &path) const
true if directory exists
Definition: DQMStore.cc:698
void DQMRivetClient::normalizeToLumi ( const std::string &  startDir,
const std::string &  histName,
const std::string &  normHistName,
double  xsection 
)

Definition at line 251 of file DQMRivetClient.cc.

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

254  {
255  normalizeToIntegral(startDir, histName, normHistName);
256  theDQM->cd();
257  ME* element = theDQM->get(startDir + "/" + histName);
258  TH1F* hist = element->getTH1F();
259  if (!hist) {
260  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
261  << "Cannot create TH1F from ME\n";
262  return;
263  }
264  hist->Scale(xsection);
265  return;
266 }
void cd()
go to top directory (ie. root)
Definition: DQMStore.cc:621
Definition: ME.h:11
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1509
void normalizeToIntegral(const std::string &startDir, const std::string &histName, const std::string &normHistName)
DQMStore * theDQM
void DQMRivetClient::scaleByFactor ( const std::string &  startDir,
const std::string &  histName,
double  factor 
)

Definition at line 268 of file DQMRivetClient.cc.

References DEFINE_FWK_MODULE, and compare::hist.

268  {
269  if (!theDQM->dirExists(startDir)) {
270  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
271  << "Cannot find sub-directory " << startDir << endl;
272  return;
273  }
274 
275  theDQM->cd();
276 
277  ME* element = theDQM->get(startDir + "/" + histName);
278 
279  if (!element) {
280  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
281  << "No such element '" << histName << "' found\n";
282  return;
283  }
284 
285  TH1F* hist = element->getTH1F();
286  if (!hist) {
287  LogInfo("DQMRivetClient") << "normalizeToEntries() : "
288  << "Cannot create TH1F from ME\n";
289  return;
290  }
291  hist->Scale(factor);
292 }
void cd()
go to top directory (ie. root)
Definition: DQMStore.cc:621
Definition: ME.h:11
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1509
DQMStore * theDQM
bool dirExists(std::string const &path) const
true if directory exists
Definition: DQMStore.cc:698

Member Data Documentation

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

Definition at line 53 of file DQMRivetClient.h.

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

Definition at line 52 of file DQMRivetClient.h.

std::string DQMRivetClient::outputFileName_
private

Definition at line 50 of file DQMRivetClient.h.

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

Definition at line 54 of file DQMRivetClient.h.

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

Definition at line 49 of file DQMRivetClient.h.

DQMStore* DQMRivetClient::theDQM
private

Definition at line 48 of file DQMRivetClient.h.

unsigned int DQMRivetClient::verbose_
private

Definition at line 46 of file DQMRivetClient.h.