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 
33 
34 
37 
38 namespace pat {
39 
41 
42  public:
43 
44  explicit PATPhotonProducer(const edm::ParameterSet & iConfig);
46 
47  virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;
48 
49  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
50 
51  private:
52 
53  // configurables
60 
65 
68  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > genMatchTokens_;
69 
70  // tools
71  GreaterByEt<Photon> eTComparator_;
72 
73  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
74  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
75  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
76  typedef std::vector<IsolationLabel> IsolationLabels;
77 
79  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
80  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
81  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
82 
85 
88  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig,
89  const char* psetName,
91  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
92 
95 
98 
100  typedef std::pair<std::string, edm::InputTag> NameTag;
101  std::vector<NameTag> photIDSrcs_;
102  std::vector<edm::EDGetTokenT<edm::ValueMap<Bool_t> > > photIDTokens_;
103 
106 
108 
109 
110  };
111 
112 }
113 
114 
115 using namespace pat;
116 
117 template<typename T>
119  const char* psetName,
121  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens) {
122 
123  labels.clear();
124 
125  if (iConfig.exists( psetName )) {
126  edm::ParameterSet depconf
127  = iConfig.getParameter<edm::ParameterSet>(psetName);
128 
129  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
130  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
131  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
132  if (depconf.exists("pfAllParticles")) {
133  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
134  }
135  if (depconf.exists("pfChargedHadrons")) {
136  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
137  }
138  if (depconf.exists("pfChargedAll")) {
139  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
140  }
141  if (depconf.exists("pfPUChargedHadrons")) {
142  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
143  }
144  if (depconf.exists("pfNeutralHadrons")) {
145  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
146  }
147  if (depconf.exists("pfPhotons")) {
148  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
149  }
150  if (depconf.exists("user")) {
151  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
152  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
153  int key = UserBaseIso;
154  for ( ; it != ed; ++it, ++key) {
155  labels.push_back(std::make_pair(IsolationKeys(key), *it));
156  }
157  }
158  }
159 
160  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
161 
162 }
163 
164 
165 #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_
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
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
edm::InputTag reducedEndcapRecHitCollection_
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
const CaloTopology * ecalTopology_
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)
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
edm::InputTag reducedBarrelRecHitCollection_
Produces the pat::Photon.