CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MultiIsolator.cc
Go to the documentation of this file.
5 #include <sstream>
6 
7 using namespace pat::helper;
8 
10  using pat::Flags;
11  if (conf.exists("tracker"))
13  if (conf.exists("ecal"))
15  if (conf.exists("hcal"))
17  if (conf.exists("calo"))
19  if (conf.exists("calo") && (conf.exists("ecal") || conf.exists("hcal"))) {
20  throw cms::Exception("Configuration")
21  << "MultiIsolator: you can't specify both 'calo' isolation and 'ecal'/'hcal', "
22  << "as the 'calo' isolation flag is just the logical OR of 'ecal' and 'hcal'.\n";
23  }
24  if (conf.exists("pfAllParticles"))
27  if (conf.exists("pfChargedHadron"))
28  addIsolator(conf.getParameter<edm::ParameterSet>("pfChargedHadron"),
29  iC,
30  cuts,
33  if (conf.exists("pfNeutralHadron"))
34  addIsolator(conf.getParameter<edm::ParameterSet>("pfNeutralHadron"),
35  iC,
36  cuts,
39  if (conf.exists("pfGamma"))
41  if (conf.exists("user")) {
42  std::vector<edm::ParameterSet> psets = conf.getParameter<std::vector<edm::ParameterSet> >("user");
43  if (psets.size() > 5) {
44  throw cms::Exception("Configuration") << "MultiIsolator: you can specify at most 5 user isolation collections.\n";
45  }
46  uint32_t bit = Flags::Isolation::User1;
47  for (std::vector<edm::ParameterSet>::const_iterator it = psets.begin(), ed = psets.end(); it != ed;
48  ++it, bit <<= 1) {
49  addIsolator(*it, iC, cuts, bit, pat::IsolationKeys(pat::UserBaseIso + (it - psets.begin())));
50  }
51  }
52 }
53 
55  isolators_.emplace_back(iso);
56  masks_.push_back(mask);
57  keys_.push_back(key);
58 }
59 
61  if (conf.empty())
62  return nullptr;
63  if (conf.exists("placeholder") && conf.getParameter<bool>("placeholder"))
64  return nullptr;
65  if (conf.exists("deltaR")) {
66  return new IsoDepositIsolator(conf, iC, withCut);
67  } else {
68  return new SimpleIsolator(conf, iC, withCut);
69  }
70 }
71 
73  const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut, uint32_t mask, pat::IsolationKeys key) {
74  BaseIsolator *iso = make(conf, iC, withCut);
75  if (iso)
76  addIsolator(iso, mask, key);
77 }
78 
79 void MultiIsolator::beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup) {
80  for (auto it = isolators_.begin(), ed = isolators_.end(); it != ed; ++it) {
81  (*it)->beginEvent(event, eventSetup);
82  }
83 }
84 
86  for (auto it = isolators_.begin(), ed = isolators_.end(); it != ed; ++it) {
87  (*it)->endEvent();
88  }
89 }
90 
91 void MultiIsolator::print(std::ostream &out) const {
92  for (auto it = isolators_.cbegin(), ed = isolators_.end(); it != ed; ++it) {
93  out << " * ";
94  (*it)->print(out);
95  out << ": Flag " << pat::Flags::bitToString(masks_[it - isolators_.begin()]) << "\n";
96  }
97  out << "\n";
98 }
99 
101  std::ostringstream isoSumm;
102  print(isoSumm);
103  return isoSumm.str();
104 }
bool empty() const
Definition: ParameterSet.h:201
std::vector< uint32_t > masks_
Definition: MultiIsolator.h:59
static const std::string & bitToString(uint32_t bit)
Definition: Flags.cc:5
bool exists(std::string const &parameterName) const
checks if a parameter exists
void print(std::ostream &out) const
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
TkSoA const *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
tuple key
prepare the HTCondor submission files and eventually submit them
std::string printSummary() const
static BaseIsolator * make(const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut)
std::vector< pat::IsolationKeys > keys_
Definition: MultiIsolator.h:60
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Flags used in PAT, and static translator from flags to strings.
Definition: Flags.h:19
std::vector< std::unique_ptr< BaseIsolator > > isolators_
Definition: MultiIsolator.h:58
void addIsolator(BaseIsolator *iso, uint32_t mask, pat::IsolationKeys key)