CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoTracker/CkfPattern/interface/PrintoutHelper.h

Go to the documentation of this file.
00001 #ifndef RecoTracker_CkfPattern_PrintoutHelper_h
00002 #define RecoTracker_CkfPattern_PrintoutHelper_h
00003 
00004 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
00005 #include "TrackingTools/PatternTools/interface/TrajectoryBuilder.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 
00009 #include "TrackingTools/PatternTools/interface/bqueue.h"
00010 
00011 class TrackerGeometry;
00012 
00013 class PrintoutHelper{
00014  public:
00015   template< class collection > static std::string dumpCandidates( collection & candidates);
00016   template< class Candidate> static std::string dumpCandidate( const Candidate & candidate,bool showErrors=false);
00017   static std::string dumpMeasurements(const std::vector<TrajectoryMeasurement> & v) ;
00018   static std::string dumpMeasurements(const cmsutils::bqueue<TrajectoryMeasurement> & v);
00019   static std::string dumpMeasurement(const TrajectoryMeasurement & tm);
00020   static std::string regressionTest(const TrackerGeometry & tracker,std::vector<Trajectory> & unsmoothedResult);
00021 };
00022 
00023 template<class Candidate>
00024 std::string PrintoutHelper::dumpCandidate( const Candidate & traj,bool showErrors ){
00025 
00026   LogDebug("PrintoutHelperError")<<"switching on error printout"<<(showErrors=true);
00027 
00028   std::stringstream buffer;
00029   if (!traj.measurements().empty()){
00030     const TrajectoryMeasurement & last = traj.lastMeasurement();
00031     
00032     buffer<<"with: "<<traj.measurements().size()<<" measurements."<< traj.lostHits() << " lost, " << traj.foundHits()<<" found, chi2="<<traj.chiSquared()<<"\n";
00033     if (last.updatedState().isValid()) {
00034       const TrajectoryStateOnSurface & tsos = last.updatedState();
00035       if (showErrors)
00036         buffer <<"Last [Updated] state\n : "<<tsos<<"\n";
00037       else
00038         buffer <<"Last [Updated] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
00039     } else if(last.forwardPredictedState().isValid()){
00040       const TrajectoryStateOnSurface & tsos = last.forwardPredictedState();
00041       if (showErrors)
00042         buffer <<"Last [fwdPredicted] state\n : "<<tsos<<"\n";
00043       else
00044         buffer <<"Last [fwdPredicted] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
00045     } else if (last.predictedState().isValid()){
00046       const TrajectoryStateOnSurface & tsos = last.predictedState();
00047       if (showErrors)
00048         buffer <<"Last [Predicted] state\n : "<<tsos<<"\n";
00049       else
00050         buffer <<"Last [Predicted] state\n x: "<<tsos.globalPosition()<<"\n p: "<<tsos.globalMomentum()<<"\n";
00051     }
00052     buffer <<" hit is: "<<(last.recHit()->isValid()?"valid":"invalid")<<"\n";
00053     if (last.recHit()->isValid())
00054       buffer <<"on detId: "<<last.recHit()->geographicalId().rawId()<<"\n";  
00055   }
00056   else{
00057       buffer<<" no measurement. \n";}
00058   return buffer.str();
00059 }
00060 
00061 
00062 template< class collection > 
00063 std::string PrintoutHelper::dumpCandidates( collection & candidates) {
00064   std::stringstream buffer;
00065   unsigned int ic=0;
00066   typename collection::const_iterator traj=candidates.begin();
00067   for (;traj!=candidates.end(); traj++) {  
00068     buffer<<ic++<<"] ";
00069     buffer<<PrintoutHelper::dumpCandidate(*traj);
00070   }
00071   return buffer.str();
00072 }
00073 
00074 
00075 #endif