52 template<
typename PDF_TYPE
53 ,
typename EVENTLIST_TYPE>
72 , EVENTLIST_TYPE & erptr
112 _pdf.parametersChanged();
123 std::cout <<
"Neg2LLClass: I got initialised with an event list with " 124 <<
_eventList.size() <<
" events." << std::endl;
125 std::cout <<
"Neg2LLClass: with pointer: " << &
_eventList << std::endl;
135 for(
unsigned int i=0; i <
_grad.size(); i++)
_grad[i]= 0.;
139 virtual double getPdf(
unsigned int evtNumber){
157 if(dbThis) std::cout <<
" that worked! the value is " 158 << valPdf << std::endl;
160 if(dbThis) std::cout <<
"ERROR in Neg2LLClass::logPdf()" 161 <<
" the pdf is " << valPdf
164 return -9999.e20 * (1.0 + fabs(valPdf));
169 virtual double logPdf(
unsigned int evtNumber){
170 return log(
getPdf(evtNumber));
181 void doGradient(
unsigned int i,
double pdfVal,
double weight){
184 std::vector<double> gradPDF(this->
getParSet()->size());
187 _grad.at(j)+= weight*gradPDF.at(j)/pdfVal;
198 if(
_NCalls > 500) printFreq = 1000;
199 if(
_NCalls > 10000) printFreq = 5000;
207 if(verbose && printout){
208 std::cout <<
"Neg2LLClass::getVal after " <<
_NCalls <<
" calls." 209 <<
" pdf ptr is non zero - that's a start." 212 double sumweights=0.0;
213 double sumsquareweights=0.0;
217 for(
unsigned int i=0; i <
_grad.size(); i++)
_grad[i]= 0.;
229 for(
unsigned int i=0; i <
_eventList.size(); ++i){
234 double pdfVal =
getPdf(i);
235 double logPdfVal = log(pdfVal);
236 if(TMath::IsNaN(weight*logPdfVal))
continue;
237 sum += weight*logPdfVal;
238 sumweights += weight;
239 sumsquareweights += weight*weight;
271 for(
unsigned int i=0; i <
_grad.size(); i++)
_grad[i]=-2. *
_grad[i] * fabs(sumweights/sumsquareweights);
275 std::cout <<
"Neg2LLClass::getVal after " <<
_NCalls <<
" calls." 277 <<
" events, I'm about to return " 278 << -2.0*sum*fabs(sumweights/sumsquareweights) << std::endl;
279 std::cout <<
"Sum of weights = " << sumweights << std::endl;
281 return -2.* sum*fabs(sumweights/sumsquareweights);
310 template <
typename PDF_TYPE,
typename EVENTLIST_TYPE>
311 Neg2LL(PDF_TYPE & pdf, EVENTLIST_TYPE & evtList
virtual void parametersChanged()
virtual MinuitParameterSet * getParSet()
virtual double getNewVal()
virtual double getNewVal()
std::vector< double > _grad
virtual void Gradient(std::vector< double > &grad)
unsigned int size() const
virtual void setUseAnalyticGradient(bool useAnalyticGradient)
virtual void setUseAnalyticGradient(bool useAnalyticGradient)
bool _useAnalyticGradient
virtual double getPdf(unsigned int evtNumber)
virtual double eventWeight(unsigned int evtNumber)
Neg2LL(PDF_TYPE &pdf, EVENTLIST_TYPE &evtList, MinuitParameterSet *mps=0)
counted_ptr< IMinimisable > _imini
virtual void Gradient(std::vector< double > &grad)
MinuitParameterSet * getParSet()
virtual bool useAnalyticGradient()
double getWeight(const EVT_TYPE &)
virtual double logPdf(unsigned int evtNumber)
void doGradient(unsigned int i, double pdfVal, double weight)
Neg2LLClass(const Neg2LLClass< PDF_TYPE, EVENTLIST_TYPE > &other)
EVENTLIST_TYPE & _eventList
virtual bool useAnalyticGradient()
Neg2LLClass(PDF_TYPE &pdf, EVENTLIST_TYPE &erptr, MinuitParameterSet *mps=0)
virtual void parametersChanged()