46 useUserData_(iConfig.exists(
"userData"))
92 "PATElectronProducer: you can't specify both 'electronIDSource' and 'electronIDSources'\n";
96 for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
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 " <<
156 produces<std::vector<Electron> >();
186 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
204 std::vector<edm::Handle<edm::ValueMap<float> > > idhandles;
205 std::vector<pat::Electron::IdPair> ids;
221 bool beamSpotIsValid =
false;
222 bool primaryVertexIsValid =
false;
236 if ( beamSpotHandle.
isValid() ){
237 beamSpot = *beamSpotHandle;
238 beamSpotIsValid =
true;
241 <<
"No beam spot available from EventSetup, not adding high level selection \n";
244 double x0 = beamSpot.
x0();
245 double y0 = beamSpot.
y0();
246 double z0 = beamSpot.
z0();
250 if ( pvHandle.
isValid() && !pvHandle->empty() ) {
251 primaryVertex = pvHandle->at(0);
252 primaryVertexIsValid =
true;
255 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
260 std::vector<Electron> *
patElectrons =
new std::vector<Electron>();
273 i != pfElectrons->end(); ++
i, ++
index) {
282 bool MatchedToAmbiguousGsfTrack=
false;
284 unsigned int idx = itElectron - electrons->begin();
285 if (Matched || MatchedToAmbiguousGsfTrack)
continue;
289 if (itElectron->gsfTrack()==
i->gsfTrackRef()){
294 it!=itElectron->ambiguousGsfTracksEnd(); it++ ){
295 MatchedToAmbiguousGsfTrack |= (bool)(
i->gsfTrackRef()==(*it));
299 if (Matched || MatchedToAmbiguousGsfTrack){
329 primaryVertexIsValid,
334 double corr_d0 = track->dxy( beamPoint );
335 anElectron.
setDB( corr_d0, -1.0 );
338 double d0_corr = result.second.value();
339 double d0_err = result.second.error();
340 anElectron.
setDB( d0_corr, d0_err );
350 ids[
i].second = (*idhandles[
i])[elecsRef];
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()));
373 genMatches, deposits, isolationValues );
380 while (source.
id() != pfForLinking.
id()) {
381 source = source->sourceCandidatePtr(0);
388 patElectrons->push_back(anElectron);
398 unsigned int idx = itElectron - electrons->begin();
415 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
422 ids[
i].second = (*idhandles[
i])[elecsRef];
446 primaryVertexIsValid,
452 double corr_d0 = track->dxy( beamPoint );
453 anElectron.
setDB( corr_d0, -1.0 );
457 double d0_corr = result.second.value();
458 double d0_err = result.second.error();
459 anElectron.
setDB( d0_corr, d0_err );
466 genMatches, deposits, isolationValues);
467 patElectrons->push_back(anElectron);
475 std::auto_ptr<std::vector<Electron> > ptr(patElectrons);
515 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
536 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
540 assert(!pfcandref.
isNull());
543 (*deposits[
j])[source]);
547 (*deposits[
j])[elecRef]);
550 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
554 (*isolationValues[
j])[source]);
558 (*isolationValues[
j])[elecRef]);
589 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
605 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
611 (*deposits[
j])[candPtrForGenMatch]);
613 else if (deposits[
j]->
contains(candPtrForIsolation.
id())) {
615 (*deposits[
j])[candPtrForIsolation]);
619 (*deposits[
j])[candPtrForIsolation->sourceCandidatePtr(0)]);
623 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
628 (*isolationValues[
j])[candPtrForGenMatch]);
630 else if (isolationValues[
j]->
contains(candPtrForIsolation.
id())) {
632 (*isolationValues[
j])[candPtrForIsolation]);
636 (*isolationValues[
j])[candPtrForIsolation->sourceCandidatePtr(0)]);
647 iDesc.
setComment(
"PAT electron producer module");
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");
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");
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;
670 )->
setComment(
"input with MC match information");
673 iDesc.
add<
bool>(
"addElectronID",
true)->setComment(
"add electron ID variables");
678 )->
setComment(
"input with electron ID variables");
690 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
702 isolationValuesPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
703 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
708 iDesc.
add(
"efficiencies", efficienciesPSet);
709 iDesc.
add<
bool>(
"addEfficiencies",
false);
717 iDesc.
add<
bool>(
"addElectronShapes",
true);
723 iDesc.
add(
"userIsolation", isolationPSet);
728 iDesc.
add<
bool>(
"embedHighLevelSelection",
true)->setComment(
"embed high level selection");
732 )->
setComment(
"input with high level selection");
734 )->
setComment(
"input with high level selection");
736 )->
setComment(
"input with high level selection, use primary vertex (true) or beam line (false)");
738 descriptions.
add(
"PATElectronProducer", iDesc);
745 const char* psetName,
750 if (iConfig.
exists( psetName )) {
757 if (depconf.
exists(
"pfAllParticles")) {
760 if (depconf.
exists(
"pfChargedHadrons")) {
763 if (depconf.
exists(
"pfNeutralHadrons")) {
766 if (depconf.
exists(
"pfPhotons")) {
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();
773 for ( ; it != ed; ++it, ++
key) {
789 bool primaryVertexIsValid,
797 std::pair<bool,Measurement1D>
result =
803 double d0_corr = result.second.value();
804 double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
815 d0_corr = result.second.value();
816 d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
831 d0_corr = result.second.value();
832 d0_err = beamspotIsValid ? result.second.error() : -1.0;
842 d0_corr = result.second.value();
843 d0_err = beamspotIsValid ? result.second.error() : -1.0;
bool enabled() const
'true' if this there is at least one efficiency configured
T getParameter(std::string const &) const
bool embedGsfElectronCore_
void setComment(std::string const &value)
double z0() const
z coordinate
Assists in assimilating all pat::UserData into pat objects.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
void embedTrack()
method to store the electron's Track internally
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
void setIsolation(IsolationKeys key, float value)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
edm::InputTag electronSrc_
void embedGsfElectronCore()
method to store the electron's core internally
bool contains(EventRange const &lh, EventID const &rh)
void setElectronIDs(const std::vector< IdPair > &ids)
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
const LorentzVector & p4(P4Kind kind) const
edm::InputTag linkToPFSource_
void embedSuperCluster()
method to store the electron's SuperCluster internally
void setAllowAnything()
allow any parameter label/value pairs
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
#define DEFINE_FWK_MODULE(type)
void setDB(double dB, double edB, IpType type=None)
IsolationLabels isoDepositLabels_
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 exists(std::string const ¶meterName) const
checks if a parameter exists
void setPFCandidateRef(const reco::PFCandidateRef &ref)
add a reference to the source IsolatedPFCandidate
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
IsolationKeys
Enum defining isolation keys.
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
void setEcalDrivenMomentum(const Candidate::LorentzVector &mom)
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
std::vector< edm::InputTag > genMatchSrc_
bool enabled() const
'true' 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.
static void fillDescription(edm::ParameterSetDescription &iDesc)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
U second(std::pair< T, U > const &p)
bool enabled() const
True if it has a non null configuration.
bool isNonnull() const
Checks for non-null.
void setComment(std::string const &value)
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)
Produces pat::Electron's.
bool isNull() const
Checks for null.
PATElectronProducer(const edm::ParameterSet &iConfig)
edm::InputTag beamLineSrc_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
ProductID id() const
Accessor for product ID.
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates
math::XYZPoint Point
point in the space
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool embedHighLevelSelection_
embed high level selection variables?
std::pair< std::string, edm::InputTag > NameTag
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void embedGsfTrack()
method to store the electron's GsfTrack internally
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 addGenParticleRef(const reco::GenParticleRef &ref)
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
pat::helper::EfficiencyLoader efficiencyLoader_
pat::PATUserDataHelper< pat::Electron > userDataHelper_
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
Analysis-level electron class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
bool isNull() const
Checks for null.
std::vector< IsolationLabel > IsolationLabels
IsolationLabels isolationValueLabels_
double y0() const
y coordinate
pat::helper::KinResolutionsLoader resolutionLoader_
const Point & position() const
position
void readIsolationLabels(const edm::ParameterSet &iConfig, const char *psetName, IsolationLabels &labels)
ProductID id() const
Accessor for product ID.
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.
static const HistoName names[]
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
Global3DVector GlobalVector
std::vector< NameTag > elecIDSrcs_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
double x0() const
x coordinate
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps