CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 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 6 of file NuclearTester.cc.

References NuclearIndex.

6  :
7  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 30 of file NuclearTester.cc.

References compatible_hits, and NuclearIndex.

Referenced by isNuclearInteraction().

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

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

Referenced by NuclearInteractionFinder::run().

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

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

Referenced by meanHitDistance().

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

Definition at line 10 of file NuclearTester.cc.

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

Referenced by NuclearInteractionFinder::run().

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

Referenced by HitPositions().

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

Definition at line 63 of file NuclearTester.cc.

References HitPositions(), and mag().

Referenced by NuclearInteractionFinder::run().

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