CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
NuclearInteractionFinder Class Reference

Class used to obtain vector of all compatible TMs associated to a trajectory to be used by the NuclearTester. More...

#include <NuclearInteractionFinder.h>

Classes

struct  Config
 

Public Member Functions

std::unique_ptr< TrajectorySeedCollectiongetPersistentSeeds ()
 Fill 'output' with persistent nuclear seeds. More...
 
void improveSeeds (const MeasurementTrackerEvent &event)
 Improve the seeds with a third RecHit. More...
 
const NavigationSchoolnav () const
 
 NuclearInteractionFinder (const Config &iConfig, const TrackerGeometry *theTrckerGeom, const Propagator *thePropagator, const MeasurementEstimator *theEstimator, const MeasurementTracker *theMeasurementTracker, const GeometricSearchTracker *theGeomSearchTracker, const NavigationSchool *theNavigationSchool)
 
TrajectoryStateOnSurface rescaleError (float rescale, const TSOS &state) const
 
bool run (const Trajectory &traj, const MeasurementTrackerEvent &event)
 Run the Finder. More...
 

Private Types

typedef TrajectoryMeasurement::ConstRecHitPointer ConstRecHitPointer
 
typedef FreeTrajectoryState FTS
 
typedef TrajectoryMeasurement TM
 
typedef std::vector< TrajectoryTrajectoryContainer
 
typedef TrajectoryStateOnSurface TSOS
 

Private Member Functions

void definePrimaryHelix (std::vector< TrajectoryMeasurement >::const_iterator it_meas)
 Calculate the parameters of the circle representing the primary track at the interaction point. More...
 
void fillSeeds (const std::pair< TrajectoryMeasurement, std::vector< TrajectoryMeasurement > > &tmPairs)
 get the seeds at the interaction point More...
 
std::vector< TrajectoryMeasurementfindCompatibleMeasurements (const TM &lastMeas, double rescaleFactor, const LayerMeasurements &layerMeasurements) const
 Find compatible TM of a TM with error rescaled by rescaleFactor. More...
 
std::vector< TrajectoryMeasurementfindMeasurementsFromTSOS (const TSOS &currentState, DetId detid, const LayerMeasurements &layerMeasurements) const
 

Private Attributes

std::vector< SeedFromNuclearInteractionallSeeds
 
bool checkCompletedTrack
 
std::unique_ptr< SeedFromNuclearInteractioncurrentSeed
 
unsigned int maxHits
 
std::unique_ptr< NuclearTesternuclTester
 
double rescaleErrorFactor
 
const MeasurementEstimatortheEstimator
 
const GeometricSearchTrackertheGeomSearchTracker
 
const MeasurementTrackertheMeasurementTracker
 
const NavigationSchooltheNavigationSchool
 
std::unique_ptr< TangentHelixthePrimaryHelix
 
const PropagatorthePropagator
 

Detailed Description

Class used to obtain vector of all compatible TMs associated to a trajectory to be used by the NuclearTester.

The method run gets all compatible TMs of all TMs associated of a trajectory. Then it uses the NuclearTester class to decide whether the trajectory has interacted nuclearly or not. It finally returns a pair of the TM where the nuclear interaction occurs and all compatible TMs associated.

Definition at line 36 of file NuclearInteractionFinder.h.

Member Typedef Documentation

◆ ConstRecHitPointer

Definition at line 42 of file NuclearInteractionFinder.h.

◆ FTS

Definition at line 39 of file NuclearInteractionFinder.h.

◆ TM

Definition at line 40 of file NuclearInteractionFinder.h.

◆ TrajectoryContainer

Definition at line 41 of file NuclearInteractionFinder.h.

◆ TSOS

Definition at line 38 of file NuclearInteractionFinder.h.

Constructor & Destructor Documentation

◆ NuclearInteractionFinder()

NuclearInteractionFinder::NuclearInteractionFinder ( const Config iConfig,
const TrackerGeometry theTrckerGeom,
const Propagator thePropagator,
const MeasurementEstimator theEstimator,
const MeasurementTracker theMeasurementTracker,
const GeometricSearchTracker theGeomSearchTracker,
const NavigationSchool theNavigationSchool 
)

Definition at line 13 of file NuclearInteractionFinder.cc.

References checkCompletedTrack, currentSeed, LogDebug, maxHits, nuclTester, NuclearInteractionFinder::Config::ptMin, rescaleErrorFactor, theEstimator, theGeomSearchTracker, theMeasurementTracker, theNavigationSchool, thePrimaryHelix, and thePropagator.

20  : maxHits(iConfig.maxHits),
21  rescaleErrorFactor(iConfig.rescaleErrorFactor),
22  checkCompletedTrack(iConfig.checkCompletedTrack) {
23  thePropagator = iPropagator;
24  theEstimator = iEstimator;
25  theMeasurementTracker = iMeasurementTracker;
26  theGeomSearchTracker = iGeomSearchTracker;
27  theNavigationSchool = iNavigationSchool;
28 
29  LogDebug("NuclearSeedGenerator") << "New NuclearInteractionFinder instance with parameters : \n"
30  << "maxHits : " << maxHits << "\n"
31  << "rescaleErrorFactor : " << rescaleErrorFactor << "\n"
32  << "checkCompletedTrack : " << checkCompletedTrack << "\n";
33 
34  nuclTester = std::make_unique<NuclearTester>(maxHits, theEstimator, iTrackerGeom);
35 
36  currentSeed = std::make_unique<SeedFromNuclearInteraction>(thePropagator, iTrackerGeom, iConfig.ptMin);
37 
38  thePrimaryHelix = std::make_unique<TangentHelix>();
39 }
std::unique_ptr< TangentHelix > thePrimaryHelix
std::unique_ptr< SeedFromNuclearInteraction > currentSeed
std::unique_ptr< NuclearTester > nuclTester
const MeasurementTracker * theMeasurementTracker
const NavigationSchool * theNavigationSchool
const MeasurementEstimator * theEstimator
const GeometricSearchTracker * theGeomSearchTracker
#define LogDebug(id)

Member Function Documentation

◆ definePrimaryHelix()

void NuclearInteractionFinder::definePrimaryHelix ( std::vector< TrajectoryMeasurement >::const_iterator  it_meas)
private

Calculate the parameters of the circle representing the primary track at the interaction point.

Definition at line 104 of file NuclearInteractionFinder.cc.

References mps_fire::i, DiDispStaMuonMonitor_cfi::pt, and thePrimaryHelix.

Referenced by run().

104  {
105  // This method uses the 3 last TM after the interaction point to calculate the helix parameters
106 
107  GlobalPoint pt[3];
108  for (int i = 0; i < 3; i++) {
109  pt[i] = (it_meas->updatedState()).globalParameters().position();
110  it_meas++;
111  }
112  thePrimaryHelix = std::make_unique<TangentHelix>(pt[0], pt[1], pt[2]);
113 }
std::unique_ptr< TangentHelix > thePrimaryHelix

◆ fillSeeds()

void NuclearInteractionFinder::fillSeeds ( const std::pair< TrajectoryMeasurement, std::vector< TrajectoryMeasurement > > &  tmPairs)
private

get the seeds at the interaction point

Definition at line 165 of file NuclearInteractionFinder.cc.

References allSeeds, currentSeed, sistrip::SpyUtilities::isValid(), LogDebug, TrajectoryMeasurement::recHit(), and TrajectoryMeasurement::updatedState().

Referenced by run().

166  {
167  // This method returns the seeds calculated by the class SeedsFromNuclearInteraction
168 
169  const TM& innerTM = tmPairs.first;
170  const std::vector<TM>& outerTMs = tmPairs.second;
171 
172  // Loop on all outer TM
173  for (std::vector<TM>::const_iterator outtm = outerTMs.begin(); outtm != outerTMs.end(); outtm++) {
174  if ((innerTM.recHit())->isValid() && (outtm->recHit())->isValid()) {
175  currentSeed->setMeasurements(innerTM.updatedState(), innerTM.recHit(), outtm->recHit());
176  allSeeds.push_back(*currentSeed);
177  } else
178  LogDebug("NuclearSeedGenerator") << "The initial hits for seeding are invalid"
179  << "\n";
180  }
181  return;
182 }
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
std::unique_ptr< SeedFromNuclearInteraction > currentSeed
std::vector< SeedFromNuclearInteraction > allSeeds
#define LogDebug(id)

◆ findCompatibleMeasurements()

std::vector< TrajectoryMeasurement > NuclearInteractionFinder::findCompatibleMeasurements ( const TM lastMeas,
double  rescaleFactor,
const LayerMeasurements layerMeasurements 
) const
private

Find compatible TM of a TM with error rescaled by rescaleFactor.

Definition at line 115 of file NuclearInteractionFinder.cc.

References findMeasurementsFromTSOS(), LogDebug, TrajectoryMeasurement::recHit(), rescaleError(), and TrajectoryMeasurement::updatedState().

Referenced by run().

116  {
117  const TSOS& currentState = lastMeas.updatedState();
118  LogDebug("NuclearSeedGenerator") << "currentState :" << currentState << "\n";
119 
120  TSOS newState = rescaleError(rescale, currentState);
121  return findMeasurementsFromTSOS(newState, lastMeas.recHit()->geographicalId(), layerMeasurements);
122 }
std::vector< TrajectoryMeasurement > findMeasurementsFromTSOS(const TSOS &currentState, DetId detid, const LayerMeasurements &layerMeasurements) const
TrajectoryStateOnSurface rescaleError(float rescale, const TSOS &state) const
#define LogDebug(id)

◆ findMeasurementsFromTSOS()

std::vector< TrajectoryMeasurement > NuclearInteractionFinder::findMeasurementsFromTSOS ( const TSOS currentState,
DetId  detid,
const LayerMeasurements layerMeasurements 
) const
private

Definition at line 124 of file NuclearInteractionFinder.cc.

References alongMomentum, GeometricSearchTracker::detLayer(), TrajectoryStateOnSurface::freeState(), LogDebug, LayerMeasurements::measurements(), NavigationSchool::nextLayers(), mps_fire::result, jetUpdater_cfi::sort, theEstimator, theGeomSearchTracker, theNavigationSchool, thePropagator, and createJobs::tmp.

Referenced by findCompatibleMeasurements(), and improveSeeds().

125  {
126  using namespace std;
127  int invalidHits = 0;
128  vector<TM> result;
129  const DetLayer* lastLayer = theGeomSearchTracker->detLayer(detid);
130  vector<const DetLayer*> nl;
131 
132  if (lastLayer) {
133  nl = theNavigationSchool->nextLayers(*lastLayer, *currentState.freeState(), alongMomentum);
134  } else {
135  edm::LogError("NuclearInteractionFinder") << "In findCompatibleMeasurements : lastLayer not accessible";
136  return result;
137  }
138 
139  if (nl.empty()) {
140  LogDebug("NuclearSeedGenerator") << "In findCompatibleMeasurements : no compatible layer found";
141  return result;
142  }
143 
144  for (vector<const DetLayer*>::iterator il = nl.begin(); il != nl.end(); il++) {
145  vector<TM> tmp = layerMeasurements.measurements((**il), currentState, *thePropagator, *theEstimator);
146  if (!tmp.empty()) {
147  if (result.empty())
148  result = tmp;
149  else {
150  // keep one dummy TM at the end, skip the others
151  result.insert(result.end() - invalidHits, tmp.begin(), tmp.end());
152  }
153  invalidHits++;
154  }
155  }
156 
157  // sort the final result, keep dummy measurements at the end
158  if (result.size() > 1) {
159  sort(result.begin(), result.end() - invalidHits, TrajMeasLessEstim());
160  }
161  return result;
162 }
const DetLayer * detLayer(const DetId &id) const
obsolete method. Use idToLayer() instead.
Log< level::Error, false > LogError
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&... args) const
const NavigationSchool * theNavigationSchool
const MeasurementEstimator * theEstimator
const GeometricSearchTracker * theGeomSearchTracker
FreeTrajectoryState const * freeState(bool withErrors=true) const
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
tmp
align.sh
Definition: createJobs.py:716
#define LogDebug(id)

◆ getPersistentSeeds()

std::unique_ptr< TrajectorySeedCollection > NuclearInteractionFinder::getPersistentSeeds ( )

Fill 'output' with persistent nuclear seeds.

Definition at line 184 of file NuclearInteractionFinder.cc.

References allSeeds, LogDebug, and convertSQLitetoXML_cfg::output.

184  {
185  auto output = std::make_unique<TrajectorySeedCollection>();
186  for (std::vector<SeedFromNuclearInteraction>::const_iterator it_seed = allSeeds.begin(); it_seed != allSeeds.end();
187  it_seed++) {
188  if (it_seed->isValid()) {
189  output->push_back(it_seed->TrajSeed());
190  } else
191  LogDebug("NuclearSeedGenerator") << "The seed is invalid"
192  << "\n";
193  }
194  return output;
195 }
std::vector< SeedFromNuclearInteraction > allSeeds
#define LogDebug(id)

◆ improveSeeds()

void NuclearInteractionFinder::improveSeeds ( const MeasurementTrackerEvent event)

Improve the seeds with a third RecHit.

Definition at line 197 of file NuclearInteractionFinder.cc.

References allSeeds, currentSeed, findMeasurementsFromTSOS(), theMeasurementTracker, and thePrimaryHelix.

197  {
198  std::vector<SeedFromNuclearInteraction> newSeedCollection;
199 
200  LayerMeasurements layerMeasurements(*theMeasurementTracker, event);
201 
202  // loop on all actual seeds
203  for (std::vector<SeedFromNuclearInteraction>::const_iterator it_seed = allSeeds.begin(); it_seed != allSeeds.end();
204  it_seed++) {
205  if (!it_seed->isValid())
206  continue;
207 
208  // find compatible TM in an outer layer
209  std::vector<TM> thirdTMs =
210  findMeasurementsFromTSOS(it_seed->updatedTSOS(), it_seed->outerHitDetId(), layerMeasurements);
211 
212  // loop on those new TMs
213  for (std::vector<TM>::const_iterator tm = thirdTMs.begin(); tm != thirdTMs.end(); tm++) {
214  if (!tm->recHit()->isValid())
215  continue;
216 
217  // create new seeds collection using the circle equation
218  currentSeed->setMeasurements(*thePrimaryHelix, it_seed->initialTSOS(), it_seed->outerHit(), tm->recHit());
219  newSeedCollection.push_back(*currentSeed);
220  }
221  }
222  allSeeds.clear();
223  allSeeds = newSeedCollection;
224 }
std::unique_ptr< TangentHelix > thePrimaryHelix
std::unique_ptr< SeedFromNuclearInteraction > currentSeed
const MeasurementTracker * theMeasurementTracker
std::vector< SeedFromNuclearInteraction > allSeeds
std::vector< TrajectoryMeasurement > findMeasurementsFromTSOS(const TSOS &currentState, DetId detid, const LayerMeasurements &layerMeasurements) const
Definition: event.py:1

◆ nav()

const NavigationSchool* NuclearInteractionFinder::nav ( ) const
inline

Definition at line 86 of file NuclearInteractionFinder.h.

References theNavigationSchool.

86 { return theNavigationSchool; }
const NavigationSchool * theNavigationSchool

◆ rescaleError()

TrajectoryStateOnSurface NuclearInteractionFinder::rescaleError ( float  rescale,
const TSOS state 
) const

Definition at line 226 of file NuclearInteractionFinder.cc.

References visualization-live-secondInstance_cfg::m, HLTObjectMonitor_cfi::mr, and LocalTrajectoryParameters::signedInverseMomentum().

Referenced by findCompatibleMeasurements().

226  {
227  AlgebraicSymMatrix55 m(state.localError().matrix());
229  LocalTrajectoryParameters ltp = state.localParameters();
230 
231  // we assume that the error on q/p is equal to 20% of q/p * rescale
232  mr(0, 0) = (ltp.signedInverseMomentum() * 0.2 * rescale) * (ltp.signedInverseMomentum() * 0.2 * rescale);
233 
234  // the error on dx/z and dy/dz is fixed to 10% (* rescale)
235  mr(1, 1) = 1E-2 * rescale * rescale;
236  mr(2, 2) = 1E-2 * rescale * rescale;
237 
238  // the error on the local x and y positions are not modified.
239  mr(3, 3) = m(3, 3);
240  mr(4, 4) = m(4, 4);
241 
242  return TSOS(ltp, mr, state.surface(), &(state.globalParameters().magneticField()), state.surfaceSide());
243 }
float signedInverseMomentum() const
Signed inverse momentum q/p (zero for neutrals).
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrajectoryStateOnSurface TSOS

◆ run()

bool NuclearInteractionFinder::run ( const Trajectory traj,
const MeasurementTrackerEvent event 
)

Run the Finder.

Definition at line 42 of file NuclearInteractionFinder.cc.

References allSeeds, alongMomentum, checkCompletedTrack, definePrimaryHelix(), Trajectory::direction(), Trajectory::empty(), fillSeeds(), findCompatibleMeasurements(), Trajectory::foundHits(), Trajectory::isValid(), LogDebug, maxHits, Trajectory::measurements(), nuclTester, rescaleErrorFactor, groupFilesInBlocks::reverse, findQualityFiles::size, and theMeasurementTracker.

42  {
43  if (traj.empty() || !traj.isValid())
44  return false;
45 
46  LogDebug("NuclearSeedGenerator") << "Analyzis of a new trajectory with a number of valid hits = " << traj.foundHits();
47 
48  std::vector<TrajectoryMeasurement> measurements = traj.measurements();
49 
50  // initialization
51  nuclTester->reset(measurements.size());
52  allSeeds.clear();
53 
54  LayerMeasurements layerMeasurements(*theMeasurementTracker, event);
55 
56  if (traj.direction() == alongMomentum) {
57  std::reverse(measurements.begin(), measurements.end());
58  }
59 
60  std::vector<TrajectoryMeasurement>::const_iterator it_meas = measurements.begin();
61 
62  std::vector<double> ncompatibleHits;
63  bool NIfound = false;
64 
65  // Loop on all the RecHits.
66  while (!NIfound) {
67  if (it_meas == measurements.end())
68  break;
69 
70  // check only the maxHits outermost hits of the primary track
71  if (nuclTester->nHitsChecked() > maxHits)
72  break;
73 
74  nuclTester->push_back(*it_meas, findCompatibleMeasurements(*it_meas, rescaleErrorFactor, layerMeasurements));
75 
76  LogDebug("NuclearSeedGenerator") << "Number of compatible meas:" << (nuclTester->back()).size() << "\n"
77  << "Mean distance between hits :" << nuclTester->meanHitDistance() << "\n"
78  << "Forward estimate :" << nuclTester->fwdEstimate() << "\n";
79 
80  // don't check tracks which reach the end of the tracker if checkCompletedTrack==false
81  if (checkCompletedTrack == false && (nuclTester->compatibleHits()).front() == 0)
82  break;
83 
84  if (nuclTester->isNuclearInteraction())
85  NIfound = true;
86 
87  ++it_meas;
88  }
89 
90  if (NIfound) {
91  LogDebug("NuclearSeedGenerator") << "NUCLEAR INTERACTION FOUND at index : " << nuclTester->nuclearIndex() << "\n";
92 
93  // Get correct parametrization of the helix of the primary track at the interaction point (to be used by improveCurrentSeed)
94  definePrimaryHelix(measurements.begin() + nuclTester->nuclearIndex() - 1);
95 
96  this->fillSeeds(nuclTester->goodTMPair());
97 
98  return true;
99  }
100 
101  return false;
102 }
size
Write out results.
bool isValid() const
Definition: Trajectory.h:257
int foundHits() const
Definition: Trajectory.h:206
std::unique_ptr< NuclearTester > nuclTester
DataContainer const & measurements() const
Definition: Trajectory.h:178
PropagationDirection const & direction() const
Definition: Trajectory.cc:133
const MeasurementTracker * theMeasurementTracker
std::vector< SeedFromNuclearInteraction > allSeeds
std::vector< TrajectoryMeasurement > findCompatibleMeasurements(const TM &lastMeas, double rescaleFactor, const LayerMeasurements &layerMeasurements) const
Find compatible TM of a TM with error rescaled by rescaleFactor.
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:233
void fillSeeds(const std::pair< TrajectoryMeasurement, std::vector< TrajectoryMeasurement > > &tmPairs)
get the seeds at the interaction point
void definePrimaryHelix(std::vector< TrajectoryMeasurement >::const_iterator it_meas)
Calculate the parameters of the circle representing the primary track at the interaction point...
Definition: event.py:1
#define LogDebug(id)

Member Data Documentation

◆ allSeeds

std::vector<SeedFromNuclearInteraction> NuclearInteractionFinder::allSeeds
private

Definition at line 97 of file NuclearInteractionFinder.h.

Referenced by fillSeeds(), getPersistentSeeds(), improveSeeds(), and run().

◆ checkCompletedTrack

bool NuclearInteractionFinder::checkCompletedTrack
private

If set to true check all the tracks, even those reaching the edge of the tracker

Definition at line 103 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder(), and run().

◆ currentSeed

std::unique_ptr<SeedFromNuclearInteraction> NuclearInteractionFinder::currentSeed
private

Definition at line 96 of file NuclearInteractionFinder.h.

Referenced by fillSeeds(), improveSeeds(), and NuclearInteractionFinder().

◆ maxHits

unsigned int NuclearInteractionFinder::maxHits
private

Definition at line 101 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder(), and run().

◆ nuclTester

std::unique_ptr<NuclearTester> NuclearInteractionFinder::nuclTester
private

Definition at line 95 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder(), and run().

◆ rescaleErrorFactor

double NuclearInteractionFinder::rescaleErrorFactor
private

Definition at line 102 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder(), and run().

◆ theEstimator

const MeasurementEstimator* NuclearInteractionFinder::theEstimator
private

◆ theGeomSearchTracker

const GeometricSearchTracker* NuclearInteractionFinder::theGeomSearchTracker
private

◆ theMeasurementTracker

const MeasurementTracker* NuclearInteractionFinder::theMeasurementTracker
private

Definition at line 91 of file NuclearInteractionFinder.h.

Referenced by improveSeeds(), NuclearInteractionFinder(), and run().

◆ theNavigationSchool

const NavigationSchool* NuclearInteractionFinder::theNavigationSchool
private

◆ thePrimaryHelix

std::unique_ptr<TangentHelix> NuclearInteractionFinder::thePrimaryHelix
private

◆ thePropagator

const Propagator* NuclearInteractionFinder::thePropagator
private