CMS 3D CMS Logo

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")) addIsolator(conf.getParameter<edm::ParameterSet>("tracker"), iC, cuts, Flags::Isolation::Tracker, pat::TrackIso);
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"), iC, cuts,Flags::Isolation::Calo, pat::PfAllParticleIso);
21  if (conf.exists("pfChargedHadron")) addIsolator(conf.getParameter<edm::ParameterSet>("pfChargedHadron"), iC, cuts,Flags::Isolation::Calo, pat::PfChargedHadronIso);
22  if (conf.exists("pfNeutralHadron")) addIsolator(conf.getParameter<edm::ParameterSet>("pfNeutralHadron"), iC, cuts,Flags::Isolation::Calo, pat::PfNeutralHadronIso);
23  if (conf.exists("pfGamma")) addIsolator(conf.getParameter<edm::ParameterSet>("pfGamma"), iC, cuts,Flags::Isolation::Calo, pat::PfGammaIso);
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, iC, 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 
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, iC, withCut);
52  } else {
53  return new SimpleIsolator(conf, iC, withCut);
54  }
55 }
56 
57 
58 void
60  BaseIsolator * iso = make(conf, iC, 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:218
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
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
std::string printSummary() const
static BaseIsolator * make(const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut)
std::vector< pat::IsolationKeys > keys_
Definition: MultiIsolator.h:54
Flags used in PAT, and static translator from flags to strings.
Definition: Flags.h:19
void addIsolator(BaseIsolator *iso, uint32_t mask, pat::IsolationKeys key)
Definition: event.py:1