CMS 3D CMS Logo

SeedTransformer.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author D. Trocino - University and INFN Torino
5  */
6 
8 
9 // System include files
10 // #include <memory>
11 // #include <Riostream.h>
12 
13 // Framework
21 
22 // Services and Tools
23 
24 // Geometry and Magnetic field
29 
30 // Other include files
39 
41 
42 using namespace std;
43 using namespace edm;
44 using namespace reco;
45 
47  LogTrace("Reco|TrackingTools|SeedTransformer") << "SeedTransformer constructor called." << endl << endl;
48 
49  theFitterName = iConfig.getParameter<string>("Fitter");
50  theMuonRecHitBuilderName = iConfig.getParameter<string>("MuonRecHitBuilder");
51  thePropagatorName = iConfig.getParameter<string>("Propagator");
52 
53  nMinRecHits = iConfig.getParameter<unsigned int>("NMinRecHits");
54  errorRescale = iConfig.getParameter<double>("RescaleError");
55  useSubRecHits = iConfig.getParameter<bool>("UseSubRecHits");
56 }
57 
59  LogTrace("Reco|TrackingTools|SeedTransformer") << "SeedTransformer destructor called." << endl << endl;
60 }
61 
63  iSetup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
64  iSetup.get<IdealMagneticFieldRecord>().get(theMagneticField);
65  iSetup.get<TrajectoryFitter::Record>().get(theFitterName, theFitter);
66  iSetup.get<TransientRecHitRecord>().get(theMuonRecHitBuilderName, theMuonRecHitBuilder);
67  iSetup.get<TrackingComponentsRecord>().get(thePropagatorName, thePropagator);
68 }
69 
70 vector<Trajectory> SeedTransformer::seedTransform(const TrajectorySeed& aSeed) const {
71  const string metname = "Reco|TrackingTools|SeedTransformer";
72 
73  LogTrace(metname) << " Number of valid RecHits: " << aSeed.nHits() << endl;
74 
75  if (aSeed.nHits() < nMinRecHits) {
76  LogTrace(metname) << " --- Too few RecHits, no refit performed! ---" << endl;
77  return vector<Trajectory>();
78  }
79 
80  TrajectoryStateOnSurface aTSOS(seedTransientState(aSeed));
81 
82  // Rescale errors before refit, not to bias the result
83  aTSOS.rescaleError(errorRescale);
84 
85  vector<TransientTrackingRecHit::ConstRecHitPointer> recHits;
86 
87  for (auto const& recHit : aSeed.recHits()) {
88  if (recHit.isValid()) {
89  TransientTrackingRecHit::ConstRecHitPointer ttrh(theMuonRecHitBuilder->build(&recHit));
90 
91  if (useSubRecHits) {
94  copy(subHits.begin(), subHits.end(), back_inserter(recHits));
95  } else {
96  recHits.push_back(ttrh);
97  }
98  }
99  }
100 
101  TrajectoryStateOnSurface aInitTSOS = thePropagator->propagate(aTSOS, recHits.front()->det()->surface());
102 
103  if (!aInitTSOS.isValid()) {
104  LogTrace(metname) << " --- Initial state for refit not valid! ---" << endl;
105  return vector<Trajectory>();
106  }
107 
108  vector<Trajectory> refittedSeed = theFitter->fit(aSeed, recHits, aInitTSOS);
109 
110  if (refittedSeed.empty()) {
111  LogTrace(metname) << " --- Seed fit failed! ---" << endl;
112  return vector<Trajectory>();
113  }
114 
115  else if (!refittedSeed.front().isValid()) {
116  LogTrace(metname) << " --- Seed fitted, but trajectory not valid! ---" << endl;
117  return vector<Trajectory>();
118  }
119 
120  else
121  LogTrace(metname) << " +++ Seed fit succeded! +++" << endl;
122 
123  return refittedSeed;
124 }
125 
127  PTrajectoryStateOnDet tmpTSOD = tmpSeed.startingState();
128  DetId tmpDetId(tmpTSOD.detId());
129  const GeomDet* tmpGeomDet = theTrackingGeometry->idToDet(tmpDetId);
130 
131  TrajectoryStateOnSurface tmpTSOS =
132  trajectoryStateTransform::transientState(tmpTSOD, &(tmpGeomDet->surface()), &(*theMagneticField));
133 
134  return tmpTSOS;
135 }
SeedTransformer::seedTransientState
TrajectoryStateOnSurface seedTransientState(const TrajectorySeed &) const
Definition: SeedTransformer.cc:126
Propagator.h
TrajectoryStateOnSurface.h
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
ESHandle.h
TrajectorySeed::nHits
unsigned int nHits() const
Definition: TrajectorySeed.h:53
SeedTransformer::SeedTransformer
SeedTransformer(const edm::ParameterSet &)
Constructor.
Definition: SeedTransformer.cc:46
edm
HLT enums.
Definition: AlignableModifier.h:19
TransientRecHitRecord.h
HLT_FULL_cff.thePropagatorName
thePropagatorName
Definition: HLT_FULL_cff.py:113837
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
GlobalTrackingGeometryRecord
Definition: GlobalTrackingGeometryRecord.h:17
SeedTransformer::seedTransform
std::vector< Trajectory > seedTransform(const TrajectorySeed &) const
Performs the fit.
Definition: SeedTransformer.cc:70
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
MakerMacros.h
PTrajectoryStateOnDet::detId
unsigned int detId() const
Definition: PTrajectoryStateOnDet.h:65
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
MuonTransientTrackingRecHitBreaker::breakInSubRecHits
static TransientTrackingRecHit::ConstRecHitContainer breakInSubRecHits(TransientTrackingRecHit::ConstRecHitPointer, int granularity)
takes a muon rechit and returns its sub-rechits given a certain granularity
Definition: MuonTransientTrackingRecHitBreaker.cc:5
IdealMagneticFieldRecord.h
TrajectoryFitterRecord
Definition: TrajectoryFitterRecord.h:12
TrajectoryFitter.h
GlobalTrackingGeometryRecord.h
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
TrackingRecHit::ConstRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: TrackingRecHit.h:32
TrackingRecHit::ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Definition: TrackingRecHit.h:25
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
TrajectorySeed::recHits
RecHitRange recHits() const
Definition: TrajectorySeed.h:52
TrajectoryStateOnSurface::rescaleError
void rescaleError(double factor)
Definition: TrajectoryStateOnSurface.h:82
Trajectory.h
GeomDet.h
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
TrackingComponentsRecord.h
TrajectorySeed
Definition: TrajectorySeed.h:18
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrajectoryStateTransform.h
SeedTransformer::setServices
void setServices(const edm::EventSetup &)
Set the services needed by the SeedTransformer.
Definition: SeedTransformer.cc:62
TrajectorySeed::startingState
PTrajectoryStateOnDet const & startingState() const
Definition: TrajectorySeed.h:55
TransientTrackingRecHitBuilder.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
ParameterSet.h
MuonTransientTrackingRecHitBreaker.h
GlobalTrackingGeometry.h
SeedTransformer::~SeedTransformer
virtual ~SeedTransformer()
Destructor.
Definition: SeedTransformer.cc:58
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
SeedTransformer.h
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12