CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  DecreasingGlobalY
 
struct  MuonRecHitPair
 

Public Member Functions

 CosmicMuonSeedGenerator (const edm::ParameterSet &)
 Constructor. More...
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 reconstruct muon's seeds More...
 
virtual ~CosmicMuonSeedGenerator ()
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::vector
< MuonRecHitPair
MuonRecHitPairVector
 

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
< MuonDetLayerGeometry
theMuonLayers
 
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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

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(), edm::ParameterSet::getParameter(), and HLT_25ns14e33_v1_cff::InputTag.

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 
80  muonMeasurements = new MuonDetLayerMeasurements(theDTRecSegmentLabel,theCSCRecSegmentLabel,
81  InputTag(),iC,
82  theEnableDTFlag,theEnableCSCFlag,false);
83 
84 
85 
86 }
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
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
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 ( )
virtual

Destructor.

Definition at line 89 of file CosmicMuonSeedGenerator.cc.

89  {
90  if (muonMeasurements)
91  delete muonMeasurements;
92 }
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 372 of file CosmicMuonSeedGenerator.cc.

References GetRecoTauVFromDQM_MC_cff::dir2, PV3DBase< T, PVType, FrameType >::eta(), MuonTransientTrackingRecHit::globalDirection(), TValidTrackingRecHit::globalPosition(), PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::phi(), query::result, and PV3DBase< T, PVType, FrameType >::theta().

372  {
373  bool result = false;
374 
375  GlobalVector dir1 = lhs->globalDirection();
376  GlobalPoint pos1 = lhs->globalPosition();
378  GlobalPoint pos2 = rhs->globalPosition();
379 
380  GlobalVector dis = pos2 - pos1;
381 
382  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 )
383  && dis.mag() < 5.0 )
384  result = true;
385 
386  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 ) &&
387  (deltaR<double>(dir1.eta(), dir1.phi(), dis.eta(), dis.phi()) < 0.1 || deltaR<double>(dir2.eta(), dir2.phi(), dis.eta(), dis.phi()) < 0.1 ) )
388  result = true;
389 
390  if ( fabs(dir1.eta()) > 4.0 || fabs(dir2.eta()) > 4.0 ) {
391  if ( (fabs(dir1.theta() - dir2.theta()) < 0.07 ||
392  fabs(dir1.theta() + dir2.theta()) > 3.07 ) &&
393  (fabs(dir1.theta() - dis.theta()) < 0.07 ||
394  fabs(dir1.theta() - dis.theta()) < 0.07 ||
395  fabs(dir1.theta() + dis.theta()) > 3.07 ||
396  fabs(dir1.theta() + dis.theta()) > 3.07 ) )
397 
398  result = true;
399  }
400 
401  return result;
402 }
virtual GlobalVector globalDirection() const
Direction in 3D for segments, otherwise (0,0,0)
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
tuple result
Definition: query.py:137
T eta() const
Definition: PV3DBase.h:76
virtual GlobalPoint globalPosition() const
bool CosmicMuonSeedGenerator::checkQuality ( const MuonTransientTrackingRecHit::MuonRecHitPointer hit) const
private

determine if a MuonTransientTrackingRecHit is qualified to build seed

Definition at line 206 of file CosmicMuonSeedGenerator.cc.

References python.rootplot.argparse::category, MuonTransientTrackingRecHit::chi2(), GenericTransientTrackingRecHit::dimension(), MuonTransientTrackingRecHit::isCSC(), MuonTransientTrackingRecHit::isDT(), TrackingRecHit::isValid(), LogTrace, and AlCaHLTBitMon_QueryRunRegistry::string.

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

create TrajectorySeed from MuonTransientTrackingRecHit

Definition at line 307 of file CosmicMuonSeedGenerator.cc.

References python.rootplot.argparse::category, RecoTauCleanerPlugins::charge, TrackingRecHit::clone(), MuonSubdetId::CSC, TrackingRecHit::det(), MuonSubdetId::DT, MuonPatternRecoDumper::dumpMuonId(), relativeConstraints::error, PV3DBase< T, PVType, FrameType >::eta(), TrackingRecHit::geographicalId(), MuonTransientTrackingRecHit::globalDirection(), GenericTransientTrackingRecHit::hit(), GenericTransientTrackingRecHit::localPosition(), LogTrace, MuonTransientTrackingRecHit::parametersError(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), GenericTransientTrackingRecHit::projectionMatrix(), EnergyCorrector::pt, edm::OwnVector< T, P >::push_back(), DetId::rawId(), query::result, AlCaHLTBitMon_QueryRunRegistry::string, DetId::subdetId(), GeomDet::surface(), PV3DBase< T, PVType, FrameType >::theta(), and GeomDet::toLocal().

307  {
308 
309  std::vector<TrajectorySeed> result;
310 
311  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
312 
313  MuonPatternRecoDumper dumper;
314 
315  // set the pt by hand
316  double pt = 10.0;
317 
318  // AlgebraicVector4 t;
319  AlgebraicSymMatrix mat(5,0);
320 
321  // Fill the LocalTrajectoryParameters
322  LocalPoint segPos=hit->localPosition();
323 
325  hit->globalDirection().phi(),
326  1.));
327  // Force all track downward for cosmic, not beam-halo
329  if (hit->geographicalId().subdetId() == MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 && hit->globalDirection().phi() > 0 )
330  polar = - polar;
331 
332  if (hit->geographicalId().subdetId() == MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3 )
333  polar = - polar;
334  }
335 
336  polar *=fabs(pt)/polar.perp();
337 
338  LocalVector segDir =hit->det()->toLocal(polar);
339 
340  int charge= 1;
341  LocalTrajectoryParameters param(segPos,segDir, charge);
342 
343  charge= -1;
344  LocalTrajectoryParameters param2(segPos,segDir, charge);
345 
346  mat = hit->parametersError().similarityT( hit->projectionMatrix() );
347 
348  float p_err = 0.2;
349  mat[0][0]= p_err;
350 
351  LocalTrajectoryError error(asSMatrix<5>(mat));
352 
353  // Create the TrajectoryStateOnSurface
354  TrajectoryStateOnSurface tsos(param, error, hit->det()->surface(), &*theField);
355  TrajectoryStateOnSurface tsos2(param2, error, hit->det()->surface(), &*theField);
356 
357  LogTrace(category)<<"Trajectory State on Surface of Seed";
358  LogTrace(category)<<"mom: "<<tsos.globalMomentum()<<" phi: "<<tsos.globalMomentum().phi();
359  LogTrace(category)<<"pos: " << tsos.globalPosition();
360  LogTrace(category) << "The RecSegment relies on: ";
361  LogTrace(category) << dumper.dumpMuonId(hit->geographicalId());
362 
364  container.push_back(hit->hit()->clone());
365 
366  result.push_back( tsosToSeed(tsos, hit->geographicalId().rawId(), container) );
367  result.push_back( tsosToSeed(tsos2, hit->geographicalId().rawId(), container) );
368 
369  return result;
370 }
T perp() const
Definition: PV3DBase.h:72
edm::ESHandle< MagneticField > theField
virtual const TrackingRecHit * hit() const
virtual GlobalVector globalDirection() const
Direction in 3D for segments, otherwise (0,0,0)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
virtual LocalPoint localPosition() const override
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:67
virtual AlgebraicMatrix projectionMatrix() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
std::string dumpMuonId(const DetId &id) const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void push_back(D *&d)
Definition: OwnVector.h:280
static const int CSC
Definition: MuonSubdetId.h:13
const GeomDet * det() const
tuple result
Definition: query.py:137
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
#define LogTrace(id)
virtual TrackingRecHit * clone() const =0
T eta() const
Definition: PV3DBase.h:76
virtual AlgebraicSymMatrix parametersError() const override
CLHEP::HepSymMatrix AlgebraicSymMatrix
static const int DT
Definition: MuonSubdetId.h:12
DetId geographicalId() const
TrajectorySeed tsosToSeed(const TrajectoryStateOnSurface &, uint32_t) const
std::vector< TrajectorySeed > CosmicMuonSeedGenerator::createSeed ( const MuonRecHitPair hitpair,
const edm::EventSetup eSetup 
) const
private

create TrajectorySeed from MuonRecHitPair

Definition at line 447 of file CosmicMuonSeedGenerator.cc.

References python.rootplot.argparse::category, RecoTauCleanerPlugins::charge, TrackingRecHit::clone(), MuonSubdetId::CSC, SiPixelRawToDigiRegional_cfi::deltaPhi, TrackingRecHit::det(), pat::helper::ParametrizationHelper::dimension(), GenericTransientTrackingRecHit::dimension(), MuonSubdetId::DT, MuonPatternRecoDumper::dumpMuonId(), alignCSCRings::e, relativeConstraints::error, PV3DBase< T, PVType, FrameType >::eta(), CosmicMuonSeedGenerator::MuonRecHitPair::first, TrackingRecHit::geographicalId(), MuonTransientTrackingRecHit::globalDirection(), GenericTransientTrackingRecHit::hit(), GenericTransientTrackingRecHit::localPosition(), LogTrace, MuonTransientTrackingRecHit::parametersError(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), GenericTransientTrackingRecHit::projectionMatrix(), EnergyCorrector::pt, edm::OwnVector< T, P >::push_back(), DetId::rawId(), query::result, CosmicMuonSeedGenerator::MuonRecHitPair::second, AlCaHLTBitMon_QueryRunRegistry::string, DetId::subdetId(), GeomDet::surface(), tree::t, PV3DBase< T, PVType, FrameType >::theta(), GeomDet::toLocal(), and CosmicMuonSeedGenerator::MuonRecHitPair::type.

448  {
449  std::vector<TrajectorySeed> result;
450 
451  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
452 
453  MuonPatternRecoDumper dumper;
454 
455  float dphi = deltaPhi((hitpair.first)->globalDirection().phi(), (hitpair.second)->globalDirection().phi());
456 
457  LogTrace(category)<<"hitpair.type "<<hitpair.type;
458 
459  map<string, float>::const_iterator iterPar = theParameters.find(hitpair.type);
460  if ( iterPar == theParameters.end() ) {
461  return result;
462  }
463 
464  // set the pt and charge by dphi
465  int charge = (dphi > 0) ? -1 : 1;
466 
467  double pt = 999.0;
468  float paraC = (iterPar->second);
469 
470  if (fabs(dphi) > 1e-5) {
471  pt = paraC/fabs(dphi);
472  }
473 
474  if (pt < 10.0 ) { return result; } //still use the old strategy for low pt
475 
476  AlgebraicVector t(4);
477  AlgebraicSymMatrix mat(5,0) ;
478 
480  if ( hit->dimension() < (hitpair.second)->dimension() ) hit = hitpair.second;
481 
482  // Fill the LocalTrajectoryParameters
483  LocalPoint segPos=hit->localPosition();
484 
486  hit->globalDirection().phi(),
487  1.));
488  // Force all track downward for cosmic, not beam-halo
490  if (hit->geographicalId().subdetId() == MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 && hit->globalDirection().phi() > 0 )
491  polar = - polar;
492 
493  if (hit->geographicalId().subdetId() == MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3 )
494  polar = - polar;
495  }
496 
497  polar *=fabs(pt)/polar.perp();
498 
499  LocalVector segDir =hit->det()->toLocal(polar);
500 
501  LocalTrajectoryParameters param(segPos,segDir, charge);
502 
503  mat = hit->parametersError().similarityT( hit->projectionMatrix() );
504 
505  float p_err = 0.004/paraC;
506  if (pt < 10.01) p_err = 0.1;
507  mat[0][0]= p_err;
508 
509  LocalTrajectoryError error(asSMatrix<5>(mat));
510 
511  // Create the TrajectoryStateOnSurface
512  TrajectoryStateOnSurface tsos(param, error, hit->det()->surface(), &*theField);
513 
514  LogTrace(category)<<"Trajectory State on Surface of Seed";
515  LogTrace(category)<<"mom: "<<tsos.globalMomentum()<<" phi: "<<tsos.globalMomentum().phi();
516  LogTrace(category)<<"pos: " << tsos.globalPosition();
517  LogTrace(category) << "The RecSegment relies on: ";
518  LogTrace(category) << dumper.dumpMuonId(hit->geographicalId());
519 
521  container.push_back(hitpair.first->hit()->clone());
522  container.push_back(hitpair.second->hit()->clone());
523 
524  result.push_back( tsosToSeed(tsos, hit->geographicalId().rawId(), container) );
525 
526  return result;
527 }
tuple t
Definition: tree.py:139
T perp() const
Definition: PV3DBase.h:72
edm::ESHandle< MagneticField > theField
virtual GlobalVector globalDirection() const
Direction in 3D for segments, otherwise (0,0,0)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
virtual LocalPoint localPosition() const override
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:67
virtual AlgebraicMatrix projectionMatrix() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
std::string dumpMuonId(const DetId &id) const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
void push_back(D *&d)
Definition: OwnVector.h:280
static const int CSC
Definition: MuonSubdetId.h:13
const GeomDet * det() const
tuple result
Definition: query.py:137
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::map< std::string, float > theParameters
#define LogTrace(id)
CLHEP::HepVector AlgebraicVector
T eta() const
Definition: PV3DBase.h:76
virtual AlgebraicSymMatrix parametersError() const override
CLHEP::HepSymMatrix AlgebraicSymMatrix
static const int DT
Definition: MuonSubdetId.h:12
DetId geographicalId() const
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)
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 274 of file CosmicMuonSeedGenerator.cc.

References python.rootplot.argparse::category, LogTrace, and AlCaHLTBitMon_QueryRunRegistry::string.

276  {
277 
278  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
279 
280  if (hits.size() == 0 || results.size() >= theMaxSeeds ) return;
281  for (MuonRecHitContainer::const_iterator ihit = hits.begin(); ihit != hits.end(); ihit++) {
282  const std::vector<TrajectorySeed>& sds = createSeed((*ihit),eSetup);
283  LogTrace(category)<<"created seeds from rechit "<<sds.size();
284  results.insert(results.end(),sds.begin(),sds.end());
285  if ( results.size() >= theMaxSeeds ) break;
286  }
287  return;
288 }
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 290 of file CosmicMuonSeedGenerator.cc.

References python.rootplot.argparse::category, LogTrace, and AlCaHLTBitMon_QueryRunRegistry::string.

292  {
293 
294  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
295 
296  if (hitpairs.size() == 0 || results.size() >= theMaxSeeds ) return;
297  for (CosmicMuonSeedGenerator::MuonRecHitPairVector::const_iterator ihitpair = hitpairs.begin(); ihitpair != hitpairs.end(); ihitpair++) {
298  const std::vector<TrajectorySeed>& sds = createSeed((*ihitpair),eSetup);
299  LogTrace(category)<<"created seeds from rechit "<<sds.size();
300  results.insert(results.end(),sds.begin(),sds.end());
301  if ( results.size() >= theMaxSeeds ) break;
302  }
303  return;
304 }
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 404 of file CosmicMuonSeedGenerator.cc.

References beam_dqm_sourceclient-live_cfg::chi2, and MuonTransientTrackingRecHit::degreesOfFreedom().

405  {
406 
407  if ( (lhs->degreesOfFreedom() > rhs->degreesOfFreedom() ) ||
408  ( (lhs->degreesOfFreedom() == rhs->degreesOfFreedom() ) &&
409  (lhs)->chi2() < (rhs)->chi2() ) ) return true;
410  else return false;
411 
412 }
virtual int degreesOfFreedom() const
Degrees of freedom for segments, else 0.
CosmicMuonSeedGenerator::MuonRecHitPairVector CosmicMuonSeedGenerator::makeSegPairs ( const MuonTransientTrackingRecHit::MuonRecHitContainer hits1,
const MuonTransientTrackingRecHit::MuonRecHitContainer hits2,
std::string  tag 
) const
private

Definition at line 416 of file CosmicMuonSeedGenerator.cc.

References python.rootplot.argparse::category, SiPixelRawToDigiRegional_cfi::deltaPhi, query::result, AlCaHLTBitMon_QueryRunRegistry::string, and GlobalPosition_Frontier_DevDB_cff::tag.

416  {
417 
419  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
420 
421  if (hits1.empty() || hits2.empty() ) return result;
422 
423  for (MuonRecHitContainer::const_iterator ihit1 = hits1.begin(); ihit1 != hits1.end(); ihit1++) {
424  if ( !checkQuality(*ihit1) ) continue;
425 
426  for (MuonRecHitContainer::const_iterator ihit2 = hits2.begin(); ihit2 != hits2.end(); ihit2++) {
427  if ( !checkQuality(*ihit2) ) continue;
428 
429  float dphi = deltaPhi((*ihit1)->globalPosition().phi(), (*ihit2)->globalPosition().phi());
430  if ( dphi < 0.5 ) {
431  if ((*ihit1)->globalPosition().y() > 0.0 && ( (*ihit1)->globalPosition().y() > (*ihit2)->globalPosition().y() ) ) {
432  std::string tag2 = "top"+tag;
433 
434  result.push_back(MuonRecHitPair(*ihit1, *ihit2, tag2));
435  } else if ((*ihit1)->globalPosition().y() < 0.0 && ( (*ihit1)->globalPosition().y() < (*ihit2)->globalPosition().y() ) ) {
436  std::string tag2 = "bottom"+tag;
437  result.push_back(MuonRecHitPair(*ihit2, *ihit1, tag2));
438 
439  }
440  }
441  }
442  }
443 
444  return result;
445 }
tuple result
Definition: query.py:137
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 
)
overridevirtual

reconstruct muon's seeds

Implements edm::stream::EDProducerBase.

Definition at line 96 of file CosmicMuonSeedGenerator.cc.

References python.rootplot.argparse::category, edm::EventSetup::get(), LogTrace, convertSQLitetoXML_cfg::output, fileCollector::seed, and AlCaHLTBitMon_QueryRunRegistry::string.

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

select seed candidates from Segments in Event

Definition at line 230 of file CosmicMuonSeedGenerator.cc.

References python.rootplot.argparse::category, query::result, and AlCaHLTBitMon_QueryRunRegistry::string.

230  {
231 
233  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
234 
235  //Only select good quality Segments
236  for (MuonRecHitContainer::const_iterator hit = hits.begin(); hit != hits.end(); hit++) {
237  if ( checkQuality(*hit) ) result.push_back(*hit);
238  }
239 
240  if ( result.size() < 2 ) return result;
241 
242  MuonRecHitContainer result2;
243 
244  //avoid selecting Segments with similar direction
245  for (MuonRecHitContainer::iterator hit = result.begin(); hit != result.end(); hit++) {
246  if (*hit == 0) continue;
247  if ( !(*hit)->isValid() ) continue;
248  bool good = true;
249  //UNUSED: GlobalVector dir1 = (*hit)->globalDirection();
250  //UNUSED: GlobalPoint pos1 = (*hit)->globalPosition();
251  for (MuonRecHitContainer::iterator hit2 = hit + 1; hit2 != result.end(); hit2++) {
252  if (*hit2 == 0) continue;
253  if ( !(*hit2)->isValid() ) continue;
254 
255  //compare direction and position
256  //UNUSED: GlobalVector dir2 = (*hit2)->globalDirection();
257  //UNUSED: GlobalPoint pos2 = (*hit2)->globalPosition();
258  if ( !areCorrelated((*hit),(*hit2)) ) continue;
259 
260  if ( !leftIsBetter((*hit),(*hit2)) ) {
261  good = false;
262  } else (*hit2) = 0;
263  }
264 
265  if ( good ) result2.push_back(*hit);
266  }
267 
268  result.clear();
269 
270  return result2;
271 
272 }
bool areCorrelated(const MuonTransientTrackingRecHit::MuonRecHitPointer &, const MuonTransientTrackingRecHit::MuonRecHitPointer &) const
check if two rechits are correlated
tuple result
Definition: query.py:137
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 529 of file CosmicMuonSeedGenerator.cc.

529  {
530 
532  return tsosToSeed(tsos, id, container);
533 }
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 535 of file CosmicMuonSeedGenerator.cc.

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

535  {
536 
538  TrajectorySeed seed(seedTSOS,container,alongMomentum);
539  return seed;
540 }
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.