CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATElectronProducer.h
Go to the documentation of this file.
1 //
2 
3 #ifndef PhysicsTools_PatAlgos_PATElectronProducer_h
4 #define PhysicsTools_PatAlgos_PATElectronProducer_h
5 
25 
27 
31 
33 
36 
40 
42 
43 #include <string>
44 
45 
46 namespace pat {
47 
48 
49  class TrackerIsolationPt;
50  class CaloIsolationEnergy;
51  class LeptonLRCalc;
52 
53 
55 
56  public:
57 
58  explicit PATElectronProducer(const edm::ParameterSet & iConfig);
60 
61  virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override;
62 
63  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
64 
65  private:
66 
67  // configurables
83 
84  typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > GenAssociations;
85 
86  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > genMatchTokens_;
87 
93 
99 
103  bool usePV_;
105 
107  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
108  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
109 
110 
112  void fillElectron( Electron& aElectron,
113  const ElectronBaseRef& electronRef,
114  const reco::CandidateBaseRef& baseRef,
115  const GenAssociations& genMatches,
116  const IsoDepositMaps& deposits,
117  const bool pfId,
118  const IsolationValueMaps& isolationValues,
119  const IsolationValueMaps& isolationValuesNoPFId) const;
120 
121  void fillElectron2( Electron& anElectron,
122  const reco::CandidatePtr& candPtrForIsolation,
123  const reco::CandidatePtr& candPtrForGenMatch,
124  const reco::CandidatePtr& candPtrForLoader,
125  const GenAssociations& genMatches,
126  const IsoDepositMaps& deposits,
127  const IsolationValueMaps& isolationValues ) const;
128 
129  // embed various impact parameters with errors
130  // embed high level selection
131  void embedHighLevel( pat::Electron & anElectron,
132  reco::GsfTrackRef track,
134  reco::Vertex & primaryVertex,
135  bool primaryVertexIsValid,
136  reco::BeamSpot & beamspot,
137  bool beamspotIsValid );
138 
139  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
140  typedef std::vector<IsolationLabel> IsolationLabels;
141 
144  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig,
145  const char* psetName,
147  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
148 
150  typedef std::pair<std::string, edm::InputTag> NameTag;
151  std::vector<NameTag> elecIDSrcs_;
152  std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > elecIDTokens_;
153 
154  // tools
156 
158  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
160  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
162  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
164  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueNoPFIdTokens_;
165 
168 
171 
174 
176 
177  };
178 
179 
180 }
181 
182 
183 using namespace pat;
184 
185 
186 template<typename T>
188  const char* psetName,
190  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens) {
191 
192  labels.clear();
193 
194  if (iConfig.exists( psetName )) {
195  edm::ParameterSet depconf
196  = iConfig.getParameter<edm::ParameterSet>(psetName);
197 
198  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
199  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
200  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
201  if (depconf.exists("pfAllParticles")) {
202  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
203  }
204  if (depconf.exists("pfChargedHadrons")) {
205  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
206  }
207  if (depconf.exists("pfChargedAll")) {
208  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
209  }
210  if (depconf.exists("pfPUChargedHadrons")) {
211  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
212  }
213  if (depconf.exists("pfNeutralHadrons")) {
214  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
215  }
216  if (depconf.exists("pfPhotons")) {
217  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
218  }
219  if (depconf.exists("user")) {
220  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
221  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
222  int key = UserBaseIso;
223  for ( ; it != ed; ++it, ++key) {
224  labels.push_back(std::make_pair(IsolationKeys(key), *it));
225  }
226  }
227  }
228  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
229 
230 
231 }
232 
233 #endif
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
void embedHighLevel(pat::Electron &anElectron, reco::GsfTrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
bool exists(std::string const &parameterName) const
checks if a parameter exists
void fillElectron(Electron &aElectron, const ElectronBaseRef &electronRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const bool pfId, const IsolationValueMaps &isolationValues, const IsolationValueMaps &isolationValuesNoPFId) const
common electron filling, for both the standard and PF2PAT case
edm::RefToBase< reco::GsfElectron > ElectronBaseRef
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< edm::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
GreaterByPt< Electron > pTComparator_
pat::helper::MultiIsolator isolator_
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
int iEvent
Definition: GenABIO.cc:243
Produces pat::Electron&#39;s.
PATElectronProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
edm::InputTag reducedEndcapRecHitCollection_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
edm::InputTag reducedBarrelRecHitCollection_
mva input variables
edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
bool embedHighLevelSelection_
embed high level selection variables?
std::pair< std::string, edm::InputTag > NameTag
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
void fillElectron2(Electron &anElectron, const reco::CandidatePtr &candPtrForIsolation, const reco::CandidatePtr &candPtrForGenMatch, const reco::CandidatePtr &candPtrForLoader, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueNoPFIdTokens_
pat::helper::EfficiencyLoader efficiencyLoader_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
bool useParticleFlow_
pflow specific
Analysis-level electron class.
Definition: Electron.h:50
const CaloTopology * ecalTopology_
IsolationLabels isolationValueLabelsNoPFId_
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
std::vector< IsolationLabel > IsolationLabels
list key
Definition: combine.py:13
IsolationLabels isolationValueLabels_
Calculates a lepton&#39;s calorimetric isolation energy.
pat::helper::KinResolutionsLoader resolutionLoader_
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
Calculates a lepton&#39;s tracker isolation pt.
std::vector< NameTag > elecIDSrcs_
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps