CMS 3D CMS Logo

Public Member Functions

CosmicMuonUtilities Class Reference

#include <CosmicMuonUtilities.h>

List of all members.

Public Member Functions

 CosmicMuonUtilities ()
bool isTraversing (const Trajectory &) const
std::string print (const MuonRecHitContainer &) const
std::string print (const ConstRecHitContainer &) const
std::string print (const ConstMuonRecHitContainer &) const
void reverseDirection (TrajectoryStateOnSurface &, const MagneticField *) const
TrajectoryStateOnSurface stepPropagate (const TrajectoryStateOnSurface &, const ConstRecHitPointer &, const Propagator &) const
virtual ~CosmicMuonUtilities ()

Detailed Description

Definition at line 29 of file CosmicMuonUtilities.h.


Constructor & Destructor Documentation

CosmicMuonUtilities::CosmicMuonUtilities ( )

Definition at line 24 of file CosmicMuonUtilities.cc.

                                         {
}
CosmicMuonUtilities::~CosmicMuonUtilities ( ) [virtual]

Definition at line 31 of file CosmicMuonUtilities.cc.

                                          {
}

Member Function Documentation

bool CosmicMuonUtilities::isTraversing ( const Trajectory t) const

Definition at line 133 of file CosmicMuonUtilities.cc.

References PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), Trajectory::recHits(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

                                                                {

  TransientTrackingRecHit::ConstRecHitContainer hits = t.recHits();

  if ( hits.empty() ) return false;

  ConstRecHitContainer::const_iterator frontHit = hits.begin();
  ConstRecHitContainer::const_iterator backHit  = hits.end() - 1;

  // find first valid hit at both ends of the trajectory
  while ( !(*frontHit)->isValid() && frontHit != backHit) {++frontHit;}
  while ( !(*backHit)->isValid() && backHit != frontHit)  {--backHit;}

  if ( frontHit == backHit )  return false;

  GlobalPoint frontPos = (*frontHit)->globalPosition();
  GlobalPoint backPos = (*backHit)->globalPosition();

  // are there separate muon hits in 2 different hemispheres
  GlobalVector deltaPos(frontPos - backPos);
  if ( deltaPos.mag() < 100.0 ) return false;
  if ( fabs(deltaPos.z() ) > 500.0 ) return true;
  if ( deltaPos.perp() > 350.0 ) return true;
  GlobalPoint middle((frontPos.x()+backPos.x())/2, 
                     (frontPos.y()+backPos.y())/2, 
                     (frontPos.z()+backPos.z())/2);

  return ( (middle.perp() < frontPos.perp()) && (middle.perp() < backPos.perp()) );

}
string CosmicMuonUtilities::print ( const ConstMuonRecHitContainer hits) const

Definition at line 52 of file CosmicMuonUtilities.cc.

References convertSQLitetoXML_cfg::output, PV3DBase< T, PVType, FrameType >::perp(), and pos.

                                                                                                       {

   stringstream output;

    for (ConstMuonRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
    if ( !(*ir)->isValid() ) {
      output << "invalid RecHit"<<endl;
      continue;
    }

    const GlobalPoint& pos = (*ir)->globalPosition();
    output
    << "pos"<<pos
    << "radius "<<pos.perp()
    << "  dim " << (*ir)->dimension()
    << "  det " << (*ir)->det()->geographicalId().det()
    << "  sub det " << (*ir)->det()->subDetector()<<endl;
  }

  return output.str();

}
string CosmicMuonUtilities::print ( const MuonRecHitContainer hits) const

Definition at line 79 of file CosmicMuonUtilities.cc.

References convertSQLitetoXML_cfg::output, PV3DBase< T, PVType, FrameType >::perp(), and pos.

                                                                                                  {

   stringstream output;

    for (MuonRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
    if ( !(*ir)->isValid() ) {
      output << "invalid RecHit"<<endl;
      continue;
    }

    const GlobalPoint& pos = (*ir)->globalPosition();
    output
    << "pos"<<pos
    << "radius "<<pos.perp()
    << "  dim " << (*ir)->dimension()
    << "  det " << (*ir)->det()->geographicalId().det()
    << "  sub det " << (*ir)->det()->subDetector()<<endl;
  }

  return output.str();

}
string CosmicMuonUtilities::print ( const ConstRecHitContainer hits) const

Definition at line 106 of file CosmicMuonUtilities.cc.

References convertSQLitetoXML_cfg::output, PV3DBase< T, PVType, FrameType >::perp(), and pos.

                                                                                               {

    stringstream output;

    for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
    if ( !(*ir)->isValid() ) {
      output << "invalid RecHit"<<endl;
      continue;
    }

    const GlobalPoint& pos = (*ir)->globalPosition();
    output
    << "pos"<<pos
    << "radius "<<pos.perp()
    << "  dim " << (*ir)->dimension()
    << "  det " << (*ir)->det()->geographicalId().det()
    << "  sub det " << (*ir)->det()->subDetector()<<endl;
  }

  return output.str();

}
void CosmicMuonUtilities::reverseDirection ( TrajectoryStateOnSurface tsos,
const MagneticField mgfield 
) const
TrajectoryStateOnSurface CosmicMuonUtilities::stepPropagate ( const TrajectoryStateOnSurface tsos,
const ConstRecHitPointer hit,
const Propagator prop 
) const

Definition at line 168 of file CosmicMuonUtilities.cc.

References alignCSCRings::dest, TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::isValid(), LogTrace, PV3DBase< T, PVType, FrameType >::mag(), metname, PlaneBuilder::plane(), pos, Propagator::propagate(), makeMuonMisalignmentScenario::rot, relval_steps::steps, Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by CosmicMuonSmoother::fit(), and CosmicMuonSmoother::smooth().

                                                                                           {

  const std::string metname = "Muon|RecoMuon|CosmicMuonUtilities";

  GlobalPoint start = tsos.globalPosition();
  GlobalPoint dest = hit->globalPosition();
  GlobalVector StepVector = dest - start;
  GlobalVector UnitStepVector = StepVector.unit();
  GlobalPoint GP =start;
  TrajectoryStateOnSurface currTsos(tsos);
  TrajectoryStateOnSurface predTsos;
  float totalDis = StepVector.mag();
  LogTrace(metname)<<"stepPropagate: propagate from: "<<start<<" to "<<dest;
  LogTrace(metname)<<"stepPropagate: their distance: "<<totalDis;

  int steps = 3; // need to optimize

  float oneStep = totalDis/steps;
  Basic3DVector<float> Basic3DV(StepVector.x(),StepVector.y(),StepVector.z());
  for ( int istep = 0 ; istep < steps - 1 ; istep++) {
        GP += oneStep*UnitStepVector;
        Surface::PositionType pos(GP.x(),GP.y(),GP.z());
        LogTrace(metname)<<"stepPropagate: a middle plane: "<<pos<<endl;
        Surface::RotationType rot( Basic3DV , float(0));
        PlaneBuilder::ReturnType SteppingPlane = PlaneBuilder().plane(pos,rot);
        TrajectoryStateOnSurface predTsos = prop.propagate(currTsos, *SteppingPlane);
        if (predTsos.isValid()) {
            currTsos=predTsos;
            LogTrace(metname)<<"stepPropagate: middle state "<< currTsos.globalPosition()<<endl;
        }
 }

  predTsos = prop.propagate(currTsos, hit->det()->surface());

  return predTsos;

}