test
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_;
101  const bool addPuppiIsolation_;
104 
109 
111  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
112  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
113 
114 
116  void fillElectron( Electron& aElectron,
117  const ElectronBaseRef& electronRef,
118  const reco::CandidateBaseRef& baseRef,
119  const GenAssociations& genMatches,
120  const IsoDepositMaps& deposits,
121  const bool pfId,
122  const IsolationValueMaps& isolationValues,
123  const IsolationValueMaps& isolationValuesNoPFId) const;
124 
125  void fillElectron2( Electron& anElectron,
126  const reco::CandidatePtr& candPtrForIsolation,
127  const reco::CandidatePtr& candPtrForGenMatch,
128  const reco::CandidatePtr& candPtrForLoader,
129  const GenAssociations& genMatches,
130  const IsoDepositMaps& deposits,
131  const IsolationValueMaps& isolationValues ) const;
132 
133  // embed various impact parameters with errors
134  // embed high level selection
135  void embedHighLevel( pat::Electron & anElectron,
136  reco::GsfTrackRef track,
139  bool primaryVertexIsValid,
141  bool beamspotIsValid );
142 
143  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
144  typedef std::vector<IsolationLabel> IsolationLabels;
145 
148  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig,
149  const char* psetName,
151  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
152 
153  const bool addElecID_;
154  typedef std::pair<std::string, edm::InputTag> NameTag;
155  std::vector<NameTag> elecIDSrcs_;
156  std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > elecIDTokens_;
157 
158  // tools
160 
162  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
164  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
166  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
168  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueNoPFIdTokens_;
169 
170  const bool addEfficiencies_;
172 
173  const bool addResolutions_;
175 
176  const bool useUserData_;
177  //PUPPI isolation tokens
181  //PUPPINoLeptons isolation tokens
186 
188 
189  };
190 }
191 
192 template<typename T>
194  const char* psetName,
196  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens) {
197 
198  labels.clear();
199 
200  if (iConfig.exists( psetName )) {
201  edm::ParameterSet depconf
202  = iConfig.getParameter<edm::ParameterSet>(psetName);
203 
204  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
205  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
206  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
207  if (depconf.exists("pfAllParticles")) {
208  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
209  }
210  if (depconf.exists("pfChargedHadrons")) {
211  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
212  }
213  if (depconf.exists("pfChargedAll")) {
214  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
215  }
216  if (depconf.exists("pfPUChargedHadrons")) {
217  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
218  }
219  if (depconf.exists("pfNeutralHadrons")) {
220  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
221  }
222  if (depconf.exists("pfPhotons")) {
223  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
224  }
225  if (depconf.exists("user")) {
226  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
227  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
229  for ( ; it != ed; ++it, ++key) {
230  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
231  }
232  }
233  }
234  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
235 }
236 
237 #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_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
const GreaterByPt< Electron > pTComparator_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
const bool useParticleFlow_
pflow specific
const edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
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
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
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_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
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.
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
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