CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 std::vector< TrajectoryMeasurement > &vecTM) const
 
double fwdEstimate () 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 std::vector< TrajectoryMeasurement > &vecTM) const
 
double meanHitDistance () 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,
TMContainer
TMPair
 
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.

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

Definition at line 20 of file NuclearTester.h.

Definition at line 18 of file NuclearTester.h.

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

Definition at line 19 of file NuclearTester.h.

Definition at line 21 of file NuclearTester.h.

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

Definition at line 22 of file NuclearTester.h.

Constructor & Destructor Documentation

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

Definition at line 5 of file NuclearTester.cc.

References NuclearIndex.

6  : maxHits(max_hits), theEstimator(est), trackerGeom(track_geom) {
7  NuclearIndex = 0;
8 }
const MeasurementEstimator * theEstimator
Definition: NuclearTester.h:70
unsigned int maxHits
Definition: NuclearTester.h:69
const TrackerGeometry * trackerGeom
Definition: NuclearTester.h:71

Member Function Documentation

const TMContainer& NuclearTester::back ( ) const
inline

Definition at line 42 of file NuclearTester.h.

References allTM.

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

42 { return allTM.back().second; }
TMPairVector allTM
Definition: NuclearTester.h:64
bool NuclearTester::checkWithMultiplicity ( )
private

Definition at line 39 of file NuclearTester.cc.

References compatible_hits, and NuclearIndex.

Referenced by isNuclearInteraction().

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 }
std::vector< int > compatible_hits
Definition: NuclearTester.h:65
std::vector<int> NuclearTester::compatibleHits ( ) const
inline

Definition at line 60 of file NuclearTester.h.

References compatible_hits.

Referenced by NuclearInteractionFinder::run().

60 { return compatible_hits; }
std::vector< int > compatible_hits
Definition: NuclearTester.h:65
double NuclearTester::fwdEstimate ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 107 of file NuclearTester.cc.

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

Referenced by NuclearInteractionFinder::run().

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 }
const MeasurementEstimator * theEstimator
Definition: NuclearTester.h:70
U second(std::pair< T, U > const &p)
virtual HitReturnType estimate(const TrajectoryStateOnSurface &ts, const TrackingRecHit &hit) const =0
double NuclearTester::fwdEstimate ( ) const
inline

Definition at line 46 of file NuclearTester.h.

References back(), and fwdEstimate().

Referenced by fwdEstimate().

46 { return fwdEstimate(back()); }
double fwdEstimate() const
Definition: NuclearTester.h:46
const TMContainer & back() const
Definition: NuclearTester.h:42
const TMPair& NuclearTester::goodTMPair ( ) const
inline

Definition at line 56 of file NuclearTester.h.

References allTM, and nuclearIndex().

Referenced by NuclearInteractionFinder::run().

56 { return *(allTM.begin() + nuclearIndex() - 1); }
TMPairVector allTM
Definition: NuclearTester.h:64
int nuclearIndex() const
Definition: NuclearTester.h:54
std::vector< GlobalPoint > NuclearTester::HitPositions ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 94 of file NuclearTester.cc.

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

Referenced by meanHitDistance().

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 }
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
std::vector< TM >::const_iterator lastValidTM(const std::vector< TM > &vecTM) const
TransientTrackingRecHit::ConstRecHitPointer ConstRecHitPointer
const TrackerGeomDet * idToDet(DetId) const override
const TrackerGeometry * trackerGeom
Definition: NuclearTester.h:71
tuple last
Definition: dqmdumpme.py:56
bool NuclearTester::isNuclearInteraction ( )

Definition at line 11 of file NuclearTester.cc.

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

Referenced by NuclearInteractionFinder::run().

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 }
TMPairVector allTM
Definition: NuclearTester.h:64
std::vector< int > compatible_hits
Definition: NuclearTester.h:65
bool checkWithMultiplicity()
unsigned int maxHits
Definition: NuclearTester.h:69
unsigned int nHitsChecked() const
Definition: NuclearTester.h:58
std::vector< TrajectoryMeasurement >::const_iterator NuclearTester::lastValidTM ( const std::vector< TM > &  vecTM) const

Definition at line 132 of file NuclearTester.cc.

Referenced by HitPositions().

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 }
double NuclearTester::meanHitDistance ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 75 of file NuclearTester.cc.

References HitPositions(), and mag().

Referenced by NuclearInteractionFinder::run().

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 }
std::vector< GlobalPoint > HitPositions(const std::vector< TrajectoryMeasurement > &vecTM) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double NuclearTester::meanHitDistance ( ) const
inline

Definition at line 44 of file NuclearTester.h.

References back(), and meanHitDistance().

Referenced by meanHitDistance().

44 { return meanHitDistance(back()); }
const TMContainer & back() const
Definition: NuclearTester.h:42
double meanHitDistance() const
Definition: NuclearTester.h:44
unsigned int NuclearTester::nHitsChecked ( ) const
inline

Definition at line 58 of file NuclearTester.h.

References compatible_hits.

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

58 { return compatible_hits.size(); }
std::vector< int > compatible_hits
Definition: NuclearTester.h:65
int NuclearTester::nuclearIndex ( ) const
inline

Definition at line 54 of file NuclearTester.h.

References NuclearIndex.

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

54 { return NuclearIndex; }
void NuclearTester::push_back ( const TM init_tm,
const TMContainer vecTM 
)
inline

Definition at line 37 of file NuclearTester.h.

References allTM, and compatible_hits.

Referenced by NuclearInteractionFinder::run().

37  {
38  allTM.push_back(std::make_pair(init_tm, vecTM));
39  compatible_hits.push_back(vecTM.size());
40  }
TMPairVector allTM
Definition: NuclearTester.h:64
std::vector< int > compatible_hits
Definition: NuclearTester.h:65
void NuclearTester::reset ( unsigned int  nMeasurements)
inline

Definition at line 48 of file NuclearTester.h.

References allTM, compatible_hits, and maxHits.

Referenced by NuclearInteractionFinder::run().

48  {
49  allTM.clear();
50  compatible_hits.clear();
51  maxHits = (nMeasurements < maxHits) ? nMeasurements : maxHits;
52  }
TMPairVector allTM
Definition: NuclearTester.h:64
std::vector< int > compatible_hits
Definition: NuclearTester.h:65
unsigned int maxHits
Definition: NuclearTester.h:69

Member Data Documentation

TMPairVector NuclearTester::allTM
private

Definition at line 64 of file NuclearTester.h.

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

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

Definition at line 69 of file NuclearTester.h.

Referenced by isNuclearInteraction(), and reset().

int NuclearTester::NuclearIndex
private
const MeasurementEstimator* NuclearTester::theEstimator
private

Definition at line 70 of file NuclearTester.h.

Referenced by fwdEstimate().

const TrackerGeometry* NuclearTester::trackerGeom
private

Definition at line 71 of file NuclearTester.h.

Referenced by HitPositions().