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 
6 
7 class TrackerGeometry;
8 
10  public:
11  template< class collection > static std::string dumpCandidates( collection & candidates);
12  template< class Candidate> static std::string dumpCandidate( const Candidate & candidate,bool showErrors=false);
13  static std::string dumpMeasurements(const std::vector<TrajectoryMeasurement> & v) ;
16  static std::string regressionTest(const TrackerGeometry & tracker,std::vector<Trajectory> & unsmoothedResult);
17 };
18 
19 template<class Candidate>
20 std::string PrintoutHelper::dumpCandidate( const Candidate & traj,bool showErrors ){
21 
22  // does not work....
23  LogDebug("PrintoutHelperError")<<"switching on error printout"<<(showErrors=true);
24 
25  std::stringstream buffer;
26  if (!traj.measurements().empty()){
27  const TrajectoryMeasurement & last = traj.lastMeasurement();
28 
29  buffer<<"with: "<<traj.measurements().size()<<" measurements."<< traj.lostHits() << " lost, " << traj.foundHits()<<" found, "
30  << traj.trailingFoundHits() << " trailing, " << traj.cccBadHits() << " badCC, "
31  << "chi2="<<traj.chiSquared() << ' '
32  << int(traj.nLoops())<<" loops\n";
33  if (last.updatedState().isValid()) {
34  const TrajectoryStateOnSurface & tsos = last.updatedState();
35  if (showErrors)
36  buffer <<"Last [Updated] state\n : "<<tsos<<"\n";
37  else
38  buffer <<"Last [Updated] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
39  } else if(last.forwardPredictedState().isValid()){
40  const TrajectoryStateOnSurface & tsos = last.forwardPredictedState();
41  if (showErrors)
42  buffer <<"Last [fwdPredicted] state\n : "<<tsos<<"\n";
43  else
44  buffer <<"Last [fwdPredicted] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
45  } else if (last.predictedState().isValid()){
46  const TrajectoryStateOnSurface & tsos = last.predictedState();
47  if (showErrors)
48  buffer <<"Last [Predicted] state\n : "<<tsos<<"\n";
49  else
50  buffer <<"Last [Predicted] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
51  }
52  buffer <<" hit is: "<<(last.recHit()->isValid()?"valid":"invalid")<<"\n";
53  if (last.recHit()->isValid()) {
54  buffer <<"on detId: "<<last.recHit()->geographicalId().rawId()<<"\n";
55  buffer <<"gp: "<<last.recHit()->globalPosition()<<"\n";
56  }
57  }
58  else{
59  buffer<<" no measurement. \n";}
60  return buffer.str();
61 }
62 
63 
64 template< class collection >
66  std::stringstream buffer;
67  buffer << "\n____________________________\n";
68  unsigned int ic=0;
69  for (auto const & traj : candidates) {
70  buffer<<ic++<<"] " << (traj.isValid() ? "valid " : "invalid ");
71  buffer<<PrintoutHelper::dumpCandidate(traj);
72  }
73  buffer << "\n____________________________\n";
74  return buffer.str();
75 }
76 
77 
78 #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