CMS 3D CMS Logo

NuclearInteractionFinder.cc
Go to the documentation of this file.
4 
6 
9 
12 
14 
16 
18 
20  : maxHits(iConfig.getParameter<int>("maxHits")),
21  rescaleErrorFactor(iConfig.getParameter<double>("rescaleErrorFactor")),
22  checkCompletedTrack(iConfig.getParameter<bool>("checkCompletedTrack")),
23  navigationSchoolName(iConfig.getParameter<std::string>("NavigationSchool")) {
24  std::string measurementTrackerName = iConfig.getParameter<std::string>("MeasurementTrackerName");
25 
29  edm::ESHandle<MeasurementTracker> measurementTrackerHandle;
30  edm::ESHandle<GeometricSearchTracker> theGeomSearchTrackerHandle;
31  edm::ESHandle<TrackerGeometry> theTrackerGeom;
32 
33  es.get<TrackerDigiGeometryRecord>().get(theTrackerGeom);
34  es.get<TrackingComponentsRecord>().get("PropagatorWithMaterial", prop);
35  es.get<TrackingComponentsRecord>().get("Chi2", est);
36  es.get<CkfComponentsRecord>().get(measurementTrackerName, measurementTrackerHandle);
37  es.get<TrackerRecoGeometryRecord>().get(theGeomSearchTrackerHandle);
39 
42  theNavigationSchool = nav.product();
43 
44  thePropagator = prop.product();
45  theEstimator = est.product();
46  theMeasurementTracker = measurementTrackerHandle.product();
47  theGeomSearchTracker = theGeomSearchTrackerHandle.product();
48 
49  LogDebug("NuclearSeedGenerator") << "New NuclearInteractionFinder instance with parameters : \n"
50  << "maxHits : " << maxHits << "\n"
51  << "rescaleErrorFactor : " << rescaleErrorFactor << "\n"
52  << "checkCompletedTrack : " << checkCompletedTrack << "\n";
53 
54  nuclTester = new NuclearTester(maxHits, theEstimator, theTrackerGeom.product());
55 
56  currentSeed = new SeedFromNuclearInteraction(thePropagator, theTrackerGeom.product(), iConfig);
57 
59 }
60 //----------------------------------------------------------------------
62  delete nuclTester;
63  delete currentSeed;
64  delete thePrimaryHelix;
65 }
66 
67 //----------------------------------------------------------------------
69  if (traj.empty() || !traj.isValid())
70  return false;
71 
72  LogDebug("NuclearSeedGenerator") << "Analyzis of a new trajectory with a number of valid hits = " << traj.foundHits();
73 
74  std::vector<TrajectoryMeasurement> measurements = traj.measurements();
75 
76  // initialization
77  nuclTester->reset(measurements.size());
78  allSeeds.clear();
79 
80  LayerMeasurements layerMeasurements(*theMeasurementTracker, event);
81 
82  if (traj.direction() == alongMomentum) {
83  std::reverse(measurements.begin(), measurements.end());
84  }
85 
86  std::vector<TrajectoryMeasurement>::const_iterator it_meas = measurements.begin();
87 
88  std::vector<double> ncompatibleHits;
89  bool NIfound = false;
90 
91  // Loop on all the RecHits.
92  while (!NIfound) {
93  if (it_meas == measurements.end())
94  break;
95 
96  // check only the maxHits outermost hits of the primary track
98  break;
99 
100  nuclTester->push_back(*it_meas, findCompatibleMeasurements(*it_meas, rescaleErrorFactor, layerMeasurements));
101 
102  LogDebug("NuclearSeedGenerator") << "Number of compatible meas:" << (nuclTester->back()).size() << "\n"
103  << "Mean distance between hits :" << nuclTester->meanHitDistance() << "\n"
104  << "Forward estimate :" << nuclTester->fwdEstimate() << "\n";
105 
106  // don't check tracks which reach the end of the tracker if checkCompletedTrack==false
107  if (checkCompletedTrack == false && (nuclTester->compatibleHits()).front() == 0)
108  break;
109 
111  NIfound = true;
112 
113  ++it_meas;
114  }
115 
116  if (NIfound) {
117  LogDebug("NuclearSeedGenerator") << "NUCLEAR INTERACTION FOUND at index : " << nuclTester->nuclearIndex() << "\n";
118 
119  // Get correct parametrization of the helix of the primary track at the interaction point (to be used by improveCurrentSeed)
120  definePrimaryHelix(measurements.begin() + nuclTester->nuclearIndex() - 1);
121 
122  this->fillSeeds(nuclTester->goodTMPair());
123 
124  return true;
125  }
126 
127  return false;
128 }
129 //----------------------------------------------------------------------
130 void NuclearInteractionFinder::definePrimaryHelix(std::vector<TrajectoryMeasurement>::const_iterator it_meas) {
131  // This method uses the 3 last TM after the interaction point to calculate the helix parameters
132 
133  GlobalPoint pt[3];
134  for (int i = 0; i < 3; i++) {
135  pt[i] = (it_meas->updatedState()).globalParameters().position();
136  it_meas++;
137  }
138  delete thePrimaryHelix;
139  thePrimaryHelix = new TangentHelix(pt[0], pt[1], pt[2]);
140 }
141 //----------------------------------------------------------------------
142 std::vector<TrajectoryMeasurement> NuclearInteractionFinder::findCompatibleMeasurements(
143  const TM& lastMeas, double rescale, const LayerMeasurements& layerMeasurements) const {
144  const TSOS& currentState = lastMeas.updatedState();
145  LogDebug("NuclearSeedGenerator") << "currentState :" << currentState << "\n";
146 
147  TSOS newState = rescaleError(rescale, currentState);
148  return findMeasurementsFromTSOS(newState, lastMeas.recHit()->geographicalId(), layerMeasurements);
149 }
150 //----------------------------------------------------------------------
151 std::vector<TrajectoryMeasurement> NuclearInteractionFinder::findMeasurementsFromTSOS(
152  const TSOS& currentState, DetId detid, const LayerMeasurements& layerMeasurements) const {
153  using namespace std;
154  int invalidHits = 0;
155  vector<TM> result;
156  const DetLayer* lastLayer = theGeomSearchTracker->detLayer(detid);
157  vector<const DetLayer*> nl;
158 
159  if (lastLayer) {
160  nl = theNavigationSchool->nextLayers(*lastLayer, *currentState.freeState(), alongMomentum);
161  } else {
162  edm::LogError("NuclearInteractionFinder") << "In findCompatibleMeasurements : lastLayer not accessible";
163  return result;
164  }
165 
166  if (nl.empty()) {
167  LogDebug("NuclearSeedGenerator") << "In findCompatibleMeasurements : no compatible layer found";
168  return result;
169  }
170 
171  for (vector<const DetLayer*>::iterator il = nl.begin(); il != nl.end(); il++) {
172  vector<TM> tmp = layerMeasurements.measurements((**il), currentState, *thePropagator, *theEstimator);
173  if (!tmp.empty()) {
174  if (result.empty())
175  result = tmp;
176  else {
177  // keep one dummy TM at the end, skip the others
178  result.insert(result.end() - invalidHits, tmp.begin(), tmp.end());
179  }
180  invalidHits++;
181  }
182  }
183 
184  // sort the final result, keep dummy measurements at the end
185  if (result.size() > 1) {
186  sort(result.begin(), result.end() - invalidHits, TrajMeasLessEstim());
187  }
188  return result;
189 }
190 
191 //----------------------------------------------------------------------
193  const std::pair<TrajectoryMeasurement, std::vector<TrajectoryMeasurement> >& tmPairs) {
194  // This method returns the seeds calculated by the class SeedsFromNuclearInteraction
195 
196  const TM& innerTM = tmPairs.first;
197  const std::vector<TM>& outerTMs = tmPairs.second;
198 
199  // Loop on all outer TM
200  for (std::vector<TM>::const_iterator outtm = outerTMs.begin(); outtm != outerTMs.end(); outtm++) {
201  if ((innerTM.recHit())->isValid() && (outtm->recHit())->isValid()) {
202  currentSeed->setMeasurements(innerTM.updatedState(), innerTM.recHit(), outtm->recHit());
203  allSeeds.push_back(*currentSeed);
204  } else
205  LogDebug("NuclearSeedGenerator") << "The initial hits for seeding are invalid"
206  << "\n";
207  }
208  return;
209 }
210 //----------------------------------------------------------------------
211 std::unique_ptr<TrajectorySeedCollection> NuclearInteractionFinder::getPersistentSeeds() {
212  auto output = std::make_unique<TrajectorySeedCollection>();
213  for (std::vector<SeedFromNuclearInteraction>::const_iterator it_seed = allSeeds.begin(); it_seed != allSeeds.end();
214  it_seed++) {
215  if (it_seed->isValid()) {
216  output->push_back(it_seed->TrajSeed());
217  } else
218  LogDebug("NuclearSeedGenerator") << "The seed is invalid"
219  << "\n";
220  }
221  return output;
222 }
223 //----------------------------------------------------------------------
225  std::vector<SeedFromNuclearInteraction> newSeedCollection;
226 
227  LayerMeasurements layerMeasurements(*theMeasurementTracker, event);
228 
229  // loop on all actual seeds
230  for (std::vector<SeedFromNuclearInteraction>::const_iterator it_seed = allSeeds.begin(); it_seed != allSeeds.end();
231  it_seed++) {
232  if (!it_seed->isValid())
233  continue;
234 
235  // find compatible TM in an outer layer
236  std::vector<TM> thirdTMs =
237  findMeasurementsFromTSOS(it_seed->updatedTSOS(), it_seed->outerHitDetId(), layerMeasurements);
238 
239  // loop on those new TMs
240  for (std::vector<TM>::const_iterator tm = thirdTMs.begin(); tm != thirdTMs.end(); tm++) {
241  if (!tm->recHit()->isValid())
242  continue;
243 
244  // create new seeds collection using the circle equation
245  currentSeed->setMeasurements(*thePrimaryHelix, it_seed->initialTSOS(), it_seed->outerHit(), tm->recHit());
246  newSeedCollection.push_back(*currentSeed);
247  }
248  }
249  allSeeds.clear();
250  allSeeds = newSeedCollection;
251 }
252 //----------------------------------------------------------------------
254  AlgebraicSymMatrix55 m(state.localError().matrix());
256  LocalTrajectoryParameters ltp = state.localParameters();
257 
258  // we assume that the error on q/p is equal to 20% of q/p * rescale
259  mr(0, 0) = (ltp.signedInverseMomentum() * 0.2 * rescale) * (ltp.signedInverseMomentum() * 0.2 * rescale);
260 
261  // the error on dx/z and dy/dz is fixed to 10% (* rescale)
262  mr(1, 1) = 1E-2 * rescale * rescale;
263  mr(2, 2) = 1E-2 * rescale * rescale;
264 
265  // the error on the local x and y positions are not modified.
266  mr(3, 3) = m(3, 3);
267  mr(4, 4) = m(4, 4);
268 
269  return TSOS(ltp, mr, state.surface(), &(state.globalParameters().magneticField()), state.surfaceSide());
270 }
Chi2MeasurementEstimatorBase.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TrajMeasLessEstim.h
NuclearInteractionFinder::run
bool run(const Trajectory &traj, const MeasurementTrackerEvent &event)
Run the Finder.
Definition: NuclearInteractionFinder.cc:68
SeedFromNuclearInteraction::setMeasurements
void setMeasurements(const TSOS &tsosAtInteractionPoint, ConstRecHitPointer ihit, ConstRecHitPointer ohit)
Fill all data members from 2 TM's where the first one is supposed to be at the interaction point.
Definition: SeedFromNuclearInteraction.cc:25
NuclearInteractionFinder::theEstimator
const MeasurementEstimator * theEstimator
Definition: NuclearInteractionFinder.h:86
LayerMeasurements::measurements
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: LayerMeasurements.cc:122
electrons_cff.bool
bool
Definition: electrons_cff.py:393
NavigationSchoolRecord
Definition: NavigationSchoolRecord.h:12
mps_fire.i
i
Definition: mps_fire.py:428
NuclearInteractionFinder::allSeeds
std::vector< SeedFromNuclearInteraction > allSeeds
Definition: NuclearInteractionFinder.h:94
MessageLogger.h
TrackerGeometry.h
ESHandle.h
DetLayer
Definition: DetLayer.h:21
LocalTrajectoryParameters::signedInverseMomentum
float signedInverseMomentum() const
Signed inverse momentum q/p (zero for neutrals).
Definition: LocalTrajectoryParameters.h:113
NuclearInteractionFinder::rescaleError
TrajectoryStateOnSurface rescaleError(float rescale, const TSOS &state) const
Definition: NuclearInteractionFinder.cc:253
NuclearInteractionFinder.h
Trajectory::direction
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
NuclearInteractionFinder::definePrimaryHelix
void definePrimaryHelix(std::vector< TrajectoryMeasurement >::const_iterator it_meas)
Calculate the parameters of the circle representing the primary track at the interaction point.
Definition: NuclearInteractionFinder.cc:130
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
NuclearInteractionFinder::findCompatibleMeasurements
std::vector< TrajectoryMeasurement > findCompatibleMeasurements(const TM &lastMeas, double rescaleFactor, const LayerMeasurements &layerMeasurements) const
Find compatible TM of a TM with error rescaled by rescaleFactor.
Definition: NuclearInteractionFinder.cc:142
NuclearInteractionFinder::NuclearInteractionFinder
NuclearInteractionFinder()
Definition: NuclearInteractionFinder.h:65
TrajMeasLessEstim
Definition: TrajMeasLessEstim.h:10
NuclearInteractionFinder::nav
const NavigationSchool * nav() const
Definition: NuclearInteractionFinder.h:82
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
TrackerRecoGeometryRecord
Definition: TrackerRecoGeometryRecord.h:11
CkfComponentsRecord.h
Trajectory::foundHits
int foundHits() const
Definition: Trajectory.h:206
SeedFromNuclearInteraction
Definition: SeedFromNuclearInteraction.h:19
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
NuclearInteractionFinder::maxHits
unsigned int maxHits
Definition: NuclearInteractionFinder.h:99
HLT_FULL_cff.measurementTrackerName
measurementTrackerName
Definition: HLT_FULL_cff.py:10384
NuclearTester::push_back
void push_back(const TM &init_tm, const TMContainer &vecTM)
Definition: NuclearTester.h:37
groupFilesInBlocks.reverse
reverse
Definition: groupFilesInBlocks.py:131
NuclearInteractionFinder::getPersistentSeeds
std::unique_ptr< TrajectorySeedCollection > getPersistentSeeds()
Fill 'output' with persistent nuclear seeds.
Definition: NuclearInteractionFinder.cc:211
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
NuclearSeed_cfi.rescaleErrorFactor
rescaleErrorFactor
Definition: NuclearSeed_cfi.py:26
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
DetId
Definition: DetId.h:17
NuclearInteractionFinder::TSOS
TrajectoryStateOnSurface TSOS
Definition: NuclearInteractionFinder.h:43
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
NuclearInteractionFinder::fillSeeds
void fillSeeds(const std::pair< TrajectoryMeasurement, std::vector< TrajectoryMeasurement > > &tmPairs)
get the seeds at the interaction point
Definition: NuclearInteractionFinder.cc:192
NuclearTester::goodTMPair
const TMPair & goodTMPair() const
Definition: NuclearTester.h:56
NuclearInteractionFinder::theMeasurementTracker
const MeasurementTracker * theMeasurementTracker
Definition: NuclearInteractionFinder.h:87
LayerMeasurements
Definition: LayerMeasurements.h:18
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
NuclearInteractionFinder::navigationSchoolName
std::string navigationSchoolName
Definition: NuclearInteractionFinder.h:102
CkfComponentsRecord
Definition: CkfComponentsRecord.h:22
NuclearInteractionFinder::thePropagator
const Propagator * thePropagator
Definition: NuclearInteractionFinder.h:85
NuclearTester::nuclearIndex
int nuclearIndex() const
Definition: NuclearTester.h:54
NuclearSeed_cfi.checkCompletedTrack
checkCompletedTrack
Definition: NuclearSeed_cfi.py:28
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
GeometricSearchTracker::detLayer
const DetLayer * detLayer(const DetId &id) const
obsolete method. Use idToLayer() instead.
Definition: GeometricSearchTracker.h:53
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
NuclearInteractionFinder::currentSeed
SeedFromNuclearInteraction * currentSeed
Definition: NuclearInteractionFinder.h:93
NuclearTester::meanHitDistance
double meanHitDistance(const std::vector< TrajectoryMeasurement > &vecTM) const
Definition: NuclearTester.cc:75
MuonErrorMatrixAdjuster_cfi.rescale
rescale
Definition: MuonErrorMatrixAdjuster_cfi.py:8
NuclearTester::back
const TMContainer & back() const
Definition: NuclearTester.h:42
TrajectoryStateWithArbitraryError.h
edm::ESHandle< Propagator >
NuclearTester::nHitsChecked
unsigned int nHitsChecked() const
Definition: NuclearTester.h:58
Point3DBase< float, GlobalTag >
NuclearSeed_cfi.maxHits
maxHits
Definition: NuclearSeed_cfi.py:21
NuclearInteractionFinder::rescaleErrorFactor
double rescaleErrorFactor
Definition: NuclearInteractionFinder.h:100
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
MeasurementTrackerEvent
Definition: MeasurementTrackerEvent.h:16
edm::ParameterSet
Definition: ParameterSet.h:47
NuclearInteractionFinder::theMagField
edm::ESHandle< MagneticField > theMagField
Definition: NuclearInteractionFinder.h:90
NuclearTester::compatibleHits
std::vector< int > compatibleHits() const
Definition: NuclearTester.h:60
NuclearTester::isNuclearInteraction
bool isNuclearInteraction()
Definition: NuclearTester.cc:11
createfilelist.int
int
Definition: createfilelist.py:10
NuclearInteractionFinder::~NuclearInteractionFinder
virtual ~NuclearInteractionFinder()
Definition: NuclearInteractionFinder.cc:61
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
PropagationDirection.h
Trajectory::measurements
DataContainer const & measurements() const
Definition: Trajectory.h:178
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
NuclearInteractionFinder::checkCompletedTrack
bool checkCompletedTrack
Definition: NuclearInteractionFinder.h:101
NuclearInteractionFinder::improveSeeds
void improveSeeds(const MeasurementTrackerEvent &event)
Improve the seeds with a third RecHit.
Definition: NuclearInteractionFinder.cc:224
NuclearInteractionFinder::findMeasurementsFromTSOS
std::vector< TrajectoryMeasurement > findMeasurementsFromTSOS(const TSOS &currentState, DetId detid, const LayerMeasurements &layerMeasurements) const
Definition: NuclearInteractionFinder.cc:151
NuclearInteractionFinder::theNavigationSchool
const NavigationSchool * theNavigationSchool
Definition: NuclearInteractionFinder.h:89
std
Definition: JetResolutionObject.h:76
NuclearTester
Class used to test if a track has interacted nuclearly.
Definition: NuclearTester.h:16
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
Trajectory
Definition: Trajectory.h:38
NuclearInteractionFinder::thePrimaryHelix
TangentHelix * thePrimaryHelix
Definition: NuclearInteractionFinder.h:95
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
NuclearInteractionFinder::nuclTester
NuclearTester * nuclTester
Definition: NuclearInteractionFinder.h:92
TangentHelix
Definition: TangentHelix.h:6
mps_fire.result
result
Definition: mps_fire.py:311
NavigationSchoolRecord.h
event
Definition: event.py:1
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
NuclearTester::reset
void reset(unsigned int nMeasurements)
Definition: NuclearTester.h:48
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
HLTObjectMonitor_cfi.mr
mr
Definition: HLTObjectMonitor_cfi.py:366
alongMomentum
Definition: PropagationDirection.h:4
NuclearTester::fwdEstimate
double fwdEstimate(const std::vector< TrajectoryMeasurement > &vecTM) const
Definition: NuclearTester.cc:107
Trajectory::isValid
bool isValid() const
Definition: Trajectory.h:257
NuclearInteractionFinder::theGeomSearchTracker
const GeometricSearchTracker * theGeomSearchTracker
Definition: NuclearInteractionFinder.h:88
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
Trajectory::empty
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:233
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12