ATLAS Offline Software
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
MuonCalib::T0MTHistos Class Reference

#include <T0MTHistos.h>

Collaboration diagram for MuonCalib::T0MTHistos:

Classes

class  Slice
 

Public Member Functions

 T0MTHistos ()=default
 Default Constructor. More...
 
 T0MTHistos (int id, const T0MTSettings *settings, const char *hname=nullptr)
 Initializing constructor. More...
 
void Initialize (int id, const T0MTSettings *settings, const char *hname=nullptr)
 Initialize class. More...
 
TH1FGetTSpec () const
 get drift time spectrum More...
 
void SetTSpec (int id, TH1F *spec, const T0MTSettings *settings, bool copy_spec=true)
 set the pointer of the drift-time spectrum to an existing spectrum. More...
 
void FillT (double t)
 fill drift time spectrum More...
 
bool FitT0 ()
 Perform t0-fit Returns true if fit is successfull. More...
 
bool FitTmax ()
 Performs tmax-fit Returns true if fit is successfull. More...
 
int Id () const
 return tube id
More...
 
bool T0Ok () const
 returns true if t0-fit was successfull More...
 
int StatusCode () const
 returns status code - the status code applies only to the t0 fit More...
 
const TF1 * GetT0Function () const
 returns function fitted to the riding edge of the spectrum More...
 
TF1 * GetT0Function ()
 returns function fitted to the riding edge of the spectrum More...
 
bool TmaxOk () const
 returns true if tmax-fir was successfull More...
 
const TF1 * GetTMaxFunction () const
 returns function fitted to the riding edge of the spectrum More...
 
TF1 * GetTMaxFunctionNC () const
 returns function fitted to the riding edge of the spectrum More...
 
const double & T0Chi2 () const
 returns t0 chi2 More...
 

Static Public Attributes

static constexpr int N_T0_FIT_PAR = 4
 number of parameters in t0 fit More...
 
static constexpr int T0_PAR_NR_T0 = 0
 parameter numbers in t0 fit More...
 
static constexpr int T0_PAR_NR_T = 1
 
static constexpr int T0_PAR_NR_BACK = 2
 
static constexpr int T0_PAR_NR_A = 3
 
static constexpr int N_TMAX_FIT_PAR = 6
 number of parameters for tmax fit More...
 
static constexpr int TMAX_PAR_NR_TMAX = 0
 parameters numbers for tmax fit More...
 
static constexpr int TMAX_PAR_NR_T = 1
 
static constexpr int TMAX_PAR_NR_BACK = 2
 
static constexpr int TMAX_PAR_NR_A = 3
 
static constexpr int TMAX_PAR_NR_B = 4
 
static constexpr int TMAX_PAR_NR_T0 = 5
 

Private Member Functions

bool NormalFit ()
 normal t0 fit More...
 
bool T0Scramble ()
 try to get better start values from a scrambled histogram More...
 
void TopChi2 ()
 top chi2 calculation More...
 
void TopSlicing ()
 top slicing metyhod More...
 

Private Attributes

std::unique_ptr< TH1Fm_time {nullptr}
 time spectrum More...
 
int m_id {-1}
 tube id; More...
 
std::unique_ptr< TF1 > m_t0_fermi {nullptr}
 function fitted to the riding edghe of the spectrum More...
 
bool m_t0_ok {false}
 is true if t0 fit was successful More...
 
int m_status_code {99}
 status code for t0 fit (0 ok, 1 not fitted, 2 low statistics, 3 failed) More...
 
std::unique_ptr< TF1 > m_tmax_fermi {nullptr}
 function fitted to the falling edge of the spectrum More...
 
double m_tmax_ok {FLT_MAX}
 is true if tmax fit was successful More...
 
TDirectory * m_dir {nullptr}
 TDirectory where debug and result histograms are stored. More...
 
const T0MTSettingsm_settings {nullptr}
 Pointer to settings class. More...
 
double m_chi2 {FLT_MAX}
 chi2/NDF value More...
 

Detailed Description

Histogram and fitter class for drift time and pulsehight spectra The rising slope is fitted by a fermi-function: \(f(t)=r_{u,0} + \frac{A}{1+exp((t_0 - t)/T_0}\). The falling slope is fitted by \(g(t)=r_{u,max} + \frac{e(t,a,b)}{1+exp((t_{max} - t)/T_{max}}\) where \(e(t, a, b) = a e^{bt}\). A pattern recognition determines the fit ranges and the parameters \(r_u\), \(A\), \(a\) and \(b\).

Author
Felix.nosp@m..Rau.nosp@m.scher.nosp@m.@Phy.nosp@m.sik.U.nosp@m.ni-M.nosp@m.uench.nosp@m.en.D.nosp@m.e
Date
June 2006

}

Definition at line 40 of file T0MTHistos.h.

Constructor & Destructor Documentation

◆ T0MTHistos() [1/2]

MuonCalib::T0MTHistos::T0MTHistos ( )
default

Default Constructor.

◆ T0MTHistos() [2/2]

MuonCalib::T0MTHistos::T0MTHistos ( int  id,
const T0MTSettings settings,
const char *  hname = nullptr 
)
inline

Initializing constructor.

Parameters
idtube id
settingst0-fit settings: settings will be asked about histogram binning

Definition at line 50 of file T0MTHistos.h.

50  : m_t0_fermi(nullptr), m_tmax_fermi(nullptr) {
51  Initialize(id, settings, hname);
52  }

Member Function Documentation

◆ FillT()

void MuonCalib::T0MTHistos::FillT ( double  t)

fill drift time spectrum

Parameters
tdrift time

Definition at line 56 of file T0MTHistos.cxx.

56 { m_time->Fill(static_cast<Axis_t>(t)); }

◆ FitT0()

bool MuonCalib::T0MTHistos::FitT0 ( )

Perform t0-fit Returns true if fit is successfull.

Definition at line 114 of file T0MTHistos.cxx.

114  {
115  if (m_time->GetEntries() < 1000) {
116  m_status_code = 2;
117  return false;
118  }
119  if (!NormalFit()) return false;
120  if (m_time->GetEntries() < 10000) {
121  m_status_code = 0;
122  return true;
123  }
125  if (!T0Scramble()) {
126  m_status_code = 3;
127  return false;
128  }
129  }
131 #ifndef NDEBUG
132  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
133  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << m_time->GetName() << " " << m_chi2 << endmsg;
134 #endif
135  m_status_code = 0;
136  return true;
137  } // end T0MTHistos::FitT0

◆ FitTmax()

bool MuonCalib::T0MTHistos::FitTmax ( )

Performs tmax-fit Returns true if fit is successfull.

Definition at line 142 of file T0MTHistos.cxx.

142  {
143  TDirectory *cwd = gDirectory;
144  if (m_dir != nullptr) m_dir->cd();
145  if (!m_time) {
146  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
147  log << MSG::WARNING << "T0MTHistos::FitTmax: Class is not initialized!" << endmsg;
148  m_tmax_ok = false;
149  cwd->cd();
150  return false;
151  }
152  // check if t0-fit was successfull t0 is needed for tmax-pattern recognition
153  if (!m_t0_ok || m_t0_fermi == nullptr) {
154  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
155  log << MSG::WARNING << "T0MTHistos::FitTmax for tube " << m_id << ": No valid t0-value!" << endmsg;
156  m_tmax_ok = false;
157  cwd->cd();
158  return false;
159  }
160  // Create pattern Recognition Class
161  MTTmaxPatternRecognition rec;
162  // perform pattern recognition
163  if (!rec.Initialize(m_time.get(), m_t0_fermi->GetParameter(T0_PAR_NR_T0), m_settings)) {
164  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
165  log << MSG::WARNING << "T0MTHistos::FitTmax for tube " << m_id << ": Pattern recognition failed!" << endmsg;
166  m_tmax_ok = false;
167  cwd->cd();
168  return false;
169  }
170  // create function object
171  char buffer[100];
172  snprintf(buffer, 100, "mt_tmax_fermi");
173  if (!m_tmax_fermi) {
174  m_tmax_fermi = std::make_unique<TF1>(buffer, mt_tmax_fermi, rec.GetFitRangeMin(), rec.GetFitRangeMax(), N_TMAX_FIT_PAR);
175  // set parameter names
176  m_tmax_fermi->SetParName(TMAX_PAR_NR_TMAX, "t_{max}");
177  m_tmax_fermi->SetParName(TMAX_PAR_NR_T, "T");
178  m_tmax_fermi->SetParName(TMAX_PAR_NR_BACK, "r_{b}");
179  m_tmax_fermi->SetParName(TMAX_PAR_NR_A, "a");
180  m_tmax_fermi->SetParName(TMAX_PAR_NR_B, "b");
181  // set fixed values
182  m_tmax_fermi->FixParameter(TMAX_PAR_NR_BACK, rec.GetBackground());
183  m_tmax_fermi->FixParameter(TMAX_PAR_NR_A, rec.GetA());
184  m_tmax_fermi->FixParameter(TMAX_PAR_NR_B, rec.GetB());
185  m_tmax_fermi->FixParameter(TMAX_PAR_NR_T0, m_t0_fermi->GetParameter(T0_PAR_NR_T0));
186  // set start values
187  m_tmax_fermi->SetParameter(TMAX_PAR_NR_TMAX, rec.GetEstimatedTMax());
188  m_tmax_fermi->SetParameter(TMAX_PAR_NR_T, 3.0);
189  }
190  // perform fit
191  if (m_dir != nullptr) {
192  m_tmax_fermi->SetLineColor(3);
193  m_tmax_fermi->Write();
194  }
195  m_tmax_fermi->SetLineColor(4);
196  std::string fitopt("LR");
197  if (m_settings->VerboseLevel() == 0) fitopt += "Q";
198  if (m_settings->AddFitfun()) {
199  fitopt += "+";
200  } else {
201  fitopt += "0";
202  }
203  m_time->Fit(m_tmax_fermi.get(), fitopt.c_str());
204  m_tmax_ok = true;
205  cwd->cd();
206  return true;
207  } // end T0MTHistos::FitTmax

◆ GetT0Function() [1/2]

TF1* MuonCalib::T0MTHistos::GetT0Function ( )
inline

returns function fitted to the riding edge of the spectrum

Definition at line 106 of file T0MTHistos.h.

106 { return m_t0_fermi.get(); }

◆ GetT0Function() [2/2]

const TF1* MuonCalib::T0MTHistos::GetT0Function ( ) const
inline

returns function fitted to the riding edge of the spectrum

Definition at line 104 of file T0MTHistos.h.

104 { return m_t0_fermi.get(); }

◆ GetTMaxFunction()

const TF1* MuonCalib::T0MTHistos::GetTMaxFunction ( ) const
inline

returns function fitted to the riding edge of the spectrum

Definition at line 110 of file T0MTHistos.h.

110 { return m_tmax_fermi.get(); }

◆ GetTMaxFunctionNC()

TF1* MuonCalib::T0MTHistos::GetTMaxFunctionNC ( ) const
inline

returns function fitted to the riding edge of the spectrum

Definition at line 112 of file T0MTHistos.h.

112 { return m_tmax_fermi.get(); }

◆ GetTSpec()

TH1F* MuonCalib::T0MTHistos::GetTSpec ( ) const
inline

get drift time spectrum

Definition at line 72 of file T0MTHistos.h.

72 { return m_time.get(); }

◆ Id()

int MuonCalib::T0MTHistos::Id ( ) const
inline

return tube id

Definition at line 97 of file T0MTHistos.h.

97 { return m_id; }

◆ Initialize()

void MuonCalib::T0MTHistos::Initialize ( int  id,
const T0MTSettings settings,
const char *  hname = nullptr 
)

Initialize class.

Parameters
idtube id
settingst0-fit settings: settings will be asked about histogram binning

Definition at line 61 of file T0MTHistos.cxx.

61  {
62  m_settings = settings;
63 #ifndef NDEBUG
64  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
65  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "T0MTHistos::Initialize: called" << endmsg;
66 #endif
67  char buf[100];
68  if (hname == nullptr)
69  snprintf(buf, 100, "t_spec_%d", id);
70  else
71  snprintf(buf, 100, "t_spec_%s", hname);
72 #ifndef NDEBUG
73  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "directory=" << gDirectory->GetName() << endmsg;
74 #endif
75  m_time = std::make_unique<TH1F>(buf, "", settings->NBinsTime(), settings->TimeMin(), settings->TimeMax());
76  m_id = id;
77  if (settings->DrawDebugGraphs()) {
78 #ifndef NDEBUG
79  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "T0MTHistos::Initialize: debug directory created" << endmsg;
80 #endif
81  TDirectory *cwd = gDirectory;
82  snprintf(buf, 100, "t0_tmax_dir_%d", id);
83  m_dir = gDirectory->mkdir(buf, buf);
84  cwd->cd();
85  } else {
86  m_dir = nullptr;
87  }
88  m_t0_ok = false;
89  m_tmax_ok = false;
90  } // end T0MTHistos::Initialize

◆ NormalFit()

bool MuonCalib::T0MTHistos::NormalFit ( )
private

normal t0 fit

Definition at line 212 of file T0MTHistos.cxx.

212  {
213 #ifndef NDEBUG
214  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
215  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "T0MTHistos::FitT0(): called" << endmsg;
216 #endif
217  TDirectory *cwd = gDirectory;
218  if (m_dir) m_dir->cd();
219  // check if class is initialized
220  if (!m_time) {
221 #ifdef NDEBUG
222  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
223 #endif
224  log << MSG::WARNING << "T0MTHistos::FitT0: Class is not initialized!" << endmsg;
225  m_t0_ok = false;
226  cwd->cd();
227  m_status_code = 3;
228  return false;
229  }
230  // create pattern recognition class
231  MTT0PatternRecognition rec;
232  // perform pattern recognition
233  if (!rec.Initialize(m_time.get(), m_settings)) {
234  m_t0_ok = false;
235 #ifdef NDEBUG
236  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
237 #endif
238  log << MSG::WARNING << "T0MTHistos::FitT0 for tube " << m_id << ": Pattern recognition failed!" << endmsg;
239  cwd->cd();
240  m_status_code = 3;
241  return false;
242  }
243  m_t0_ok = true;
244  // create function class
245  char buffer[100];
246  // sprintf(buffer,"mt_t0_fermi_%d", m_id);
247  snprintf(buffer, 100, "mt_t0_fermi");
248  m_t0_fermi = std::make_unique<TF1>(buffer, mt_t0_fermi, rec.GetFitRangeMin(), rec.GetFitRangeMax(), N_T0_FIT_PAR);
249  // set parameter names
250  m_t0_fermi->SetParName(T0_PAR_NR_T0, "t_{0}");
251  m_t0_fermi->SetParName(T0_PAR_NR_T, "T");
252  m_t0_fermi->SetParName(T0_PAR_NR_BACK, "r_{b}");
253  m_t0_fermi->SetParName(T0_PAR_NR_A, "A");
254  // set fixed values
255  m_t0_fermi->FixParameter(T0_PAR_NR_BACK, rec.GetBackground());
256  m_t0_fermi->SetParameter(T0_PAR_NR_A, rec.GetHeight() - rec.GetBackground());
257  // set estimates as start values
258  m_t0_fermi->SetParameter(T0_PAR_NR_T0, rec.GetEstimatedT0());
259  // set resonable start value for T
260  m_t0_fermi->SetParameter(T0_PAR_NR_T, 3.0);
261  // perform fit - NOTE: The return value of the Fit function is not documented!
262  if (m_dir != nullptr) {
263  std::unique_ptr<TLine> ln = std::make_unique<TLine>(rec.GetFitRangeMin(), 0, rec.GetFitRangeMin(), m_time->GetMaximum());
264  ln->Write("t0_range_min");
265  ln = std::make_unique<TLine>(rec.GetFitRangeMax(), 0, rec.GetFitRangeMax(), m_time->GetMaximum());
266  ln->Write("t0_range_max");
267  m_t0_fermi->SetLineColor(3);
268  m_t0_fermi->Write();
269  }
270  m_t0_fermi->SetLineColor(2);
271  std::string fitopt("BLR");
272  if (m_settings->VerboseLevel() == 0) fitopt += "Q";
273  if (m_settings->AddFitfun()) {
274  fitopt += "+";
275  } else {
276  fitopt += "0";
277  }
278  m_time->Fit(m_t0_fermi.get(), fitopt.c_str(), "", rec.GetFitRangeMin(), rec.GetFitRangeMax());
279  if (m_settings->T0Settings()->UseTopChi2())
280  TopChi2();
281  else
282  m_chi2 = m_time->GetFunction("mt_t0_fermi")->GetChisquare() / m_time->GetFunction("mt_t0_fermi")->GetNDF();
283  m_t0_ok = true;
284  cwd->cd();
285  m_status_code = 0;
286  return true;
287  } // end T0MTHistos::NormalFit

◆ SetTSpec()

void MuonCalib::T0MTHistos::SetTSpec ( int  id,
TH1F spec,
const T0MTSettings settings,
bool  copy_spec = true 
)

set the pointer of the drift-time spectrum to an existing spectrum.

This is for testapps

Parameters
idtube id
specPointer to an existing spectrum

Definition at line 95 of file T0MTHistos.cxx.

95  {
96  m_settings = settings;
97  TDirectory *cwd = gDirectory;
98  if (copy_spec)
99  m_time = std::make_unique<TH1F>(*spec);
100  else
101  m_time.reset(spec);
102  m_id = id;
103  if (settings->DrawDebugGraphs()) {
104  char buffer[100];
105  snprintf(buffer, 100, "t0_tmax_dir_%d", id);
106  m_dir = gDirectory->mkdir(buffer, buffer);
107  cwd->cd();
108  }
109  } // end T0MTHistos::SetTSpec

◆ StatusCode()

int MuonCalib::T0MTHistos::StatusCode ( ) const
inline

returns status code - the status code applies only to the t0 fit

Definition at line 102 of file T0MTHistos.h.

102 { return m_status_code; }

◆ T0Chi2()

const double& MuonCalib::T0MTHistos::T0Chi2 ( ) const
inline

returns t0 chi2

Definition at line 114 of file T0MTHistos.h.

114 { return m_chi2; }

◆ T0Ok()

bool MuonCalib::T0MTHistos::T0Ok ( ) const
inline

returns true if t0-fit was successfull

Definition at line 100 of file T0MTHistos.h.

100 { return m_t0_ok; }

◆ T0Scramble()

bool MuonCalib::T0MTHistos::T0Scramble ( )
private

try to get better start values from a scrambled histogram

Definition at line 292 of file T0MTHistos.cxx.

292  {
293 #ifndef NDEBUG
294  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
295  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "Scrambling for " << m_time->GetName() << endmsg;
296 #endif
297  std::string fitopt("BLR");
298  if (m_settings->VerboseLevel() == 0) fitopt += "Q";
299  if (m_settings->AddFitfun()) {
300  fitopt += "+";
301  } else {
302  fitopt += "0";
303  }
304  // create scrambled histogram
305  char scramhistname[100];
306  snprintf(scramhistname, 100, "%s_scram", m_time->GetName());
307  std::unique_ptr<TH1F> scramhist = std::make_unique<TH1F>(scramhistname, "scrambled histogram", m_time->GetSize() - 2,
308  m_time->GetXaxis()->GetXmin(), m_time->GetXaxis()->GetXmax());
309 
310  for (int binnr = 0; binnr < m_time->GetSize(); binnr++) {
311  scramhist->SetBinContent(binnr, m_time->GetBinContent(binnr) + getTLSRandomGen()->Gaus(0, m_time->GetBinError(binnr)));
312  scramhist->SetBinError(binnr, m_time->GetBinError(binnr) * 1.41421356);
313  if (scramhist->GetBinContent(binnr) < 0) scramhist->SetBinContent(binnr, 0);
314  }
315  TDirectory *cwd = gDirectory;
316  if (m_dir) m_dir->cd();
317  MTT0PatternRecognition scramrec;
318  // perform pattern recognition
319  if (!scramrec.Initialize(scramhist.get(), m_settings)) {
320 #ifdef NDEBUG
321  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
322 #endif
323  log << MSG::WARNING << "T0MTHistos::FitT0 for tube " << m_id << ": Scrambed pattern recognition failed!" << endmsg;
324  cwd->cd();
325  return false;
326  }
327  char scrambuffer[100];
328  snprintf(scrambuffer, 100, "scrammt_t0_fermi");
329  std::unique_ptr<TF1> scramm_t0_fermi = std::make_unique<TF1>();
330  m_t0_fermi->Copy(*scramm_t0_fermi);
331  scramm_t0_fermi->SetName(scrambuffer);
332  scramm_t0_fermi->SetRange(scramrec.GetFitRangeMin(), scramrec.GetFitRangeMax());
333  // set parameter names
334  scramm_t0_fermi->SetParName(T0_PAR_NR_T0, "t_{0}");
335  scramm_t0_fermi->SetParName(T0_PAR_NR_T, "T");
336  scramm_t0_fermi->SetParName(T0_PAR_NR_BACK, "r_{b}");
337  scramm_t0_fermi->SetParName(T0_PAR_NR_A, "A");
338  // set fixed values
339  scramm_t0_fermi->FixParameter(T0_PAR_NR_BACK, scramrec.GetBackground());
340  scramm_t0_fermi->SetParameter(T0_PAR_NR_A, scramrec.GetHeight() - scramrec.GetBackground());
341  // set estimates as start values
342  scramm_t0_fermi->SetParameter(T0_PAR_NR_T0, scramrec.GetEstimatedT0());
343  // set resonable start value for T
344  scramm_t0_fermi->SetParameter(T0_PAR_NR_T, 3.0);
345  // perform fit - NOTE: The return value of the Fit function is not documented!
346  scramhist->Fit(scrambuffer, fitopt.c_str(), "", scramrec.GetFitRangeMin(), scramrec.GetFitRangeMax());
347  // set parameter for the new fit of the original histogram
348  m_time->GetListOfFunctions()->Clear();
349  // set fixed values
350  m_t0_fermi->FixParameter(T0_PAR_NR_BACK, scramm_t0_fermi->GetParameter(T0_PAR_NR_BACK));
351  m_t0_fermi->SetParameter(T0_PAR_NR_A, scramm_t0_fermi->GetParameter(T0_PAR_NR_A));
352  // set estimates as start values
353  m_t0_fermi->SetParameter(T0_PAR_NR_T0, scramm_t0_fermi->GetParameter(T0_PAR_NR_T0));
354  // set resonable start value for T
355  m_t0_fermi->SetParameter(T0_PAR_NR_T, scramm_t0_fermi->GetParameter(T0_PAR_NR_T));
356  m_time->GetListOfFunctions()->Clear();
357  m_time->Fit("mt_t0_fermi", fitopt.c_str(), "", scramrec.GetFitRangeMin(), scramrec.GetFitRangeMax());
358  if (m_settings->T0Settings()->UseTopChi2())
359  TopChi2();
360  else
361  m_chi2 = m_time->GetFunction("mt_t0_fermi")->GetChisquare() / m_time->GetFunction("mt_t0_fermi")->GetNDF();
362  cwd->cd();
363  return true;
364  } // end T0MTHistos::T0Scramble

◆ TmaxOk()

bool MuonCalib::T0MTHistos::TmaxOk ( ) const
inline

returns true if tmax-fir was successfull

Definition at line 108 of file T0MTHistos.h.

108 { return m_tmax_ok; }

◆ TopChi2()

void MuonCalib::T0MTHistos::TopChi2 ( )
private

top chi2 calculation

Definition at line 366 of file T0MTHistos.cxx.

366  {
367  // calculate topchi2
368  m_chi2 = 0;
369  int topndf = 0;
370  TF1 *t0_fermi = m_time->GetFunction("mt_t0_fermi");
371  Double_t min, max;
372  t0_fermi->GetRange(min, max);
373  int startbin = m_time->FindBin(min) + 1;
374  int endbin = m_time->FindBin(max) - 1;
375  for (int bin = startbin; bin < endbin; bin++) {
376  float measval = m_time->GetBinContent(bin);
377  float funcval = t0_fermi->Eval(m_time->GetBinCenter(bin));
378  float errval = m_time->GetBinError(bin);
379  // take only chi2 from top part or if the bin content is min 10 or if the function >10
380  if (measval < 10 && funcval < 10 &&
381  m_time->GetBinCenter(bin) < t0_fermi->GetParameter(T0_PAR_NR_T0) + 2 * t0_fermi->GetParameter(T0_PAR_NR_T))
382  continue;
383  if (errval == 0)
384  m_chi2 += (measval - funcval) * (measval - funcval);
385  else
386  m_chi2 += (measval - funcval) * (measval - funcval) / (errval * errval);
387  topndf++;
388  }
389  if (topndf != 0) m_chi2 = m_chi2 / topndf;
390  } // end T0MTHistos::TopChi2

◆ TopSlicing()

void MuonCalib::T0MTHistos::TopSlicing ( )
private

top slicing metyhod

Definition at line 392 of file T0MTHistos.cxx.

392  {
393 #ifndef NDEBUG
394  MsgStream log(Athena::getMessageSvc(), "T0MTHistos");
395  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "Slicing for " << m_time->GetName() << endmsg;
396 #endif
397  // vector with slice chi2
398  std::list<Slice> slice_chi2;
399  Slice current;
400  current.chi_2 = 0.0;
401  current.n_bins = 0;
402  TF1 *t0_fermi = m_time->GetFunction("mt_t0_fermi");
403  current.min_bin = m_time->FindBin(t0_fermi->GetParameter(T0_PAR_NR_T0) + 2 * t0_fermi->GetParameter(T0_PAR_NR_T));
404  Double_t min, max;
405  t0_fermi->GetRange(min, max);
406 #ifndef NDEBUG
407  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << current.min_bin << " " << max << endmsg;
408 #endif
409  for (int bin = m_time->FindBin(t0_fermi->GetParameter(T0_PAR_NR_T0) + 2 * t0_fermi->GetParameter(T0_PAR_NR_T));
410  bin < m_time->FindBin(max) - 1; bin++) {
411  if (current.n_bins == 10) {
412 #ifndef NDEBUG
413  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << current.chi_2 / current.n_bins << endmsg;
414 #endif
415  current.max_bin = bin;
416  slice_chi2.push_back(current);
417  current.chi_2 = 0.0;
418  current.min_bin = bin;
419  current.n_bins = 0;
420  }
421  double measval = m_time->GetBinContent(bin);
422  double funcval = t0_fermi->Eval(m_time->GetBinCenter(bin));
423  double errval = m_time->GetBinError(bin);
424  if (errval == 0)
425  current.chi_2 += std::pow(measval - funcval, 2.0);
426  else
427  current.chi_2 += std::pow(measval - funcval, 2.0) / std::pow(errval, 2);
428  current.n_bins++;
429  }
430 #ifndef NDEBUG
431  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "number of slices: " << slice_chi2.size() << endmsg;
432 #endif
433  std::list<Slice>::iterator it = slice_chi2.end();
434  do {
435  --it;
436  if (it == slice_chi2.begin()) {
437 #ifndef NDEBUG
438  if (log.level() <= MSG::VERBOSE) log << MSG::VERBOSE << "No gain in slicing!" << endmsg;
439 #endif
440  return;
441  }
442  } while (it->chi_2 / static_cast<double>(it->n_bins) > 3);
443  max = m_time->GetBinCenter(it->min_bin);
444  m_time->GetListOfFunctions()->Clear();
445  std::string fitopt("BLR");
446  if (m_settings->VerboseLevel() == 0) fitopt += "Q";
447  if (m_settings->AddFitfun()) {
448  fitopt += "+";
449  } else {
450  fitopt += "0";
451  }
452  m_time->Fit("mt_t0_fermi", fitopt.c_str(), "", min, max);
453  if (m_settings->T0Settings()->UseTopChi2())
454  TopChi2();
455  else
456  m_chi2 = m_time->GetFunction("mt_t0_fermi")->GetChisquare() / m_time->GetFunction("mt_t0_fermi")->GetNDF();
457  } // end T0MTHistos::TopSlicing

Member Data Documentation

◆ m_chi2

double MuonCalib::T0MTHistos::m_chi2 {FLT_MAX}
private

chi2/NDF value

Definition at line 137 of file T0MTHistos.h.

◆ m_dir

TDirectory* MuonCalib::T0MTHistos::m_dir {nullptr}
private

TDirectory where debug and result histograms are stored.

Definition at line 133 of file T0MTHistos.h.

◆ m_id

int MuonCalib::T0MTHistos::m_id {-1}
private

tube id;

Definition at line 121 of file T0MTHistos.h.

◆ m_settings

const T0MTSettings* MuonCalib::T0MTHistos::m_settings {nullptr}
private

Pointer to settings class.

Definition at line 135 of file T0MTHistos.h.

◆ m_status_code

int MuonCalib::T0MTHistos::m_status_code {99}
private

status code for t0 fit (0 ok, 1 not fitted, 2 low statistics, 3 failed)

Definition at line 127 of file T0MTHistos.h.

◆ m_t0_fermi

std::unique_ptr<TF1> MuonCalib::T0MTHistos::m_t0_fermi {nullptr}
private

function fitted to the riding edghe of the spectrum

Definition at line 123 of file T0MTHistos.h.

◆ m_t0_ok

bool MuonCalib::T0MTHistos::m_t0_ok {false}
private

is true if t0 fit was successful

Definition at line 125 of file T0MTHistos.h.

◆ m_time

std::unique_ptr<TH1F> MuonCalib::T0MTHistos::m_time {nullptr}
private

time spectrum

Definition at line 119 of file T0MTHistos.h.

◆ m_tmax_fermi

std::unique_ptr<TF1> MuonCalib::T0MTHistos::m_tmax_fermi {nullptr}
private

function fitted to the falling edge of the spectrum

Definition at line 129 of file T0MTHistos.h.

◆ m_tmax_ok

double MuonCalib::T0MTHistos::m_tmax_ok {FLT_MAX}
private

is true if tmax fit was successful

Definition at line 131 of file T0MTHistos.h.

◆ N_T0_FIT_PAR

constexpr int MuonCalib::T0MTHistos::N_T0_FIT_PAR = 4
staticconstexpr

number of parameters in t0 fit

Definition at line 55 of file T0MTHistos.h.

◆ N_TMAX_FIT_PAR

constexpr int MuonCalib::T0MTHistos::N_TMAX_FIT_PAR = 6
staticconstexpr

number of parameters for tmax fit

Definition at line 59 of file T0MTHistos.h.

◆ T0_PAR_NR_A

constexpr int MuonCalib::T0MTHistos::T0_PAR_NR_A = 3
static

Definition at line 57 of file T0MTHistos.h.

◆ T0_PAR_NR_BACK

constexpr int MuonCalib::T0MTHistos::T0_PAR_NR_BACK = 2
static

Definition at line 57 of file T0MTHistos.h.

◆ T0_PAR_NR_T

constexpr int MuonCalib::T0MTHistos::T0_PAR_NR_T = 1
static

Definition at line 57 of file T0MTHistos.h.

◆ T0_PAR_NR_T0

constexpr int MuonCalib::T0MTHistos::T0_PAR_NR_T0 = 0
staticconstexpr

parameter numbers in t0 fit

Definition at line 57 of file T0MTHistos.h.

◆ TMAX_PAR_NR_A

constexpr int MuonCalib::T0MTHistos::TMAX_PAR_NR_A = 3
static

Definition at line 61 of file T0MTHistos.h.

◆ TMAX_PAR_NR_B

constexpr int MuonCalib::T0MTHistos::TMAX_PAR_NR_B = 4
static

Definition at line 61 of file T0MTHistos.h.

◆ TMAX_PAR_NR_BACK

constexpr int MuonCalib::T0MTHistos::TMAX_PAR_NR_BACK = 2
static

Definition at line 61 of file T0MTHistos.h.

◆ TMAX_PAR_NR_T

constexpr int MuonCalib::T0MTHistos::TMAX_PAR_NR_T = 1
static

Definition at line 61 of file T0MTHistos.h.

◆ TMAX_PAR_NR_T0

constexpr int MuonCalib::T0MTHistos::TMAX_PAR_NR_T0 = 5
static

Definition at line 62 of file T0MTHistos.h.

◆ TMAX_PAR_NR_TMAX

constexpr int MuonCalib::T0MTHistos::TMAX_PAR_NR_TMAX = 0
staticconstexpr

parameters numbers for tmax fit

Definition at line 61 of file T0MTHistos.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
MuonCalib::T0MTSettingsT0::ScrambleThreshold
const double & ScrambleThreshold() const
the chi2 threshold at which the scrambling method is used
Definition: T0MTSettingsT0.h:63
MuonCalib::T0MTHistos::m_t0_fermi
std::unique_ptr< TF1 > m_t0_fermi
function fitted to the riding edghe of the spectrum
Definition: T0MTHistos.h:123
TH1F::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:326
max
#define max(a, b)
Definition: cfImp.cxx:41
MuonCalib::T0MTHistos::m_dir
TDirectory * m_dir
TDirectory where debug and result histograms are stored.
Definition: T0MTHistos.h:133
MuonCalib::T0MTHistos::TopChi2
void TopChi2()
top chi2 calculation
Definition: T0MTHistos.cxx:366
MuonCalib::T0MTHistos::N_T0_FIT_PAR
static constexpr int N_T0_FIT_PAR
number of parameters in t0 fit
Definition: T0MTHistos.h:55
MuonCalib::mt_t0_fermi
Double_t mt_t0_fermi(Double_t *x, Double_t *par)
The fermi function to be fitted at the rising edge of the spectrum.
Definition: T0MTHistos.cxx:34
dqt_zlumi_pandas.hname
string hname
Definition: dqt_zlumi_pandas.py:272
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
MuonCalib::T0MTSettingsT0::UseTopChi2
const bool & UseTopChi2() const
If true use only the top part of the function for the chi2 calculation.
Definition: T0MTSettingsT0.h:60
RootHelpers::FindBin
Int_t FindBin(const TAxis *axis, const double x)
Definition: RootHelpers.cxx:14
MuonCalib::getTLSRandomGen
TRandom3 * getTLSRandomGen()
Definition: T0MTHistos.cxx:22
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
skel.it
it
Definition: skel.GENtoEVGEN.py:423
bin
Definition: BinsDiffFromStripMedian.h:43
MuonCalib::T0MTHistos::m_chi2
double m_chi2
chi2/NDF value
Definition: T0MTHistos.h:137
MuonCalib::T0MTSettings::T0Settings
const T0MTSettingsT0 * T0Settings() const
get settings for the t0-fit
Definition: T0MTSettings.h:78
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
MuonCalib::T0MTSettingsT0::SlicingThreshold
const double & SlicingThreshold() const
the chi2 threshold at which the slicing method is used
Definition: T0MTSettingsT0.h:70
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::T0MTHistos::T0_PAR_NR_T
static constexpr int T0_PAR_NR_T
Definition: T0MTHistos.h:57
MuonCalib::T0MTHistos::m_tmax_fermi
std::unique_ptr< TF1 > m_tmax_fermi
function fitted to the falling edge of the spectrum
Definition: T0MTHistos.h:129
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
MuonCalib::T0MTHistos::T0_PAR_NR_BACK
static constexpr int T0_PAR_NR_BACK
Definition: T0MTHistos.h:57
MuonCalib::T0MTHistos::m_status_code
int m_status_code
status code for t0 fit (0 ok, 1 not fitted, 2 low statistics, 3 failed)
Definition: T0MTHistos.h:127
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
python.DecayParser.buf
buf
print ("=> [%s]"cmd)
Definition: DecayParser.py:27
MuonCalib::T0MTSettings::VerboseLevel
const int & VerboseLevel() const
verbose level 0: no output 1: Fitter output
Definition: T0MTSettings.h:73
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonCalib::T0MTHistos::m_t0_ok
bool m_t0_ok
is true if t0 fit was successful
Definition: T0MTHistos.h:125
MuonCalib::T0MTHistos::TMAX_PAR_NR_A
static constexpr int TMAX_PAR_NR_A
Definition: T0MTHistos.h:61
MuonCalib::T0MTHistos::Initialize
void Initialize(int id, const T0MTSettings *settings, const char *hname=nullptr)
Initialize class.
Definition: T0MTHistos.cxx:61
TH1F::SetBinContent
void SetBinContent(int, double)
Definition: rootspy.cxx:327
MuonCalib::T0MTHistos::TMAX_PAR_NR_B
static constexpr int TMAX_PAR_NR_B
Definition: T0MTHistos.h:61
MuonCalib::T0MTHistos::TMAX_PAR_NR_T0
static constexpr int TMAX_PAR_NR_T0
Definition: T0MTHistos.h:62
MuonCalib::T0MTHistos::T0_PAR_NR_T0
static constexpr int T0_PAR_NR_T0
parameter numbers in t0 fit
Definition: T0MTHistos.h:57
min
#define min(a, b)
Definition: cfImp.cxx:40
MuonCalib::T0MTHistos::m_settings
const T0MTSettings * m_settings
Pointer to settings class.
Definition: T0MTHistos.h:135
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
MuonCalib::T0MTHistos::T0Scramble
bool T0Scramble()
try to get better start values from a scrambled histogram
Definition: T0MTHistos.cxx:292
MuonCalib::T0MTHistos::m_tmax_ok
double m_tmax_ok
is true if tmax fit was successful
Definition: T0MTHistos.h:131
MuonCalib::T0MTHistos::m_time
std::unique_ptr< TH1F > m_time
time spectrum
Definition: T0MTHistos.h:119
cwd
std::string cwd
Definition: listroot.cxx:38
MuonCalib::T0MTSettings::AddFitfun
const bool & AddFitfun() const
If set to true the fitted functions are added to the histograms.
Definition: T0MTSettings.h:63
MuonCalib::T0MTHistos::T0_PAR_NR_A
static constexpr int T0_PAR_NR_A
Definition: T0MTHistos.h:57
MuonCalib::T0MTHistos::TMAX_PAR_NR_T
static constexpr int TMAX_PAR_NR_T
Definition: T0MTHistos.h:61
MuonCalib::T0MTHistos::m_id
int m_id
tube id;
Definition: T0MTHistos.h:121
MuonCalib::T0MTHistos::N_TMAX_FIT_PAR
static constexpr int N_TMAX_FIT_PAR
number of parameters for tmax fit
Definition: T0MTHistos.h:59
MuonCalib::mt_tmax_fermi
Double_t mt_tmax_fermi(Double_t *x, Double_t *par)
The fermi function to be fitted at the trailing slope of the spectrum.
Definition: T0MTHistos.cxx:44
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::T0MTHistos::TMAX_PAR_NR_TMAX
static constexpr int TMAX_PAR_NR_TMAX
parameters numbers for tmax fit
Definition: T0MTHistos.h:61
MuonCalib::T0MTHistos::TopSlicing
void TopSlicing()
top slicing metyhod
Definition: T0MTHistos.cxx:392
MuonCalib::T0MTHistos::TMAX_PAR_NR_BACK
static constexpr int TMAX_PAR_NR_BACK
Definition: T0MTHistos.h:61
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
python.compareTCTs.ln
ln
Definition: compareTCTs.py:296
MuonCalib::T0MTHistos::NormalFit
bool NormalFit()
normal t0 fit
Definition: T0MTHistos.cxx:212