File indexing completed on 2023-03-17 11:25:28
0001 #include "SimMuon/Neutron/src/AsciiNeutronWriter.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include <sstream>
0004 #include <fstream>
0005
0006 using namespace std;
0007
0008 AsciiNeutronWriter::AsciiNeutronWriter(string fileNameBase) : theFileNameBase(fileNameBase) {}
0009
0010 AsciiNeutronWriter::~AsciiNeutronWriter() {}
0011
0012 void AsciiNeutronWriter::writeCluster(int chamberType, const edm::PSimHitContainer& hits) {
0013
0014 stringstream s;
0015 s << theFileNameBase << chamberType;
0016 LogDebug("NeutronWriter") << "opening " << s.str();
0017 ofstream os;
0018 os.open(s.str().c_str(), ofstream::app);
0019 os << hits.size() << endl;
0020 for (size_t i = 0; i < hits.size(); ++i) {
0021 const PSimHit& h = hits[i];
0022 os << h.entryPoint().x() << " " << h.entryPoint().y() << " " << h.entryPoint().z() << " " << h.exitPoint().x()
0023 << " " << h.exitPoint().y() << " " << h.exitPoint().z() << " " << h.pabs() << " "
0024 << " " << h.timeOfFlight() << " " << h.energyLoss() << " " << h.particleType() << " " << h.detUnitId() << " "
0025 << h.trackId() << " " << h.momentumAtEntry().theta() << " " << h.momentumAtEntry().phi() << endl;
0026 }
0027 }