CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

NuclearInteractionFinder Class Reference

Class used to obtain vector of all compatible TMs associated to a trajectory to be used by the NuclearTester. More...

#include <NuclearInteractionFinder.h>

List of all members.

Public Member Functions

std::auto_ptr
< TrajectorySeedCollection
getPersistentSeeds ()
 Fill 'output' with persistent nuclear seeds.
void improveSeeds ()
 Improve the seeds with a third RecHit.
const NavigationSchoolnav () const
 NuclearInteractionFinder (const edm::EventSetup &es, const edm::ParameterSet &iConfig)
 NuclearInteractionFinder ()
TrajectoryStateOnSurface rescaleError (float rescale, const TSOS &state) const
bool run (const Trajectory &traj)
 Run the Finder.
void setEvent (const edm::Event &event) const
 define the measurement (to be called for each event)
virtual ~NuclearInteractionFinder ()

Private Types

typedef
TrajectoryMeasurement::ConstRecHitPointer 
ConstRecHitPointer
typedef FreeTrajectoryState FTS
typedef TrajectoryMeasurement TM
typedef std::vector< TrajectoryTrajectoryContainer
typedef TrajectoryStateOnSurface TSOS

Private Member Functions

void definePrimaryHelix (std::vector< TrajectoryMeasurement >::const_iterator it_meas)
 Calculate the parameters of the circle representing the primary track at the interaction point.
void fillSeeds (const std::pair< TrajectoryMeasurement, std::vector< TrajectoryMeasurement > > &tmPairs)
 get the seeds at the interaction point
std::vector
< TrajectoryMeasurement
findCompatibleMeasurements (const TM &lastMeas, double rescaleFactor) const
 Find compatible TM of a TM with error rescaled by rescaleFactor.
std::vector
< TrajectoryMeasurement
findMeasurementsFromTSOS (const TSOS &currentState, DetId detid) const

Private Attributes

std::vector
< SeedFromNuclearInteraction
allSeeds
bool checkCompletedTrack
SeedFromNuclearInteractioncurrentSeed
unsigned int maxHits
std::string navigationSchoolName
NuclearTesternuclTester
double ptMin
double rescaleErrorFactor
const MeasurementEstimatortheEstimator
const GeometricSearchTrackertheGeomSearchTracker
const LayerMeasurementstheLayerMeasurements
edm::ESHandle< MagneticFieldtheMagField
const MeasurementTrackertheMeasurementTracker
const NavigationSchooltheNavigationSchool
TangentHelixthePrimaryHelix
const PropagatorthePropagator

Detailed Description

Class used to obtain vector of all compatible TMs associated to a trajectory to be used by the NuclearTester.

The method run gets all compatible TMs of all TMs associated of a trajectory. Then it uses the NuclearTester class to decide whether the trajectory has interacted nuclearly or not. It finally returns a pair of the TM where the nuclear interaction occurs and all compatible TMs associated.

Definition at line 45 of file NuclearInteractionFinder.h.


Member Typedef Documentation

Definition at line 52 of file NuclearInteractionFinder.h.

Definition at line 49 of file NuclearInteractionFinder.h.

Definition at line 50 of file NuclearInteractionFinder.h.

Definition at line 51 of file NuclearInteractionFinder.h.

Definition at line 48 of file NuclearInteractionFinder.h.


Constructor & Destructor Documentation

NuclearInteractionFinder::NuclearInteractionFinder ( ) [inline]

Definition at line 69 of file NuclearInteractionFinder.h.

{}
NuclearInteractionFinder::NuclearInteractionFinder ( const edm::EventSetup es,
const edm::ParameterSet iConfig 
)

Definition at line 20 of file NuclearInteractionFinder.cc.

References checkCompletedTrack, currentSeed, edm::EventSetup::get(), edm::ParameterSet::getParameter(), LogDebug, maxHits, PixelTracksForL3Isolation_cfi::measurementTrackerName, nav(), navigationSchoolName, nuclTester, edm::ESHandle< T >::product(), rescaleErrorFactor, theEstimator, theGeomSearchTracker, theLayerMeasurements, theMagField, theMeasurementTracker, theNavigationSchool, thePrimaryHelix, and thePropagator.

                                                                                                          :
maxHits(iConfig.getParameter<int>("maxHits")),
rescaleErrorFactor(iConfig.getParameter<double>("rescaleErrorFactor")),
checkCompletedTrack(iConfig.getParameter<bool>("checkCompletedTrack")),
navigationSchoolName(iConfig.getParameter<std::string>("NavigationSchool"))
{

   std::string measurementTrackerName = iConfig.getParameter<std::string>("MeasurementTrackerName");

   edm::ESHandle<Propagator> prop;
   edm::ESHandle<TrajectoryStateUpdator> upd;
   edm::ESHandle<Chi2MeasurementEstimatorBase> est;
   edm::ESHandle<MeasurementTracker> measurementTrackerHandle;
   edm::ESHandle<GeometricSearchTracker>       theGeomSearchTrackerHandle;
   edm::ESHandle<TrackerGeometry>              theTrackerGeom;

   es.get<TrackerDigiGeometryRecord> ().get (theTrackerGeom);
   es.get<TrackingComponentsRecord>().get("PropagatorWithMaterial",prop);
   es.get<TrackingComponentsRecord>().get("Chi2",est);
   es.get<CkfComponentsRecord>().get(measurementTrackerName, measurementTrackerHandle);
   es.get<TrackerRecoGeometryRecord>().get(theGeomSearchTrackerHandle );
   es.get<IdealMagneticFieldRecord>().get(theMagField);

   edm::ESHandle<NavigationSchool>             nav;
   es.get<NavigationSchoolRecord>().get(navigationSchoolName, nav);
   theNavigationSchool  = nav.product();

   thePropagator = prop.product();
   theEstimator = est.product();
   theMeasurementTracker = measurementTrackerHandle.product();
   theLayerMeasurements = new LayerMeasurements(theMeasurementTracker);
   theGeomSearchTracker = theGeomSearchTrackerHandle.product();

   LogDebug("NuclearSeedGenerator") << "New NuclearInteractionFinder instance with parameters : \n"
                                        << "maxHits : " << maxHits << "\n"
                                        << "rescaleErrorFactor : " << rescaleErrorFactor << "\n"
                                        << "checkCompletedTrack : " << checkCompletedTrack << "\n";

   nuclTester = new NuclearTester(maxHits, theEstimator, theTrackerGeom.product() );

   currentSeed = new SeedFromNuclearInteraction(thePropagator, theTrackerGeom.product(), iConfig) ;

   thePrimaryHelix = new TangentHelix();
}
NuclearInteractionFinder::~NuclearInteractionFinder ( ) [virtual]

Definition at line 71 of file NuclearInteractionFinder.cc.

References currentSeed, nuclTester, theLayerMeasurements, and thePrimaryHelix.

                                                    {
  delete theLayerMeasurements;
  delete nuclTester;
  delete currentSeed;
  delete thePrimaryHelix;
}

Member Function Documentation

void NuclearInteractionFinder::definePrimaryHelix ( std::vector< TrajectoryMeasurement >::const_iterator  it_meas) [private]

Calculate the parameters of the circle representing the primary track at the interaction point.

Definition at line 137 of file NuclearInteractionFinder.cc.

References i, and thePrimaryHelix.

Referenced by run().

                                                                                                        {
    // This method uses the 3 last TM after the interaction point to calculate the helix parameters

    GlobalPoint pt[3];
    for(int i=0; i<3; i++) {
       pt[i] = (it_meas->updatedState()).globalParameters().position();
       it_meas++;
    }
    delete thePrimaryHelix;
    thePrimaryHelix = new TangentHelix( pt[0], pt[1], pt[2] );
}
void NuclearInteractionFinder::fillSeeds ( const std::pair< TrajectoryMeasurement, std::vector< TrajectoryMeasurement > > &  tmPairs) [private]

get the seeds at the interaction point

Definition at line 203 of file NuclearInteractionFinder.cc.

References allSeeds, currentSeed, LogDebug, TrajectoryMeasurement::recHit(), SeedFromNuclearInteraction::setMeasurements(), and TrajectoryMeasurement::updatedState().

Referenced by run().

                                                                                                                           {
  // This method returns the seeds calculated by the class SeedsFromNuclearInteraction

            const TM& innerTM = tmPairs.first;
            const std::vector<TM>& outerTMs = tmPairs.second;

            // Loop on all outer TM
            for(std::vector<TM>::const_iterator outtm = outerTMs.begin(); outtm!=outerTMs.end(); outtm++) {
               if((innerTM.recHit())->isValid() && (outtm->recHit())->isValid()) {
                     currentSeed->setMeasurements(innerTM.updatedState(), innerTM.recHit(), outtm->recHit());
                     allSeeds.push_back(*currentSeed);
                }
                else  LogDebug("NuclearSeedGenerator") << "The initial hits for seeding are invalid" << "\n";
             }
             return;
}
std::vector< TrajectoryMeasurement > NuclearInteractionFinder::findCompatibleMeasurements ( const TM lastMeas,
double  rescaleFactor 
) const [private]

Find compatible TM of a TM with error rescaled by rescaleFactor.

Definition at line 150 of file NuclearInteractionFinder.cc.

References findMeasurementsFromTSOS(), LogDebug, TrajectoryMeasurement::recHit(), rescaleError(), and TrajectoryMeasurement::updatedState().

Referenced by run().

{
  TSOS currentState = lastMeas.updatedState();
  LogDebug("NuclearSeedGenerator") << "currentState :" << currentState << "\n";

  TSOS newState = rescaleError(rescale, currentState);
  return findMeasurementsFromTSOS(newState, lastMeas.recHit()->geographicalId());
}
std::vector< TrajectoryMeasurement > NuclearInteractionFinder::findMeasurementsFromTSOS ( const TSOS currentState,
DetId  detid 
) const [private]

Definition at line 160 of file NuclearInteractionFinder.cc.

References alongMomentum, GeometricSearchTracker::detLayer(), TrajectoryStateOnSurface::freeState(), LogDebug, LayerMeasurements::measurements(), DetLayer::nextLayers(), query::result, python::multivaluedict::sort(), theEstimator, theGeomSearchTracker, theLayerMeasurements, thePropagator, and tmp.

Referenced by findCompatibleMeasurements(), and improveSeeds().

                                                                                              {

  using namespace std;
  int invalidHits = 0;
  vector<TM> result;
  const DetLayer* lastLayer = theGeomSearchTracker->detLayer( detid );
  vector<const DetLayer*> nl;

  if(lastLayer) {
          nl = lastLayer->nextLayers( *currentState.freeState(), alongMomentum);
  }
  else {
      edm::LogError("NuclearInteractionFinder") << "In findCompatibleMeasurements : lastLayer not accessible";
      return result;
  }

  if (nl.empty()) {
      LogDebug("NuclearSeedGenerator") << "In findCompatibleMeasurements :  no compatible layer found";
      return result;
  }

  for (vector<const DetLayer*>::iterator il = nl.begin();
       il != nl.end(); il++) {
    vector<TM> tmp =
      theLayerMeasurements->measurements((**il),currentState, *thePropagator, *theEstimator);
    if ( !tmp.empty()) {
      if ( result.empty()) result = tmp;
      else {
        // keep one dummy TM at the end, skip the others
        result.insert( result.end()-invalidHits, tmp.begin(), tmp.end());
      }
      invalidHits++;
    }
  }

  // sort the final result, keep dummy measurements at the end
  if ( result.size() > 1) {
    sort( result.begin(), result.end()-invalidHits, TrajMeasLessEstim());
  }
  return result;
}
std::auto_ptr< TrajectorySeedCollection > NuclearInteractionFinder::getPersistentSeeds ( )

Fill 'output' with persistent nuclear seeds.

Definition at line 220 of file NuclearInteractionFinder.cc.

References allSeeds, LogDebug, and convertSQLitetoXML_cfg::output.

                                                                                   {
   std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection);
   for(std::vector<SeedFromNuclearInteraction>::const_iterator it_seed = allSeeds.begin(); it_seed != allSeeds.end(); it_seed++) {
       if(it_seed->isValid()) {
           output->push_back( it_seed->TrajSeed() );
       }
       else LogDebug("NuclearSeedGenerator") << "The seed is invalid" << "\n";
   }
   return output;
}
void NuclearInteractionFinder::improveSeeds ( )

Improve the seeds with a third RecHit.

Definition at line 231 of file NuclearInteractionFinder.cc.

References allSeeds, currentSeed, findMeasurementsFromTSOS(), SeedFromNuclearInteraction::setMeasurements(), and thePrimaryHelix.

                                            {
        std::vector<SeedFromNuclearInteraction> newSeedCollection;

        // loop on all actual seeds
        for(std::vector<SeedFromNuclearInteraction>::const_iterator it_seed = allSeeds.begin(); it_seed != allSeeds.end(); it_seed++) {

              if( !it_seed->isValid() ) continue;

              // find compatible TM in an outer layer
              std::vector<TM> thirdTMs = findMeasurementsFromTSOS( it_seed->updatedTSOS() , it_seed->outerHitDetId() );

              // loop on those new TMs
              for(std::vector<TM>::const_iterator tm = thirdTMs.begin(); tm!= thirdTMs.end(); tm++) {

                   if( ! tm->recHit()->isValid() ) continue;

                   // create new seeds collection using the circle equation
                   currentSeed->setMeasurements(*thePrimaryHelix, it_seed->initialTSOS(), it_seed->outerHit(), tm->recHit() );
                   newSeedCollection.push_back( *currentSeed );
              }
       }
       allSeeds.clear();
       allSeeds = newSeedCollection;
}
const NavigationSchool* NuclearInteractionFinder::nav ( ) const [inline]

Definition at line 89 of file NuclearInteractionFinder.h.

References theNavigationSchool.

Referenced by NuclearInteractionFinder().

{ return theNavigationSchool; }
TrajectoryStateOnSurface NuclearInteractionFinder::rescaleError ( float  rescale,
const TSOS state 
) const

Definition at line 256 of file NuclearInteractionFinder.cc.

References TrajectoryStateOnSurface::globalParameters(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), m, GlobalTrajectoryParameters::magneticField(), LocalTrajectoryError::matrix(), LocalTrajectoryParameters::signedInverseMomentum(), TrajectoryStateOnSurface::surface(), and TrajectoryStateOnSurface::surfaceSide().

Referenced by findCompatibleMeasurements().

                                                                                                      {

     AlgebraicSymMatrix55 m(state.localError().matrix());
     AlgebraicSymMatrix55 mr;
     LocalTrajectoryParameters ltp = state.localParameters();

     // we assume that the error on q/p is equal to 20% of q/p * rescale 
     mr(0,0) = (ltp.signedInverseMomentum()*0.2*rescale)*(ltp.signedInverseMomentum()*0.2*rescale);

     // the error on dx/z and dy/dz is fixed to 10% (* rescale)
     mr(1,1) = 1E-2*rescale*rescale;
     mr(2,2) = 1E-2*rescale*rescale;

     // the error on the local x and y positions are not modified.
     mr(3,3) = m(3,3);
     mr(4,4) = m(4,4);

     return TSOS(ltp, mr, state.surface(), &(state.globalParameters().magneticField()), state.surfaceSide());
}
bool NuclearInteractionFinder::run ( const Trajectory traj)

Run the Finder.

Definition at line 79 of file NuclearInteractionFinder.cc.

References allSeeds, alongMomentum, NuclearTester::back(), checkCompletedTrack, NuclearTester::compatibleHits(), definePrimaryHelix(), Trajectory::direction(), Trajectory::empty(), fillSeeds(), findCompatibleMeasurements(), Trajectory::foundHits(), prof2calltree::front, NuclearTester::fwdEstimate(), NuclearTester::goodTMPair(), NuclearTester::isNuclearInteraction(), Trajectory::isValid(), LogDebug, maxHits, NuclearTester::meanHitDistance(), Trajectory::measurements(), NuclearTester::nHitsChecked(), NuclearTester::nuclearIndex(), nuclTester, NuclearTester::push_back(), rescaleErrorFactor, NuclearTester::reset(), and findQualityFiles::size.

                                                          {

        if(traj.empty() || !traj.isValid()) return false;

        LogDebug("NuclearSeedGenerator") << "Analyzis of a new trajectory with a number of valid hits = " << traj.foundHits();

        std::vector<TrajectoryMeasurement> measurements = traj.measurements();

        // initialization
        nuclTester->reset( measurements.size() );
        allSeeds.clear();


        if(traj.direction()==alongMomentum)  {
                std::reverse(measurements.begin(), measurements.end());
        }

        std::vector<TrajectoryMeasurement>::const_iterator it_meas = measurements.begin();

        std::vector<double> ncompatibleHits;
        bool NIfound = false;

        // Loop on all the RecHits.
        while(!NIfound)
         {
           if(it_meas == measurements.end()) break;

           // check only the maxHits outermost hits of the primary track
           if(nuclTester->nHitsChecked() > maxHits) break;

           nuclTester->push_back(*it_meas, findCompatibleMeasurements(*it_meas, rescaleErrorFactor));

           LogDebug("NuclearSeedGenerator") << "Number of compatible meas:" << (nuclTester->back()).size() << "\n"
                                                << "Mean distance between hits :" << nuclTester->meanHitDistance() << "\n"
                                                << "Forward estimate :" << nuclTester->fwdEstimate() << "\n";

           // don't check tracks which reach the end of the tracker if checkCompletedTrack==false
           if( checkCompletedTrack==false && (nuclTester->compatibleHits()).front()==0 ) break;

           if(nuclTester->isNuclearInteraction()) NIfound=true;

           ++it_meas;
         }

        if(NIfound) {
            LogDebug("NuclearSeedGenerator") << "NUCLEAR INTERACTION FOUND at index : " << nuclTester->nuclearIndex()  << "\n";

            // Get correct parametrization of the helix of the primary track at the interaction point (to be used by improveCurrentSeed)
            definePrimaryHelix(measurements.begin()+nuclTester->nuclearIndex()-1);

            this->fillSeeds( nuclTester->goodTMPair());

            return true;
        }

    return false;
}
void NuclearInteractionFinder::setEvent ( const edm::Event event) const

define the measurement (to be called for each event)

Definition at line 65 of file NuclearInteractionFinder.cc.

References theMeasurementTracker, and MeasurementTracker::update().

{
   theMeasurementTracker->update(event);
}

Member Data Documentation

Definition at line 103 of file NuclearInteractionFinder.h.

Referenced by fillSeeds(), getPersistentSeeds(), improveSeeds(), and run().

If set to true check all the tracks, even those reaching the edge of the tracker

Definition at line 110 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder(), and run().

unsigned int NuclearInteractionFinder::maxHits [private]

Definition at line 108 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder(), and run().

Definition at line 111 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder().

Definition at line 107 of file NuclearInteractionFinder.h.

Definition at line 109 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder(), and run().

Definition at line 99 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder().

Definition at line 95 of file NuclearInteractionFinder.h.

Referenced by NuclearInteractionFinder(), and setEvent().

Definition at line 98 of file NuclearInteractionFinder.h.

Referenced by nav(), and NuclearInteractionFinder().