File indexing completed on 2024-04-06 12:30:13
0001 #include "SimG4CMS/Tracker/interface/TkSimHitPrinter.h"
0002
0003 #include <iomanip>
0004 #include <fstream>
0005
0006 #include "G4Track.hh"
0007
0008 std::ofstream* TkSimHitPrinter::theFile(nullptr);
0009
0010 TkSimHitPrinter::TkSimHitPrinter(const std::string& filename) {
0011 if (theFile)
0012 return;
0013 const char* theName = filename.c_str();
0014 theFile = new std::ofstream(theName, std::ios::out);
0015 }
0016
0017 TkSimHitPrinter::~TkSimHitPrinter() {}
0018
0019 void TkSimHitPrinter::startNewSimHit(const std::string& s, const std::string& d, int i, int j, int k, int eve) {
0020 (*theFile) << "Event: " << eve << " " << s << " " << d << " " << i << " Track " << j << " " << k;
0021 }
0022
0023 void TkSimHitPrinter::printLocal(const Local3DPoint& p, const Local3DPoint& e) const {
0024 (*theFile) << "\n Local(cm): " << p.x() << " " << p.y() << " " << p.z() << " ; " << e.x() << " " << e.y() << " "
0025 << e.z();
0026 }
0027
0028 void TkSimHitPrinter::printGlobal(const Local3DPoint& p, const Local3DPoint& e) const {
0029 (*theFile) << "\n Global(mm): " << p.x() << " " << p.y() << " " << p.z() << " ; " << e.x() << " " << e.y() << " "
0030 << e.z();
0031 }
0032
0033 void TkSimHitPrinter::printHitData(const std::string& nam, float p, float de, float tof) const {
0034 (*theFile) << "\n " << nam << " p(GeV): " << p << " Edep(GeV): " << de << " ToF: " << tof;
0035 }
0036 void TkSimHitPrinter::printGlobalMomentum(float px, float py, float pz) const {
0037 (*theFile) << " Momentum " << px << " " << py << " " << pz << "\n";
0038 }