17 std::regex token(
"\\w+");
18 std::sregex_iterator tbegin(expr.begin(), expr.end(), token), tend;
19 if (tbegin == tend)
return expr;
20 std::stringstream
out;
21 std::sregex_iterator
last;
22 for (std::sregex_iterator
i = tbegin;
i != tend; last =
i, ++
i) {
24 out << match.prefix().str();
26 out <<
"getAnyValue(\"" << match.str() <<
"\")";
31 out << last->suffix().str();
54 virtual void fill(
const FlatTable & table,
const std::vector<bool> & rowsel) = 0;
62 Plot(booker.book1D(cfg.getParameter<
std::
string>(
"name"), cfg.getParameter<
std::
string>(
"title"), cfg.getParameter<uint32_t>(
"nbins"), cfg.getParameter<double>(
"min"), cfg.getParameter<double>(
"max")))
66 void fill(
const FlatTable & table,
const std::vector<bool> & rowsel)
override {
67 plot_->
Fill(std::accumulate(rowsel.begin(), rowsel.end(), 0u));
74 Plot(booker.book1D(cfg.getParameter<
std::
string>(
"name"), cfg.getParameter<
std::
string>(
"title"), cfg.getParameter<uint32_t>(
"nbins"), cfg.getParameter<double>(
"min"), cfg.getParameter<double>(
"max"))),
75 col_(cfg.getParameter<
std::
string>(
"column"))
79 void fill(
const FlatTable & table,
const std::vector<bool> & rowsel)
override {
81 if (icol == -1)
return;
92 void vfill(
const FlatTable & table,
int icol,
const std::vector<bool> & rowsel) {
94 for (
unsigned int i = 0,
n =
data.size();
i <
n; ++
i) {
103 cfg.getParameter<uint32_t>(
"nbins"), cfg.getParameter<double>(
"min"), cfg.getParameter<double>(
"max"),
105 ycol_(cfg.getParameter<
std::
string>(
"ycolumn")), xcol_(cfg.getParameter<
std::
string>(
"xcolumn"))
109 void fill(
const FlatTable & table,
const std::vector<bool> & rowsel)
override {
112 if (icolx == -1)
throw cms::Exception(
"LogicError",
"Missing "+xcol_);
113 if (icoly == -1)
throw cms::Exception(
"LogicError",
"Missing "+ycol_);
114 for (
unsigned int irow = 0,
n = table.
size(); irow <
n; ++irow) {
126 if (kind ==
"none")
return nullptr;
127 if (kind ==
"count1d")
return std::make_unique<Count1D>(booker,
cfg);
128 if (kind ==
"hist1d")
return std::make_unique<Plot1D>(booker,
cfg);
129 if (kind ==
"prof1d")
return std::make_unique<Profile1D>(booker,
cfg);
130 throw cms::Exception(
"Configuration",
"Unsupported plot kind '"+kind+
"'");
137 std::unique_ptr<StringCutObjectSelector<FlatTable::RowView>>
cutptr;
138 std::vector<std::unique_ptr<Plot>>
plots;
141 bool nullCut()
const {
return cutstr.empty(); }
142 void fillSel(
const FlatTable & table, std::vector<bool> & out) {
143 out.resize(table.
size());
148 cutptr.reset(
new Selector(replaceStringsToColumGets(cutstr, table)));
150 for (
unsigned int i = 0,
n = table.
size();
i <
n; ++
i) {
151 out[
i] = (*cutptr)(table.
row(
i));
169 group.plotPSets =
pset.getParameter<std::vector<edm::ParameterSet>>(
"plots");
170 group.selGroups.emplace_back();
176 consumesMany<FlatTable>();
184 for (
auto &
sels : pair.second.selGroups) {
186 if (!
sels.nullCut()) dir +=
"/" +
sels.name;
190 plots.reserve(pair.second.plotPSets.size());
191 for (
const auto &
cfg : pair.second.plotPSets) {
200 std::vector<edm::Handle<FlatTable>> alltables;
202 std::map<std::string, std::pair<const FlatTable *, std::vector<const FlatTable *>>> maintables;
204 for (
const auto & htab : alltables) {
205 if (htab->extension())
continue;
206 maintables[htab->name()] = std::make_pair(htab.product(), std::vector<const FlatTable *>());
208 for (
const auto & htab : alltables) {
209 if (htab->extension()) {
210 if (maintables.find(htab->name()) == maintables.end())
throw cms::Exception(
"LogicError",
"Missing main table for "+htab->name());
211 maintables[htab->name()].second.push_back(htab.product());
218 if (maintables.find(name) == maintables.end())
continue;
221 if (!
tables.second.empty()) {
228 std::vector<bool> selbits;
229 for (
auto &
sel : pair.second.selGroups) {
230 sel.fillSel(*table, selbits);
232 for (
auto &
plot :
sel.plots) {
233 plot->fill(*table, selbits);
boost::sub_range< const std::vector< T > > columnData(unsigned int column) const
get a column by index (const)
void getManyByType(std::vector< Handle< PROD > > &results) const
void addExtension(const FlatTable &extension)
T getParameter(std::string const &) const
RowView row(unsigned int row) const
std::vector< edm::ParameterSet > plotPSets
int columnIndex(const std::string &name) const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
virtual void fill(const FlatTable &table, const std::vector< bool > &rowsel)=0
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
std::vector< SelGroupConfig > selGroups
ColumnType columnType(unsigned int col) const
std::unique_ptr< StringCutObjectSelector< FlatTable::RowView > > cutptr
void analyze(const edm::Event &, const edm::EventSetup &) override
const std::string & getName() const
get name of ME
nanoaod::FlatTable FlatTable
static std::unique_ptr< Plot > makePlot(DQMStore::IBooker &booker, const edm::ParameterSet &cfg)
Plot1D(DQMStore::IBooker &booker, const edm::ParameterSet &cfg)
NanoAODDQM(const edm::ParameterSet &)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Profile1D(DQMStore::IBooker &booker, const edm::ParameterSet &cfg)
std::map< std::string, GroupConfig > groups_
void vfill(const FlatTable &table, int icol, const std::vector< bool > &rowsel)
void fill(const FlatTable &table, const std::vector< bool > &rowsel) override
Count1D(DQMStore::IBooker &booker, const edm::ParameterSet &cfg)
void fill(const FlatTable &table, const std::vector< bool > &rowsel) override
void setCurrentFolder(const std::string &fullpath)
std::vector< std::unique_ptr< Plot > > plots
SelGroupConfig(const std::string &nam, const std::string &cut)
unsigned int size() const
char data[epos_bytes_allocation]
StringCutObjectSelector< FlatTable::RowView > Selector
void fillSel(const FlatTable &table, std::vector< bool > &out)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
void fill(const FlatTable &table, const std::vector< bool > &rowsel) override
double getAnyValue(unsigned int row, unsigned int column) const
void endRun(const edm::Run &, const edm::EventSetup &) override
const std::string & name() const