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 
108 
110  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
111  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
112 
113 
115  void fillElectron( Electron& aElectron,
116  const ElectronBaseRef& electronRef,
117  const reco::CandidateBaseRef& baseRef,
118  const GenAssociations& genMatches,
119  const IsoDepositMaps& deposits,
120  const bool pfId,
121  const IsolationValueMaps& isolationValues,
122  const IsolationValueMaps& isolationValuesNoPFId) const;
123 
124  void fillElectron2( Electron& anElectron,
125  const reco::CandidatePtr& candPtrForIsolation,
126  const reco::CandidatePtr& candPtrForGenMatch,
127  const reco::CandidatePtr& candPtrForLoader,
128  const GenAssociations& genMatches,
129  const IsoDepositMaps& deposits,
130  const IsolationValueMaps& isolationValues ) const;
131 
132  // embed various impact parameters with errors
133  // embed high level selection
134  void embedHighLevel( pat::Electron & anElectron,
135  reco::GsfTrackRef track,
138  bool primaryVertexIsValid,
140  bool beamspotIsValid );
141 
142  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
143  typedef std::vector<IsolationLabel> IsolationLabels;
144 
147  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig,
148  const char* psetName,
150  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
151 
153  typedef std::pair<std::string, edm::InputTag> NameTag;
154  std::vector<NameTag> elecIDSrcs_;
155  std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > elecIDTokens_;
156 
157  // tools
159 
161  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
163  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
165  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
167  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueNoPFIdTokens_;
168 
171 
174 
177 
179 
180  };
181 
182 
183 }
184 
185 
186 using namespace pat;
187 
188 
189 template<typename T>
191  const char* psetName,
193  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens) {
194 
195  labels.clear();
196 
197  if (iConfig.exists( psetName )) {
198  edm::ParameterSet depconf
199  = iConfig.getParameter<edm::ParameterSet>(psetName);
200 
201  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
202  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
203  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
204  if (depconf.exists("pfAllParticles")) {
205  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
206  }
207  if (depconf.exists("pfChargedHadrons")) {
208  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
209  }
210  if (depconf.exists("pfChargedAll")) {
211  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
212  }
213  if (depconf.exists("pfPUChargedHadrons")) {
214  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
215  }
216  if (depconf.exists("pfNeutralHadrons")) {
217  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
218  }
219  if (depconf.exists("pfPhotons")) {
220  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
221  }
222  if (depconf.exists("user")) {
223  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
224  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
225  int key = UserBaseIso;
226  for ( ; it != ed; ++it, ++key) {
227  labels.push_back(std::make_pair(IsolationKeys(key), *it));
228  }
229  }
230  }
231  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
232 
233 
234 }
235 
236 #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)
edm::EDGetTokenT< edm::ValueMap< float > > hcalPFClusterIsoT_
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:230
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:52
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
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)
edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
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