// ------------------------------------------------------------------- // File name: G4ComptonTest // // Author: Maria Grazia Pia // // Creation date: 1 August 2008 // // Modifications: // // ------------------------------------------------------------------- #include "globals.hh" #include "G4ios.hh" #include #include #include "G4SystemOfUnits.hh" #include "G4CsComptonAPC.hh" int main() { // Produce total Compton cross sections in the same configuration // (energy and target atom) as experimental data char* path = getenv("G4WORKDIR"); // Path to experimental data files G4String pathData("/data/"); // Name of input file G4String nameIn("exp_comptonAPC.txt"); // Name of output file G4String nameOut("all_comptonAPC.txt"); // Number of rows in experimental data files int nRows = 214; G4String ref; G4String element; int Z; double exp; double error; double energy; // Prepare the output file where to write total cross sections std::ostringstream fileName; fileName << path << pathData << nameOut; G4String outFileName(fileName.str()); std::ofstream outFile(outFileName); std::cout << "Output file: " << outFileName << std::endl; // Read the file with experimental data std::ostringstream inputFileName; inputFileName << path << pathData << nameIn; G4String inFileName(inputFileName.str()); std::ifstream in(inFileName); std::cout << "Input file: " << inFileName << std::endl; if (!in.is_open()) { G4String message("Experimental input data file " + inFileName + " not found"); std::cout << message << std::endl; G4Exception("ComptonTest", "dummy", FatalException, message); } // Instantiate a Compton cross section G4CsComptonAPC csAPC; // Loop over data rows for (int iRow=0; iRow> ref >> Z >> energy >> exp >> error; // Rescale energy from keV (in experimental file) to MeV energy = energy * keV; // Calculate cross sections for the same energy and Z double sigma = csAPC.CrossSection(Z,energy) / barn; // Write experimental information and corresponding calculated cross section std::cout << ref << "\t" << Z << "\t" << energy << "\t" << exp << "\t" << error << "\t" << sigma << "\t" << std::endl; outFile << ref << "\t" << Z << "\t" << energy << "\t" << exp << "\t" << error << "\t" << sigma << "\t" << std::endl; } // end of loop over data rows // --------------------------------------------------------------------------- std::cout << "END OF THE MAIN PROGRAM" << G4endl; }