CMS 3D CMS Logo

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

#include <CosmicMuonSeedGenerator.h>

Inheritance diagram for CosmicMuonSeedGenerator:
edm::stream::EDProducer<>

Classes

struct  DecreasingGlobalY
 
struct  MuonRecHitPair
 

Public Member Functions

 CosmicMuonSeedGenerator (const edm::ParameterSet &)
 Constructor. More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 reconstruct muon's seeds More...
 
 ~CosmicMuonSeedGenerator () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Types

typedef std::vector< MuonRecHitPairMuonRecHitPairVector
 

Private Member Functions

bool areCorrelated (const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
 check if two rechits are correlated More...
 
bool checkQuality (const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
 determine if a MuonTransientTrackingRecHit is qualified to build seed More...
 
std::vector< TrajectorySeedcreateSeed (const MuonTransientTrackingRecHit::MuonRecHitPointer &, const edm::EventSetup &) const
 create TrajectorySeed from MuonTransientTrackingRecHit More...
 
std::vector< TrajectorySeedcreateSeed (const MuonRecHitPair &, const edm::EventSetup &) const
 create TrajectorySeed from MuonRecHitPair More...
 
void createSeeds (TrajectorySeedCollection &results, const MuonTransientTrackingRecHit::MuonRecHitContainer &hits, const edm::EventSetup &eSetup) const
 generate TrajectorySeeds and put them into results More...
 
void createSeeds (TrajectorySeedCollection &results, const CosmicMuonSeedGenerator::MuonRecHitPairVector &hits, const edm::EventSetup &eSetup) const
 
bool leftIsBetter (const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
 compare quality of two rechits More...
 
std::vector< MuonRecHitPairmakeSegPairs (const MuonTransientTrackingRecHit::MuonRecHitContainer &, const MuonTransientTrackingRecHit::MuonRecHitContainer &, std::string) const
 
MuonTransientTrackingRecHit::MuonRecHitContainer selectSegments (const MuonTransientTrackingRecHit::MuonRecHitContainer &) const
 select seed candidates from Segments in Event More...
 
TrajectorySeed tsosToSeed (const TrajectoryStateOnSurface &, uint32_t) const
 
TrajectorySeed tsosToSeed (const TrajectoryStateOnSurface &, uint32_t, edm::OwnVector< TrackingRecHit > &) const
 

Private Attributes

MuonDetLayerMeasurementsmuonMeasurements
 
edm::InputTag theCSCRecSegmentLabel
 the name of the CSC rec hits collection More...
 
edm::InputTag theDTRecSegmentLabel
 the name of the DT rec hits collection More...
 
bool theEnableCSCFlag
 enable CSCSegment Flag More...
 
bool theEnableDTFlag
 enable DT Segment Flag More...
 
edm::ESHandle< MagneticFieldtheField
 
bool theForcePointDownFlag
 
double theMaxCSCChi2
 
double theMaxDTChi2
 the maximum chi2 required for dt and csc rechits More...
 
unsigned int theMaxSeeds
 the maximum number of Seeds More...
 
edm::ESHandle< MuonDetLayerGeometrytheMuonLayers
 
std::map< std::string, float > theParameters
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

SeedGenerator for Cosmic Muon

Author
Chang Liu - Purdue University

Definition at line 26 of file CosmicMuonSeedGenerator.h.

Member Typedef Documentation

Definition at line 50 of file CosmicMuonSeedGenerator.h.

Constructor & Destructor Documentation

CosmicMuonSeedGenerator::CosmicMuonSeedGenerator ( const edm::ParameterSet pset)

Constructor.

Definition at line 44 of file CosmicMuonSeedGenerator.cc.

References edm::ParameterSet::existsAs(), and edm::ParameterSet::getParameter().

44  {
45  produces<TrajectorySeedCollection>();
46 
47  // enable the DT chamber
48  theEnableDTFlag = pset.getParameter<bool>("EnableDTMeasurement");
49  // enable the CSC chamber
50  theEnableCSCFlag = pset.getParameter<bool>("EnableCSCMeasurement");
51 
52  theDTRecSegmentLabel = pset.getParameter<InputTag>("DTRecSegmentLabel");
53 
54  theCSCRecSegmentLabel = pset.getParameter<InputTag>("CSCRecSegmentLabel");
55 
56  // the maximum number of TrajectorySeed
57  theMaxSeeds = pset.getParameter<int>("MaxSeeds");
58 
59  theMaxDTChi2 = pset.getParameter<double>("MaxDTChi2");
60  theMaxCSCChi2 = pset.getParameter<double>("MaxCSCChi2");
61 
62  theForcePointDownFlag = pset.existsAs<bool>("ForcePointDown") ? pset.getParameter<bool>("ForcePointDown") : true;
63 
64  // pre-determined parameters for seed pt calculation ( pt * dphi )
65  theParameters["topmb41"] = 0.87;
66  theParameters["bottommb41"] = 1.2;
67  theParameters["topmb42"] = 0.67;
68  theParameters["bottommb42"] = 0.98;
69  theParameters["topmb43"] = 0.34;
70  theParameters["bottommb43"] = 0.58;
71  theParameters["topmb31"] = 0.54;
72  theParameters["bottommb31"] = 0.77;
73  theParameters["topmb32"] = 0.35;
74  theParameters["bottommb32"] = 0.55;
75  theParameters["topmb21"] = 0.21;
76  theParameters["bottommb21"] = 0.31;
77 
78 
79  edm::ConsumesCollector iC = consumesCollector();
80  muonMeasurements = new MuonDetLayerMeasurements(theDTRecSegmentLabel,theCSCRecSegmentLabel,
81 
82  InputTag(),InputTag(),InputTag(),iC,
83  theEnableDTFlag,theEnableCSCFlag,false,false,false);
84 
85 
86 
87 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
unsigned int theMaxSeeds
the maximum number of Seeds
double theMaxDTChi2
the maximum chi2 required for dt and csc rechits
edm::InputTag theDTRecSegmentLabel
the name of the DT rec hits collection
std::map< std::string, float > theParameters
MuonDetLayerMeasurements * muonMeasurements
bool theEnableCSCFlag
enable CSCSegment Flag
bool theEnableDTFlag
enable DT Segment Flag
edm::InputTag theCSCRecSegmentLabel
the name of the CSC rec hits collection
CosmicMuonSeedGenerator::~CosmicMuonSeedGenerator ( )
override

Destructor.

Definition at line 90 of file CosmicMuonSeedGenerator.cc.

90  {
91  if (muonMeasurements)
92  delete muonMeasurements;
93 }
MuonDetLayerMeasurements * muonMeasurements

Member Function Documentation

bool CosmicMuonSeedGenerator::areCorrelated ( const MuonTransientTrackingRecHit::MuonRecHitPointer lhs,
const MuonTransientTrackingRecHit::MuonRecHitPointer rhs 
) const
private

check if two rechits are correlated

Definition at line 373 of file CosmicMuonSeedGenerator.cc.

References GetRecoTauVFromDQM_MC_cff::dir2, PV3DBase< T, PVType, FrameType >::eta(), PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::phi(), mps_fire::result, and PV3DBase< T, PVType, FrameType >::theta().

373  {
374  bool result = false;
375 
376  GlobalVector dir1 = lhs->globalDirection();
377  GlobalPoint pos1 = lhs->globalPosition();
378  GlobalVector dir2 = rhs->globalDirection();
379  GlobalPoint pos2 = rhs->globalPosition();
380 
381  GlobalVector dis = pos2 - pos1;
382 
383  if ( (deltaR<double>(dir1.eta(), dir1.phi(), dir2.eta(), dir2.phi()) < 0.1 || deltaR<double>(dir1.eta(), dir1.phi(), -dir2.eta(), -dir2.phi()) < 0.1 )
384  && dis.mag() < 5.0 )
385  result = true;
386 
387  if ( (deltaR<double>(dir1.eta(), dir1.phi(), dir2.eta(), dir2.phi()) < 0.1 || deltaR<double>(dir1.eta(), dir1.phi(), -dir2.eta(), -dir2.phi()) < 0.1 ) &&
388  (deltaR<double>(dir1.eta(), dir1.phi(), dis.eta(), dis.phi()) < 0.1 || deltaR<double>(dir2.eta(), dir2.phi(), dis.eta(), dis.phi()) < 0.1 ) )
389  result = true;
390 
391  if ( fabs(dir1.eta()) > 4.0 || fabs(dir2.eta()) > 4.0 ) {
392  if ( (fabs(dir1.theta() - dir2.theta()) < 0.07 ||
393  fabs(dir1.theta() + dir2.theta()) > 3.07 ) &&
394  (fabs(dir1.theta() - dis.theta()) < 0.07 ||
395  fabs(dir1.theta() - dis.theta()) < 0.07 ||
396  fabs(dir1.theta() + dis.theta()) > 3.07 ||
397  fabs(dir1.theta() + dis.theta()) > 3.07 ) )
398 
399  result = true;
400  }
401 
402  return result;
403 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T mag() const
Definition: PV3DBase.h:67
T eta() const
Definition: PV3DBase.h:76
bool CosmicMuonSeedGenerator::checkQuality ( const MuonTransientTrackingRecHit::MuonRecHitPointer hit) const
private

determine if a MuonTransientTrackingRecHit is qualified to build seed

Definition at line 207 of file CosmicMuonSeedGenerator.cc.

References taus_updatedMVAIds_cff::category, LogTrace, and AlCaHLTBitMon_QueryRunRegistry::string.

207  {
208 
209  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
210 
211  // only use 4D segments
212  if ( !hit->isValid() ) return false;
213 
214  if (hit->dimension() < 4) {
215  LogTrace(category)<<"dim < 4";
216  return false;
217  }
218 
219  if (hit->isDT() && ( hit->chi2()> theMaxDTChi2 )) {
220  LogTrace(category)<<"DT chi2 too large";
221  return false;
222  }
223  else if (hit->isCSC() &&( hit->chi2()> theMaxCSCChi2 ) ) {
224  LogTrace(category)<<"CSC chi2 too large";
225  return false;
226  }
227  return true;
228 
229 }
double theMaxDTChi2
the maximum chi2 required for dt and csc rechits
#define LogTrace(id)
std::vector< TrajectorySeed > CosmicMuonSeedGenerator::createSeed ( const MuonTransientTrackingRecHit::MuonRecHitPointer hit,
const edm::EventSetup eSetup 
) const
private

create TrajectorySeed from MuonTransientTrackingRecHit

Definition at line 308 of file CosmicMuonSeedGenerator.cc.

References taus_updatedMVAIds_cff::category, ALCARECOTkAlJpsiMuMu_cff::charge, MuonSubdetId::CSC, MuonSubdetId::DT, MuonPatternRecoDumper::dumpMuonId(), relativeConstraints::error, LogTrace, PV3DBase< T, PVType, FrameType >::perp(), EnergyCorrector::pt, edm::OwnVector< T, P >::push_back(), mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

308  {
309 
310  std::vector<TrajectorySeed> result;
311 
312  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
313 
314  MuonPatternRecoDumper dumper;
315 
316  // set the pt by hand
317  double pt = 10.0;
318 
319  // AlgebraicVector4 t;
320  AlgebraicSymMatrix mat(5,0);
321 
322  // Fill the LocalTrajectoryParameters
323  LocalPoint segPos=hit->localPosition();
324 
325  GlobalVector polar(GlobalVector::Spherical(hit->globalDirection().theta(),
326  hit->globalDirection().phi(),
327  1.));
328  // Force all track downward for cosmic, not beam-halo
330  if (hit->geographicalId().subdetId() == MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 && hit->globalDirection().phi() > 0 )
331  polar = - polar;
332 
333  if (hit->geographicalId().subdetId() == MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3 )
334  polar = - polar;
335  }
336 
337  polar *=fabs(pt)/polar.perp();
338 
339  LocalVector segDir =hit->det()->toLocal(polar);
340 
341  int charge= 1;
342  LocalTrajectoryParameters param(segPos,segDir, charge);
343 
344  charge= -1;
345  LocalTrajectoryParameters param2(segPos,segDir, charge);
346 
347  mat = hit->parametersError().similarityT( hit->projectionMatrix() );
348 
349  float p_err = 0.2;
350  mat[0][0]= p_err;
351 
352  LocalTrajectoryError error(asSMatrix<5>(mat));
353 
354  // Create the TrajectoryStateOnSurface
355  TrajectoryStateOnSurface tsos(param, error, hit->det()->surface(), &*theField);
356  TrajectoryStateOnSurface tsos2(param2, error, hit->det()->surface(), &*theField);
357 
358  LogTrace(category)<<"Trajectory State on Surface of Seed";
359  LogTrace(category)<<"mom: "<<tsos.globalMomentum()<<" phi: "<<tsos.globalMomentum().phi();
360  LogTrace(category)<<"pos: " << tsos.globalPosition();
361  LogTrace(category) << "The RecSegment relies on: ";
362  LogTrace(category) << dumper.dumpMuonId(hit->geographicalId());
363 
365  container.push_back(hit->hit()->clone());
366 
367  result.push_back( tsosToSeed(tsos, hit->geographicalId().rawId(), container) );
368  result.push_back( tsosToSeed(tsos2, hit->geographicalId().rawId(), container) );
369 
370  return result;
371 }
T perp() const
Definition: PV3DBase.h:72
edm::ESHandle< MagneticField > theField
std::string dumpMuonId(const DetId &id) const
void push_back(D *&d)
Definition: OwnVector.h:290
#define LogTrace(id)
CLHEP::HepSymMatrix AlgebraicSymMatrix
static constexpr int DT
Definition: MuonSubdetId.h:12
TrajectorySeed tsosToSeed(const TrajectoryStateOnSurface &, uint32_t) const
static constexpr int CSC
Definition: MuonSubdetId.h:13
std::vector< TrajectorySeed > CosmicMuonSeedGenerator::createSeed ( const MuonRecHitPair hitpair,
const edm::EventSetup eSetup 
) const
private

create TrajectorySeed from MuonRecHitPair

Definition at line 448 of file CosmicMuonSeedGenerator.cc.

References taus_updatedMVAIds_cff::category, ALCARECOTkAlJpsiMuMu_cff::charge, MuonSubdetId::CSC, hiPixelPairStep_cff::deltaPhi, pat::helper::ParametrizationHelper::dimension(), MuonSubdetId::DT, MuonPatternRecoDumper::dumpMuonId(), MillePedeFileConverter_cfg::e, relativeConstraints::error, CosmicMuonSeedGenerator::MuonRecHitPair::first, LogTrace, PV3DBase< T, PVType, FrameType >::perp(), EnergyCorrector::pt, edm::OwnVector< T, P >::push_back(), mps_fire::result, CosmicMuonSeedGenerator::MuonRecHitPair::second, AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, and CosmicMuonSeedGenerator::MuonRecHitPair::type.

449  {
450  std::vector<TrajectorySeed> result;
451 
452  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
453 
454  MuonPatternRecoDumper dumper;
455 
456  float dphi = deltaPhi((hitpair.first)->globalDirection().barePhi(), (hitpair.second)->globalDirection().barePhi());
457 
458  LogTrace(category)<<"hitpair.type "<<hitpair.type;
459 
460  map<string, float>::const_iterator iterPar = theParameters.find(hitpair.type);
461  if ( iterPar == theParameters.end() ) {
462  return result;
463  }
464 
465  // set the pt and charge by dphi
466  int charge = (dphi > 0) ? -1 : 1;
467 
468  double pt = 999.0;
469  float paraC = (iterPar->second);
470 
471  if (fabs(dphi) > 1e-5) {
472  pt = paraC/fabs(dphi);
473  }
474 
475  if (pt < 10.0 ) { return result; } //still use the old strategy for low pt
476 
477  AlgebraicVector t(4);
478  AlgebraicSymMatrix mat(5,0) ;
479 
481  if ( hit->dimension() < (hitpair.second)->dimension() ) hit = hitpair.second;
482 
483  // Fill the LocalTrajectoryParameters
484  LocalPoint segPos=hit->localPosition();
485 
486  GlobalVector polar(GlobalVector::Spherical(hit->globalDirection().theta(),
487  hit->globalDirection().phi(),
488  1.));
489  // Force all track downward for cosmic, not beam-halo
491  if (hit->geographicalId().subdetId() == MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 && hit->globalDirection().phi() > 0 )
492  polar = - polar;
493 
494  if (hit->geographicalId().subdetId() == MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3 )
495  polar = - polar;
496  }
497 
498  polar *=fabs(pt)/polar.perp();
499 
500  LocalVector segDir =hit->det()->toLocal(polar);
501 
502  LocalTrajectoryParameters param(segPos,segDir, charge);
503 
504  mat = hit->parametersError().similarityT( hit->projectionMatrix() );
505 
506  float p_err = 0.004/paraC;
507  if (pt < 10.01) p_err = 0.1;
508  mat[0][0]= p_err;
509 
510  LocalTrajectoryError error(asSMatrix<5>(mat));
511 
512  // Create the TrajectoryStateOnSurface
513  TrajectoryStateOnSurface tsos(param, error, hit->det()->surface(), &*theField);
514 
515  LogTrace(category)<<"Trajectory State on Surface of Seed";
516  LogTrace(category)<<"mom: "<<tsos.globalMomentum()<<" phi: "<<tsos.globalMomentum().phi();
517  LogTrace(category)<<"pos: " << tsos.globalPosition();
518  LogTrace(category) << "The RecSegment relies on: ";
519  LogTrace(category) << dumper.dumpMuonId(hit->geographicalId());
520 
522  container.push_back(hitpair.first->hit()->clone());
523  container.push_back(hitpair.second->hit()->clone());
524 
525  result.push_back( tsosToSeed(tsos, hit->geographicalId().rawId(), container) );
526 
527  return result;
528 }
T perp() const
Definition: PV3DBase.h:72
edm::ESHandle< MagneticField > theField
std::string dumpMuonId(const DetId &id) const
void push_back(D *&d)
Definition: OwnVector.h:290
std::shared_ptr< MuonTransientTrackingRecHit > MuonRecHitPointer
std::map< std::string, float > theParameters
#define LogTrace(id)
CLHEP::HepVector AlgebraicVector
CLHEP::HepSymMatrix AlgebraicSymMatrix
static constexpr int DT
Definition: MuonSubdetId.h:12
TrajectorySeed tsosToSeed(const TrajectoryStateOnSurface &, uint32_t) const
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
static constexpr int CSC
Definition: MuonSubdetId.h:13
void CosmicMuonSeedGenerator::createSeeds ( TrajectorySeedCollection results,
const MuonTransientTrackingRecHit::MuonRecHitContainer hits,
const edm::EventSetup eSetup 
) const
private

generate TrajectorySeeds and put them into results

Definition at line 275 of file CosmicMuonSeedGenerator.cc.

References taus_updatedMVAIds_cff::category, LogTrace, and AlCaHLTBitMon_QueryRunRegistry::string.

277  {
278 
279  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
280 
281  if (hits.empty() || results.size() >= theMaxSeeds ) return;
282  for (MuonRecHitContainer::const_iterator ihit = hits.begin(); ihit != hits.end(); ihit++) {
283  const std::vector<TrajectorySeed>& sds = createSeed((*ihit),eSetup);
284  LogTrace(category)<<"created seeds from rechit "<<sds.size();
285  results.insert(results.end(),sds.begin(),sds.end());
286  if ( results.size() >= theMaxSeeds ) break;
287  }
288  return;
289 }
unsigned int theMaxSeeds
the maximum number of Seeds
std::vector< TrajectorySeed > createSeed(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const edm::EventSetup &) const
create TrajectorySeed from MuonTransientTrackingRecHit
#define LogTrace(id)
void CosmicMuonSeedGenerator::createSeeds ( TrajectorySeedCollection results,
const CosmicMuonSeedGenerator::MuonRecHitPairVector hits,
const edm::EventSetup eSetup 
) const
private

Definition at line 291 of file CosmicMuonSeedGenerator.cc.

References taus_updatedMVAIds_cff::category, LogTrace, and AlCaHLTBitMon_QueryRunRegistry::string.

293  {
294 
295  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
296 
297  if (hitpairs.empty() || results.size() >= theMaxSeeds ) return;
298  for (CosmicMuonSeedGenerator::MuonRecHitPairVector::const_iterator ihitpair = hitpairs.begin(); ihitpair != hitpairs.end(); ihitpair++) {
299  const std::vector<TrajectorySeed>& sds = createSeed((*ihitpair),eSetup);
300  LogTrace(category)<<"created seeds from rechit "<<sds.size();
301  results.insert(results.end(),sds.begin(),sds.end());
302  if ( results.size() >= theMaxSeeds ) break;
303  }
304  return;
305 }
unsigned int theMaxSeeds
the maximum number of Seeds
std::vector< TrajectorySeed > createSeed(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const edm::EventSetup &) const
create TrajectorySeed from MuonTransientTrackingRecHit
#define LogTrace(id)
bool CosmicMuonSeedGenerator::leftIsBetter ( const MuonTransientTrackingRecHit::MuonRecHitPointer lhs,
const MuonTransientTrackingRecHit::MuonRecHitPointer rhs 
) const
private

compare quality of two rechits

Definition at line 405 of file CosmicMuonSeedGenerator.cc.

References vertices_cff::chi2.

406  {
407 
408  if ( (lhs->degreesOfFreedom() > rhs->degreesOfFreedom() ) ||
409  ( (lhs->degreesOfFreedom() == rhs->degreesOfFreedom() ) &&
410  (lhs)->chi2() < (rhs)->chi2() ) ) return true;
411  else return false;
412 
413 }
CosmicMuonSeedGenerator::MuonRecHitPairVector CosmicMuonSeedGenerator::makeSegPairs ( const MuonTransientTrackingRecHit::MuonRecHitContainer hits1,
const MuonTransientTrackingRecHit::MuonRecHitContainer hits2,
std::string  tag 
) const
private

Definition at line 417 of file CosmicMuonSeedGenerator.cc.

References taus_updatedMVAIds_cff::category, hiPixelPairStep_cff::deltaPhi, mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, and GlobalPosition_Frontier_DevDB_cff::tag.

417  {
418 
420  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
421 
422  if (hits1.empty() || hits2.empty() ) return result;
423 
424  for (MuonRecHitContainer::const_iterator ihit1 = hits1.begin(); ihit1 != hits1.end(); ihit1++) {
425  if ( !checkQuality(*ihit1) ) continue;
426 
427  for (MuonRecHitContainer::const_iterator ihit2 = hits2.begin(); ihit2 != hits2.end(); ihit2++) {
428  if ( !checkQuality(*ihit2) ) continue;
429 
430  float dphi = deltaPhi((*ihit1)->globalPosition().barePhi(), (*ihit2)->globalPosition().barePhi());
431  if ( dphi < 0.5 ) {
432  if ((*ihit1)->globalPosition().y() > 0.0 && ( (*ihit1)->globalPosition().y() > (*ihit2)->globalPosition().y() ) ) {
433  std::string tag2 = "top"+tag;
434 
435  result.push_back(MuonRecHitPair(*ihit1, *ihit2, tag2));
436  } else if ((*ihit1)->globalPosition().y() < 0.0 && ( (*ihit1)->globalPosition().y() < (*ihit2)->globalPosition().y() ) ) {
437  std::string tag2 = "bottom"+tag;
438  result.push_back(MuonRecHitPair(*ihit2, *ihit1, tag2));
439 
440  }
441  }
442  }
443  }
444 
445  return result;
446 }
std::vector< MuonRecHitPair > MuonRecHitPairVector
bool checkQuality(const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
determine if a MuonTransientTrackingRecHit is qualified to build seed
void CosmicMuonSeedGenerator::produce ( edm::Event event,
const edm::EventSetup eSetup 
)
override

reconstruct muon's seeds

Definition at line 97 of file CosmicMuonSeedGenerator.cc.

References taus_updatedMVAIds_cff::category, edm::EventSetup::get(), LogTrace, eostools::move(), convertSQLitetoXML_cfg::output, SurveyInfoScenario_cff::seed, and AlCaHLTBitMon_QueryRunRegistry::string.

97  {
98 
99  eSetup.get<IdealMagneticFieldRecord>().get(theField);
100 
101  auto output = std::make_unique<TrajectorySeedCollection>();
102 
104 
105  std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
106 
107  // Muon Geometry - DT, CSC and RPC
109 
110  // get the DT layers
111  vector<const DetLayer*> dtLayers = theMuonLayers->allDTLayers();
112 
113  // get the CSC layers
114  vector<const DetLayer*> cscForwardLayers = theMuonLayers->forwardCSCLayers();
115  vector<const DetLayer*> cscBackwardLayers = theMuonLayers->backwardCSCLayers();
116 
117 
118 
119  muonMeasurements->setEvent(event);
120 
121  MuonRecHitContainer allHits;
122 
123  vector<MuonRecHitContainer> RHMBs;
124  vector<MuonRecHitContainer> RHMEFs;
125  vector<MuonRecHitContainer> RHMEBs;
126 
127  stable_sort(allHits.begin(),allHits.end(),DecreasingGlobalY());
128 
129  for (vector<const DetLayer*>::reverse_iterator icsclayer = cscForwardLayers.rbegin();
130  icsclayer != cscForwardLayers.rend() - 1; ++icsclayer) {
131 
132  MuonRecHitContainer RHMF = muonMeasurements->recHits(*icsclayer);
133  allHits.insert(allHits.end(),RHMF.begin(),RHMF.end());
134 
135  }
136 
137  for (vector<const DetLayer*>::reverse_iterator icsclayer = cscBackwardLayers.rbegin();
138  icsclayer != cscBackwardLayers.rend() - 1; ++icsclayer) {
139 
140  MuonRecHitContainer RHMF = muonMeasurements->recHits(*icsclayer);
141  allHits.insert(allHits.end(),RHMF.begin(),RHMF.end());
142 
143  }
144 
145  for (vector<const DetLayer*>::reverse_iterator idtlayer = dtLayers.rbegin();
146  idtlayer != dtLayers.rend(); ++idtlayer) {
147 
148  MuonRecHitContainer RHMB = muonMeasurements->recHits(*idtlayer);
149  RHMBs.push_back(RHMB);
150 
151  if ( idtlayer != dtLayers.rbegin() ) allHits.insert(allHits.end(),RHMB.begin(),RHMB.end());
152 
153  }
154 
155 // stable_sort(allHits.begin(),allHits.end(),DecreasingGlobalY());
156 
157  LogTrace(category)<<"all RecHits: "<<allHits.size();
158 
159 // CosmicMuonSeedGenerator::MuonRecHitPairVector mb41 = makeSegPairs(RHMBs[0], RHMBs[3], "mb41");
160 // createSeeds(seeds, mb41, eSetup);
161 
162 // CosmicMuonSeedGenerator::MuonRecHitPairVector mb43 = makeSegPairs(RHMBs[0],RHMBs[1], "mb43");
163 // createSeeds(seeds, mb43, eSetup);
164 
165  CosmicMuonSeedGenerator::MuonRecHitPairVector mb42 = makeSegPairs(RHMBs[0],RHMBs[2], "mb42");
166  createSeeds(seeds, mb42, eSetup);
167 
168 // CosmicMuonSeedGenerator::MuonRecHitPairVector mb32 = makeSegPairs(RHMBs[1], RHMBs[2], "mb32");
169 // createSeeds(seeds, mb32, eSetup);
170 
171  CosmicMuonSeedGenerator::MuonRecHitPairVector mb31 = makeSegPairs(RHMBs[1], RHMBs[3], "mb31");
172  createSeeds(seeds, mb31, eSetup);
173 
174 // CosmicMuonSeedGenerator::MuonRecHitPairVector mb21 = makeSegPairs(RHMBs[2], RHMBs[3], "mb21");
175 // createSeeds(seeds, mb21, eSetup);
176 
177  if ( !allHits.empty() ) {
178 
179  MuonRecHitContainer goodhits = selectSegments(allHits);
180  LogTrace(category)<<"good RecHits: "<<goodhits.size();
181 
182  if ( goodhits.empty() ) {
183  LogTrace(category)<<"No qualified Segments in Event! ";
184  LogTrace(category)<<"Use 2D RecHit";
185 
186  createSeeds(seeds,allHits,eSetup);
187 
188  }
189  else {
190  createSeeds(seeds,goodhits,eSetup);
191  }
192  }
193 
194  LogTrace(category)<<"Seeds built: "<<seeds.size();
195 
196  for(std::vector<TrajectorySeed>::iterator seed = seeds.begin();
197  seed != seeds.end(); ++seed) {
198  output->push_back(*seed);
199  }
200 
201  event.put(std::move(output));
202  seeds.clear();
203 
204 }
edm::ESHandle< MagneticField > theField
MuonTransientTrackingRecHit::MuonRecHitContainer selectSegments(const MuonTransientTrackingRecHit::MuonRecHitContainer &) const
select seed candidates from Segments in Event
std::vector< TrajectorySeed > TrajectorySeedCollection
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
edm::ESHandle< MuonDetLayerGeometry > theMuonLayers
#define LogTrace(id)
std::vector< MuonRecHitPair > MuonRecHitPairVector
MuonDetLayerMeasurements * muonMeasurements
const std::vector< const DetLayer * > & allDTLayers() const
return the DT DetLayers (barrel), inside-out
const std::vector< const DetLayer * > & forwardCSCLayers() const
return the forward (+Z) CSC DetLayers, inside-out
void setEvent(const edm::Event &)
set event
T get() const
Definition: EventSetup.h:63
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
const std::vector< const DetLayer * > & backwardCSCLayers() const
return the backward (-Z) CSC DetLayers, inside-out
std::vector< MuonRecHitPair > makeSegPairs(const MuonTransientTrackingRecHit::MuonRecHitContainer &, const MuonTransientTrackingRecHit::MuonRecHitContainer &, std::string) const
void createSeeds(TrajectorySeedCollection &results, const MuonTransientTrackingRecHit::MuonRecHitContainer &hits, const edm::EventSetup &eSetup) const
generate TrajectorySeeds and put them into results
def move(src, dest)
Definition: eostools.py:510
MuonRecHitContainer CosmicMuonSeedGenerator::selectSegments ( const MuonTransientTrackingRecHit::MuonRecHitContainer hits) const
private

select seed candidates from Segments in Event

Definition at line 231 of file CosmicMuonSeedGenerator.cc.

References taus_updatedMVAIds_cff::category, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

231  {
232 
234  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
235 
236  //Only select good quality Segments
237  for (MuonRecHitContainer::const_iterator hit = hits.begin(); hit != hits.end(); hit++) {
238  if ( checkQuality(*hit) ) result.push_back(*hit);
239  }
240 
241  if ( result.size() < 2 ) return result;
242 
243  MuonRecHitContainer result2;
244 
245  //avoid selecting Segments with similar direction
246  for (MuonRecHitContainer::iterator hit = result.begin(); hit != result.end(); hit++) {
247  if (*hit == nullptr) continue;
248  if ( !(*hit)->isValid() ) continue;
249  bool good = true;
250  //UNUSED: GlobalVector dir1 = (*hit)->globalDirection();
251  //UNUSED: GlobalPoint pos1 = (*hit)->globalPosition();
252  for (MuonRecHitContainer::iterator hit2 = hit + 1; hit2 != result.end(); hit2++) {
253  if (*hit2 == nullptr) continue;
254  if ( !(*hit2)->isValid() ) continue;
255 
256  //compare direction and position
257  //UNUSED: GlobalVector dir2 = (*hit2)->globalDirection();
258  //UNUSED: GlobalPoint pos2 = (*hit2)->globalPosition();
259  if ( !areCorrelated((*hit),(*hit2)) ) continue;
260 
261  if ( !leftIsBetter((*hit),(*hit2)) ) {
262  good = false;
263  } else (*hit2) = nullptr;
264  }
265 
266  if ( good ) result2.push_back(*hit);
267  }
268 
269  result.clear();
270 
271  return result2;
272 
273 }
bool areCorrelated(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
check if two rechits are correlated
bool leftIsBetter(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
compare quality of two rechits
bool checkQuality(const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
determine if a MuonTransientTrackingRecHit is qualified to build seed
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
TrajectorySeed CosmicMuonSeedGenerator::tsosToSeed ( const TrajectoryStateOnSurface tsos,
uint32_t  id 
) const
private

Definition at line 530 of file CosmicMuonSeedGenerator.cc.

530  {
531 
533  return tsosToSeed(tsos, id, container);
534 }
TrajectorySeed tsosToSeed(const TrajectoryStateOnSurface &, uint32_t) const
TrajectorySeed CosmicMuonSeedGenerator::tsosToSeed ( const TrajectoryStateOnSurface tsos,
uint32_t  id,
edm::OwnVector< TrackingRecHit > &  container 
) const
private

Definition at line 536 of file CosmicMuonSeedGenerator.cc.

References alongMomentum, trajectoryStateTransform::persistentState(), and SurveyInfoScenario_cff::seed.

536  {
537 
539  TrajectorySeed seed(seedTSOS,container,alongMomentum);
540  return seed;
541 }
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)

Member Data Documentation

MuonDetLayerMeasurements* CosmicMuonSeedGenerator::muonMeasurements
private

Definition at line 122 of file CosmicMuonSeedGenerator.h.

edm::InputTag CosmicMuonSeedGenerator::theCSCRecSegmentLabel
private

the name of the CSC rec hits collection

Definition at line 108 of file CosmicMuonSeedGenerator.h.

edm::InputTag CosmicMuonSeedGenerator::theDTRecSegmentLabel
private

the name of the DT rec hits collection

Definition at line 105 of file CosmicMuonSeedGenerator.h.

bool CosmicMuonSeedGenerator::theEnableCSCFlag
private

enable CSCSegment Flag

Definition at line 102 of file CosmicMuonSeedGenerator.h.

bool CosmicMuonSeedGenerator::theEnableDTFlag
private

enable DT Segment Flag

Definition at line 99 of file CosmicMuonSeedGenerator.h.

edm::ESHandle<MagneticField> CosmicMuonSeedGenerator::theField
private

Definition at line 118 of file CosmicMuonSeedGenerator.h.

bool CosmicMuonSeedGenerator::theForcePointDownFlag
private

Definition at line 116 of file CosmicMuonSeedGenerator.h.

double CosmicMuonSeedGenerator::theMaxCSCChi2
private

Definition at line 115 of file CosmicMuonSeedGenerator.h.

double CosmicMuonSeedGenerator::theMaxDTChi2
private

the maximum chi2 required for dt and csc rechits

Definition at line 114 of file CosmicMuonSeedGenerator.h.

unsigned int CosmicMuonSeedGenerator::theMaxSeeds
private

the maximum number of Seeds

Definition at line 111 of file CosmicMuonSeedGenerator.h.

edm::ESHandle<MuonDetLayerGeometry> CosmicMuonSeedGenerator::theMuonLayers
private

Definition at line 117 of file CosmicMuonSeedGenerator.h.

std::map<std::string, float> CosmicMuonSeedGenerator::theParameters
private

Definition at line 120 of file CosmicMuonSeedGenerator.h.