/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$Id$
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/

//////////////////////////////////////////////////////////////////////////////
// 
// BEGIN_HTML
// RooConvCoefVar is an auxilary class that represents the coefficient
// of a RooAbsAnaConvPdf implementation as a separate RooAbsReal object
// to be able to interface these coefficient terms with the generic
// RooRealIntegral integration mechanism
// END_HTML
//
//

#include "RooFit.h"

#include "RooAbsAnaConvPdf.h"
#include "RooAbsAnaConvPdf.h"
#include "RooConvCoefVar.h"

using namespace std;

ClassImp(RooConvCoefVar)
;


//_____________________________________________________________________________
RooConvCoefVar::RooConvCoefVar(const char *name, const char *title, const RooAbsAnaConvPdf& input, 
			       Int_t coefIdx, const RooArgSet* varList) :
  RooAbsReal(name,title),
  _varSet("varSet","Set of coefficient variables",this),
  _convPdf("convPdf","Convoluted PDF",this,(RooAbsReal&)input,kFALSE,kFALSE),
  _coefIdx(coefIdx)
{
  // Constuctor given a RooAbsAnaConvPdf a coefficient index and a set with the
  // convoluted observable(s)
  if (varList) _varSet.add(*varList) ;
}



//_____________________________________________________________________________
RooConvCoefVar::RooConvCoefVar(const RooConvCoefVar& other, const char* name) :
  RooAbsReal(other,name),
  _varSet("varSet",this,other._varSet),
  _convPdf("convPdf",this,other._convPdf),
  _coefIdx(other._coefIdx)
{
  // Copy constructor
}



//_____________________________________________________________________________
Double_t RooConvCoefVar::getValV(const RooArgSet*) const 
{ 
  // Return value of chosen coefficient
  return evaluate() ; 
}



//_____________________________________________________________________________
Double_t RooConvCoefVar::evaluate() const 
{
  // Return value of chosen coefficient
  return ((RooAbsAnaConvPdf&)_convPdf.arg()).coefficient(_coefIdx) ;
}



//_____________________________________________________________________________
Int_t RooConvCoefVar::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName) const 
{
  // Return analytical integration capabilities of chosen coefficient

  Int_t code = ((RooAbsAnaConvPdf&)_convPdf.arg()).getCoefAnalyticalIntegral(_coefIdx,allVars,analVars,rangeName) ;
  return code ;
}



//_____________________________________________________________________________
Double_t RooConvCoefVar::analyticalIntegral(Int_t code, const char* rangeName) const 
{
  // Return analytical integral of chosen coefficient

  return ((RooAbsAnaConvPdf&)_convPdf.arg()).coefAnalyticalIntegral(_coefIdx,code,rangeName) ;
}

 RooConvCoefVar.cxx:1
 RooConvCoefVar.cxx:2
 RooConvCoefVar.cxx:3
 RooConvCoefVar.cxx:4
 RooConvCoefVar.cxx:5
 RooConvCoefVar.cxx:6
 RooConvCoefVar.cxx:7
 RooConvCoefVar.cxx:8
 RooConvCoefVar.cxx:9
 RooConvCoefVar.cxx:10
 RooConvCoefVar.cxx:11
 RooConvCoefVar.cxx:12
 RooConvCoefVar.cxx:13
 RooConvCoefVar.cxx:14
 RooConvCoefVar.cxx:15
 RooConvCoefVar.cxx:16
 RooConvCoefVar.cxx:17
 RooConvCoefVar.cxx:18
 RooConvCoefVar.cxx:19
 RooConvCoefVar.cxx:20
 RooConvCoefVar.cxx:21
 RooConvCoefVar.cxx:22
 RooConvCoefVar.cxx:23
 RooConvCoefVar.cxx:24
 RooConvCoefVar.cxx:25
 RooConvCoefVar.cxx:26
 RooConvCoefVar.cxx:27
 RooConvCoefVar.cxx:28
 RooConvCoefVar.cxx:29
 RooConvCoefVar.cxx:30
 RooConvCoefVar.cxx:31
 RooConvCoefVar.cxx:32
 RooConvCoefVar.cxx:33
 RooConvCoefVar.cxx:34
 RooConvCoefVar.cxx:35
 RooConvCoefVar.cxx:36
 RooConvCoefVar.cxx:37
 RooConvCoefVar.cxx:38
 RooConvCoefVar.cxx:39
 RooConvCoefVar.cxx:40
 RooConvCoefVar.cxx:41
 RooConvCoefVar.cxx:42
 RooConvCoefVar.cxx:43
 RooConvCoefVar.cxx:44
 RooConvCoefVar.cxx:45
 RooConvCoefVar.cxx:46
 RooConvCoefVar.cxx:47
 RooConvCoefVar.cxx:48
 RooConvCoefVar.cxx:49
 RooConvCoefVar.cxx:50
 RooConvCoefVar.cxx:51
 RooConvCoefVar.cxx:52
 RooConvCoefVar.cxx:53
 RooConvCoefVar.cxx:54
 RooConvCoefVar.cxx:55
 RooConvCoefVar.cxx:56
 RooConvCoefVar.cxx:57
 RooConvCoefVar.cxx:58
 RooConvCoefVar.cxx:59
 RooConvCoefVar.cxx:60
 RooConvCoefVar.cxx:61
 RooConvCoefVar.cxx:62
 RooConvCoefVar.cxx:63
 RooConvCoefVar.cxx:64
 RooConvCoefVar.cxx:65
 RooConvCoefVar.cxx:66
 RooConvCoefVar.cxx:67
 RooConvCoefVar.cxx:68
 RooConvCoefVar.cxx:69
 RooConvCoefVar.cxx:70
 RooConvCoefVar.cxx:71
 RooConvCoefVar.cxx:72
 RooConvCoefVar.cxx:73
 RooConvCoefVar.cxx:74
 RooConvCoefVar.cxx:75
 RooConvCoefVar.cxx:76
 RooConvCoefVar.cxx:77
 RooConvCoefVar.cxx:78
 RooConvCoefVar.cxx:79
 RooConvCoefVar.cxx:80
 RooConvCoefVar.cxx:81
 RooConvCoefVar.cxx:82
 RooConvCoefVar.cxx:83
 RooConvCoefVar.cxx:84
 RooConvCoefVar.cxx:85
 RooConvCoefVar.cxx:86
 RooConvCoefVar.cxx:87
 RooConvCoefVar.cxx:88
 RooConvCoefVar.cxx:89
 RooConvCoefVar.cxx:90
 RooConvCoefVar.cxx:91
 RooConvCoefVar.cxx:92
 RooConvCoefVar.cxx:93
 RooConvCoefVar.cxx:94
 RooConvCoefVar.cxx:95
 RooConvCoefVar.cxx:96
 RooConvCoefVar.cxx:97
 RooConvCoefVar.cxx:98
 RooConvCoefVar.cxx:99
 RooConvCoefVar.cxx:100
 RooConvCoefVar.cxx:101
 RooConvCoefVar.cxx:102
 RooConvCoefVar.cxx:103