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"))
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_.push_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 (boost::ptr_vector<BaseIsolator>::iterator it = isolators_.begin(), ed = isolators_.end(); it != ed; ++it) {
81  it->beginEvent(event, eventSetup);
82  }
83 }
84 
86  for (boost::ptr_vector<BaseIsolator>::iterator 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 (boost::ptr_vector<BaseIsolator>::const_iterator it = isolators_.begin(), 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 }
pat::Flags::Isolation::Calo
Definition: Flags.h:102
pat::EcalIso
Definition: Isolation.h:11
pat::Flags::Isolation::User1
Definition: Flags.h:104
pat::helper::MultiIsolator::make
static BaseIsolator * make(const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut)
Definition: MultiIsolator.cc:60
pat::helper
Definition: ParametrizationHelper.h:8
pat::PfAllParticleIso
Definition: Isolation.h:13
pat::Flags
Flags used in PAT, and static translator from flags to strings.
Definition: Flags.h:19
pat::Flags::Isolation::Tracker
Definition: Flags.h:99
MultiIsolator.h
pat::helper::MultiIsolator::isolators_
boost::ptr_vector< BaseIsolator > isolators_
Definition: MultiIsolator.h:58
pat::helper::MultiIsolator::endEvent
void endEvent()
Definition: MultiIsolator.cc:85
pat::Flags::bitToString
static const std::string & bitToString(uint32_t bit)
Definition: Flags.cc:5
pat::PfChargedHadronIso
Definition: Isolation.h:14
pat::helper::IsoDepositIsolator
Definition: IsoDepositIsolator.h:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IsoDepositIsolator.h
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
pat::Flags::Isolation::HCal
Definition: Flags.h:101
edm::ParameterSet
Definition: ParameterSet.h:36
pat::PfGammaIso
Definition: Isolation.h:16
pat::UserBaseIso
Definition: Isolation.h:22
pat::TrackIso
Definition: Isolation.h:10
pat::HcalIso
Definition: Isolation.h:12
pat::PfNeutralHadronIso
Definition: Isolation.h:15
pat::helper::MultiIsolator::addIsolator
void addIsolator(BaseIsolator *iso, uint32_t mask, pat::IsolationKeys key)
Definition: MultiIsolator.cc:54
pat::helper::MultiIsolator::printSummary
std::string printSummary() const
Definition: MultiIsolator.cc:100
edm::EventSetup
Definition: EventSetup.h:57
pat::helper::BaseIsolator
Definition: BaseIsolator.h:13
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
pat::helper::SimpleIsolator
Definition: SimpleIsolator.h:8
pat::helper::MultiIsolator::print
void print(std::ostream &out) const
Definition: MultiIsolator.cc:91
pat::IsolationKeys
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
pat::helper::MultiIsolator::beginEvent
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
Definition: MultiIsolator.cc:79
Exception
Definition: hltDiff.cc:246
pat::Flags::Isolation::ECal
Definition: Flags.h:100
pat::CaloIso
Definition: Isolation.h:23
Flags.h
SimpleIsolator.h
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
L1TMuonDQMOffline_cfi.cuts
cuts
Definition: L1TMuonDQMOffline_cfi.py:41
event
Definition: event.py:1
pat::helper::MultiIsolator::keys_
std::vector< pat::IsolationKeys > keys_
Definition: MultiIsolator.h:60
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
pat::helper::MultiIsolator::masks_
std::vector< uint32_t > masks_
Definition: MultiIsolator.h:59
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
edm::ParameterSet::empty
bool empty() const
Definition: ParameterSet.h:190
pat::helper::MultiIsolator::MultiIsolator
MultiIsolator()
Definition: MultiIsolator.h:18