CMS 3D CMS Logo

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>

List of all members.

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.

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

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().

{ return allTM.back().second; }
bool NuclearTester::checkWithMultiplicity ( ) [private]

Definition at line 30 of file NuclearTester.cc.

References compatible_hits, and NuclearIndex.

Referenced by isNuclearInteraction().

                                          {
    //RQ: assume that the input vector of compatible hits has been filled from Outside to Inside the tracker !

    // find the first min nb of compatible TM :
    std::vector<int>::iterator min_it = min_element(compatible_hits.begin(), compatible_hits.end());

    // if the outermost hit has no compatible TM, min_it has to be recalculated :
    if(min_it == compatible_hits.begin() && *min_it!=0) return false;
    if(min_it == compatible_hits.begin() && *min_it==0) min_it=min_element(compatible_hits.begin()+1, compatible_hits.end());

    // this first min cannot be the innermost TM :
    if(min_it == compatible_hits.end()-1) return false;

    // if the previous nb of compatible TM is > min+2 and if the next compatible TM is min+-1 -> NUCLEAR
    // example : Nhits = 5, 8, 2, 2, ...
    if((*(min_it-1) - *min_it) > 2 && (*(min_it+1) - *min_it) < 2 ) {
            NuclearIndex = min_it - compatible_hits.begin();
            return true;
    }

    // case of : Nhits = 5, 8, 3, 2, 2, ...
    if(min_it-1 != compatible_hits.begin())  //because min_it must be at least at the third position
    {
      if(min_it-1 != compatible_hits.begin() && (*(min_it-1) - *min_it) < 2 && (*(min_it-2) - *(min_it-1)) > 2 ) {
           NuclearIndex = min_it - 1 - compatible_hits.begin();
           return true;
      }
    }

    return false;
}
std::vector<int> NuclearTester::compatibleHits ( ) const [inline]

Definition at line 61 of file NuclearTester.h.

References compatible_hits.

Referenced by NuclearInteractionFinder::run().

{ return compatible_hits; }
double NuclearTester::fwdEstimate ( ) const [inline]

Definition at line 47 of file NuclearTester.h.

References back(), and fwdEstimate().

Referenced by fwdEstimate().

{ return fwdEstimate( back() ); }
double NuclearTester::fwdEstimate ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 93 of file NuclearTester.cc.

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

Referenced by NuclearInteractionFinder::run().

                                                                                     {
       if(vecTM.empty()) return 0;

       const TransientTrackingRecHit* hit = vecTM.front().recHit().get();
       if( hit->isValid() )
          return theEstimator->estimate( vecTM.front().forwardPredictedState(), *hit ).second;
       else return -1;
/*
       double meanEst=0;
       int    goodTM=0;
       std::vector<TM>::const_iterator last;
       //std::vector<TM>::const_iterator last = this->lastValidTM(vecTM);
       if(vecTM.size() > 2) last = vecTM.begin()+2;
       else last = vecTM.end();

       for(std::vector<TrajectoryMeasurement>::const_iterator itm = vecTM.begin(); itm!=last; itm++) {
             meanEst += itm->estimate();
             goodTM++;
       }
       return meanEst/goodTM;
*/
}
const TMPair& NuclearTester::goodTMPair ( ) const [inline]

Definition at line 57 of file NuclearTester.h.

References allTM, and nuclearIndex().

Referenced by NuclearInteractionFinder::run().

{ return *(allTM.begin()+nuclearIndex()-1); }
std::vector< GlobalPoint > NuclearTester::HitPositions ( const std::vector< TrajectoryMeasurement > &  vecTM) const

Definition at line 81 of file NuclearTester.cc.

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

Referenced by meanHitDistance().

                                                                                                      {
   std::vector<GlobalPoint> gp;

   std::vector<TM>::const_iterator last = this->lastValidTM(vecTM);

   for(std::vector<TrajectoryMeasurement>::const_iterator itm = vecTM.begin(); itm!=last; itm++) {
               ConstRecHitPointer trh = itm->recHit();
               if(trh->isValid()) gp.push_back(trackerGeom->idToDet(trh->geographicalId())->surface().toGlobal(trh->localPosition()));
   }
   return gp;
}
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().

                                          {
// TODO : if energy of primary track is below a threshold don't use checkWithMultiplicity but only checkwith compatible_hits.front

        // 1. if momentum of the primary track is below 5 GeV and if the number of compatible hits >0
        //    assume that a nuclear interaction occured at the end of the track
        if( allTM.front().first.updatedState().globalMomentum().mag() < 5.0 && compatible_hits.front()>0) { NuclearIndex=1; return true; } 

        // 2. else to use multiplicity we require at least 3 TM vectors to check if nuclear interactions occurs
        if(nHitsChecked()<3) return false;

        // 2. check with multiplicity :
        if( checkWithMultiplicity() == true ) return true;
        else  {
               // 3. last case : uncompleted track with at least 1 compatible hits in the last layer
               if( nHitsChecked() >= maxHits && compatible_hits.front()>0) {NuclearIndex=1; return true; }
        }

        return false;
}
std::vector< TrajectoryMeasurement >::const_iterator NuclearTester::lastValidTM ( const std::vector< TM > &  vecTM) const

Definition at line 116 of file NuclearTester.cc.

Referenced by HitPositions().

                                                                                                          {
   if (vecTM.empty()) return vecTM.end();
   if (vecTM.front().recHit()->isValid())
            return std::find_if( vecTM.begin(), vecTM.end(), RecHitIsInvalid());
   else return vecTM.end();
}
double NuclearTester::meanHitDistance ( ) const [inline]

Definition at line 45 of file NuclearTester.h.

References back(), and meanHitDistance().

Referenced by meanHitDistance().

{ return meanHitDistance( back() ); }
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().

                                                                                         {
    std::vector<GlobalPoint> vgp = this->HitPositions(vecTM);
    double mean_dist=0;
    int ncomb=0;
    if(vgp.size()<2) return 0;
    for(std::vector<GlobalPoint>::iterator itp = vgp.begin(); itp != vgp.end()-1; itp++) {
       for(std::vector<GlobalPoint>::iterator itq = itp+1; itq != vgp.end(); itq++) {
          double dist = ((*itp) - (*itq)).mag();
          // to calculate mean distance between particles and not hits (to not take into account twice stereo hits)
          if(dist > 1E-12) {
                mean_dist += dist;
                ncomb++;
          }
        }
    }
    return mean_dist/ncomb;
}
unsigned int NuclearTester::nHitsChecked ( ) const [inline]

Definition at line 59 of file NuclearTester.h.

References compatible_hits.

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

{ return compatible_hits.size(); }
int NuclearTester::nuclearIndex ( ) const [inline]

Definition at line 55 of file NuclearTester.h.

References NuclearIndex.

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

{ 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().

                                                                { 
             allTM.push_back(std::make_pair(init_tm, vecTM) ); 
             compatible_hits.push_back(vecTM.size()); 
  }
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().

                                         { 
               allTM.clear(); 
               compatible_hits.clear(); 
               maxHits = (nMeasurements < maxHits) ? nMeasurements : maxHits; 
  }

Member Data Documentation

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().

Definition at line 72 of file NuclearTester.h.

Referenced by fwdEstimate().

Definition at line 73 of file NuclearTester.h.

Referenced by HitPositions().