8#include "manager/manager.h"
21 if (CheckNodeExists(SampleManager->raw(),
"DUNESampleBools",
"iselike" )) {
22 iselike = SampleManager->raw()[
"DUNESampleBools"][
"iselike"].as<
bool>();
24 MACH3LOG_ERROR(
"Did not find DUNESampleBools:iselike in {}, please add this", SampleManager->GetFileName());
25 throw MaCh3Exception(__FILE__, __LINE__);
28 if (CheckNodeExists(SampleManager->raw(),
"DUNESampleBools",
"isfhc" )) {
29 _isFHC = SampleManager->raw()[
"DUNESampleBools"][
"isfhc"].as<
int>();
31 MACH3LOG_ERROR(
"Did not find DUNESampleBools:isfhc in {}, please add this", SampleManager->GetFileName());
32 throw MaCh3Exception(__FILE__, __LINE__);
35 if (CheckNodeExists(SampleManager->raw(),
"POT")) {
36 pot = SampleManager->raw()[
"POT"].as<
double>();
38 MACH3LOG_ERROR(
"POT not defined in {}, please add this!", SampleManager->GetFileName());
39 throw MaCh3Exception(__FILE__, __LINE__);
169 MACH3LOG_INFO(
"-------------------------------------------------------------------");
175 if(XsecCov->GetNumParamsFromDetID(SampleDetID, kSpline) > 0){
176 MACH3LOG_INFO(
"Found {} splines for this sample so I will create a spline object", XsecCov->GetNumParamsFromDetID(SampleDetID, kSpline));
177 SplineHandler = std::unique_ptr<splineFDBase>(
new splinesDUNE(XsecCov));
178 InitialiseSplineObject();
181 MACH3LOG_INFO(
"Found {} splines for this sample so I will not load or evaluate splines", XsecCov->GetNumParamsFromDetID(SampleDetID, kSpline));
182 SplineHandler =
nullptr;
191 MCSamples[i].ntotal_weight_pointers[j] = 6;
192 MCSamples[i].total_weight_pointers[j].resize(MCSamples[i].ntotal_weight_pointers[j]);
193 MCSamples[i].total_weight_pointers[j][0] = &(
dunemcSamples[i].pot_s);
194 MCSamples[i].total_weight_pointers[j][1] = &(
dunemcSamples[i].norm_s);
195 MCSamples[i].total_weight_pointers[j][2] = MCSamples[i].osc_w_pointer[j];
196 MCSamples[i].total_weight_pointers[j][3] = &(
dunemcSamples[i].rw_berpaacvwgt[j]);
197 MCSamples[i].total_weight_pointers[j][4] = &(
dunemcSamples[i].flux_w[j]);
198 MCSamples[i].total_weight_pointers[j][5] = &(MCSamples[i].xsec_w[j]);
207 int nupdgUnosc = sample_nupdgunosc[iSample];
208 int nupdg = sample_nupdg[iSample];
210 MACH3LOG_INFO(
"-------------------------------------------------------------------");
211 MACH3LOG_INFO(
"input file: {}", mc_files[iSample]);
213 _sampleFile = TFile::Open(mc_files[iSample].c_str(),
"READ");
217 MACH3LOG_INFO(
"Found \"caf\" tree in {}", mc_files[iSample]);
218 MACH3LOG_INFO(
"With number of entries: {}",
_data->GetEntries());
221 MACH3LOG_ERROR(
"Could not find \"caf\" tree in {}", mc_files[iSample]);
222 throw MaCh3Exception(__FILE__, __LINE__);
225 _data->SetBranchStatus(
"*", 0);
226 _data->SetBranchStatus(
"Ev", 1);
227 _data->SetBranchAddress(
"Ev", &
_ev);
228 _data->SetBranchStatus(
"Ev_reco_numu", 1);
229 _data->SetBranchAddress(
"Ev_reco_numu", &
_erec);
230 _data->SetBranchStatus(
"Ev_reco_nue", 1);
232 _data->SetBranchStatus(
"RecoHadEnNumu", 1);
234 _data->SetBranchStatus(
"RecoHadEnNue", 1);
236 _data->SetBranchStatus(
"RecoLepEnNumu", 1);
238 _data->SetBranchStatus(
"RecoLepEnNue", 1);
241 _data->SetBranchStatus(
"eRecoP", 1);
243 _data->SetBranchStatus(
"eRecoPip", 1);
245 _data->SetBranchStatus(
"eRecoPim", 1);
247 _data->SetBranchStatus(
"eRecoPi0", 1);
249 _data->SetBranchStatus(
"eRecoN", 1);
252 _data->SetBranchStatus(
"LepE", 1);
254 _data->SetBranchStatus(
"eP", 1);
255 _data->SetBranchAddress(
"eP", &
_eP);
256 _data->SetBranchStatus(
"ePip", 1);
258 _data->SetBranchStatus(
"ePim", 1);
260 _data->SetBranchStatus(
"ePi0", 1);
262 _data->SetBranchStatus(
"eN", 1);
263 _data->SetBranchAddress(
"eN", &
_eN);
265 _data->SetBranchStatus(
"mode",1);
267 _data->SetBranchStatus(
"cvnnumu",1);
269 _data->SetBranchStatus(
"cvnnue",1);
271 _data->SetBranchStatus(
"isCC", 1);
273 _data->SetBranchStatus(
"nuPDGunosc", 1);
275 _data->SetBranchStatus(
"nuPDG", 1);
277 _data->SetBranchStatus(
"BeRPA_A_cvwgt", 1);
279 _data->SetBranchStatus(
"vtx_x", 1);
281 _data->SetBranchStatus(
"vtx_y", 1);
283 _data->SetBranchStatus(
"vtx_z", 1);
288 MACH3LOG_ERROR(
"Add a norm KEY to the root file using MakeNormHists.cxx");
289 throw MaCh3Exception(__FILE__, __LINE__);
293 duneobj->
norm_s = norm->GetBinContent(1);
294 duneobj->
pot_s =
pot/norm->GetBinContent(2);
340 for (
int i = 0; i < duneobj->
nEvents; ++i) {
343 duneobj->
nupdg[i] = sample_nupdg[iSample];
344 duneobj->
nupdgUnosc[i] = sample_nupdgunosc[iSample];
388 int mode= TMath::Abs(
_mode);
402 if (kChannelToFill!=-1) {
404 MACH3LOG_ERROR(
"Required channel is not available. kChannelToFill should be between 0 and {}",
dunemcSamples.size());
405 MACH3LOG_ERROR(
"kChannelToFill given: {}",kChannelToFill);
406 throw MaCh3Exception(__FILE__, __LINE__);
413 if (kModeToFill!=-1) {
415 MACH3LOG_ERROR(
"Required mode is not available. kModeToFill should be between 0 and {}",
kMaCh3_nModes);
416 MACH3LOG_ERROR(
"kModeToFill given: {}",kModeToFill);
417 throw MaCh3Exception(__FILE__, __LINE__);
424 std::vector< std::vector<double> > SelectionVec;
427 std::vector<double> SelecMode(3);
429 SelecMode[1] = kModeToFill;
430 SelecMode[2] = kModeToFill+1;
431 SelectionVec.push_back(SelecMode);
435 std::vector<double> SelecChannel(3);
437 SelecChannel[1] = kChannelToFill;
438 SelecChannel[2] = kChannelToFill+1;
439 SelectionVec.push_back(SelecChannel);
442 return get1DVarHist(Var1,SelectionVec,WeightStyle,Axis);
451 Selection = SelectionVec;
453 for (
unsigned int iStoredSelection=0;iStoredSelection<StoredSelection.size();iStoredSelection++) {
454 Selection.push_back(StoredSelection[iStoredSelection]);
457 for (
unsigned int iSelection=0;iSelection<Selection.size();iSelection++) {
458 if (Selection[iSelection].size()!=3) {
459 MACH3LOG_ERROR(
"Selection Vector[{}] is not formed correctly. Expect size == 3, given: {}",iSelection,Selection[iSelection].size());
460 throw MaCh3Exception(__FILE__, __LINE__);
465 bool fChannel =
false;
466 int kChannelToFill = -1;
467 for (
unsigned int iSelection=0;iSelection<Selection.size();iSelection++) {
470 kChannelToFill = Selection[iSelection][1];
475 MACH3LOG_ERROR(
"Required channel is not available. kChannelToFill should be between 0 and {}",
dunemcSamples.size());
476 MACH3LOG_ERROR(
"kChannelToFill given: {}",kChannelToFill);
477 throw MaCh3Exception(__FILE__, __LINE__);
482 _h1DVar =
new TH1D(
"",
"", xBinEdges.size()-1, xBinEdges.data());
487 if (fChannel && (i!=kChannelToFill)) {
493 if (!IsEventSelected(i,j)) {
497 double Weight = GetEventWeight(i,j);
498 if (WeightStyle==1) {
503 if (MCSamples[i].xsec_w[j] == 0.)
continue;
508 if (Var1_Val!=_DEFAULT_RETURN_VAL_) {
509 _h1DVar->Fill(Var1_Val,Weight);
535 double KinematicValue = -999;
542 KinematicValue =
dunemcSamples[iSample].rw_erec_shifted[iEvent];
554 KinematicValue =
dunemcSamples[iSample].rw_cvnnumu_shifted[iEvent];
557 KinematicValue =
dunemcSamples[iSample].rw_cvnnue_shifted[iEvent];
566 MACH3LOG_ERROR(
"Did not recognise Kinematic Parameter type");
567 MACH3LOG_ERROR(
"Was given a Kinematic Variable of {}", KinematicVariable);
568 throw MaCh3Exception(__FILE__, __LINE__);
571 return KinematicValue;
576 double KinematicValue = -999;
583 KinematicValue =
dunemcSamples[iSample].rw_erec_shifted[iEvent];
595 KinematicValue =
dunemcSamples[iSample].rw_cvnnumu_shifted[iEvent];
598 KinematicValue =
dunemcSamples[iSample].rw_cvnnue_shifted[iEvent];
604 MACH3LOG_ERROR(
"Did not recognise Kinematic Parameter type... {}", KinematicParameter);
605 throw MaCh3Exception(__FILE__, __LINE__);
608 return KinematicValue;
614 double* KinematicValue =
nullptr;
621 KinematicValue = &
dunemcSamples[iSample].rw_erec_shifted[iEvent];
633 KinematicValue = &
dunemcSamples[iSample].rw_cvnnumu_shifted[iEvent];
636 KinematicValue = &
dunemcSamples[iSample].rw_cvnnue_shifted[iEvent];
639 MACH3LOG_ERROR(
"Did not recognise Kinematic Parameter type...");
640 throw MaCh3Exception(__FILE__, __LINE__);
643 return KinematicValue;
647 if (KinematicParameterStr.find(
"TrueNeutrinoEnergy") != std::string::npos) {
return kTrueNeutrinoEnergy;}
648 if (KinematicParameterStr.find(
"RecoNeutrinoEnergy") != std::string::npos) {
return kRecoNeutrinoEnergy;}
649 if (KinematicParameterStr.find(
"TrueXPos") != std::string::npos) {
return kTrueXPos;}
650 if (KinematicParameterStr.find(
"TrueYPos") != std::string::npos) {
return kTrueYPos;}
651 if (KinematicParameterStr.find(
"TrueZPos") != std::string::npos) {
return kTrueZPos;}
652 if (KinematicParameterStr.find(
"CVNNumu") != std::string::npos) {
return kCVNNumu;}
653 if (KinematicParameterStr.find(
"CVNNue") != std::string::npos) {
return kCVNNue;}
654 if (KinematicParameterStr.find(
"M3Mode") != std::string::npos) {
return kM3Mode;}
655 if (KinematicParameterStr.find(
"IsFHC") != std::string::npos) {
return kIsFHC;}
660 double* KinematicValue =
nullptr;
667 KinematicValue = &
dunemcSamples[iSample].rw_erec_shifted[iEvent];
679 KinematicValue = &
dunemcSamples[iSample].rw_cvnnumu_shifted[iEvent];
682 KinematicValue = &
dunemcSamples[iSample].rw_cvnnue_shifted[iEvent];
685 MACH3LOG_ERROR(
"Did not recognise Kinematic Parameter type...");
686 throw MaCh3Exception(__FILE__, __LINE__);
689 return KinematicValue;
693 std::string KinematicString =
"";
695 switch(KinematicParameter){
697 KinematicString =
"RecoNeutrinoEnergy";
700 KinematicString =
"RecoNeutrinoEnergy";
703 KinematicString=
"TrueXPos";
706 KinematicString=
"TrueYPos";
709 KinematicString=
"TrueZPos";
712 KinematicString =
"CVNNumu";
715 KinematicString =
"CVNNue";
718 KinematicString =
"M3Mode";
724 return KinematicString;
729 FarDetectorCoreInfo *fdobj = &(MCSamples[iSample]);
731 for(
int iEvent = 0 ;iEvent < fdobj->nEvents ; ++iEvent) {
732 fdobj->rw_etru[iEvent] = &(duneobj->
rw_etru[iEvent]);
733 fdobj->mode[iEvent] = &(duneobj->
mode[iEvent]);
734 fdobj->Target[iEvent] = &(duneobj->
Target[iEvent]);
735 fdobj->isNC[iEvent] = !(duneobj->
rw_isCC[iEvent]);
736 fdobj->nupdg[iEvent] = &(duneobj->
nupdg[iEvent]);
737 fdobj->nupdgUnosc[iEvent] = &(duneobj->
nupdgUnosc[iEvent]);
823 std::vector<double> binningVector;
827 double bin_width = 0;
828 switch(KinematicParameter){
843 for(
int bin_i = 0 ; bin_i < nBins ; bin_i++){
844 binningVector.push_back(bin_i*bin_width);
847 return binningVector;
int SIMBMode_ToMaCh3Mode(int SIMB_mode, int isCC)
double tot_escale_invsqrt_fd_pos
double n_escale_sqrt_fd_pos
void SetupSplines()
Setup our spline file, this calls InitialseSplineObject() under the hood.
void applyShifts(int iSample, int iEvent)
Apply kinematic shifts.
double n_escale_invsqrt_fd_pos
double tot_escale_sqrt_fd_pos
TFile * _sampleFile
File containing sample objects.
samplePDFDUNEBeamFD(std::string mc_version, covarianceXsec *xsec_cov, covarianceOsc *osc_cov)
samplePDFDUNE FD beam Constructor
double had_escale_invsqrt_fd_pos
std::vector< struct dunemc_base > dunemcSamples
DUNE MC sampels.
std::string ReturnStringFromKinematicParameter(int KinematicParameterStr)
TTree * _data
TTree containing sample Data.
TH1D * get1DVarHist(KinematicTypes Var1, int fModeToFill=-1, int fSampleToFill=-1, int WeightStyle=0, TAxis *Axis=0)
Getter to make plots in different variables, mode, osc channel, systematic weighting and with bin ran...
double mu_escale_sqrt_fd_pos
const double * GetPointerToKinematicParameter(std::string KinematicParameter, int iSample, int iEvent)
Returns pointer to kinemtatic parameter for event in Structs DUNE.
int ReturnKinematicParameterFromString(std::string KinematicParameterStr)
double mu_escale_invsqrt_fd_pos
void SetupWeightPointers()
Sets up pointers weights for each event (oscillation/xsec/etc.)
double pot
Value of POT used for sample.
int setupExperimentMC(int iSample)
Function to setup MC from file.
double em_escale_sqrt_fd_pos
double had_escale_sqrt_fd_pos
void setupFDMC(int iSample)
Tells FD base which variables to point to/be set to.
~samplePDFDUNEBeamFD()
destructor
double ReturnKinematicParameter(double KinematicVariable, int iSample, int iEvent)
Returns pointer to kinemtatic parameter for event in Structs DUNE.
void Init()
Initialises object.
double em_escale_invsqrt_fd_pos
std::vector< double > ReturnKinematicParameterBinning(std::string KinematicParameter)
Specialisation of FD (binned) spline class.
double * rw_cvnnue_shifted
double * rw_cvnnumu_shifted