00001 #include "SimMuon/Neutron/src/AsciiNeutronWriter.h" 00002 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00003 #include <sstream> 00004 #include <fstream> 00005 00006 using namespace std; 00007 00008 AsciiNeutronWriter::AsciiNeutronWriter(string fileNameBase) : 00009 theFileNameBase(fileNameBase) { 00010 } 00011 00012 00013 AsciiNeutronWriter::~AsciiNeutronWriter() { 00014 } 00015 00016 00017 void AsciiNeutronWriter::writeEvent(int chamberType, const edm::PSimHitContainer & hits) 00018 { 00019 // open the correct file 00020 stringstream s; 00021 s << theFileNameBase << chamberType; 00022 LogDebug("NeutronWriter") << "opening " << s.str(); 00023 ofstream os; 00024 os.open(s.str().c_str(), ofstream::app); 00025 os << hits.size() << endl; 00026 for(size_t i = 0; i < hits.size(); ++i) { 00027 PSimHit h = hits[i]; 00028 os << h.entryPoint().x() << " " << h.entryPoint().y() << " " 00029 << h.entryPoint().z() << " " << h.exitPoint().x() << " " 00030 << h.exitPoint().y() << " " << h.exitPoint().z() << " " 00031 << h.pabs() << " " << " " << h.timeOfFlight() << " " 00032 << h.energyLoss() << " " <<h.particleType() << " " 00033 << h.detUnitId() << " " << h.trackId() << " " 00034 << h.momentumAtEntry().theta() << " " << h.momentumAtEntry().phi() << endl; 00035 } 00036 } 00037