CMS 3D CMS Logo

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

#include <GlobalMuonRefitter.h>

Public Types

typedef MuonTransientTrackingRecHit::ConstMuonRecHitContainer ConstMuonRecHitContainer
 
typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer
 
typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
 
typedef TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
 
typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
 
typedef MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
 
typedef TransientTrackingRecHit::RecHitContainer RecHitContainer
 
typedef TransientTrackingRecHit::RecHitPointer RecHitPointer
 
enum  subDetector {
  PXB = 1, PXF = 2, TIB = 3, TID = 4,
  TOB = 5, TEC = 6
}
 
typedef std::vector< TrajectoryTC
 
typedef TC::const_iterator TI
 

Public Member Functions

const reco::DYTInfogetDYTInfo ()
 
ConstRecHitContainer getRidOfSelectStationHits (const ConstRecHitContainer &hits, const TrackerTopology *tTopo) const
 
 GlobalMuonRefitter (const edm::ParameterSet &, const MuonServiceProxy *, edm::ConsumesCollector &)
 constructor with Parameter Set and MuonServiceProxy More...
 
std::vector< Trajectoryrefit (const reco::Track &globalTrack, const int theMuonHitsOption, const TrackerTopology *tTopo) const
 build combined trajectory from sta Track and tracker RecHits More...
 
std::vector< Trajectoryrefit (const reco::Track &globalTrack, const reco::TransientTrack track, const TransientTrackingRecHit::ConstRecHitContainer &allRecHitsTemp, const int theMuonHitsOption, const TrackerTopology *tTopo) const
 build combined trajectory from subset of sta Track and tracker RecHits More...
 
virtual void setEvent (const edm::Event &)
 pass the Event to the algo at each event More...
 
void setServices (const edm::EventSetup &)
 set the services needed by the TrackTransformer More...
 
std::vector< Trajectorytransform (const reco::Track &newTrack, const reco::TransientTrack track, const TransientTrackingRecHit::ConstRecHitContainer &recHitsForReFit) const
 refit the track with a new set of RecHits More...
 
virtual ~GlobalMuonRefitter ()
 destructor More...
 

Protected Types

enum  RefitDirection { insideOut, outsideIn, undetermined }
 

Protected Member Functions

void checkMuonHits (const reco::Track &, ConstRecHitContainer &, std::map< DetId, int > &) const
 check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit More...
 
RefitDirection checkRecHitsOrdering (const ConstRecHitContainer &) const
 
void getFirstHits (const reco::Track &, ConstRecHitContainer &, ConstRecHitContainer &) const
 get the RecHits in the tracker and the first muon chamber with hits More...
 
void printHits (const ConstRecHitContainer &) const
 print all RecHits of a trajectory More...
 
ConstRecHitContainer selectMuonHits (const Trajectory &, const std::map< DetId, int > &) const
 select muon hits compatible with trajectory; check hits in chambers with showers More...
 
const MuonServiceProxyservice () const
 

Protected Attributes

std::string theCategory
 
float thePtCut
 
bool theTkTrajsAvailableFlag
 

Private Attributes

edm::Handle< DTRecSegment4DCollectionall4DSegments
 
edm::EDGetTokenT< DTRecSegment4DCollectionall4DSegmentsToken
 
edm::Handle< CSCSegmentCollectionCSCSegments
 
edm::EDGetTokenT< CSCSegmentCollectionCSCSegmentsToken
 
reco::DYTInfodytInfo
 
TkClonerImpl hitCloner
 
unsigned long long theCacheId_TRH
 
bool theCosmicFlag
 
float theCSCChi2Cut
 
edm::InputTag theCSCRecHitLabel
 
edm::Handle< CSCRecHit2DCollectiontheCSCRecHits
 
edm::EDGetTokenT< CSCRecHit2DCollectiontheCSCRecHitToken
 
float theDTChi2Cut
 
edm::InputTag theDTRecHitLabel
 
edm::Handle< DTRecHitCollectiontheDTRecHits
 
edm::EDGetTokenT< DTRecHitCollectiontheDTRecHitToken
 
int theDYTselector
 
std::vector< int > theDYTthrs
 
bool theDYTupdator
 
bool theDYTuseAPE
 
const edm::EventtheEvent
 
std::unique_ptr< TrajectoryFittertheFitter
 
std::string theFitterName
 
float theGEMChi2Cut
 
edm::InputTag theGEMRecHitLabel
 
edm::Handle< GEMRecHitCollectiontheGEMRecHits
 
edm::EDGetTokenT< GEMRecHitCollectiontheGEMRecHitToken
 
int theHitThreshold
 
float theME0Chi2Cut
 
edm::InputTag theME0RecHitLabel
 
edm::Handle< ME0SegmentCollectiontheME0RecHits
 
edm::EDGetTokenT< ME0SegmentCollectiontheME0RecHitToken
 
int theMuonHitsOption
 
edm::ESHandle< TransientTrackingRecHitBuildertheMuonRecHitBuilder
 
std::string theMuonRecHitBuilderName
 
float theProbCut
 
std::string thePropagatorName
 
RefitDirection theRefitDirection
 
double theRescaleErrorFactor
 
float theRPCChi2Cut
 
bool theRPCInTheFit
 
const MuonServiceProxytheService
 
int theSkipStation
 
edm::ESHandle< TransientTrackingRecHitBuildertheTrackerRecHitBuilder
 
std::string theTrackerRecHitBuilderName
 
int theTrackerSkipSection
 
int theTrackerSkipSystem
 

Detailed Description

class to build muon trajectory

Author
N. Neumeister Purdue University
C. Liu Purdue University
A. Everett Purdue University

by C. Calabria INFN & Universita  Bari by D. Nash Northeastern University

Definition at line 47 of file GlobalMuonRefitter.h.

Member Typedef Documentation

Definition at line 59 of file GlobalMuonRefitter.h.

Definition at line 57 of file GlobalMuonRefitter.h.

Definition at line 52 of file GlobalMuonRefitter.h.

Definition at line 54 of file GlobalMuonRefitter.h.

Definition at line 58 of file GlobalMuonRefitter.h.

Definition at line 56 of file GlobalMuonRefitter.h.

Definition at line 51 of file GlobalMuonRefitter.h.

Definition at line 53 of file GlobalMuonRefitter.h.

typedef std::vector<Trajectory> GlobalMuonRefitter::TC

Definition at line 61 of file GlobalMuonRefitter.h.

typedef TC::const_iterator GlobalMuonRefitter::TI

Definition at line 62 of file GlobalMuonRefitter.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

GlobalMuonRefitter::GlobalMuonRefitter ( const edm::ParameterSet par,
const MuonServiceProxy service,
edm::ConsumesCollector iC 
)

constructor with Parameter Set and MuonServiceProxy

Definition at line 75 of file GlobalMuonRefitter.cc.

References all4DSegmentsToken, edm::ConsumesCollector::consumes(), CSCSegmentsToken, dytInfo, Exception, edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), insideOut, outsideIn, theCacheId_TRH, theCategory, theCSCChi2Cut, theCSCRecHitLabel, theCSCRecHitToken, theDTChi2Cut, theDTRecHitLabel, theDTRecHitToken, theDYTselector, theDYTthrs, theDYTupdator, theDYTuseAPE, theFitterName, theGEMChi2Cut, theGEMRecHitLabel, theGEMRecHitToken, theHitThreshold, theME0Chi2Cut, theME0RecHitLabel, theME0RecHitToken, theMuonRecHitBuilderName, thePropagatorName, theRefitDirection, theRescaleErrorFactor, theRPCChi2Cut, theRPCInTheFit, theSkipStation, theTrackerRecHitBuilderName, theTrackerSkipSection, and theTrackerSkipSystem.

77  :
78  theCosmicFlag(par.getParameter<bool>("PropDirForCosmics")),
79  theDTRecHitLabel(par.getParameter<InputTag>("DTRecSegmentLabel")),
80  theCSCRecHitLabel(par.getParameter<InputTag>("CSCRecSegmentLabel")),
81  theGEMRecHitLabel(par.getParameter<InputTag>("GEMRecHitLabel")),
82  theME0RecHitLabel(par.getParameter<InputTag>("ME0RecHitLabel")),
84 
85  theCategory = par.getUntrackedParameter<string>("Category", "Muon|RecoMuon|GlobalMuon|GlobalMuonRefitter");
86 
87  theHitThreshold = par.getParameter<int>("HitThreshold");
88  theDTChi2Cut = par.getParameter<double>("Chi2CutDT");
89  theCSCChi2Cut = par.getParameter<double>("Chi2CutCSC");
90  theRPCChi2Cut = par.getParameter<double>("Chi2CutRPC");
91  theGEMChi2Cut = par.getParameter<double>("Chi2CutGEM");
92  theME0Chi2Cut = par.getParameter<double>("Chi2CutME0");
93 
94  // Refit direction
95  string refitDirectionName = par.getParameter<string>("RefitDirection");
96 
97  if (refitDirectionName == "insideOut" ) theRefitDirection = insideOut;
98  else if (refitDirectionName == "outsideIn" ) theRefitDirection = outsideIn;
99  else
100  throw cms::Exception("TrackTransformer constructor")
101  <<"Wrong refit direction chosen in TrackTransformer ParameterSet"
102  << "\n"
103  << "Possible choices are:"
104  << "\n"
105  << "RefitDirection = insideOut or RefitDirection = outsideIn";
106 
107  theFitterName = par.getParameter<string>("Fitter");
108  thePropagatorName = par.getParameter<string>("Propagator");
109 
110  theSkipStation = par.getParameter<int>("SkipStation");
111  theTrackerSkipSystem = par.getParameter<int>("TrackerSkipSystem");
112  theTrackerSkipSection = par.getParameter<int>("TrackerSkipSection");//layer, wheel, or disk depending on the system
113 
114  theTrackerRecHitBuilderName = par.getParameter<string>("TrackerRecHitBuilder");
115  theMuonRecHitBuilderName = par.getParameter<string>("MuonRecHitBuilder");
116 
117  theRPCInTheFit = par.getParameter<bool>("RefitRPCHits");
118 
119  theDYTthrs = par.getParameter< std::vector<int> >("DYTthrs");
120  theDYTselector = par.existsAs<int>("DYTselector")?par.getParameter<int>("DYTselector"):1;
121  theDYTupdator = par.existsAs<bool>("DYTupdator")?par.getParameter<bool>("DYTupdator"):false;
122  theDYTuseAPE = par.existsAs<bool>("DYTuseAPE")?par.getParameter<bool>("DYTuseAPE"):false;
123  dytInfo = new reco::DYTInfo();
124 
125  if (par.existsAs<double>("RescaleErrorFactor")) {
126  theRescaleErrorFactor = par.getParameter<double>("RescaleErrorFactor");
127  edm::LogWarning("GlobalMuonRefitter") << "using error rescale factor " << theRescaleErrorFactor;
128  }
129  else
130  theRescaleErrorFactor = 1000.;
131 
132  theCacheId_TRH = 0;
139 }
std::string theMuonRecHitBuilderName
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T 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
const MuonServiceProxy * theService
RefitDirection theRefitDirection
std::string thePropagatorName
edm::EDGetTokenT< CSCSegmentCollection > CSCSegmentsToken
std::vector< int > theDYTthrs
edm::EDGetTokenT< ME0SegmentCollection > theME0RecHitToken
edm::EDGetTokenT< DTRecHitCollection > theDTRecHitToken
edm::EDGetTokenT< CSCRecHit2DCollection > theCSCRecHitToken
edm::InputTag theDTRecHitLabel
edm::InputTag theGEMRecHitLabel
edm::InputTag theME0RecHitLabel
edm::EDGetTokenT< DTRecSegment4DCollection > all4DSegmentsToken
reco::DYTInfo * dytInfo
unsigned long long theCacheId_TRH
std::string theTrackerRecHitBuilderName
edm::InputTag theCSCRecHitLabel
edm::EDGetTokenT< GEMRecHitCollection > theGEMRecHitToken
GlobalMuonRefitter::~GlobalMuonRefitter ( )
virtual

destructor

Definition at line 145 of file GlobalMuonRefitter.cc.

References dytInfo.

145  {
146  delete dytInfo;
147 }
reco::DYTInfo * dytInfo

Member Function Documentation

void GlobalMuonRefitter::checkMuonHits ( const reco::Track muon,
ConstRecHitContainer all,
std::map< DetId, int > &  hitMap 
) const
protected

check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit

Definition at line 307 of file GlobalMuonRefitter.cc.

References alongMomentum, CSCDetId::chamberId(), ME0DetId::chamberId(), GEMDetId::chamberId(), highPtTrackIsolations_cff::coneSize, MuonSubdetId::CSC, MuonSubdetId::DT, MuonSubdetId::GEM, globals_cff::id1, LogTrace, mag(), MuonSubdetId::ME0, DetId::Muon, DetId::rawId(), MuonSubdetId::RPC, theCategory, theCSCRecHits, theDTRecHits, theGEMRecHits, and theME0RecHits.

Referenced by refit().

309  {
310 
311  LogTrace(theCategory) << " GlobalMuonRefitter::checkMuonHits " << endl;
312 
313  float coneSize = 20.0;
314 
315  // loop through all muon hits and calculate the maximum # of hits in each chamber
316  for (ConstRecHitContainer::const_iterator imrh = all.begin(); imrh != all.end(); imrh++ ) {
317 
318  if ( (*imrh != nullptr ) && !(*imrh)->isValid() ) continue;
319 
320  int detRecHits = 0;
321  MuonRecHitContainer dRecHits;
322 
323  DetId id = (*imrh)->geographicalId();
324  DetId chamberId;
325 
326  // Skip tracker hits
327  if (id.det()!=DetId::Muon) continue;
328 
329  if ( id.subdetId() == MuonSubdetId::DT ) {
330  DTChamberId did(id.rawId());
331  chamberId=did;
332 
333  if ((*imrh)->dimension()>1) {
334  std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
335  for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
336  if ((*hit2d)->dimension()>1) {
337  std::vector <const TrackingRecHit*> hits1d = (*hit2d)->recHits();
338  for (std::vector <const TrackingRecHit*>::const_iterator hit1d = hits1d.begin(); hit1d!= hits1d.end(); hit1d++) {
339  DetId id1 = (*hit1d)->geographicalId();
340  DTLayerId lid(id1.rawId());
341  // Get the 1d DT RechHits from this layer
342  DTRecHitCollection::range dRecHits = theDTRecHits->get(lid);
343  int layerHits=0;
344  for (DTRecHitCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
345  double rhitDistance = fabs(ir->localPosition().x()-(**hit1d).localPosition().x());
346  if ( rhitDistance < coneSize ) layerHits++;
347  LogTrace(theCategory) << " " << (ir)->localPosition() << " " << (**hit1d).localPosition()
348  << " Distance: " << rhitDistance << " recHits: " << layerHits << " SL: " << lid.superLayer() << endl;
349  }
350  if (layerHits>detRecHits) detRecHits=layerHits;
351  }
352  } else {
353  DTLayerId lid(id.rawId());
354  // Get the 1d DT RechHits from this layer
355  DTRecHitCollection::range dRecHits = theDTRecHits->get(lid);
356  for (DTRecHitCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
357  double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
358  if ( rhitDistance < coneSize ) detRecHits++;
359  LogTrace(theCategory)<< " " << (ir)->localPosition() << " " << (**imrh).localPosition()
360  << " Distance: " << rhitDistance << " recHits: " << detRecHits << endl;
361  }
362  }
363  }
364 
365  } else {
366  DTLayerId lid(id.rawId());
367 
368  // Get the 1d DT RechHits from this layer
369  DTRecHitCollection::range dRecHits = theDTRecHits->get(lid);
370 
371  for (DTRecHitCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
372  double rhitDistance = fabs(ir->localPosition().x()-(**imrh).localPosition().x());
373  if ( rhitDistance < coneSize ) detRecHits++;
374  LogTrace(theCategory) << " " << (ir)->localPosition() << " " << (**imrh).localPosition()
375  << " Distance: " << rhitDistance << " recHits: " << detRecHits << endl;
376  }
377  }
378  }// end of if DT
379  else if ( id.subdetId() == MuonSubdetId::CSC ) {
380  CSCDetId did(id.rawId());
381  chamberId=did.chamberId();
382 
383  if ((*imrh)->recHits().size()>1) {
384  std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
385  for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
386  DetId id1 = (*hit2d)->geographicalId();
387  CSCDetId lid(id1.rawId());
388 
389  // Get the CSC Rechits from this layer
390  CSCRecHit2DCollection::range dRecHits = theCSCRecHits->get(lid);
391  int layerHits=0;
392 
393  for (CSCRecHit2DCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
394  double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).mag();
395  if ( rhitDistance < coneSize ) layerHits++;
396  LogTrace(theCategory) << ir->localPosition() << " " << (**hit2d).localPosition()
397  << " Distance: " << rhitDistance << " recHits: " << layerHits << endl;
398  }
399  if (layerHits>detRecHits) detRecHits=layerHits;
400  }
401  } else {
402  // Get the CSC Rechits from this layer
403  CSCRecHit2DCollection::range dRecHits = theCSCRecHits->get(did);
404 
405  for (CSCRecHit2DCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
406  double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).mag();
407  if ( rhitDistance < coneSize ) detRecHits++;
408  LogTrace(theCategory) << ir->localPosition() << " " << (**imrh).localPosition()
409  << " Distance: " << rhitDistance << " recHits: " << detRecHits << endl;
410  }
411  }
412  } //end of CSC if
413  else if ( id.subdetId() == MuonSubdetId::GEM ) {
414  GEMDetId did(id.rawId());
415  chamberId=did.chamberId();
416 
417  if ((*imrh)->recHits().size()>1) {
418  std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
419  for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
420  DetId id1 = (*hit2d)->geographicalId();
421  GEMDetId lid(id1.rawId());
422 
423  // Get the GEM Rechits from this layer
424  GEMRecHitCollection::range dRecHits = theGEMRecHits->get(lid);
425  int layerHits=0;
426 
427  for (GEMRecHitCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
428  double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).mag();
429  if ( rhitDistance < coneSize ) layerHits++;
430  LogTrace(theCategory) << ir->localPosition() << " " << (**hit2d).localPosition()
431  << " Distance: " << rhitDistance << " recHits: " << layerHits << endl;
432  }
433  if (layerHits>detRecHits) detRecHits=layerHits;
434  }
435  } else {
436  // Get the GEM Rechits from this layer
437  GEMRecHitCollection::range dRecHits = theGEMRecHits->get(did);
438 
439  for (GEMRecHitCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
440  double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).mag();
441  if ( rhitDistance < coneSize ) detRecHits++;
442  LogTrace(theCategory) << ir->localPosition() << " " << (**imrh).localPosition()
443  << " Distance: " << rhitDistance << " recHits: " << detRecHits << endl;
444  }
445  }
446  } //end of GEM if
447  else if ( id.subdetId() == MuonSubdetId::ME0 ) {
448  ME0DetId did(id.rawId());
449  chamberId=did.chamberId();
450 
451  if ((*imrh)->recHits().size()>1) {
452  std::vector <const TrackingRecHit*> hits2d = (*imrh)->recHits();
453  for (std::vector <const TrackingRecHit*>::const_iterator hit2d = hits2d.begin(); hit2d!= hits2d.end(); hit2d++) {
454  DetId id1 = (*hit2d)->geographicalId();
455  ME0DetId lid(id1.rawId());
456 
457  // Get the ME0 Rechits from this layer
458  ME0SegmentCollection::range dRecHits = theME0RecHits->get(lid);
459  int layerHits=0;
460 
461  for (ME0SegmentCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
462  double rhitDistance = (ir->localPosition()-(**hit2d).localPosition()).mag();
463  if ( rhitDistance < coneSize ) layerHits++;
464  LogTrace(theCategory) << ir->localPosition() << " " << (**hit2d).localPosition()
465  << " Distance: " << rhitDistance << " recHits: " << layerHits << endl;
466  }
467  if (layerHits>detRecHits) detRecHits=layerHits;
468  }
469  } else {
470  // Get the ME0 Rechits from this layer
471  ME0SegmentCollection::range dRecHits = theME0RecHits->get(did);
472 
473  for (ME0SegmentCollection::const_iterator ir = dRecHits.first; ir != dRecHits.second; ir++ ) {
474  double rhitDistance = (ir->localPosition()-(**imrh).localPosition()).mag();
475  if ( rhitDistance < coneSize ) detRecHits++;
476  LogTrace(theCategory) << ir->localPosition() << " " << (**imrh).localPosition()
477  << " Distance: " << rhitDistance << " recHits: " << detRecHits << endl;
478  }
479  }
480  } //end of ME0 if
481  else {
482  if ( id.subdetId() != MuonSubdetId::RPC ) LogError(theCategory)<<" Wrong Hit Type ";
483  continue;
484  }
485 
486  map<DetId,int>::iterator imap=hitMap.find(chamberId);
487  if (imap!=hitMap.end()) {
488  if (detRecHits>imap->second) imap->second=detRecHits;
489  } else hitMap[chamberId]=detRecHits;
490 
491  } // end of loop over muon rechits
492 
493  for (map<DetId,int>::iterator imap=hitMap.begin(); imap!=hitMap.end(); imap++ )
494  LogTrace(theCategory) << " Station " << imap->first.rawId() << ": " << imap->second <<endl;
495 
496  LogTrace(theCategory) << "CheckMuonHits: "<<all.size();
497 
498  // check order of muon measurements
499  if ( (all.size() > 1) &&
500  ( all.front()->globalPosition().mag() >
501  all.back()->globalPosition().mag() ) ) {
502  LogTrace(theCategory)<< "reverse order: ";
503  stable_sort(all.begin(),all.end(),RecHitLessByDet(alongMomentum));
504  }
505 }
edm::Handle< DTRecHitCollection > theDTRecHits
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
static const int GEM
Definition: MuonSubdetId.h:15
edm::Handle< GEMRecHitCollection > theGEMRecHits
edm::Handle< ME0SegmentCollection > theME0RecHits
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
static const int ME0
Definition: MuonSubdetId.h:16
static const int CSC
Definition: MuonSubdetId.h:13
edm::Handle< CSCRecHit2DCollection > theCSCRecHits
#define LogTrace(id)
Definition: DetId.h:18
static const int RPC
Definition: MuonSubdetId.h:14
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
static const int DT
Definition: MuonSubdetId.h:12
GlobalMuonRefitter::RefitDirection GlobalMuonRefitter::checkRecHitsOrdering ( const ConstRecHitContainer recHits) const
protected

Definition at line 675 of file GlobalMuonRefitter.cc.

References insideOut, outsideIn, theCategory, and undetermined.

Referenced by transform().

675  {
676 
677  if (!recHits.empty()){
678  ConstRecHitContainer::const_iterator frontHit = recHits.begin();
679  ConstRecHitContainer::const_iterator backHit = recHits.end() - 1;
680  while( !(*frontHit)->isValid() && frontHit != backHit) {frontHit++;}
681  while( !(*backHit)->isValid() && backHit != frontHit) {backHit--;}
682 
683  double rFirst = (*frontHit)->globalPosition().mag();
684  double rLast = (*backHit) ->globalPosition().mag();
685 
686  if(rFirst < rLast) return insideOut;
687  else if(rFirst > rLast) return outsideIn;
688  else {
689  LogError(theCategory) << "Impossible determine the rechits order" <<endl;
690  return undetermined;
691  }
692  } else {
693  LogError(theCategory) << "Impossible determine the rechits order" <<endl;
694  return undetermined;
695  }
696 }
const reco::DYTInfo* GlobalMuonRefitter::getDYTInfo ( )
inline

Definition at line 101 of file GlobalMuonRefitter.h.

101 {return dytInfo;}
reco::DYTInfo * dytInfo
void GlobalMuonRefitter::getFirstHits ( const reco::Track muon,
ConstRecHitContainer all,
ConstRecHitContainer first 
) const
protected

get the RecHits in the tracker and the first muon chamber with hits

Definition at line 511 of file GlobalMuonRefitter.cc.

References MuonSubdetId::CSC, MuonSubdetId::DT, MuonSubdetId::GEM, mps_fire::i, LogTrace, MuonSubdetId::ME0, DetId::Muon, DetId::rawId(), MuonSubdetId::RPC, DTChamberId::station(), GEMDetId::station(), relativeConstraints::station, ME0DetId::station(), CSCDetId::station(), RPCDetId::station(), and theCategory.

Referenced by refit().

513  {
514 
515  LogTrace(theCategory) << " GlobalMuonRefitter::getFirstHits\nall rechits length:" << all.size() << endl;
516  first.clear();
517 
518  int station_to_keep = 999;
519  vector<int> stations;
520  for (ConstRecHitContainer::const_iterator ihit = all.begin(); ihit != all.end(); ++ihit) {
521 
522  int station = 0;
523  bool use_it = true;
524  DetId id = (*ihit)->geographicalId();
525  unsigned raw_id = id.rawId();
526  if (!(*ihit)->isValid()) station = -1;
527  else {
528  if (id.det() == DetId::Muon) {
529  switch (id.subdetId()) {
530  case MuonSubdetId::DT: station = DTChamberId(raw_id).station(); break;
531  case MuonSubdetId::CSC: station = CSCDetId(raw_id).station(); break;
532  case MuonSubdetId::GEM: station = GEMDetId(raw_id).station(); break;
533  case MuonSubdetId::ME0: station = ME0DetId(raw_id).station(); break;
534  case MuonSubdetId::RPC: station = RPCDetId(raw_id).station(); use_it = false; break;
535  }
536  }
537  }
538 
539 
540  if (use_it && station > 0 && station < station_to_keep) station_to_keep = station;
541  stations.push_back(station);
542  LogTrace(theCategory) << "rawId: " << raw_id << " station = " << station << " station_to_keep is now " << station_to_keep;
543  }
544 
545  if (station_to_keep <= 0 || station_to_keep > 4 || stations.size() != all.size())
546  LogInfo(theCategory) << "failed to getFirstHits (all muon hits are outliers/bad ?)! station_to_keep = "
547  << station_to_keep << " stations.size " << stations.size() << " all.size " << all.size();
548 
549  for (unsigned i = 0; i < stations.size(); ++i)
550  if (stations[i] >= 0 && stations[i] <= station_to_keep) first.push_back(all[i]);
551 
552  return;
553 }
static const int GEM
Definition: MuonSubdetId.h:15
int station() const
Definition: ME0DetId.h:76
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
static const int ME0
Definition: MuonSubdetId.h:16
static const int CSC
Definition: MuonSubdetId.h:13
int station() const
Station id : the station is the pair of chambers at same disk.
Definition: GEMDetId.h:64
#define LogTrace(id)
Definition: DetId.h:18
static const int RPC
Definition: MuonSubdetId.h:14
int station() const
Definition: CSCDetId.h:86
static const int DT
Definition: MuonSubdetId.h:12
int station() const
Return the station number.
Definition: DTChamberId.h:51
int station() const
Definition: RPCDetId.h:96
GlobalMuonRefitter::ConstRecHitContainer GlobalMuonRefitter::getRidOfSelectStationHits ( const ConstRecHitContainer hits,
const TrackerTopology tTopo 
) const

Definition at line 850 of file GlobalMuonRefitter.cc.

References MuonSubdetId::CSC, MuonSubdetId::DT, MuonSubdetId::GEM, MuonSubdetId::ME0, DetId::Muon, PXB, TrackerTopology::pxbLayer(), PXF, TrackerTopology::pxfDisk(), mps_update::results, MuonSubdetId::RPC, DTChamberId::station(), GEMDetId::station(), relativeConstraints::station, ME0DetId::station(), CSCDetId::station(), RPCDetId::station(), TEC, TrackerTopology::tecWheel(), theSkipStation, theTrackerSkipSection, theTrackerSkipSystem, TIB, TrackerTopology::tibLayer(), TID, TrackerTopology::tidWheel(), TOB, TrackerTopology::tobLayer(), DetId::Tracker, and makeMuonMisalignmentScenario::wheel.

Referenced by refit().

852 {
854  ConstRecHitContainer::const_iterator it = hits.begin();
855  for (; it!=hits.end(); it++) {
856 
857  DetId id = (*it)->geographicalId();
858 
859  //Check that this is a Muon hit that we're toying with -- else pass on this because the hacker is a moron / not careful
860 
861  if (id.det() == DetId::Tracker && theTrackerSkipSystem > 0) {
862  int layer = -999;
863  int disk = -999;
864  int wheel = -999;
865  if ( id.subdetId() == theTrackerSkipSystem){
866  // continue; //caveat that just removes the whole system from refitting
867 
868  if (theTrackerSkipSystem == PXB) {
869 
870  layer = tTopo->pxbLayer(id);
871  }
872  if (theTrackerSkipSystem == TIB) {
873 
874  layer = tTopo->tibLayer(id);
875  }
876 
877  if (theTrackerSkipSystem == TOB) {
878 
879  layer = tTopo->tobLayer(id);
880  }
881  if (theTrackerSkipSystem == PXF) {
882 
883  disk = tTopo->pxfDisk(id);
884  }
885  if (theTrackerSkipSystem == TID) {
886 
887  wheel = tTopo->tidWheel(id);
888  }
889  if (theTrackerSkipSystem == TEC) {
890 
891  wheel = tTopo->tecWheel(id);
892  }
893  if (theTrackerSkipSection >= 0 && layer == theTrackerSkipSection) continue;
894  if (theTrackerSkipSection >= 0 && disk == theTrackerSkipSection) continue;
895  if (theTrackerSkipSection >= 0 && wheel == theTrackerSkipSection) continue;
896  }
897  }
898 
899  if (id.det() == DetId::Muon && theSkipStation) {
900  int station = -999;
901  //UNUSED: int wheel = -999;
902  if ( id.subdetId() == MuonSubdetId::DT ) {
903  DTChamberId did(id.rawId());
904  station = did.station();
905  //UNUSED: wheel = did.wheel();
906  } else if ( id.subdetId() == MuonSubdetId::CSC ) {
907  CSCDetId did(id.rawId());
908  station = did.station();
909  } else if ( id.subdetId() == MuonSubdetId::GEM ) {
910  GEMDetId did(id.rawId());
911  station = did.station();
912  } else if ( id.subdetId() == MuonSubdetId::ME0 ) {
913  ME0DetId did(id.rawId());
914  station = did.station();
915  } else if ( id.subdetId() == MuonSubdetId::RPC ) {
916  RPCDetId rpcid(id.rawId());
917  station = rpcid.station();
918  }
919  if(station == theSkipStation) continue;
920  }
921  results.push_back(*it);
922  }
923  return results;
924 }
unsigned int tibLayer(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
static const int GEM
Definition: MuonSubdetId.h:15
unsigned int tidWheel(const DetId &id) const
static const int ME0
Definition: MuonSubdetId.h:16
static const int CSC
Definition: MuonSubdetId.h:13
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
static const int RPC
Definition: MuonSubdetId.h:14
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
static const int DT
Definition: MuonSubdetId.h:12
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
void GlobalMuonRefitter::printHits ( const ConstRecHitContainer hits) const
protected

print all RecHits of a trajectory

Definition at line 648 of file GlobalMuonRefitter.cc.

References LogTrace, mathSSE::sqrt(), theCategory, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ntuplePrintersDiff.TrackingParticlePrinter::__call__(), ntuplePrintersDiff.SeedPrinter::diff(), ntuplePrintersDiff.TrackPrinter::diff(), ntuplePrintersDiff.TrackingParticlePrinter::diff(), ntuplePrintersDiff.SeedPrinter::printSeed(), ntuplePrintersDiff.TrackPrinter::printTrack(), and transform().

648  {
649 
650  LogTrace(theCategory) << "Used RecHits: " << hits.size();
651  for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
652  if ( !(*ir)->isValid() ) {
653  LogTrace(theCategory) << "invalid RecHit";
654  continue;
655  }
656 
657  const GlobalPoint& pos = (*ir)->globalPosition();
658 
660  << "r = " << sqrt(pos.x() * pos.x() + pos.y() * pos.y())
661  << " z = " << pos.z()
662  << " dimension = " << (*ir)->dimension()
663  << " det = " << (*ir)->det()->geographicalId().det()
664  << " subdet = " << (*ir)->det()->subDetector()
665  << " raw id = " << (*ir)->det()->geographicalId().rawId();
666  }
667 
668 }
T y() const
Definition: PV3DBase.h:63
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
#define LogTrace(id)
T x() const
Definition: PV3DBase.h:62
vector< Trajectory > GlobalMuonRefitter::refit ( const reco::Track globalTrack,
const int  theMuonHitsOption,
const TrackerTopology tTopo 
) const

build combined trajectory from sta Track and tracker RecHits

Definition at line 188 of file GlobalMuonRefitter.cc.

References TransientTrackingRecHitBuilder::build(), LogTrace, DetId::Muon, edm::ESHandle< T >::product(), theCategory, theMuonRecHitBuilder, theRPCInTheFit, theService, theTrackerRecHitBuilder, HiIsolationCommonParameters_cff::track, and DetId::Tracker.

Referenced by GlobalTrajectoryBuilderBase::build(), and GlobalTrackQualityProducer::produce().

190  {
191  LogTrace(theCategory) << " *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
192 
193  ConstRecHitContainer allRecHitsTemp; // all muon rechits temp
194 
195  reco::TransientTrack track(globalTrack,&*(theService->magneticField()),theService->trackingGeometry());
196 
197  auto tkbuilder = static_cast<TkTransientTrackingRecHitBuilder const *>(theTrackerRecHitBuilder.product());
198 
199  for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit)
200  if ((*hit)->isValid()) {
201  if ((*hit)->geographicalId().det() == DetId::Tracker)
202  allRecHitsTemp.push_back((**hit).cloneForFit(*tkbuilder->geometry()->idToDet( (**hit).geographicalId() ) ) );
203  else if ((*hit)->geographicalId().det() == DetId::Muon) {
204  if ((*hit)->geographicalId().subdetId() == 3 && !theRPCInTheFit) {
205  LogTrace(theCategory) << "RPC Rec Hit discarged";
206  continue;
207  }
208  allRecHitsTemp.push_back(theMuonRecHitBuilder->build(&**hit));
209  }
210  }
211  vector<Trajectory> refitted = refit(globalTrack,track,allRecHitsTemp,theMuonHitsOption, tTopo);
212  return refitted;
213 }
const MuonServiceProxy * theService
edm::ESHandle< TransientTrackingRecHitBuilder > theTrackerRecHitBuilder
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
#define LogTrace(id)
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
T const * product() const
Definition: ESHandle.h:86
std::vector< Trajectory > refit(const reco::Track &globalTrack, const int theMuonHitsOption, const TrackerTopology *tTopo) const
build combined trajectory from sta Track and tracker RecHits
vector< Trajectory > GlobalMuonRefitter::refit ( const reco::Track globalTrack,
const reco::TransientTrack  track,
const TransientTrackingRecHit::ConstRecHitContainer allRecHitsTemp,
const int  theMuonHitsOption,
const TrackerTopology tTopo 
) const

build combined trajectory from subset of sta Track and tracker RecHits

Definition at line 218 of file GlobalMuonRefitter.cc.

References all4DSegments, alongMomentum, checkMuonHits(), reco::DYTInfo::CopyFrom(), CSCSegments, dytInfo, DynamicTruncation::filter(), DynamicTruncation::getDYTInfo(), getFirstHits(), getRidOfSelectStationHits(), LogTrace, reco::TrackBase::pt(), selectMuonHits(), DynamicTruncation::setProd(), DynamicTruncation::setSelector(), DynamicTruncation::setThr(), DynamicTruncation::setUpdateState(), DynamicTruncation::setUseAPE(), theCategory, theDYTselector, theDYTthrs, theDYTupdator, theDYTuseAPE, theEvent, theService, and transform().

222  {
223 
224  // MuonHitsOption: 0 - tracker only
225  // 1 - include all muon hits
226  // 2 - include only first muon hit(s)
227  // 3 - include only selected muon hits
228  // 4 - redo pattern recognition with dynamic truncation
229 
230  vector<int> stationHits(4,0);
231  map<DetId, int> hitMap;
232 
233  ConstRecHitContainer allRecHits; // all muon rechits
234  ConstRecHitContainer fmsRecHits; // only first muon rechits
235  ConstRecHitContainer selectedRecHits; // selected muon rechits
236  ConstRecHitContainer DYTRecHits; // rec hits from dynamic truncation algorithm
237 
238  LogTrace(theCategory) << " *** GlobalMuonRefitter *** option " << theMuonHitsOption << endl;
239  LogTrace(theCategory) << " Track momentum before refit: " << globalTrack.pt() << endl;
240  LogTrace(theCategory) << " Hits size before : " << allRecHitsTemp.size() << endl;
241 
242  allRecHits = getRidOfSelectStationHits(allRecHitsTemp, tTopo);
243  // printHits(allRecHits);
244  LogTrace(theCategory) << " Hits size: " << allRecHits.size() << endl;
245 
246  vector <Trajectory> outputTraj;
247 
248  if ((theMuonHitsOption == 1) || (theMuonHitsOption == 3) || (theMuonHitsOption == 4) ) {
249  // refit the full track with all muon hits
250  vector <Trajectory> globalTraj = transform(globalTrack, track, allRecHits);
251 
252  if (globalTraj.empty()) {
253  LogTrace(theCategory) << "No trajectory from the TrackTransformer!" << endl;
254  return vector<Trajectory>();
255  }
256 
257  LogTrace(theCategory) << " Initial trajectory state: "
258  << globalTraj.front().lastMeasurement().updatedState().freeState()->parameters() << endl;
259 
260  if (theMuonHitsOption == 1 )
261  outputTraj.push_back(globalTraj.front());
262 
263  if (theMuonHitsOption == 3 ) {
264  checkMuonHits(globalTrack, allRecHits, hitMap);
265  selectedRecHits = selectMuonHits(globalTraj.front(),hitMap);
266  LogTrace(theCategory) << " Selected hits size: " << selectedRecHits.size() << endl;
267  outputTraj = transform(globalTrack, track, selectedRecHits);
268  }
269 
270  if (theMuonHitsOption == 4 ) {
271  //
272  // DYT 2.0
273  //
275  dytRefit.setProd(all4DSegments, CSCSegments);
276  dytRefit.setSelector(theDYTselector);
277  dytRefit.setThr(theDYTthrs);
278  dytRefit.setUpdateState(theDYTupdator);
279  dytRefit.setUseAPE(theDYTuseAPE);
280  DYTRecHits = dytRefit.filter(globalTraj.front());
281  dytInfo->CopyFrom(dytRefit.getDYTInfo());
282  if ((DYTRecHits.size() > 1) && (DYTRecHits.front()->globalPosition().mag() > DYTRecHits.back()->globalPosition().mag()))
283  stable_sort(DYTRecHits.begin(),DYTRecHits.end(),RecHitLessByDet(alongMomentum));
284  outputTraj = transform(globalTrack, track, DYTRecHits);
285  }
286 
287  } else if (theMuonHitsOption == 2 ) {
288  getFirstHits(globalTrack, allRecHits, fmsRecHits);
289  outputTraj = transform(globalTrack, track, fmsRecHits);
290  }
291 
292 
293  if (!outputTraj.empty()) {
294  LogTrace(theCategory) << "Refitted pt: " << outputTraj.front().firstMeasurement().updatedState().globalParameters().momentum().perp() << endl;
295  return outputTraj;
296  } else {
297  LogTrace(theCategory) << "No refitted Tracks... " << endl;
298  return vector<Trajectory>();
299  }
300 
301 }
const MuonServiceProxy * theService
edm::Handle< CSCSegmentCollection > CSCSegments
void CopyFrom(const DYTInfo &)
copy from another DYTInfo
Definition: DYTInfo.cc:15
void checkMuonHits(const reco::Track &, ConstRecHitContainer &, std::map< DetId, int > &) const
check muon RecHits, calculate chamber occupancy and select hits to be used in the final fit ...
std::vector< int > theDYTthrs
void getFirstHits(const reco::Track &, ConstRecHitContainer &, ConstRecHitContainer &) const
get the RecHits in the tracker and the first muon chamber with hits
const edm::Event * theEvent
edm::Handle< DTRecSegment4DCollection > all4DSegments
ConstRecHitContainer selectMuonHits(const Trajectory &, const std::map< DetId, int > &) const
select muon hits compatible with trajectory; check hits in chambers with showers
ConstRecHitContainer getRidOfSelectStationHits(const ConstRecHitContainer &hits, const TrackerTopology *tTopo) const
double pt() const
track transverse momentum
Definition: TrackBase.h:621
#define LogTrace(id)
reco::DYTInfo * dytInfo
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
std::vector< Trajectory > transform(const reco::Track &newTrack, const reco::TransientTrack track, const TransientTrackingRecHit::ConstRecHitContainer &recHitsForReFit) const
refit the track with a new set of RecHits
GlobalMuonRefitter::ConstRecHitContainer GlobalMuonRefitter::selectMuonHits ( const Trajectory traj,
const std::map< DetId, int > &  hitMap 
) const
protected

select muon hits compatible with trajectory; check hits in chambers with showers

Definition at line 561 of file GlobalMuonRefitter.cc.

References CSCDetId::chamberId(), ME0DetId::chamberId(), GEMDetId::chamberId(), PixelTripletNoTipGenerator_cfi::chi2Cut, TrackingRecHit::geographicalId(), keep, LogTrace, Trajectory::measurements(), DetId::Muon, groupFilesInBlocks::reverse, theCategory, theCSCChi2Cut, theDTChi2Cut, theGEMChi2Cut, theHitThreshold, theME0Chi2Cut, theRPCChi2Cut, and electronIdCutBased_cfi::threshold.

Referenced by refit().

562  {
563 
564  ConstRecHitContainer muonRecHits;
565  const double globalChi2Cut = 200.0;
566 
567  vector<TrajectoryMeasurement> muonMeasurements = traj.measurements();
568 
569  // loop through all muon hits and skip hits with bad chi2 in chambers with high occupancy
570  for (std::vector<TrajectoryMeasurement>::const_iterator im = muonMeasurements.begin(); im != muonMeasurements.end(); im++ ) {
571 
572  if ( !(*im).recHit()->isValid() ) continue;
573  if ( (*im).recHit()->det()->geographicalId().det() != DetId::Muon ) {
574  // if ( ( chi2ndf < globalChi2Cut ) )
575  muonRecHits.push_back((*im).recHit());
576  continue;
577  }
578  const MuonTransientTrackingRecHit* immrh = dynamic_cast<const MuonTransientTrackingRecHit*>((*im).recHit().get());
579 
580  DetId id = immrh->geographicalId();
581  DetId chamberId;
582  int threshold = 0;
583  double chi2Cut = 0.0;
584 
585  // get station of hit if it is in DT
586  if ( (*immrh).isDT() ) {
587  DTChamberId did(id.rawId());
588  chamberId = did;
589  threshold = theHitThreshold;
590  chi2Cut = theDTChi2Cut;
591  }
592  // get station of hit if it is in CSC
593  else if ( (*immrh).isCSC() ) {
594  CSCDetId did(id.rawId());
595  chamberId = did.chamberId();
596  threshold = theHitThreshold;
597  chi2Cut = theCSCChi2Cut;
598  }
599  // get station of hit if it is in GEM
600  else if ( (*immrh).isGEM() ) {
601  GEMDetId did(id.rawId());
602  chamberId = did.chamberId();
603  threshold = theHitThreshold;
604  chi2Cut = theGEMChi2Cut;
605  }
606  // get station of hit if it is in ME0
607  else if ( (*immrh).isME0() ) {
608  ME0DetId did(id.rawId());
609  chamberId = did.chamberId();
610  threshold = theHitThreshold;
611  chi2Cut = theME0Chi2Cut;
612  }
613  // get station of hit if it is in RPC
614  else if ( (*immrh).isRPC() ) {
615  RPCDetId rpcid(id.rawId());
616  chamberId = rpcid;
617  threshold = theHitThreshold;
618  chi2Cut = theRPCChi2Cut;
619  } else
620  continue;
621 
622  double chi2ndf = (*im).estimate()/(*im).recHit()->dimension();
623 
624  bool keep = true;
625  map<DetId,int>::const_iterator imap=hitMap.find(chamberId);
626  if ( imap!=hitMap.end() )
627  if (imap->second>threshold) keep = false;
628 
629  if ( (keep || (chi2ndf<chi2Cut)) && (chi2ndf<globalChi2Cut) ) {
630  muonRecHits.push_back((*im).recHit());
631  } else {
633  << "Skip hit: " << id.rawId() << " chi2="
634  << chi2ndf << " ( threshold: " << chi2Cut << ") Det: "
635  << imap->second << endl;
636  }
637  }
638 
639  // check order of rechits
640  reverse(muonRecHits.begin(),muonRecHits.end());
641  return muonRecHits;
642 }
DataContainer const & measurements() const
Definition: Trajectory.h:196
const int keep
#define LogTrace(id)
Definition: DetId.h:18
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
DetId geographicalId() const
const MuonServiceProxy* GlobalMuonRefitter::service ( ) const
inlineprotected

Definition at line 124 of file GlobalMuonRefitter.h.

124 { return theService; }
const MuonServiceProxy * theService
void GlobalMuonRefitter::setEvent ( const edm::Event event)
virtual

pass the Event to the algo at each event

Definition at line 153 of file GlobalMuonRefitter.cc.

References all4DSegments, all4DSegmentsToken, CSCSegments, CSCSegmentsToken, event(), theCSCRecHits, theCSCRecHitToken, theDTRecHits, theDTRecHitToken, theEvent, theGEMRecHits, theGEMRecHitToken, theME0RecHits, and theME0RecHitToken.

Referenced by GlobalTrackQualityProducer::produce(), and GlobalTrajectoryBuilderBase::setEvent().

153  {
154 
155  theEvent = &event;
156  event.getByToken(theDTRecHitToken, theDTRecHits);
157  event.getByToken(theCSCRecHitToken, theCSCRecHits);
158  event.getByToken(theGEMRecHitToken, theGEMRecHits);
159  event.getByToken(theME0RecHitToken, theME0RecHits);
160  event.getByToken(CSCSegmentsToken, CSCSegments);
161  event.getByToken(all4DSegmentsToken, all4DSegments);
162 }
edm::Handle< DTRecHitCollection > theDTRecHits
edm::Handle< CSCSegmentCollection > CSCSegments
edm::Handle< GEMRecHitCollection > theGEMRecHits
edm::EDGetTokenT< CSCSegmentCollection > CSCSegmentsToken
edm::Handle< ME0SegmentCollection > theME0RecHits
const edm::Event * theEvent
edm::Handle< DTRecSegment4DCollection > all4DSegments
edm::EDGetTokenT< ME0SegmentCollection > theME0RecHitToken
edm::Handle< CSCRecHit2DCollection > theCSCRecHits
edm::EDGetTokenT< DTRecHitCollection > theDTRecHitToken
edm::EDGetTokenT< CSCRecHit2DCollection > theCSCRecHitToken
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< DTRecSegment4DCollection > all4DSegmentsToken
edm::EDGetTokenT< GEMRecHitCollection > theGEMRecHitToken
void GlobalMuonRefitter::setServices ( const edm::EventSetup setup)

set the services needed by the TrackTransformer

Definition at line 165 of file GlobalMuonRefitter.cc.

References TrajectoryFitter::clone(), edm::EventSetup::get(), hitCloner, LogDebug, edm::ESHandle< T >::product(), theCacheId_TRH, theCategory, theFitter, theFitterName, theMuonRecHitBuilder, theMuonRecHitBuilderName, theService, theTrackerRecHitBuilder, and theTrackerRecHitBuilderName.

Referenced by GlobalTrackQualityProducer::produce(), and GlobalTrajectoryBuilderBase::setEvent().

165  {
166 
168  theService->eventSetup().get<TrajectoryFitter::Record>().get(theFitterName,aFitter);
169  theFitter = aFitter->clone();
170 
171 
172  // Transient Rechit Builders
173  unsigned long long newCacheId_TRH = setup.get<TransientRecHitRecord>().cacheIdentifier();
174  if ( newCacheId_TRH != theCacheId_TRH ) {
175  LogDebug(theCategory) << "TransientRecHitRecord changed!";
179  }
180  theFitter->setHitCloner(&hitCloner);
181 
182 }
#define LogDebug(id)
std::string theMuonRecHitBuilderName
const MuonServiceProxy * theService
edm::ESHandle< TransientTrackingRecHitBuilder > theTrackerRecHitBuilder
std::unique_ptr< TrajectoryFitter > theFitter
edm::ESHandle< TransientTrackingRecHitBuilder > theMuonRecHitBuilder
virtual std::unique_ptr< TrajectoryFitter > clone() const =0
const T & get() const
Definition: EventSetup.h:59
unsigned long long theCacheId_TRH
std::string theTrackerRecHitBuilderName
T const * product() const
Definition: ESHandle.h:86
vector< Trajectory > GlobalMuonRefitter::transform ( const reco::Track newTrack,
const reco::TransientTrack  track,
const TransientTrackingRecHit::ConstRecHitContainer recHitsForReFit 
) const

refit the track with a new set of RecHits

Definition at line 702 of file GlobalMuonRefitter.cc.

References alongMomentum, PV3DBase< T, PVType, FrameType >::basicVector(), checkRecHitsOrdering(), Basic3DVector< T >::dot(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), reco::Track::innerDetId(), reco::TransientTrack::innermostMeasurementState(), insideOut, LogDebug, LogTrace, PV3DBase< T, PVType, FrameType >::mag(), oppositeToMomentum, reco::Track::outerDetId(), reco::TransientTrack::outermostMeasurementState(), outsideIn, printHits(), groupFilesInBlocks::reverse, SurveyInfoScenario_cff::seed, theCategory, theCosmicFlag, theFitter, thePropagatorName, theRefitDirection, theRescaleErrorFactor, theService, and HiRegitMuonDetachedTripletStep_cff::trajectories.

Referenced by refit().

704  {
705 
706  TransientTrackingRecHit::ConstRecHitContainer recHitsForReFit = urecHitsForReFit;
707  LogTrace(theCategory) << "GlobalMuonRefitter::transform: " << recHitsForReFit.size() << " hits:";
708  printHits(recHitsForReFit);
709 
710  if(recHitsForReFit.size() < 2) return vector<Trajectory>();
711 
712  // Check the order of the rechits
713  RefitDirection recHitsOrder = checkRecHitsOrdering(recHitsForReFit);
714 
715  LogTrace(theCategory) << "checkRecHitsOrdering() returned " << recHitsOrder
716  << ", theRefitDirection is " << theRefitDirection
717  << " (insideOut == " << insideOut << ", outsideIn == " << outsideIn << ")";
718 
719  // Reverse the order in the case of inconsistency between the fit direction and the rechit order
720  if(theRefitDirection != recHitsOrder) reverse(recHitsForReFit.begin(),recHitsForReFit.end());
721 
722  // Even though we checked the rechits' ordering above, we may have
723  // already flipped them elsewhere (getFirstHits() is such a
724  // culprit). Use the global positions of the states and the desired
725  // refit direction to find the starting TSOS.
726  TrajectoryStateOnSurface firstTSOS, lastTSOS;
727  unsigned int innerId; //UNUSED: outerId;
728  bool order_swapped = track.outermostMeasurementState().globalPosition().mag() < track.innermostMeasurementState().globalPosition().mag();
729  bool inner_is_first;
730  LogTrace(theCategory) << "order swapped? " << order_swapped;
731 
732  // Fill the starting state, depending on the ordering above.
733  if ((theRefitDirection == insideOut && !order_swapped) || (theRefitDirection == outsideIn && order_swapped)) {
734  innerId = newTrack.innerDetId();
735  //UNUSED: outerId = newTrack.outerDetId();
736  firstTSOS = track.innermostMeasurementState();
737  lastTSOS = track.outermostMeasurementState();
738  inner_is_first = true;
739  }
740  else {
741  innerId = newTrack.outerDetId();
742  //UNUSED: outerId = newTrack.innerDetId();
743  firstTSOS = track.outermostMeasurementState();
744  lastTSOS = track.innermostMeasurementState();
745  inner_is_first = false;
746  }
747 
748  LogTrace(theCategory) << "firstTSOS: inner_is_first? " << inner_is_first
749  << " globalPosition is " << firstTSOS.globalPosition()
750  << " innerId is " << innerId;
751 
752  if(!firstTSOS.isValid()){
753  LogWarning(theCategory) << "Error wrong initial state!" << endl;
754  return vector<Trajectory>();
755  }
756 
757  firstTSOS.rescaleError(theRescaleErrorFactor);
758 
759  // This is the only way to get a TrajectorySeed with settable propagation direction
760  PTrajectoryStateOnDet garbage1;
762 
763  // These lines cause the code to ignore completely what was set
764  // above, and force propDir for tracks from collisions!
765 // if(propDir == alongMomentum && theRefitDirection == outsideIn) propDir=oppositeToMomentum;
766 // if(propDir == oppositeToMomentum && theRefitDirection == insideOut) propDir=alongMomentum;
767 
768  const TrajectoryStateOnSurface& tsosForDir = inner_is_first ? lastTSOS : firstTSOS;
770  LogTrace(theCategory) << "propDir based on firstTSOS x dot p is " << propDir
771  << " (alongMomentum == " << alongMomentum << ", oppositeToMomentum == " << oppositeToMomentum << ")";
772 
773  // Additional propagation diretcion determination logic for cosmic muons
774  if (theCosmicFlag) {
775  PropagationDirection propDir_first = (firstTSOS.globalPosition().basicVector().dot(firstTSOS.globalMomentum().basicVector()) > 0) ? alongMomentum : oppositeToMomentum;
776  PropagationDirection propDir_last = (lastTSOS .globalPosition().basicVector().dot(lastTSOS .globalMomentum().basicVector()) > 0) ? alongMomentum : oppositeToMomentum;
777  LogTrace(theCategory) << "propDir_first " << propDir_first << ", propdir_last " << propDir_last
778  << " : they " << (propDir_first == propDir_last ? "agree" : "disagree");
779 
780  int y_count = 0;
781  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator it = recHitsForReFit.begin(); it != recHitsForReFit.end(); ++it) {
782  if ((*it)->globalPosition().y() > 0) ++y_count;
783  else --y_count;
784  }
785 
786  PropagationDirection propDir_ycount = alongMomentum;
787  if (y_count > 0) {
788  if (theRefitDirection == insideOut) propDir_ycount = oppositeToMomentum;
789  else if (theRefitDirection == outsideIn) propDir_ycount = alongMomentum;
790  }
791  else {
792  if (theRefitDirection == insideOut) propDir_ycount = alongMomentum;
793  else if (theRefitDirection == outsideIn) propDir_ycount = oppositeToMomentum;
794  }
795 
796  LogTrace(theCategory) << "y_count = " << y_count
797  << "; based on geometrically-outermost TSOS, propDir is " << propDir << ": "
798  << (propDir == propDir_ycount ? "agrees" : "disagrees")
799  << " with ycount determination";
800 
801  if (propDir_first != propDir_last) {
802  LogTrace(theCategory) << "since first/last disagreed, using y_count propDir";
803  propDir = propDir_ycount;
804  }
805  }
806 
807  TrajectorySeed seed(garbage1,garbage2,propDir);
808 
809  if(recHitsForReFit.front()->geographicalId() != DetId(innerId)){
810  LogDebug(theCategory)<<"Propagation occured"<<endl;
811  LogTrace(theCategory) << "propagating firstTSOS at " << firstTSOS.globalPosition()
812  << " to first rechit with surface pos " << recHitsForReFit.front()->det()->surface().toGlobal(LocalPoint(0,0,0));
813  firstTSOS = theService->propagator(thePropagatorName)->propagate(firstTSOS, recHitsForReFit.front()->det()->surface());
814  if(!firstTSOS.isValid()){
815  LogDebug(theCategory)<<"Propagation error!"<<endl;
816  return vector<Trajectory>();
817  }
818  }
819 
820 /*
821  cout << " GlobalMuonRefitter : theFitter " << propDir << endl;
822  cout << " First TSOS: "
823  << firstTSOS.globalPosition() << " p="
824  << firstTSOS.globalMomentum() << " = "
825  << firstTSOS.globalMomentum().mag() << endl;
826 
827  cout << " Starting seed: "
828  << " nHits= " << seed.nHits()
829  << " tsos: "
830  << seed.startingState().parameters().position() << " p="
831  << seed.startingState().parameters().momentum() << endl;
832 
833  cout << " RecHits: "
834  << recHitsForReFit.size() << endl;
835 */
836 
837  vector<Trajectory> trajectories = theFitter->fit(seed,recHitsForReFit,firstTSOS);
838 
839  if(trajectories.empty()){
840  LogDebug(theCategory) << "No Track refitted!" << endl;
841  return vector<Trajectory>();
842  }
843  return trajectories;
844 }
#define LogDebug(id)
void printHits(const ConstRecHitContainer &) const
print all RecHits of a trajectory
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
const MuonServiceProxy * theService
RefitDirection theRefitDirection
std::string thePropagatorName
GlobalPoint globalPosition() const
PropagationDirection
std::unique_ptr< TrajectoryFitter > theFitter
TrajectoryStateOnSurface innermostMeasurementState() const
T mag() const
Definition: PV3DBase.h:67
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:94
RefitDirection checkRecHitsOrdering(const ConstRecHitContainer &) const
TrajectoryStateOnSurface outermostMeasurementState() const
#define LogTrace(id)
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: DetId.h:18
GlobalVector globalMomentum() const
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:99
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.

Member Data Documentation

edm::Handle<DTRecSegment4DCollection> GlobalMuonRefitter::all4DSegments
private

Definition at line 192 of file GlobalMuonRefitter.h.

Referenced by refit(), and setEvent().

edm::EDGetTokenT<DTRecSegment4DCollection> GlobalMuonRefitter::all4DSegmentsToken
private

Definition at line 190 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setEvent().

edm::Handle<CSCSegmentCollection> GlobalMuonRefitter::CSCSegments
private

Definition at line 191 of file GlobalMuonRefitter.h.

Referenced by refit(), and setEvent().

edm::EDGetTokenT<CSCSegmentCollection> GlobalMuonRefitter::CSCSegmentsToken
private

Definition at line 189 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setEvent().

reco::DYTInfo* GlobalMuonRefitter::dytInfo
private

Definition at line 174 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), refit(), and ~GlobalMuonRefitter().

TkClonerImpl GlobalMuonRefitter::hitCloner
private

Definition at line 181 of file GlobalMuonRefitter.h.

Referenced by setServices().

unsigned long long GlobalMuonRefitter::theCacheId_TRH
private

Definition at line 160 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setServices().

std::string GlobalMuonRefitter::theCategory
protected
bool GlobalMuonRefitter::theCosmicFlag
private

Definition at line 141 of file GlobalMuonRefitter.h.

Referenced by transform().

float GlobalMuonRefitter::theCSCChi2Cut
private

Definition at line 137 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and selectMuonHits().

edm::InputTag GlobalMuonRefitter::theCSCRecHitLabel
private

Definition at line 144 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter().

edm::Handle<CSCRecHit2DCollection> GlobalMuonRefitter::theCSCRecHits
private

Definition at line 148 of file GlobalMuonRefitter.h.

Referenced by checkMuonHits(), and setEvent().

edm::EDGetTokenT<CSCRecHit2DCollection> GlobalMuonRefitter::theCSCRecHitToken
private

Definition at line 152 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setEvent().

float GlobalMuonRefitter::theDTChi2Cut
private

Definition at line 136 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and selectMuonHits().

edm::InputTag GlobalMuonRefitter::theDTRecHitLabel
private

Definition at line 143 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter().

edm::Handle<DTRecHitCollection> GlobalMuonRefitter::theDTRecHits
private

Definition at line 147 of file GlobalMuonRefitter.h.

Referenced by checkMuonHits(), and setEvent().

edm::EDGetTokenT<DTRecHitCollection> GlobalMuonRefitter::theDTRecHitToken
private

Definition at line 151 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setEvent().

int GlobalMuonRefitter::theDYTselector
private

Definition at line 171 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and refit().

std::vector<int> GlobalMuonRefitter::theDYTthrs
private

Definition at line 170 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and refit().

bool GlobalMuonRefitter::theDYTupdator
private

Definition at line 172 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and refit().

bool GlobalMuonRefitter::theDYTuseAPE
private

Definition at line 173 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and refit().

const edm::Event* GlobalMuonRefitter::theEvent
private

Definition at line 187 of file GlobalMuonRefitter.h.

Referenced by refit(), and setEvent().

std::unique_ptr<TrajectoryFitter> GlobalMuonRefitter::theFitter
private

Definition at line 177 of file GlobalMuonRefitter.h.

Referenced by setServices(), and transform().

std::string GlobalMuonRefitter::theFitterName
private

Definition at line 176 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setServices().

float GlobalMuonRefitter::theGEMChi2Cut
private

Definition at line 139 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and selectMuonHits().

edm::InputTag GlobalMuonRefitter::theGEMRecHitLabel
private

Definition at line 145 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter().

edm::Handle<GEMRecHitCollection> GlobalMuonRefitter::theGEMRecHits
private

Definition at line 149 of file GlobalMuonRefitter.h.

Referenced by checkMuonHits(), and setEvent().

edm::EDGetTokenT<GEMRecHitCollection> GlobalMuonRefitter::theGEMRecHitToken
private

Definition at line 153 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setEvent().

int GlobalMuonRefitter::theHitThreshold
private

Definition at line 135 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and selectMuonHits().

float GlobalMuonRefitter::theME0Chi2Cut
private

Definition at line 140 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and selectMuonHits().

edm::InputTag GlobalMuonRefitter::theME0RecHitLabel
private

Definition at line 146 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter().

edm::Handle<ME0SegmentCollection> GlobalMuonRefitter::theME0RecHits
private

Definition at line 150 of file GlobalMuonRefitter.h.

Referenced by checkMuonHits(), and setEvent().

edm::EDGetTokenT<ME0SegmentCollection> GlobalMuonRefitter::theME0RecHitToken
private

Definition at line 154 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setEvent().

int GlobalMuonRefitter::theMuonHitsOption
private

Definition at line 133 of file GlobalMuonRefitter.h.

edm::ESHandle<TransientTrackingRecHitBuilder> GlobalMuonRefitter::theMuonRecHitBuilder
private

Definition at line 184 of file GlobalMuonRefitter.h.

Referenced by refit(), and setServices().

std::string GlobalMuonRefitter::theMuonRecHitBuilderName
private

Definition at line 183 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setServices().

float GlobalMuonRefitter::theProbCut
private

Definition at line 134 of file GlobalMuonRefitter.h.

std::string GlobalMuonRefitter::thePropagatorName
private

Definition at line 162 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and transform().

float GlobalMuonRefitter::thePtCut
protected

Definition at line 129 of file GlobalMuonRefitter.h.

RefitDirection GlobalMuonRefitter::theRefitDirection
private

Definition at line 168 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and transform().

double GlobalMuonRefitter::theRescaleErrorFactor
private

Definition at line 166 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and transform().

float GlobalMuonRefitter::theRPCChi2Cut
private

Definition at line 138 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and selectMuonHits().

bool GlobalMuonRefitter::theRPCInTheFit
private

Definition at line 164 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and refit().

const MuonServiceProxy* GlobalMuonRefitter::theService
private

Definition at line 186 of file GlobalMuonRefitter.h.

Referenced by refit(), setServices(), and transform().

int GlobalMuonRefitter::theSkipStation
private

Definition at line 156 of file GlobalMuonRefitter.h.

Referenced by getRidOfSelectStationHits(), and GlobalMuonRefitter().

bool GlobalMuonRefitter::theTkTrajsAvailableFlag
protected

Definition at line 128 of file GlobalMuonRefitter.h.

edm::ESHandle<TransientTrackingRecHitBuilder> GlobalMuonRefitter::theTrackerRecHitBuilder
private

Definition at line 180 of file GlobalMuonRefitter.h.

Referenced by refit(), and setServices().

std::string GlobalMuonRefitter::theTrackerRecHitBuilderName
private

Definition at line 179 of file GlobalMuonRefitter.h.

Referenced by GlobalMuonRefitter(), and setServices().

int GlobalMuonRefitter::theTrackerSkipSection
private

Definition at line 158 of file GlobalMuonRefitter.h.

Referenced by getRidOfSelectStationHits(), and GlobalMuonRefitter().

int GlobalMuonRefitter::theTrackerSkipSystem
private

Definition at line 157 of file GlobalMuonRefitter.h.

Referenced by getRidOfSelectStationHits(), and GlobalMuonRefitter().