CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::VertexCollection
tokenPV_
 

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
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
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...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 26 of file HiBadParticleCleaner.cc.

Constructor & Destructor Documentation

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 }
edm::EDGetTokenT< reco::VertexCollection > tokenPV_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const double minMuonTrackRelPtErr_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const double minCaloCompatibility_
edm::EDGetTokenT< edm::View< reco::PFCandidate > > tokenPFCandidates_
HiBadParticleCleaner::~HiBadParticleCleaner ( )
overridedefault

Member Function Documentation

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.

References funct::abs(), reco::Vertex::covariance(), PVValHelper::dxy, PVValHelper::dz, edm::Event::getByToken(), h, maxSigLoose_, maxSigTight_, minCaloCompatibility_, minChargedHadronPt_, minMuonPt_, minMuonTrackRelPtErr_, minPixelNHits_, minTrackerLayersForMuonLoose_, minTrackerLayersForMuonTight_, minTrackNHits_, eostools::move(), RPCpg::mu, reco::TrackBase::muonSeededStepInOut, reco::TrackBase::muonSeededStepOutIn, nHits, AlCaHLTBitMon_ParallelJobs::p, slimmedMuons_cfi::pfCandidates, reco::Vertex::position(), edm::Event::put(), mathSSE::sqrt(), tokenPFCandidates_, tokenPV_, HLT_FULL_cff::track, GoodVertex_cfg::vertexCollection, and reco::Vertex::zError().

76  {
77  using namespace std;
78  using namespace edm;
79 
83 
84  const reco::VertexCollection* recoVertices;
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 
110  if (track->algo() == reco::TrackBase::muonSeededStepInOut ||
111  track->algo() == reco::TrackBase::muonSeededStepOutIn ||
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 
188  if (track->algo() == reco::TrackBase::muonSeededStepInOut ||
189  track->algo() == reco::TrackBase::muonSeededStepOutIn ||
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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
double zError() const
error on z
Definition: Vertex.h:141
edm::EDGetTokenT< reco::VertexCollection > tokenPV_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
ErrorD< N >::type type
Definition: Error.h:32
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:148
const Point & position() const
position
Definition: Vertex.h:127
tuple vertexCollection
T sqrt(T t)
Definition: SSEVec.h:19
const double minMuonTrackRelPtErr_
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
const double minCaloCompatibility_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
edm::EDGetTokenT< edm::View< reco::PFCandidate > > tokenPFCandidates_
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23

Member Data Documentation

const double HiBadParticleCleaner::maxSigLoose_
private

Definition at line 41 of file HiBadParticleCleaner.cc.

Referenced by produce().

const double HiBadParticleCleaner::maxSigTight_
private

Definition at line 42 of file HiBadParticleCleaner.cc.

Referenced by produce().

const double HiBadParticleCleaner::minCaloCompatibility_
private

Definition at line 43 of file HiBadParticleCleaner.cc.

Referenced by produce().

const double HiBadParticleCleaner::minChargedHadronPt_
private

Definition at line 39 of file HiBadParticleCleaner.cc.

Referenced by produce().

const double HiBadParticleCleaner::minMuonPt_
private

Definition at line 38 of file HiBadParticleCleaner.cc.

Referenced by produce().

const double HiBadParticleCleaner::minMuonTrackRelPtErr_
private

Definition at line 40 of file HiBadParticleCleaner.cc.

Referenced by produce().

const unsigned HiBadParticleCleaner::minPixelNHits_
private

Definition at line 45 of file HiBadParticleCleaner.cc.

Referenced by produce().

const int HiBadParticleCleaner::minTrackerLayersForMuonLoose_
private

Definition at line 46 of file HiBadParticleCleaner.cc.

Referenced by produce().

const int HiBadParticleCleaner::minTrackerLayersForMuonTight_
private

Definition at line 47 of file HiBadParticleCleaner.cc.

Referenced by produce().

const unsigned HiBadParticleCleaner::minTrackNHits_
private

Definition at line 44 of file HiBadParticleCleaner.cc.

Referenced by produce().

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

Definition at line 35 of file HiBadParticleCleaner.cc.

Referenced by produce().

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

Definition at line 36 of file HiBadParticleCleaner.cc.

Referenced by produce().