Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:58

0001 #ifndef RecoTracker_CkfPattern_PrintoutHelper_h
0002 #define RecoTracker_CkfPattern_PrintoutHelper_h
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 
0006 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0007 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
0008 #include "TrackingTools/PatternTools/interface/bqueue.h"
0009 
0010 class TrackerGeometry;
0011 
0012 class PrintoutHelper {
0013 public:
0014   template <class collection>
0015   static std::string dumpCandidates(collection& candidates);
0016   template <class Candidate>
0017   static std::string dumpCandidate(const Candidate& candidate, bool showErrors = false);
0018   static std::string dumpMeasurements(const std::vector<TrajectoryMeasurement>& v);
0019   static std::string dumpMeasurements(const cmsutils::bqueue<TrajectoryMeasurement>& v);
0020   static std::string dumpMeasurement(const TrajectoryMeasurement& tm);
0021   static std::string regressionTest(const TrackerGeometry& tracker, std::vector<Trajectory>& unsmoothedResult);
0022 };
0023 
0024 template <class Candidate>
0025 std::string PrintoutHelper::dumpCandidate(const Candidate& traj, bool showErrors) {
0026   // does not work....
0027   LogDebug("PrintoutHelperError") << "switching on error printout" << (showErrors = true);
0028 
0029   std::stringstream buffer;
0030   if (!traj.measurements().empty()) {
0031     const TrajectoryMeasurement& last = traj.lastMeasurement();
0032 
0033     buffer << "with: " << traj.measurements().size() << " measurements." << traj.lostHits() << " lost, "
0034            << traj.foundHits() << " found, " << traj.trailingFoundHits() << " trailing, " << traj.cccBadHits()
0035            << " badCC, "
0036            << "chi2=" << traj.chiSquared() << ' ' << int(traj.nLoops()) << " loops\n";
0037     if (last.updatedState().isValid()) {
0038       const TrajectoryStateOnSurface& tsos = last.updatedState();
0039       if (showErrors)
0040         buffer << "Last [Updated] state\n : " << tsos << "\n";
0041       else
0042         buffer << "Last [Updated] state\n x: " << tsos.globalPosition() << "\n p: " << tsos.globalMomentum() << "\n";
0043     } else if (last.forwardPredictedState().isValid()) {
0044       const TrajectoryStateOnSurface& tsos = last.forwardPredictedState();
0045       if (showErrors)
0046         buffer << "Last [fwdPredicted] state\n : " << tsos << "\n";
0047       else
0048         buffer << "Last [fwdPredicted] state\n x: " << tsos.globalPosition() << "\n p: " << tsos.globalMomentum()
0049                << "\n";
0050     } else if (last.predictedState().isValid()) {
0051       const TrajectoryStateOnSurface& tsos = last.predictedState();
0052       if (showErrors)
0053         buffer << "Last [Predicted] state\n : " << tsos << "\n";
0054       else
0055         buffer << "Last [Predicted] state\n x: " << tsos.globalPosition() << "\n p: " << tsos.globalMomentum() << "\n";
0056     }
0057     buffer << " hit is: " << (last.recHit()->isValid() ? "valid" : "invalid") << "\n";
0058     if (last.recHit()->isValid()) {
0059       buffer << "on detId: " << last.recHit()->geographicalId().rawId() << "\n";
0060       buffer << "gp: " << last.recHit()->globalPosition() << "\n";
0061     }
0062   } else {
0063     buffer << " no measurement. \n";
0064   }
0065   return buffer.str();
0066 }
0067 
0068 template <class collection>
0069 std::string PrintoutHelper::dumpCandidates(collection& candidates) {
0070   std::stringstream buffer;
0071   buffer << "\n____________________________\n";
0072   unsigned int ic = 0;
0073   for (auto const& traj : candidates) {
0074     buffer << ic++ << "] " << (traj.isValid() ? "valid " : "invalid ");
0075     buffer << PrintoutHelper::dumpCandidate(traj);
0076   }
0077   buffer << "\n____________________________\n";
0078   return buffer.str();
0079 }
0080 
0081 #endif