File indexing completed on 2024-04-06 12:32:17
0001 #include "Validation/Geometry/interface/MaterialBudgetTxt.h"
0002 #include "Validation/Geometry/interface/MaterialBudgetData.h"
0003 #include "G4EventManager.hh"
0004 #include "G4Event.hh"
0005
0006 MaterialBudgetTxt::MaterialBudgetTxt(std::shared_ptr<MaterialBudgetData> data, const std::string& fileName)
0007 : MaterialBudgetFormat(data) {
0008 const char* fnamechar = fileName.c_str();
0009 theFile = new std::ofstream(fnamechar, std::ios::out);
0010 edm::LogInfo("MaterialBudget") << "MaterialBudgetTxt: Dumping Material Budget to " << fileName;
0011 if (theFile->fail()) {
0012 edm::LogError("MaterialBudget") << "MaterialBudgetTxt: Error opening file" << fileName;
0013 }
0014 }
0015
0016 MaterialBudgetTxt::~MaterialBudgetTxt() {}
0017
0018 void MaterialBudgetTxt::fillStartTrack() {
0019 (*theFile) << " Track " << G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID() << " "
0020 << theData->getEta() << " " << theData->getPhi() << std::endl;
0021
0022 }
0023
0024 void MaterialBudgetTxt::fillPerStep() {
0025 (*theFile) << "step " << theData->getTrkLen() << " " << theData->getPVname() << " " << theData->getPVcopyNo() << " "
0026 << theData->getTotalMB() << " " << theData->getRadLen() << std::endl;
0027
0028 }
0029
0030 void MaterialBudgetTxt::fillEndTrack() {
0031 (*theFile) << G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID() << " "
0032 << "finalTrkMB " << theData->getTotalMB() << std::endl;
0033 }
0034
0035 void MaterialBudgetTxt::endOfRun() { theFile->close(); }