CMS 3D CMS Logo

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);
59  ~PATElectronProducer() override;
60 
61  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  // for mini-iso calculation
86  std::vector<double> miniIsoParamsE_;
87  std::vector<double> miniIsoParamsB_;
88 
89  typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > GenAssociations;
90 
91  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > genMatchTokens_;
92 
94  const bool useParticleFlow_;
99  const bool embedPFCandidate_;
100 
106 
107  const bool addPFClusterIso_;
108  const bool addPuppiIsolation_;
111 
116 
118  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
119  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
120 
121 
123  void fillElectron( Electron& aElectron,
124  const ElectronBaseRef& electronRef,
125  const reco::CandidateBaseRef& baseRef,
126  const GenAssociations& genMatches,
127  const IsoDepositMaps& deposits,
128  const bool pfId,
129  const IsolationValueMaps& isolationValues,
130  const IsolationValueMaps& isolationValuesNoPFId) const;
131 
132  void fillElectron2( Electron& anElectron,
133  const reco::CandidatePtr& candPtrForIsolation,
134  const reco::CandidatePtr& candPtrForGenMatch,
135  const reco::CandidatePtr& candPtrForLoader,
136  const GenAssociations& genMatches,
137  const IsoDepositMaps& deposits,
138  const IsolationValueMaps& isolationValues ) const;
139 
140  // set the mini-isolation variables
142 
143  // embed various impact parameters with errors
144  // embed high level selection
145  void embedHighLevel( pat::Electron & anElectron,
149  bool primaryVertexIsValid,
151  bool beamspotIsValid );
152 
153  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
154  typedef std::vector<IsolationLabel> IsolationLabels;
155 
158  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig,
159  const char* psetName,
160  IsolationLabels& labels,
161  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
162 
163  const bool addElecID_;
164  typedef std::pair<std::string, edm::InputTag> NameTag;
165  std::vector<NameTag> elecIDSrcs_;
166  std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > elecIDTokens_;
167 
168  // tools
170 
172  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
173  IsolationLabels isoDepositLabels_;
174  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
175  IsolationLabels isolationValueLabels_;
176  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
178  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueNoPFIdTokens_;
179 
180  const bool addEfficiencies_;
182 
183  const bool addResolutions_;
185 
186  const bool useUserData_;
187  //PUPPI isolation tokens
191  //PUPPINoLeptons isolation tokens
196 
198 
199  };
200 }
201 
202 template<typename T>
204  const char* psetName,
206  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens) {
207 
208  labels.clear();
209 
210  if (iConfig.exists( psetName )) {
211  edm::ParameterSet depconf
212  = iConfig.getParameter<edm::ParameterSet>(psetName);
213 
214  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
215  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
216  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
217  if (depconf.exists("pfAllParticles")) {
218  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
219  }
220  if (depconf.exists("pfChargedHadrons")) {
221  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
222  }
223  if (depconf.exists("pfChargedAll")) {
224  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
225  }
226  if (depconf.exists("pfPUChargedHadrons")) {
227  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
228  }
229  if (depconf.exists("pfNeutralHadrons")) {
230  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
231  }
232  if (depconf.exists("pfPhotons")) {
233  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
234  }
235  if (depconf.exists("user")) {
236  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
237  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
239  for ( ; it != ed; ++it, ++key) {
240  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
241  }
242  }
243  }
244  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
245 }
246 
247 #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_
std::vector< double > miniIsoParamsE_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
const edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
std::vector< pat::PackedCandidate > PackedCandidateCollection
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_
std::vector< double > miniIsoParamsB_
Definition: HeavyIon.h:7
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
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > pfCandidateMultiMapToken_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
Analysis-level electron class.
Definition: Electron.h:52
const CaloTopology * ecalTopology_
IsolationLabels isolationValueLabelsNoPFId_
void setElectronMiniIso(pat::Electron &anElectron, const pat::PackedCandidateCollection *pc)
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_
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
std::vector< NameTag > elecIDSrcs_
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps