@@ -111,8 +111,8 @@ void runMassFitter(const std::string& configFileName)
111111 std ::vector < double > fixSecondSigmaManual ;
112112 std ::vector < double > fixFracDoubleGausManual ;
113113 std ::vector < int > nRebin ;
114- std ::vector < int > bkgFuncConfig ;
115- std ::vector < int > sgnFuncConfig ;
114+ std ::vector < int > bkgFunc ;
115+ std ::vector < int > sgnFunc ;
116116
117117 readJsonVector (inputHistoName , config , "InputHistoName" , true);
118118 readJsonVector (promptHistoName , config , "PromptHistoName" );
@@ -151,35 +151,57 @@ void runMassFitter(const std::string& configFileName)
151151 bool const includeSecPeak = readJsonField < bool > (config , "InclSecPeak" , false);
152152 bool const useLikelihood = readJsonField < bool > (config , "UseLikelihood" );
153153
154- readJsonVector (bkgFuncConfig , config , "BkgFunc" , true);
155- readJsonVector (sgnFuncConfig , config , "SgnFunc" , true);
154+ readJsonVector (bkgFunc , config , "BkgFunc" , true);
155+ readJsonVector (sgnFunc , config , "SgnFunc" , true);
156156
157157 const bool enableRefl = readJsonField < bool > (config , "EnableRefl" , false);
158158 const bool drawBgPrefit = readJsonField < bool > (config , "drawBgPrefit" , true);
159159 const bool highlightPeakRegion = readJsonField < bool > (config , "highlightPeakRegion" , true);
160160
161161 const int nSliceVarBins = static_cast < int > (sliceVarMin .size ());
162- std ::vector < int > bkgFunc (nSliceVarBins );
163- std ::vector < int > sgnFunc (nSliceVarBins );
164162 std ::vector < double > sliceVarLimits (nSliceVarBins + 1 );
165163
164+ auto checkVectorSize = [& ](const auto& vec , const std ::string & name = "" , const bool isEmptyOk = false) {
165+ if (vec .size () != static_cast < size_t > (nSliceVarBins )) {
166+ if (isEmptyOk && vec .empty ()) {
167+ return ;
168+ }
169+ throw std ::runtime_error ("ERROR: inconsistent vector size for " + name + "! Exit" );
170+ }
171+ };
172+
173+ checkVectorSize (inputHistoName , "inputHistoName" , true);
174+ checkVectorSize (promptHistoName , "promptHistoName" , true);
175+ checkVectorSize (fdHistoName , "fdHistoName" , true);
176+ checkVectorSize (reflHistoName , "reflHistoName" , true);
177+ checkVectorSize (promptSecPeakHistoName , "promptSecPeakHistoName" , true);
178+ checkVectorSize (fdSecPeakHistoName , "fdSecPeakHistoName" , true);
179+ checkVectorSize (sliceVarMin , "sliceVarMin" );
180+ checkVectorSize (sliceVarMax , "sliceVarMax" );
181+ checkVectorSize (massMin , "massMin" );
182+ checkVectorSize (massMax , "massMax" );
183+ checkVectorSize (fixMeanManual , "fixMeanManual" , true);
184+ checkVectorSize (fixSigmaManual , "fixSigmaManual" , true);
185+ checkVectorSize (fixSecondSigmaManual , "fixSecondSigmaManual" , true);
186+ checkVectorSize (fixFracDoubleGausManual , "fixFracDoubleGausManual" , true);
187+ checkVectorSize (nRebin , "nRebin" );
188+ checkVectorSize (bkgFunc , "bkgFunc" );
189+ checkVectorSize (sgnFunc , "sgnFunc" );
190+
166191 for (int iSliceVar = 0 ; iSliceVar < nSliceVarBins ; iSliceVar ++ ) {
167192 sliceVarLimits [iSliceVar ] = sliceVarMin [iSliceVar ];
168- sliceVarLimits [iSliceVar + 1 ] = sliceVarMax [iSliceVar ];
169193
170- if (bkgFuncConfig [iSliceVar ] < 0 || bkgFuncConfig [iSliceVar ] >= HFInvMassFitter ::NTypesOfBkgPdf ) {
194+ if (bkgFunc [iSliceVar ] < 0 || bkgFunc [iSliceVar ] >= HFInvMassFitter ::NTypesOfBkgPdf ) {
171195 throw std ::runtime_error ("ERROR: only Expo, Poly1, Poly2, Pow and PowEx background functions supported! Exit" );
172196 }
173- bkgFunc [iSliceVar ] = bkgFuncConfig [iSliceVar ];
174197 if (isMc && bkgFunc [iSliceVar ] != HFInvMassFitter ::NoBkg ) {
175198 throw std ::runtime_error ("ERROR: in MC mode the background function must be NoBkg! Exit" );
176199 }
177-
178- if (sgnFuncConfig [iSliceVar ] < 0 || sgnFuncConfig [iSliceVar ] >= HFInvMassFitter ::NTypesOfSgnPdf ) {
200+ if (sgnFunc [iSliceVar ] < 0 || sgnFunc [iSliceVar ] >= HFInvMassFitter ::NTypesOfSgnPdf ) {
179201 throw std ::runtime_error ("ERROR: only SingleGaus, DoubleGaus and DoubleGausSigmaRatioPar signal functions supported! Exit" );
180202 }
181- sgnFunc [iSliceVar ] = sgnFuncConfig [iSliceVar ];
182203 }
204+ sliceVarLimits [nSliceVarBins ] = sliceVarMax [nSliceVarBins - 1 ];
183205
184206 struct decayInfo {
185207 std ::string decayProducts ;
@@ -474,8 +496,8 @@ void runMassFitter(const std::string& configFileName)
474496 const auto valueToFix = fixSigmaManual .empty () ? hSigmaToFix -> GetBinContent (iSliceVar + 1 ) : fixSigmaManual [iSliceVar ];
475497 hFitConfig -> SetBinContent (ConfigFixSigma , iSliceVar + 1 , valueToFix );
476498 }
477- hFitConfig -> SetBinContent (ConfigBkgFunc , iSliceVar + 1 , bkgFuncConfig [iSliceVar ]);
478- hFitConfig -> SetBinContent (ConfigSgnFunc , iSliceVar + 1 , sgnFuncConfig [iSliceVar ]);
499+ hFitConfig -> SetBinContent (ConfigBkgFunc , iSliceVar + 1 , bkgFunc [iSliceVar ]);
500+ hFitConfig -> SetBinContent (ConfigSgnFunc , iSliceVar + 1 , sgnFunc [iSliceVar ]);
479501 }
480502
481503 // save output histograms
0 commit comments