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 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, 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.

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 21 of file NuclearTester.h.

Definition at line 19 of file NuclearTester.h.

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

Definition at line 20 of file NuclearTester.h.

Definition at line 22 of file NuclearTester.h.

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

Definition at line 23 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.

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

Member Function Documentation

const TMContainer& NuclearTester::back ( ) const
inline

Definition at line 43 of file NuclearTester.h.

References allTM.

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

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

Definition at line 29 of file NuclearTester.cc.

References compatible_hits, and NuclearIndex.

Referenced by isNuclearInteraction().

29  {
30  //RQ: assume that the input vector of compatible hits has been filled from Outside to Inside the tracker !
31 
32  // find the first min nb of compatible TM :
33  std::vector<int>::iterator min_it = min_element(compatible_hits.begin(), compatible_hits.end());
34 
35  // if the outermost hit has no compatible TM, min_it has to be recalculated :
36  if(min_it == compatible_hits.begin() && *min_it!=0) return false;
37  if(min_it == compatible_hits.begin() && *min_it==0) min_it=min_element(compatible_hits.begin()+1, compatible_hits.end());
38 
39  // this first min cannot be the innermost TM :
40  if(min_it == compatible_hits.end()-1) return false;
41 
42  // if the previous nb of compatible TM is > min+2 and if the next compatible TM is min+-1 -> NUCLEAR
43  // example : Nhits = 5, 8, 2, 2, ...
44  if((*(min_it-1) - *min_it) > 2 && (*(min_it+1) - *min_it) < 2 ) {
45  NuclearIndex = min_it - compatible_hits.begin();
46  return true;
47  }
48 
49  // case of : Nhits = 5, 8, 3, 2, 2, ...
50  if(min_it-1 != compatible_hits.begin()) //because min_it must be at least at the third position
51  {
52  if(min_it-1 != compatible_hits.begin() && (*(min_it-1) - *min_it) < 2 && (*(min_it-2) - *(min_it-1)) > 2 ) {
53  NuclearIndex = min_it - 1 - compatible_hits.begin();
54  return true;
55  }
56  }
57 
58  return false;
59 }
std::vector< int > compatible_hits
Definition: NuclearTester.h:67
std::vector<int> NuclearTester::compatibleHits ( ) const
inline

Definition at line 61 of file NuclearTester.h.

References compatible_hits.

Referenced by NuclearInteractionFinder::run().

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

Definition at line 92 of file NuclearTester.cc.

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

Referenced by NuclearInteractionFinder::run().

92  {
93  if(vecTM.empty()) return 0;
94 
95  auto hit = vecTM.front().recHit().get();
96  if( hit->isValid() )
97  return theEstimator->estimate( vecTM.front().forwardPredictedState(), *hit ).second;
98  else return -1;
99 /*
100  double meanEst=0;
101  int goodTM=0;
102  std::vector<TM>::const_iterator last;
103  //std::vector<TM>::const_iterator last = this->lastValidTM(vecTM);
104  if(vecTM.size() > 2) last = vecTM.begin()+2;
105  else last = vecTM.end();
106 
107  for(std::vector<TrajectoryMeasurement>::const_iterator itm = vecTM.begin(); itm!=last; itm++) {
108  meanEst += itm->estimate();
109  goodTM++;
110  }
111  return meanEst/goodTM;
112 */
113 }
const MeasurementEstimator * theEstimator
Definition: NuclearTester.h:72
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 47 of file NuclearTester.h.

References back(), and fwdEstimate().

Referenced by fwdEstimate().

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

Definition at line 57 of file NuclearTester.h.

References allTM, and nuclearIndex().

Referenced by NuclearInteractionFinder::run().

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

Definition at line 80 of file NuclearTester.cc.

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

Referenced by meanHitDistance().

80  {
81  std::vector<GlobalPoint> gp;
82 
83  std::vector<TM>::const_iterator last = this->lastValidTM(vecTM);
84 
85  for(std::vector<TrajectoryMeasurement>::const_iterator itm = vecTM.begin(); itm!=last; itm++) {
86  ConstRecHitPointer trh = itm->recHit();
87  if(trh->isValid()) gp.push_back(trackerGeom->idToDet(trh->geographicalId())->surface().toGlobal(trh->localPosition()));
88  }
89  return gp;
90 }
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:54
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:73
bool NuclearTester::isNuclearInteraction ( )

Definition at line 9 of file NuclearTester.cc.

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

Referenced by NuclearInteractionFinder::run().

9  {
10 // TODO : if energy of primary track is below a threshold don't use checkWithMultiplicity but only checkwith compatible_hits.front
11 
12  // 1. if momentum of the primary track is below 5 GeV and if the number of compatible hits >0
13  // assume that a nuclear interaction occured at the end of the track
14  if( allTM.front().first.updatedState().globalMomentum().mag() < 5.0 && compatible_hits.front()>0) { NuclearIndex=1; return true; }
15 
16  // 2. else to use multiplicity we require at least 3 TM vectors to check if nuclear interactions occurs
17  if(nHitsChecked()<3) return false;
18 
19  // 2. check with multiplicity :
20  if( checkWithMultiplicity() == true ) return true;
21  else {
22  // 3. last case : uncompleted track with at least 1 compatible hits in the last layer
23  if( nHitsChecked() >= maxHits && compatible_hits.front()>0) {NuclearIndex=1; return true; }
24  }
25 
26  return false;
27 }
TMPairVector allTM
Definition: NuclearTester.h:66
bool checkWithMultiplicity()
std::vector< int > compatible_hits
Definition: NuclearTester.h:67
unsigned int maxHits
Definition: NuclearTester.h:71
unsigned int nHitsChecked() const
Definition: NuclearTester.h:59
std::vector< TrajectoryMeasurement >::const_iterator NuclearTester::lastValidTM ( const std::vector< TM > &  vecTM) const

Definition at line 115 of file NuclearTester.cc.

Referenced by HitPositions().

115  {
116  if (vecTM.empty()) return vecTM.end();
117  if (vecTM.front().recHit()->isValid())
118  return std::find_if( vecTM.begin(), vecTM.end(),
119  [](auto const& meas){ return !meas.recHit()->isValid(); });
120  else return vecTM.end();
121 }
double NuclearTester::meanHitDistance ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 62 of file NuclearTester.cc.

References HitPositions(), and mag().

Referenced by NuclearInteractionFinder::run().

62  {
63  std::vector<GlobalPoint> vgp = this->HitPositions(vecTM);
64  double mean_dist=0;
65  int ncomb=0;
66  if(vgp.size()<2) return 0;
67  for(std::vector<GlobalPoint>::iterator itp = vgp.begin(); itp != vgp.end()-1; itp++) {
68  for(std::vector<GlobalPoint>::iterator itq = itp+1; itq != vgp.end(); itq++) {
69  double dist = ((*itp) - (*itq)).mag();
70  // to calculate mean distance between particles and not hits (to not take into account twice stereo hits)
71  if(dist > 1E-12) {
72  mean_dist += dist;
73  ncomb++;
74  }
75  }
76  }
77  return mean_dist/ncomb;
78 }
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 45 of file NuclearTester.h.

References back(), and meanHitDistance().

Referenced by meanHitDistance().

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

Definition at line 59 of file NuclearTester.h.

References compatible_hits.

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

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

Definition at line 55 of file NuclearTester.h.

References NuclearIndex.

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

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

Definition at line 38 of file NuclearTester.h.

References allTM, and compatible_hits.

Referenced by NuclearInteractionFinder::run().

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

Definition at line 49 of file NuclearTester.h.

References allTM, compatible_hits, and maxHits.

Referenced by NuclearInteractionFinder::run().

49  {
50  allTM.clear();
51  compatible_hits.clear();
52  maxHits = (nMeasurements < maxHits) ? nMeasurements : maxHits;
53  }
TMPairVector allTM
Definition: NuclearTester.h:66
std::vector< int > compatible_hits
Definition: NuclearTester.h:67
unsigned int maxHits
Definition: NuclearTester.h:71

Member Data Documentation

TMPairVector NuclearTester::allTM
private

Definition at line 66 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 71 of file NuclearTester.h.

Referenced by isNuclearInteraction(), and reset().

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

Definition at line 72 of file NuclearTester.h.

Referenced by fwdEstimate().

const TrackerGeometry* NuclearTester::trackerGeom
private

Definition at line 73 of file NuclearTester.h.

Referenced by HitPositions().