51 isolator_(iConfig.exists(
"userIsolation") ? iConfig.getParameter<edm::
ParameterSet>(
"userIsolation") : edm::
ParameterSet(), consumesCollector(),
false) ,
52 useUserData_(iConfig.exists(
"userData"))
96 addResolutions_ = iConfig.getParameter<
bool>(
"addResolutions" );
97 if (addResolutions_) {
101 addElecID_ = iConfig.getParameter<
bool>(
"addElectronID" );
105 elecIDSrcs_.push_back(NameTag(
"", iConfig.getParameter<
edm::InputTag>(
"electronIDSource")));
110 if (!elecIDSrcs_.empty()){
111 throw cms::Exception(
"Configuration") <<
"PATElectronProducer: you can't specify both 'electronIDSource' and 'electronIDSources'\n";
116 for (std::vector<std::string>::const_iterator it = names.begin(), ed = names.end(); it != ed; ++it) {
121 if (elecIDSrcs_.empty()){
123 "PATElectronProducer: id addElectronID is true, you must specify either:\n" <<
124 "\tInputTag electronIDSource = <someTag>\n" <<
"or\n" <<
125 "\tPSet electronIDSources = { \n" <<
126 "\t\tInputTag <someName> = <someTag> // as many as you want \n " <<
130 elecIDTokens_ =
edm::vector_transform(elecIDSrcs_, [
this](NameTag
const &
tag){
return mayConsume<edm::ValueMap<float> >(tag.second);});
153 readIsolationLabels(iConfig,
"isoDeposits", isoDepositLabels_, isoDepositTokens_);
155 readIsolationLabels(iConfig,
"isolationValues", isolationValueLabels_, isolationValueTokens_);
157 readIsolationLabels(iConfig,
"isolationValuesNoPFId", isolationValueLabelsNoPFId_, isolationValueNoPFIdTokens_);
159 addEfficiencies_ = iConfig.getParameter<
bool>(
"addEfficiencies");
160 if (addEfficiencies_) {
164 if ( useUserData_ ) {
168 embedHighLevelSelection_ = iConfig.getParameter<
bool>(
"embedHighLevelSelection");
169 beamLineToken_ = consumes<reco::BeamSpot>(iConfig.getParameter<
edm::InputTag>(
"beamLineSrc"));
170 if ( embedHighLevelSelection_ ) {
171 pvToken_ = consumes<std::vector<reco::Vertex> >(iConfig.getParameter<
edm::InputTag>(
"pvSrc"));
174 produces<std::vector<Electron> >();
178 PATElectronProducer::~PATElectronProducer()
200 edm::InputTag reducedEBRecHitCollection(
string(
"reducedEcalRecHitsEB"));
201 edm::InputTag reducedEERecHitCollection(
string(
"reducedEcalRecHitsEE"));
242 std::vector<edm::Handle<edm::ValueMap<float> > > idhandles;
243 std::vector<pat::Electron::IdPair> ids;
259 bool beamSpotIsValid =
false;
260 bool primaryVertexIsValid =
false;
274 if ( pvHandle.
isValid() && !pvHandle->empty() ) {
275 primaryVertex = pvHandle->at(0);
276 primaryVertexIsValid =
true;
279 <<
"No primary vertex available from EventSetup, not adding high level selection \n";
283 std::vector<Electron> *
patElectrons =
new std::vector<Electron>();
291 i != pfElectrons->end(); ++
i, ++
index) {
300 bool MatchedToAmbiguousGsfTrack=
false;
302 unsigned int idx = itElectron - electrons->begin();
303 if (Matched || MatchedToAmbiguousGsfTrack)
continue;
307 if (itElectron->gsfTrack()==
i->gsfTrackRef()){
312 it!=itElectron->ambiguousGsfTracksEnd(); it++ ){
313 MatchedToAmbiguousGsfTrack |= (bool)(
i->gsfTrackRef()==(*it));
317 if (Matched || MatchedToAmbiguousGsfTrack){
351 primaryVertexIsValid,
356 ip3d = ip3dpv.second.value();
365 ids[
i].second = (*idhandles[
i])[elecsRef];
368 ids.push_back(std::make_pair(
"pf_evspi",pfRef->mva_e_pi()));
369 ids.push_back(std::make_pair(
"pf_evsmu",pfRef->mva_e_mu()));
374 std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
391 std::vector<DetId> selectedCells;
392 bool barrel = itElectron->isEB();
395 for (
reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin(); clusIt!=itElectron->superCluster()->clustersEnd(); ++clusIt) {
397 DetId seed = lazyTools.getMaximum(**clusIt).first;
401 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
404 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
405 selectedCells.push_back(
hit.first);
411 for (
reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin(); clusIt!=itElectron->parentSuperCluster()->clustersEnd(); ++clusIt) {
413 DetId seed = lazyTools.getMaximum(**clusIt).first;
417 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
420 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
421 selectedCells.push_back(
hit.first);
427 std::sort(selectedCells.begin(),selectedCells.end());
428 std::unique(selectedCells.begin(),selectedCells.end());
442 unsigned nSelectedCells = selectedCells.
size();
443 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
445 if ( it != recHits->
end() ) {
449 selectedRecHits.
sort();
453 bool passconversionveto =
false;
480 genMatches, deposits, isolationValues );
484 patElectrons->push_back(anElectron);
502 unsigned int idx = itElectron - electrons->begin();
510 if ( pfCandsPresent ) {
515 ie != pfElectrons->end(); ++ie, ++
index) {
518 if( trkRef == pfTrkRef ) {
526 else if( valMapPresent ) {
548 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
555 ids[
i].second = (*idhandles[
i])[elecsRef];
581 primaryVertexIsValid,
586 ip3d = ip3dpv.second.value();
592 std::vector<float> vCov = lazyTools.localCovariances(*( itElectron->superCluster()->seed()));
609 std::vector<DetId> selectedCells;
610 bool barrel = itElectron->isEB();
613 for (
reco::CaloCluster_iterator clusIt = itElectron->superCluster()->clustersBegin(); clusIt!=itElectron->superCluster()->clustersEnd(); ++clusIt) {
615 DetId seed = lazyTools.getMaximum(**clusIt).first;
619 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
622 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
623 selectedCells.push_back(
hit.first);
629 for (
reco::CaloCluster_iterator clusIt = itElectron->parentSuperCluster()->clustersBegin(); clusIt!=itElectron->parentSuperCluster()->clustersEnd(); ++clusIt) {
631 DetId seed = lazyTools.getMaximum(**clusIt).first;
635 selectedCells.insert(selectedCells.end(), dets5x5.begin(), dets5x5.end());
638 for (
const std::pair<DetId, float> &
hit : (*clusIt)->hitsAndFractions()) {
639 selectedCells.push_back(
hit.first);
645 std::sort(selectedCells.begin(),selectedCells.end());
646 std::unique(selectedCells.begin(),selectedCells.end());
659 unsigned nSelectedCells = selectedCells.
size();
660 for (
unsigned icell = 0 ; icell < nSelectedCells ; ++icell) {
662 if ( it != recHits->
end() ) {
666 selectedRecHits.
sort();
670 bool passconversionveto =
false;
682 genMatches, deposits, pfId, isolationValues, isolationValuesNoPFId);
683 patElectrons->push_back(anElectron);
691 std::auto_ptr<std::vector<Electron> > ptr(patElectrons);
739 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
760 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
767 (*deposits[
j])[source]);
771 (*deposits[
j])[elecRef]);
774 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
778 (*isolationValues[
j])[source]);
787 for (
size_t j = 0;
j<isolationValuesNoPFId.size(); ++
j) {
825 for(
size_t i = 0,
n = genMatches.size();
i <
n; ++
i) {
841 for (
size_t j = 0, nd = deposits.size();
j < nd; ++
j) {
847 (*deposits[
j])[candPtrForGenMatch]);
849 else if (deposits[
j]->
contains(candPtrForIsolation.
id())) {
851 (*deposits[
j])[candPtrForIsolation]);
855 (*deposits[
j])[candPtrForIsolation->sourceCandidatePtr(0)]);
859 for (
size_t j = 0;
j<isolationValues.size(); ++
j) {
863 isolationValues[
j]->
contains(candPtrForGenMatch.
id())) {
865 (*isolationValues[
j])[candPtrForGenMatch]);
867 else if (isolationValues[
j]->
contains(candPtrForIsolation.
id())) {
869 (*isolationValues[
j])[candPtrForIsolation]);
873 (*isolationValues[
j])[candPtrForIsolation->sourceCandidatePtr(0)]);
883 iDesc.
setComment(
"PAT electron producer module");
896 iDesc.
add<
bool>(
"embedGsfElectronCore",
true)->setComment(
"embed external gsf electron core");
897 iDesc.
add<
bool>(
"embedGsfTrack",
true)->setComment(
"embed external gsf track");
898 iDesc.
add<
bool>(
"embedSuperCluster",
true)->setComment(
"embed external super cluster");
899 iDesc.
add<
bool>(
"embedPflowSuperCluster",
true)->setComment(
"embed external super cluster");
900 iDesc.
add<
bool>(
"embedSeedCluster",
true)->setComment(
"embed external seed cluster");
901 iDesc.
add<
bool>(
"embedBasicClusters",
true)->setComment(
"embed external basic clusters");
902 iDesc.
add<
bool>(
"embedPreshowerClusters",
true)->setComment(
"embed external preshower clusters");
903 iDesc.
add<
bool>(
"embedPflowBasicClusters",
true)->setComment(
"embed external pflow basic clusters");
904 iDesc.
add<
bool>(
"embedPflowPreshowerClusters",
true)->setComment(
"embed external pflow preshower clusters");
905 iDesc.
add<
bool>(
"embedTrack",
false)->setComment(
"embed external track");
906 iDesc.
add<
bool>(
"embedRecHits",
true)->setComment(
"embed external RecHits");
910 iDesc.
add<
bool>(
"useParticleFlow",
false)->setComment(
"whether to use particle flow or not");
911 iDesc.
add<
bool>(
"embedPFCandidate",
false)->setComment(
"embed external particle flow object");
914 iDesc.
add<
bool>(
"addGenMatch",
true)->setComment(
"add MC matching");
915 iDesc.
add<
bool>(
"embedGenMatch",
false)->setComment(
"embed MC matched MC information");
916 std::vector<edm::InputTag> emptySourceVector;
919 )->
setComment(
"input with MC match information");
922 iDesc.
add<
bool>(
"addElectronID",
true)->setComment(
"add electron ID variables");
927 )->
setComment(
"input with electron ID variables");
941 isoDepositsPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
955 isolationValuesPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
956 iDesc.
addOptional(
"isolationValues", isolationValuesPSet);
969 isolationValuesNoPFIdPSet.
addOptional<std::vector<edm::InputTag> >(
"user");
970 iDesc.
addOptional(
"isolationValuesNoPFId", isolationValuesNoPFIdPSet);
975 iDesc.
add(
"efficiencies", efficienciesPSet);
976 iDesc.
add<
bool>(
"addEfficiencies",
false);
984 iDesc.
add<
bool>(
"addElectronShapes",
true);
990 iDesc.
add(
"userIsolation", isolationPSet);
995 iDesc.
add<
bool>(
"embedHighLevelSelection",
true)->setComment(
"embed high level selection");
999 )->
setComment(
"input with high level selection");
1001 )->
setComment(
"input with high level selection");
1003 descriptions.
add(
"PATElectronProducer", iDesc);
1014 bool primaryVertexIsValid,
1016 bool beamspotIsValid
1022 std::pair<bool,Measurement1D>
result =
1028 double d0_corr = result.second.value();
1029 double d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1040 d0_corr = result.second.value();
1041 d0_err = primaryVertexIsValid ? result.second.error() : -1.0;
1056 d0_corr = result.second.value();
1057 d0_err = beamspotIsValid ? result.second.error() : -1.0;
1067 d0_corr = result.second.value();
1068 d0_err = beamspotIsValid ? result.second.error() : -1.0;
void setMvaVariables(double sigmaIetaIphi, double ip3d)
set missing mva input variables
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)
Assists in assimilating all pat::UserData into pat objects.
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
void setP4(P4Kind kind, const LorentzVector &p4, float p4Error, bool setCandidate)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
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
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...
static const HistoName names[]
Covariance3DMatrix covariance3D() const
return only 3D position covariance matrix
const LorentzVector & p4(P4Kind kind) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setAllowAnything()
allow any parameter label/value pairs
#define DEFINE_FWK_MODULE(type)
IsolationLabels isoDepositLabels_
edm::EDGetTokenT< edm::View< reco::GsfElectron > > electronToken_
void embedSuperCluster()
method to store the electron's SuperCluster internally
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
edm::EDGetTokenT< edm::ValueMap< float > > hcalPFClusterIsoT_
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)
void setDB(double dB, double edB, IpType type)
Set impact parameter of a certain type and its uncertainty.
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
void embedGsfElectronCore()
method to store the electron's core internally
void setPassConversionVeto(bool flag)
void setHcalPFClusterIso(float hcalPFClus)
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 >
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::EDGetTokenT< edm::ValueMap< float > > > elecIDTokens_
void embedPflowSuperCluster()
method to store the electron's PflowSuperCluster internally
bool enabled() const
'true' if this there is at least one efficiency configured
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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
bool enabled() const
True if it has a non null configuration.
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.
void embedSeedCluster()
method to store the electron's seedcluster internally
PATElectronProducer(const edm::ParameterSet &iConfig)
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollectionToken_
reco::PFCandidateRef pfCandidateRef() const
reference to the source PFCandidates; null if this has been built from a standard electron ...
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
std::vector< edm::EDGetTokenT< edm::Association< reco::GenParticleCollection > > > genMatchTokens_
edm::InputTag reducedEndcapRecHitCollection_
std::vector< edm::EDGetTokenT< edm::ValueMap< IsoDeposit > > > isoDepositTokens_
edm::InputTag reducedBarrelRecHitCollection_
mva input variables
edm::EDGetTokenT< reco::ConversionCollection > hConversionsToken_
math::XYZPoint Point
point in the space
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
void embedPflowBasicClusters()
method to store the electron's pflow basic clusters
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool embedHighLevelSelection_
embed high level selection variables?
void embedBasicClusters()
method to store the electron's basic clusters
bool isNull() const
Checks for null.
void embedGsfTrack()
method to store the electron's GsfTrack internally
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
bool isNonnull() const
Checks for non-null.
const_iterator end() const
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollectionToken_
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)
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::auto_ptr< ParameterDescriptionCases< T > > cases)
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueNoPFIdTokens_
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.
void setEcalPFClusterIso(float ecalPFClus)
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 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
ProductID id() const
Accessor for product ID.
IsolationLabels isolationValueLabelsNoPFId_
edm::EDGetTokenT< edm::ValueMap< reco::PFCandidatePtr > > pfCandidateMapToken_
void embedPreshowerClusters()
method to store the electron's preshower clusters
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
iterator find(key_type k)
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
IsolationLabels isolationValueLabels_
pat::helper::KinResolutionsLoader resolutionLoader_
const Point & position() const
position
volatile std::atomic< bool > shutdown_flag false
void embedPflowPreshowerClusters()
method to store the electron's pflow preshower clusters
bool embedPflowBasicClusters_
edm::EDGetTokenT< edm::ValueMap< float > > ecalPFClusterIsoT_
std::vector< edm::EDGetTokenT< edm::ValueMap< double > > > isolationValueTokens_
edm::EDGetTokenT< reco::BeamSpot > beamLineToken_
void embedTrack()
method to store the electron's Track internally
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.
edm::EDGetTokenT< reco::PFCandidateCollection > pfElecToken_
static std::string const source
bool embedPflowPreshowerClusters_
void embedPFCandidate()
embed the PFCandidate pointed to by pfCandidateRef_
void newEvent(const edm::Event &event) const
To be called for each new event, reads in the ValueMaps for efficiencies.
edm::EDGetTokenT< std::vector< reco::Vertex > > pvToken_
Global3DVector GlobalVector
std::vector< NameTag > elecIDSrcs_
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
std::vector< edm::Handle< edm::ValueMap< IsoDeposit > > > IsoDepositMaps