MINT2
Classes | Enumerations | Functions
MINT Namespace Reference

Classes

class  BasicComplex
 
class  ComplexProduct
 
class  ComplexProductForEvent
 
class  const_counted_ptr
 
class  counted_ptr
 
class  counted_ptr_counter
 
class  EventList
 
class  EventPtrList
 
class  EvtTRandom
 
class  FitComplex
 
class  FitComplexCart
 
class  FitComplexPolar
 
class  FitParameter
 
class  FitParDependent
 
class  FitParRef
 
class  GaussFct
 
class  IComplexFitParDependent
 
class  IComplexForEventFitParDependent
 
class  IEventGenerator
 
class  IEventList
 
class  IEvtGen
 
class  IEvtRandom
 
class  IFitParDependent
 
class  IFitParRegister
 
class  IMinimalEventList
 
class  IMinimisable
 
class  IMintGen
 
class  IMinuitParameter
 
class  INamedParameter
 
class  IPdf
 
class  IReturnComplex
 
class  IReturnComplexForEvent
 
class  IReturnReal
 
class  IReturnRealForEvent
 
class  IReturnRealWithSmoothy
 
class  IUnweightedEventGenerator
 
class  IWeightedEvent
 
class  LASSO
 
class  LASSO_flexi
 
class  Minimisable
 
class  minimisePareto
 
class  Minimiser
 
class  MintFcn
 
class  MintFcnGrad
 
class  MintGen
 
class  MinuitParameterSet
 
class  NamedParameter
 
class  NamedParameterBase
 
class  NamedParameterStream
 
class  Neg2LL
 
class  Neg2LLClass
 
class  Neg2LLConstraint
 
class  Neg2LLMultiConstraint
 
class  Neg2LLSum
 
class  ParsedParameterFile
 
class  ParsedParameterFileList
 
class  ParsedParameterLine
 
class  PdfBase
 
class  Phase
 
class  PolymorphMap
 
class  PolymorphVector
 
class  SimulMinimisable
 
class  SumPdf
 
class  TwoDArray
 

Enumerations

enum  OWNERSHIP { CALLER_PASSES_OWNERSHIP, CALLER_KEEPS_OWNERSHIP }
 

Functions

template<typename T >
std::complex< T > cexp (std::complex< T > arg)
 
counted_ptr< FitComplexFitComplexMaker (const std::string &name, const char *fname=0, MinuitParameterSet *pset=0, MINT::IFitParRegister *daddy=0, FitParameter::FIX_OR_WHAT fow=FitParameter::FIX, NamedParameterBase::VERBOSITY vb=NamedParameterBase::VERBOSE)
 
double generalisedPareto_cumulative (double y, double xi, double sigma_bar)
 
double generalisedPareto_pdf (double y, double xi, double sigma_bar)
 
double generalisedPareto_logPdf (double y, double xi, double sigma_bar)
 
double generalisedPareto_xiFromMeanRMS (double mean, double rms)
 
double generalisedPareto_sigmaFromMeanRMS (double mean, double rms)
 
double generalisedPareto_yFromCL (double CL, double xi, double sigma_bar)
 
double generalisedPareto_limit (double xi, double sigma_bar)
 
double generalisedPareto_estimateMaximum (const std::vector< double > &input, double CL=0.001)
 
double generalisedPareto_estimateMaximum (std::vector< double > input, double CL, double &actualMax, double &paretoMax, int numEvents=-9999)
 
template<typename EVT_TYPE >
double getWeight (const EVT_TYPE &)
 
template<>
double getWeight (const MINT::IWeightedEvent &evt)
 
NamedParameterStreamoperator>> (NamedParameterStream &eam, std::string &ing)
 
template<typename Key , typename Val >
const Val & keyFinder (const Key &k, const std::map< Key, Val > &m, const Val &dummy, bool &successFlag)
 
template<typename Key , typename Val >
const Val & keyFinder (const Key &k, const std::map< Key, Val > &m, const Val &dummy)
 
template<typename T >
TMatrixTSym< T > makeTMatrixTSym (const TMatrixT< T > &m)
 
template<typename T >
void stringToAnything (const std::string &str, T &anything)
 
template<typename T >
std::string anythingToString (const T &anything)
 
template<typename T >
std::string anyVectorToString (const std::vector< T > &anyV)
 
std::string stringtime (double dt)
 
int nearestInt (double f)
 
bool A_is_in_B (const std::string &a, const std::string &b)
 
int LeviCita (int a, int b)
 
int LeviCita (int a, int b, int c)
 
int LeviCita (int a, int b, int c, int d)
 
int LeviCita (int a, int b, int c, int d, int e)
 
int LeviCita (const std::vector< int > &v)
 

Enumeration Type Documentation

◆ OWNERSHIP

Enumerator
CALLER_PASSES_OWNERSHIP 
CALLER_KEEPS_OWNERSHIP 

Definition at line 17 of file Utils.h.

Function Documentation

◆ A_is_in_B()

bool MINT::A_is_in_B ( const std::string &  a,
const std::string &  b 
)

Definition at line 34 of file Utils.cpp.

34  {
35  unsigned int pos = b.find(a);
36  return pos < b.size();
37 }

◆ anythingToString()

template<typename T >
std::string MINT::anythingToString ( const T &  anything)

Definition at line 62 of file Utils.h.

62  {
63  std::stringstream strm;
64  strm << anything;
65  std::string ing;
66  strm >> ing;
67  return ing;
68 }

◆ anyVectorToString()

template<typename T >
std::string MINT::anyVectorToString ( const std::vector< T > &  anyV)

Definition at line 71 of file Utils.h.

71  {
72  std::stringstream strm;
73  for(unsigned int i=0; i<anyV.size(); i++){
74  strm << anyV[i];
75  }
76  std::string ing;
77  strm >> ing;
78  return ing;
79 }

◆ cexp()

template<typename T >
std::complex<T> MINT::cexp ( std::complex< T >  arg)

Definition at line 11 of file cexp.h.

11  {
12  std::complex<T> phase(cos(arg.imag()), sin(arg.imag()));
13  return exp(arg.real())*phase;
14 }

◆ FitComplexMaker()

counted_ptr< FitComplex > MINT::FitComplexMaker ( const std::string &  name,
const char *  fname = 0,
MinuitParameterSet pset = 0,
MINT::IFitParRegister daddy = 0,
FitParameter::FIX_OR_WHAT  fow = FitParameter::FIX,
NamedParameterBase::VERBOSITY  vb = NamedParameterBase::VERBOSE 
)

Definition at line 17 of file FitComplex.cpp.

23  {
24  bool dbThis=false;
25  bool verbose=false;
27  ptr_polar(new FitComplexPolar(name, fname, pset, daddy, fow, vb));
28 
30  ptr_euclid(new FitComplexCart(name, fname, pset, daddy, fow, vb));
31 
32  int count=0;
33  counted_ptr<FitComplex> return_ptr(0);
34  counted_ptr<FitComplex> default_ptr(ptr_polar);
35 
36  if( ptr_polar->gotInitialised()){
37  if(dbThis){
38  cout << " FitComplexMaker for " << name
39  << " found polar co-ordinates." << endl;
40  }
41  return_ptr = ptr_polar;
42  count++;
43  }
44  if( ptr_euclid->gotInitialised()){
45  if(dbThis){
46  cout << " FitComplexMaker for " << name
47  << " found Cartesian co-ordinates." << endl;
48  }
49  return_ptr = ptr_euclid;
50  count++;
51  }
52  if(0 == count){
53  if(verbose){
54  cout << " FitComplexMaker WARNING!: " << name
55  << " did not get initialised!" << endl;
56  }
57  return default_ptr;
58  }else if(2 == count){
59  cout << " FitComplexMaker WARNING!: " << name
60  << " got initialised " << count << " times!!" << endl;
61  return default_ptr;
62  }
63  return return_ptr;
64 }

◆ generalisedPareto_cumulative()

double MINT::generalisedPareto_cumulative ( double  y,
double  xi,
double  sigma_bar 
)

Definition at line 27 of file GeneralisedPareto.cpp.

27  {
28 
29  return 1 - pow(1.0 + xi*y/sigma_bar, -1.0/xi);
30 }

◆ generalisedPareto_estimateMaximum() [1/2]

double MINT::generalisedPareto_estimateMaximum ( const std::vector< double > &  input,
double  CL = 0.001 
)

Definition at line 65 of file GeneralisedPareto.cpp.

66  {
67  double paretoMax=-9999;
68  double actualMax=-9999;
70  , CL
71  , paretoMax
72  , actualMax);
73 }
double generalisedPareto_estimateMaximum(const std::vector< double > &input, double CL=0.001)

◆ generalisedPareto_estimateMaximum() [2/2]

double MINT::generalisedPareto_estimateMaximum ( std::vector< double >  input,
double  CL,
double &  actualMax,
double &  paretoMax,
int  numEvents = -9999 
)

Definition at line 98 of file GeneralisedPareto.cpp.

103  {
104  bool dbThis=false;
105  bool verbose=true;
106 
107  double max=-9999;
108  std::vector<double> input;
109  for(unsigned int i=0; i < input_a.size(); i++){
110  if(i > 0 && i%200 == 0){
111  input.push_back(max);
112  max = -9999;
113  }
114  if(input_a[i] > max) max=input_a[i];
115  }
116 
117  sort(input.begin(), input.end());
118 
119  unsigned int n=-9999;
120 // unsigned int n=9999;
121 
122  if(numEvents > 0){
123  n = (unsigned int) numEvents;
124  }else{
125  // let's take 0.2% of events, but at least 100, at most 1000:
126  n = input.size()/50; // originally /500,
127  if(n < 100) n=100;
128  if(n > 1000) n=1000;
129  }
130  if(n > input.size()) n = input.size()-1;
131  if(n == 0){
132  cout << "MINT::generalisedPareto_estimateMaximum: "
133  << input.size() << " too few events."
134  << endl;
135  return -9999;
136  }
137  double sum=0, sumsq=0;
138  unsigned int counter=0;
139  double lastVal=-9999;
140  std::vector<double>::reverse_iterator it = input.rbegin();
141  double maxVal = *it;
142  for( ;
143  it != input.rend() && counter < n;
144  it++, counter++){
145  if(dbThis) cout << *it << endl;
146  lastVal = *it;
147  sum += lastVal;
148  sumsq += (lastVal) * (lastVal);
149  }
150  double threshold = 0.5*(lastVal + *it); // *it is one event beyond lastVal;
151 
152  double mean = sum/((double)n);
153  double meansq = sumsq/((double)n);
154  double var = meansq - mean*mean;
155  double rms = sqrt(var);
156 
157  double xi = MINT::generalisedPareto_xiFromMeanRMS(mean - threshold, rms);
158  double sg = MINT::generalisedPareto_sigmaFromMeanRMS(mean - threshold, rms);
159 
160  if(sg < -1.5*xi*(maxVal-threshold)) sg = fabs(1.5*xi*(maxVal-threshold));
161 
162  cout << "xi, sg before fit: xi = " << xi << ", sg = " << sg << endl;
163  minimisePareto ll(input, threshold, xi, sg);
164  Minimiser mini(&ll);
165  mini.doFit();
166  xi = ll.getXi();
167  sg = fabs(ll.getSigma());
168  cout << "xi, sg after fit: xi = " << xi << ", sg = " << sg << endl;
169 
170  double limity = -9999;
171  if(xi < 0){
172  limity = MINT::generalisedPareto_limit(xi, sg);
173  }else{
174  limity = MINT::generalisedPareto_yFromCL(CL, xi, sg);
175  }
176 
177  double limit = limity + threshold;
178 
179  if(verbose || dbThis){
180  cout << "MINT::generalisedPareto_estimateMaximum with CL = " << CL << endl;
181  cout << "\n maxVal " << maxVal
182  << "\n mean " << mean
183  << "\n rms " << rms
184  << "\n threshold " << threshold
185  << "\n xi " << xi
186  << "\n sg " << sg
187  << "\n limity " << limity
188  << "\n limit " << limit
189  << endl;
190  }
191  if(limit < maxVal){
192  cout << "MINT::generalisedPareto_estimateMaximum with CL = " << CL
193  << ": Something clearly went wrong"
194  << "\n Estimated upper limit smaller than actual upper limit:"
195  << " actual: " << maxVal << ", estimated " << limit << endl;
196  actualMax = maxVal;
197  paretoMax = maxVal;
198  return maxVal;
199  }
200  actualMax = maxVal;
201  paretoMax = limit;
202  return limit;
203 }
double generalisedPareto_yFromCL(double CL, double xi, double sigma_bar)
double generalisedPareto_sigmaFromMeanRMS(double mean, double rms)
double generalisedPareto_xiFromMeanRMS(double mean, double rms)
double generalisedPareto_limit(double xi, double sigma_bar)

◆ generalisedPareto_limit()

double MINT::generalisedPareto_limit ( double  xi,
double  sigma_bar 
)

Definition at line 56 of file GeneralisedPareto.cpp.

56  {
57  if(xi >=0){
58  cout << " MINT::generalisedPareto_limit: Limit only for negative xi."
59  << " This xi = " << xi << endl;
60  return -9999.0;
61  }
62  return -sigma_bar/xi;
63 }

◆ generalisedPareto_logPdf()

double MINT::generalisedPareto_logPdf ( double  y,
double  xi,
double  sigma_bar 
)

Definition at line 36 of file GeneralisedPareto.cpp.

36  {
37  double d = 1.0 + xi*y/fabs(sigma_bar);
38  if(d < 0) return -99999;
39  return -log(fabs(sigma_bar)) + log(1.0 + xi*y/fabs(sigma_bar)) *(-1.0/xi - 1.0);
40 }

◆ generalisedPareto_pdf()

double MINT::generalisedPareto_pdf ( double  y,
double  xi,
double  sigma_bar 
)

Definition at line 31 of file GeneralisedPareto.cpp.

31  {
32  double d = 1.0 + xi*y/fabs(sigma_bar);
33  if(d < 0) return 0;
34  return (1./fabs(sigma_bar))*pow(1.0 + xi*y/fabs(sigma_bar), -1.0/xi - 1.0);
35 }

◆ generalisedPareto_sigmaFromMeanRMS()

double MINT::generalisedPareto_sigmaFromMeanRMS ( double  mean,
double  rms 
)

Definition at line 46 of file GeneralisedPareto.cpp.

46  {
47  // assuming threshold == 0, shift parameters if necessary
48  return 0.5*mean*(1.0 + mean*mean/(rms*rms));
49 }

◆ generalisedPareto_xiFromMeanRMS()

double MINT::generalisedPareto_xiFromMeanRMS ( double  mean,
double  rms 
)

Definition at line 42 of file GeneralisedPareto.cpp.

42  {
43  // assuming threshold == 0, shift parameters if necessary
44  return 0.5*(1.0 - mean*mean/(rms*rms));
45 }

◆ generalisedPareto_yFromCL()

double MINT::generalisedPareto_yFromCL ( double  CL,
double  xi,
double  sigma_bar 
)

Definition at line 51 of file GeneralisedPareto.cpp.

51  {
52 
53  return sigma_bar/xi * ( pow( 1.0 - CL , -xi) - 1.0 );
54 }

◆ getWeight() [1/2]

template<typename EVT_TYPE >
double MINT::getWeight ( const EVT_TYPE &  )

Definition at line 32 of file IWeightedEvent.h.

32  {
33  return 1;
34  }

◆ getWeight() [2/2]

template<>
double MINT::getWeight ( const MINT::IWeightedEvent evt)
inline

Definition at line 36 of file IWeightedEvent.h.

36  {
37  return evt.getWeight();
38  }
virtual double getWeight() const =0

◆ keyFinder() [1/2]

template<typename Key , typename Val >
const Val& MINT::keyFinder ( const Key &  k,
const std::map< Key, Val > &  m,
const Val &  dummy,
bool &  successFlag 
)

Definition at line 20 of file Utils.h.

24  {
25  typename std::map< Key , Val >::const_iterator it = m.find(k);
26  if(it == m.end()){
27  successFlag = false;
28  return dummy;
29  }else{
30  successFlag = true;
31  return it->second;
32  }
33 }
static const double m

◆ keyFinder() [2/2]

template<typename Key , typename Val >
const Val& MINT::keyFinder ( const Key &  k,
const std::map< Key, Val > &  m,
const Val &  dummy 
)

Definition at line 36 of file Utils.h.

39  {
40  bool successFlag;
41  return keyFinder<Key, Val>(k, m, dummy, successFlag);
42 }
static const double m

◆ LeviCita() [1/5]

int MINT::LeviCita ( int  a,
int  b 
)

Definition at line 41 of file Utils.cpp.

41  {
42  std::vector<int> v(2);
43  v[0]=a; v[1]=b;
44  return MINT::LeviCita(v);
45 }
int LeviCita(int a, int b)
Definition: Utils.cpp:41

◆ LeviCita() [2/5]

int MINT::LeviCita ( int  a,
int  b,
int  c 
)

Definition at line 46 of file Utils.cpp.

46  {
47  std::vector<int> v(3);
48  v[0]=a; v[1]=b; v[2]=c;
49  return MINT::LeviCita(v);
50 }
int LeviCita(int a, int b)
Definition: Utils.cpp:41

◆ LeviCita() [3/5]

int MINT::LeviCita ( int  a,
int  b,
int  c,
int  d 
)

Definition at line 51 of file Utils.cpp.

51  {
52  std::vector<int> v(4);
53  v[0]=a; v[1]=b; v[2]=c; v[3]=d;
54  return MINT::LeviCita(v);
55 }
int LeviCita(int a, int b)
Definition: Utils.cpp:41

◆ LeviCita() [4/5]

int MINT::LeviCita ( int  a,
int  b,
int  c,
int  d,
int  e 
)

Definition at line 56 of file Utils.cpp.

56  {
57  std::vector<int> v(5);
58  v[0]=a; v[1]=b; v[2]=c; v[3]=d; v[4]=e;
59  return MINT::LeviCita(v);
60 }
int LeviCita(int a, int b)
Definition: Utils.cpp:41

◆ LeviCita() [5/5]

int MINT::LeviCita ( const std::vector< int > &  v)

Definition at line 62 of file Utils.cpp.

62  {
63  if(v.size() <=1) return 1;
64 
65  std::vector<int> checkMultiples(v.size(), 0);
66  int p=1;
67  for(unsigned int i=0; i<v.size(); i++){
68  if(v[i] < 0 || v[i] >= (int) v.size()) return 0;
69  if(++(checkMultiples[i]) > 1) return 0;
70  }
71  for(unsigned int i=0; i<v.size()-1; i++){
72  for(unsigned int j=i+1; j < v.size(); j++){
73  if(v[i] > v[j]) p*= -1;
74  }
75  }
76  return p;
77 }

◆ makeTMatrixTSym()

template<typename T >
TMatrixTSym<T> MINT::makeTMatrixTSym ( const TMatrixT< T > &  m)

Definition at line 45 of file Utils.h.

45  {
46  TMatrixTSym<T> ms(m.GetNcols());
47  for(int i=0; i < ms.GetNcols(); i++){
48  for(int j=i; j < ms.GetNcols(); j++){
49  ms(i,j) = ms(j,i) = m(i,j);
50  }
51  }
52  return ms;
53 }
static const double m
static const double ms

◆ nearestInt()

int MINT::nearestInt ( double  f)

Definition at line 26 of file Utils.cpp.

26  {
27  if(f >= 0) return ((int)(f+0.5));
28 
29  f *= -1;
30 
31  return - ((int)(f+0.5));
32 }

◆ operator>>()

NamedParameterStream& MINT::operator>> ( NamedParameterStream eam,
std::string &  ing 
)

Definition at line 8 of file NamedParameterStream.cpp.

10  {
11  std::getline(eam,ing);
12  return eam;
13 }

◆ stringtime()

std::string MINT::stringtime ( double  dt)

Definition at line 14 of file Utils.cpp.

14  {
15  int dt = (int) ddt;
16  std::string str;
17  int sec = 1;
18  int min = sec*60;
19  int h = min*60;
20  if(dt >= h) str += MINT::anythingToString( (int) (dt/h) ) + " h ";
21  if(dt >= min) str += MINT::anythingToString( (int) (dt%h)/min ) + " min ";
22  str += MINT::anythingToString(dt%min) + " s";
23  return str;
24 }
std::string anythingToString(const T &anything)
Definition: Utils.h:62

◆ stringToAnything()

template<typename T >
void MINT::stringToAnything ( const std::string &  str,
T &  anything 
)

Definition at line 56 of file Utils.h.

56  {
57  std::stringstream strm(str);
58  strm >> anything;
59 }