MINT2
MinuitParameterSet.h
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:17:55 GMT
3 #ifndef MINUIT_PARAMETER_SET
4 #define MINUIT_PARAMETER_SET
5 
6 #include <vector>
7 #include <iostream>
8 #include "TMinuit.h"
9 
10 #include "Mint/IMinuitParameter.h"
11 #include "Mint/Utils.h"
12 #include "TMatrixTSym.h"
13 
14 
15 class TNtupleD;
16 class TFile;
17 
18 namespace MINT{
19 
21  public :
22  typedef TMatrixTSym<double> CovMatrix ;
23  protected:
24  std::vector<IMinuitParameter*> _parPtrList;
26 
27  static const char ntpNameChars[];
28  static const char prtNameChars[];
29  static std::string prtToNtpName(const std::string& s_in);
30 
31  bool addToEnd(IMinuitParameter* parPtr);
32  bool setAllIndices();
33 
35  public:
37 
40 
42 
43  bool add(IMinuitParameter* parPtr);
44  bool unregister(IMinuitParameter* patPtr);
45 
46  unsigned int size()const;
47 
48  // double getVal(int i) const;
49  IMinuitParameter* getParPtr(unsigned int i);
50  const IMinuitParameter* getParPtr(unsigned int i) const;
51 
52  IMinuitParameter* getParPtr(std::string name){
53  for(unsigned int i=0; i <this->size(); i++){
54  if(0 == this->getParPtr(i)) continue;
55  if(A_is_in_B(name,this->getParPtr(i)->name()))return this->getParPtr(i);
56  }
57  return 0;
58  }
59  const IMinuitParameter* getParPtr(std::string name) const {
60  for(unsigned int i=0; i <this->size(); i++){
61  if(0 == this->getParPtr(i)) continue;
62  if(A_is_in_B(name,this->getParPtr(i)->name()))return this->getParPtr(i);
63  }
64  return 0;
65  }
66 
67  int findParPtr(std::string name){
68  for(unsigned int i=0; i <this->size(); i++){
69  if(0 == this->getParPtr(i)) continue;
70  if(A_is_in_B(name,this->getParPtr(i)->name()))return i;
71  }
72  return -1;
73  }
74 
75  // regarding the two routines below:
76  // normally you don't want to use deleteListAndObjects()
77  // This object is a collection of pointers
78  // but it does not own the objects being
79  // pointed to. However, if you created
80  // the objects pointed to with 'new', this might
81  // be a useful routine for memory management. Otherwise
82  // use deleteListKeepObjects(). Or nothing at all.
83 
84  void deleteListAndObjects();
85  // pitfall: delete objects in use
86  void deleteListKeepObjects();
87  // pitfall: potential memory leak
88 
89  TNtupleD* makeNewNtpForOwner(TFile*& ntpFile) const;
90  std::string ntpNames() const;
91  void fillNtp(TFile*& ntpFile, TNtupleD*& ntp) const;
92 
93  void print(std::ostream& os = std::cout) const;
94  void printVariable(std::ostream& os = std::cout) const;
95  void printResultVsInput(std::ostream& os = std::cout) const;
96 
98  bool setCovMatrix(const CovMatrix&) ;
100  const CovMatrix& covMatrix() const ;
101 };
102 
103 }//namespace MINT
104 #endif
105 //
static const char prtNameChars[]
const IMinuitParameter * getParPtr(std::string name) const
std::vector< IMinuitParameter * > _parPtrList
void fillNtp(TFile *&ntpFile, TNtupleD *&ntp) const
bool addToEnd(IMinuitParameter *parPtr)
bool setCovMatrix(const CovMatrix &)
Set the covariance matrix.
IMinuitParameter * getParPtr(unsigned int i)
static MinuitParameterSet * getDefaultSet()
unsigned int size() const
static MinuitParameterSet * _defaultMinuitParameterSet
int findParPtr(std::string name)
bool unregister(IMinuitParameter *patPtr)
bool A_is_in_B(const std::string &a, const std::string &b)
Definition: Utils.cpp:34
TMatrixTSym< double > CovMatrix
void printResultVsInput(std::ostream &os=std::cout) const
TNtupleD * makeNewNtpForOwner(TFile *&ntpFile) const
bool add(IMinuitParameter *parPtr)
static std::string prtToNtpName(const std::string &s_in)
const CovMatrix & covMatrix() const
Get the covariance matrix.
void print(std::ostream &os=std::cout) const
void printVariable(std::ostream &os=std::cout) const
static const char ntpNameChars[]
IMinuitParameter * getParPtr(std::string name)
MinuitParameterSet getFloating()
std::string ntpNames() const