17 using namespace dqmTnP;
32 void findAllSubdirectories(
const std::string&
dir, std::set<std::string>*
myList, TString pattern);
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")) {
51 plots = savePlotsInRootFileName !=
"" ?
new TFile(savePlotsInRootFileName,
"recreate") :
nullptr;
57 TPRegexp metacharacters(
"[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]");
61 LogError(
"DQMGenericTnPClient") <<
"Could not find DQMStore service\n";
66 set<std::string> subDirSet;
71 for (
auto iSubDir =
subDirs.begin(); iSubDir !=
subDirs.end(); ++iSubDir) {
73 if (subDir[subDir.size() - 1] ==
'/')
74 subDir.erase(subDir.size() - 1);
75 if (TString(subDir).Contains(metacharacters)) {
77 const string searchPath = subDir.substr(0, shiftPos);
78 const string pattern = subDir.substr(shiftPos + 1, subDir.length());
81 subDirSet.insert(subDir);
86 for (
auto const&
dirName : subDirSet) {
99 if (allME ==
nullptr || passME ==
nullptr) {
100 LogDebug(
"DQMGenericTnPClient") <<
"Could not find MEs: " << allMEname <<
" or " << passMEname << endl;
103 TH1*
all = allME->getTH1();
104 TH1* pass = passME->
getTH1();
108 if (fitFunction ==
"GaussianPlusLinear") {
114 }
else if (fitFunction ==
"VoigtianPlusExponential") {
122 LogError(
"DQMGenericTnPClient") <<
"Fit function: " << fitFunction <<
" does not exist" << endl;
126 int dimensions = all->GetDimension();
128 if (massDimension > dimensions) {
129 LogError(
"DQMGenericTnPClient") <<
"Monitoring Element " << allMEname <<
" has smaller dimension than "
130 << massDimension << endl;
137 if (string::npos != slashPos) {
138 effDir +=
"/" + effName.substr(0, slashPos);
139 effName.erase(0, slashPos + 1);
142 TString
prefix(effDir.c_str());
143 prefix.ReplaceAll(
'/',
'_');
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() :
"");
151 LogError(
"DQMGenericTnPClient") << error << endl;
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() :
"");
164 LogError(
"DQMGenericTnPClient") << error << endl;
182 std::set<std::string>*
myList,
183 TString pattern =
"") {
185 LogError(
"DQMGenericTnPClient") <<
" DQMGenericTnPClient::findAllSubdirectories ==> Missing folder " << dir
189 TPRegexp nonPerlWildcard(
"\\w\\*|^\\*");
191 if (pattern.Contains(nonPerlWildcard))
192 pattern.ReplaceAll(
"*",
".*");
193 TPRegexp regexp(pattern);
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))
206 LogInfo(
"DQMGenericClient") <<
"Trying to find sub-directories of " << dir <<
" failed because " << dir
207 <<
" does not exist";
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())
dqm::legacy::DQMStore DQMStore
GaussianPlusLinearFitter * GPLfitter
~DQMGenericTnPClient() override
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
#define DEFINE_FWK_MODULE(type)
std::vector< ParameterSet > VParameterSet
void setCurrentFolder(std::string const &fullpath) override
void endRun(const edm::Run &run, const edm::EventSetup &setup) override
void setup(double expectedMean_, double massLow, double massHigh, double expectedSigma_)
virtual bool dirExists(std::string const &path) const
void calculateEfficiency(const std::string &dirName, const ParameterSet &pset)
Log< level::Error, false > LogError
void setup(double expectedMean_, double massLow, double massHigh, double expectedSigma_, double width_)
DQMGenericTnPClient(const edm::ParameterSet &pset)
void findAllSubdirectories(const std::string &dir, std::set< std::string > *myList, TString pattern)
VoigtianPlusExponentialFitter * VPEfitter
tuple DQMGenericTnPClient
static constexpr int verbose
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())
virtual MonitorElement * get(std::string const &fullpath) const
void analyze(const edm::Event &event, const edm::EventSetup &eventSetup) override
std::string myDQMrootFolder
Log< level::Info, false > LogInfo
const VParameterSet efficiencies
std::vector< std::string > vstring
virtual TH1 * getTH1() const
dqm::legacy::MonitorElement MonitorElement