CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
DQMGenericTnPClient Class Reference
Inheritance diagram for DQMGenericTnPClient:
edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

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 (edm::Run const &, edm::EventSetup const &) 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::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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::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 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 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 46 of file DQMGenericTnPClient.cc.

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

47  : subDirs(pset.getUntrackedParameter<vstring>("subDirs", vstring())),
48  myDQMrootFolder(pset.getUntrackedParameter<std::string>("MyDQMrootFolder", "")),
49  verbose(pset.getUntrackedParameter<bool>("Verbose", false)),
50  efficiencies(pset.getUntrackedParameter<VParameterSet>("Efficiencies")) {
51  usesResource("DQMStore");
52  TString savePlotsInRootFileName = pset.getUntrackedParameter<string>("SavePlotsInRootFileName", "");
53  plots = savePlotsInRootFileName != "" ? new TFile(savePlotsInRootFileName, "recreate") : nullptr;
56 }
GaussianPlusLinearFitter * GPLfitter
vector< string > vstring
Definition: ExoticaDQM.cc:7
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
VoigtianPlusExponentialFitter * VPEfitter
const VParameterSet efficiencies

◆ ~DQMGenericTnPClient()

DQMGenericTnPClient::~DQMGenericTnPClient ( )
override

Definition at line 176 of file DQMGenericTnPClient.cc.

References GPLfitter, and plots.

176  {
177  delete GPLfitter;
178  if (plots) {
179  plots->Close();
180  }
181 }
GaussianPlusLinearFitter * GPLfitter

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 29 of file DQMGenericTnPClient.cc.

29 {};

◆ beginRun()

void DQMGenericTnPClient::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverride

Definition at line 30 of file DQMGenericTnPClient.cc.

30 {}

◆ calculateEfficiency()

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

Definition at line 95 of file DQMGenericTnPClient.cc.

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

Referenced by endRun().

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

◆ endRun()

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

Definition at line 58 of file DQMGenericTnPClient.cc.

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

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

◆ findAllSubdirectories()

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

Definition at line 183 of file DQMGenericTnPClient.cc.

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().

185  {
186  if (!dqmStore->dirExists(dir)) {
187  LogError("DQMGenericTnPClient") << " DQMGenericTnPClient::findAllSubdirectories ==> Missing folder " << dir
188  << " !!!";
189  return;
190  }
191  TPRegexp nonPerlWildcard("\\w\\*|^\\*");
192  if (pattern != "") {
193  if (pattern.Contains(nonPerlWildcard))
194  pattern.ReplaceAll("*", ".*");
195  TPRegexp regexp(pattern);
196  dqmStore->cd(dir);
197  vector<string> foundDirs = dqmStore->getSubdirs();
198  for (auto iDir = foundDirs.begin(); iDir != foundDirs.end(); ++iDir) {
199  TString dirName = iDir->substr(iDir->rfind('/') + 1, iDir->length());
200  if (dirName.Contains(regexp))
202  }
203  } else if (dqmStore->dirExists(dir)) {
204  myList->insert(dir);
205  dqmStore->cd(dir);
207  } else {
208  LogInfo("DQMGenericClient") << "Trying to find sub-directories of " << dir << " failed because " << dir
209  << " does not exist";
210  }
211  return;
212 }
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:769
Log< level::Error, false > LogError
void findAllSubdirectories(const std::string &dir, std::set< std::string > *myList, TString pattern)
Log< level::Info, false > LogInfo
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:739

Member Data Documentation

◆ dqmStore

DQMStore* DQMGenericTnPClient::dqmStore
private

Definition at line 36 of file DQMGenericTnPClient.cc.

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

◆ efficiencies

const VParameterSet DQMGenericTnPClient::efficiencies
private

Definition at line 41 of file DQMGenericTnPClient.cc.

Referenced by endRun().

◆ GPLfitter

GaussianPlusLinearFitter* DQMGenericTnPClient::GPLfitter
private

◆ myDQMrootFolder

std::string DQMGenericTnPClient::myDQMrootFolder
private

Definition at line 39 of file DQMGenericTnPClient.cc.

Referenced by endRun().

◆ plots

TFile* DQMGenericTnPClient::plots
private

◆ subDirs

vstring DQMGenericTnPClient::subDirs
private

Definition at line 38 of file DQMGenericTnPClient.cc.

Referenced by endRun().

◆ verbose

bool DQMGenericTnPClient::verbose
private

◆ VPEfitter

VoigtianPlusExponentialFitter* DQMGenericTnPClient::VPEfitter
private

Definition at line 43 of file DQMGenericTnPClient.cc.

Referenced by calculateEfficiency(), and DQMGenericTnPClient().