CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MultiIsolator.cc
Go to the documentation of this file.
5 #include <sstream>
6 
7 using namespace pat::helper;
8 
10  using pat::Flags;
15  if (conf.exists("calo") && (conf.exists("ecal") || conf.exists("hcal"))) {
16  throw cms::Exception("Configuration") <<
17  "MultiIsolator: you can't specify both 'calo' isolation and 'ecal'/'hcal', " <<
18  "as the 'calo' isolation flag is just the logical OR of 'ecal' and 'hcal'.\n";
19  }
20  if (conf.exists("pfAllParticles")) addIsolator(conf.getParameter<edm::ParameterSet>("pfAllParticles"), cuts,Flags::Isolation::Calo, pat::PfAllParticleIso);
21  if (conf.exists("pfChargedHadron")) addIsolator(conf.getParameter<edm::ParameterSet>("pfChargedHadron"), cuts,Flags::Isolation::Calo, pat::PfChargedHadronIso);
22  if (conf.exists("pfNeutralHadron")) addIsolator(conf.getParameter<edm::ParameterSet>("pfNeutralHadron"), cuts,Flags::Isolation::Calo, pat::PfNeutralHadronIso);
24  if (conf.exists("user")) {
25 
26  std::vector<edm::ParameterSet> psets = conf.getParameter<std::vector<edm::ParameterSet> >("user");
27  if (psets.size() > 5) {
28  throw cms::Exception("Configuration") <<
29  "MultiIsolator: you can specify at most 5 user isolation collections.\n";
30  }
31  uint32_t bit = Flags::Isolation::User1;
32  for (std::vector<edm::ParameterSet>::const_iterator it = psets.begin(), ed = psets.end(); it != ed; ++it, bit <<= 1) {
33  addIsolator(*it, cuts, bit, pat::IsolationKeys(pat::UserBaseIso + (it - psets.begin())));
34  }
35  }
36 }
37 
38 
39 void
41  isolators_.push_back(iso);
42  masks_.push_back(mask);
43  keys_.push_back(key);
44 }
45 
46 BaseIsolator *
48  if (conf.empty()) return 0;
49  if (conf.exists("placeholder") && conf.getParameter<bool>("placeholder")) return 0;
50  if (conf.exists("deltaR")) {
51  return new IsoDepositIsolator(conf, withCut);
52  } else {
53  return new SimpleIsolator(conf, withCut);
54  }
55 }
56 
57 
58 void
60  BaseIsolator * iso = make(conf, withCut);
61  if (iso) addIsolator(iso, mask, key);
62 }
63 
64 
65 void
67  for (boost::ptr_vector<BaseIsolator>::iterator it = isolators_.begin(), ed = isolators_.end(); it != ed; ++it) {
68  it->beginEvent(event, eventSetup);
69  }
70 }
71 
72 void
74  for (boost::ptr_vector<BaseIsolator>::iterator it = isolators_.begin(), ed = isolators_.end(); it != ed; ++it) {
75  it->endEvent();
76  }
77 }
78 
79 void
80 MultiIsolator::print(std::ostream &out) const {
81  for (boost::ptr_vector<BaseIsolator>::const_iterator it = isolators_.begin(), ed = isolators_.end(); it != ed; ++it) {
82  out << " * ";
83  it->print(out);
84  out << ": Flag " << pat::Flags::bitToString( masks_[it - isolators_.begin()] ) << "\n";
85  }
86  out << "\n";
87 }
88 
91  std::ostringstream isoSumm;
92  print(isoSumm);
93  return isoSumm.str();
94 }
95 
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:219
std::vector< uint32_t > masks_
Definition: MultiIsolator.h:53
boost::ptr_vector< BaseIsolator > isolators_
Definition: MultiIsolator.h:52
static const std::string & bitToString(uint32_t bit)
Definition: Flags.cc:6
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
static BaseIsolator * make(const edm::ParameterSet &conf, bool withCut)
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
std::string printSummary() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
tuple conf
Definition: dbtoconf.py:185
tuple out
Definition: dbtoconf.py:99
std::vector< pat::IsolationKeys > keys_
Definition: MultiIsolator.h:54
Flags used in PAT, and static translator from flags to strings.
Definition: Flags.h:21
list key
Definition: combine.py:13
void addIsolator(BaseIsolator *iso, uint32_t mask, pat::IsolationKeys key)