Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding REST_Axion_RayTracingNgamma.C macro #67

Merged
merged 5 commits into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions macros/REST_Axion_RayTracingNgamma.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "TRestDataSet.h"
#include "TRestTask.h"

#ifndef RestTask_RayTracingNgamma
#define RestTask_RayTracingNgamma

const std::string BabyIAXOWeights =
"axionPhoton_probability,axionPhoton_transmission,boreExitGate_transmission,optics_efficiency,window_"
"transmission";
const std::string BabyIAXOFlux = "SolarFlux*GeneratorArea*(1000*MassInterval)/Nsim";

//*******************************************************************************************************
//*** Description: This macro will add three new columns (Probability/Flux/Ngamma) to the dataset given
//*** in the argument. The probability will be the result of the products of the weights given by argument,
//*** the Flux will be a normalizing factor related to the solar flux and the number of simulated MC events,
//*** and Ngamma will be the result of multiplying the Flux by Probability.
//***
//*** The weights must be existing columns in the given dataset
//*** The normalization factor is a formula that may contain relevant quantites and existint dataset
//*** columns.
//***
//*** --------------
//*** Usage: restManager RayTracingNGamma dataset.root [outputPath] [weight1,weight2] [normalizationFactor]
//***
//*******************************************************************************************************
Int_t REST_Axion_RayTracingNGamma(const std::string& fname, const std::string& outputPath = "",
const std::string& weights = BabyIAXOWeights,
const std::string& mcFlux = BabyIAXOFlux) {
std::vector<std::string> ws = REST_StringHelper::Split(weights, ",");

TRestDataSet d;
d.Import(fname);

std::string probability = "";
int cont = 0;
for (const auto& w : ws) {
if (cont > 0) probability += "*";
probability += w;
cont++;
}
// std::cout << "Probability: " << probability << std::endl;

d.Define("Probability", probability);
d.Define("Flux", mcFlux); // Per axion mass and second
d.Define("Ngamma", "Probability*Flux"); // (units: eV x s-1) Must be normalized by (and integrated to) a
// given axion mass interval
// --> TRestComponent

d.GetDataFrame().Display({"Probability", "Flux", "Ngamma"})->Print();

std::string tag = fname;
size_t pos1 = tag.find("_");
size_t pos2 = tag.find_last_of(".");
tag = tag.substr(pos1 + 1, pos2 - pos1 - 1);

std::cout << "Writting to file: "
<< "DataSet_RayTracing_Ngamma_" << tag << ".root" << std::endl;
if (!outputPath.empty()) std::cout << "Output path: " << outputPath << std::endl;

d.Export(outputPath + "DataSet_RayTracing_Ngamma_" + tag + ".root");

return 0;
}
#endif