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 
24 
26 
30 
32 
35 
39 
41 
42 #include <string>
43 
44 namespace pat {
45 
46  class TrackerIsolationPt;
47  class CaloIsolationEnergy;
48  class LeptonLRCalc;
49 
51  public:
52  explicit PATElectronProducer(const edm::ParameterSet& iConfig);
53  ~PATElectronProducer() override;
54 
55  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
56 
57  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
58 
59  private:
60  // configurables
64  const bool embedGsfTrack_;
65  const bool embedSuperCluster_;
67  const bool embedSeedCluster_;
68  const bool embedBasicClusters_;
72  const bool embedTrack_;
75  const bool embedRecHits_;
76  // for mini-iso calculation
79  std::vector<double> miniIsoParamsE_;
80  std::vector<double> miniIsoParamsB_;
81 
82  typedef std::vector<edm::Handle<edm::Association<reco::GenParticleCollection> > > GenAssociations;
83 
84  std::vector<edm::EDGetTokenT<edm::Association<reco::GenParticleCollection> > > genMatchTokens_;
85 
87  const bool useParticleFlow_;
92  const bool embedPFCandidate_;
93 
95  const bool addMVAVariables_;
100 
101  const bool addPFClusterIso_;
102  const bool addPuppiIsolation_;
105 
110 
112  typedef std::vector<edm::Handle<edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
113  typedef std::vector<edm::Handle<edm::ValueMap<double> > > IsolationValueMaps;
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,
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  // set the mini-isolation variables
135 
136  // embed various impact parameters with errors
137  // embed high level selection
138  void embedHighLevel(pat::Electron& anElectron,
142  bool primaryVertexIsValid,
144  bool beamspotIsValid);
145 
146  typedef std::pair<pat::IsolationKeys, edm::InputTag> IsolationLabel;
147  typedef std::vector<IsolationLabel> IsolationLabels;
148 
151  template <typename T>
152  void readIsolationLabels(const edm::ParameterSet& iConfig,
153  const char* psetName,
155  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > >& tokens);
156 
157  const bool addElecID_;
158  typedef std::pair<std::string, edm::InputTag> NameTag;
159  std::vector<NameTag> elecIDSrcs_;
160  std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > elecIDTokens_;
161 
162  // tools
164 
166  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
168  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
170  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
172  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueNoPFIdTokens_;
173 
174  const bool addEfficiencies_;
176 
177  const bool addResolutions_;
179 
180  const bool useUserData_;
181  //PUPPI isolation tokens
185  //PUPPINoLeptons isolation tokens
190 
192  };
193 } // namespace pat
194 
195 template <typename T>
197  const char* psetName,
199  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > >& tokens) {
200  labels.clear();
201 
202  if (iConfig.exists(psetName)) {
203  edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>(psetName);
204 
205  if (depconf.exists("tracker"))
206  labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
207  if (depconf.exists("ecal"))
208  labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
209  if (depconf.exists("hcal"))
210  labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
211  if (depconf.exists("pfAllParticles")) {
212  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
213  }
214  if (depconf.exists("pfChargedHadrons")) {
215  labels.push_back(
216  std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
217  }
218  if (depconf.exists("pfChargedAll")) {
219  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
220  }
221  if (depconf.exists("pfPUChargedHadrons")) {
222  labels.push_back(
223  std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
224  }
225  if (depconf.exists("pfNeutralHadrons")) {
226  labels.push_back(
227  std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
228  }
229  if (depconf.exists("pfPhotons")) {
230  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
231  }
232  if (depconf.exists("user")) {
233  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
234  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
236  for (; it != ed; ++it, ++key) {
237  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
238  }
239  }
240  }
241  tokens = edm::vector_transform(
242  labels, [this](IsolationLabel const& label) { return consumes<edm::ValueMap<T> >(label.second); });
243 }
244 
245 #endif
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
pat::PATElectronProducer::isolatorTmpStorage_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
Definition: PATElectronProducer.h:166
pat::PATElectronProducer::isolationValueNoPFIdTokens_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueNoPFIdTokens_
Definition: PATElectronProducer.h:172
pat::PATUserDataHelper< pat::Electron >
pat::EcalIso
Definition: Isolation.h:11
GreaterByPt
Definition: PtComparator.h:24
pat::PATElectronProducer::embedGsfTrack_
const bool embedGsfTrack_
Definition: PATElectronProducer.h:64
pat::PATElectronProducer::elecIDSrcs_
std::vector< NameTag > elecIDSrcs_
Definition: PATElectronProducer.h:159
pat::PATElectronProducer::genMatchTokens_
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
Definition: PATElectronProducer.h:84
pat::PATElectronProducer::ElectronBaseRef
edm::RefToBase< reco::GsfElectron > ElectronBaseRef
Definition: PATElectronProducer.h:111
pat::PATElectronProducer::addPFClusterIso_
const bool addPFClusterIso_
Definition: PATElectronProducer.h:101
electronProducer_cff.isolationValues
isolationValues
Definition: electronProducer_cff.py:26
pat::PATElectronProducer::embedHighLevel
void embedHighLevel(pat::Electron &anElectron, reco::GsfTrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
Definition: PATElectronProducer.cc:1196
pat::PATElectronProducer::IsolationLabel
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
Definition: PATElectronProducer.h:146
pat::PATElectronProducer::fillElectron2
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
Definition: PATElectronProducer.cc:911
pat::PATElectronProducer::PUPPINoLeptonsIsolation_photons_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
Definition: PATElectronProducer.h:188
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
pat::helper::EfficiencyLoader
Definition: EfficiencyLoader.h:16
pat::PATElectronProducer::setElectronMiniIso
void setElectronMiniIso(pat::Electron &anElectron, const pat::PackedCandidateCollection *pc)
Definition: PATElectronProducer.cc:990
pat::PATElectronProducer::resolutionLoader_
pat::helper::KinResolutionsLoader resolutionLoader_
Definition: PATElectronProducer.h:178
pat::PATElectronProducer::isolationValueLabels_
IsolationLabels isolationValueLabels_
Definition: PATElectronProducer.h:169
edm::EDGetTokenT
Definition: EDGetToken.h:33
Electron
Definition: Electron.py:1
pat::PATElectronProducer::embedRecHits_
const bool embedRecHits_
Definition: PATElectronProducer.h:75
pat::PATElectronProducer::pvToken_
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
Definition: PATElectronProducer.h:109
pat::PATElectronProducer::elecIDTokens_
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
Definition: PATElectronProducer.h:160
EDProducer.h
pat::PATElectronProducer::embedPflowBasicClusters_
const bool embedPflowBasicClusters_
Definition: PATElectronProducer.h:70
electronProducer_cff.isolationValuesNoPFId
isolationValuesNoPFId
Definition: electronProducer_cff.py:34
pat::PfAllParticleIso
Definition: Isolation.h:13
pat::PATElectronProducer::embedHighLevelSelection_
const bool embedHighLevelSelection_
embed high level selection variables?
Definition: PATElectronProducer.h:107
PtComparator.h
pat::PATElectronProducer::IsoDepositMaps
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
Definition: PATElectronProducer.h:112
pat::PATElectronProducer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: PATElectronProducer.cc:231
EcalClusterLazyTools.h
pat::PATElectronProducer::userDataHelper_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
Definition: PATElectronProducer.h:189
pat::PATElectronProducer::PUPPINoLeptonsIsolation_charged_hadrons_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_charged_hadrons_
Definition: PATElectronProducer.h:186
pat::PATElectronProducer::addEfficiencies_
const bool addEfficiencies_
Definition: PATElectronProducer.h:174
TransientTrack.h
pat::PATElectronProducer::isolationValueLabelsNoPFId_
IsolationLabels isolationValueLabelsNoPFId_
Definition: PATElectronProducer.h:171
pat::PATElectronProducer::embedGenMatch_
bool embedGenMatch_
Definition: PATElectronProducer.h:74
pat::PATElectronProducer::NameTag
std::pair< std::string, edm::InputTag > NameTag
Definition: PATElectronProducer.h:158
pat::helper::MultiIsolator::IsolationValuePairs
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:17
CaloTopology
Definition: CaloTopology.h:19
MultiIsolator.h
EfficiencyLoader.h
pat::PATElectronProducer::useUserData_
const bool useUserData_
Definition: PATElectronProducer.h:180
pat::PATElectronProducer::embedPreshowerClusters_
const bool embedPreshowerClusters_
Definition: PATElectronProducer.h:69
pat::PATElectronProducer::pTComparator_
const GreaterByPt< Electron > pTComparator_
Definition: PATElectronProducer.h:163
pat::PATElectronProducer::pfCandidateMapToken_
const edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
Definition: PATElectronProducer.h:90
edm::Ref< GsfTrackCollection >
pat::PATElectronProducer::pfElecToken_
const edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
Definition: PATElectronProducer.h:89
pat::PATElectronProducer::embedPflowSuperCluster_
const bool embedPflowSuperCluster_
Definition: PATElectronProducer.h:66
pat::PATElectronProducer::embedSeedCluster_
const bool embedSeedCluster_
Definition: PATElectronProducer.h:67
BeamMonitor_cff.primaryVertex
primaryVertex
hltOfflineBeamSpot for HLTMON
Definition: BeamMonitor_cff.py:7
pat::PATElectronProducer::usePfCandidateMultiMap_
const bool usePfCandidateMultiMap_
Definition: PATElectronProducer.h:88
pat::PATElectronProducer::pfCandidateMultiMapToken_
const edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > pfCandidateMultiMapToken_
Definition: PATElectronProducer.h:91
pat::PATElectronProducer::isoDepositTokens_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
Definition: PATElectronProducer.h:168
pat::PATElectronProducer::isolationValueTokens_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
Definition: PATElectronProducer.h:170
pat::PfChargedHadronIso
Definition: Isolation.h:14
pat::PATElectronProducer::embedBasicClusters_
const bool embedBasicClusters_
Definition: PATElectronProducer.h:68
pat::PATElectronProducer::embedGsfElectronCore_
const bool embedGsfElectronCore_
Definition: PATElectronProducer.h:63
reco::BeamSpot
Definition: BeamSpot.h:21
pat::helper::KinResolutionsLoader
Definition: KinResolutionsLoader.h:18
KinResolutionsLoader.h
pat::PATElectronProducer::reducedEndcapRecHitCollection_
const edm::InputTag reducedEndcapRecHitCollection_
Definition: PATElectronProducer.h:98
beamspot
Definition: BeamSpotWrite2Txt.h:8
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::vector_transform
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
Vertex.h
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:674
pat::PATElectronProducer::PUPPIIsolation_charged_hadrons_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_charged_hadrons_
Definition: PATElectronProducer.h:182
pat::PATElectronProducer::hcalPFClusterIsoT_
const edm::EDGetTokenT< edm::ValueMap< float > > hcalPFClusterIsoT_
Definition: PATElectronProducer.h:104
edm::ParameterSet
Definition: ParameterSet.h:36
CandAssociation.h
Event.h
pat::PfGammaIso
Definition: Isolation.h:16
UserData.h
pat::UserBaseIso
Definition: Isolation.h:22
pat::PATElectronProducer::embedSuperCluster_
const bool embedSuperCluster_
Definition: PATElectronProducer.h:65
pat::PATElectronProducer::reducedBarrelRecHitCollection_
const edm::InputTag reducedBarrelRecHitCollection_
Definition: PATElectronProducer.h:96
pat::PATElectronProducer::IsolationLabels
std::vector< IsolationLabel > IsolationLabels
Definition: PATElectronProducer.h:147
pat::TrackIso
Definition: Isolation.h:10
pat::PATElectronProducer::reducedEndcapRecHitCollectionToken_
const edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
Definition: PATElectronProducer.h:99
pat::PATElectronProducer::embedPflowPreshowerClusters_
const bool embedPflowPreshowerClusters_
Definition: PATElectronProducer.h:71
iEvent
int iEvent
Definition: GenABIO.cc:224
pat::HcalIso
Definition: Isolation.h:12
pat::PATElectronProducer::addElecID_
const bool addElecID_
Definition: PATElectronProducer.h:157
pat::PATElectronProducer::electronToken_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
Definition: PATElectronProducer.h:61
pat::PfNeutralHadronIso
Definition: Isolation.h:15
edm::stream::EDProducer
Definition: EDProducer.h:38
pat::PfChargedAllIso
Definition: Isolation.h:25
pat::PATElectronProducer::ecalTopology_
const CaloTopology * ecalTopology_
Definition: PATElectronProducer.h:191
edm::EventSetup
Definition: EventSetup.h:57
pat::PATElectronProducer::embedPFCandidate_
const bool embedPFCandidate_
Definition: PATElectronProducer.h:92
pat
Definition: HeavyIon.h:7
pat::PATElectronProducer::hConversionsToken_
const edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
Definition: PATElectronProducer.h:62
pat::PfPUChargedHadronIso
Definition: Isolation.h:24
pat::PATElectronProducer::~PATElectronProducer
~PATElectronProducer() override
Definition: PATElectronProducer.cc:229
pat::PATElectronProducer::PUPPIIsolation_photons_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_photons_
Definition: PATElectronProducer.h:184
InputTag.h
pat::PATElectronProducer::addMVAVariables_
const bool addMVAVariables_
mva input variables
Definition: PATElectronProducer.h:95
pat::PATElectronProducer::useParticleFlow_
const bool useParticleFlow_
pflow specific
Definition: PATElectronProducer.h:87
edm::Ptr< Candidate >
pat::PATElectronProducer::addPuppiIsolation_
const bool addPuppiIsolation_
Definition: PATElectronProducer.h:102
pat::PackedCandidateCollection
std::vector< pat::PackedCandidate > PackedCandidateCollection
Definition: PackedCandidate.h:1130
pat::PATElectronProducer::PATElectronProducer
PATElectronProducer(const edm::ParameterSet &iConfig)
Definition: PATElectronProducer.cc:52
pat::PATElectronProducer::isolator_
pat::helper::MultiIsolator isolator_
Definition: PATElectronProducer.h:165
ValueMap.h
pat::PATElectronProducer::IsolationValueMaps
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
Definition: PATElectronProducer.h:113
pat::PATElectronProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PATElectronProducer.cc:1020
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CaloSubdetectorTopology.h
pat::helper::MultiIsolator
Definition: MultiIsolator.h:15
pat::PATElectronProducer::embedTrack_
const bool embedTrack_
Definition: PATElectronProducer.h:72
pat::PATElectronProducer::pcToken_
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
Definition: PATElectronProducer.h:77
pat::IsolationKeys
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
reco::TransientTrack
Definition: TransientTrack.h:19
pat::PATElectronProducer::miniIsoParamsB_
std::vector< double > miniIsoParamsB_
Definition: PATElectronProducer.h:80
pat::PATElectronProducer::fillElectron
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
Definition: PATElectronProducer.cc:815
pat::PATElectronProducer::addGenMatch_
bool addGenMatch_
Definition: PATElectronProducer.h:73
edm::ValueMap
Definition: ValueMap.h:107
pat::PATElectronProducer::ecalPFClusterIsoT_
const edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
Definition: PATElectronProducer.h:103
PATUserDataHelper.h
pat::PATElectronProducer::beamLineToken_
const edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
Definition: PATElectronProducer.h:108
edm::RefToBase
Definition: AssociativeIterator.h:54
pat::PATElectronProducer::PUPPINoLeptonsIsolation_neutral_hadrons_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_neutral_hadrons_
Definition: PATElectronProducer.h:187
Electron.h
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
pat::PATElectronProducer::GenAssociations
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
Definition: PATElectronProducer.h:82
pat::Electron
Analysis-level electron class.
Definition: Electron.h:51
View.h
ParameterSet.h
pat::PATElectronProducer::isoDepositLabels_
IsolationLabels isoDepositLabels_
Definition: PATElectronProducer.h:167
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
pat::PATElectronProducer::miniIsoParamsE_
std::vector< double > miniIsoParamsE_
Definition: PATElectronProducer.h:79
CandIsolatorFromDeposits_cfi.deposits
deposits
Definition: CandIsolatorFromDeposits_cfi.py:4
pat::PATElectronProducer::addResolutions_
const bool addResolutions_
Definition: PATElectronProducer.h:177
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
pat::PATElectronProducer::efficiencyLoader_
pat::helper::EfficiencyLoader efficiencyLoader_
Definition: PATElectronProducer.h:175
reco::Vertex
Definition: Vertex.h:35
pat::PATElectronProducer
Produces pat::Electron's.
Definition: PATElectronProducer.h:50
pat::PATElectronProducer::computeMiniIso_
bool computeMiniIso_
Definition: PATElectronProducer.h:78
pat::PATElectronProducer::readIsolationLabels
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels, std::vector< edm::EDGetTokenT< edm::ValueMap< T > > > &tokens)
Definition: PATElectronProducer.h:196
pat::PATElectronProducer::reducedBarrelRecHitCollectionToken_
const edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
Definition: PATElectronProducer.h:97
pat::PATElectronProducer::PUPPIIsolation_neutral_hadrons_
edm::EDGetTokenT< edm::ValueMap< float > > PUPPIIsolation_neutral_hadrons_
Definition: PATElectronProducer.h:183