CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATPhotonProducer.h
Go to the documentation of this file.
1 //
2 //
3 
4 #ifndef PhysicsTools_PatAlgos_PATPhotonProducer_h
5 #define PhysicsTools_PatAlgos_PATPhotonProducer_h
6 
22 
24 
26 
30 
31 
34 
35 namespace pat {
36 
38 
39  public:
40 
41  explicit PATPhotonProducer(const edm::ParameterSet & iConfig);
43 
44  virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;
45 
46  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
47 
48  private:
49 
50  // configurables
53 
56  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > genMatchTokens_;
57 
58  // tools
59  GreaterByEt<Photon> eTComparator_;
60 
61  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
62  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
63  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
64  typedef std::vector<IsolationLabel> IsolationLabels;
65 
67  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
68  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
69  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
70 
73 
76  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig,
77  const char* psetName,
79  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
80 
83 
86 
88  typedef std::pair<std::string, edm::InputTag> NameTag;
89  std::vector<NameTag> photIDSrcs_;
90  std::vector<edm::EDGetTokenT<edm::ValueMap<Bool_t> > > photIDTokens_;
91 
94 
95  };
96 
97 }
98 
99 
100 using namespace pat;
101 
102 template<typename T>
104  const char* psetName,
106  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens) {
107 
108  labels.clear();
109 
110  if (iConfig.exists( psetName )) {
111  edm::ParameterSet depconf
112  = iConfig.getParameter<edm::ParameterSet>(psetName);
113 
114  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
115  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
116  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
117  if (depconf.exists("pfAllParticles")) {
118  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
119  }
120  if (depconf.exists("pfChargedHadrons")) {
121  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
122  }
123  if (depconf.exists("pfChargedAll")) {
124  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
125  }
126  if (depconf.exists("pfPUChargedHadrons")) {
127  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
128  }
129  if (depconf.exists("pfNeutralHadrons")) {
130  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
131  }
132  if (depconf.exists("pfPhotons")) {
133  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
134  }
135  if (depconf.exists("user")) {
136  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
137  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
138  int key = UserBaseIso;
139  for ( ; it != ed; ++it, ++key) {
140  labels.push_back(std::make_pair(IsolationKeys(key), *it));
141  }
142  }
143  }
144 
145  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
146 
147 }
148 
149 
150 #endif
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
pat::PATUserDataHelper< pat::Photon > userDataHelper_
std::pair< std::string, edm::InputTag > NameTag
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
std::vector< edm::EDGetTokenT< edm::ValueMap< Bool_t > > > photIDTokens_
edm::EDGetTokenT< edm::View< reco::Photon > > photonToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
pat::helper::KinResolutionsLoader resolutionLoader_
GreaterByEt< Photon > eTComparator_
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
std::vector< IsolationLabel > IsolationLabels
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
IsolationLabels isoDepositLabels_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
int iEvent
Definition: GenABIO.cc:243
IsolationLabels isolationValueLabels_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
pat::helper::EfficiencyLoader efficiencyLoader_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< NameTag > photIDSrcs_
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
pat::helper::MultiIsolator isolator_
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
list key
Definition: combine.py:13
PATPhotonProducer(const edm::ParameterSet &iConfig)
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
Produces the pat::Photon.