7 using namespace RooFit;
17 useFloor(true), floorEval(0), floorInt(0),
18 rangeXmin(1), rangeXmax(-1),
19 theXVar(
"theXVar",
"theXVar", this),
20 FcnList(
"FcnList",
"FcnList", this),
21 leafDepsList(
"leafDepsList",
"leafDepsList", this)
28 RooAbsReal(name, title),
30 useFloor(true), floorEval(0), floorInt(0),
31 rangeXmin(1), rangeXmax(-1),
32 theXVar(
"theXVar",
"theXVar", this),
33 FcnList(
"FcnList",
"FcnList", this),
34 leafDepsList(
"leafDepsList",
"leafDepsList", this)
41 const std::vector<MELALinearInterpFunc::T>& inXList,
42 const RooArgList& inFcnList,
47 RooAbsReal(name, title),
49 useFloor(inUseFloor), floorEval(inFloorEval), floorInt(inFloorInt),
50 rangeXmin(1), rangeXmax(-1),
52 theXVar(
"theXVar",
"theXVar", this, inXVar),
53 FcnList(
"FcnList",
"FcnList", this),
54 leafDepsList(
"leafDepsList",
"leafDepsList", this)
57 if (!
dynamic_cast<RooRealVar*
>(
theXVar.absArg())){
59 theXVar.absArg()->leafNodeServerList(&tmpdeps, 0,
true);
63 TIterator* iter = inFcnList.createIterator();
65 while ((absarg = (RooAbsArg*)iter->Next())){
66 if (!
dynamic_cast<RooAbsReal*
>(absarg)){
67 coutE(InputArguments) <<
"ERROR::MELALinearInterpFunc(" << GetName() <<
") function " << absarg->GetName() <<
" is not of type RooAbsReal" << endl;
72 if (!
dynamic_cast<RooRealVar*
>(absarg)){
74 absarg->leafNodeServerList(&tmpdeps, 0,
true);
80 iter = leafset.createIterator();
81 while ((absarg = (RooAbsArg*)iter->Next())){
if (
dynamic_cast<RooRealVar*
>(absarg))
leafDepsList.add(*absarg); }
85 coutE(InputArguments) <<
"MELALinearInterpFunc ERROR::MELALinearInterpFunc(" << GetName() <<
") input XList size not the same as FcnList size!" << endl;
94 RooAbsReal(other, name),
95 verbosity(other.verbosity),
96 useFloor(other.useFloor), floorEval(other.floorEval), floorInt(other.floorInt),
97 rangeXmin(other.rangeXmin), rangeXmax(other.rangeXmax),
99 theXVar(
"theXVar", this, other.theXVar),
100 FcnList(
"FcnList", this, other.FcnList),
101 leafDepsList(
"leafDepsList", this, other.leafDepsList)
113 vector<MELALinearInterpFunc::T>
const* coord=&
XList;
118 valjpo = coord->at(0);
119 for (Int_t j=0; j<np-1; j++){
121 valjpo = coord->at(j+1);
122 if (val<valjpo && val>=valj){ bin=j;
break; }
124 if (bin==-1 && val>=valjpo) bin=np-2;
125 else if (bin==-1) bin=0;
132 vector<MELALinearInterpFunc::T>
const* coord=&
XList;
134 if (Int_t(coord->size())>(bin+1)) diff = coord->at(bin+1)-coord->at(bin);
142 vector<MELALinearInterpFunc::T>
const* coord=&
XList;
144 return (val - coord->at(bin))*
kappa;
148 const Int_t xprime = 101;
149 const bool intAlongX=(code>0 && code%xprime==0);
152 Int_t coderem = (intAlongX ? code/xprime : code);
153 if (coderem==1) coderem=0;
156 if (intAlongX)
cout <<
"MELALinearInterpFunc(" << GetName() <<
")::interpolateFcn integrates using code = " << code <<
", coderem = " << coderem << endl;
157 else cout <<
"MELALinearInterpFunc(" << GetName() <<
")::interpolateFcn evaluates using code = " << code <<
", coderem = " << coderem << endl;
161 Int_t xbin=-1, xbinmin=-1, xbinmax=-1;
180 if (coderem==0) fcnval =
dynamic_cast<const RooAbsReal*
>(
FcnList.at(0))->getVal();
183 if (intAlongX) res *= (txmax-txmin);
186 for (
int ix=0; ix<nxbins; ix++){
188 (xbin>=0 && ix!=xbin)
190 (xbinmin>=0 && xbinmax>=xbinmin && !(xbinmin<=ix && ix<=xbinmax))
195 if (ix==xbinmin) txlow=txmin;
196 if (ix==xbinmax) txhigh=txmax;
202 for (
unsigned int j=0; j<2; j++) fcnval[j] = dynamic_cast<const RooAbsReal*>(
FcnList.at(ix+j))->getVal();
205 for (
unsigned int j=0; j<2; j++) fcnval[j] = dynamic_cast<const RooAbsReal*>(
FcnList.at(ix+j))->analyticalIntegral(coderem, rangeName);
209 if (intAlongX) segval += (fcnval[1] - fcnval[0])*(pow(txhigh, 2)-pow(txlow, 2))/2.;
210 else segval += (fcnval[1] - fcnval[0])*txhigh;
214 <<
"MELALinearInterpFunc(" << GetName() <<
")::interpolateFcn evaluated bin " << ix
215 <<
" with txlow = " << txlow <<
", txhigh = " << txhigh <<
", fcnval[0] = " << fcnval[0] <<
", fcnval[1] = " << fcnval[1]
232 if (_forceNumInt)
return 0;
234 const Int_t xprime = 101;
237 RooArgSet Xdeps, Fcndeps;
238 RooRealVar* rrv_x =
dynamic_cast<RooRealVar*
>(
theXVar.absArg());
239 if (rrv_x==0)
theXVar.absArg()->leafNodeServerList(&Xdeps, 0,
true);
241 for (
int ix=0; ix<
FcnList.getSize(); ix++){
243 RooAbsReal
const* fcn =
dynamic_cast<const RooAbsReal*
>(
FcnList.at(ix));
244 fcn->leafNodeServerList(&tmpdeps, 0,
true);
245 Fcndeps.add(tmpdeps);
247 RooArgSet mirrorvars;
248 TIterator* iter = allVars.createIterator();
250 while ((var = (RooAbsArg*)iter->Next())){
251 RooRealVar* rrv_tmp =
dynamic_cast<RooRealVar*
>(var);
252 if (rrv_tmp==0)
continue;
255 isFound = (rrv_tmp==rrv_x);
258 TIterator* iter_deps = Xdeps.createIterator();
260 while ((var_deps = (RooAbsArg*)iter_deps->Next())){
261 RooRealVar* depvar =
dynamic_cast<RooRealVar*
>(var_deps);
262 if (depvar==0)
continue;
263 if (depvar==rrv_tmp){ isFound=
true;
break; }
267 if (!isFound) mirrorvars.add(*var);
271 Int_t codetmp = fcn->getAnalyticalIntegral(mirrorvars, analVars, rangeName);
272 if (codetmp!=0) code *= codetmp;
277 if (Fcndeps.find(*rrv_x)==0){
278 if (matchArgs(allVars, analVars,
theXVar)) code *= xprime;
284 cout <<
"MELALinearInterpFunc(" << GetName() <<
")::getAnalyticalIntegral code = " << code << endl;
304 return (*(range[0])>*(range[1]) || (val>=*(range[0]) && val<=*(range[1])));
318 if (val<*(range[0])) val = *(range[0]);
319 if (val>*(range[1])) val = *(range[1]);