CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
pat::PATElectronProducer Class Reference

Produces pat::Electron's. More...

#include "PhysicsTools/PatAlgos/interface/PATElectronProducer.h"

Inheritance diagram for pat::PATElectronProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 PATElectronProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 ~PATElectronProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 

Private Types

typedef edm::RefToBase
< reco::GsfElectron
ElectronBaseRef
 
typedef std::vector
< edm::Handle
< edm::Association
< reco::GenParticleCollection > > > 
GenAssociations
 
typedef std::vector
< edm::Handle< edm::ValueMap
< IsoDeposit > > > 
IsoDepositMaps
 
typedef std::pair
< pat::IsolationKeys,
edm::InputTag
IsolationLabel
 
typedef std::vector
< IsolationLabel
IsolationLabels
 
typedef std::vector
< edm::Handle< edm::ValueMap
< double > > > 
IsolationValueMaps
 
typedef std::pair< std::string,
edm::InputTag
NameTag
 

Private Member Functions

void embedHighLevel (pat::Electron &anElectron, reco::GsfTrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
 
void fillElectron (Electron &aElectron, const ElectronBaseRef &electronRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
 common electron filling, for both the standard and PF2PAT case More...
 
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
 
void readIsolationLabels (const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels)
 

Private Attributes

bool addEfficiencies_
 
bool addElecID_
 
bool addGenMatch_
 
bool addResolutions_
 
edm::InputTag beamLineSrc_
 
pat::helper::EfficiencyLoader efficiencyLoader_
 
std::vector< NameTagelecIDSrcs_
 
edm::InputTag electronSrc_
 
bool embedGenMatch_
 
bool embedGsfElectronCore_
 
bool embedGsfTrack_
 
bool embedHighLevelSelection_
 embed high level selection variables? More...
 
bool embedPFCandidate_
 
bool embedSuperCluster_
 
bool embedTrack_
 
std::vector< edm::InputTaggenMatchSrc_
 
IsolationLabels isoDepositLabels_
 
IsolationLabels isolationValueLabels_
 
pat::helper::MultiIsolator isolator_
 
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
 
edm::InputTag linkToPFSource_
 
edm::InputTag pfElecSrc_
 
GreaterByPt< ElectronpTComparator_
 
edm::InputTag pvSrc_
 
pat::helper::KinResolutionsLoader resolutionLoader_
 
bool useParticleFlow_
 pflow specific More...
 
bool usePV_
 
pat::PATUserDataHelper
< pat::Electron
userDataHelper_
 
bool useUserData_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Produces pat::Electron's.

The PATElectronProducer produces analysis-level pat::Electron's starting from a collection of objects of reco::GsfElectron.

Author
Steven Lowette, James Lamb\
Version
Id:
PATElectronProducer.h,v 1.25 2011/03/31 09:52:39 namapane Exp

Definition at line 55 of file PATElectronProducer.h.

Member Typedef Documentation

Definition at line 91 of file PATElectronProducer.h.

Definition at line 90 of file PATElectronProducer.h.

Definition at line 92 of file PATElectronProducer.h.

Definition at line 122 of file PATElectronProducer.h.

Definition at line 123 of file PATElectronProducer.h.

typedef std::vector< edm::Handle< edm::ValueMap<double> > > pat::PATElectronProducer::IsolationValueMaps
private

Definition at line 93 of file PATElectronProducer.h.

typedef std::pair<std::string, edm::InputTag> pat::PATElectronProducer::NameTag
private

Definition at line 132 of file PATElectronProducer.h.

Constructor & Destructor Documentation

PATElectronProducer::PATElectronProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 44 of file PATElectronProducer.cc.

References addEfficiencies_, addElecID_, addGenMatch_, addResolutions_, beamLineSrc_, efficiencyLoader_, elecIDSrcs_, electronSrc_, embedGenMatch_, embedGsfElectronCore_, embedGsfTrack_, embedHighLevelSelection_, embedPFCandidate_, embedSuperCluster_, embedTrack_, edm::ParameterSet::existsAs(), genMatchSrc_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), isoDepositLabels_, isolationValueLabels_, linkToPFSource_, h::names, pfElecSrc_, pvSrc_, readIsolationLabels(), resolutionLoader_, useParticleFlow_, usePV_, userDataHelper_, and useUserData_.

44  :
45  isolator_(iConfig.exists("userIsolation") ? iConfig.getParameter<edm::ParameterSet>("userIsolation") : edm::ParameterSet(), false) ,
46  useUserData_(iConfig.exists("userData"))
47 {
48 
49  // general configurables
50  electronSrc_ = iConfig.getParameter<edm::InputTag>( "electronSource" );
51  embedGsfElectronCore_ = iConfig.getParameter<bool> ( "embedGsfElectronCore" );
52  embedGsfTrack_ = iConfig.getParameter<bool> ( "embedGsfTrack" );
53  embedSuperCluster_= iConfig.getParameter<bool> ( "embedSuperCluster" );
54  embedTrack_ = iConfig.getParameter<bool> ( "embedTrack" );
55 
56  // pflow specific
57  pfElecSrc_ = iConfig.getParameter<edm::InputTag>( "pfElectronSource" );
58  useParticleFlow_ = iConfig.getParameter<bool>( "useParticleFlow" );
59  linkToPFSource_ = iConfig.getParameter<edm::InputTag>( "linkToPFSource" ); //SAK
60  embedPFCandidate_ = iConfig.getParameter<bool>( "embedPFCandidate" );
61 
62 
63  // MC matching configurables
64  addGenMatch_ = iConfig.getParameter<bool> ( "addGenMatch" );
65  if (addGenMatch_) {
66  embedGenMatch_ = iConfig.getParameter<bool> ( "embedGenMatch" );
67  if (iConfig.existsAs<edm::InputTag>("genParticleMatch")) {
68  genMatchSrc_.push_back(iConfig.getParameter<edm::InputTag>( "genParticleMatch" ));
69  } else {
70  genMatchSrc_ = iConfig.getParameter<std::vector<edm::InputTag> >( "genParticleMatch" );
71  }
72  }
73 
74  // resolution configurables
75  addResolutions_ = iConfig.getParameter<bool> ( "addResolutions" );
76  if (addResolutions_) {
78  }
79 
80 
81  // electron ID configurables
82  addElecID_ = iConfig.getParameter<bool> ( "addElectronID" );
83  if (addElecID_) {
84  // it might be a single electron ID
85  if (iConfig.existsAs<edm::InputTag>("electronIDSource")) {
86  elecIDSrcs_.push_back(NameTag("", iConfig.getParameter<edm::InputTag>("electronIDSource")));
87  }
88  // or there might be many of them
89  if (iConfig.existsAs<edm::ParameterSet>("electronIDSources")) {
90  // please don't configure me twice
91  if (!elecIDSrcs_.empty()) throw cms::Exception("Configuration") <<
92  "PATElectronProducer: you can't specify both 'electronIDSource' and 'electronIDSources'\n";
93  // read the different electron ID names
94  edm::ParameterSet idps = iConfig.getParameter<edm::ParameterSet>("electronIDSources");
95  std::vector<std::string> names = idps.getParameterNamesForType<edm::InputTag>();
96  for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
97  elecIDSrcs_.push_back(NameTag(*it, idps.getParameter<edm::InputTag>(*it)));
98  }
99  }
100  // but in any case at least once
101  if (elecIDSrcs_.empty()) throw cms::Exception("Configuration") <<
102  "PATElectronProducer: id addElectronID is true, you must specify either:\n" <<
103  "\tInputTag electronIDSource = <someTag>\n" << "or\n" <<
104  "\tPSet electronIDSources = { \n" <<
105  "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
106  "\t}\n";
107  }
108 
109  // construct resolution calculator
110 
111  // // IsoDeposit configurables
112  // if (iConfig.exists("isoDeposits")) {
113  // edm::ParameterSet depconf = iConfig.getParameter<edm::ParameterSet>("isoDeposits");
114  // if (depconf.exists("tracker")) isoDepositLabels_.push_back(std::make_pair(TrackerIso, depconf.getParameter<edm::InputTag>("tracker")));
115  // if (depconf.exists("ecal")) isoDepositLabels_.push_back(std::make_pair(ECalIso, depconf.getParameter<edm::InputTag>("ecal")));
116  // if (depconf.exists("hcal")) isoDepositLabels_.push_back(std::make_pair(HCalIso, depconf.getParameter<edm::InputTag>("hcal")));
117 
118 
119  // if (depconf.exists("user")) {
120  // std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
121  // std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
122  // int key = UserBaseIso;
123  // for ( ; it != ed; ++it, ++key) {
124  // isoDepositLabels_.push_back(std::make_pair(IsolationKeys(key), *it));
125  // }
126  // }
127  // }
128 
129  // read isoDeposit labels, for direct embedding
130  readIsolationLabels(iConfig, "isoDeposits", isoDepositLabels_);
131 
132  // read isolation value labels, for direct embedding
133  readIsolationLabels(iConfig, "isolationValues", isolationValueLabels_);
134 
135  // Efficiency configurables
136  addEfficiencies_ = iConfig.getParameter<bool>("addEfficiencies");
137  if (addEfficiencies_) {
139  }
140 
141  // Check to see if the user wants to add user data
142  if ( useUserData_ ) {
144  }
145 
146  // embed high level selection variables?
147  embedHighLevelSelection_ = iConfig.getParameter<bool>("embedHighLevelSelection");
148  if ( embedHighLevelSelection_ ) {
149  beamLineSrc_ = iConfig.getParameter<edm::InputTag>("beamLineSrc");
150  usePV_ = iConfig.getParameter<bool>("usePV");
151  pvSrc_ = iConfig.getParameter<edm::InputTag>("pvSrc");
152  }
153 
154 
155  // produces vector of muons
156  produces<std::vector<Electron> >();
157 
158 }
T getParameter(std::string const &) const
Assists in assimilating all pat::UserData into pat objects.
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:181
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< edm::InputTag > genMatchSrc_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:189
pat::helper::MultiIsolator isolator_
bool embedHighLevelSelection_
embed high level selection variables?
std::pair< std::string, edm::InputTag > NameTag
pat::helper::EfficiencyLoader efficiencyLoader_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
bool useParticleFlow_
pflow specific
IsolationLabels isolationValueLabels_
pat::helper::KinResolutionsLoader resolutionLoader_
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels)
static const HistoName names[]
std::vector< NameTag > elecIDSrcs_
PATElectronProducer::~PATElectronProducer ( )

Definition at line 161 of file PATElectronProducer.cc.

161  {
162 }

Member Function Documentation

void PATElectronProducer::embedHighLevel ( pat::Electron anElectron,
reco::GsfTrackRef  track,
reco::TransientTrack tt,
reco::Vertex primaryVertex,
bool  primaryVertexIsValid,
reco::BeamSpot beamspot,
bool  beamspotIsValid 
)
private

Definition at line 785 of file PATElectronProducer.cc.

References pat::Electron::BS2D, pat::Electron::BS3D, reco::BeamSpot::covariance3D(), reco::BeamSpot::position(), pat::Electron::PV2D, pat::Electron::PV3D, query::result, pat::Electron::setDB(), IPTools::signedImpactParameter3D(), and IPTools::signedTransverseImpactParameter().

Referenced by produce().

793 {
794  // Correct to PV
795 
796  // PV2D
797  std::pair<bool,Measurement1D> result =
799  GlobalVector(track->px(),
800  track->py(),
801  track->pz()),
802  primaryVertex);
803  double d0_corr = result.second.value();
804  double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
805  anElectron.setDB( d0_corr, d0_err, pat::Electron::PV2D);
806 
807 
808  // PV3D
809  result =
811  GlobalVector(track->px(),
812  track->py(),
813  track->pz()),
814  primaryVertex);
815  d0_corr = result.second.value();
816  d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
817  anElectron.setDB( d0_corr, d0_err, pat::Electron::PV3D);
818 
819 
820  // Correct to beam spot
821  // make a fake vertex out of beam spot
822  reco::Vertex vBeamspot(beamspot.position(), beamspot.covariance3D());
823 
824  // BS2D
825  result =
827  GlobalVector(track->px(),
828  track->py(),
829  track->pz()),
830  vBeamspot);
831  d0_corr = result.second.value();
832  d0_err = beamspotIsValid ? result.second.error() : -1.0;
833  anElectron.setDB( d0_corr, d0_err, pat::Electron::BS2D);
834 
835  // BS3D
836  result =
838  GlobalVector(track->px(),
839  track->py(),
840  track->pz()),
841  vBeamspot);
842  d0_corr = result.second.value();
843  d0_err = beamspotIsValid ? result.second.error() : -1.0;
844  anElectron.setDB( d0_corr, d0_err, pat::Electron::BS3D);
845 }
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
Definition: BeamSpot.h:119
void setDB(double dB, double edB, IpType type=None)
Definition: Electron.cc:275
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
tuple result
Definition: query.py:137
const Point & position() const
position
Definition: BeamSpot.h:63
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void PATElectronProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 644 of file PATElectronProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addNode(), edm::ParameterSetDescription::addOptional(), pat::helper::KinResolutionsLoader::fillDescription(), pat::PATUserDataHelper< ObjectType >::fillDescription(), edm::ParameterSetDescription::setAllowAnything(), edm::ParameterSetDescription::setComment(), and edm::ParameterDescriptionNode::setComment().

645 {
647  iDesc.setComment("PAT electron producer module");
648 
649  // input source
650  iDesc.add<edm::InputTag>("electronSource", edm::InputTag("no default"))->setComment("input collection");
651 
652  // embedding
653  iDesc.add<bool>("embedGsfElectronCore", true)->setComment("embed external gsf electron core");
654  iDesc.add<bool>("embedGsfTrack", true)->setComment("embed external gsf track");
655  iDesc.add<bool>("embedSuperCluster", true)->setComment("embed external super cluster");
656  iDesc.add<bool>("embedTrack", false)->setComment("embed external track");
657 
658  // pf specific parameters
659  iDesc.add<edm::InputTag>("pfElectronSource", edm::InputTag("pfElectrons"))->setComment("particle flow input collection");
660  iDesc.add<bool>("useParticleFlow", false)->setComment("whether to use particle flow or not");
661  iDesc.add<edm::InputTag>("linkToPFSource", edm::InputTag())->setComment("alternative PF collection to link to (pfCandidateRef) -- traverses inheritance chain up to this");
662  iDesc.add<bool>("embedPFCandidate", false)->setComment("embed external particle flow object");
663 
664  // MC matching configurables
665  iDesc.add<bool>("addGenMatch", true)->setComment("add MC matching");
666  iDesc.add<bool>("embedGenMatch", false)->setComment("embed MC matched MC information");
667  std::vector<edm::InputTag> emptySourceVector;
668  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("genParticleMatch", edm::InputTag(), true) xor
669  edm::ParameterDescription<std::vector<edm::InputTag> >("genParticleMatch", emptySourceVector, true)
670  )->setComment("input with MC match information");
671 
672  // electron ID configurables
673  iDesc.add<bool>("addElectronID",true)->setComment("add electron ID variables");
674  edm::ParameterSetDescription electronIDSourcesPSet;
675  electronIDSourcesPSet.setAllowAnything();
676  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("electronIDSource", edm::InputTag(), true) xor
677  edm::ParameterDescription<edm::ParameterSetDescription>("electronIDSources", electronIDSourcesPSet, true)
678  )->setComment("input with electron ID variables");
679 
680 
681  // IsoDeposit configurables
682  edm::ParameterSetDescription isoDepositsPSet;
683  isoDepositsPSet.addOptional<edm::InputTag>("tracker");
684  isoDepositsPSet.addOptional<edm::InputTag>("ecal");
685  isoDepositsPSet.addOptional<edm::InputTag>("hcal");
686  isoDepositsPSet.addOptional<edm::InputTag>("pfAllParticles");
687  isoDepositsPSet.addOptional<edm::InputTag>("pfChargedHadrons");
688  isoDepositsPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
689  isoDepositsPSet.addOptional<edm::InputTag>("pfPhotons");
690  isoDepositsPSet.addOptional<std::vector<edm::InputTag> >("user");
691  iDesc.addOptional("isoDeposits", isoDepositsPSet);
692 
693  // isolation values configurables
694  edm::ParameterSetDescription isolationValuesPSet;
695  isolationValuesPSet.addOptional<edm::InputTag>("tracker");
696  isolationValuesPSet.addOptional<edm::InputTag>("ecal");
697  isolationValuesPSet.addOptional<edm::InputTag>("hcal");
698  isolationValuesPSet.addOptional<edm::InputTag>("pfAllParticles");
699  isolationValuesPSet.addOptional<edm::InputTag>("pfChargedHadrons");
700  isolationValuesPSet.addOptional<edm::InputTag>("pfNeutralHadrons");
701  isolationValuesPSet.addOptional<edm::InputTag>("pfPhotons");
702  isolationValuesPSet.addOptional<std::vector<edm::InputTag> >("user");
703  iDesc.addOptional("isolationValues", isolationValuesPSet);
704 
705  // Efficiency configurables
706  edm::ParameterSetDescription efficienciesPSet;
707  efficienciesPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
708  iDesc.add("efficiencies", efficienciesPSet);
709  iDesc.add<bool>("addEfficiencies", false);
710 
711  // Check to see if the user wants to add user data
712  edm::ParameterSetDescription userDataPSet;
714  iDesc.addOptional("userData", userDataPSet);
715 
716  // electron shapes
717  iDesc.add<bool>("addElectronShapes", true);
718  iDesc.add<edm::InputTag>("reducedBarrelRecHitCollection", edm::InputTag("reducedEcalRecHitsEB"));
719  iDesc.add<edm::InputTag>("reducedEndcapRecHitCollection", edm::InputTag("reducedEcalRecHitsEE"));
720 
721  edm::ParameterSetDescription isolationPSet;
722  isolationPSet.setAllowAnything(); // TODO: the pat helper needs to implement a description.
723  iDesc.add("userIsolation", isolationPSet);
724 
725  // Resolution configurables
727 
728  iDesc.add<bool>("embedHighLevelSelection", true)->setComment("embed high level selection");
729  edm::ParameterSetDescription highLevelPSet;
730  highLevelPSet.setAllowAnything();
731  iDesc.addNode( edm::ParameterDescription<edm::InputTag>("beamLineSrc", edm::InputTag(), true)
732  )->setComment("input with high level selection");
734  )->setComment("input with high level selection");
735  iDesc.addNode( edm::ParameterDescription<bool>("usePV", bool(), true)
736  )->setComment("input with high level selection, use primary vertex (true) or beam line (false)");
737 
738  descriptions.add("PATElectronProducer", iDesc);
739 
740 }
void setComment(std::string const &value)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
static void fillDescription(edm::ParameterSetDescription &iDesc)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void PATElectronProducer::fillElectron ( Electron aElectron,
const ElectronBaseRef electronRef,
const reco::CandidateBaseRef baseRef,
const GenAssociations genMatches,
const IsoDepositMaps deposits,
const IsolationValueMaps isolationValues 
) const
private

common electron filling, for both the standard and PF2PAT case

Definition at line 483 of file PATElectronProducer.cc.

References addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), efficiencyLoader_, embedGenMatch_, pat::PATObject< ObjectType >::embedGenParticle(), pat::Electron::embedGsfElectronCore(), embedGsfElectronCore_, pat::Electron::embedGsfTrack(), embedGsfTrack_, pat::Electron::embedSuperCluster(), embedSuperCluster_, pat::Electron::embedTrack(), embedTrack_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), first, i, edm::Ref< C, T, F >::isNull(), isoDepositLabels_, isolationValueLabels_, j, n, pat::Electron::pfCandidateRef(), resolutionLoader_, pat::helper::EfficiencyLoader::setEfficiencies(), pat::Lepton< LeptonType >::setIsoDeposit(), pat::Lepton< LeptonType >::setIsolation(), pat::helper::KinResolutionsLoader::setResolutions(), LaserTracksInput_cfi::source, and useParticleFlow_.

Referenced by produce().

489  {
490 
491  //COLIN: might want to use the PFCandidate 4-mom. Which one is in use now?
492  // if (useParticleFlow_)
493  // aMuon.setP4( aMuon.pfCandidateRef()->p4() );
494 
495  //COLIN:
496  //In the embedding case, the reference cannot be used to look into a value map.
497  //therefore, one has to had the PFCandidateRef to this function, which becomes a bit
498  //too much specific.
499 
500  // in fact, this function needs a baseref or ptr for genmatch
501  // and a baseref or ptr for isodeposits and isolationvalues.
502  // baseref is not needed
503  // the ptrForIsolation and ptrForMatching should be defined upstream.
504 
505  // is the concrete elecRef needed for the efficiency loader? what is this loader?
506  // how can we make it compatible with the particle flow electrons?
507 
508  if (embedGsfElectronCore_) anElectron.embedGsfElectronCore();
509  if (embedGsfTrack_) anElectron.embedGsfTrack();
510  if (embedSuperCluster_) anElectron.embedSuperCluster();
511  if (embedTrack_) anElectron.embedTrack();
512 
513  // store the match to the generated final state muons
514  if (addGenMatch_) {
515  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
516  if(useParticleFlow_) {
517  reco::GenParticleRef genElectron = (*genMatches[i])[anElectron.pfCandidateRef()];
518  anElectron.addGenParticleRef(genElectron);
519  }
520  else {
521  reco::GenParticleRef genElectron = (*genMatches[i])[elecRef];
522  anElectron.addGenParticleRef(genElectron);
523  }
524  }
525  if (embedGenMatch_) anElectron.embedGenParticle();
526  }
527 
528  if (efficiencyLoader_.enabled()) {
529  efficiencyLoader_.setEfficiencies( anElectron, elecRef );
530  }
531 
532  if (resolutionLoader_.enabled()) {
533  resolutionLoader_.setResolutions(anElectron);
534  }
535 
536  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
537  if(useParticleFlow_) {
538 
539  reco::PFCandidateRef pfcandref = anElectron.pfCandidateRef();
540  assert(!pfcandref.isNull());
541  reco::CandidatePtr source = pfcandref->sourceCandidatePtr(0);
542  anElectron.setIsoDeposit(isoDepositLabels_[j].first,
543  (*deposits[j])[source]);
544  }
545  else
546  anElectron.setIsoDeposit(isoDepositLabels_[j].first,
547  (*deposits[j])[elecRef]);
548  }
549 
550  for (size_t j = 0; j<isolationValues.size(); ++j) {
551  if(useParticleFlow_) {
552  reco::CandidatePtr source = anElectron.pfCandidateRef()->sourceCandidatePtr(0);
553  anElectron.setIsolation(isolationValueLabels_[j].first,
554  (*isolationValues[j])[source]);
555  }
556  else
557  anElectron.setIsolation(isolationValueLabels_[j].first,
558  (*isolationValues[j])[elecRef]);
559  }
560 
561 
562 
563 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
int i
Definition: DBlmapReader.cc:9
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
bool isNull() const
Checks for null.
Definition: Ref.h:246
int j
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:79
pat::helper::EfficiencyLoader efficiencyLoader_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
bool useParticleFlow_
pflow specific
IsolationLabels isolationValueLabels_
pat::helper::KinResolutionsLoader resolutionLoader_
void PATElectronProducer::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
private

Definition at line 565 of file PATElectronProducer.cc.

References addGenMatch_, pat::PATObject< ObjectType >::addGenParticleRef(), edm::contains(), pat::EcalIso, efficiencyLoader_, embedGenMatch_, pat::PATObject< ObjectType >::embedGenParticle(), pat::Electron::embedGsfElectronCore(), embedGsfElectronCore_, pat::Electron::embedGsfTrack(), embedGsfTrack_, pat::Electron::embedSuperCluster(), embedSuperCluster_, pat::Electron::embedTrack(), embedTrack_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), first, pat::HcalIso, i, edm::Ptr< T >::id(), isoDepositLabels_, isolationValueLabels_, j, n, reco::GsfElectron::p4(), pat::Electron::pfCandidateRef(), resolutionLoader_, pat::Electron::setEcalDrivenMomentum(), pat::helper::EfficiencyLoader::setEfficiencies(), pat::Lepton< LeptonType >::setIsoDeposit(), pat::Lepton< LeptonType >::setIsolation(), reco::GsfElectron::setP4(), pat::helper::KinResolutionsLoader::setResolutions(), and pat::TrackIso.

Referenced by produce().

571  {
572 
573  //COLIN/Florian: use the PFCandidate 4-mom.
574  anElectron.setEcalDrivenMomentum(anElectron.p4()) ;
575  anElectron.setP4( anElectron.pfCandidateRef()->p4() );
576 
577 
578  // is the concrete elecRef needed for the efficiency loader? what is this loader?
579  // how can we make it compatible with the particle flow electrons?
580 
582  if (embedGsfTrack_) anElectron.embedGsfTrack();
583  if (embedSuperCluster_) anElectron.embedSuperCluster();
584  if (embedTrack_) anElectron.embedTrack();
585 
586  // store the match to the generated final state muons
587 
588  if (addGenMatch_) {
589  for(size_t i = 0, n = genMatches.size(); i < n; ++i) {
590  reco::GenParticleRef genElectron = (*genMatches[i])[candPtrForGenMatch];
591  anElectron.addGenParticleRef(genElectron);
592  }
593  if (embedGenMatch_) anElectron.embedGenParticle();
594  }
595 
596  //COLIN what's this? does it have to be GsfElectron specific?
597  if (efficiencyLoader_.enabled()) {
598  efficiencyLoader_.setEfficiencies( anElectron, candPtrForLoader );
599  }
600 
601  if (resolutionLoader_.enabled()) {
602  resolutionLoader_.setResolutions(anElectron);
603  }
604 
605  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
609 
611  (*deposits[j])[candPtrForGenMatch]);
612  }
613  else if (deposits[j]->contains(candPtrForIsolation.id())) {
614  anElectron.setIsoDeposit(isoDepositLabels_[j].first,
615  (*deposits[j])[candPtrForIsolation]);
616  }
617  else {
618  anElectron.setIsoDeposit(isoDepositLabels_[j].first,
619  (*deposits[j])[candPtrForIsolation->sourceCandidatePtr(0)]);
620  }
621  }
622 
623  for (size_t j = 0; j<isolationValues.size(); ++j) {
624  if( isolationValueLabels_[j].first==pat::TrackIso ||
627  anElectron.setIsolation(isolationValueLabels_[j].first,
628  (*isolationValues[j])[candPtrForGenMatch]);
629  }
630  else if (isolationValues[j]->contains(candPtrForIsolation.id())) {
631  anElectron.setIsolation(isolationValueLabels_[j].first,
632  (*isolationValues[j])[candPtrForIsolation]);
633  }
634  else {
635  anElectron.setIsolation(isolationValueLabels_[j].first,
636  (*isolationValues[j])[candPtrForIsolation->sourceCandidatePtr(0)]);
637  }
638 
639  }
640 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
int i
Definition: DBlmapReader.cc:9
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
Definition: GsfElectron.cc:170
void embedTrack()
method to store the electron&#39;s Track internally
Definition: Electron.cc:175
void setIsolation(IsolationKeys key, float value)
Definition: Lepton.h:99
void embedGsfElectronCore()
method to store the electron&#39;s core internally
Definition: Electron.cc:146
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:196
void embedSuperCluster()
method to store the electron&#39;s SuperCluster internally
Definition: Electron.cc:165
void setEcalDrivenMomentum(const Candidate::LorentzVector &mom)
Definition: Electron.h:173
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
Definition: Lepton.h:173
void embedGenParticle()
Definition: PATObject.h:669
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:169
int j
Definition: DBlmapReader.cc:9
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates
Definition: Electron.cc:207
bool first
Definition: L1TdeRCT.cc:79
void embedGsfTrack()
method to store the electron&#39;s GsfTrack internally
Definition: Electron.cc:155
void addGenParticleRef(const reco::GenParticleRef &ref)
Definition: PATObject.h:653
pat::helper::EfficiencyLoader efficiencyLoader_
void setEfficiencies(pat::PATObject< T > &obj, const R &originalRef) const
Sets the efficiencies for this object, using the reference to the original objects.
IsolationLabels isolationValueLabels_
pat::helper::KinResolutionsLoader resolutionLoader_
void PATElectronProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 165 of file PATElectronProducer.cc.

References IPTools::absoluteTransverseImpactParameter(), addElecID_, addGenMatch_, beamLineSrc_, pat::helper::MultiIsolator::beginEvent(), efficiencyLoader_, elecIDSrcs_, electronSrc_, embedGenMatch_, embedHighLevel(), embedHighLevelSelection_, pat::Electron::embedPFCandidate(), embedPFCandidate_, pat::helper::EfficiencyLoader::enabled(), pat::helper::KinResolutionsLoader::enabled(), pat::helper::MultiIsolator::enabled(), edm::InputTag::encode(), pat::helper::MultiIsolator::endEvent(), pat::helper::MultiIsolator::fill(), fillElectron(), fillElectron2(), first, genMatchSrc_, edm::EventSetup::get(), edm::Event::getByLabel(), i, edm::HandleBase::id(), edm::Ptr< T >::id(), edm::Ref< C, T, F >::id(), getHLTprescales::index, edm::Ref< C, T, F >::isAvailable(), edm::Ref< C, T, F >::isNonnull(), edm::Ptr< T >::isNull(), isoDepositLabels_, isolationValueLabels_, isolator_, isolatorTmpStorage_, edm::EventBase::isRealData(), edm::HandleBase::isValid(), j, edm::Ptr< T >::key(), edm::InputTag::label(), linkToPFSource_, reco::Matched, pat::helper::EfficiencyLoader::newEvent(), pat::helper::KinResolutionsLoader::newEvent(), electronProducer_cfi::patElectrons, pat::Electron::pfCandidateRef(), pfElecSrc_, pTComparator_, edm::Event::put(), pvSrc_, resolutionLoader_, query::result, edm::second(), pat::Electron::setDB(), pat::Electron::setElectronIDs(), pat::Lepton< LeptonType >::setIsoDeposit(), pat::Lepton< LeptonType >::setIsolation(), pat::Electron::setPFCandidateRef(), python.multivaluedict::sort(), LaserTracksInput_cfi::source, useParticleFlow_, usePV_, userDataHelper_, useUserData_, reco::BeamSpot::x0(), reco::BeamSpot::y0(), and reco::BeamSpot::z0().

165  {
166 
167  // Get the collection of electrons from the event
169  iEvent.getByLabel(electronSrc_, electrons);
170 
171  if (iEvent.isRealData()){
172  addGenMatch_ = false;
173  embedGenMatch_ = false;
174  }
175 
176  // Get the ESHandle for the transient track builder, if needed for
177  // high level selection embedding
179 
180  if (isolator_.enabled()) isolator_.beginEvent(iEvent,iSetup);
181 
183  if (resolutionLoader_.enabled()) resolutionLoader_.newEvent(iEvent, iSetup);
184 
185  IsoDepositMaps deposits(isoDepositLabels_.size());
186  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
187  iEvent.getByLabel(isoDepositLabels_[j].second, deposits[j]);
188  }
189 
190  IsolationValueMaps isolationValues(isolationValueLabels_.size());
191  for (size_t j = 0; j<isolationValueLabels_.size(); ++j) {
192  iEvent.getByLabel(isolationValueLabels_[j].second, isolationValues[j]);
193  }
194 
195  // prepare the MC matching
196  GenAssociations genMatches(genMatchSrc_.size());
197  if (addGenMatch_) {
198  for (size_t j = 0, nd = genMatchSrc_.size(); j < nd; ++j) {
199  iEvent.getByLabel(genMatchSrc_[j], genMatches[j]);
200  }
201  }
202 
203  // prepare ID extraction
204  std::vector<edm::Handle<edm::ValueMap<float> > > idhandles;
205  std::vector<pat::Electron::IdPair> ids;
206  if (addElecID_) {
207  idhandles.resize(elecIDSrcs_.size());
208  ids.resize(elecIDSrcs_.size());
209  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
210  iEvent.getByLabel(elecIDSrcs_[i].second, idhandles[i]);
211  ids[i].first = elecIDSrcs_[i].first;
212  }
213  }
214 
215 
216  // prepare the high level selection:
217  // needs beamline
218  reco::TrackBase::Point beamPoint(0,0,0);
219  reco::Vertex primaryVertex;
220  reco::BeamSpot beamSpot;
221  bool beamSpotIsValid = false;
222  bool primaryVertexIsValid = false;
223  if ( embedHighLevelSelection_ ) {
224  // Get the beamspot
225  edm::Handle<reco::BeamSpot> beamSpotHandle;
226  iEvent.getByLabel(beamLineSrc_, beamSpotHandle);
227 
228  // Get the primary vertex
230  iEvent.getByLabel( pvSrc_, pvHandle );
231 
232  // This is needed by the IPTools methods from the tracking group
233  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", trackBuilder);
234 
235  if ( ! usePV_ ) {
236  if ( beamSpotHandle.isValid() ){
237  beamSpot = *beamSpotHandle;
238  beamSpotIsValid = true;
239  } else{
240  edm::LogError("DataNotAvailable")
241  << "No beam spot available from EventSetup, not adding high level selection \n";
242  }
243 
244  double x0 = beamSpot.x0();
245  double y0 = beamSpot.y0();
246  double z0 = beamSpot.z0();
247 
248  beamPoint = reco::TrackBase::Point ( x0, y0, z0 );
249  } else {
250  if ( pvHandle.isValid() && !pvHandle->empty() ) {
251  primaryVertex = pvHandle->at(0);
252  primaryVertexIsValid = true;
253  } else {
254  edm::LogError("DataNotAvailable")
255  << "No primary vertex available from EventSetup, not adding high level selection \n";
256  }
257  }
258  }
259 
260  std::vector<Electron> * patElectrons = new std::vector<Electron>();
261 
262  if( useParticleFlow_ ) {
264  iEvent.getByLabel(pfElecSrc_, pfElectrons);
265  //-- SAK ------------------------------------------------------------------
267  if (linkToPFSource_.label().length())
268  iEvent.getByLabel(linkToPFSource_, pfForLinking);
269  //-- SAK ------------------------------------------------------------------
270  unsigned index=0;
271 
272  for( reco::PFCandidateConstIterator i = pfElectrons->begin();
273  i != pfElectrons->end(); ++i, ++index) {
274 
275  reco::PFCandidateRef pfRef(pfElectrons, index);
276  reco::PFCandidatePtr ptrToPFElectron(pfElectrons,index);
277 // reco::CandidateBaseRef pfBaseRef( pfRef );
278 
279  reco::GsfTrackRef PfTk= i->gsfTrackRef();
280 
281  bool Matched=false;
282  bool MatchedToAmbiguousGsfTrack=false;
283  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end(); ++itElectron) {
284  unsigned int idx = itElectron - electrons->begin();
285  if (Matched || MatchedToAmbiguousGsfTrack) continue;
286 
287  reco::GsfTrackRef EgTk= itElectron->gsfTrack();
288 
289  if (itElectron->gsfTrack()==i->gsfTrackRef()){
290  Matched=true;
291  }
292  else {
293  for( reco::GsfTrackRefVector::const_iterator it = itElectron->ambiguousGsfTracksBegin() ;
294  it!=itElectron->ambiguousGsfTracksEnd(); it++ ){
295  MatchedToAmbiguousGsfTrack |= (bool)(i->gsfTrackRef()==(*it));
296  }
297  }
298 
299  if (Matched || MatchedToAmbiguousGsfTrack){
300 
301  // ptr needed for finding the matched gen particle
302  reco::CandidatePtr ptrToGsfElectron(electrons,idx);
303 
304  // ref to base needed for the construction of the pat object
305  const edm::RefToBase<reco::GsfElectron>& elecsRef = electrons->refAt(idx);
306  Electron anElectron(elecsRef);
307  anElectron.setPFCandidateRef( pfRef );
308 
309  if( embedPFCandidate_ ) anElectron.embedPFCandidate();
310 
311  if ( useUserData_ ) {
312  userDataHelper_.add( anElectron, iEvent, iSetup );
313  }
314 
315 
316  // embed high level selection
317  if ( embedHighLevelSelection_ ) {
318  // get the global track
319  reco::GsfTrackRef track = PfTk;
320 
321  // Make sure the collection it points to is there
322  if ( track.isNonnull() && track.isAvailable() ) {
323 
324  reco::TransientTrack tt = trackBuilder->build(track);
325  embedHighLevel( anElectron,
326  track,
327  tt,
328  primaryVertex,
329  primaryVertexIsValid,
330  beamSpot,
331  beamSpotIsValid );
332 
333  if ( !usePV_ ) {
334  double corr_d0 = track->dxy( beamPoint );
335  anElectron.setDB( corr_d0, -1.0 );
336  } else {
337  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
338  double d0_corr = result.second.value();
339  double d0_err = result.second.error();
340  anElectron.setDB( d0_corr, d0_err );
341  }
342  }
343  }
344 
345  //Electron Id
346 
347  if (addElecID_) {
348  //STANDARD EL ID
349  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
350  ids[i].second = (*idhandles[i])[elecsRef];
351  }
352  //SPECIFIC PF ID
353  ids.push_back(std::make_pair("pf_evspi",pfRef->mva_e_pi()));
354  ids.push_back(std::make_pair("pf_evsmu",pfRef->mva_e_mu()));
355  anElectron.setElectronIDs(ids);
356  }
357 
358 // fillElectron(anElectron,elecsRef,pfBaseRef,
359 // genMatches, deposits, isolationValues);
360 
361  //COLIN small warning !
362  // we are currently choosing to take the 4-momentum of the PFCandidate;
363  // the momentum of the GsfElectron is saved though
364  // we must therefore match the GsfElectron.
365  // because of this, we should not change the source of the electron matcher
366  // to the collection of PFElectrons in the python configuration
367  // I don't know what to do with the efficiencyLoader, since I don't know
368  // what this class is for.
369  fillElectron2( anElectron,
370  ptrToPFElectron,
371  ptrToGsfElectron,
372  ptrToGsfElectron,
373  genMatches, deposits, isolationValues );
374 
375  //COLIN need to use fillElectron2 in the non-pflow case as well, and to test it.
376 
377  //-- SAK ------------------------------------------------------------------
378  if (linkToPFSource_.label().length() && anElectron.pfCandidateRef().id() != pfForLinking.id()) {
379  reco::CandidatePtr source = anElectron.pfCandidateRef()->sourceCandidatePtr(0);
380  while (source.id() != pfForLinking.id()) {
381  source = source->sourceCandidatePtr(0);
382  if (source.isNull())
383  throw cms::Exception("InputSource", "Object in "+pfElecSrc_.encode()+" does not link back to "+linkToPFSource_.encode());
384  } // end loop over inheritance chain
385  anElectron.setPFCandidateRef(reco::PFCandidateRef(pfForLinking, source.key()));
386  }
387  //-- SAK ------------------------------------------------------------------
388  patElectrons->push_back(anElectron);
389  }
390  }
391  //if( !Matched && !MatchedToAmbiguousGsfTrack) std::cout << "!!!!A pf electron could not be matched to a gsf!!!!" << std::endl;
392  }
393  }
394 
395  else{
396  for (edm::View<reco::GsfElectron>::const_iterator itElectron = electrons->begin(); itElectron != electrons->end(); ++itElectron) {
397  // construct the Electron from the ref -> save ref to original object
398  unsigned int idx = itElectron - electrons->begin();
399  edm::RefToBase<reco::GsfElectron> elecsRef = electrons->refAt(idx);
400  reco::CandidateBaseRef elecBaseRef(elecsRef);
401  Electron anElectron(elecsRef);
402 
403  // add resolution info
404 
405  // Isolation
406  if (isolator_.enabled()) {
407  isolator_.fill(*electrons, idx, isolatorTmpStorage_);
408  typedef pat::helper::MultiIsolator::IsolationValuePairs IsolationValuePairs;
409  // better to loop backwards, so the vector is resized less times
410  for (IsolationValuePairs::const_reverse_iterator it = isolatorTmpStorage_.rbegin(), ed = isolatorTmpStorage_.rend(); it != ed; ++it) {
411  anElectron.setIsolation(it->first, it->second);
412  }
413  }
414 
415  for (size_t j = 0, nd = deposits.size(); j < nd; ++j) {
416  anElectron.setIsoDeposit(isoDepositLabels_[j].first, (*deposits[j])[elecsRef]);
417  }
418 
419  // add electron ID info
420  if (addElecID_) {
421  for (size_t i = 0; i < elecIDSrcs_.size(); ++i) {
422  ids[i].second = (*idhandles[i])[elecsRef];
423  }
424  anElectron.setElectronIDs(ids);
425  }
426 
427 
428  if ( useUserData_ ) {
429  userDataHelper_.add( anElectron, iEvent, iSetup );
430  }
431 
432 
433  // embed high level selection
434  if ( embedHighLevelSelection_ ) {
435  // get the global track
436  reco::GsfTrackRef track = itElectron->gsfTrack();
437 
438  // Make sure the collection it points to is there
439  if ( track.isNonnull() && track.isAvailable() ) {
440 
441  reco::TransientTrack tt = trackBuilder->build(track);
442  embedHighLevel( anElectron,
443  track,
444  tt,
445  primaryVertex,
446  primaryVertexIsValid,
447  beamSpot,
448  beamSpotIsValid );
449 
450 
451  if ( !usePV_ ) {
452  double corr_d0 = track->dxy( beamPoint );
453  anElectron.setDB( corr_d0, -1.0 );
454  } else {
455 
456  std::pair<bool,Measurement1D> result = IPTools::absoluteTransverseImpactParameter(tt, primaryVertex);
457  double d0_corr = result.second.value();
458  double d0_err = result.second.error();
459  anElectron.setDB( d0_corr, d0_err );
460  }
461  }
462  }
463 
464  // add sel to selected
465  fillElectron( anElectron, elecsRef,elecBaseRef,
466  genMatches, deposits, isolationValues);
467  patElectrons->push_back(anElectron);
468  }
469  }
470 
471  // sort electrons in pt
472  std::sort(patElectrons->begin(), patElectrons->end(), pTComparator_);
473 
474  // add the electrons to the event output
475  std::auto_ptr<std::vector<Electron> > ptr(patElectrons);
476  iEvent.put(ptr);
477 
478  // clean up
480 
481 }
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
double z0() const
z coordinate
Definition: BeamSpot.h:69
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
ProductID id() const
Definition: HandleBase.cc:15
void embedHighLevel(pat::Electron &anElectron, reco::GsfTrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
void fillElectron(Electron &aElectron, const ElectronBaseRef &electronRef, const reco::CandidateBaseRef &baseRef, const GenAssociations &genMatches, const IsoDepositMaps &deposits, const IsolationValueMaps &isolationValues) const
common electron filling, for both the standard and PF2PAT case
bool isAvailable() const
Definition: Ref.h:275
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
bool isRealData() const
Definition: EventBase.h:60
std::string encode() const
Definition: InputTag.cc:72
std::vector< edm::InputTag > genMatchSrc_
bool enabled() const
&#39;true&#39; if this there is at least one efficiency configured
U second(std::pair< T, U > const &p)
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:50
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:249
GreaterByPt< Electron > pTComparator_
pat::helper::MultiIsolator isolator_
std::vector< edm::Handle< edm::Association< reco::GenParticleCollection > > > GenAssociations
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:169
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
math::XYZPoint Point
point in the space
Definition: TrackBase.h:76
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
bool embedHighLevelSelection_
embed high level selection variables?
bool first
Definition: L1TdeRCT.cc:79
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
key_type key() const
Definition: Ptr.h:174
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
pat::helper::EfficiencyLoader efficiencyLoader_
const T & get() const
Definition: EventSetup.h:55
pat::PATUserDataHelper< pat::Electron > userDataHelper_
bool useParticleFlow_
pflow specific
Analysis-level electron class.
Definition: Electron.h:50
std::pair< bool, Measurement1D > absoluteTransverseImpactParameter(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:43
std::string const & label() const
Definition: InputTag.h:25
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
bool isNull() const
Checks for null.
Definition: Ptr.h:153
IsolationLabels isolationValueLabels_
double y0() const
y coordinate
Definition: BeamSpot.h:67
pat::helper::KinResolutionsLoader resolutionLoader_
pat::helper::MultiIsolator::IsolationValuePairs isolatorTmpStorage_
void newEvent(const edm::Event &event, const edm::EventSetup &setup) const
To be called for each new event, reads in the EventSetup object.
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
std::vector< NameTag > elecIDSrcs_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82
double x0() const
x coordinate
Definition: BeamSpot.h:65
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps
void PATElectronProducer::readIsolationLabels ( const edm::ParameterSet iConfig,
const char *  psetName,
IsolationLabels labels 
)
private

fill the labels vector from the contents of the parameter set, for the isodeposit or isolation values embedding

Definition at line 744 of file PATElectronProducer.cc.

References pat::EcalIso, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), pat::HcalIso, combine::key, pat::PfAllParticleIso, pat::PfChargedHadronIso, pat::PfGammaIso, pat::PfNeutralHadronIso, pat::TrackIso, and pat::UserBaseIso.

Referenced by PATElectronProducer().

746  {
747 
748  labels.clear();
749 
750  if (iConfig.exists( psetName )) {
751  edm::ParameterSet depconf
752  = iConfig.getParameter<edm::ParameterSet>(psetName);
753 
754  if (depconf.exists("tracker")) labels.push_back(std::make_pair(pat::TrackIso, depconf.getParameter<edm::InputTag>("tracker")));
755  if (depconf.exists("ecal")) labels.push_back(std::make_pair(pat::EcalIso, depconf.getParameter<edm::InputTag>("ecal")));
756  if (depconf.exists("hcal")) labels.push_back(std::make_pair(pat::HcalIso, depconf.getParameter<edm::InputTag>("hcal")));
757  if (depconf.exists("pfAllParticles")) {
758  labels.push_back(std::make_pair(pat::PfAllParticleIso, depconf.getParameter<edm::InputTag>("pfAllParticles")));
759  }
760  if (depconf.exists("pfChargedHadrons")) {
761  labels.push_back(std::make_pair(pat::PfChargedHadronIso, depconf.getParameter<edm::InputTag>("pfChargedHadrons")));
762  }
763  if (depconf.exists("pfNeutralHadrons")) {
764  labels.push_back(std::make_pair(pat::PfNeutralHadronIso, depconf.getParameter<edm::InputTag>("pfNeutralHadrons")));
765  }
766  if (depconf.exists("pfPhotons")) {
767  labels.push_back(std::make_pair(pat::PfGammaIso, depconf.getParameter<edm::InputTag>("pfPhotons")));
768  }
769  if (depconf.exists("user")) {
770  std::vector<edm::InputTag> userdeps = depconf.getParameter<std::vector<edm::InputTag> >("user");
771  std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
772  int key = UserBaseIso;
773  for ( ; it != ed; ++it, ++key) {
774  labels.push_back(std::make_pair(IsolationKeys(key), *it));
775  }
776  }
777  }
778 
779 
780 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
tuple labels
Definition: L1TDQM_cfg.py:62
list key
Definition: combine.py:13

Member Data Documentation

bool pat::PATElectronProducer::addEfficiencies_
private

Definition at line 143 of file PATElectronProducer.h.

Referenced by PATElectronProducer().

bool pat::PATElectronProducer::addElecID_
private

Definition at line 131 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

bool pat::PATElectronProducer::addGenMatch_
private

Definition at line 74 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), PATElectronProducer(), and produce().

bool pat::PATElectronProducer::addResolutions_
private

Definition at line 146 of file PATElectronProducer.h.

Referenced by PATElectronProducer().

edm::InputTag pat::PATElectronProducer::beamLineSrc_
private

Definition at line 86 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

pat::helper::EfficiencyLoader pat::PATElectronProducer::efficiencyLoader_
private

Definition at line 144 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), PATElectronProducer(), and produce().

std::vector<NameTag> pat::PATElectronProducer::elecIDSrcs_
private

Definition at line 133 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

edm::InputTag pat::PATElectronProducer::electronSrc_
private

Definition at line 69 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

bool pat::PATElectronProducer::embedGenMatch_
private

Definition at line 75 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), PATElectronProducer(), and produce().

bool pat::PATElectronProducer::embedGsfElectronCore_
private

Definition at line 70 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), and PATElectronProducer().

bool pat::PATElectronProducer::embedGsfTrack_
private

Definition at line 71 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), and PATElectronProducer().

bool pat::PATElectronProducer::embedHighLevelSelection_
private

embed high level selection variables?

Definition at line 85 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

bool pat::PATElectronProducer::embedPFCandidate_
private

Definition at line 82 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

bool pat::PATElectronProducer::embedSuperCluster_
private

Definition at line 72 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), and PATElectronProducer().

bool pat::PATElectronProducer::embedTrack_
private

Definition at line 73 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), and PATElectronProducer().

std::vector<edm::InputTag> pat::PATElectronProducer::genMatchSrc_
private

Definition at line 76 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

IsolationLabels pat::PATElectronProducer::isoDepositLabels_
private

Definition at line 140 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), PATElectronProducer(), and produce().

IsolationLabels pat::PATElectronProducer::isolationValueLabels_
private

Definition at line 141 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), PATElectronProducer(), and produce().

pat::helper::MultiIsolator pat::PATElectronProducer::isolator_
private

Definition at line 138 of file PATElectronProducer.h.

Referenced by produce().

pat::helper::MultiIsolator::IsolationValuePairs pat::PATElectronProducer::isolatorTmpStorage_
private

Definition at line 139 of file PATElectronProducer.h.

Referenced by produce().

edm::InputTag pat::PATElectronProducer::linkToPFSource_
private

Definition at line 80 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

edm::InputTag pat::PATElectronProducer::pfElecSrc_
private

Definition at line 81 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

GreaterByPt<Electron> pat::PATElectronProducer::pTComparator_
private

Definition at line 136 of file PATElectronProducer.h.

Referenced by produce().

edm::InputTag pat::PATElectronProducer::pvSrc_
private

Definition at line 88 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

pat::helper::KinResolutionsLoader pat::PATElectronProducer::resolutionLoader_
private

Definition at line 147 of file PATElectronProducer.h.

Referenced by fillElectron(), fillElectron2(), PATElectronProducer(), and produce().

bool pat::PATElectronProducer::useParticleFlow_
private

pflow specific

Definition at line 79 of file PATElectronProducer.h.

Referenced by fillElectron(), PATElectronProducer(), and produce().

bool pat::PATElectronProducer::usePV_
private

Definition at line 87 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

pat::PATUserDataHelper<pat::Electron> pat::PATElectronProducer::userDataHelper_
private

Definition at line 150 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().

bool pat::PATElectronProducer::useUserData_
private

Definition at line 149 of file PATElectronProducer.h.

Referenced by PATElectronProducer(), and produce().