diff --git a/samplePDF/FDMCStruct.h b/samplePDF/FDMCStruct.h index 28d7e760c..285a1916b 100644 --- a/samplePDF/FDMCStruct.h +++ b/samplePDF/FDMCStruct.h @@ -7,7 +7,8 @@ struct fdmc_base { int nupdg; int nupdgUnosc; bool signal; // true if signue - int nEvents; // how many MC events are there + int nEvents; // how many MC events are there + double ChannelIndex; std::string flavourName; int **Target; // target the interaction was on @@ -52,7 +53,7 @@ struct fdmc_base { double *rw_upper_xbinedge; // upper to check if Eb has moved the erec bin double *rw_upper_upper_xbinedge; // upper to check if Eb has moved the erec bin - int **mode; + double **mode; const _float_ **osc_w_pointer; double *xsec_w; diff --git a/samplePDF/samplePDFFDBase.cpp b/samplePDF/samplePDFFDBase.cpp index 03cdfe907..0548ad332 100644 --- a/samplePDF/samplePDFFDBase.cpp +++ b/samplePDF/samplePDFFDBase.cpp @@ -1537,7 +1537,7 @@ void samplePDFFDBase::InitialiseSingleFDMCObject(int iSample, int nEvents_) { fdobj->rw_lower_lower_xbinedge = new double [fdobj->nEvents]; fdobj->rw_upper_xbinedge = new double [fdobj->nEvents]; fdobj->rw_upper_upper_xbinedge = new double [fdobj->nEvents]; - fdobj->mode = new int*[fdobj->nEvents]; + fdobj->mode = new double*[fdobj->nEvents]; fdobj->nxsec_norm_pointers = new int[fdobj->nEvents]; fdobj->xsec_norm_pointers = new const double**[fdobj->nEvents]; fdobj->xsec_norms_bins = new std::list< int >[fdobj->nEvents]; @@ -1554,7 +1554,7 @@ void samplePDFFDBase::InitialiseSingleFDMCObject(int iSample, int nEvents_) { for(int iEvent = 0 ;iEvent < fdobj->nEvents ; ++iEvent){ fdobj->rw_etru[iEvent] = &fdobj->Unity; //fdobj->rw_truecz[iEvent] = &fdobj->Unity; - fdobj->mode[iEvent] = &fdobj->Unity_Int; + fdobj->mode[iEvent] = &fdobj->Unity; fdobj->Target[iEvent] = 0; fdobj->NomXBin[iEvent] = -1; fdobj->NomYBin[iEvent] = -1; @@ -1604,3 +1604,62 @@ void samplePDFFDBase::InitialiseSplineObject() { fillSplineBins(); } + +TH1* samplePDFFDBase::get1DVarHist(std::string ProjectionVar_Str, std::vector< std::vector > SelectionVec, int WeightStyle, TAxis* Axis) { + //DB Grab the associated enum with the argument string + int ProjectionVar_Int = ReturnKinematicParameterFromString(ProjectionVar_Str); + + //DB Need to overwrite the Selection member variable so that IsEventSelected function operates correctly. + // Consequently, store the selection cuts already saved in the sample, overwrite the Selection variable, then reset + std::vector< std::vector > tmp_Selection = Selection; + + std::vector< std::vector > SelectionVecToApply; + + //DB Add all the predefined selections to the selection vector which will be applied + for (int iSelec=0;iSelecGetNbins(),Axis->GetXbins()->GetArray()); + } else { + std::vector xBinEdges = ReturnKinematicParameterBinning(ProjectionVar_Str); + double xbin_edges[xBinEdges.size()]; + for (unsigned int i=0;iFill(Var,Weight); + } + } + } + + //DB Reset the saved selection + Selection = tmp_Selection; + + return _h1DVar; +} diff --git a/samplePDF/samplePDFFDBase.h b/samplePDF/samplePDFFDBase.h index 0b48d9d52..1daae01e1 100644 --- a/samplePDF/samplePDFFDBase.h +++ b/samplePDF/samplePDFFDBase.h @@ -60,6 +60,30 @@ class samplePDFFDBase : public samplePDFBase virtual void setupSplines(fdmc_base *FDObj, const char *SplineFileName, int nutype, int signal){}; void ReadSampleConfig(); + int getNMCSamples() {return MCSamples.size();} + + int getNEventsInSample(int iSample) { + if (iSample < 0 || iSample > getNMCSamples()) { + MACH3LOG_ERROR("Invalid Sample Requested: {}",iSample); + throw MaCh3Exception(__FILE__ , __LINE__); + } + return MCSamples[iSample].nEvents; + } + + std::string getFlavourName(int iSample) { + if (iSample < 0 || iSample > getNMCSamples()) { + MACH3LOG_ERROR("Invalid Sample Requested: {}",iSample); + throw MaCh3Exception(__FILE__ , __LINE__); + } + return MCSamples[iSample].flavourName; + } + + TH1* get1DVarHist(std::string ProjectionVar, std::vector< std::vector > SelectionVec = std::vector< std::vector >(), int WeightStyle=0, TAxis* Axis=nullptr); + + //ETA - new function to generically convert a string from xsec cov to a kinematic type + virtual inline int ReturnKinematicParameterFromString(std::string KinematicStr) = 0; + virtual inline std::string ReturnStringFromKinematicParameter(int KinematicVariable) = 0; + protected: /// @brief DB Function to determine which weights apply to which types of samples pure virtual!! virtual void SetupWeightPointers() = 0; @@ -128,10 +152,6 @@ class samplePDFFDBase : public samplePDFBase virtual const double* GetPointerToKinematicParameter(std::string KinematicParamter, int iSample, int iEvent) = 0; virtual const double* GetPointerToKinematicParameter(double KinematicVariable, int iSample, int iEvent) = 0; - //ETA - new function to generically convert a string from xsec cov to a kinematic type - virtual inline int ReturnKinematicParameterFromString(std::string KinematicStr) = 0; - virtual inline std::string ReturnStringFromKinematicParameter(int KinematicVariable) = 0; - // Function to setup Functional and shift parameters. This isn't idea but // do this in your experiment specific code for now as we don't have a // generic treatment for func and shift pars yet