#ifndef DFitGroup_h #define DFitGroup_h #include #include #include #include "DFitFunctor.h" using namespace std; //DFitGroup: one for all signal, one for all background class DFitGroup : public DFitFunctor { //This class owns all of the input fit functors (when delete is called, it deletes them) public: DFitGroup(string locGroupName, vector locInitParams, vector locFitFunctors, int locFuncColor = 0); DFitGroup(string locGroupName, TF1* locTotalFunc, unsigned int locParamIndex, vector locFitFunctors, int locFuncColor = 0); virtual ~DFitGroup(void); virtual double operator()(double* locX, double* locParamArray); //Fit Functors void Append_FitFunctor(DFitFunctor* locFitFunctor); void Replace_FitFunctor(DFitFunctor* locFitFunctor, size_t locFuncIndex = 0); //will delete the old one! void Insert_FitFunctor(DFitFunctor* locFitFunctor, size_t locFuncIndex = 0); void Remove_FitFunctor(size_t locFuncIndex = 0); //will delete the old one! void Set_CovarianceMatrix(const TMatrixDSym& locFullCovarianceMatrix, unsigned int locParamIndex); void Create_Function(string locFuncBaseName, double locFitRangeMin, double locFitRangeMax, double* locParamArray, double* locParamErrorArray); using DFitFunctor::Create_Function; template void Remove_FitFunctions(DType* locFitObject) const; template void Add_FitFunctions(DType* locFitObject) const; void Prepare_Refit(void); virtual void Calc_Integral(double& locIntegral, double& locIntegralError) const; virtual void Calc_Integral(double locRangeMin, double locRangeMax, double& locIntegral, double& locIntegralError) const; vector dFitFunctors; bool dAddGroupFuncFlag; vector > dExcludeDataRanges; //exclude data points within ranges from fit private: DFitGroup(void) : DFitFunctor("", vector(), false){} ClassDef(DFitGroup, 1) }; template void DFitGroup::Remove_FitFunctions(DType* locFitObject) const { //WILL NOT delete the functions! Just removes them from the fit object if(dAddGroupFuncFlag) { locFitObject->GetListOfFunctions()->Remove(dFunc); return; } for(size_t loc_i = 0; loc_i < dFitFunctors.size(); ++loc_i) { if(dFitFunctors[loc_i]->dAddFitToFitObjectFlag) locFitObject->GetListOfFunctions()->Remove(dFitFunctors[loc_i]->dFunc); } } template void DFitGroup::Add_FitFunctions(DType* locFitObject) const { if(dAddGroupFuncFlag) { locFitObject->GetListOfFunctions()->Add(dFunc); return; } for(size_t loc_i = 0; loc_i < dFitFunctors.size(); ++loc_i) { if(dFitFunctors[loc_i]->dAddFitToFitObjectFlag) locFitObject->GetListOfFunctions()->Add(dFitFunctors[loc_i]->dFunc); } } inline void DFitGroup::Replace_FitFunctor(DFitFunctor* locFitFunctor, size_t locFuncIndex) { Remove_FitFunctor(locFuncIndex); Insert_FitFunctor(locFitFunctor, locFuncIndex); } #endif