RooThreshold.cc

Go to the documentation of this file.
00001 /*****************************************************************************
00002 * Project: BaBar detector at the SLAC PEP-II B-factory
00003 * Package: RooRarFit
00004  *    File: $Id: RooThreshold.cc,v 1.1 2012/04/02 14:47:56 fwilson Exp $
00005  * Authors: Fergus Wilson
00006  * History:
00007  * 
00008  * Copyright (C) 2005-2012, RAL
00009  *****************************************************************************/
00010 
00011 // -- CLASS DESCRIPTION [PDF] --
00012 // This is an implementation of a generic threshold function
00013 //
00014 //
00016 //
00017 // BEGIN_HTML
00018 // This is an implementation of a generic threshold function
00019 //
00020 // END_HTML
00021 //
00022 // Begin_Latex Amplitude : A(m) = ({m-m_{0})^{p} exp(P00 x + P01 x^{2} + ...) End_Latex
00023 
00024 #include "Riostream.h"
00025 #include "TMath.h"
00026 
00027 #include "RooFitCore/RooAbsReal.hh"
00028 #include "RooFitCore/RooRealVar.hh"
00029 
00030 //#include "RooRarFit/rarVersion.hh"
00031 #include "RooRarFit/RooThreshold.hh"
00032 
00033 ClassImp(RooThreshold)
00034 
00035 //------------------------------------------------------------------
00036 RooThreshold::RooThreshold(const char *name, const char *title,
00037                            RooAbsReal& _x, RooAbsReal& _m0,
00038                            RooAbsReal& _power, const RooArgList& _coeffs) :
00039   RooAbsPdf(name,title),
00040   x("x","Dependent",this,_x),
00041   m0("mean","Mean",this,_m0),
00042   power("power","power",this,_power),
00043   coeffs("coeffs","coeffs",this)
00044 {
00045   // copy over coefficeints
00046   TIterator* coefIter = _coeffs.createIterator() ;
00047   RooAbsArg* coef(0) ;
00048   while ((coef = (RooAbsArg*)coefIter->Next())) {
00049     if (!dynamic_cast<RooAbsReal*>(coef)) {
00050       cout << "RooTheshold::ctor(" << GetName() << ") ERROR: coefficient " << coef->GetName() 
00051            << " is not of type RooAbsReal" << endl ;
00052       assert(0) ;
00053     }
00054     coeffs.add(*coef) ;
00055   }
00056   delete coefIter ;
00057 }
00058 
00059 //------------------------------------------------------------------
00060 RooThreshold::RooThreshold(const RooThreshold& other, 
00061                      const char* name) : 
00062   RooAbsPdf(other,name), 
00063   x("x",this,other.x), 
00064   m0("m0",this,other.m0),
00065   power("power",this,other.power),
00066   coeffs("coeffs",this, other.coeffs)
00067 {
00068 }
00069 
00070 //------------------------------------------------------------------
00071 Double_t RooThreshold::evaluate() const
00072 {
00073   // calculate Threshold
00074 
00075   if (x<m0) {return(0);} // below threshold
00076   Double_t result(0);
00077 
00078   // loop over coefficient
00079   TIterator* iter = coeffs.createIterator() ;
00080   RooRealVar* coef(0) ;
00081   Int_t n(0);
00082   while ((coef = (RooRealVar*) iter->Next())) {
00083     n++;
00084     result += coef->getVal() * TMath::Power(x,n);
00085   }
00086   delete iter ;
00087 
00088   result = TMath::Exp(result) * TMath::Power(x-m0,power);
00089 
00090   //  cout << result << " " << x << " " << power << " " << m0 << endl;
00091   return(result);
00092 }
00093 

Generated on 30 Oct 2013 for RooRarFit by  doxygen 1.4.7