51 useUserData_(iConfig.exists(
"userData"))
101 throw cms::Exception(
"Configuration") <<
"PATElectronProducer: you can't specify both 'electronIDSource' and 'electronIDSources'\n";
106 for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
113 "PATElectronProducer: id addElectronID is true, you must specify either:\n" <<
114 "\tInputTag electronIDSource = <someTag>\n" <<
"or\n" <<
115 "\tPSet electronIDSources = { \n" <<
116 "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
163 produces<std::vector<Electron> >();
189 edm::InputTag reducedEBRecHitCollection(
string(
"reducedEcalRecHitsEB"));
190 edm::InputTag reducedEERecHitCollection(
string(
"reducedEcalRecHitsEE"));
196 iEvent.
getByLabel(
"allConversions", hConversions);
208 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
231 std::vector<edm::Handle<edm::ValueMap<float> > > idhandles;
232 std::vector<pat::Electron::IdPair> ids;
248 bool beamSpotIsValid =
false;
249 bool primaryVertexIsValid =
false;
265 if ( beamSpotHandle.
isValid() ){
266 beamSpot = *beamSpotHandle;
267 beamSpotIsValid =
true;
270 <<
"No beam spot available from EventSetup, not adding high level selection \n";
273 double x0 = beamSpot.
x0();
274 double y0 = beamSpot.
y0();
275 double z0 = beamSpot.
z0();
279 if ( pvHandle.
isValid() && !pvHandle->empty() ) {
280 primaryVertex = pvHandle->at(0);
281 primaryVertexIsValid =
true;
284 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
289 std::vector<Electron> *
patElectrons =
new std::vector<Electron>();
297 i != pfElectrons->end(); ++
i, ++
index) {
306 bool MatchedToAmbiguousGsfTrack=
false;
308 unsigned int idx = itElectron - electrons->begin();
309 if (Matched || MatchedToAmbiguousGsfTrack)
continue;
313 if (itElectron->gsfTrack()==
i->gsfTrackRef()){
318 it!=itElectron->ambiguousGsfTracksEnd(); it++ ){
319 MatchedToAmbiguousGsfTrack |= (bool)(
i->gsfTrackRef()==(*it));
323 if (Matched || MatchedToAmbiguousGsfTrack){
357 primaryVertexIsValid,
362 ip3d = ip3dpv.second.value();
365 double corr_d0 = track->dxy( beamPoint );
366 anElectron.
setDB( corr_d0, -1.0 );
369 double d0_corr = result.second.value();
370 double d0_err = result.second.error();
371 anElectron.
setDB( d0_corr, d0_err );
381 ids[
i].second = (*idhandles[
i])[elecsRef];
384 ids.push_back(std::make_pair(
"pf_evspi",pfRef->mva_e_pi()));
385 ids.push_back(std::make_pair(
"pf_evsmu",pfRef->mva_e_mu()));
390 double r9 = lazyTools.
e3x3( *( itElectron->superCluster()->seed())) / itElectron->superCluster()->rawEnergy() ;
391 double sigmaIphiIphi;
392 double sigmaIetaIphi;
393 std::vector<float> vCov = lazyTools.
localCovariances(*( itElectron->superCluster()->seed()));
395 else sigmaIphiIphi = 0;
396 sigmaIetaIphi = vCov[1];
400 bool barrel = itElectron->isEB();
401 DetId seed = lazyTools.
getMaximum(*(itElectron->superCluster()->seed())).first;
408 std::vector<DetId> cellsIn5x5;
409 for ( ; itscl!= itsclE ; ++ itscl) {
414 cellsIn5x5.insert(cellsIn5x5.end(),cellsToAdd.begin(), cellsToAdd.end());
419 unsigned nCellsIn5x5 = cellsIn5x5.size() ;
421 for(
unsigned i=0;
i< nCellsIn5x5 ; ++
i ) {
422 std::vector<DetId>::const_iterator itcheck =
find(selectedCells.begin(), selectedCells.end(),cellsIn5x5[
i]);
423 if (itcheck == selectedCells.end())
424 selectedCells.push_back(cellsIn5x5[
i]);
429 std::vector< std::pair<DetId, float> >::const_iterator it=itElectron->superCluster()->hitsAndFractions().begin();
430 std::vector< std::pair<DetId, float> >::const_iterator itend=itElectron->superCluster()->hitsAndFractions().end();
431 for( ; it!=itend ; ++it) {
434 std::vector<DetId>::const_iterator itcheck =
find(selectedCells.begin(),selectedCells.end(),id);
435 if ( itcheck == selectedCells.end()) {
436 selectedCells.push_back(
id);
450 unsigned nSelectedCells = selectedCells.size();
451 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
453 if ( it != recHits->
end() ) {
457 selectedRecHits.
sort();
461 bool passconversionveto =
false;
467 passconversionveto = itElectron->gsfTrack()->trackerExpectedHitsInner().numberOfLostHits() < 1;
488 genMatches, deposits, isolationValues );
492 patElectrons->push_back(anElectron);
510 unsigned int idx = itElectron - electrons->begin();
518 if ( pfCandsPresent ) {
523 ie != pfElectrons->end(); ++ie, ++
index) {
526 if( trkRef == pfTrkRef ) {
534 else if( valMapPresent ) {
556 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
563 ids[
i].second = (*idhandles[
i])[elecsRef];
589 primaryVertexIsValid,
594 ip3d = ip3dpv.second.value();
597 double corr_d0 = track->dxy( beamPoint );
598 anElectron.
setDB( corr_d0, -1.0 );
601 double d0_corr = result.second.value();
602 double d0_err = result.second.error();
603 anElectron.
setDB( d0_corr, d0_err );
609 double r9 = lazyTools.
e3x3( *( itElectron->superCluster()->seed())) / itElectron->superCluster()->rawEnergy() ;
610 double sigmaIphiIphi;
611 double sigmaIetaIphi;
612 std::vector<float> vCov = lazyTools.
localCovariances(*( itElectron->superCluster()->seed()));
614 else sigmaIphiIphi = 0;
615 sigmaIetaIphi = vCov[1];
619 bool barrel= itElectron->isEB();
621 DetId seed=lazyTools.
getMaximum(*(itElectron->superCluster()->seed())).first;
629 std::vector<DetId> cellsIn5x5;
630 for ( ; itscl!= itsclE ; ++ itscl) {
635 cellsIn5x5.insert(cellsIn5x5.end(),cellsToAdd.begin(), cellsToAdd.end());
639 unsigned nCellsIn5x5 = cellsIn5x5.size() ;
641 for(
unsigned i=0;
i< nCellsIn5x5 ; ++
i ) {
642 std::vector<DetId>::const_iterator itcheck =
find(selectedCells.begin(), selectedCells.end(),cellsIn5x5[
i]);
643 if (itcheck == selectedCells.end())
644 selectedCells.push_back(cellsIn5x5[
i]);
648 std::vector< std::pair<DetId, float> >::const_iterator it=itElectron->superCluster()->hitsAndFractions().begin();
649 std::vector< std::pair<DetId, float> >::const_iterator itend=itElectron->superCluster()->hitsAndFractions().end();
650 for( ; it!=itend ; ++it) {
653 std::vector<DetId>::const_iterator itcheck =
find(selectedCells.begin(),selectedCells.end(),id);
654 if ( itcheck == selectedCells.end()) {
655 selectedCells.push_back(
id);
669 unsigned nSelectedCells = selectedCells.size();
670 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
672 if ( it != recHits->
end() ) {
676 selectedRecHits.
sort();
680 bool passconversionveto =
false;
686 passconversionveto = itElectron->gsfTrack()->trackerExpectedHitsInner().numberOfLostHits() < 1;
692 genMatches, deposits, pfId, isolationValues, isolationValuesNoPFId);
693 patElectrons->push_back(anElectron);
701 std::auto_ptr<std::vector<Electron> > ptr(patElectrons);
749 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
770 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
774 assert(!pfcandref.
isNull());
777 (*deposits[
j])[source]);
781 (*deposits[
j])[elecRef]);
784 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
788 (*isolationValues[
j])[source]);
797 for (
size_t j = 0;
j<isolationValuesNoPFId.size(); ++
j) {
835 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
851 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
857 (*deposits[
j])[candPtrForGenMatch]);
859 else if (deposits[
j]->
contains(candPtrForIsolation.
id())) {
861 (*deposits[
j])[candPtrForIsolation]);
865 (*deposits[
j])[candPtrForIsolation->sourceCandidatePtr(0)]);
869 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
873 isolationValues[
j]->
contains(candPtrForGenMatch.
id())) {
875 (*isolationValues[
j])[candPtrForGenMatch]);
877 else if (isolationValues[
j]->
contains(candPtrForIsolation.
id())) {
879 (*isolationValues[
j])[candPtrForIsolation]);
883 (*isolationValues[
j])[candPtrForIsolation->sourceCandidatePtr(0)]);
893 iDesc.
setComment(
"PAT electron producer module");
900 iDesc.
add<
bool>(
"embedGsfElectronCore",
true)->setComment(
"embed external gsf electron core");
901 iDesc.
add<
bool>(
"embedGsfTrack",
true)->setComment(
"embed external gsf track");
902 iDesc.
add<
bool>(
"embedSuperCluster",
true)->setComment(
"embed external super cluster");
903 iDesc.
add<
bool>(
"embedPflowSuperCluster",
true)->setComment(
"embed external super cluster");
904 iDesc.
add<
bool>(
"embedSeedCluster",
true)->setComment(
"embed external seed cluster");
905 iDesc.
add<
bool>(
"embedBasicClusters",
true)->setComment(
"embed external basic clusters");
906 iDesc.
add<
bool>(
"embedPreshowerClusters",
true)->setComment(
"embed external preshower clusters");
907 iDesc.
add<
bool>(
"embedPflowBasicClusters",
true)->setComment(
"embed external pflow basic clusters");
908 iDesc.
add<
bool>(
"embedPflowPreshowerClusters",
true)->setComment(
"embed external pflow preshower clusters");
909 iDesc.
add<
bool>(
"embedTrack",
false)->setComment(
"embed external track");
910 iDesc.
add<
bool>(
"embedRecHits",
true)->setComment(
"embed external RecHits");
914 iDesc.
add<
bool>(
"useParticleFlow",
false)->setComment(
"whether to use particle flow or not");
915 iDesc.
add<
bool>(
"embedPFCandidate",
false)->setComment(
"embed external particle flow object");
918 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
919 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
920 std::vector<edm::InputTag> emptySourceVector;
923 )->
setComment(
"input with MC match information");
926 iDesc.
add<
bool>(
"addElectronID",
true)->setComment(
"add electron ID variables");
931 )->
setComment(
"input with electron ID variables");
945 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
959 isolationValuesPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
960 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
973 isolationValuesNoPFIdPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
974 iDesc.
addOptional(
"isolationValuesNoPFId", isolationValuesNoPFIdPSet);
979 iDesc.
add(
"efficiencies", efficienciesPSet);
980 iDesc.
add<
bool>(
"addEfficiencies",
false);
988 iDesc.
add<
bool>(
"addElectronShapes",
true);
994 iDesc.
add(
"userIsolation", isolationPSet);
999 iDesc.
add<
bool>(
"embedHighLevelSelection",
true)->setComment(
"embed high level selection");
1003 )->
setComment(
"input with high level selection");
1005 )->
setComment(
"input with high level selection");
1007 )->
setComment(
"input with high level selection, use primary vertex (true) or beam line (false)");
1009 descriptions.
add(
"PATElectronProducer", iDesc);
1016 const char* psetName,
1021 if (iConfig.
exists( psetName )) {
1028 if (depconf.
exists(
"pfAllParticles")) {
1031 if (depconf.
exists(
"pfChargedHadrons")) {
1034 if (depconf.
exists(
"pfChargedAll")) {
1037 if (depconf.
exists(
"pfPUChargedHadrons")) {
1040 if (depconf.
exists(
"pfNeutralHadrons")) {
1043 if (depconf.
exists(
"pfPhotons")) {
1046 if (depconf.
exists(
"user")) {
1047 std::vector<edm::InputTag> userdeps = depconf.
getParameter<std::vector<edm::InputTag> >(
"user");
1048 std::vector<edm::InputTag>::const_iterator it = userdeps.begin(), ed = userdeps.end();
1050 for ( ; it != ed; ++it, ++
key) {
1066 bool primaryVertexIsValid,
1068 bool beamspotIsValid
1074 std::pair<bool,Measurement1D>
result =
1080 double d0_corr = result.second.value();
1081 double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1092 d0_corr = result.second.value();
1093 d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1108 d0_corr = result.second.value();
1109 d0_err = beamspotIsValid ? result.second.error() : -1.0;
1119 d0_corr = result.second.value();
1120 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
void embedSeedCluster()
method to store the electron's seedcluster 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)
Store multiple electron ID values, discarding existing ones. The first one in the list becomes the 'd...
void embedPflowBasicClusters()
method to store the electron's pflow basic clusters
static const HistoName names[]
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
const LorentzVector & p4(P4Kind kind) const
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)
Set impact parameter of a certain type and its uncertainty.
IsolationLabels isoDepositLabels_
edm::InputTag pfCandidateMap_
void embedHighLevel(pat::Electron &anElectron, reco::GsfTrackRef track, reco::TransientTrack &tt, reco::Vertex &primaryVertex, bool primaryVertexIsValid, reco::BeamSpot &beamspot, bool beamspotIsValid)
std::vector< EcalRecHit >::const_iterator const_iterator
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
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
void push_back(T const &t)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
void setPassConversionVeto(bool flag)
IsolationKeys
Enum defining isolation keys.
PFCandidateCollection::const_iterator PFCandidateConstIterator
iterator
void setEcalDrivenMomentum(const Candidate::LorentzVector &mom)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void setResolutions(pat::PATObject< T > &obj) const
Sets the efficiencies for this object, using the reference to the original objects.
void setMvaVariables(double r9, double sigmaIphiIphi, double sigmaIetaIphi, double ip3d)
set missing mva input variables
void embedPreshowerClusters()
method to store the electron's preshower clusters
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)
void embedBasicClusters()
method to store the electron's basic clusters
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
bool isNonnull() const
Checks for non-null.
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.
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
ProductID id() const
Accessor for product ID.
edm::InputTag reducedEndcapRecHitCollection_
edm::InputTag reducedBarrelRecHitCollection_
mva input variables
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
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?
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::pair< std::string, edm::InputTag > NameTag
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
void embedGsfTrack()
method to store the electron's GsfTrack internally
const_iterator end() const
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)
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
static void fillDescription(edm::ParameterSetDescription &iDesc)
Method for documentation and validation of PSet.
bool embedPflowSuperCluster_
pat::helper::EfficiencyLoader efficiencyLoader_
void setIsPF(bool hasPFCandidate)
bool embedPreshowerClusters_
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
pat::PATUserDataHelper< pat::Electron > userDataHelper_
void embedPflowSuperCluster()
method to store the electron's PflowSuperCluster internally
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.
const CaloTopology * ecalTopology_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
IsolationLabels isolationValueLabelsNoPFId_
T const * product() const
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
iterator find(key_type k)
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)
bool embedPflowBasicClusters_
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.
bool embedPflowPreshowerClusters_
void embedPflowPreshowerClusters()
method to store the electron's pflow preshower clusters
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