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 
102  const bool addMVAVariables_;
107 
108  const bool addPFClusterIso_;
109  const bool addPuppiIsolation_;
112 
117 
119  typedef std::vector< edm::Handle< edm::ValueMap<IsoDeposit> > > IsoDepositMaps;
120  typedef std::vector< edm::Handle< edm::ValueMap<double> > > IsolationValueMaps;
121 
122 
124  void fillElectron( Electron& aElectron,
125  const ElectronBaseRef& electronRef,
126  const reco::CandidateBaseRef& baseRef,
127  const GenAssociations& genMatches,
128  const IsoDepositMaps& deposits,
129  const bool pfId,
130  const IsolationValueMaps& isolationValues,
131  const IsolationValueMaps& isolationValuesNoPFId) const;
132 
133  void fillElectron2( Electron& anElectron,
134  const reco::CandidatePtr& candPtrForIsolation,
135  const reco::CandidatePtr& candPtrForGenMatch,
136  const reco::CandidatePtr& candPtrForLoader,
137  const GenAssociations& genMatches,
138  const IsoDepositMaps& deposits,
139  const IsolationValueMaps& isolationValues ) const;
140 
141  // set the mini-isolation variables
143 
144  // embed various impact parameters with errors
145  // embed high level selection
146  void embedHighLevel( pat::Electron & anElectron,
150  bool primaryVertexIsValid,
152  bool beamspotIsValid );
153 
154  typedef std::pair<pat::IsolationKeys,edm::InputTag> IsolationLabel;
155  typedef std::vector<IsolationLabel> IsolationLabels;
156 
159  template<typename T> void readIsolationLabels( const edm::ParameterSet & iConfig,
160  const char* psetName,
161  IsolationLabels& labels,
162  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens);
163 
164  const bool addElecID_;
165  typedef std::pair<std::string, edm::InputTag> NameTag;
166  std::vector<NameTag> elecIDSrcs_;
167  std::vector<edm::EDGetTokenT<edm::ValueMap<float> > > elecIDTokens_;
168 
169  // tools
171 
173  pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_; // better here than recreate at each event
174  IsolationLabels isoDepositLabels_;
175  std::vector<edm::EDGetTokenT<edm::ValueMap<IsoDeposit> > > isoDepositTokens_;
176  IsolationLabels isolationValueLabels_;
177  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueTokens_;
179  std::vector<edm::EDGetTokenT<edm::ValueMap<double> > > isolationValueNoPFIdTokens_;
180 
181  const bool addEfficiencies_;
183 
184  const bool addResolutions_;
186 
187  const bool useUserData_;
188  //PUPPI isolation tokens
192  //PUPPINoLeptons isolation tokens
197 
199 
200  };
201 }
202 
203 template<typename T>
205  const char* psetName,
207  std::vector<edm::EDGetTokenT<edm::ValueMap<T> > > & tokens) {
208 
209  labels.clear();
210 
211  if (iConfig.exists( psetName )) {
212  edm::ParameterSet depconf
213  = iConfig.getParameter<edm::ParameterSet>(psetName);
214 
215  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
216  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
217  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
218  if (depconf.exists("pfAllParticles")) {
219  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
220  }
221  if (depconf.exists("pfChargedHadrons")) {
222  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
223  }
224  if (depconf.exists("pfChargedAll")) {
225  labels.push_back(std::make_pair(pat::PfChargedAllIso, depconf.getParameter<edm::InputTag>("pfChargedAll")));
226  }
227  if (depconf.exists("pfPUChargedHadrons")) {
228  labels.push_back(std::make_pair(pat::PfPUChargedHadronIso, depconf.getParameter<edm::InputTag>("pfPUChargedHadrons")));
229  }
230  if (depconf.exists("pfNeutralHadrons")) {
231  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
232  }
233  if (depconf.exists("pfPhotons")) {
234  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
235  }
236  if (depconf.exists("user")) {
237  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
238  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
240  for ( ; it != ed; ++it, ++key) {
241  labels.push_back(std::make_pair(pat::IsolationKeys(key), *it));
242  }
243  }
244  }
245  tokens = edm::vector_transform(labels, [this](IsolationLabel const & label){return consumes<edm::ValueMap<T> >(label.second);});
246 }
247 
248 #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_
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_
std::pair< pat::IsolationKeys, edm::InputTag > IsolationLabel
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::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
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: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