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::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Classes

struct  DecreasingGlobalY
 
struct  MuonRecHitPair
 

Public Member Functions

 CosmicMuonSeedGenerator (const edm::ParameterSet &)
 Constructor. More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 reconstruct muon's seeds More...
 
virtual ~CosmicMuonSeedGenerator ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
 

Private Attributes

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
 
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
 
TrajectoryStateTransformtheTSTransform
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

SeedGenerator for Cosmic Muon

Date:
2009/01/16 03:02:45
Revision:
1.2
Author
Chang Liu - Purdue University

Definition at line 27 of file CosmicMuonSeedGenerator.h.

Member Typedef Documentation

Definition at line 51 of file CosmicMuonSeedGenerator.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 47 of file CosmicMuonSeedGenerator.cc.

References edm::ParameterSet::getParameter().

47  {
48  produces<TrajectorySeedCollection>();
49 
50  // enable the DT chamber
51  theEnableDTFlag = pset.getParameter<bool>("EnableDTMeasurement");
52  // enable the CSC chamber
53  theEnableCSCFlag = pset.getParameter<bool>("EnableCSCMeasurement");
54 
55  theDTRecSegmentLabel = pset.getParameter<InputTag>("DTRecSegmentLabel");
56 
57  theCSCRecSegmentLabel = pset.getParameter<InputTag>("CSCRecSegmentLabel");
58 
59  // the maximum number of TrajectorySeed
60  theMaxSeeds = pset.getParameter<int>("MaxSeeds");
61 
62  theMaxDTChi2 = pset.getParameter<double>("MaxDTChi2");
63  theMaxCSCChi2 = pset.getParameter<double>("MaxCSCChi2");
64 
66 
67  // pre-determined parameters for seed pt calculation ( pt * dphi )
68  theParameters["topmb41"] = 0.87;
69  theParameters["bottommb41"] = 1.2;
70  theParameters["topmb42"] = 0.67;
71  theParameters["bottommb42"] = 0.98;
72  theParameters["topmb43"] = 0.34;
73  theParameters["bottommb43"] = 0.58;
74  theParameters["topmb31"] = 0.54;
75  theParameters["bottommb31"] = 0.77;
76  theParameters["topmb32"] = 0.35;
77  theParameters["bottommb32"] = 0.55;
78  theParameters["topmb21"] = 0.21;
79  theParameters["bottommb21"] = 0.31;
80 
81 }
T getParameter(std::string const &) const
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
TrajectoryStateTransform * theTSTransform
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 84 of file CosmicMuonSeedGenerator.cc.

84  {
85  delete theTSTransform;
86 }
TrajectoryStateTransform * theTSTransform

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 364 of file CosmicMuonSeedGenerator.cc.

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

364  {
365  bool result = false;
366 
367  GlobalVector dir1 = lhs->globalDirection();
368  GlobalPoint pos1 = lhs->globalPosition();
369  GlobalVector dir2 = rhs->globalDirection();
370  GlobalPoint pos2 = rhs->globalPosition();
371 
372  GlobalVector dis = pos2 - pos1;
373 
374  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 )
375  && dis.mag() < 5.0 )
376  result = true;
377 
378  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 ) &&
379  (deltaR<double>(dir1.eta(), dir1.phi(), dis.eta(), dis.phi()) < 0.1 || deltaR<double>(dir2.eta(), dir2.phi(), dis.eta(), dis.phi()) < 0.1 ) )
380  result = true;
381 
382  if ( fabs(dir1.eta()) > 4.0 || fabs(dir2.eta()) > 4.0 ) {
383  if ( (fabs(dir1.theta() - dir2.theta()) < 0.07 ||
384  fabs(dir1.theta() + dir2.theta()) > 3.07 ) &&
385  (fabs(dir1.theta() - dis.theta()) < 0.07 ||
386  fabs(dir1.theta() - dis.theta()) < 0.07 ||
387  fabs(dir1.theta() + dis.theta()) > 3.07 ||
388  fabs(dir1.theta() + dis.theta()) > 3.07 ) )
389 
390  result = true;
391  }
392 
393  return result;
394 }
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
T mag() const
Definition: PV3DBase.h:61
tuple result
Definition: query.py:137
T eta() const
Definition: PV3DBase.h:70
bool CosmicMuonSeedGenerator::checkQuality ( const MuonTransientTrackingRecHit::MuonRecHitPointer hit) const
private

determine if a MuonTransientTrackingRecHit is qualified to build seed

Definition at line 202 of file CosmicMuonSeedGenerator.cc.

References category(), and LogTrace.

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

create TrajectorySeed from MuonTransientTrackingRecHit

Definition at line 303 of file CosmicMuonSeedGenerator.cc.

References category(), DeDxDiscriminatorTools::charge(), MuonSubdetId::CSC, MuonSubdetId::DT, MuonPatternRecoDumper::dumpMuonId(), error, LogTrace, PV3DBase< T, PVType, FrameType >::perp(), ExpressReco_HICollisions_FallBack::pt, query::result, and matplotRender::t.

303  {
304 
305  std::vector<TrajectorySeed> result;
306 
307  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
308 
309  MuonPatternRecoDumper dumper;
310 
311  // set the pt by hand
312  double pt = 10.0;
313 
314  AlgebraicVector t(4);
315  AlgebraicSymMatrix mat(5,0) ;
316 
317  // Fill the LocalTrajectoryParameters
318  LocalPoint segPos=hit->localPosition();
319 
320  GlobalVector polar(GlobalVector::Spherical(hit->globalDirection().theta(),
321  hit->globalDirection().phi(),
322  1.));
323  // Force all track downward for cosmic, not beam-halo
324  if (hit->geographicalId().subdetId() == MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 && hit->globalDirection().phi() > 0 )
325  polar = - polar;
326 
327  if (hit->geographicalId().subdetId() == MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3 ) {
328  polar = - polar;
329  }
330 
331  polar *=fabs(pt)/polar.perp();
332 
333  LocalVector segDir =hit->det()->toLocal(polar);
334 
335  int charge= 1;
336  LocalTrajectoryParameters param(segPos,segDir, charge);
337 
338  charge= -1;
339  LocalTrajectoryParameters param2(segPos,segDir, charge);
340 
341  mat = hit->parametersError().similarityT( hit->projectionMatrix() );
342 
343  float p_err = 0.2;
344  mat[0][0]= p_err;
345 
347 
348  // Create the TrajectoryStateOnSurface
349  TrajectoryStateOnSurface tsos(param, error, hit->det()->surface(), &*theField);
350  TrajectoryStateOnSurface tsos2(param2, error, hit->det()->surface(), &*theField);
351 
352  LogTrace(category)<<"Trajectory State on Surface of Seed";
353  LogTrace(category)<<"mom: "<<tsos.globalMomentum()<<" phi: "<<tsos.globalMomentum().phi();
354  LogTrace(category)<<"pos: " << tsos.globalPosition();
355  LogTrace(category) << "The RecSegment relies on: ";
356  LogTrace(category) << dumper.dumpMuonId(hit->geographicalId());
357 
358  result.push_back( tsosToSeed(tsos, hit->geographicalId().rawId()) );
359  result.push_back( tsosToSeed(tsos2, hit->geographicalId().rawId()) );
360 
361  return result;
362 }
T perp() const
Definition: PV3DBase.h:66
edm::ESHandle< MagneticField > theField
double charge(const std::vector< uint8_t > &Ampls)
std::string dumpMuonId(const DetId &id) const
static const int CSC
Definition: MuonSubdetId.h:15
tuple result
Definition: query.py:137
#define LogTrace(id)
CLHEP::HepVector AlgebraicVector
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
CLHEP::HepSymMatrix AlgebraicSymMatrix
static const int DT
Definition: MuonSubdetId.h:14
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 439 of file CosmicMuonSeedGenerator.cc.

References category(), DeDxDiscriminatorTools::charge(), MuonSubdetId::CSC, Geom::deltaPhi(), pat::helper::ParametrizationHelper::dimension(), MuonSubdetId::DT, MuonPatternRecoDumper::dumpMuonId(), ExpressReco_HICollisions_FallBack::e, error, CosmicMuonSeedGenerator::MuonRecHitPair::first, LogTrace, PV3DBase< T, PVType, FrameType >::perp(), ExpressReco_HICollisions_FallBack::pt, query::result, CosmicMuonSeedGenerator::MuonRecHitPair::second, matplotRender::t, and CosmicMuonSeedGenerator::MuonRecHitPair::type.

440  {
441  std::vector<TrajectorySeed> result;
442 
443  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
444 
445  MuonPatternRecoDumper dumper;
446 
447  float dphi = deltaPhi((hitpair.first)->globalDirection().phi(), (hitpair.second)->globalDirection().phi());
448 
449  LogTrace(category)<<"hitpair.type "<<hitpair.type;
450 
451  map<string, float>::const_iterator iterPar = theParameters.find(hitpair.type);
452  if ( iterPar == theParameters.end() ) {
453  return result;
454  }
455 
456  // set the pt and charge by dphi
457  int charge = (dphi > 0) ? -1 : 1;
458 
459  double pt = 999.0;
460  float paraC = (iterPar->second);
461 
462  if (fabs(dphi) > 1e-5) {
463  pt = paraC/fabs(dphi);
464  }
465 
466  if (pt < 10.0 ) { return result; } //still use the old strategy for low pt
467 
468  AlgebraicVector t(4);
469  AlgebraicSymMatrix mat(5,0) ;
470 
472  if ( hit->dimension() < (hitpair.second)->dimension() ) hit = hitpair.second;
473 
474  // Fill the LocalTrajectoryParameters
475  LocalPoint segPos=hit->localPosition();
476 
477  GlobalVector polar(GlobalVector::Spherical(hit->globalDirection().theta(),
478  hit->globalDirection().phi(),
479  1.));
480  // Force all track downward for cosmic, not beam-halo
481  if (hit->geographicalId().subdetId() == MuonSubdetId::DT && fabs(hit->globalDirection().eta()) < 4.0 && hit->globalDirection().phi() > 0 )
482  polar = - polar;
483 
484  if (hit->geographicalId().subdetId() == MuonSubdetId::CSC && fabs(hit->globalDirection().eta()) > 2.3 ) {
485  polar = - polar;
486  }
487 
488  polar *=fabs(pt)/polar.perp();
489 
490  LocalVector segDir =hit->det()->toLocal(polar);
491 
492  LocalTrajectoryParameters param(segPos,segDir, charge);
493 
494  mat = hit->parametersError().similarityT( hit->projectionMatrix() );
495 
496  float p_err = 0.004/paraC;
497  if (pt < 10.01) p_err = 0.1;
498  mat[0][0]= p_err;
499 
501 
502  // Create the TrajectoryStateOnSurface
503  TrajectoryStateOnSurface tsos(param, error, hit->det()->surface(), &*theField);
504 
505  LogTrace(category)<<"Trajectory State on Surface of Seed";
506  LogTrace(category)<<"mom: "<<tsos.globalMomentum()<<" phi: "<<tsos.globalMomentum().phi();
507  LogTrace(category)<<"pos: " << tsos.globalPosition();
508  LogTrace(category) << "The RecSegment relies on: ";
509  LogTrace(category) << dumper.dumpMuonId(hit->geographicalId());
510 
511  result.push_back( tsosToSeed(tsos, hit->geographicalId().rawId()) );
512 
513  return result;
514 }
T perp() const
Definition: PV3DBase.h:66
edm::ESHandle< MagneticField > theField
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
double charge(const std::vector< uint8_t > &Ampls)
std::string dumpMuonId(const DetId &id) const
static const int CSC
Definition: MuonSubdetId.h:15
tuple result
Definition: query.py:137
std::map< std::string, float > theParameters
#define LogTrace(id)
CLHEP::HepVector AlgebraicVector
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
CLHEP::HepSymMatrix AlgebraicSymMatrix
static const int DT
Definition: MuonSubdetId.h:14
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 270 of file CosmicMuonSeedGenerator.cc.

References category(), and LogTrace.

272  {
273 
274  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
275 
276  if (hits.size() == 0 || results.size() >= theMaxSeeds ) return;
277  for (MuonRecHitContainer::const_iterator ihit = hits.begin(); ihit != hits.end(); ihit++) {
278  const std::vector<TrajectorySeed>& sds = createSeed((*ihit),eSetup);
279  LogTrace(category)<<"created seeds from rechit "<<sds.size();
280  results.insert(results.end(),sds.begin(),sds.end());
281  if ( results.size() >= theMaxSeeds ) break;
282  }
283  return;
284 }
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)
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
void CosmicMuonSeedGenerator::createSeeds ( TrajectorySeedCollection results,
const CosmicMuonSeedGenerator::MuonRecHitPairVector hits,
const edm::EventSetup eSetup 
) const
private

Definition at line 286 of file CosmicMuonSeedGenerator.cc.

References category(), and LogTrace.

288  {
289 
290  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
291 
292  if (hitpairs.size() == 0 || results.size() >= theMaxSeeds ) return;
293  for (CosmicMuonSeedGenerator::MuonRecHitPairVector::const_iterator ihitpair = hitpairs.begin(); ihitpair != hitpairs.end(); ihitpair++) {
294  const std::vector<TrajectorySeed>& sds = createSeed((*ihitpair),eSetup);
295  LogTrace(category)<<"created seeds from rechit "<<sds.size();
296  results.insert(results.end(),sds.begin(),sds.end());
297  if ( results.size() >= theMaxSeeds ) break;
298  }
299  return;
300 }
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)
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
bool CosmicMuonSeedGenerator::leftIsBetter ( const MuonTransientTrackingRecHit::MuonRecHitPointer lhs,
const MuonTransientTrackingRecHit::MuonRecHitPointer rhs 
) const
private

compare quality of two rechits

Definition at line 396 of file CosmicMuonSeedGenerator.cc.

References ExpressReco_HICollisions_FallBack::chi2.

397  {
398 
399  if ( (lhs->degreesOfFreedom() > rhs->degreesOfFreedom() ) ||
400  ( (lhs->degreesOfFreedom() == rhs->degreesOfFreedom() ) &&
401  (lhs)->chi2() < (rhs)->chi2() ) ) return true;
402  else return false;
403 
404 }
CosmicMuonSeedGenerator::MuonRecHitPairVector CosmicMuonSeedGenerator::makeSegPairs ( const MuonTransientTrackingRecHit::MuonRecHitContainer hits1,
const MuonTransientTrackingRecHit::MuonRecHitContainer hits2,
std::string  tag 
) const
private

Definition at line 408 of file CosmicMuonSeedGenerator.cc.

References category(), Geom::deltaPhi(), query::result, and GlobalPosition_Frontier_DevDB_cff::tag.

408  {
409 
411  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
412 
413  if (hits1.empty() || hits2.empty() ) return result;
414 
415  for (MuonRecHitContainer::const_iterator ihit1 = hits1.begin(); ihit1 != hits1.end(); ihit1++) {
416  if ( !checkQuality(*ihit1) ) continue;
417 
418  for (MuonRecHitContainer::const_iterator ihit2 = hits2.begin(); ihit2 != hits2.end(); ihit2++) {
419  if ( !checkQuality(*ihit2) ) continue;
420 
421  float dphi = deltaPhi((*ihit1)->globalPosition().phi(), (*ihit2)->globalPosition().phi());
422  if ( dphi < 0.5 ) {
423  if ((*ihit1)->globalPosition().y() > 0.0 && ( (*ihit1)->globalPosition().y() > (*ihit2)->globalPosition().y() ) ) {
424  std::string tag2 = "top"+tag;
425 
426  result.push_back(MuonRecHitPair(*ihit1, *ihit2, tag2));
427  } else if ((*ihit1)->globalPosition().y() < 0.0 && ( (*ihit1)->globalPosition().y() < (*ihit2)->globalPosition().y() ) ) {
428  std::string tag2 = "bottom"+tag;
429  result.push_back(MuonRecHitPair(*ihit2, *ihit1, tag2));
430 
431  }
432  }
433  }
434  }
435 
436  return result;
437 }
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
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
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
void CosmicMuonSeedGenerator::produce ( edm::Event event,
const edm::EventSetup eSetup 
)
virtual

reconstruct muon's seeds

Implements edm::EDProducer.

Definition at line 90 of file CosmicMuonSeedGenerator.cc.

References category(), edm::EventSetup::get(), LogTrace, convertSQLitetoXML_cfg::output, MuonDetLayerMeasurements::recHits(), and MuonDetLayerMeasurements::setEvent().

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

References category(), and query::result.

226  {
227 
229  const std::string category = "Muon|RecoMuon|CosmicMuonSeedGenerator";
230 
231  //Only select good quality Segments
232  for (MuonRecHitContainer::const_iterator hit = hits.begin(); hit != hits.end(); hit++) {
233  if ( checkQuality(*hit) ) result.push_back(*hit);
234  }
235 
236  if ( result.size() < 2 ) return result;
237 
238  MuonRecHitContainer result2;
239 
240  //avoid selecting Segments with similar direction
241  for (MuonRecHitContainer::iterator hit = result.begin(); hit != result.end(); hit++) {
242  if (*hit == 0) continue;
243  if ( !(*hit)->isValid() ) continue;
244  bool good = true;
245  GlobalVector dir1 = (*hit)->globalDirection();
246  GlobalPoint pos1 = (*hit)->globalPosition();
247  for (MuonRecHitContainer::iterator hit2 = hit + 1; hit2 != result.end(); hit2++) {
248  if (*hit2 == 0) continue;
249  if ( !(*hit2)->isValid() ) continue;
250 
251  //compare direction and position
252  GlobalVector dir2 = (*hit2)->globalDirection();
253  GlobalPoint pos2 = (*hit2)->globalPosition();
254  if ( !areCorrelated((*hit),(*hit2)) ) continue;
255 
256  if ( !leftIsBetter((*hit),(*hit2)) ) {
257  good = false;
258  } else (*hit2) = 0;
259  }
260 
261  if ( good ) result2.push_back(*hit);
262  }
263 
264  result.clear();
265 
266  return result2;
267 
268 }
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
static const std::string category("Muon|RecoMuon|L3MuonCandidateProducerFromMuons")
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
TrajectorySeed CosmicMuonSeedGenerator::tsosToSeed ( const TrajectoryStateOnSurface tsos,
uint32_t  id 
) const
private

Definition at line 516 of file CosmicMuonSeedGenerator.cc.

References alongMomentum.

516  {
517 
518  PTrajectoryStateOnDet *seedTSOS =
519  theTSTransform->persistentState(tsos, id);
520 
522  TrajectorySeed seed(*seedTSOS,container,alongMomentum);
523  delete seedTSOS;
524  return seed;
525 }
PTrajectoryStateOnDet * persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid) const
TrajectoryStateTransform * theTSTransform

Member Data Documentation

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 117 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 116 of file CosmicMuonSeedGenerator.h.

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

Definition at line 121 of file CosmicMuonSeedGenerator.h.

TrajectoryStateTransform* CosmicMuonSeedGenerator::theTSTransform
private

Definition at line 119 of file CosmicMuonSeedGenerator.h.