Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:38

0001 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0002 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0003 
0004 #ifdef EDM_ML_DEBUG
0005 
0006 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0007 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0008 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0009 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0010 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0011 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
0012 #include "DataFormats/MuonDetId/interface/ME0DetId.h"
0013 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0014 #include "TrackingTools/GsfTools/interface/GetComponents.h"
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 
0017 namespace {
0018   inline void dump(TrackingRecHit const& hit, int hitcounter, const std::string& msgCat) {
0019     if (hit.isValid()) {
0020       LogTrace(msgCat) << " ----------------- HIT #" << hitcounter << " (VALID)-----------------------\n"
0021                        << "  HIT IS AT R   " << hit.globalPosition().perp() << "\n"
0022                        << "  HIT IS AT Z   " << hit.globalPosition().z() << "\n"
0023                        << "  HIT IS AT Phi " << hit.globalPosition().phi() << "\n"
0024                        << "  HIT IS AT Loc " << hit.localPosition() << "\n"
0025                        << "  WITH LocError " << hit.localPositionError() << "\n"
0026                        << "  HIT IS AT Glo " << hit.globalPosition() << "\n"
0027                        << "SURFACE POSITION"
0028                        << "\n"
0029                        << hit.surface()->position() << "\n"
0030                        << "SURFACE ROTATION"
0031                        << "\n"
0032                        << hit.surface()->rotation() << "dimension " << hit.dimension();
0033 
0034       DetId hitId = hit.geographicalId();
0035 
0036       LogDebug(msgCat) << " hit det=" << hitId.rawId();
0037 
0038       if (hitId.det() == DetId::Tracker) {
0039         switch (hitId.subdetId()) {
0040           case StripSubdetector::TIB:
0041             LogDebug(msgCat) << " I am TIB";
0042             break;
0043           case StripSubdetector::TOB:
0044             LogDebug(msgCat) << " I am TOB";
0045             break;
0046           case StripSubdetector::TEC:
0047             LogDebug(msgCat) << " I am TEC";
0048             break;
0049           case StripSubdetector::TID:
0050             LogDebug(msgCat) << " I am TID";
0051             break;
0052           case PixelSubdetector::PixelBarrel:
0053             LogDebug(msgCat) << " I am PixBar";
0054             break;
0055           case PixelSubdetector::PixelEndcap:
0056             LogDebug(msgCat) << " I am PixFwd";
0057             break;
0058           default:
0059             LogDebug(msgCat) << " UNKNOWN TRACKER HIT TYPE ";
0060         }
0061       } else if (hitId.det() == DetId::Muon) {
0062         if (hitId.subdetId() == MuonSubdetId::DT)
0063           LogDebug(msgCat) << " I am DT " << DTWireId(hitId);
0064         else if (hitId.subdetId() == MuonSubdetId::CSC)
0065           LogDebug(msgCat) << " I am CSC " << CSCDetId(hitId);
0066         else if (hitId.subdetId() == MuonSubdetId::RPC)
0067           LogDebug(msgCat) << " I am RPC " << RPCDetId(hitId);
0068         else if (hitId.subdetId() == MuonSubdetId::GEM)
0069           LogDebug(msgCat) << " I am GEM " << GEMDetId(hitId);
0070 
0071         else if (hitId.subdetId() == MuonSubdetId::ME0)
0072           LogDebug(msgCat) << " I am ME0 " << ME0DetId(hitId);
0073         else
0074           LogDebug(msgCat) << " UNKNOWN MUON HIT TYPE ";
0075       } else
0076         LogDebug(msgCat) << " UNKNOWN HIT TYPE ";
0077 
0078     } else {
0079       LogDebug(msgCat) << " ----------------- INVALID HIT #" << hitcounter << " -----------------------";
0080     }
0081   }
0082 #include <sstream>
0083   inline void dump(TrajectoryStateOnSurface const& tsos, const char* header, const std::string& msgCat) {
0084     std::ostringstream ss;
0085     ss << " weights ";
0086     GetComponents comps(tsos);
0087     auto const& tsosComponents = comps();
0088 
0089     for (auto const& c : tsosComponents)
0090       ss << c.weight() << '/';
0091     ss << "\nmomentums ";
0092     for (auto const& c : tsosComponents)
0093       ss << c.globalMomentum().mag() << '/';
0094     ss << "\ndeltap/p ";
0095     for (auto const& c : tsosComponents)
0096       ss << std::sqrt(tsos.curvilinearError().matrix()(0, 0)) / c.globalMomentum().mag() << '/';
0097     LogTrace(msgCat) << header << "! size " << tsosComponents.size() << ss.str() << "\n"
0098                      << " with local position " << tsos.localPosition() << "\n"
0099                      << tsos;
0100   }
0101 }  // namespace
0102 #else
0103 namespace {
0104   inline void dump(TrackingRecHit const &, int, const std::string &) {}
0105   inline void dump(TrajectoryStateOnSurface const &, const char *, const std::string &) {}
0106 }  // namespace
0107 #endif