CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HiBadParticleCleaner Class Reference
Inheritance diagram for HiBadParticleCleaner:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HiBadParticleCleaner (const edm::ParameterSet &)
 
 ~HiBadParticleCleaner () override=default
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const double maxSigLoose_
 
const double maxSigTight_
 
const double minCaloCompatibility_
 
const double minChargedHadronPt_
 
const double minMuonPt_
 
const double minMuonTrackRelPtErr_
 
const unsigned minPixelNHits_
 
const int minTrackerLayersForMuonLoose_
 
const int minTrackerLayersForMuonTight_
 
const unsigned minTrackNHits_
 
edm::EDGetTokenT< edm::View< reco::PFCandidate > > tokenPFCandidates_
 
edm::EDGetTokenT< reco::VertexCollectiontokenPV_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 26 of file HiBadParticleCleaner.cc.

Constructor & Destructor Documentation

◆ HiBadParticleCleaner()

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

Definition at line 53 of file HiBadParticleCleaner.cc.

55  tokenPV_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("offlinePV"))),
56  minMuonPt_(iConfig.getParameter<double>("minMuonPt")),
57  minChargedHadronPt_(iConfig.getParameter<double>("minChargedHadronPt")),
58  minMuonTrackRelPtErr_(iConfig.getParameter<double>("minMuonTrackRelPtErr")),
59  maxSigLoose_(iConfig.getParameter<double>("maxSigLoose")),
60  maxSigTight_(iConfig.getParameter<double>("maxSigTight")),
61  minCaloCompatibility_(iConfig.getParameter<double>("minCaloCompatibility")),
62  minTrackNHits_(iConfig.getParameter<uint>("minTrackNHits")),
63  minPixelNHits_(iConfig.getParameter<uint>("minPixelNHits")),
64  minTrackerLayersForMuonLoose_(iConfig.getParameter<int>("minTrackerLayersForMuonLoose")),
65  minTrackerLayersForMuonTight_(iConfig.getParameter<int>("minTrackerLayersForMuonTight")) {
66  produces<bool>();
67  produces<reco::PFCandidateCollection>();
68  produces<reco::PFCandidateCollection>("removed");
69 }

◆ ~HiBadParticleCleaner()

HiBadParticleCleaner::~HiBadParticleCleaner ( )
overridedefault

Member Function Documentation

◆ produce()

void HiBadParticleCleaner::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup  
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 76 of file HiBadParticleCleaner.cc.

76  {
77  using namespace std;
78  using namespace edm;
79 
83 
84  const reco::VertexCollection* recoVertices;
86  iEvent.getByToken(tokenPV_, vertexCollection);
87  recoVertices = vertexCollection.product();
88 
89  auto pOutputCandidateCollection = std::make_unique<reco::PFCandidateCollection>();
90  auto pBadCandidateCollection = std::make_unique<reco::PFCandidateCollection>();
91 
92  bool foundBadCandidate = false;
93 
94  for (const reco::PFCandidate& pfCandidate : *pfCandidates) {
95  if (pfCandidate.particleId() == reco::PFCandidate::ParticleType::mu) // muon cleaning
96  {
97  if (pfCandidate.pt() > minMuonPt_) {
98  if (!pfCandidate.muonRef()->isGlobalMuon() || !pfCandidate.muonRef()->isTrackerMuon() ||
99  !pfCandidate.trackRef().isNonnull()) {
100  foundBadCandidate = true;
101  continue;
102  }
103  reco::TrackRef track = pfCandidate.trackRef();
104 
105  if (track->ptError() / track->pt() > minMuonTrackRelPtErr_ || track->pt() < pfCandidate.pt() / 2.) {
106  foundBadCandidate = true;
107  continue;
108  }
109 
112  track->originalAlgo() == reco::TrackBase::muonSeededStepInOut ||
113  track->originalAlgo() == reco::TrackBase::muonSeededStepOutIn ||
114  track->hitPattern().trackerLayersWithMeasurement() < minTrackerLayersForMuonLoose_) {
115  const reco::Vertex& vtx = (*recoVertices)[0];
116  float bestVzError = vtx.zError();
117  const math::XYZPoint& bestVtx(vtx.position());
118  math::Error<3>::type vtx_cov = vtx.covariance();
119  float dz = std::abs(track->dz(bestVtx));
120  float dxy = std::abs(track->dxy(bestVtx));
121  float dzError2 = track->dzError() * track->dzError() + bestVzError * bestVzError;
122  float dxyError = track->dxyError(bestVtx, vtx_cov);
123 
124  float dzSig2 = dz * dz / dzError2;
125  float dxySig2 = dxy * dxy / dxyError / dxyError;
126 
127  float sig3d = sqrt(dzSig2 + dxySig2);
128 
129  if (sig3d > maxSigLoose_) {
130  pBadCandidateCollection->push_back(pfCandidate);
131  foundBadCandidate = true;
132  continue;
133  }
134 
135  if (track->pt() < pfCandidate.pt() / 1.5 || track->pt() > pfCandidate.pt() * 1.5) {
136  foundBadCandidate = true;
137  pBadCandidateCollection->push_back(pfCandidate);
138  continue;
139  }
140  if (track->originalAlgo() == reco::TrackBase::muonSeededStepOutIn &&
141  track->hitPattern().trackerLayersWithMeasurement() < minTrackerLayersForMuonTight_) {
142  foundBadCandidate = true;
143  pBadCandidateCollection->push_back(pfCandidate);
144  continue;
145  }
146  }
147  }
148  } else if (pfCandidate.particleId() == reco::PFCandidate::ParticleType::h) //charged hadron cleaning
149  {
150  if (pfCandidate.pt() > minChargedHadronPt_) {
151  reco::TrackRef track = pfCandidate.trackRef();
152 
153  unsigned nHits = track->numberOfValidHits();
154  unsigned nPixelHits = track->hitPattern().numberOfValidPixelHits();
155 
156  if ((nHits < minTrackNHits_ && nPixelHits < minPixelNHits_) || nHits == 3) {
157  foundBadCandidate = true;
158  pBadCandidateCollection->push_back(pfCandidate);
159  continue;
160  }
161 
162  const reco::Vertex& vtx = (*recoVertices)[0];
163  float bestVzError = vtx.zError();
164  const math::XYZPoint& bestVtx(vtx.position());
165  math::Error<3>::type vtx_cov = vtx.covariance();
166  float dz = std::abs(track->dz(bestVtx));
167  float dxy = std::abs(track->dxy(bestVtx));
168  float dzError2 = track->dzError() * track->dzError() + bestVzError * bestVzError;
169  float dxyError = track->dxyError(bestVtx, vtx_cov);
170 
171  float dzSig2 = dz * dz / dzError2;
172  float dxySig2 = dxy * dxy / dxyError / dxyError;
173 
174  float sig3d = sqrt(dzSig2 + dxySig2);
175 
176  if (sig3d > maxSigLoose_) {
177  foundBadCandidate = true;
178  pBadCandidateCollection->push_back(pfCandidate);
179  continue;
180  }
181 
182  if (sig3d > maxSigTight_ && nHits < minTrackNHits_) {
183  foundBadCandidate = true;
184  pBadCandidateCollection->push_back(pfCandidate);
185  continue;
186  }
187 
190  track->originalAlgo() == reco::TrackBase::muonSeededStepInOut ||
191  track->originalAlgo() == reco::TrackBase::muonSeededStepOutIn) {
192  if (sig3d > maxSigLoose_) {
193  foundBadCandidate = true;
194  pBadCandidateCollection->push_back(pfCandidate);
195  continue;
196  }
197 
198  if (nHits < minTrackNHits_) {
199  foundBadCandidate = true;
200  pBadCandidateCollection->push_back(pfCandidate);
201  continue;
202  }
203  }
204 
205  double caloEnergy = pfCandidate.ecalEnergy() + pfCandidate.hcalEnergy();
206 
207  if (caloEnergy < track->p() * minCaloCompatibility_) {
208  if (sig3d > maxSigTight_) {
209  foundBadCandidate = true;
210  pBadCandidateCollection->push_back(pfCandidate);
211  continue;
212  }
213 
214  if (nHits < minTrackNHits_) {
215  foundBadCandidate = true;
216  pBadCandidateCollection->push_back(pfCandidate);
217  continue;
218  }
219 
220  if (nPixelHits < minPixelNHits_) {
221  foundBadCandidate = true;
222  pBadCandidateCollection->push_back(pfCandidate);
223  continue;
224  }
225  }
226  }
227  }
228 
229  pOutputCandidateCollection->push_back(pfCandidate);
230 
231  } // end loop over pf candidates
232 
233  bool pass = !foundBadCandidate;
234 
235  iEvent.put(std::move(pOutputCandidateCollection));
236  iEvent.put(std::move(pBadCandidateCollection), "removed");
237 
238  iEvent.put(std::make_unique<bool>(pass));
239 }

References funct::abs(), PVValHelper::dxy, PVValHelper::dz, h, iEvent, maxSigLoose_, maxSigTight_, minCaloCompatibility_, minChargedHadronPt_, minMuonPt_, minMuonTrackRelPtErr_, minPixelNHits_, minTrackerLayersForMuonLoose_, minTrackerLayersForMuonTight_, minTrackNHits_, eostools::move(), amptDefaultParameters_cff::mu, reco::TrackBase::muonSeededStepInOut, reco::TrackBase::muonSeededStepOutIn, AlCaHLTBitMon_ParallelJobs::p, zmumugammaAnalyzer_cfi::pfCandidates, mathSSE::sqrt(), tokenPFCandidates_, tokenPV_, HLT_FULL_cff::track, spclusmultinvestigator_cfi::vertexCollection, and extraflags_cff::vtx.

Member Data Documentation

◆ maxSigLoose_

const double HiBadParticleCleaner::maxSigLoose_
private

Definition at line 41 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ maxSigTight_

const double HiBadParticleCleaner::maxSigTight_
private

Definition at line 42 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ minCaloCompatibility_

const double HiBadParticleCleaner::minCaloCompatibility_
private

Definition at line 43 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ minChargedHadronPt_

const double HiBadParticleCleaner::minChargedHadronPt_
private

Definition at line 39 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ minMuonPt_

const double HiBadParticleCleaner::minMuonPt_
private

Definition at line 38 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ minMuonTrackRelPtErr_

const double HiBadParticleCleaner::minMuonTrackRelPtErr_
private

Definition at line 40 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ minPixelNHits_

const unsigned HiBadParticleCleaner::minPixelNHits_
private

Definition at line 45 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ minTrackerLayersForMuonLoose_

const int HiBadParticleCleaner::minTrackerLayersForMuonLoose_
private

Definition at line 46 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ minTrackerLayersForMuonTight_

const int HiBadParticleCleaner::minTrackerLayersForMuonTight_
private

Definition at line 47 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ minTrackNHits_

const unsigned HiBadParticleCleaner::minTrackNHits_
private

Definition at line 44 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ tokenPFCandidates_

edm::EDGetTokenT<edm::View<reco::PFCandidate> > HiBadParticleCleaner::tokenPFCandidates_
private

Definition at line 35 of file HiBadParticleCleaner.cc.

Referenced by produce().

◆ tokenPV_

edm::EDGetTokenT<reco::VertexCollection> HiBadParticleCleaner::tokenPV_
private

Definition at line 36 of file HiBadParticleCleaner.cc.

Referenced by produce().

HiBadParticleCleaner::minMuonPt_
const double minMuonPt_
Definition: HiBadParticleCleaner.cc:38
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
reco::CandidateView
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
HiBadParticleCleaner::minTrackerLayersForMuonLoose_
const int minTrackerLayersForMuonLoose_
Definition: HiBadParticleCleaner.cc:46
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HiBadParticleCleaner::minChargedHadronPt_
const double minChargedHadronPt_
Definition: HiBadParticleCleaner.cc:39
HiBadParticleCleaner::minPixelNHits_
const unsigned minPixelNHits_
Definition: HiBadParticleCleaner.cc:45
HiBadParticleCleaner::minTrackerLayersForMuonTight_
const int minTrackerLayersForMuonTight_
Definition: HiBadParticleCleaner.cc:47
edm::Handle
Definition: AssociativeIterator.h:50
parallelization.uint
uint
Definition: parallelization.py:124
edm::Ref< TrackCollection >
HiBadParticleCleaner::maxSigTight_
const double maxSigTight_
Definition: HiBadParticleCleaner.cc:42
reco::TrackBase::muonSeededStepOutIn
Definition: TrackBase.h:104
HiBadParticleCleaner::minTrackNHits_
const unsigned minTrackNHits_
Definition: HiBadParticleCleaner.cc:44
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
HiBadParticleCleaner::minMuonTrackRelPtErr_
const double minMuonTrackRelPtErr_
Definition: HiBadParticleCleaner.cc:40
edm::View< reco::PFCandidate >
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::TrackBase::muonSeededStepInOut
Definition: TrackBase.h:103
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HiBadParticleCleaner::tokenPV_
edm::EDGetTokenT< reco::VertexCollection > tokenPV_
Definition: HiBadParticleCleaner.cc:36
PVValHelper::dxy
Definition: PVValidationHelpers.h:47
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:18
PVValHelper::dz
Definition: PVValidationHelpers.h:50
spclusmultinvestigator_cfi.vertexCollection
vertexCollection
Definition: spclusmultinvestigator_cfi.py:4
math::Error::type
ErrorD< N >::type type
Definition: Error.h:32
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
HiBadParticleCleaner::tokenPFCandidates_
edm::EDGetTokenT< edm::View< reco::PFCandidate > > tokenPFCandidates_
Definition: HiBadParticleCleaner.cc:35
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:153
HiBadParticleCleaner::maxSigLoose_
const double maxSigLoose_
Definition: HiBadParticleCleaner.cc:41
edm::InputTag
Definition: InputTag.h:15
HiBadParticleCleaner::minCaloCompatibility_
const double minCaloCompatibility_
Definition: HiBadParticleCleaner.cc:43
reco::Vertex
Definition: Vertex.h:35