IAP GITLAB

Commit 75874b83 authored by Matthieu Carrere's avatar Matthieu Carrere

added new tests to compare corsika 7 and corsika 8

parent c3aef363
Pipeline #5266 failed with stages
in 40 minutes and 23 seconds
......@@ -48,13 +48,16 @@ namespace corsika::cherenkov {
depthToSortPhotons_[i] = i * grammageStepDepthStatic_ + grammageStepDepthStatic_;
}
auto dxy = tan(theta) * (atmosphereTop_ - altitudeForObservationLevel_);
offsetXForObservationLevel_ = cos(phi) * dxy;
offsetYForObservationLevel_ = sin(phi) * dxy;
CORSIKA_LOG_TRACE("@CHERENKOV xoff: offset for observator level= {}",
offsetXForObservationLevel_);
CORSIKA_LOG_TRACE("@CHERENKOV yoff: offset for observator level= {}",
offsetYForObservationLevel_);
// auto dxy = tan(theta) * (atmosphereTop_ - altitudeForObservationLevel_);
// offsetXForObservationLevel_ = -cos(phi) * dxy;
// if(sin(phi)<1e-15) offsetYForObservationLevel_ = 0._m;
// else offsetYForObservationLevel_ = -sin(phi) * dxy;
// CORSIKA_LOG_TRACE("@CHERENKOV xoff: offset for observator level= {}",
// offsetXForObservationLevel_);
// CORSIKA_LOG_TRACE("@CHERENKOV yoff: offset for observator level= {}",
// offsetYForObservationLevel_);
offsetXForObservationLevel_=0._m;
offsetYForObservationLevel_=0._m;
}
template <typename TOutputWriter>
......
......@@ -471,7 +471,7 @@ namespace corsika::cherenkov {
double photonsOnTheGround_ = 0.;
double bunchesOnTheGround_ = 0.;
int photonsGenerated_ = 0.;
double photonsGenerated_ = 0.;
// pseudo random generator for cherenkov
std::uniform_real_distribution<double> uniformRealDistribution_{0., 1.};
......
......@@ -70,3 +70,11 @@ CORSIKA_REGISTER_EXAMPLE (corsika7_cascade_example_cherenkov RUN_OPTIONS 26 prot
add_executable (em_shower_cherenkov_tabulated em_shower_cherenkov_tabulated.cpp)
target_link_libraries (em_shower_cherenkov_tabulated CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (em_shower_cherenkov_tabulated RUN_OPTIONS)
add_executable (corsika8_with_corsika7_inputs corsika8_with_corsika7_inputs.cpp)
target_link_libraries (corsika8_with_corsika7_inputs CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (corsika8_with_corsika7_inputs RUN_OPTIONS 26 gamma 1)
add_executable (inputCardTest inputCardTest.cpp)
target_link_libraries (inputCardTest CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (inputCardTest RUN_OPTIONS)
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#include <corsika/framework/core/Cascade.hpp>
#include <corsika/framework/geometry/Plane.hpp>
#include <corsika/framework/geometry/Sphere.hpp>
#include <corsika/framework/process/InteractionCounter.hpp>
#include <corsika/framework/process/ProcessSequence.hpp>
#include <corsika/media/Environment.hpp>
#include <corsika/media/LayeredSphericalAtmosphereBuilder.hpp>
#include <corsika/media/NuclearComposition.hpp>
#include <corsika/media/ShowerAxis.hpp>
#include <corsika/modules/ParticleCut.hpp>
#include <corsika/output/OutputManager.hpp>
#include <corsika/output/NoOutput.hpp>
#include <corsika/output/NoOutputCherenkov.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/random/RNGManager.hpp>
#include <corsika/framework/utility/CorsikaFenv.hpp>
#include <corsika/modules/TrackWriter.hpp>
#include <corsika/modules/CherenkovToolBox.hpp>
#include <corsika/modules/Cherenkov.hpp>
#include <corsika/setup/SetupEnvironment.hpp>
#include <corsika/setup/SetupStack.hpp>
#include <corsika/setup/SetupTrajectory.hpp>
#include <corsika/framework/core/Logging.hpp>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <typeinfo>
using namespace corsika;
using namespace std;
struct myExperiment {
int atmosphereNumber = 26;
string particleType = "gamma";
string nbShower = "10";
};
//
// The example main program for a particle cascade
//
// argv : 1.number of atmosphere, 2.particle type,
// 3.number of showers
int main(int argc, char** argv) {
corsika_logger->set_pattern("[%n:%^%-8l%$] %s:%#: %v");
logging::set_level(logging::level::info);
CORSIKA_LOG_INFO("vertical_EAS");
CORSIKA_LOG_INFO("cascade_example_cherenkov_tabulated_corsika7");
myExperiment experiment;
experiment.atmosphereNumber = stoi(string(argv[1]));
experiment.particleType = argv[2];
experiment.nbShower = argv[3];
const LengthType height_atmosphere = 112.8_km;
const LengthType height_observator = 215000._cm;
double theta = 20.;
double phi = 180.;
auto const thetaRad = theta / 180. * M_PI;
auto const phiRad = phi / 180. * M_PI;
std::string const configurationTelescopeName = "position_99";
string const cherenkov_file = "cherenkov";
cherenkov::AtmosphereTabulated atmosphere{experiment.atmosphereNumber,
height_atmosphere, height_observator};
cherenkov::TelescopeGrid telescopeGrid{
configurationTelescopeName, height_atmosphere, 0._m,
height_observator, thetaRad, phiRad};
RNGManager<>::getInstance().registerRandomStream("cherenkov");
cherenkov::CherenkovToolBox pCherenkovToolBox{atmosphere, experiment.particleType,
experiment.nbShower};
cherenkov::Cherenkov<> pCherenkov{atmosphere, telescopeGrid, thetaRad,
phiRad, false, true};
pCherenkovToolBox.countNumberOfSamples();
auto const numberSamples = pCherenkovToolBox.getNumberOfSamples();
OutputManager output("corsika8_with_corsika7_input");
output.add(cherenkov_file, pCherenkov); // register Cherenkov
output.startOfLibrary();
for (int i = 0; i < numberSamples; i++) {
output.startOfShower();
pCherenkov.initParticleValuesWithCorsika7Values(pCherenkovToolBox);
if (!pCherenkov.conditionsToStartCherenkov()) { continue; }
pCherenkov.generatePhotons();
output.endOfShower();
}
output.endOfLibrary();
pCherenkov.savePhotonsByHeight();
pCherenkov.savePhotonsByDepth();
pCherenkov.printNumberOfPhotonBunches();
}
This diff is collapsed.
This diff is collapsed.
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/media/NuclearComposition.hpp>
#include <corsika/framework/core/Logging.hpp>
#include <iomanip>
#include <iostream>
#include <limits>
#include <fstream>
#include <string>
#include <typeinfo>
#include <algorithm>
#include <vector>
#include <boost/algorithm/string/erase.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
using namespace corsika;
using namespace std;
namespace corsika::experimentC8 {
class ExperimentC8 {
public:
ExperimentC8();
ExperimentC8(std::string inputFileDir) {
ifstream inputFile(inputFileDir);
if (!inputFile) {
CORSIKA_LOG_INFO(
"An error has occurred while reading input file. Default values loaded.");
} else {
std::string line;
while (std::getline(inputFile, line)) {
std::string option;
std::string value;
std::string description;
std::stringstream linestream(line);
std::getline(linestream, option, '#');
std::getline(linestream, value, '#');
std::getline(linestream, description, '#');
if (option.find("showers") != std::string::npos) {
showers_ = std::stoi(value);
} else if (option.find("height_atmosphere") != std::string::npos) {
heightAtmosphere_ = std::stod(value) * 1._km;
} else if (option.find("height_observator") != std::string::npos) {
heightObservator_ = std::stod(value) * 1._km;
} else if (option.find("zenith_angle") != std::string::npos) {
zenithAngle_ = std::stod(value);
} else if (option.find("azimutal_angle") != std::string::npos) {
azimutalAngle_ = std::stod(value);
} else if (option.find("E0") != std::string::npos) {
energy_ = std::stod(value) * 1._GeV;
} else if (option.find("seed") != std::string::npos) {
seed_ = std::stoi(value);
} else if (option.find("energy_cut") != std::string::npos) {
int counter = 0;
std::string word = "";
for (auto letter : value) {
if (letter == ',' || letter == ';') {
energyCut_[counter] = std::stod(value) * 1._GeV;
counter++;
word = "";
continue;
}
word += letter;
}
boost::algorithm::erase_all(word, " ");
boost::algorithm::erase_all(word, "\t");
istringstream(word) >> std::boolalpha >> energyCutInvisible_;
} else if (option.find("atmosphere_tab") != std::string::npos) {
atmosphereTabulatedNumber_ = std::stoi(value);
} else if (option.find("magnetic_field") != std::string::npos) {
int counter = 0;
std::string word = "";
for (auto letter : value) {
if (letter == ',') {
magneticField_[counter] = std::stod(word);
counter++;
word = "";
continue;
}
word += letter;
}
magneticField_[counter] = std::stod(word);
} else if (option.find("world_sphere") != std::string::npos) {
int counter = 0;
std::string word = "";
for (auto letter : value) {
if (letter == ',' || letter == ';') {
worldSphere_[counter] = std::stod(word) * 1._m;
counter++;
word = "";
continue;
}
word += letter;
}
worldSphere_[counter] = std::stod(word) * 1._km;
} else if (option.find("obs_level") != std::string::npos) {
int counter = 0;
std::string word = "";
for (auto letter : value) {
if (letter == ',' || letter == ';') {
obsLevel_[counter] = std::stod(word);
counter++;
word = "";
continue;
}
word += letter;
}
obsLevel_[counter] = std::stod(word);
} else if (option.find("obs_plane") != std::string::npos) {
int counter = 0;
std::string word = "";
for (auto letter : value) {
if (letter == ',' || letter == ';') {
obsPlane_[counter] = std::stod(word);
counter++;
word = "";
continue;
}
word += letter;
}
obsPlane_[counter] = std::stod(word);
} else if (option.find("shower_axis") != std::string::npos) {
int counter = 0;
bool first = true;
std::string word = "";
for (auto letter : value) {
if (letter == ',') {
showerAxisDirVec_[counter] = std::stod(word) * 1._m;
counter++;
word = "";
continue;
} else if (letter == ';') {
if (first) {
showerAxisDirVec_[counter] = std::stod(word) * 1._m;
word = "";
first = false;
continue;
} else {
showerAxisInterpolStep_ = std::stoi(word);
word = "";
continue;
}
}
word += letter;
}
showerAxisCoeff_ = std::stod(word);
} else if (option.find("tel_conf") != std::string::npos) {
telConfig_ = std::string(value);
boost::algorithm::erase_all(telConfig_, "\t");
boost::algorithm::erase_all(telConfig_, " ");
}
}
inputFile.close();
}
}
void showAllParameters() {
CORSIKA_LOG_DEBUG("showers_:{}", showers_);
CORSIKA_LOG_DEBUG("heightAtmosphere_:{}", heightAtmosphere_);
CORSIKA_LOG_DEBUG("heightObservator_:{}", heightObservator_);
CORSIKA_LOG_DEBUG("zenithAngle_:{}", zenithAngle_);
CORSIKA_LOG_DEBUG("azimutalAngle_:{}", azimutalAngle_);
CORSIKA_LOG_DEBUG("energy_:{}", energy_);
CORSIKA_LOG_DEBUG("seed_:{}", seed_);
CORSIKA_LOG_DEBUG("energyCut_:{},{},{},{},{}", energyCut_[0], energyCut_[1],
energyCut_[2], energyCut_[3], energyCutInvisible_);
CORSIKA_LOG_DEBUG("atmosphereTabulatedNumber_:{}", atmosphereTabulatedNumber_);
CORSIKA_LOG_DEBUG("magneticField_:{},{},{}", magneticField_[0], magneticField_[1],
magneticField_[2]);
CORSIKA_LOG_DEBUG("worldSphere_:{},{},{}", worldSphere_[0], worldSphere_[1],
worldSphere_[2]);
CORSIKA_LOG_DEBUG("obsPlane_:{},{},{}", obsPlane_[0], obsPlane_[1], obsPlane_[2]);
CORSIKA_LOG_DEBUG("obsLevel_:{},{},{}", obsLevel_[0], obsLevel_[1], obsLevel_[2]);
CORSIKA_LOG_DEBUG("showerAxisDirVec_:{},{},{}", showerAxisDirVec_[0],
showerAxisDirVec_[1], showerAxisDirVec_[2]);
CORSIKA_LOG_DEBUG("showerAxisInterpolStep_:{}", showerAxisInterpolStep_);
CORSIKA_LOG_DEBUG("showerAxisCoeff_:{}", showerAxisCoeff_);
CORSIKA_LOG_DEBUG("telConfig_:{}", telConfig_);
}
int showers_ = 1;
LengthType heightAtmosphere_ = 112.8_km;
LengthType heightObservator_ = 2.15_km;
double zenithAngle_ = 20.;
double azimutalAngle_ = 180.;
HEPEnergyType energy_ = 100._GeV;
int seed_ = 0;
std::array<HEPEnergyType, 4> energyCut_ = {60._GeV, 60._GeV, 100._GeV, 100._GeV};
bool energyCutInvisible_ = true;
int atmosphereTabulatedNumber_ = 26;
std::array<double, 3> magneticField_ = {0., 50., 0.};
std::array<LengthType, 3> worldSphere_= {0._m, 0._m, 0._m};
std::array<LengthType, 3> showerAxisDirVec_ = {0._m, 0._m, 0._m};
std::array<double, 3> obsPlane_ = {0., 0., 1.};
std::array<double, 3> obsLevel_ = {1., 0., 0.};
int showerAxisInterpolStep_ = 10000;
double showerAxisCoeff_ = 1.5;
std::string telConfig_ = "position_99";
};
}
This diff is collapsed.
This diff is collapsed.
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#include <inputCard.hpp>
#include <corsika/framework/core/Logging.hpp>
#include <iostream>
/*
NOTE, WARNING, ATTENTION
The .../Random.hpppp implement the hooks of external modules to the C8 random
number generator. It has to occur excatly ONCE per linked
executable. If you include the header below multiple times and
link this togehter, it will fail.
*/
using namespace corsika;
using namespace std;
using namespace experimentC7;
// main function to generate Cherenkov photons with em showers
int main(int argc, char** argv) {
corsika_logger->set_pattern("[%n:%^%-8l%$] %s:%#: %v");
logging::set_level(logging::level::debug);
CORSIKA_LOG_INFO("input_card");
std::string inputExperimentDir = "";
if (argc > 1) { inputExperimentDir = std::string(argv[1]); }
ExperimentC7 myExperiment{inputExperimentDir};
myExperiment.showAllParameters();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment