CMS 3D CMS Logo

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

Class used to test if a track has interacted nuclearly. More...

#include <NuclearTester.h>

Public Member Functions

const TMContainerback () const
 
std::vector< int > compatibleHits () const
 
double fwdEstimate () const
 
double fwdEstimate (const std::vector< TrajectoryMeasurement > &vecTM) const
 
const TMPairgoodTMPair () const
 
std::vector< GlobalPointHitPositions (const std::vector< TrajectoryMeasurement > &vecTM) const
 
bool isNuclearInteraction ()
 
std::vector< TM >::const_iterator lastValidTM (const std::vector< TM > &vecTM) const
 
double meanHitDistance () const
 
double meanHitDistance (const std::vector< TrajectoryMeasurement > &vecTM) const
 
unsigned int nHitsChecked () const
 
int nuclearIndex () const
 
 NuclearTester (unsigned int max_hits, const MeasurementEstimator *est, const TrackerGeometry *track_geom)
 
void push_back (const TM &init_tm, const TMContainer &vecTM)
 
void reset (unsigned int nMeasurements)
 

Private Types

typedef TrajectoryMeasurement::ConstRecHitPointer ConstRecHitPointer
 
typedef TrajectoryMeasurement TM
 
typedef std::vector< TMTMContainer
 
typedef std::pair< TrajectoryMeasurement, TMContainerTMPair
 
typedef std::vector< TMPairTMPairVector
 

Private Member Functions

bool checkWithMultiplicity ()
 

Private Attributes

TMPairVector allTM
 
std::vector< int > compatible_hits
 
unsigned int maxHits
 
int NuclearIndex
 
const MeasurementEstimatortheEstimator
 
const TrackerGeometrytrackerGeom
 

Detailed Description

Class used to test if a track has interacted nuclearly.

\description Using the properties of all the compatible TMs of the TMs associated to a track, the method isNuclearInteraction return 1 in case the track has interacted nuclearly, 0 else.

Definition at line 16 of file NuclearTester.h.

Member Typedef Documentation

◆ ConstRecHitPointer

Definition at line 20 of file NuclearTester.h.

◆ TM

Definition at line 18 of file NuclearTester.h.

◆ TMContainer

typedef std::vector<TM> NuclearTester::TMContainer
private

Definition at line 19 of file NuclearTester.h.

◆ TMPair

Definition at line 21 of file NuclearTester.h.

◆ TMPairVector

typedef std::vector<TMPair> NuclearTester::TMPairVector
private

Definition at line 22 of file NuclearTester.h.

Constructor & Destructor Documentation

◆ NuclearTester()

NuclearTester::NuclearTester ( unsigned int  max_hits,
const MeasurementEstimator est,
const TrackerGeometry track_geom 
)

Definition at line 5 of file NuclearTester.cc.

6  : maxHits(max_hits), theEstimator(est), trackerGeom(track_geom) {
7  NuclearIndex = 0;
8 }

References NuclearIndex.

Member Function Documentation

◆ back()

const TMContainer& NuclearTester::back ( ) const
inline

Definition at line 42 of file NuclearTester.h.

42 { return allTM.back().second; }

References allTM.

Referenced by fwdEstimate(), meanHitDistance(), and NuclearInteractionFinder::run().

◆ checkWithMultiplicity()

bool NuclearTester::checkWithMultiplicity ( )
private

Definition at line 39 of file NuclearTester.cc.

39  {
40  //RQ: assume that the input vector of compatible hits has been filled from Outside to Inside the tracker !
41 
42  // find the first min nb of compatible TM :
43  std::vector<int>::iterator min_it = min_element(compatible_hits.begin(), compatible_hits.end());
44 
45  // if the outermost hit has no compatible TM, min_it has to be recalculated :
46  if (min_it == compatible_hits.begin() && *min_it != 0)
47  return false;
48  if (min_it == compatible_hits.begin() && *min_it == 0)
49  min_it = min_element(compatible_hits.begin() + 1, compatible_hits.end());
50 
51  // this first min cannot be the innermost TM :
52  if (min_it == compatible_hits.end() - 1)
53  return false;
54 
55  // if the previous nb of compatible TM is > min+2 and if the next compatible TM is min+-1 -> NUCLEAR
56  // example : Nhits = 5, 8, 2, 2, ...
57  if ((*(min_it - 1) - *min_it) > 2 && (*(min_it + 1) - *min_it) < 2) {
58  NuclearIndex = min_it - compatible_hits.begin();
59  return true;
60  }
61 
62  // case of : Nhits = 5, 8, 3, 2, 2, ...
63  if (min_it - 1 != compatible_hits.begin()) //because min_it must be at least at the third position
64  {
65  if (min_it - 1 != compatible_hits.begin() && (*(min_it - 1) - *min_it) < 2 && (*(min_it - 2) - *(min_it - 1)) > 2) {
66  NuclearIndex = min_it - 1 - compatible_hits.begin();
67  return true;
68  }
69  }
70 
71  return false;
72 }

References compatible_hits, and NuclearIndex.

Referenced by isNuclearInteraction().

◆ compatibleHits()

std::vector<int> NuclearTester::compatibleHits ( ) const
inline

Definition at line 60 of file NuclearTester.h.

60 { return compatible_hits; }

References compatible_hits.

Referenced by NuclearInteractionFinder::run().

◆ fwdEstimate() [1/2]

double NuclearTester::fwdEstimate ( ) const
inline

Definition at line 46 of file NuclearTester.h.

46 { return fwdEstimate(back()); }

References back(), and fwdEstimate().

Referenced by fwdEstimate().

◆ fwdEstimate() [2/2]

double NuclearTester::fwdEstimate ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 107 of file NuclearTester.cc.

107  {
108  if (vecTM.empty())
109  return 0;
110 
111  auto hit = vecTM.front().recHit().get();
112  if (hit->isValid())
113  return theEstimator->estimate(vecTM.front().forwardPredictedState(), *hit).second;
114  else
115  return -1;
116  /*
117  double meanEst=0;
118  int goodTM=0;
119  std::vector<TM>::const_iterator last;
120  //std::vector<TM>::const_iterator last = this->lastValidTM(vecTM);
121  if(vecTM.size() > 2) last = vecTM.begin()+2;
122  else last = vecTM.end();
123 
124  for(std::vector<TrajectoryMeasurement>::const_iterator itm = vecTM.begin(); itm!=last; itm++) {
125  meanEst += itm->estimate();
126  goodTM++;
127  }
128  return meanEst/goodTM;
129 */
130 }

References MeasurementEstimator::estimate(), edm::second(), and theEstimator.

Referenced by NuclearInteractionFinder::run().

◆ goodTMPair()

const TMPair& NuclearTester::goodTMPair ( ) const
inline

Definition at line 56 of file NuclearTester.h.

56 { return *(allTM.begin() + nuclearIndex() - 1); }

References allTM, and nuclearIndex().

Referenced by NuclearInteractionFinder::run().

◆ HitPositions()

std::vector< GlobalPoint > NuclearTester::HitPositions ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 94 of file NuclearTester.cc.

94  {
95  std::vector<GlobalPoint> gp;
96 
97  std::vector<TM>::const_iterator last = this->lastValidTM(vecTM);
98 
99  for (std::vector<TrajectoryMeasurement>::const_iterator itm = vecTM.begin(); itm != last; itm++) {
100  ConstRecHitPointer trh = itm->recHit();
101  if (trh->isValid())
102  gp.push_back(trackerGeom->idToDet(trh->geographicalId())->surface().toGlobal(trh->localPosition()));
103  }
104  return gp;
105 }

References runTauDisplay::gp, TrackerGeometry::idToDet(), dqmdumpme::last, lastValidTM(), GeomDet::toGlobal(), and trackerGeom.

Referenced by meanHitDistance().

◆ isNuclearInteraction()

bool NuclearTester::isNuclearInteraction ( )

Definition at line 11 of file NuclearTester.cc.

11  {
12  // TODO : if energy of primary track is below a threshold don't use checkWithMultiplicity but only checkwith compatible_hits.front
13 
14  // 1. if momentum of the primary track is below 5 GeV and if the number of compatible hits >0
15  // assume that a nuclear interaction occured at the end of the track
16  if (allTM.front().first.updatedState().globalMomentum().mag() < 5.0 && compatible_hits.front() > 0) {
17  NuclearIndex = 1;
18  return true;
19  }
20 
21  // 2. else to use multiplicity we require at least 3 TM vectors to check if nuclear interactions occurs
22  if (nHitsChecked() < 3)
23  return false;
24 
25  // 2. check with multiplicity :
26  if (checkWithMultiplicity() == true)
27  return true;
28  else {
29  // 3. last case : uncompleted track with at least 1 compatible hits in the last layer
30  if (nHitsChecked() >= maxHits && compatible_hits.front() > 0) {
31  NuclearIndex = 1;
32  return true;
33  }
34  }
35 
36  return false;
37 }

References allTM, checkWithMultiplicity(), compatible_hits, maxHits, nHitsChecked(), and NuclearIndex.

Referenced by NuclearInteractionFinder::run().

◆ lastValidTM()

std::vector< TrajectoryMeasurement >::const_iterator NuclearTester::lastValidTM ( const std::vector< TM > &  vecTM) const

Definition at line 132 of file NuclearTester.cc.

132  {
133  if (vecTM.empty())
134  return vecTM.end();
135  if (vecTM.front().recHit()->isValid())
136  return std::find_if(vecTM.begin(), vecTM.end(), [](auto const& meas) { return !meas.recHit()->isValid(); });
137  else
138  return vecTM.end();
139 }

Referenced by HitPositions().

◆ meanHitDistance() [1/2]

double NuclearTester::meanHitDistance ( ) const
inline

Definition at line 44 of file NuclearTester.h.

44 { return meanHitDistance(back()); }

References back(), and meanHitDistance().

Referenced by meanHitDistance().

◆ meanHitDistance() [2/2]

double NuclearTester::meanHitDistance ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 75 of file NuclearTester.cc.

75  {
76  std::vector<GlobalPoint> vgp = this->HitPositions(vecTM);
77  double mean_dist = 0;
78  int ncomb = 0;
79  if (vgp.size() < 2)
80  return 0;
81  for (std::vector<GlobalPoint>::iterator itp = vgp.begin(); itp != vgp.end() - 1; itp++) {
82  for (std::vector<GlobalPoint>::iterator itq = itp + 1; itq != vgp.end(); itq++) {
83  double dist = ((*itp) - (*itq)).mag();
84  // to calculate mean distance between particles and not hits (to not take into account twice stereo hits)
85  if (dist > 1E-12) {
86  mean_dist += dist;
87  ncomb++;
88  }
89  }
90  }
91  return mean_dist / ncomb;
92 }

References HitPositions(), and mag().

Referenced by NuclearInteractionFinder::run().

◆ nHitsChecked()

unsigned int NuclearTester::nHitsChecked ( ) const
inline

Definition at line 58 of file NuclearTester.h.

58 { return compatible_hits.size(); }

References compatible_hits.

Referenced by isNuclearInteraction(), and NuclearInteractionFinder::run().

◆ nuclearIndex()

int NuclearTester::nuclearIndex ( ) const
inline

Definition at line 54 of file NuclearTester.h.

54 { return NuclearIndex; }

References NuclearIndex.

Referenced by goodTMPair(), and NuclearInteractionFinder::run().

◆ push_back()

void NuclearTester::push_back ( const TM init_tm,
const TMContainer vecTM 
)
inline

Definition at line 37 of file NuclearTester.h.

37  {
38  allTM.push_back(std::make_pair(init_tm, vecTM));
39  compatible_hits.push_back(vecTM.size());
40  }

References allTM, and compatible_hits.

Referenced by NuclearInteractionFinder::run().

◆ reset()

void NuclearTester::reset ( unsigned int  nMeasurements)
inline

Definition at line 48 of file NuclearTester.h.

48  {
49  allTM.clear();
50  compatible_hits.clear();
51  maxHits = (nMeasurements < maxHits) ? nMeasurements : maxHits;
52  }

References allTM, compatible_hits, and maxHits.

Referenced by NuclearInteractionFinder::run().

Member Data Documentation

◆ allTM

TMPairVector NuclearTester::allTM
private

Definition at line 64 of file NuclearTester.h.

Referenced by back(), goodTMPair(), isNuclearInteraction(), push_back(), and reset().

◆ compatible_hits

std::vector<int> NuclearTester::compatible_hits
private

◆ maxHits

unsigned int NuclearTester::maxHits
private

Definition at line 69 of file NuclearTester.h.

Referenced by isNuclearInteraction(), and reset().

◆ NuclearIndex

int NuclearTester::NuclearIndex
private

◆ theEstimator

const MeasurementEstimator* NuclearTester::theEstimator
private

Definition at line 70 of file NuclearTester.h.

Referenced by fwdEstimate().

◆ trackerGeom

const TrackerGeometry* NuclearTester::trackerGeom
private

Definition at line 71 of file NuclearTester.h.

Referenced by HitPositions().

TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
NuclearTester::theEstimator
const MeasurementEstimator * theEstimator
Definition: NuclearTester.h:70
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
NuclearTester::trackerGeom
const TrackerGeometry * trackerGeom
Definition: NuclearTester.h:71
MeasurementEstimator::estimate
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
NuclearTester::allTM
TMPairVector allTM
Definition: NuclearTester.h:64
dqmdumpme.last
last
Definition: dqmdumpme.py:56
ConstRecHitPointer
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
Definition: MillePedeAlignmentAlgorithm.cc:70
NuclearTester::nuclearIndex
int nuclearIndex() const
Definition: NuclearTester.h:54
NuclearTester::lastValidTM
std::vector< TM >::const_iterator lastValidTM(const std::vector< TM > &vecTM) const
Definition: NuclearTester.cc:132
NuclearTester::back
const TMContainer & back() const
Definition: NuclearTester.h:42
NuclearTester::nHitsChecked
unsigned int nHitsChecked() const
Definition: NuclearTester.h:58
NuclearTester::fwdEstimate
double fwdEstimate() const
Definition: NuclearTester.h:46
NuclearTester::maxHits
unsigned int maxHits
Definition: NuclearTester.h:69
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
NuclearTester::compatible_hits
std::vector< int > compatible_hits
Definition: NuclearTester.h:65
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
NuclearTester::checkWithMultiplicity
bool checkWithMultiplicity()
Definition: NuclearTester.cc:39
NuclearTester::meanHitDistance
double meanHitDistance() const
Definition: NuclearTester.h:44
NuclearTester::HitPositions
std::vector< GlobalPoint > HitPositions(const std::vector< TrajectoryMeasurement > &vecTM) const
Definition: NuclearTester.cc:94
NuclearTester::NuclearIndex
int NuclearIndex
Definition: NuclearTester.h:66
hit
Definition: SiStripHitEffFromCalibTree.cc:88