#include "RooFit.h"
#include "TClass.h"
#include "TMath.h"
#include "Riostream.h"
#include "RooResolutionModel.h"
#include "RooMsgService.h"
#include "RooSentinel.h"
using namespace std;
ClassImp(RooResolutionModel)
;
RooFormulaVar* RooResolutionModel::_identity = 0;
void RooResolutionModel::cleanup()
{
delete _identity ;
_identity = 0 ;
}
RooResolutionModel::RooResolutionModel(const char *name, const char *title, RooRealVar& _x) :
RooAbsPdf(name,title),
x("x","Dependent or convolution variable",this,_x),
_basisCode(0), _basis(0),
_ownBasis(kFALSE)
{
if (!_identity) {
_identity = identity() ;
}
}
RooResolutionModel::RooResolutionModel(const RooResolutionModel& other, const char* name) :
RooAbsPdf(other,name),
x("x",this,other.x),
_basisCode(other._basisCode), _basis(0),
_ownBasis(kFALSE)
{
if (other._basis) {
_basis = (RooFormulaVar*) other._basis->Clone() ;
_ownBasis = kTRUE ;
}
if (_basis) {
TIterator* bsIter = _basis->serverIterator() ;
RooAbsArg* basisServer ;
while((basisServer = (RooAbsArg*)bsIter->Next())) {
addServer(*basisServer,kTRUE,kFALSE) ;
}
delete bsIter ;
}
}
RooResolutionModel::~RooResolutionModel()
{
if (_ownBasis && _basis) {
delete _basis ;
}
}
RooFormulaVar* RooResolutionModel::identity()
{
if (!_identity) {
_identity = new RooFormulaVar("identity","1",RooArgSet("")) ;
RooSentinel::activate() ;
}
return _identity ;
}
RooResolutionModel* RooResolutionModel::convolution(RooFormulaVar* inBasis, RooAbsArg* owner) const
{
if (inBasis->getParameter(0) != x.absArg()) {
coutE(InputArguments) << "RooResolutionModel::convolution(" << GetName() << "," << this
<< ") convolution parameter of basis function and PDF don't match" << endl
<< "basis->findServer(0) = " << inBasis->findServer(0) << endl
<< "x.absArg() = " << x.absArg() << endl ;
return 0 ;
}
if (basisCode(inBasis->GetTitle())==0) {
coutE(InputArguments) << "RooResolutionModel::convolution(" << GetName() << "," << this
<< ") basis function '" << inBasis->GetTitle() << "' is not supported." << endl ;
return 0 ;
}
TString newName(GetName()) ;
newName.Append("_conv_") ;
newName.Append(inBasis->GetName()) ;
newName.Append("_[") ;
newName.Append(owner->GetName()) ;
newName.Append("]") ;
RooResolutionModel* conv = (RooResolutionModel*) clone(newName) ;
TString newTitle(conv->GetTitle()) ;
newTitle.Append(" convoluted with basis function ") ;
newTitle.Append(inBasis->GetName()) ;
conv->SetTitle(newTitle.Data()) ;
conv->changeBasis(inBasis) ;
return conv ;
}
void RooResolutionModel::changeBasis(RooFormulaVar* inBasis)
{
if (_basis) {
TIterator* bsIter = _basis->serverIterator() ;
RooAbsArg* basisServer ;
while((basisServer = (RooAbsArg*)bsIter->Next())) {
removeServer(*basisServer) ;
}
delete bsIter ;
if (_ownBasis) {
delete _basis ;
}
}
_ownBasis = kFALSE ;
_basis = inBasis ;
if (_basis) {
TIterator* bsIter = _basis->serverIterator() ;
RooAbsArg* basisServer ;
while((basisServer = (RooAbsArg*)bsIter->Next())) {
addServer(*basisServer,kTRUE,kFALSE) ;
}
delete bsIter ;
}
_basisCode = inBasis?basisCode(inBasis->GetTitle()):0 ;
}
const RooRealVar& RooResolutionModel::basisConvVar() const
{
TIterator* sIter = basis().serverIterator() ;
RooRealVar* var = (RooRealVar*) sIter->Next() ;
delete sIter ;
return *var ;
}
RooRealVar& RooResolutionModel::convVar() const
{
return (RooRealVar&) x.arg() ;
}
Double_t RooResolutionModel::getValV(const RooArgSet* nset) const
{
if (!_basis) return RooAbsPdf::getValV(nset) ;
if (isValueDirty()) {
_value = evaluate() ;
if (_verboseDirty) cxcoutD(Tracing) << "RooResolutionModel(" << GetName() << ") value = " << _value << endl ;
clearValueDirty() ;
clearShapeDirty() ;
}
return _value ;
}
Bool_t RooResolutionModel::redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t )
{
if (!_basis) {
_norm = 0 ;
return kFALSE ;
}
RooFormulaVar* newBasis = (RooFormulaVar*) newServerList.find(_basis->GetName()) ;
if (newBasis) {
if (_ownBasis) {
delete _basis ;
}
_basis = newBasis ;
_ownBasis = kFALSE ;
}
_basis->redirectServers(newServerList,mustReplaceAll,nameChange) ;
return (mustReplaceAll && !newBasis) ;
}
Bool_t RooResolutionModel::traceEvalHook(Double_t value) const
{
return TMath::IsNaN(value) ;
}
void RooResolutionModel::normLeafServerList(RooArgSet& list) const
{
_norm->leafNodeServerList(&list) ;
}
Double_t RooResolutionModel::getNorm(const RooArgSet* nset) const
{
if (!nset) {
return getVal() ;
}
syncNormalization(nset,kFALSE) ;
if (_verboseEval>1) cxcoutD(Tracing) << IsA()->GetName() << "::getNorm(" << GetName()
<< "): norm(" << _norm << ") = " << _norm->getVal() << endl ;
Double_t ret = _norm->getVal() ;
return ret ;
}
void RooResolutionModel::printMultiline(ostream& os, Int_t content, Bool_t verbose, TString indent) const
{
RooAbsPdf::printMultiline(os,content,verbose,indent) ;
if(verbose) {
os << indent << "--- RooResolutionModel ---" << endl;
os << indent << "basis function = " ;
if (_basis) {
_basis->printStream(os,kName|kAddress|kTitle,kSingleLine,indent) ;
} else {
os << "<none>" << endl ;
}
}
}
RooResolutionModel.cxx:10 RooResolutionModel.cxx:11 RooResolutionModel.cxx:12 RooResolutionModel.cxx:13 RooResolutionModel.cxx:14 RooResolutionModel.cxx:15 RooResolutionModel.cxx:16 RooResolutionModel.cxx:17 RooResolutionModel.cxx:18 RooResolutionModel.cxx:19 RooResolutionModel.cxx:20 RooResolutionModel.cxx:21 RooResolutionModel.cxx:22 RooResolutionModel.cxx:23 RooResolutionModel.cxx:24 RooResolutionModel.cxx:25 RooResolutionModel.cxx:26 RooResolutionModel.cxx:27 RooResolutionModel.cxx:28 RooResolutionModel.cxx:29 RooResolutionModel.cxx:30 RooResolutionModel.cxx:31 RooResolutionModel.cxx:32 RooResolutionModel.cxx:33 RooResolutionModel.cxx:34 RooResolutionModel.cxx:35 RooResolutionModel.cxx:36 RooResolutionModel.cxx:37 RooResolutionModel.cxx:38 RooResolutionModel.cxx:39 RooResolutionModel.cxx:40 RooResolutionModel.cxx:41 RooResolutionModel.cxx:42 RooResolutionModel.cxx:43 RooResolutionModel.cxx:44 RooResolutionModel.cxx:45 RooResolutionModel.cxx:46 RooResolutionModel.cxx:47 RooResolutionModel.cxx:48 RooResolutionModel.cxx:49 RooResolutionModel.cxx:50 RooResolutionModel.cxx:51 RooResolutionModel.cxx:52 RooResolutionModel.cxx:53 RooResolutionModel.cxx:54 RooResolutionModel.cxx:55 RooResolutionModel.cxx:56 RooResolutionModel.cxx:57 RooResolutionModel.cxx:58 RooResolutionModel.cxx:59 RooResolutionModel.cxx:60 RooResolutionModel.cxx:61 RooResolutionModel.cxx:62 RooResolutionModel.cxx:63 RooResolutionModel.cxx:64 RooResolutionModel.cxx:65 RooResolutionModel.cxx:66 RooResolutionModel.cxx:67 RooResolutionModel.cxx:68 RooResolutionModel.cxx:69 RooResolutionModel.cxx:70 RooResolutionModel.cxx:71 RooResolutionModel.cxx:72 RooResolutionModel.cxx:73 RooResolutionModel.cxx:74 RooResolutionModel.cxx:75 RooResolutionModel.cxx:76 RooResolutionModel.cxx:77 RooResolutionModel.cxx:78 RooResolutionModel.cxx:79 RooResolutionModel.cxx:80 RooResolutionModel.cxx:81 RooResolutionModel.cxx:82 RooResolutionModel.cxx:83 RooResolutionModel.cxx:84 RooResolutionModel.cxx:85 RooResolutionModel.cxx:86 RooResolutionModel.cxx:87 RooResolutionModel.cxx:88 RooResolutionModel.cxx:89 RooResolutionModel.cxx:90 RooResolutionModel.cxx:91 RooResolutionModel.cxx:92 RooResolutionModel.cxx:93 RooResolutionModel.cxx:94 RooResolutionModel.cxx:95 RooResolutionModel.cxx:96 RooResolutionModel.cxx:97 RooResolutionModel.cxx:98 RooResolutionModel.cxx:99 RooResolutionModel.cxx:100 RooResolutionModel.cxx:101 RooResolutionModel.cxx:102 RooResolutionModel.cxx:103 RooResolutionModel.cxx:104 RooResolutionModel.cxx:105 RooResolutionModel.cxx:106 RooResolutionModel.cxx:107 RooResolutionModel.cxx:108 RooResolutionModel.cxx:109 RooResolutionModel.cxx:110 RooResolutionModel.cxx:111 RooResolutionModel.cxx:112 RooResolutionModel.cxx:113 RooResolutionModel.cxx:114 RooResolutionModel.cxx:115 RooResolutionModel.cxx:116 RooResolutionModel.cxx:117 RooResolutionModel.cxx:118 RooResolutionModel.cxx:119 RooResolutionModel.cxx:120 RooResolutionModel.cxx:121 RooResolutionModel.cxx:122 RooResolutionModel.cxx:123 RooResolutionModel.cxx:124 RooResolutionModel.cxx:125 RooResolutionModel.cxx:126 RooResolutionModel.cxx:127 RooResolutionModel.cxx:128 RooResolutionModel.cxx:129 RooResolutionModel.cxx:130 RooResolutionModel.cxx:131 RooResolutionModel.cxx:132 RooResolutionModel.cxx:133 RooResolutionModel.cxx:134 RooResolutionModel.cxx:135 RooResolutionModel.cxx:136 RooResolutionModel.cxx:137 RooResolutionModel.cxx:138 RooResolutionModel.cxx:139 RooResolutionModel.cxx:140 RooResolutionModel.cxx:141 RooResolutionModel.cxx:142 RooResolutionModel.cxx:143 RooResolutionModel.cxx:144 RooResolutionModel.cxx:145 RooResolutionModel.cxx:146 RooResolutionModel.cxx:147 RooResolutionModel.cxx:148 RooResolutionModel.cxx:149 RooResolutionModel.cxx:150 RooResolutionModel.cxx:151 RooResolutionModel.cxx:152 RooResolutionModel.cxx:153 RooResolutionModel.cxx:154 RooResolutionModel.cxx:155 RooResolutionModel.cxx:156 RooResolutionModel.cxx:157 RooResolutionModel.cxx:158 RooResolutionModel.cxx:159 RooResolutionModel.cxx:160 RooResolutionModel.cxx:161 RooResolutionModel.cxx:162 RooResolutionModel.cxx:163 RooResolutionModel.cxx:164 RooResolutionModel.cxx:165 RooResolutionModel.cxx:166 RooResolutionModel.cxx:167 RooResolutionModel.cxx:168 RooResolutionModel.cxx:169 RooResolutionModel.cxx:170 RooResolutionModel.cxx:171 RooResolutionModel.cxx:172 RooResolutionModel.cxx:173 RooResolutionModel.cxx:174 RooResolutionModel.cxx:175 RooResolutionModel.cxx:176 RooResolutionModel.cxx:177 RooResolutionModel.cxx:178 RooResolutionModel.cxx:179 RooResolutionModel.cxx:180 RooResolutionModel.cxx:181 RooResolutionModel.cxx:182 RooResolutionModel.cxx:183 RooResolutionModel.cxx:184 RooResolutionModel.cxx:185 RooResolutionModel.cxx:186 RooResolutionModel.cxx:187 RooResolutionModel.cxx:188 RooResolutionModel.cxx:189 RooResolutionModel.cxx:190 RooResolutionModel.cxx:191 RooResolutionModel.cxx:192 RooResolutionModel.cxx:193 RooResolutionModel.cxx:194 RooResolutionModel.cxx:195 RooResolutionModel.cxx:196 RooResolutionModel.cxx:197 RooResolutionModel.cxx:198 RooResolutionModel.cxx:199 RooResolutionModel.cxx:200 RooResolutionModel.cxx:201 RooResolutionModel.cxx:202 RooResolutionModel.cxx:203 RooResolutionModel.cxx:204 RooResolutionModel.cxx:205 RooResolutionModel.cxx:206 RooResolutionModel.cxx:207 RooResolutionModel.cxx:208 RooResolutionModel.cxx:209 RooResolutionModel.cxx:210 RooResolutionModel.cxx:211 RooResolutionModel.cxx:212 RooResolutionModel.cxx:213 RooResolutionModel.cxx:214 RooResolutionModel.cxx:215 RooResolutionModel.cxx:216 RooResolutionModel.cxx:217 RooResolutionModel.cxx:218 RooResolutionModel.cxx:219 RooResolutionModel.cxx:220 RooResolutionModel.cxx:221 RooResolutionModel.cxx:222 RooResolutionModel.cxx:223 RooResolutionModel.cxx:224 RooResolutionModel.cxx:225 RooResolutionModel.cxx:226 RooResolutionModel.cxx:227 RooResolutionModel.cxx:228 RooResolutionModel.cxx:229 RooResolutionModel.cxx:230 RooResolutionModel.cxx:231 RooResolutionModel.cxx:232 RooResolutionModel.cxx:233 RooResolutionModel.cxx:234 RooResolutionModel.cxx:235 RooResolutionModel.cxx:236 RooResolutionModel.cxx:237 RooResolutionModel.cxx:238 RooResolutionModel.cxx:239 RooResolutionModel.cxx:240 RooResolutionModel.cxx:241 RooResolutionModel.cxx:242 RooResolutionModel.cxx:243 RooResolutionModel.cxx:244 RooResolutionModel.cxx:245 RooResolutionModel.cxx:246 RooResolutionModel.cxx:247 RooResolutionModel.cxx:248 RooResolutionModel.cxx:249 RooResolutionModel.cxx:250 RooResolutionModel.cxx:251 RooResolutionModel.cxx:252 RooResolutionModel.cxx:253 RooResolutionModel.cxx:254 RooResolutionModel.cxx:255 RooResolutionModel.cxx:256 RooResolutionModel.cxx:257 RooResolutionModel.cxx:258 RooResolutionModel.cxx:259 RooResolutionModel.cxx:260 RooResolutionModel.cxx:261 RooResolutionModel.cxx:262 RooResolutionModel.cxx:263 RooResolutionModel.cxx:264 RooResolutionModel.cxx:265 RooResolutionModel.cxx:266 RooResolutionModel.cxx:267 RooResolutionModel.cxx:268 RooResolutionModel.cxx:269 RooResolutionModel.cxx:270 RooResolutionModel.cxx:271 RooResolutionModel.cxx:272 RooResolutionModel.cxx:273 RooResolutionModel.cxx:274 RooResolutionModel.cxx:275 RooResolutionModel.cxx:276 RooResolutionModel.cxx:277 RooResolutionModel.cxx:278 RooResolutionModel.cxx:279 RooResolutionModel.cxx:280 RooResolutionModel.cxx:281 RooResolutionModel.cxx:282 RooResolutionModel.cxx:283 RooResolutionModel.cxx:284 RooResolutionModel.cxx:285 RooResolutionModel.cxx:286 RooResolutionModel.cxx:287 RooResolutionModel.cxx:288 RooResolutionModel.cxx:289 RooResolutionModel.cxx:290 RooResolutionModel.cxx:291 RooResolutionModel.cxx:292 RooResolutionModel.cxx:293 RooResolutionModel.cxx:294 RooResolutionModel.cxx:295 RooResolutionModel.cxx:296 RooResolutionModel.cxx:297 RooResolutionModel.cxx:298 RooResolutionModel.cxx:299 RooResolutionModel.cxx:300 RooResolutionModel.cxx:301 RooResolutionModel.cxx:302 RooResolutionModel.cxx:303 RooResolutionModel.cxx:304 RooResolutionModel.cxx:305 RooResolutionModel.cxx:306 RooResolutionModel.cxx:307 RooResolutionModel.cxx:308 RooResolutionModel.cxx:309 RooResolutionModel.cxx:310 RooResolutionModel.cxx:311 RooResolutionModel.cxx:312 RooResolutionModel.cxx:313 RooResolutionModel.cxx:314 RooResolutionModel.cxx:315 RooResolutionModel.cxx:316 RooResolutionModel.cxx:317 RooResolutionModel.cxx:318 RooResolutionModel.cxx:319 RooResolutionModel.cxx:320 RooResolutionModel.cxx:321 RooResolutionModel.cxx:322 RooResolutionModel.cxx:323 RooResolutionModel.cxx:324 RooResolutionModel.cxx:325 RooResolutionModel.cxx:326 RooResolutionModel.cxx:327 RooResolutionModel.cxx:328 RooResolutionModel.cxx:329 RooResolutionModel.cxx:330 RooResolutionModel.cxx:331 RooResolutionModel.cxx:332 RooResolutionModel.cxx:333 RooResolutionModel.cxx:334 RooResolutionModel.cxx:335 RooResolutionModel.cxx:336 RooResolutionModel.cxx:337 RooResolutionModel.cxx:338 RooResolutionModel.cxx:339 RooResolutionModel.cxx:340 RooResolutionModel.cxx:341 RooResolutionModel.cxx:342 RooResolutionModel.cxx:343 RooResolutionModel.cxx:344 RooResolutionModel.cxx:345 RooResolutionModel.cxx:346 RooResolutionModel.cxx:347 RooResolutionModel.cxx:348 RooResolutionModel.cxx:349 RooResolutionModel.cxx:350 RooResolutionModel.cxx:351 RooResolutionModel.cxx:352 RooResolutionModel.cxx:353 RooResolutionModel.cxx:354 RooResolutionModel.cxx:355 RooResolutionModel.cxx:356 RooResolutionModel.cxx:357 RooResolutionModel.cxx:358 RooResolutionModel.cxx:359 RooResolutionModel.cxx:360 RooResolutionModel.cxx:361 RooResolutionModel.cxx:362 RooResolutionModel.cxx:363 RooResolutionModel.cxx:364 RooResolutionModel.cxx:365 RooResolutionModel.cxx:366 RooResolutionModel.cxx:367 RooResolutionModel.cxx:368 RooResolutionModel.cxx:369 RooResolutionModel.cxx:370 RooResolutionModel.cxx:371 RooResolutionModel.cxx:372 RooResolutionModel.cxx:373 RooResolutionModel.cxx:374 RooResolutionModel.cxx:375 RooResolutionModel.cxx:376 RooResolutionModel.cxx:377 RooResolutionModel.cxx:378 RooResolutionModel.cxx:379 RooResolutionModel.cxx:380 RooResolutionModel.cxx:381 RooResolutionModel.cxx:382 RooResolutionModel.cxx:383 RooResolutionModel.cxx:384 RooResolutionModel.cxx:385