MINT2
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
MINT::MinuitParameterSet Class Reference

#include <MinuitParameterSet.h>

Inheritance diagram for MINT::MinuitParameterSet:
BinFlipParSet

Public Types

typedef TMatrixTSym< double > CovMatrix
 

Public Member Functions

 MinuitParameterSet ()
 
 MinuitParameterSet (const MinuitParameterSet &other)
 
MinuitParameterSet getFloating ()
 
bool add (IMinuitParameter *parPtr)
 
bool unregister (IMinuitParameter *patPtr)
 
unsigned int size () const
 
IMinuitParametergetParPtr (unsigned int i)
 
const IMinuitParametergetParPtr (unsigned int i) const
 
IMinuitParametergetParPtr (std::string name)
 
const IMinuitParametergetParPtr (std::string name) const
 
int findParPtr (std::string name)
 
void deleteListAndObjects ()
 
void deleteListKeepObjects ()
 
TNtupleD * makeNewNtpForOwner (TFile *&ntpFile) const
 
std::string ntpNames () const
 
void fillNtp (TFile *&ntpFile, TNtupleD *&ntp) const
 
void print (std::ostream &os=std::cout) const
 
void printVariable (std::ostream &os=std::cout) const
 
void printResultVsInput (std::ostream &os=std::cout) const
 
bool setCovMatrix (const CovMatrix &)
 Set the covariance matrix. More...
 
const CovMatrixcovMatrix () const
 Get the covariance matrix. More...
 

Static Public Member Functions

static MinuitParameterSetgetDefaultSet ()
 

Protected Member Functions

bool addToEnd (IMinuitParameter *parPtr)
 
bool setAllIndices ()
 

Static Protected Member Functions

static std::string prtToNtpName (const std::string &s_in)
 

Protected Attributes

std::vector< IMinuitParameter * > _parPtrList
 
CovMatrix _covMatrix
 

Static Protected Attributes

static MinuitParameterSet_defaultMinuitParameterSet =0
 
static const char ntpNameChars [] = { 'p', 'm', 's', '_', '_', '_', '_', '_', '_', '\0'}
 
static const char prtNameChars [] = { '+', '-', '*', '>', ',', '(', ')', '[', ']', '\0'}
 

Detailed Description

Definition at line 20 of file MinuitParameterSet.h.

Member Typedef Documentation

◆ CovMatrix

typedef TMatrixTSym<double> MINT::MinuitParameterSet::CovMatrix

Definition at line 22 of file MinuitParameterSet.h.

Constructor & Destructor Documentation

◆ MinuitParameterSet() [1/2]

MinuitParameterSet::MinuitParameterSet ( )

Definition at line 32 of file MinuitParameterSet.cpp.

32 {}

◆ MinuitParameterSet() [2/2]

MinuitParameterSet::MinuitParameterSet ( const MinuitParameterSet other)

Definition at line 33 of file MinuitParameterSet.cpp.

34  : _parPtrList(other._parPtrList)
35 {}
std::vector< IMinuitParameter * > _parPtrList

Member Function Documentation

◆ add()

bool MinuitParameterSet::add ( IMinuitParameter parPtr)

Definition at line 67 of file MinuitParameterSet.cpp.

67  {
68  return addToEnd(parPtr);
69 }
bool addToEnd(IMinuitParameter *parPtr)

◆ addToEnd()

bool MinuitParameterSet::addToEnd ( IMinuitParameter parPtr)
protected

Definition at line 47 of file MinuitParameterSet.cpp.

47  {
48  bool dbThis=false;
49  bool success=true;
50  if(0 == parPtr) return false;
51  if(dbThis){
52  cout << "MinuitParameterSet::add "
53  << " adding parPtr " << parPtr->name() << endl;
54  }
55  if(find(_parPtrList.begin(), _parPtrList.end(), parPtr) != _parPtrList.end()){
56  if(dbThis){
57  cout << "MinuitParameterSet::add "
58  << " already have parPtr " << parPtr->name() << endl;
59  }
60  return true ;
61  }
62  _parPtrList.push_back(parPtr);
63  success &= parPtr->setParSet(this);
64  success &= parPtr->setParSetIndex(_parPtrList.size()-1);
65  return success;
66 }
virtual bool setParSetIndex(int psetIndex)=0
std::vector< IMinuitParameter * > _parPtrList
virtual const std::string & name() const =0
virtual bool setParSet(MinuitParameterSet *ps)=0

◆ covMatrix()

const MinuitParameterSet::CovMatrix & MinuitParameterSet::covMatrix ( ) const

Get the covariance matrix.

Definition at line 255 of file MinuitParameterSet.cpp.

255  {
256  return _covMatrix ;
257 }

◆ deleteListAndObjects()

void MinuitParameterSet::deleteListAndObjects ( )

Definition at line 110 of file MinuitParameterSet.cpp.

110  {
111  for(std::vector<IMinuitParameter*>::iterator it = _parPtrList.begin();
112  it != _parPtrList.end(); it++){
113  delete (*it);
114  }
115  _parPtrList.clear();
116 }
std::vector< IMinuitParameter * > _parPtrList

◆ deleteListKeepObjects()

void MinuitParameterSet::deleteListKeepObjects ( )

Definition at line 118 of file MinuitParameterSet.cpp.

118  {
119  _parPtrList.clear();
120 }
std::vector< IMinuitParameter * > _parPtrList

◆ fillNtp()

void MinuitParameterSet::fillNtp ( TFile *&  ntpFile,
TNtupleD *&  ntp 
) const

Definition at line 179 of file MinuitParameterSet.cpp.

179  {
180  bool dbThis=false;
181  if(dbThis){
182  cout << "hello from MinuitParameterSet::fillNtp " << endl;
183  cout << " you called me with: " << ntp << endl;
184  }
185 
186  if(0 == ntp) ntp = makeNewNtpForOwner(ntpFile);
187  if(dbThis) cout << "got an ntuple ptr: " << ntp << endl;
188  Double_t* array = new Double_t[size()*4];
189  if(dbThis) cout << "made array" << endl;
190  int n=0;
191  for(unsigned int i=0; i < size(); i++){
192  if(0 == getParPtr(i)) continue;
193  if(0 != getParPtr(i)->iFixInit()) continue;
194  array[n++] = ((FitParameter*)getParPtr(i))->blindedMean();
195  array[n++] = getParPtr(i)->meanInit();
196  array[n++] = getParPtr(i)->err();
197  Double_t pull=-9999.0;
198  if(getParPtr(i)->err() > 0){
199  pull = (((FitParameter*)getParPtr(i))->blindedMean() - getParPtr(i)->meanInit())/getParPtr(i)->err();
200  }
201  array[n++] = pull;
202  }
203  if(dbThis){
204  cout << "checking how ntuple behaves with GetEntries()" << endl;
205  cout << " ntp->GetEntries() = " << ntp->GetEntries() << endl;
206  }
207  if(dbThis)cout << "filled the array, now putting this into the ntp" << endl;
208  ntp->Fill(array);
209  if(dbThis)cout << "filled into the ntuple, now deleting array" << endl;
210  delete[] array;
211  if(dbThis)cout << "done. returning" << endl;
212  return;
213 }
virtual double meanInit() const =0
virtual int iFixInit() const =0
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
virtual double err() const =0
TNtupleD * makeNewNtpForOwner(TFile *&ntpFile) const

◆ findParPtr()

int MINT::MinuitParameterSet::findParPtr ( std::string  name)
inline

Definition at line 67 of file MinuitParameterSet.h.

67  {
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  }
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
bool A_is_in_B(const std::string &a, const std::string &b)
Definition: Utils.cpp:34

◆ getDefaultSet()

MinuitParameterSet * MinuitParameterSet::getDefaultSet ( )
static

Definition at line 25 of file MinuitParameterSet.cpp.

25  {
28  }
30 }
static MinuitParameterSet * _defaultMinuitParameterSet

◆ getFloating()

MinuitParameterSet MinuitParameterSet::getFloating ( )

Definition at line 37 of file MinuitParameterSet.cpp.

37  {
38  MinuitParameterSet floating;
39  for(unsigned int i=0; i< size(); i++){
40  if(0 != getParPtr(i)){
41  floating.add(getParPtr(i));
42  }
43  }
44  return floating;
45 }
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
bool add(IMinuitParameter *parPtr)

◆ getParPtr() [1/4]

IMinuitParameter * MinuitParameterSet::getParPtr ( unsigned int  i)

Definition at line 100 of file MinuitParameterSet.cpp.

100  {
101  if(i >= _parPtrList.size()) return 0;
102  return _parPtrList[i];
103 }
std::vector< IMinuitParameter * > _parPtrList

◆ getParPtr() [2/4]

const IMinuitParameter * MinuitParameterSet::getParPtr ( unsigned int  i) const

Definition at line 105 of file MinuitParameterSet.cpp.

105  {
106  if(i >= _parPtrList.size()) return 0;
107  return _parPtrList[i];
108 }
std::vector< IMinuitParameter * > _parPtrList

◆ getParPtr() [3/4]

IMinuitParameter* MINT::MinuitParameterSet::getParPtr ( std::string  name)
inline

Definition at line 52 of file MinuitParameterSet.h.

52  {
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  }
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
bool A_is_in_B(const std::string &a, const std::string &b)
Definition: Utils.cpp:34

◆ getParPtr() [4/4]

const IMinuitParameter* MINT::MinuitParameterSet::getParPtr ( std::string  name) const
inline

Definition at line 59 of file MinuitParameterSet.h.

59  {
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  }
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
bool A_is_in_B(const std::string &a, const std::string &b)
Definition: Utils.cpp:34

◆ makeNewNtpForOwner()

TNtupleD * MinuitParameterSet::makeNewNtpForOwner ( TFile *&  ntpFile) const

Definition at line 122 of file MinuitParameterSet.cpp.

122  {
123  bool dbThis=false;
124  if(dbThis){
125  cout << "Hello from MinuitParameterSet::makeNewNtpForOwner" << endl;
126  }
127  gDirectory->cd();
128  if(0 == ntpFile) ntpFile = new TFile("MinuitParameterSetFile.root"
129  , "RECREATE");
130  ntpFile->cd();
131  TNtupleD* ntp = new TNtupleD("MinuitParameterSetNtp"
132  , "MinuitParameterSetNtp"
133  , ntpNames().c_str());
134  return ntp;
135 }
std::string ntpNames() const

◆ ntpNames()

std::string MinuitParameterSet::ntpNames ( ) const

Definition at line 152 of file MinuitParameterSet.cpp.

152  {
153  bool dbThis=false;
154  std::string str="";
155  int n=0;
156  for(unsigned int i=0; i < size(); i++){
157  if(0 == getParPtr(i)) continue;
158  if(0 != getParPtr(i)->iFixInit()) continue;
159  std::string name = //"p" + anythingToString(i) + "_" +
160  prtToNtpName(getParPtr(i)->name());
161  name = ((string) (TString(name).ReplaceAll("GS","")));
162  name = ((string) (TString(name).ReplaceAll("Lass","")));
163  name = ((string) (TString(name).ReplaceAll("RhoOmega","")));
164  if(str != "") str += ":";
165  str += (name + "_mean" + ":"); n++;
166  str += (name + "_init" + ":"); n++;
167  str += (name + "_err:"); n++;
168  str += (name + "_pull"); n++;
169  }
170  if(dbThis){
171  cout << "MinuitParameterSet::ntpNames():"
172  << " made " << n << " names " << str << endl;
173  cout << " this becomes: prtToNtpName(str) "
174  << prtToNtpName(str) << endl;
175  }
176  //return str;
177  return prtToNtpName(str);
178 }
virtual int iFixInit() const =0
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
static std::string prtToNtpName(const std::string &s_in)

◆ print()

void MinuitParameterSet::print ( std::ostream &  os = std::cout) const

Definition at line 216 of file MinuitParameterSet.cpp.

216  {
217  for(unsigned int i=0; i < size(); i++){
218  if(0 == getParPtr(i)) continue;
219  os << '\n';
220  getParPtr(i)->print(os);
221  }
222 }
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
virtual void print(std::ostream &os=std::cout) const =0

◆ printResultVsInput()

void MinuitParameterSet::printResultVsInput ( std::ostream &  os = std::cout) const

Definition at line 231 of file MinuitParameterSet.cpp.

231  {
232  os << "\n ======== MinuitParameterSet::(FitResult - StartValue)/error ========\n";
233  for(unsigned int i=0; i < this->size(); i++){
234  if(0 == getParPtr(i)) continue;
235  if(getParPtr(i)->iFixInit() == 1) continue;
236  os << '\n';
238  }
239  os << "\n ===================================================================="
240  << endl;
241 }
virtual void printResultVsInput(std::ostream &os=std::cout) const =0
virtual int iFixInit() const =0
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const

◆ printVariable()

void MinuitParameterSet::printVariable ( std::ostream &  os = std::cout) const

Definition at line 223 of file MinuitParameterSet.cpp.

223  {
224  for(unsigned int i=0; i < size(); i++){
225  if(0 == getParPtr(i)) continue;
226  if(getParPtr(i)->iFixInit() == 1) continue;
227  os << '\n';
228  getParPtr(i)->print(os);
229  }
230 }
virtual int iFixInit() const =0
IMinuitParameter * getParPtr(unsigned int i)
unsigned int size() const
virtual void print(std::ostream &os=std::cout) const =0

◆ prtToNtpName()

std::string MinuitParameterSet::prtToNtpName ( const std::string &  s_in)
staticprotected

Definition at line 137 of file MinuitParameterSet.cpp.

137  {
138  std::string s(s_in);
139  for(unsigned int i=1; i < s.size(); i++){
140  // cout << "... " << s[i-1] << s[i];
141  if(s[i-1] == '-' && s[i] == '>'){
142  s[i-1] = 't'; s[i] = 'o';
143  }
144  }
145 
146  for(int i=0; prtNameChars[i] != '\0'; i++){
147  replace(s.begin(), s.end(), prtNameChars[i], ntpNameChars[i]);
148  }
149  return s;
150 }
static const char prtNameChars[]
static const double s
static const char ntpNameChars[]

◆ setAllIndices()

bool MinuitParameterSet::setAllIndices ( )
protected

Definition at line 88 of file MinuitParameterSet.cpp.

88  {
89  bool success=true;
90  for(unsigned int i=0; i < _parPtrList.size(); i++){
91  success &= _parPtrList[i]->setParSetIndex(i);
92  }
93  return success;
94 }
std::vector< IMinuitParameter * > _parPtrList

◆ setCovMatrix()

bool MinuitParameterSet::setCovMatrix ( const CovMatrix covMatrix)

Set the covariance matrix.

Definition at line 243 of file MinuitParameterSet.cpp.

243  {
244  if(covMatrix.GetNcols() != size() || covMatrix.GetNrows() != size()){
245  cout << "WARNING: MiniutParameterSet::setCovMatrix: given matrix has the wrong size!" << endl ;
246  cout << "N. parameters: " << size() << ", matrix is " << covMatrix.GetNcols() << "x"
247  << covMatrix.GetNrows() << endl ;
248  return false ;
249  }
250  _covMatrix.ResizeTo(covMatrix) ;
252  return true ;
253 }
unsigned int size() const
const CovMatrix & covMatrix() const
Get the covariance matrix.

◆ size()

unsigned int MinuitParameterSet::size ( ) const

Definition at line 96 of file MinuitParameterSet.cpp.

96  {
97  return _parPtrList.size();
98 }
std::vector< IMinuitParameter * > _parPtrList

◆ unregister()

bool MinuitParameterSet::unregister ( IMinuitParameter patPtr)

Definition at line 71 of file MinuitParameterSet.cpp.

71  {
72 
73  if(_parPtrList.end() == find(_parPtrList.begin(), _parPtrList.end(), parPtr)){
74  cout << "WARNING in MinuitParameterSet::unregister"
75  << " parPtr you want to unregister is not part of this list!"
76  << endl;
77  return false;
78  }
79 
80  parPtr->setParSetIndex(-9999);
81  _parPtrList.erase(remove(_parPtrList.begin(), _parPtrList.end(), parPtr)
82  , _parPtrList.end()
83  );
84  setAllIndices();
85  return true;
86 }
std::vector< IMinuitParameter * > _parPtrList

Member Data Documentation

◆ _covMatrix

CovMatrix MINT::MinuitParameterSet::_covMatrix
protected

Definition at line 34 of file MinuitParameterSet.h.

◆ _defaultMinuitParameterSet

MinuitParameterSet * MinuitParameterSet::_defaultMinuitParameterSet =0
staticprotected

Definition at line 25 of file MinuitParameterSet.h.

◆ _parPtrList

std::vector<IMinuitParameter*> MINT::MinuitParameterSet::_parPtrList
protected

Definition at line 24 of file MinuitParameterSet.h.

◆ ntpNameChars

const char MinuitParameterSet::ntpNameChars = { 'p', 'm', 's', '_', '_', '_', '_', '_', '_', '\0'}
staticprotected

Definition at line 27 of file MinuitParameterSet.h.

◆ prtNameChars

const char MinuitParameterSet::prtNameChars = { '+', '-', '*', '>', ',', '(', ')', '[', ']', '\0'}
staticprotected

Definition at line 28 of file MinuitParameterSet.h.


The documentation for this class was generated from the following files: