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,
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  // 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,
154  IsolationLabels& labels,
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
167  IsolationLabels isoDepositLabels_;
168  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
169  IsolationLabels isolationValueLabels_;
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
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_
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
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_
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
std::vector< edm::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
const edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
const bool addMVAVariables_
mva input variables
std::vector< double > miniIsoParamsB_
Definition: HeavyIon.h:7
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
const edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
char const * label
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:224
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::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
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::pair< std::string, edm::InputTag > NameTag
edm::EDGetTokenT< edm::ValueMap< float > > PUPPINoLeptonsIsolation_photons_
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:17
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
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< 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:51
const CaloTopology * ecalTopology_
IsolationLabels isolationValueLabelsNoPFId_
void setElectronMiniIso(pat::Electron &anElectron, const pat::PackedCandidateCollection *pc)
std::vector< IsolationLabel > IsolationLabels
IsolationLabels isolationValueLabels_
pat::helper::KinResolutionsLoader resolutionLoader_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
primaryVertex
hltOfflineBeamSpot for HLTMON
edm::EDGetTokenT< pat::PackedCandidateCollection > pcToken_
std::vector< NameTag > elecIDSrcs_