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