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
71  const bool embedGsfTrack_;
72  const bool embedSuperCluster_;
74  const bool embedSeedCluster_;
75  const bool embedBasicClusters_;
79  const bool embedTrack_;
82  const bool embedRecHits_;
83 
84  typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > GenAssociations;
85 
86  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > genMatchTokens_;
87 
89  const bool useParticleFlow_;
92  const bool embedPFCandidate_;
93 
99 
100  const bool addPFClusterIso_;
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 
152  const bool addElecID_;
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 
169  const bool addEfficiencies_;
171 
172  const bool addResolutions_;
174 
175  const bool useUserData_;
177 
179 
180  };
181 }
182 
183 template<typename T>
185  const char* psetName,
187  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens) {
188 
189  labels.clear();
190 
191  if (iConfig.exists( psetName )) {
192  edm::ParameterSet depconf
193  = iConfig.getParameter<edm::ParameterSet>(psetName);
194 
195  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
196  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
197  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
198  if (depconf.exists("pfAllParticles")) {
199  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
200  }
201  if (depconf.exists("pfChargedHadrons")) {
202  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
203  }
204  if (depconf.exists("pfChargedAll")) {
205  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
206  }
207  if (depconf.exists("pfPUChargedHadrons")) {
208  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
209  }
210  if (depconf.exists("pfNeutralHadrons")) {
211  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
212  }
213  if (depconf.exists("pfPhotons")) {
214  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
215  }
216  if (depconf.exists("user")) {
217  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
218  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
220  for ( ; it != ed; ++it, ++key) {
221  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
222  }
223  }
224  }
225  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
226 }
227 
228 #endif
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
const edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
const GreaterByPt< Electron > pTComparator_
const bool useParticleFlow_
pflow specific
const edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
const edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
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
const edm::InputTag reducedBarrelRecHitCollection_
mva input variables
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
const edm::EDGetTokenT< edm::ValueMap< float > > hcalPFClusterIsoT_
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_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
const edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
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)
const bool embedHighLevelSelection_
embed high level selection variables?
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
const edm::InputTag reducedEndcapRecHitCollection_
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
std::pair< std::string, edm::InputTag > NameTag
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
const edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
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_
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
Analysis-level electron class.
Definition: Electron.h:52
const CaloTopology * ecalTopology_
IsolationLabels isolationValueLabelsNoPFId_
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
std::vector< IsolationLabel > IsolationLabels
IsolationLabels isolationValueLabels_
pat::helper::KinResolutionsLoader resolutionLoader_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
std::vector< NameTag > elecIDSrcs_
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps