7 std::vector<float> convertToFloat(
const std::vector<double>& vecD) {
8 return std::vector<float>(vecD.begin(), vecD.end());
15 tagFilters_(config.getParameter<edm::
ParameterSet>(
"tagFilters")),
16 collName_(config.getParameter<std::
string>(
"collName")),
17 folderName_(config.getParameter<std::
string>(
"folderName")),
18 histDefs_(config.getParameter<edm::
ParameterSet>(
"histDefs")),
19 evtTrigSel_(config.getParameter<edm::
ParameterSet>(
"evtTrigSel"))
22 auto probeFilters = config.
getParameter<std::vector<std::string>>(
"probeFilters");
23 for (
auto& probeFilter : probeFilters) {
38 desc.
add<std::vector<std::string>>(
"probeFilters", std::vector<std::string>());
57 for (
auto& tagKey : tagTrigKeys) {
79 : isAND_(config.getParameter<bool>(
"isAND")) {
80 auto filterSetConfigs = config.
getParameter<std::vector<edm::ParameterSet>>(
"filterSets");
81 for (
auto& filterSetConfig : filterSetConfigs)
87 desc.
addVPSet(
"filterSets", FilterSet::makePSetDescription(), std::vector<edm::ParameterSet>());
88 desc.
add<
bool>(
"isAND",
false);
94 bool isFirstFilterSet =
true;
95 for (
const auto& filterSet : filterSets_) {
96 auto keysOfFilterSet = filterSet.getPassingKeys(trigEvt);
98 passingKeys = keysOfFilterSet;
100 mergeTrigKeys(passingKeys, keysOfFilterSet, isAND_);
101 isFirstFilterSet =
false;
103 cleanTrigKeys(passingKeys);
111 for (
auto&
key : keys) {
112 if (
std::count(keysToMerge.begin(), keysToMerge.end(),
key) == 0) {
117 for (
const auto key : keysToMerge) {
124 std::sort(keys.begin(), keys.end());
132 : filters_(config.getParameter<std::
vector<std::
string>>(
"filters")), isAND_(config.getParameter<bool>(
"isAND")) {}
135 : selectionStr_(config.getParameter<std::
string>(
"selectionStr")),
136 isANDForExpandedPaths_(config.getParameter<bool>(
"isANDForExpandedPaths")),
137 verbose_(config.getParameter<int>(
"verbose")),
143 desc.
add<
bool>(
"isANDForExpandedPaths",
false);
144 desc.
add<
int>(
"verbose", 1);
149 expandedSelStr_ = expandSelectionStr(selectionStr_, hltConfig, isANDForExpandedPaths_, verbose_);
152 edm::LogInfo(
"TrigObjTnPHistColl::PathSelector") <<
"trigger selection string: \"" << expandedSelStr_ <<
"\"";
158 if (selectionStr_.empty())
160 else if (!isInited_) {
162 <<
" error, TrigObjTnPHistColl::PathSelector is not initalised, returning false ";
164 }
else if (expandedSelStr_.empty()) {
177 bool accept = pathIndex < trigNames.
size() ? trigResults.
accept(pathIndex) :
false;
194 if (pathName.find(
'*') != std::string::npos) {
195 std::string pathPatternExpanded = expandPath(pathName, hltConfig, isAND, verbose);
196 expandedSelStr.replace(expandedSelStr.find(pathName), pathName.size(), pathPatternExpanded);
199 return expandedSelStr;
210 std::vector<std::string> matched;
212 if (pathPattern.substr(pathPattern.size() - versionWildcard.size()) == versionWildcard) {
213 const std::string pathPatternBase(pathPattern.substr(0, pathPattern.size() - versionWildcard.size()));
216 matched = hltConfig.
matched(trigNames, pathPattern);
219 if (matched.empty()) {
222 <<
"pattern: \"" << pathPattern
223 <<
"\" could not be resolved, please check your triggers are spelt correctly and present in the data you are "
230 for (
unsigned iVers = 0; iVers < matched.size(); ++iVers) {
232 expanded.append(isAND ?
" AND " :
" OR ");
233 expanded.append(matched.at(iVers));
235 expanded.append(
")");
237 edm::LogInfo(
"TrigObjTnPHistColl::PathSelector") <<
"Logical expression : \"" << pathPattern <<
"\"\n"
238 <<
" expanded to: \"" << expanded <<
"\"";
245 desc.
add<std::vector<std::string>>(
"filters", std::vector<std::string>());
246 desc.
add<
bool>(
"isAND",
true);
253 bool firstFilter =
true;
257 passingKeys = trigKeys;
260 mergeTrigKeys(passingKeys, trigKeys, isAND_);
262 cleanTrigKeys(passingKeys);
269 auto absPos = varName.rfind(
"Abs");
270 if (absPos != std::string::npos && absPos + 3 == varName.size()) {
272 varName = varName.erase(absPos);
276 else if (varName ==
"eta")
278 else if (varName ==
"phi")
281 std::ostringstream
msg;
282 msg <<
"var " << varName <<
" not recognised (use pt or p rather than et or e for speed!) ";
284 msg <<
" varName was \"Abs\" suffex cleaned where it tried to remove \"Abs\" at the end of the variable name ";
285 msg << __FILE__ <<
"," << __LINE__ << std::endl;
292 var_(config.getParameter<std::
string>(
"var")) {}
304 if (localCuts_(probe))
305 hist->
Fill(var_(probe), mass);
309 : massBins_(convertToFloat(config.getParameter<std::
vector<double>>(
"massBins"))) {
310 const auto histConfigs = config.
getParameter<std::vector<edm::ParameterSet>>(
"configs");
311 for (
const auto& histConfig : histConfigs) {
318 desc.
addVPSet(
"configs", Data::makePSetDescription(), std::vector<edm::ParameterSet>());
319 std::vector<double> massBins;
321 massBins.push_back(
mass);
322 desc.
add<std::vector<double>>(
"massBins", massBins);
326 std::vector<std::pair<TrigObjTnPHistColl::HistFiller, dqm::reco::MonitorElement*>>
330 std::vector<std::pair<HistFiller, dqm::reco::MonitorElement*>>
hists;
331 for (
const auto&
data : histData_) {
332 hists.push_back({
data.filler(),
data.book(iBooker, name, title, massBins_)});
338 : histFiller_(config.getParameter<edm::
ParameterSet>(
"filler")),
339 bins_(convertToFloat(config.getParameter<std::
vector<double>>(
"bins"))),
340 nameSuffex_(config.getParameter<std::
string>(
"nameSuffex")),
341 titleSuffex_(config.getParameter<std::
string>(
"titleSuffex")) {}
346 desc.
add<std::vector<double>>(
"bins", {-2.5, -1.5, 0, 1.5, 2.5});
355 const std::vector<float>& massBins)
const {
356 return iBooker.
book2D((name + nameSuffex_).c_str(),
357 (title + titleSuffex_).c_str(),
368 hists_ = histDefs.
bookHists(iBooker, name, title);
372 for (
auto&
hist : hists_) {
373 hist.first(probe, mass,
hist.second);
380 hists_.bookHists(iBooker, tagName +
"_" + probeFilter_, tagName +
"_" + probeFilter_, histDefs);
386 auto probeKeys =
getKeys(trigEvt, probeFilter_);
387 for (
auto probeKey : probeKeys) {
389 if (tagKey != probeKey && probeCuts(probe)) {
391 auto massFunc = [](
float pt1,
float eta1,
float phi1,
float pt2,
float eta2,
float phi2) {
392 return std::sqrt(2 * pt1 * pt2 * (std::cosh(eta1 - eta2) -
std::cos(phi1 - phi2)));
395 hists_.fill(probe, mass);
void fill(const trigger::TriggerObject &probe, float mass) const
static void cleanTrigKeys(trigger::Keys &keys)
static const std::vector< std::string > matched(const std::vector< std::string > &inputs, const std::string &pattern)
regexp processing
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
The single EDProduct to be saved for each event (AOD case)
trigger::size_type sizeFilters() const
static edm::ParameterSetDescription makePSetDescription()
virtual void setCurrentFolder(std::string const &fullpath)
static edm::ParameterSetDescription makePSetDescription()
static const trigger::Keys getKeys(const trigger::TriggerEvent &trigEvt, const std::string &filterName)
std::vector< ProbeData > probeHists_
TrigObjTnPHistColl(const edm::ParameterSet &config)
void bookHists(DQMStore::IBooker &iBooker)
bool accept() const
Has at least one path accepted the event?
const std::vector< std::string > & triggerNames() const
names of trigger paths
const Keys & filterKeys(trigger::size_type index) const
const trigger::Keys getPassingKeys(const trigger::TriggerEvent &trigEvt) const
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
unsigned int triggerIndex(std::string_view name) const
static edm::ParameterSetDescription makePSetDescription()
Data(const edm::ParameterSet &config)
FilterSet(const edm::ParameterSet &config)
Log< level::Error, false > LogError
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
static std::string expandPath(const std::string &pathPattern, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
VarRangeCutColl< trigger::TriggerObject > probeCuts_
Single trigger physics object (e.g., an isolated muon)
void bookHists(const std::string &tagName, DQMStore::IBooker &iBooker, const HistDefs &histDefs)
static edm::ParameterSetDescription makePSetDescription()
void init(const HLTConfigProvider &hltConfig)
void operator()(const trigger::TriggerObject &probe, float mass, dqm::reco::MonitorElement *hist) const
std::vector< OperandToken > & operandTokenVector()
return the vector of operand tokens
const TriggerObjectCollection & getObjects() const
void fill(const trigger::size_type tagKey, const trigger::TriggerEvent &trigEvt, const VarRangeCutColl< trigger::TriggerObject > &probeCuts) const
const std::string & usedProcessName() const
getters
Cos< T >::type cos(const T &t)
tuple key
prepare the HTCondor submission files and eventually submit them
void bookHists(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title, const HistDefs &histDefs)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void mergeTrigKeys(trigger::Keys &keys, const trigger::Keys &keysToMerge, bool isAND)
Log< level::Info, false > LogInfo
static const char *const trigNames[]
HistFiller(const edm::ParameterSet &config)
PathSelector(const edm::ParameterSet &config)
static std::string expandSelectionStr(const std::string &selStr, const HLTConfigProvider &hltConfig, bool isAND, int verbose)
static const std::vector< std::string > restoreVersion(const std::vector< std::string > &inputs, const std::string &trigger)
const trigger::Keys getPassingKeys(const trigger::TriggerEvent &trigEvt) const
std::vector< size_type > Keys
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
T getParameter(std::string const &) const
HistDefs(const edm::ParameterSet &config)
std::vector< FilterSet > filterSets_
tuple config
parse the configuration file
VarRangeCutColl< trigger::TriggerObject > tagCuts_
char data[epos_bytes_allocation]
std::vector< Data > histData_
static edm::ParameterSetDescription makePSetDescription()
FilterSelector(const edm::ParameterSet &config)
static edm::ParameterSetDescription makePSetDescription()
std::vector< std::pair< HistFiller, dqm::reco::MonitorElement * > > bookHists(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title) const
Log< level::Warning, false > LogWarning
float(trigger::TriggerObject::* varFunc_)() const
bool operator()(const edm::TriggerResults &trigResults, const edm::TriggerNames &trigNames) const
FilterSelector tagFilters_
void fill(const trigger::TriggerEvent &trigEvt, const edm::TriggerResults &trigResults, const edm::TriggerNames &trigNames) const
dqm::reco::MonitorElement * book(DQMStore::IBooker &iBooker, const std::string &name, const std::string &title, const std::vector< float > &massBins) const
static edm::ParameterSetDescription makePSetDescription()
virtual const bool expressionResult() const
TrigObjVarF(std::string varName)