CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
MuonSeedCleaner Class Reference

#include <MuonSeedCleaner.h>

Public Types

typedef std::deque< bool > BoolContainer
 
typedef MuonTransientTrackingRecHit::MuonRecHitContainer SegmentContainer
 

Public Member Functions

 MuonSeedCleaner (const edm::ParameterSet &, edm::ConsumesCollector &&)
 Constructor. More...
 
int NRecHitsFromSegment (const TrackingRecHit &rhit)
 
int NRecHitsFromSegment (MuonTransientTrackingRecHit *rhit)
 
std::vector< TrajectorySeedseedCleaner (const edm::EventSetup &eventSetup, std::vector< TrajectorySeed > &seeds)
 Cache pointer to geometry. More...
 
 ~MuonSeedCleaner ()
 Destructor. More...
 

Public Attributes

std::vector< int > badSeedLayer
 

Private Member Functions

TrajectorySeed BiggerCone (std::vector< TrajectorySeed > &seeds)
 select the seed with bigger projection cone to next layer More...
 
TrajectorySeed Chi2LengthSelection (std::vector< TrajectorySeed > &seeds)
 select seed by balance length and chi2 More...
 
std::vector< SeedContainerGroupSeeds (std::vector< TrajectorySeed > &seeds)
 group the seeds More...
 
TrajectorySeed LeanHighMomentum (std::vector< TrajectorySeed > &seeds)
 select the highest momentum pt seed More...
 
SeedContainer LengthFilter (std::vector< TrajectorySeed > &seeds)
 
bool MomentumFilter (std::vector< TrajectorySeed > &seeds)
 filter out the bad pt seeds, if all are bad pt seeds then keep all More...
 
TrajectorySeed MoreRecHits (std::vector< TrajectorySeed > &seeds)
 select the seed with more rechits More...
 
double NChi2OfSegment (const TrackingRecHit &rhit)
 retrieve number of rechits& normalized chi2 of associated segments of a seed More...
 
unsigned int OverlapSegments (const TrajectorySeed &seed1, const TrajectorySeed &seed2)
 check overlapping segment for seeds More...
 
SeedContainer SeedCandidates (std::vector< TrajectorySeed > &seeds, bool good)
 pick the seeds w/ 1st layer information and w/ more than 1 segments More...
 
double SeedChi2 (const TrajectorySeed &seed)
 
int SeedLength (const TrajectorySeed &seed)
 
GlobalVector SeedMomentum (const TrajectorySeed &seed)
 retrieve seed global momentum More...
 
GlobalPoint SeedPosition (const TrajectorySeed &seed)
 retrieve seed global position More...
 

Private Attributes

bool debug
 
std::vector< int > ShoweringLayers
 
SegmentContainer ShoweringSegments
 
MuonServiceProxytheService
 

Detailed Description

Algorith to clean duplicate seeds and select a right one

author: Shih-Chuan Kao - UCR

Definition at line 28 of file MuonSeedCleaner.h.

Member Typedef Documentation

◆ BoolContainer

typedef std::deque<bool> MuonSeedCleaner::BoolContainer

Definition at line 31 of file MuonSeedCleaner.h.

◆ SegmentContainer

Definition at line 30 of file MuonSeedCleaner.h.

Constructor & Destructor Documentation

◆ MuonSeedCleaner()

MuonSeedCleaner::MuonSeedCleaner ( const edm::ParameterSet pset,
edm::ConsumesCollector &&  iC 
)
explicit

Constructor.

Definition at line 49 of file MuonSeedCleaner.cc.

References debug, eostools::move(), MuonServiceProxy_cff::MuonServiceProxy, muonDTDigis_cfi::pset, and theService.

49  {
50  // Local Debug flag
51  debug = pset.getParameter<bool>("DebugMuonSeed");
52 
53  // muon service
54  edm::ParameterSet serviceParameters = pset.getParameter<edm::ParameterSet>("ServiceParameters");
55  theService = new MuonServiceProxy(serviceParameters, std::move(iC));
56 }
MuonServiceProxy * theService
def move(src, dest)
Definition: eostools.py:511

◆ ~MuonSeedCleaner()

MuonSeedCleaner::~MuonSeedCleaner ( )

Destructor.

Definition at line 61 of file MuonSeedCleaner.cc.

References theService.

61  {
62  if (theService)
63  delete theService;
64 }
MuonServiceProxy * theService

Member Function Documentation

◆ BiggerCone()

TrajectorySeed MuonSeedCleaner::BiggerCone ( std::vector< TrajectorySeed > &  seeds)
private

select the seed with bigger projection cone to next layer

Definition at line 162 of file MuonSeedCleaner.cc.

References mps_fire::i, NRecHitsFromSegment(), diffTwoXMLs::r1, HLT_2024v12_cff::seeds, and mathSSE::sqrt().

Referenced by seedCleaner().

162  {
163  if (seeds.size() == 1)
164  return seeds[0];
165 
166  float biggerProjErr = 9999.;
167  int winner = 0;
168  AlgebraicSymMatrix mat(5, 0);
169  for (size_t i = 0; i < seeds.size(); i++) {
170  auto r1 = seeds[i].recHits().begin();
171  mat = r1->parametersError().similarityT(r1->projectionMatrix());
172 
173  int NRecHits = NRecHitsFromSegment(*r1);
174 
175  float ddx = mat[1][1];
176  float ddy = mat[2][2];
177  float dxx = mat[3][3];
178  float dyy = mat[4][4];
179  float projectErr = sqrt((ddx * 10000.) + (ddy * 10000.) + dxx + dyy);
180 
181  if (NRecHits < 5)
182  continue;
183  if (projectErr < biggerProjErr)
184  continue;
185 
186  winner = static_cast<int>(i);
187  biggerProjErr = projectErr;
188  }
189  TrajectorySeed theSeed = seeds[winner];
190  seeds.erase(seeds.begin() + winner);
191  return theSeed;
192 }
T sqrt(T t)
Definition: SSEVec.h:19
int NRecHitsFromSegment(const TrackingRecHit &rhit)
CLHEP::HepSymMatrix AlgebraicSymMatrix

◆ Chi2LengthSelection()

TrajectorySeed MuonSeedCleaner::Chi2LengthSelection ( std::vector< TrajectorySeed > &  seeds)
private

select seed by balance length and chi2

Definition at line 124 of file MuonSeedCleaner.cc.

References mps_fire::i, SeedChi2(), HLT_2024v12_cff::seeds, and bscTrigger_cfi::theHits.

Referenced by seedCleaner().

124  {
125  if (seeds.size() == 1)
126  return seeds[0];
127 
128  int winner = 0;
129  int moreHits = 0;
130  double bestChi2 = 99999.;
131  for (size_t i = 0; i < seeds.size(); i++) {
132  // 1. fill out the Nchi2 of segments of the seed
133  //GlobalVector mom = SeedMomentum( seeds[i] ); // temporary use for debugging
134  //double pt = sqrt( (mom.x()*mom.x()) + (mom.y()*mom.y()) );
135  //std::cout<<" > SEED"<<i<<" pt:"<<pt<< std::endl;
136 
137  double theChi2 = SeedChi2(seeds[i]);
138  double dChi2 = fabs(1. - (theChi2 / bestChi2));
139  int theHits = seeds[i].nHits();
140  int dHits = theHits - moreHits;
141  //std::cout<<" ----- "<<std::endl;
142 
143  // 2. better chi2
144  if (theChi2 < bestChi2 && dChi2 > 0.05) {
145  winner = static_cast<int>(i);
146  bestChi2 = theChi2;
147  moreHits = theHits;
148  }
149  // 3. if chi2 is not much better, pick more rechits one
150  if (theChi2 >= bestChi2 && dChi2 < 0.05 && dHits > 0) {
151  winner = static_cast<int>(i);
152  bestChi2 = theChi2;
153  moreHits = theHits;
154  }
155  }
156  //std::cout<<" Winner is "<< winner <<std::endl;
157  TrajectorySeed theSeed = seeds[winner];
158  seeds.erase(seeds.begin() + winner);
159  return theSeed;
160 }
double SeedChi2(const TrajectorySeed &seed)

◆ GroupSeeds()

std::vector< SeedContainer > MuonSeedCleaner::GroupSeeds ( std::vector< TrajectorySeed > &  seeds)
private

group the seeds

Definition at line 323 of file MuonSeedCleaner.cc.

References hgcalPerformanceValidation::df, cuy::dh, HGC3DClusterGenMatchSelector_cfi::dR, PV3DBase< T, PVType, FrameType >::eta(), mps_fire::i, dqmiolumiharvest::j, lengthSorting(), nHits, OverlapSegments(), PV3DBase< T, PVType, FrameType >::phi(), ElectronSeedTrackRefFix_cfi::seedCollection, SeedPosition(), HLT_2024v12_cff::seeds, jetUpdater_cfi::sort, and mathSSE::sqrt().

Referenced by seedCleaner().

323  {
324  std::vector<SeedContainer> seedCollection;
325  seedCollection.clear();
326  std::vector<TrajectorySeed> theGroup;
327  std::vector<bool> usedSeed(seeds.size(), false);
328 
329  // categorize seeds by comparing overlapping segments or a certian eta-phi cone
330  for (size_t i = 0; i < seeds.size(); i++) {
331  if (usedSeed[i])
332  continue;
333  theGroup.push_back(seeds[i]);
334  usedSeed[i] = true;
335 
336  GlobalPoint pos1 = SeedPosition(seeds[i]);
337 
338  for (size_t j = i + 1; j < seeds.size(); j++) {
339  // 1.1 seeds with overlaaping segments will be grouped together
340  unsigned int overlapping = OverlapSegments(seeds[i], seeds[j]);
341  if (!usedSeed[j] && overlapping > 0) {
342  // reject the identical seeds
343  if (seeds[i].nHits() == overlapping && seeds[j].nHits() == overlapping) {
344  usedSeed[j] = true;
345  continue;
346  }
347  theGroup.push_back(seeds[j]);
348  usedSeed[j] = true;
349  }
350  if (usedSeed[j])
351  continue;
352 
353  // 1.2 seeds in a certain cone are grouped together
354  GlobalPoint pos2 = SeedPosition(seeds[j]);
355  double dh = pos1.eta() - pos2.eta();
356  double df = pos1.phi() - pos2.phi();
357  double dR = sqrt((dh * dh) + (df * df));
358 
359  if (dR > 0.3 && seeds[j].nHits() == 1)
360  continue;
361  if (dR > 0.2 && seeds[j].nHits() > 1)
362  continue;
363  theGroup.push_back(seeds[j]);
364  usedSeed[j] = true;
365  }
366  sort(theGroup.begin(), theGroup.end(), lengthSorting);
367  seedCollection.push_back(theGroup);
368  //std::cout<<" group "<<seedCollection.size() <<" w/"<< theGroup.size() <<" seeds"<<std::endl;
369  theGroup.clear();
370  }
371  return seedCollection;
372 }
static bool lengthSorting(const TrajectorySeed &s1, const TrajectorySeed &s2)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
GlobalPoint SeedPosition(const TrajectorySeed &seed)
retrieve seed global position
unsigned int OverlapSegments(const TrajectorySeed &seed1, const TrajectorySeed &seed2)
check overlapping segment for seeds
T sqrt(T t)
Definition: SSEVec.h:19
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
dh
Definition: cuy.py:354

◆ LeanHighMomentum()

TrajectorySeed MuonSeedCleaner::LeanHighMomentum ( std::vector< TrajectorySeed > &  seeds)
private

select the highest momentum pt seed

Definition at line 194 of file MuonSeedCleaner.cc.

References mps_fire::i, DiDispStaMuonMonitor_cfi::pt, SeedMomentum(), HLT_2024v12_cff::seeds, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by seedCleaner().

194  {
195  if (seeds.size() == 1)
196  return seeds[0];
197 
198  double highestPt = 0.;
199  int winner = 0;
200  for (size_t i = 0; i < seeds.size(); i++) {
202  double pt = sqrt((mom.x() * mom.x()) + (mom.y() * mom.y()));
203  if (pt > highestPt) {
204  winner = static_cast<int>(i);
205  highestPt = pt;
206  }
207  }
208  TrajectorySeed theSeed = seeds[winner];
209  seeds.erase(seeds.begin() + winner);
210  return theSeed;
211 }
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
GlobalVector SeedMomentum(const TrajectorySeed &seed)
retrieve seed global momentum

◆ LengthFilter()

SeedContainer MuonSeedCleaner::LengthFilter ( std::vector< TrajectorySeed > &  seeds)
private

pick the seed by better parameter error collect long seeds

Definition at line 243 of file MuonSeedCleaner.cc.

References mps_fire::i, and HLT_2024v12_cff::seeds.

243  {
244  SeedContainer longSeeds;
245  int NSegs = 0;
246  for (size_t i = 0; i < seeds.size(); i++) {
247  int theLength = static_cast<int>(seeds[i].nHits());
248  if (theLength > NSegs) {
249  NSegs = theLength;
250  longSeeds.clear();
251  longSeeds.push_back(seeds[i]);
252  } else if (theLength == NSegs) {
253  longSeeds.push_back(seeds[i]);
254  } else {
255  continue;
256  }
257  }
258  //std::cout<<" final Length :"<<NSegs<<std::endl;
259 
260  return longSeeds;
261 }
std::vector< TrajectorySeed > SeedContainer

◆ MomentumFilter()

bool MuonSeedCleaner::MomentumFilter ( std::vector< TrajectorySeed > &  seeds)
private

filter out the bad pt seeds, if all are bad pt seeds then keep all

Definition at line 263 of file MuonSeedCleaner.cc.

References mps_fire::i, DiDispStaMuonMonitor_cfi::pt, SeedMomentum(), HLT_2024v12_cff::seeds, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by seedCleaner().

263  {
264  bool findgoodMomentum = false;
265  SeedContainer goodMomentumSeeds = seeds;
266  seeds.clear();
267  for (size_t i = 0; i < goodMomentumSeeds.size(); i++) {
268  GlobalVector mom = SeedMomentum(goodMomentumSeeds[i]);
269  double pt = sqrt((mom.x() * mom.x()) + (mom.y() * mom.y()));
270  if (pt < 6. || pt > 2000.)
271  continue;
272  //if ( pt < 6. ) continue;
273  //std::cout<<" passed momentum :"<< pt <<std::endl;
274  seeds.push_back(goodMomentumSeeds[i]);
275  findgoodMomentum = true;
276  }
277  if (seeds.empty())
278  seeds = goodMomentumSeeds;
279 
280  return findgoodMomentum;
281 }
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
GlobalVector SeedMomentum(const TrajectorySeed &seed)
retrieve seed global momentum
std::vector< TrajectorySeed > SeedContainer

◆ MoreRecHits()

TrajectorySeed MuonSeedCleaner::MoreRecHits ( std::vector< TrajectorySeed > &  seeds)
private

select the seed with more rechits

Definition at line 213 of file MuonSeedCleaner.cc.

References mps_fire::i, NRecHitsFromSegment(), diffTwoXMLs::r1, FastTrackerRecHitMaskProducer_cfi::recHits, SeedChi2(), HLT_2024v12_cff::seeds, and bscTrigger_cfi::theHits.

Referenced by seedCleaner().

213  {
214  if (seeds.size() == 1)
215  return seeds[0];
216 
217  int winner = 0;
218  int moreHits = 0;
219  double betterChi2 = 99999.;
220  for (size_t i = 0; i < seeds.size(); i++) {
221  int theHits = 0;
222  for (auto const& r1 : seeds[i].recHits()) {
224  }
225 
226  double theChi2 = SeedChi2(seeds[i]);
227 
228  if (theHits == moreHits && theChi2 < betterChi2) {
229  betterChi2 = theChi2;
230  winner = static_cast<int>(i);
231  }
232  if (theHits > moreHits) {
233  moreHits = theHits;
234  betterChi2 = theChi2;
235  winner = static_cast<int>(i);
236  }
237  }
238  TrajectorySeed theSeed = seeds[winner];
239  seeds.erase(seeds.begin() + winner);
240  return theSeed;
241 }
double SeedChi2(const TrajectorySeed &seed)
int NRecHitsFromSegment(const TrackingRecHit &rhit)

◆ NChi2OfSegment()

double MuonSeedCleaner::NChi2OfSegment ( const TrackingRecHit rhit)
private

retrieve number of rechits& normalized chi2 of associated segments of a seed

Definition at line 489 of file MuonSeedCleaner.cc.

References TrackingRecHit::clone(), TrackingRecHit::geographicalId(), GlobalTrackingGeometry::idToDet(), MuonTransientTrackingRecHit::specificBuild(), theService, and MuonServiceProxy::trackingGeometry().

Referenced by SeedChi2().

489  {
490  double NChi2 = 999999.;
491  const GeomDet* gdet = theService->trackingGeometry()->idToDet(rhit.geographicalId());
494 
495  double dof = static_cast<double>(theSeg->degreesOfFreedom());
496  NChi2 = theSeg->chi2() / dof;
497  //std::cout<<" Chi2 = "<< NChi2 <<" |" ;
498 
499  return NChi2;
500 }
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
MuonServiceProxy * theService
const GeomDet * idToDet(DetId) const override
std::shared_ptr< MuonTransientTrackingRecHit > MuonRecHitPointer
virtual TrackingRecHit * clone() const =0
DetId geographicalId() const
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)

◆ NRecHitsFromSegment() [1/2]

int MuonSeedCleaner::NRecHitsFromSegment ( const TrackingRecHit rhit)

Definition at line 446 of file MuonSeedCleaner.cc.

References TrackingRecHit::clone(), MuonSubdetId::CSC, MuonSubdetId::DT, GeomDet::geographicalId(), TrackingRecHit::geographicalId(), GlobalTrackingGeometry::idToDet(), dqmiolumiharvest::j, findQualityFiles::size, MuonTransientTrackingRecHit::specificBuild(), theService, and MuonServiceProxy::trackingGeometry().

Referenced by BiggerCone(), MuonSeedBuilder::foundMatchingSegment(), MuonSeedBuilder::IdentifyShowering(), MoreRecHits(), and SeedLength().

446  {
447  int NRechits = 0;
448  const GeomDet* gdet = theService->trackingGeometry()->idToDet(rhit.geographicalId());
451 
452  DetId geoId = gdet->geographicalId();
453  if (geoId.subdetId() == MuonSubdetId::DT) {
454  DTChamberId DT_Id(rhit.geographicalId());
455  std::vector<TrackingRecHit*> DThits = theSeg->recHits();
456  int dt1DHits = 0;
457  for (size_t j = 0; j < DThits.size(); j++) {
458  dt1DHits += (DThits[j]->recHits()).size();
459  }
460  NRechits = dt1DHits;
461  }
462 
463  if (geoId.subdetId() == MuonSubdetId::CSC) {
464  NRechits = (theSeg->recHits()).size();
465  }
466  return NRechits;
467 }
size
Write out results.
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
MuonServiceProxy * theService
const GeomDet * idToDet(DetId) const override
std::shared_ptr< MuonTransientTrackingRecHit > MuonRecHitPointer
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
virtual TrackingRecHit * clone() const =0
Definition: DetId.h:17
DetId geographicalId() const
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12
static MuonRecHitPointer specificBuild(const GeomDet *geom, const TrackingRecHit *rh)

◆ NRecHitsFromSegment() [2/2]

int MuonSeedCleaner::NRecHitsFromSegment ( MuonTransientTrackingRecHit rhit)

Definition at line 469 of file MuonSeedCleaner.cc.

References MuonSubdetId::CSC, MuonSubdetId::DT, TrackingRecHit::geographicalId(), dqmiolumiharvest::j, GenericTransientTrackingRecHit::recHits(), findQualityFiles::size, and DetId::subdetId().

469  {
470  int NRechits = 0;
471  DetId geoId = rhit->geographicalId();
472  if (geoId.subdetId() == MuonSubdetId::DT) {
473  DTChamberId DT_Id(geoId);
474  std::vector<TrackingRecHit*> DThits = rhit->recHits();
475  int dt1DHits = 0;
476  for (size_t j = 0; j < DThits.size(); j++) {
477  dt1DHits += (DThits[j]->recHits()).size();
478  }
479  NRechits = dt1DHits;
480  //std::cout<<" D_rh("<< dt1DHits <<") " ;
481  }
482  if (geoId.subdetId() == MuonSubdetId::CSC) {
483  NRechits = (rhit->recHits()).size();
484  //std::cout<<" C_rh("<<(rhit->recHits()).size() <<") " ;
485  }
486  return NRechits;
487 }
size
Write out results.
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
DetId geographicalId() const
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12

◆ OverlapSegments()

unsigned int MuonSeedCleaner::OverlapSegments ( const TrajectorySeed seed1,
const TrajectorySeed seed2 
)
private

check overlapping segment for seeds

Definition at line 374 of file MuonSeedCleaner.cc.

References PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, globals_cff::id1, globals_cff::id2, GlobalTrackingGeometry::idToDet(), diffTwoXMLs::r1, diffTwoXMLs::r2, TrajectorySeed::recHits(), mathSSE::sqrt(), theService, GeomDet::toGlobal(), MuonServiceProxy::trackingGeometry(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by GroupSeeds().

374  {
375  unsigned int overlapping = 0;
376  for (auto const& r1 : seed1.recHits()) {
377  DetId id1 = r1.geographicalId();
378  const GeomDet* gdet1 = theService->trackingGeometry()->idToDet(id1);
379  GlobalPoint gp1 = gdet1->toGlobal(r1.localPosition());
380 
381  for (auto const& r2 : seed2.recHits()) {
382  DetId id2 = r2.geographicalId();
383  if (id1 != id2)
384  continue;
385 
386  const GeomDet* gdet2 = theService->trackingGeometry()->idToDet(id2);
387  GlobalPoint gp2 = gdet2->toGlobal(r2.localPosition());
388 
389  double dx = gp1.x() - gp2.x();
390  double dy = gp1.y() - gp2.y();
391  double dz = gp1.z() - gp2.z();
392  double dL = sqrt(dx * dx + dy * dy + dz * dz);
393 
394  if (dL < 1.)
395  overlapping++;
396  }
397  }
398  return overlapping;
399 }
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
T z() const
Definition: PV3DBase.h:61
RecHitRange recHits() const
MuonServiceProxy * theService
const GeomDet * idToDet(DetId) const override
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
Definition: DetId.h:17

◆ SeedCandidates()

SeedContainer MuonSeedCleaner::SeedCandidates ( std::vector< TrajectorySeed > &  seeds,
bool  good 
)
private

pick the seeds w/ 1st layer information and w/ more than 1 segments

Definition at line 283 of file MuonSeedCleaner.cc.

References MuonSubdetId::CSC, MuonSubdetId::DT, GeomDet::geographicalId(), caHitNtupletGeneratorKernels::good, mps_fire::i, GlobalTrackingGeometry::idToDet(), nHits, diffTwoXMLs::r1, FastTrackerRecHitMaskProducer_cfi::recHits, HLT_2024v12_cff::seeds, CSCDetId::station(), DetId::subdetId(), theService, and MuonServiceProxy::trackingGeometry().

Referenced by seedCleaner().

283  {
284  SeedContainer theCandidate;
285  theCandidate.clear();
286 
287  bool longSeed = false;
288  bool withFirstLayer = false;
289 
290  //std::cout<<"***** Seed Classification *****"<< seeds.size() <<std::endl;
291  for (size_t i = 0; i < seeds.size(); i++) {
292  if (seeds[i].nHits() > 1)
293  longSeed = true;
294  //std::cout<<" Seed: "<<i<<" w/"<<seeds[i].nHits()<<" segs "<<std::endl;
295  // looking for 1st layer segment
296  for (auto const& r1 : seeds[i].recHits()) {
297  const GeomDet* gdet = theService->trackingGeometry()->idToDet(r1.geographicalId());
298  DetId geoId = gdet->geographicalId();
299 
300  if (geoId.subdetId() == MuonSubdetId::DT) {
301  DTChamberId DT_Id(r1.geographicalId());
302  //std::cout<<" ID:"<<DT_Id <<" pos:"<< r1->localPosition() <<std::endl;
303  if (DT_Id.station() != 1)
304  continue;
305  withFirstLayer = true;
306  }
307  if (geoId.subdetId() == MuonSubdetId::CSC) {
308  CSCDetId CSC_Id = CSCDetId(r1.geographicalId());
309  //std::cout<<" ID:"<<CSC_Id <<" pos:"<< r1->localPosition() <<std::endl;
310  if (CSC_Id.station() != 1)
311  continue;
312  withFirstLayer = true;
313  }
314  }
315  bool goodseed = (longSeed && withFirstLayer) ? true : false;
316 
317  if (goodseed == good)
318  theCandidate.push_back(seeds[i]);
319  }
320  return theCandidate;
321 }
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
MuonServiceProxy * theService
const GeomDet * idToDet(DetId) const override
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Definition: DetId.h:17
int station() const
Definition: CSCDetId.h:79
static constexpr int DT
Definition: MuonSubdetId.h:11
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
std::vector< TrajectorySeed > SeedContainer
static constexpr int CSC
Definition: MuonSubdetId.h:12

◆ SeedChi2()

double MuonSeedCleaner::SeedChi2 ( const TrajectorySeed seed)
private

Definition at line 401 of file MuonSeedCleaner.cc.

References NChi2OfSegment(), diffTwoXMLs::r1, and fileCollector::seed.

Referenced by Chi2LengthSelection(), and MoreRecHits().

401  {
402  double theChi2 = 0.;
403  for (auto const& r1 : seed.recHits()) {
404  //std::cout<<" segmet : "<<it <<std::endl;
405  theChi2 += NChi2OfSegment(r1);
406  }
407  theChi2 = theChi2 / seed.nHits();
408 
409  //std::cout<<" final Length :"<<NSegs<<std::endl;
410  return theChi2;
411 }
double NChi2OfSegment(const TrackingRecHit &rhit)
retrieve number of rechits& normalized chi2 of associated segments of a seed

◆ seedCleaner()

std::vector< TrajectorySeed > MuonSeedCleaner::seedCleaner ( const edm::EventSetup eventSetup,
std::vector< TrajectorySeed > &  seeds 
)

Cache pointer to geometry.

Cache pointer to Magnetic field cleaning the seeds

Definition at line 72 of file MuonSeedCleaner.cc.

References BiggerCone(), Chi2LengthSelection(), PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), options_cfi::eventSetup, GroupSeeds(), mps_fire::i, LeanHighMomentum(), MomentumFilter(), MoreRecHits(), SeedCandidates(), SeedPosition(), HLT_2024v12_cff::seeds, theService, and MuonServiceProxy::update().

Referenced by MuonSeedBuilder::build().

73  {
75 
76  std::vector<TrajectorySeed> FinalSeeds;
77 
78  // group the seeds
79  std::vector<SeedContainer> theCollection = GroupSeeds(seeds);
80 
81  // ckeck each group and pick the good one
82  for (size_t i = 0; i < theCollection.size(); i++) {
83  // separate seeds w/ more than 1 segments and w/ 1st layer segment information
84  SeedContainer goodSeeds = SeedCandidates(theCollection[i], true);
85  SeedContainer otherSeeds = SeedCandidates(theCollection[i], false);
86  if (MomentumFilter(goodSeeds)) {
87  //std::cout<<" == type1 "<<std::endl;
88  TrajectorySeed bestSeed = Chi2LengthSelection(goodSeeds);
89  FinalSeeds.push_back(bestSeed);
90 
91  GlobalPoint seedgp = SeedPosition(bestSeed);
92  double eta = fabs(seedgp.eta());
93  if (goodSeeds.size() > 2 && eta > 1.5) {
94  TrajectorySeed anotherSeed = MoreRecHits(goodSeeds);
95  FinalSeeds.push_back(anotherSeed);
96  }
97  } else if (MomentumFilter(otherSeeds)) {
98  //std::cout<<" == type2 "<<std::endl;
99  TrajectorySeed bestSeed = MoreRecHits(otherSeeds);
100  FinalSeeds.push_back(bestSeed);
101 
102  GlobalPoint seedgp = SeedPosition(bestSeed);
103  double eta = fabs(seedgp.eta());
104  if (otherSeeds.size() > 2 && eta > 1.5) {
105  TrajectorySeed anotherSeed = LeanHighMomentum(otherSeeds);
106  FinalSeeds.push_back(anotherSeed);
107  }
108  } else {
109  //std::cout<<" == type3 "<<std::endl;
110  TrajectorySeed bestSeed = LeanHighMomentum(theCollection[i]);
111  FinalSeeds.push_back(bestSeed);
112 
113  GlobalPoint seedgp = SeedPosition(bestSeed);
114  double eta = fabs(seedgp.eta());
115  if (theCollection.size() > 2 && eta > 1.5) {
116  TrajectorySeed anotherSeed = BiggerCone(theCollection[i]);
117  FinalSeeds.push_back(anotherSeed);
118  }
119  }
120  }
121  return FinalSeeds;
122 }
TrajectorySeed BiggerCone(std::vector< TrajectorySeed > &seeds)
select the seed with bigger projection cone to next layer
T eta() const
Definition: PV3DBase.h:73
MuonServiceProxy * theService
GlobalPoint SeedPosition(const TrajectorySeed &seed)
retrieve seed global position
bool MomentumFilter(std::vector< TrajectorySeed > &seeds)
filter out the bad pt seeds, if all are bad pt seeds then keep all
TrajectorySeed LeanHighMomentum(std::vector< TrajectorySeed > &seeds)
select the highest momentum pt seed
std::vector< SeedContainer > GroupSeeds(std::vector< TrajectorySeed > &seeds)
group the seeds
SeedContainer SeedCandidates(std::vector< TrajectorySeed > &seeds, bool good)
pick the seeds w/ 1st layer information and w/ more than 1 segments
void update(const edm::EventSetup &setup, bool duringEvent=true)
update the services each event
TrajectorySeed MoreRecHits(std::vector< TrajectorySeed > &seeds)
select the seed with more rechits
std::vector< TrajectorySeed > SeedContainer
TrajectorySeed Chi2LengthSelection(std::vector< TrajectorySeed > &seeds)
select seed by balance length and chi2

◆ SeedLength()

int MuonSeedCleaner::SeedLength ( const TrajectorySeed seed)
private

Definition at line 413 of file MuonSeedCleaner.cc.

References NRecHitsFromSegment(), rpcPointValidation_cfi::recHit, fileCollector::seed, and bscTrigger_cfi::theHits.

413  {
414  int theHits = 0;
415  for (auto const& recHit : seed.recHits()) {
416  //std::cout<<" segmet : "<<it <<std::endl;
418  }
419 
420  //std::cout<<" final Length :"<<NSegs<<std::endl;
421  return theHits;
422 }
int NRecHitsFromSegment(const TrackingRecHit &rhit)

◆ SeedMomentum()

GlobalVector MuonSeedCleaner::SeedMomentum ( const TrajectorySeed seed)
private

retrieve seed global momentum

Definition at line 435 of file MuonSeedCleaner.cc.

References PTrajectoryStateOnDet::detId(), TrajectoryStateOnSurface::globalMomentum(), GlobalTrackingGeometry::idToDet(), MuonServiceProxy::magneticField(), fileCollector::seed, theService, MuonServiceProxy::trackingGeometry(), and trajectoryStateTransform::transientState().

Referenced by LeanHighMomentum(), and MomentumFilter().

435  {
436  PTrajectoryStateOnDet pTSOD = seed.startingState();
437  DetId SeedDetId(pTSOD.detId());
438  const GeomDet* geoDet = theService->trackingGeometry()->idToDet(SeedDetId);
439  TrajectoryStateOnSurface SeedTSOS =
440  trajectoryStateTransform::transientState(pTSOD, &(geoDet->surface()), &*theService->magneticField());
441  GlobalVector mom = SeedTSOS.globalMomentum();
442 
443  return mom;
444 }
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
edm::ESHandle< MagneticField > magneticField() const
get the magnetic field
MuonServiceProxy * theService
const GeomDet * idToDet(DetId) const override
unsigned int detId() const
Definition: DetId.h:17
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
GlobalVector globalMomentum() const

◆ SeedPosition()

GlobalPoint MuonSeedCleaner::SeedPosition ( const TrajectorySeed seed)
private

retrieve seed global position

Definition at line 424 of file MuonSeedCleaner.cc.

References PTrajectoryStateOnDet::detId(), TrajectoryStateOnSurface::globalPosition(), GlobalTrackingGeometry::idToDet(), MuonServiceProxy::magneticField(), fileCollector::seed, theService, MuonServiceProxy::trackingGeometry(), and trajectoryStateTransform::transientState().

Referenced by GroupSeeds(), and seedCleaner().

424  {
425  PTrajectoryStateOnDet pTSOD = seed.startingState();
426  DetId SeedDetId(pTSOD.detId());
427  const GeomDet* geoDet = theService->trackingGeometry()->idToDet(SeedDetId);
428  TrajectoryStateOnSurface SeedTSOS =
429  trajectoryStateTransform::transientState(pTSOD, &(geoDet->surface()), &*theService->magneticField());
430  GlobalPoint pos = SeedTSOS.globalPosition();
431 
432  return pos;
433 }
edm::ESHandle< GlobalTrackingGeometry > trackingGeometry() const
get the tracking geometry
edm::ESHandle< MagneticField > magneticField() const
get the magnetic field
MuonServiceProxy * theService
const GeomDet * idToDet(DetId) const override
unsigned int detId() const
GlobalPoint globalPosition() const
Definition: DetId.h:17
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)

Member Data Documentation

◆ badSeedLayer

std::vector<int> MuonSeedCleaner::badSeedLayer

Definition at line 54 of file MuonSeedCleaner.h.

◆ debug

bool MuonSeedCleaner::debug
private

◆ ShoweringLayers

std::vector<int> MuonSeedCleaner::ShoweringLayers
private

Definition at line 97 of file MuonSeedCleaner.h.

◆ ShoweringSegments

SegmentContainer MuonSeedCleaner::ShoweringSegments
private

Definition at line 96 of file MuonSeedCleaner.h.

◆ theService

MuonServiceProxy* MuonSeedCleaner::theService
private