CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 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

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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)
 
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 22 of file DQMGenericTnPClient.cc.

Member Typedef Documentation

Definition at line 25 of file DQMGenericTnPClient.cc.

Definition at line 24 of file DQMGenericTnPClient.cc.

Constructor & Destructor Documentation

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

Definition at line 45 of file DQMGenericTnPClient.cc.

References edm::ParameterSet::getUntrackedParameter(), GPLfitter, plots, verbose, and VPEfitter.

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 }
T getUntrackedParameter(std::string const &, T const &) const
GaussianPlusLinearFitter * GPLfitter
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
VoigtianPlusExponentialFitter * VPEfitter
const VParameterSet efficiencies
DQMGenericTnPClient::~DQMGenericTnPClient ( )
override

Definition at line 174 of file DQMGenericTnPClient.cc.

References GPLfitter, and plots.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 29 of file DQMGenericTnPClient.cc.

29 {};
void DQMGenericTnPClient::calculateEfficiency ( const std::string &  dirName,
const ParameterSet pset 
)

Definition at line 93 of file DQMGenericTnPClient.cc.

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

Referenced by endRun().

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 }
T getUntrackedParameter(std::string const &, T const &) const
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
GaussianPlusLinearFitter * GPLfitter
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
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:322
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
def all
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
virtual TH1 * getTH1() const
#define LogDebug(id)
void DQMGenericTnPClient::endRun ( const edm::Run run,
const edm::EventSetup setup 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file DQMGenericTnPClient.cc.

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

56  {
57  TPRegexp metacharacters("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
58 
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 }
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
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
void DQMGenericTnPClient::findAllSubdirectories ( const std::string &  dir,
std::set< std::string > *  myList,
TString  pattern = "" 
)

Definition at line 181 of file DQMGenericTnPClient.cc.

References dqm::implementation::DQMStore::cd(), dqm::implementation::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, dqmStore, and dqm::implementation::IGetter::getSubdirs().

Referenced by endRun().

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 }
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:700
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
Log< level::Error, false > LogError
void findAllSubdirectories(const std::string &dir, std::set< std::string > *myList, TString pattern)
Log< level::Info, false > LogInfo

Member Data Documentation

DQMStore* DQMGenericTnPClient::dqmStore
private

Definition at line 35 of file DQMGenericTnPClient.cc.

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

const VParameterSet DQMGenericTnPClient::efficiencies
private

Definition at line 40 of file DQMGenericTnPClient.cc.

Referenced by endRun().

GaussianPlusLinearFitter* DQMGenericTnPClient::GPLfitter
private
std::string DQMGenericTnPClient::myDQMrootFolder
private

Definition at line 38 of file DQMGenericTnPClient.cc.

Referenced by endRun().

TFile* DQMGenericTnPClient::plots
private
vstring DQMGenericTnPClient::subDirs
private

Definition at line 37 of file DQMGenericTnPClient.cc.

Referenced by endRun().

bool DQMGenericTnPClient::verbose
private
VoigtianPlusExponentialFitter* DQMGenericTnPClient::VPEfitter
private

Definition at line 42 of file DQMGenericTnPClient.cc.

Referenced by calculateEfficiency(), and DQMGenericTnPClient().