ATLAS Offline Software
TMinuit_LHMM.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "TMath.h"
7 
8 #ifdef FAKEBKGTOOLS_ATLAS_ENVIRONMENT
10 #endif
11 
12 void TMinuit_LHMM::mnrazz(Double_t ynew, Double_t *pnew, Double_t *y, Int_t &jh, Int_t &jl)
13 {
14 //*-*-*-*-*Called only by MNSIMP (and MNIMPR) to add a new point*-*-*-*-*-*-*
15 //*-* =====================================================
16 //*-* and remove an old one from the current simplex, and get the
17 //*-* estimated distance to minimum.
18 //
19 //*-* This is a verbatim copy of the base class function, except that
20 //*-* printf's about the function not appearing to depend on the
21 //*-* fit parameters now are invoked only when DEBUG-level output
22 //*-* is requested by the user.
23 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
24 
25  /* Local variables */
26  Double_t pbig, plit;
27  Int_t i, j, nparp1;
28 
29  /* Function Body */
30  for (i = 1; i <= fNpar; ++i) { fP[i + jh*fMaxpar - fMaxpar-1] = pnew[i-1]; }
31  y[jh-1] = ynew;
32  if (ynew < fAmin) {
33  for (i = 1; i <= fNpar; ++i) { fX[i-1] = pnew[i-1]; }
34  mninex(fX);
35  fAmin = ynew;
36  fCstatu = "PROGRESS ";
37  jl = jh;
38  }
39  jh = 1;
40  nparp1 = fNpar + 1;
41  for (j = 2; j <= nparp1; ++j) { if (y[j-1] > y[jh-1]) jh = j; }
42  fEDM = y[jh-1] - y[jl-1];
43  if (fEDM <= 0) goto L45;
44  for (i = 1; i <= fNpar; ++i) {
45  pbig = fP[i-1];
46  plit = pbig;
47  for (j = 2; j <= nparp1; ++j) {
48  if (fP[i + j*fMaxpar - fMaxpar-1] > pbig) pbig = fP[i + j*fMaxpar - fMaxpar-1];
49  if (fP[i + j*fMaxpar - fMaxpar-1] < plit) plit = fP[i + j*fMaxpar - fMaxpar-1];
50  }
51  fDirin[i-1] = pbig - plit;
52  }
53 L40:
54  return;
55 L45:
56  if (fISW[4] >= 0) {
57  Printf(" FUNCTION VALUE DOES NOT SEEM TO DEPEND ON ANY OF THE %d VARIABLE PARAMETERS.",fNpar);
58  Printf(" VERIFY THAT STEP SIZES ARE BIG ENOUGH AND CHECK FCN LOGIC.");
59  Printf(" *******************************************************************************");
60  Printf(" *******************************************************************************");
61  }
62  goto L40;
63 } /* mnrazz_ */
64 
66 {
67 //*-*-*-*-*-*-*-*-*-*-*Performs a MINOS error analysis*-*-*-*-*-*-*-*-*-*-*-*
68 //*-* ===============================
69 //*-* Performs a MINOS error analysis on those parameters for
70 //*-* which it is requested on the MINOS command by calling
71 //*-* MNMNOT for each parameter requested.
72 //
73 //*-* This is a verbatim copy of the base class function, except that
74 //*-* printf's about a new minimum being found are now invoked only
75 //*-* when DEBUG-level output
76 //*-* is requested by the user.
77 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
78 
79  /* Local variables */
80  Double_t val2mi, val2pl;
81  Int_t nbad, ilax, ilax2, ngood, nfcnmi, iin, knt;
82 
83  if (fNpar <= 0) goto L700;
84  ngood = 0;
85  nbad = 0;
86  nfcnmi = fNfcn;
87 //*-*- . loop over parameters requested
88  for (knt = 1; knt <= fNpar; ++knt) {
89  if (Int_t(fWord7[1]) == 0) {
90  ilax = fNexofi[knt-1];
91  } else {
92  if (knt >= 7) break;
93  ilax = Int_t(fWord7[knt]);
94  if (ilax == 0) break;
95  if (ilax > 0 && ilax <= fNu) {
96  if (fNiofex[ilax-1] > 0) goto L565;
97  }
98  Printf(" PARAMETER NUMBER %3d NOT A VARIABLE. IGNORED.",ilax);
99  continue;
100  }
101 L565:
102 //*-*- calculate one pair of M E s
103  ilax2 = 0;
104  mnmnot(ilax, ilax2, val2pl, val2mi);
105  if (fLnewmn) goto L650;
106 //*-*- update NGOOD and NBAD
107  iin = fNiofex[ilax-1];
108  if (fErp[iin-1] > 0) ++ngood;
109  else ++nbad;
110  if (fErn[iin-1] < 0) ++ngood;
111  else ++nbad;
112  }
113 //*-*- end of loop . . . . . . .
114 //*-*- . . . . printout final values .
115  fCfrom = "MINOS ";
116  fNfcnfr = nfcnmi;
117  fCstatu = "UNCHANGED ";
118  if (ngood == 0 && nbad == 0) goto L700;
119  if (ngood > 0 && nbad == 0) fCstatu = "SUCCESSFUL";
120  if (ngood == 0 && nbad > 0) fCstatu = "FAILURE ";
121  if (ngood > 0 && nbad > 0) fCstatu = "PROBLEMS ";
122  if (fISW[4] >= 0) mnprin(4, fAmin);
123  if (fISW[4] >= 2) mnmatu(0);
124  return;
125 //*-*- . . . new minimum found . . . .
126 L650:
127  fCfrom = "MINOS ";
128  fNfcnfr = nfcnmi;
129  fCstatu = "NEW MINIMU";
130  if (fISW[4] >= 0) {
131  mnprin(4, fAmin);
132  Printf(" NEW MINIMUM FOUND. GO BACK TO MINIMIZATION STEP.");
133  Printf(" =================================================");
134  Printf(" V");
135  Printf(" V");
136  Printf(" V");
137  Printf(" VVVVVVV");
138  Printf(" VVVVV");
139  Printf(" VVV");
140  Printf(" V");
141  Printf(" ");
142  }
143  return;
144 L700:
145  Printf(" THERE ARE NO MINOS ERRORS TO CALCULATE.");
146 } /* mnmnos_ */
147 
149 {
150 //*-*-*-*-*-*-*-*Makes sure that the current point is a local minimum*-*-*-*-*
151 //*-* ====================================================
152 //*-* Makes sure that the current point is a local
153 //*-* minimum and that the error matrix exists,
154 //*-* or at least something good enough for MINOS and MNCONT
155 //*-*
156 //*-* Modified so that printout ("FUNCTION MUST BE MINIMIZED...")
157 //*-* only appears if verbose output is requested
158 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
159 
160  /* Local variables */
161  Double_t dxdi, wint;
162  Int_t ndex, iext, i, j;
163 
164  if (fISW[3] < 1) {
165  if (fISW[4] >= 0) {
166  Printf(" FUNCTION MUST BE MINIMIZED BEFORE CALLING %s",(const char*)fCfrom);
167  }
168  fApsi = fEpsi;
169  mnmigr();
170  }
171  if (fISW[1] < 3) {
172  mnhess();
173  if (fISW[1] < 1) {
174  mnwarn("W", fCfrom, "NO ERROR MATRIX. WILL IMPROVISE.");
175  for (i = 1; i <= fNpar; ++i) {
176  ndex = i*(i-1) / 2;
177  for (j = 1; j <= i-1; ++j) {
178  ++ndex;
179  fVhmat[ndex-1] = 0;
180  }
181  ++ndex;
182  if (fG2[i-1] <= 0) {
183  wint = fWerr[i-1];
184  iext = fNexofi[i-1];
185  if (fNvarl[iext-1] > 1) {
186  mndxdi(fX[i-1], i-1, dxdi);
187  if (TMath::Abs(dxdi) < .001) wint = .01;
188  else wint /= TMath::Abs(dxdi);
189  }
190  fG2[i-1] = fUp / (wint*wint);
191  }
192  fVhmat[ndex-1] = 2 / fG2[i-1];
193  }
194  fISW[1] = 1;
195  fDcovar = 1;
196  } else mnwerr();
197  }
198 } /* mncuve_ */
TMinuit_LHMM.h
TMinuit_LHMM::mnrazz
void mnrazz(Double_t ynew, Double_t *pnew, Double_t *y, Int_t &jh, Int_t &jl) override
Definition: TMinuit_LHMM.cxx:12
lumiFormat.i
int i
Definition: lumiFormat.py:85
TMinuit_LHMM::mncuve
void mncuve() override
Definition: TMinuit_LHMM.cxx:148
ClassImp
ClassImp(xAOD::Experimental::RFileChecker) namespace xAOD
Definition: RFileChecker.cxx:28
TMinuit_LHMM::mnmnos
void mnmnos() override
Definition: TMinuit_LHMM.cxx:65
y
#define y
TMinuit_LHMM
Definition: TMinuit_LHMM.h:12