CMS 3D CMS Logo

PrintoutHelper.h
Go to the documentation of this file.
1 #ifndef RecoTracker_CkfPattern_PrintoutHelper_h
2 #define RecoTracker_CkfPattern_PrintoutHelper_h
3 
5 
9 
10 class TrackerGeometry;
11 
13  public:
14  template< class collection > static std::string dumpCandidates( collection & candidates);
15  template< class Candidate> static std::string dumpCandidate( const Candidate & candidate,bool showErrors=false);
16  static std::string dumpMeasurements(const std::vector<TrajectoryMeasurement> & v) ;
19  static std::string regressionTest(const TrackerGeometry & tracker,std::vector<Trajectory> & unsmoothedResult);
20 };
21 
22 template<class Candidate>
23 std::string PrintoutHelper::dumpCandidate( const Candidate & traj,bool showErrors ){
24 
25  // does not work....
26  LogDebug("PrintoutHelperError")<<"switching on error printout"<<(showErrors=true);
27 
28  std::stringstream buffer;
29  if (!traj.measurements().empty()){
30  const TrajectoryMeasurement & last = traj.lastMeasurement();
31 
32  buffer<<"with: "<<traj.measurements().size()<<" measurements."<< traj.lostHits() << " lost, " << traj.foundHits()<<" found, "
33  << traj.trailingFoundHits() << " trailing, " << traj.cccBadHits() << " badCC, "
34  << "chi2="<<traj.chiSquared() << ' '
35  << int(traj.nLoops())<<" loops\n";
36  if (last.updatedState().isValid()) {
37  const TrajectoryStateOnSurface & tsos = last.updatedState();
38  if (showErrors)
39  buffer <<"Last [Updated] state\n : "<<tsos<<"\n";
40  else
41  buffer <<"Last [Updated] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
42  } else if(last.forwardPredictedState().isValid()){
43  const TrajectoryStateOnSurface & tsos = last.forwardPredictedState();
44  if (showErrors)
45  buffer <<"Last [fwdPredicted] state\n : "<<tsos<<"\n";
46  else
47  buffer <<"Last [fwdPredicted] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
48  } else if (last.predictedState().isValid()){
49  const TrajectoryStateOnSurface & tsos = last.predictedState();
50  if (showErrors)
51  buffer <<"Last [Predicted] state\n : "<<tsos<<"\n";
52  else
53  buffer <<"Last [Predicted] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
54  }
55  buffer <<" hit is: "<<(last.recHit()->isValid()?"valid":"invalid")<<"\n";
56  if (last.recHit()->isValid()) {
57  buffer <<"on detId: "<<last.recHit()->geographicalId().rawId()<<"\n";
58  buffer <<"gp: "<<last.recHit()->globalPosition()<<"\n";
59  }
60  }
61  else{
62  buffer<<" no measurement. \n";}
63  return buffer.str();
64 }
65 
66 
67 template< class collection >
69  std::stringstream buffer;
70  buffer << "\n____________________________\n";
71  unsigned int ic=0;
72  for (auto const & traj : candidates) {
73  buffer<<ic++<<"] " << (traj.isValid() ? "valid " : "invalid ");
74  buffer<<PrintoutHelper::dumpCandidate(traj);
75  }
76  buffer << "\n____________________________\n";
77  return buffer.str();
78 }
79 
80 
81 #endif
#define LogDebug(id)
static std::string dumpCandidates(collection &candidates)
TrajectoryStateOnSurface const & predictedState() const
ConstRecHitPointer const & recHit() const
GlobalPoint globalPosition() const
static std::string dumpMeasurement(const TrajectoryMeasurement &tm)
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
static std::string regressionTest(const TrackerGeometry &tracker, std::vector< Trajectory > &unsmoothedResult)
static std::string dumpCandidate(const Candidate &candidate, bool showErrors=false)
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
TrajectoryStateOnSurface const & updatedState() const