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  unsigned int countRH = 0;
87 
88  for (TrajectorySeed::recHitContainer::const_iterator itRecHits = aSeed.recHits().first;
89  itRecHits != aSeed.recHits().second;
90  ++itRecHits, ++countRH) {
91  if ((*itRecHits).isValid()) {
92  TransientTrackingRecHit::ConstRecHitPointer ttrh(theMuonRecHitBuilder->build(&(*itRecHits)));
93 
94  if (useSubRecHits) {
97  copy(subHits.begin(), subHits.end(), back_inserter(recHits));
98  } else {
99  recHits.push_back(ttrh);
100  }
101  }
102  } // end for(TrajectorySeed::recHitContainer::const_iterator itRecHits=aSeed.recHits().first; itRecHits!=aSeed.recHits().second; ++itRecHits, ++countRH)
103 
104  TrajectoryStateOnSurface aInitTSOS = thePropagator->propagate(aTSOS, recHits.front()->det()->surface());
105 
106  if (!aInitTSOS.isValid()) {
107  LogTrace(metname) << " --- Initial state for refit not valid! ---" << endl;
108  return vector<Trajectory>();
109  }
110 
111  vector<Trajectory> refittedSeed = theFitter->fit(aSeed, recHits, aInitTSOS);
112 
113  if (refittedSeed.empty()) {
114  LogTrace(metname) << " --- Seed fit failed! ---" << endl;
115  return vector<Trajectory>();
116  }
117 
118  else if (!refittedSeed.front().isValid()) {
119  LogTrace(metname) << " --- Seed fitted, but trajectory not valid! ---" << endl;
120  return vector<Trajectory>();
121  }
122 
123  else
124  LogTrace(metname) << " +++ Seed fit succeded! +++" << endl;
125 
126  return refittedSeed;
127 }
128 
130  PTrajectoryStateOnDet tmpTSOD = tmpSeed.startingState();
131  DetId tmpDetId(tmpTSOD.detId());
132  const GeomDet* tmpGeomDet = theTrackingGeometry->idToDet(tmpDetId);
133 
134  TrajectoryStateOnSurface tmpTSOS =
135  trajectoryStateTransform::transientState(tmpTSOD, &(tmpGeomDet->surface()), &(*theMagneticField));
136 
137  return tmpTSOS;
138 }
SeedTransformer::seedTransientState
TrajectoryStateOnSurface seedTransientState(const TrajectorySeed &) const
Definition: SeedTransformer.cc:129
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:109759
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:45
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:73
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:36
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:57
get
#define get
TrajectoryStateOnSurface::rescaleError
void rescaleError(double factor)
Definition: TrajectoryStateOnSurface.h:82
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Trajectory.h
GeomDet.h
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
TrackingComponentsRecord.h
TrajectorySeed::recHits
range recHits() const
Definition: TrajectorySeed.h:52
TrajectorySeed
Definition: TrajectorySeed.h:17
EventSetup.h
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:671
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:43
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12