ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCalib::MTTmaxPatternRecognition Class Reference

#include <MTTmaxPatternRecognition.h>

Collaboration diagram for MuonCalib::MTTmaxPatternRecognition:

Public Member Functions

 MTTmaxPatternRecognition ()
 Default constructor.
bool Initialize (TH1F *hist, double t0, const T0MTSettings *settings)
 Initialize class.
double GetBackground () const
 get the background level
double GetA () const
 get parameter a in exp-function representing the end of the spectrum
double GetB () const
 get parameter a in exp-function representing the end of the spectrum
double GetEstimatedTMax () const
 get estimated t0
double GetFitRangeMin () const
 get fit range
double GetFitRangeMax () const
 get fit range
bool GetError () const
 return error flag

Private Member Functions

bool estimate_background (TH1F *hist)
 estimates the background level
bool estimate_height (TH1F *hist)
 estimates the height of the spectrum.

Private Attributes

const T0MTSettingsTMaxm_settings
 settings
bool m_draw_debug_graph
double m_background
 background level
double m_a
 parameters a, b in a*exp(b*x)
double m_b
double m_fit_min
 fit range
double m_fit_max
double m_tmax_est
 t0 estimate
VariableBinwidthHistogram m_vbh
 Variable binwidth histogram.
double m_t0
 t0
bool m_error
 error flag

Detailed Description

Definition at line 36 of file MTTmaxPatternRecognition.h.

Constructor & Destructor Documentation

◆ MTTmaxPatternRecognition()

MuonCalib::MTTmaxPatternRecognition::MTTmaxPatternRecognition ( )
inline

Member Function Documentation

◆ estimate_background()

bool MuonCalib::MTTmaxPatternRecognition::estimate_background ( TH1F * hist)
private

estimates the background level

Parameters
histinput histogram

Definition at line 39 of file MTTmaxPatternRecognition.cxx.

39 {
40 // smooth VBH in several steps
41 for (double i = 1.0; i <= 4.0; i *= 2.0) {
42 for (int j = 0; j < 2; j++)
43 if (!m_vbh.Smooth(hist->GetBinWidth(1) / i)) {
44 m_error = true;
45 return false;
46 }
47 }
49 m_vbh.DenistyGraph()->Write("tmax_density");
50 m_vbh.BinWidthGraph()->Write("tmax_binwidth");
51 m_vbh.DiffDensityGraph()->Write("tmax_diffdensity");
52 m_vbh.DiffBinwidthGraph()->Write("tmax_diffbinwidth");
53 }
54 // find falling edge - search for steepenst slope in a range of 600 to 800 ns after the t0
55 double peak_falling(0.0), peak_falling_slope(-9e9);
56 for (unsigned int i = 0; i < m_vbh.GetNumberOfBins() - 1; i++) {
57 const VariableBinwidthHistogramBin &bin1(m_vbh.GetBin(i)), &bin2(m_vbh.GetBin(i + 1));
58 // select region
59 if (bin1.Center() < m_t0 + m_settings->EndMin() || bin1.Center() > m_t0 + m_settings->EndMax()) continue;
60 if (bin2.Width() - bin1.Width() > peak_falling_slope && bin2.Right() < hist->GetBinLowEdge(hist->GetNbinsX()) - 10) {
61 peak_falling = bin1.Right();
62 peak_falling_slope = bin2.Width() - bin1.Width();
63 }
64 }
65 // check region size
66 int firstbin = hist->FindBin(peak_falling + m_settings->DistBackground());
67 int lastbin = hist->FindBin(m_vbh.GetBin(m_vbh.GetNumberOfBins() - 1).Right());
68 if (lastbin - firstbin < m_settings->MinBackgroundBins()) lastbin = hist->GetNbinsX();
69 if (lastbin - firstbin < m_settings->MinBackgroundBins()) {
70 MsgStream log(Athena::getMessageSvc(), "MTTmaxPatternRecognition");
71 log << MSG::WARNING << "estimate_background() - Falling edge is to glose to upper histogram range!" << endmsg;
72 m_error = true;
73 return false;
74 }
75 // calcul;ate mean
76 m_background = 0.0;
77 double n_bins = 0.0;
78 if (lastbin > hist->GetNbinsX()) lastbin = hist->GetNbinsX();
79 for (int i = firstbin; i <= lastbin; i++) {
80 m_background += hist->GetBinContent(i);
81 n_bins++;
82 }
83 // mark selected range
85 (new TLine(hist->GetBinCenter(firstbin), 0, hist->GetBinCenter(firstbin), hist->GetMaximum()))->Write("tmax_back_left");
86 (new TLine(hist->GetBinCenter(lastbin), 0, hist->GetBinCenter(lastbin), hist->GetMaximum()))->Write("tmax_back_right");
87 }
88
89 m_background /= n_bins;
90 m_tmax_est = peak_falling;
91 m_fit_max = hist->GetBinCenter(lastbin);
92 return true;
93 }
#define endmsg
VariableBinwidthHistogram m_vbh
Variable binwidth histogram.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ estimate_height()

bool MuonCalib::MTTmaxPatternRecognition::estimate_height ( TH1F * hist)
private

estimates the height of the spectrum.

The height is representet by an exponetial function a*exp(b*t). It returns the upper end of the height region.

Parameters
histinput histogram

Definition at line 99 of file MTTmaxPatternRecognition.cxx.

99 {
100 // get start value for fit
101 Double_t left = m_tmax_est - m_settings->DistAB() - m_settings->WidthAB(), right = m_tmax_est - m_settings->DistAB();
102 // fit
103 TF1* fun = new TF1("myexp", myexp, left, right, 4);
104 fun->FixParameter(2, m_background);
105 fun->FixParameter(3, m_t0);
106 hist->Fit("myexp", "Q0+", "", left, right);
107 // store parameters
108 m_a = fun->GetParameter(0);
109 m_b = fun->GetParameter(1);
110 m_fit_min = m_tmax_est - m_settings->DistAB() - m_settings->WidthAB();
111 // mark selected range
112 if (m_draw_debug_graph) {
113 (new TLine(left, 0, left, hist->GetMaximum()))->Write("tmax_height_left");
114 (new TLine(right, 0, right, hist->GetMaximum()))->Write("tmax_height_right");
115 }
116 return true;
117 }
Double_t myexp(Double_t *x, Double_t *p)

◆ GetA()

double MuonCalib::MTTmaxPatternRecognition::GetA ( ) const
inline

get parameter a in exp-function representing the end of the spectrum

Definition at line 63 of file MTTmaxPatternRecognition.h.

63{ return m_a; }

◆ GetB()

double MuonCalib::MTTmaxPatternRecognition::GetB ( ) const
inline

get parameter a in exp-function representing the end of the spectrum

Definition at line 66 of file MTTmaxPatternRecognition.h.

66{ return m_b; }

◆ GetBackground()

double MuonCalib::MTTmaxPatternRecognition::GetBackground ( ) const
inline

get the background level

Definition at line 60 of file MTTmaxPatternRecognition.h.

60{ return m_background; }

◆ GetError()

bool MuonCalib::MTTmaxPatternRecognition::GetError ( ) const
inline

return error flag

Definition at line 78 of file MTTmaxPatternRecognition.h.

78{ return m_error; }

◆ GetEstimatedTMax()

double MuonCalib::MTTmaxPatternRecognition::GetEstimatedTMax ( ) const
inline

get estimated t0

Definition at line 69 of file MTTmaxPatternRecognition.h.

69{ return m_tmax_est; }

◆ GetFitRangeMax()

double MuonCalib::MTTmaxPatternRecognition::GetFitRangeMax ( ) const
inline

get fit range

Definition at line 75 of file MTTmaxPatternRecognition.h.

75{ return m_fit_max; }

◆ GetFitRangeMin()

double MuonCalib::MTTmaxPatternRecognition::GetFitRangeMin ( ) const
inline

get fit range

Definition at line 72 of file MTTmaxPatternRecognition.h.

72{ return m_fit_min; }

◆ Initialize()

bool MuonCalib::MTTmaxPatternRecognition::Initialize ( TH1F * hist,
double t0,
const T0MTSettings * settings )

Initialize class.

Parameters
histHistogram which is to be fitted
t0comes from the t0 fit

Definition at line 20 of file MTTmaxPatternRecognition.cxx.

20 {
21 m_settings = settings->TMaxSettings();
22 m_draw_debug_graph = settings->DrawDebugGraphs();
23 m_error = false;
24 m_t0 = t0;
25 m_error = !m_vbh.Initialize(hist, m_settings->VBHBinContent(), m_settings->MaxBinwidth(), t0 + m_settings->VBHLow());
26 if (m_error || m_vbh.GetNumberOfBins() < 2) {
27 MsgStream log(Athena::getMessageSvc(), "MTTmaxPatternRecognition");
28 log << MSG::WARNING << "Initialize() - Initialization of VBH failed!" << endmsg;
29 }
30 if (!m_error) estimate_background(hist);
31 if (!m_error) estimate_height(hist);
32 return !m_error;
33 }
static Double_t t0
bool estimate_background(TH1F *hist)
estimates the background level
bool estimate_height(TH1F *hist)
estimates the height of the spectrum.

Member Data Documentation

◆ m_a

double MuonCalib::MTTmaxPatternRecognition::m_a
private

parameters a, b in a*exp(b*x)

Definition at line 90 of file MTTmaxPatternRecognition.h.

◆ m_b

double MuonCalib::MTTmaxPatternRecognition::m_b
private

Definition at line 90 of file MTTmaxPatternRecognition.h.

◆ m_background

double MuonCalib::MTTmaxPatternRecognition::m_background
private

background level

Definition at line 87 of file MTTmaxPatternRecognition.h.

◆ m_draw_debug_graph

bool MuonCalib::MTTmaxPatternRecognition::m_draw_debug_graph
private

Definition at line 84 of file MTTmaxPatternRecognition.h.

◆ m_error

bool MuonCalib::MTTmaxPatternRecognition::m_error
private

error flag

Definition at line 105 of file MTTmaxPatternRecognition.h.

◆ m_fit_max

double MuonCalib::MTTmaxPatternRecognition::m_fit_max
private

Definition at line 93 of file MTTmaxPatternRecognition.h.

◆ m_fit_min

double MuonCalib::MTTmaxPatternRecognition::m_fit_min
private

fit range

Definition at line 93 of file MTTmaxPatternRecognition.h.

◆ m_settings

const T0MTSettingsTMax* MuonCalib::MTTmaxPatternRecognition::m_settings
private

settings

Definition at line 83 of file MTTmaxPatternRecognition.h.

◆ m_t0

double MuonCalib::MTTmaxPatternRecognition::m_t0
private

t0

Definition at line 102 of file MTTmaxPatternRecognition.h.

◆ m_tmax_est

double MuonCalib::MTTmaxPatternRecognition::m_tmax_est
private

t0 estimate

Definition at line 96 of file MTTmaxPatternRecognition.h.

◆ m_vbh

VariableBinwidthHistogram MuonCalib::MTTmaxPatternRecognition::m_vbh
private

Variable binwidth histogram.

Definition at line 99 of file MTTmaxPatternRecognition.h.


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