CMS 3D CMS Logo

MuonCkfTrajectoryBuilder.cc
Go to the documentation of this file.
2 
16 #include <sstream>
17 
19  : CkfTrajectoryBuilder(conf, iC),
20  theDeltaEta(conf.getParameter<double>("deltaEta")),
21  theDeltaPhi(conf.getParameter<double>("deltaPhi")),
22  theProximityPropagatorName(conf.getParameter<std::string>("propagatorProximity")),
23  theProximityPropagator(nullptr),
24  theEtaPhiEstimator(nullptr) {
25  //and something specific to me ?
26  theUseSeedLayer = conf.getParameter<bool>("useSeedLayer");
27  theRescaleErrorIfFail = conf.getParameter<double>("rescaleErrorIfFail");
28 }
29 
31 
34 
35  edm::ESHandle<Propagator> propagatorProximityHandle;
36  iSetup.get<TrackingComponentsRecord>().get(theProximityPropagatorName, propagatorProximityHandle);
37  theProximityPropagator = propagatorProximityHandle.product();
38 
39  // theEstimator is set for this event in the base class
40  if (theEstimatorWatcher.check(iSetup) && theDeltaEta > 0 && theDeltaPhi > 0)
41  theEtaPhiEstimator = std::make_unique<EtaPhiEstimator>(theDeltaEta, theDeltaPhi, theEstimator);
42 }
43 
44 /*
45 std::string dumpMeasurement(const TrajectoryMeasurement & tm)
46 {
47  std::stringstream buffer;
48  buffer<<"layer pointer: "<<tm.layer()<<"\n"
49  <<"estimate: "<<tm.estimate()<<"\n"
50  <<"forward state: \n"
51  <<"x: "<<tm.forwardPredictedState().globalPosition()<<"\n"
52  <<"p: "<<tm.forwardPredictedState().globalMomentum()<<"\n"
53  <<"geomdet pointer from rechit: "<<tm.recHit()->det()<<"\n"
54  <<"detId: "<<tm.recHit()->geographicalId().rawId();
55  if (tm.recHit()->isValid()){
56  buffer<<"\n hit global x: "<<tm.recHit()->globalPosition()
57  <<"\n hit global error: "<<tm.recHit()->globalPositionError().matrix()
58  <<"\n hit local x:"<<tm.recHit()->localPosition()
59  <<"\n hit local error"<<tm.recHit()->localPositionError();
60  }
61  return buffer.str();
62 }
63 std::string dumpMeasurements(const std::vector<TrajectoryMeasurement> & v)
64 {
65  std::stringstream buffer;
66  buffer<<v.size()<<" total measurements\n";
67  for (std::vector<TrajectoryMeasurement>::const_iterator it = v.begin(); it!=v.end();++it){
68  buffer<<dumpMeasurement(*it);
69  buffer<<"\n";}
70  return buffer.str();
71 }
72 */
73 
75  const std::vector<const DetLayer*>& nl,
76  const TrajectoryStateOnSurface& currentState,
77  std::vector<TM>& result,
78  int& invalidHits,
79  const Propagator* prop) const {
80  for (std::vector<const DetLayer*>::const_iterator il = nl.begin(); il != nl.end(); il++) {
81  TSOS stateToUse = currentState;
82 
83  if (layer == (*il)) {
84  LogDebug("CkfPattern") << " self propagating in findCompatibleMeasurements.\n from: \n" << stateToUse;
85  //self navigation case
86  // go to a middle point first
88  GlobalPoint center(0, 0, 0);
89  stateToUse = middle.extrapolate(stateToUse, center, *prop);
90 
91  if (!stateToUse.isValid())
92  continue;
93  LogDebug("CkfPattern") << "to: " << stateToUse;
94  }
95 
97  std::vector<TM> tmp = layerMeasurements.measurements((**il), stateToUse, *prop, *theEstimator);
98 
99  if (tmp.size() == 1 && theEtaPhiEstimator) {
100  LogDebug("CkfPattern") << "only an invalid hit is found. trying differently";
101  tmp = layerMeasurements.measurements((**il), stateToUse, *prop, *theEtaPhiEstimator);
102  }
103  LogDebug("CkfPattern") << tmp.size() << " measurements returned by LayerMeasurements";
104 
105  if (!tmp.empty()) {
106  // FIXME durty-durty-durty cleaning: never do that please !
107  /* for (vector<TM>::iterator it = tmp.begin(); it!=tmp.end(); ++it)
108  {if (it->recHit()->det()==0) it=tmp.erase(it)--;}*/
109 
110  if (result.empty())
111  result = tmp;
112  else {
113  // keep one dummy TM at the end, skip the others
114  result.insert(result.end() - invalidHits, tmp.begin(), tmp.end());
115  }
116  invalidHits++;
117  }
118  }
119 
120  LogDebug("CkfPattern") << "starting from:\n"
121  << "x: " << currentState.globalPosition() << "\n"
122  << "p: " << currentState.globalMomentum() << "\n"
124 }
125 
127  const TempTrajectory& traj,
128  std::vector<TrajectoryMeasurement>& result) const {
129  int invalidHits = 0;
130 
131  std::vector<const DetLayer*> nl;
132 
133  if (traj.empty()) {
134  LogDebug("CkfPattern") << "using JR patch for no measurement case";
135  //what if there are no measurement on the Trajectory
136 
137  //set the currentState to be the one from the trajectory seed starting point
138  PTrajectoryStateOnDet ptod = seed.startingState();
139  DetId id(ptod.detId());
141  const Surface* surface = &g->surface();
142 
143  TrajectoryStateOnSurface currentState(
145 
146  //set the next layers to be that one the state is on
148 
149  if (theUseSeedLayer) {
150  {
151  //get the measurements on the layer first
152  LogDebug("CkfPattern") << "using the layer of the seed first.";
153  nl.push_back(l);
154  collectMeasurement(l, nl, currentState, result, invalidHits, theProximityPropagator);
155  }
156 
157  //if fails: try to rescale locally the state to find measurements
158  if ((unsigned int)invalidHits == result.size() && theRescaleErrorIfFail != 1.0 && !result.empty()) {
159  result.clear();
160  LogDebug("CkfPattern") << "using a rescale by " << theRescaleErrorIfFail << " to find measurements.";
161  TrajectoryStateOnSurface rescaledCurrentState = currentState;
162  rescaledCurrentState.rescaleError(theRescaleErrorIfFail);
163  invalidHits = 0;
164  collectMeasurement(l, nl, rescaledCurrentState, result, invalidHits, theProximityPropagator);
165  }
166  }
167 
168  //if fails: go to next layers
169  if (result.empty() || (unsigned int)invalidHits == result.size()) {
170  result.clear();
171  LogDebug("CkfPattern") << "Need to go to next layer to get measurements";
172  //the following will "JUMP" the first layer measurements
173  nl = theNavigationSchool->nextLayers(*l, *currentState.freeState(), traj.direction());
174  if (nl.empty()) {
175  LogDebug("CkfPattern") << " there was no next layer with wellInside. Use the next with no check.";
176  //means you did not get any compatible layer on the next 1/2 tracker layer.
177  // use the next layers with no checking
179  }
180  invalidHits = 0;
181  collectMeasurement(l, nl, currentState, result, invalidHits, forwardPropagator(seed));
182  }
183 
184  //if fails: this is on the next layers already, try rescaling locally the state
185  if (!result.empty() && (unsigned int)invalidHits == result.size() && theRescaleErrorIfFail != 1.0) {
186  result.clear();
187  LogDebug("CkfPattern") << "using a rescale by " << theRescaleErrorIfFail
188  << " to find measurements on next layers.";
189  TrajectoryStateOnSurface rescaledCurrentState = currentState;
190  rescaledCurrentState.rescaleError(theRescaleErrorIfFail);
191  invalidHits = 0;
192  collectMeasurement(l, nl, rescaledCurrentState, result, invalidHits, forwardPropagator(seed));
193  }
194 
195  } else //regular case
196  {
197  TSOS currentState(traj.lastMeasurement().updatedState());
198 
199  nl = theNavigationSchool->nextLayers(*traj.lastLayer(), *currentState.freeState(), traj.direction());
200  if (nl.empty()) {
201  LogDebug("CkfPattern") << " no next layers... going " << traj.direction() << "\n from: \n"
202  << currentState
203  << "\n from detId: " << traj.lastMeasurement().recHit()->geographicalId().rawId();
204  return;
205  }
206 
207  collectMeasurement(traj.lastLayer(), nl, currentState, result, invalidHits, forwardPropagator(seed));
208  }
209 
210  // sort the final result, keep dummy measurements at the end
211  if (result.size() > 1) {
212  sort(result.begin(), result.end() - invalidHits, TrajMeasLessEstim());
213  }
214 
215 #ifdef DEBUG_INVALID
216  bool afterInvalid = false;
217  for (std::vector<TM>::const_iterator i = result.begin(); i != result.end(); i++) {
218  if (!i->recHit().isValid())
219  afterInvalid = true;
220  if (afterInvalid && i->recHit().isValid()) {
221  edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: valid hit after invalid!";
222  }
223  }
224 #endif
225 
226  //analyseMeasurements( result, traj);
227 }
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
Chi2MeasurementEstimatorBase.h
MuonCkfTrajectoryBuilder::theProximityPropagatorName
const std::string theProximityPropagatorName
Definition: MuonCkfTrajectoryBuilder.h:31
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TrajMeasLessEstim.h
MuonCkfTrajectoryBuilder::MuonCkfTrajectoryBuilder
MuonCkfTrajectoryBuilder(const edm::ParameterSet &conf, edm::ConsumesCollector &iC)
Definition: MuonCkfTrajectoryBuilder.cc:18
mps_fire.i
i
Definition: mps_fire.py:428
TempTrajectory::direction
PropagationDirection direction() const
Definition: TempTrajectory.cc:118
MeasurementTrackerEvent.h
MessageLogger.h
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
TrajectoryFilter.h
DetLayer
Definition: DetLayer.h:21
TempTrajectory
Definition: TempTrajectory.h:40
MuonCkfTrajectoryBuilder::theEtaPhiEstimator
std::unique_ptr< Chi2MeasurementEstimatorBase > theEtaPhiEstimator
Definition: MuonCkfTrajectoryBuilder.h:34
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
BaseCkfTrajectoryBuilder::theEstimator
const Chi2MeasurementEstimatorBase * theEstimator
Definition: BaseCkfTrajectoryBuilder.h:173
MeasurementTrackerEvent::geomTracker
const TrackerGeometry * geomTracker() const
Definition: MeasurementTrackerEvent.h:72
Surface
Definition: Surface.h:36
TrajMeasLessEstim
Definition: TrajMeasLessEstim.h:10
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
TransverseImpactPointExtrapolator
Definition: TransverseImpactPointExtrapolator.h:26
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
MuonCkfTrajectoryBuilder::collectMeasurement
void collectMeasurement(const DetLayer *layer, const std::vector< const DetLayer * > &nl, const TrajectoryStateOnSurface &currentState, std::vector< TM > &result, int &invalidHits, const Propagator *) const
Definition: MuonCkfTrajectoryBuilder.cc:74
EtaPhiEstimator.h
MuonCkfTrajectoryBuilder::findCompatibleMeasurements
void findCompatibleMeasurements(const TrajectorySeed &seed, const TempTrajectory &traj, std::vector< TrajectoryMeasurement > &result) const override
Definition: MuonCkfTrajectoryBuilder.cc:126
fileCollector.seed
seed
Definition: fileCollector.py:127
Propagator
Definition: Propagator.h:44
DetId
Definition: DetId.h:17
GeometricSearchTracker.h
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
LayerMeasurements
Definition: LayerMeasurements.h:18
PTrajectoryStateOnDet::detId
unsigned int detId() const
Definition: PTrajectoryStateOnDet.h:65
NavigationSchool::nextLayers
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&... args) const
Definition: NavigationSchool.h:33
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
PrintoutHelper::dumpMeasurements
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
Definition: PrintoutHelper.cc:21
MuonCkfTrajectoryBuilder::theDeltaEta
const double theDeltaEta
Definition: MuonCkfTrajectoryBuilder.h:29
TempTrajectory::lastMeasurement
const TrajectoryMeasurement & lastMeasurement() const
Definition: TempTrajectory.h:159
LayerMeasurements.h
GeometricSearchTracker::detLayer
const DetLayer * detLayer(const DetId &id) const
obsolete method. Use idToLayer() instead.
Definition: GeometricSearchTracker.h:53
edm::ESHandle< Propagator >
BaseCkfTrajectoryBuilder::theMeasurementTracker
const MeasurementTrackerEvent * theMeasurementTracker
Definition: BaseCkfTrajectoryBuilder.h:175
Point3DBase< float, GlobalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MuonCkfTrajectoryBuilder.h
MeasurementTrackerEvent::measurementTracker
const MeasurementTracker & measurementTracker() const
Definition: MeasurementTrackerEvent.h:61
MuonCkfTrajectoryBuilder::theProximityPropagator
const Propagator * theProximityPropagator
Definition: MuonCkfTrajectoryBuilder.h:32
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
MuonCkfTrajectoryBuilder::theRescaleErrorIfFail
double theRescaleErrorIfFail
Definition: MuonCkfTrajectoryBuilder.h:28
MeasurementTrackerEvent::geometricSearchTracker
const GeometricSearchTracker * geometricSearchTracker() const
Definition: MeasurementTrackerEvent.h:73
MuonCkfTrajectoryBuilder::setEvent_
void setEvent_(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: MuonCkfTrajectoryBuilder.cc:32
CkfTrajectoryBuilder
Definition: CkfTrajectoryBuilder.h:33
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
BaseCkfTrajectoryBuilder::theNavigationSchool
const NavigationSchool * theNavigationSchool
Definition: BaseCkfTrajectoryBuilder.h:176
BaseCkfTrajectoryBuilder::forwardPropagator
const Propagator * forwardPropagator(const TrajectorySeed &seed) const
Definition: BaseCkfTrajectoryBuilder.h:160
MuonCkfTrajectoryBuilder::theEstimatorWatcher
edm::ESWatcher< BaseCkfTrajectoryBuilder::Chi2MeasurementEstimatorRecord > theEstimatorWatcher
Definition: MuonCkfTrajectoryBuilder.h:33
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
TrajectoryStateOnSurface::rescaleError
void rescaleError(double factor)
Definition: TrajectoryStateOnSurface.h:82
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
CkfTrajectoryBuilder::setEvent_
void setEvent_(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: CkfTrajectoryBuilder.cc:56
TrajectoryStateOnSurface::globalMomentum
GlobalVector globalMomentum() const
Definition: TrajectoryStateOnSurface.h:66
std
Definition: JetResolutionObject.h:76
outsideIn
Definition: NavigationDirection.h:4
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
MuonCkfTrajectoryBuilder::theUseSeedLayer
bool theUseSeedLayer
Definition: MuonCkfTrajectoryBuilder.h:27
TransverseImpactPointExtrapolator.h
TrajectorySeed
Definition: TrajectorySeed.h:18
TransverseImpactPointExtrapolator::extrapolate
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
Definition: TransverseImpactPointExtrapolator.cc:23
TempTrajectory::lastLayer
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
Definition: TempTrajectory.h:237
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrajectoryStateTransform.h
insideOut
Definition: NavigationDirection.h:4
mps_fire.result
result
Definition: mps_fire.py:311
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
NavigationSchool.h
edm::Event
Definition: Event.h:73
MuonCkfTrajectoryBuilder::~MuonCkfTrajectoryBuilder
~MuonCkfTrajectoryBuilder() override
Definition: MuonCkfTrajectoryBuilder.cc:30
MuonCkfTrajectoryBuilder::theDeltaPhi
const double theDeltaPhi
Definition: MuonCkfTrajectoryBuilder.h:30
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
alongMomentum
Definition: PropagationDirection.h:4
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
MeasurementTracker.h
TempTrajectory::empty
bool empty() const
True if trajectory has no measurements.
Definition: TempTrajectory.h:210
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12