CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
DQMGenericTnPClient Class Reference
Inheritance diagram for DQMGenericTnPClient:
edm::EDAnalyzer edm::EDConsumerBase

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
 
void calculateEfficiency (const std::string &dirName, const ParameterSet &pset)
 
 DQMGenericTnPClient (const edm::ParameterSet &pset)
 
void endRun (const edm::Run &run, const edm::EventSetup &setup) override
 
void findAllSubdirectories (const std::string &dir, std::set< std::string > *myList, TString pattern)
 
 ~DQMGenericTnPClient () 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
 
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

DQMStoredqmStore
 
const VParameterSet efficiencies
 
GaussianPlusLinearFitterGPLfitter
 
std::string myDQMrootFolder
 
TFile * plots
 
vstring subDirs
 
bool verbose
 
VoigtianPlusExponentialFitterVPEfitter
 

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
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>
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)
 
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 22 of file DQMGenericTnPClient.cc.

Member Typedef Documentation

◆ DQMStore

Definition at line 25 of file DQMGenericTnPClient.cc.

◆ MonitorElement

Definition at line 24 of file DQMGenericTnPClient.cc.

Constructor & Destructor Documentation

◆ DQMGenericTnPClient()

DQMGenericTnPClient::DQMGenericTnPClient ( const edm::ParameterSet pset)

Definition at line 45 of file DQMGenericTnPClient.cc.

46  : subDirs(pset.getUntrackedParameter<vstring>("subDirs", vstring())),
47  myDQMrootFolder(pset.getUntrackedParameter<std::string>("MyDQMrootFolder", "")),
48  verbose(pset.getUntrackedParameter<bool>("Verbose", false)),
49  efficiencies(pset.getUntrackedParameter<VParameterSet>("Efficiencies")) {
50  TString savePlotsInRootFileName = pset.getUntrackedParameter<string>("SavePlotsInRootFileName", "");
51  plots = savePlotsInRootFileName != "" ? new TFile(savePlotsInRootFileName, "recreate") : nullptr;
54 }

References GPLfitter, plots, muonDTDigis_cfi::pset, verbose, and VPEfitter.

◆ ~DQMGenericTnPClient()

DQMGenericTnPClient::~DQMGenericTnPClient ( )
override

Definition at line 174 of file DQMGenericTnPClient.cc.

174  {
175  delete GPLfitter;
176  if (plots) {
177  plots->Close();
178  }
179 }

References GPLfitter, and plots.

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 29 of file DQMGenericTnPClient.cc.

29 {};

◆ calculateEfficiency()

void DQMGenericTnPClient::calculateEfficiency ( const std::string &  dirName,
const ParameterSet pset 
)

Definition at line 93 of file DQMGenericTnPClient.cc.

93  {
94  //get hold of numerator and denominator histograms
95  string allMEname = dirName + "/" + pset.getUntrackedParameter<string>("DenominatorMEname");
96  string passMEname = dirName + "/" + pset.getUntrackedParameter<string>("NumeratorMEname");
97  MonitorElement* allME = dqmStore->get(allMEname);
98  MonitorElement* passME = dqmStore->get(passMEname);
99  if (allME == nullptr || passME == nullptr) {
100  LogDebug("DQMGenericTnPClient") << "Could not find MEs: " << allMEname << " or " << passMEname << endl;
101  return;
102  }
103  TH1* all = allME->getTH1();
104  TH1* pass = passME->getTH1();
105  //setup the fitter
106  string fitFunction = pset.getUntrackedParameter<string>("FitFunction");
107  AbstractFitter* fitter = nullptr;
108  if (fitFunction == "GaussianPlusLinear") {
109  GPLfitter->setup(pset.getUntrackedParameter<double>("ExpectedMean"),
110  pset.getUntrackedParameter<double>("FitRangeLow"),
111  pset.getUntrackedParameter<double>("FitRangeHigh"),
112  pset.getUntrackedParameter<double>("ExpectedSigma"));
113  fitter = GPLfitter;
114  } else if (fitFunction == "VoigtianPlusExponential") {
115  VPEfitter->setup(pset.getUntrackedParameter<double>("ExpectedMean"),
116  pset.getUntrackedParameter<double>("FitRangeLow"),
117  pset.getUntrackedParameter<double>("FitRangeHigh"),
118  pset.getUntrackedParameter<double>("ExpectedSigma"),
119  pset.getUntrackedParameter<double>("FixedWidth"));
120  fitter = VPEfitter;
121  } else {
122  LogError("DQMGenericTnPClient") << "Fit function: " << fitFunction << " does not exist" << endl;
123  return;
124  }
125  //check dimensions
126  int dimensions = all->GetDimension();
127  int massDimension = pset.getUntrackedParameter<int>("MassDimension");
128  if (massDimension > dimensions) {
129  LogError("DQMGenericTnPClient") << "Monitoring Element " << allMEname << " has smaller dimension than "
130  << massDimension << endl;
131  return;
132  }
133  //figure out directory and efficiency names
134  string effName = pset.getUntrackedParameter<string>("EfficiencyMEname");
135  string effDir = dirName;
136  string::size_type slashPos = effName.rfind('/');
137  if (string::npos != slashPos) {
138  effDir += "/" + effName.substr(0, slashPos);
139  effName.erase(0, slashPos + 1);
140  }
141  dqmStore->setCurrentFolder(effDir);
142  TString prefix(effDir.c_str());
143  prefix.ReplaceAll('/', '_');
144  //calculate and book efficiency
145  if (dimensions == 2) {
146  TProfile* eff = nullptr;
147  TProfile* effChi2 = nullptr;
148  TString error = fitter->calculateEfficiency(
149  (TH2*)pass, (TH2*)all, massDimension, eff, effChi2, plots ? prefix + effName.c_str() : "");
150  if (error != "") {
151  LogError("DQMGenericTnPClient") << error << endl;
152  return;
153  }
154  dqmStore->bookProfile(effName, eff);
155  dqmStore->bookProfile(effName + "Chi2", effChi2);
156  delete eff;
157  delete effChi2;
158  } else if (dimensions == 3) {
159  TProfile2D* eff = nullptr;
160  TProfile2D* effChi2 = nullptr;
161  TString error = fitter->calculateEfficiency(
162  (TH3*)pass, (TH3*)all, massDimension, eff, effChi2, plots ? prefix + effName.c_str() : "");
163  if (error != "") {
164  LogError("DQMGenericTnPClient") << error << endl;
165  return;
166  }
167  dqmStore->bookProfile2D(effName, eff);
168  dqmStore->bookProfile2D(effName + "Chi2", effChi2);
169  delete eff;
170  delete effChi2;
171  }
172 }

References python.cmstools::all(), dqm::implementation::IBooker::bookProfile(), dqm::implementation::IBooker::bookProfile2D(), HistogramManager_cfi::dimensions, TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, relativeConstraints::error, dqm::implementation::IGetter::get(), dqm::legacy::MonitorElement::getTH1(), GPLfitter, LogDebug, plots, ZMuMuAnalysisNtupler_cff::prefix, muonDTDigis_cfi::pset, dqm::implementation::DQMStore::setCurrentFolder(), dqmTnP::AbstractFitter::setup(), dqmTnP::VoigtianPlusExponentialFitter::setup(), and VPEfitter.

Referenced by endRun().

◆ endRun()

void DQMGenericTnPClient::endRun ( const edm::Run run,
const edm::EventSetup setup 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file DQMGenericTnPClient.cc.

56  {
57  TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
58 
59  dqmStore = Service<DQMStore>().operator->();
60  if (!dqmStore) {
61  LogError("DQMGenericTnPClient") << "Could not find DQMStore service\n";
62  return;
63  }
65 
66  set<std::string> subDirSet;
67 
68  if (!myDQMrootFolder.empty())
69  subDirSet.insert(myDQMrootFolder);
70  else {
71  for (auto iSubDir = subDirs.begin(); iSubDir != subDirs.end(); ++iSubDir) {
72  std::string subDir = *iSubDir;
73  if (subDir[subDir.size() - 1] == '/')
74  subDir.erase(subDir.size() - 1);
75  if (TString(subDir).Contains(metacharacters)) {
76  const string::size_type shiftPos = subDir.rfind('/');
77  const string searchPath = subDir.substr(0, shiftPos);
78  const string pattern = subDir.substr(shiftPos + 1, subDir.length());
79  findAllSubdirectories(searchPath, &subDirSet, pattern);
80  } else {
81  subDirSet.insert(subDir);
82  }
83  }
84  }
85 
86  for (auto const& dirName : subDirSet) {
87  for (auto const& efficiencie : efficiencies) {
88  calculateEfficiency(dirName, efficiencie);
89  }
90  }
91 }

References calculateEfficiency(), TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, efficiencies, findAllSubdirectories(), myDQMrootFolder, topSingleLeptonDQM_PU_cfi::pattern, dqm::implementation::DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, PostProcessorHcalIsoTrack_cfi::subDir, and subDirs.

◆ findAllSubdirectories()

void DQMGenericTnPClient::findAllSubdirectories ( const std::string &  dir,
std::set< std::string > *  myList,
TString  pattern = "" 
)

Definition at line 181 of file DQMGenericTnPClient.cc.

183  {
184  if (!dqmStore->dirExists(dir)) {
185  LogError("DQMGenericTnPClient") << " DQMGenericTnPClient::findAllSubdirectories ==> Missing folder " << dir
186  << " !!!";
187  return;
188  }
189  TPRegexp nonPerlWildcard("\\w\\*|^\\*");
190  if (pattern != "") {
191  if (pattern.Contains(nonPerlWildcard))
192  pattern.ReplaceAll("*", ".*");
193  TPRegexp regexp(pattern);
194  dqmStore->cd(dir);
195  vector<string> foundDirs = dqmStore->getSubdirs();
196  for (auto iDir = foundDirs.begin(); iDir != foundDirs.end(); ++iDir) {
197  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
198  if (dirName.Contains(regexp))
200  }
201  } else if (dqmStore->dirExists(dir)) {
202  myList->insert(dir);
203  dqmStore->cd(dir);
205  } else {
206  LogInfo("DQMGenericClient") << "Trying to find sub-directories of " << dir << " failed because " << dir
207  << " does not exist";
208  }
209  return;
210 }

References dqm::implementation::DQMStore::cd(), DeadROC_duringRun::dir, dqm::implementation::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, dqm::implementation::IGetter::getSubdirs(), PatBasicFWLiteJetAnalyzer_Selector_cfg::myList, topSingleLeptonDQM_PU_cfi::pattern, and fetchall_from_DQM_v2::regexp.

Referenced by endRun().

Member Data Documentation

◆ dqmStore

DQMStore* DQMGenericTnPClient::dqmStore
private

Definition at line 35 of file DQMGenericTnPClient.cc.

Referenced by calculateEfficiency(), endRun(), and findAllSubdirectories().

◆ efficiencies

const VParameterSet DQMGenericTnPClient::efficiencies
private

Definition at line 40 of file DQMGenericTnPClient.cc.

Referenced by endRun().

◆ GPLfitter

GaussianPlusLinearFitter* DQMGenericTnPClient::GPLfitter
private

◆ myDQMrootFolder

std::string DQMGenericTnPClient::myDQMrootFolder
private

Definition at line 38 of file DQMGenericTnPClient.cc.

Referenced by endRun().

◆ plots

TFile* DQMGenericTnPClient::plots
private

◆ subDirs

vstring DQMGenericTnPClient::subDirs
private

Definition at line 37 of file DQMGenericTnPClient.cc.

Referenced by endRun().

◆ verbose

bool DQMGenericTnPClient::verbose
private

◆ VPEfitter

VoigtianPlusExponentialFitter* DQMGenericTnPClient::VPEfitter
private

Definition at line 42 of file DQMGenericTnPClient.cc.

Referenced by calculateEfficiency(), and DQMGenericTnPClient().

DQMGenericTnPClient::subDirs
vstring subDirs
Definition: DQMGenericTnPClient.cc:37
DQMGenericTnPClient::dqmStore
DQMStore * dqmStore
Definition: DQMGenericTnPClient.cc:35
dqm::implementation::IBooker::bookProfile2D
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:399
DQMGenericTnPClient::GPLfitter
GaussianPlusLinearFitter * GPLfitter
Definition: DQMGenericTnPClient.cc:41
edm::LogInfo
Definition: MessageLogger.h:254
edm::VParameterSet
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
dqm::implementation::IGetter::getSubdirs
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:678
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
relativeConstraints.error
error
Definition: relativeConstraints.py:53
HistogramManager_cfi.dimensions
dimensions
Definition: HistogramManager_cfi.py:71
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:26
fetchall_from_DQM_v2.regexp
regexp
Definition: fetchall_from_DQM_v2.py:93
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
dqmTnP::VoigtianPlusExponentialFitter::setup
void setup(double expectedMean_, double massLow, double massHigh, double expectedSigma_, double width_)
Definition: GenericTnPFitter.h:364
PostProcessorHcalIsoTrack_cfi.subDir
subDir
Definition: PostProcessorHcalIsoTrack_cfi.py:5
DQMGenericTnPClient::myDQMrootFolder
std::string myDQMrootFolder
Definition: DQMGenericTnPClient.cc:38
dqmTnP::AbstractFitter::setup
void setup(double expectedMean_, double massLow, double massHigh, double expectedSigma_)
Definition: GenericTnPFitter.h:67
dqm::implementation::IBooker::bookProfile
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:322
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dqm::legacy::MonitorElement::getTH1
virtual TH1 * getTH1() const
Definition: MonitorElement.h:474
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dqmTnP::GaussianPlusLinearFitter
Definition: GenericTnPFitter.h:270
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
PatBasicFWLiteJetAnalyzer_Selector_cfg.myList
myList
Definition: PatBasicFWLiteJetAnalyzer_Selector_cfg.py:14
dqmTnP::AbstractFitter
Definition: GenericTnPFitter.h:23
dqmTnP::VoigtianPlusExponentialFitter
Definition: GenericTnPFitter.h:334
edm::Service
Definition: Service.h:30
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
DQMGenericTnPClient::verbose
bool verbose
Definition: DQMGenericTnPClient.cc:39
DQMGenericTnPClient::plots
TFile * plots
Definition: DQMGenericTnPClient.cc:36
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
vstring
vector< string > vstring
Definition: ExoticaDQM.cc:8
DQMGenericTnPClient::VPEfitter
VoigtianPlusExponentialFitter * VPEfitter
Definition: DQMGenericTnPClient.cc:42
DQMGenericTnPClient::findAllSubdirectories
void findAllSubdirectories(const std::string &dir, std::set< std::string > *myList, TString pattern)
Definition: DQMGenericTnPClient.cc:181
dqm::implementation::IGetter::dirExists
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:707
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqm::implementation::DQMStore::cd
void cd() override
Definition: DQMStore.h:564
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
ZMuMuAnalysisNtupler_cff.prefix
prefix
Definition: ZMuMuAnalysisNtupler_cff.py:14
DQMGenericTnPClient::efficiencies
const VParameterSet efficiencies
Definition: DQMGenericTnPClient.cc:40
DQMGenericTnPClient::calculateEfficiency
void calculateEfficiency(const std::string &dirName, const ParameterSet &pset)
Definition: DQMGenericTnPClient.cc:93