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

#include <MTTmaxPatternRecognition.h>

Collaboration diagram for MuonCalib::MTTmaxPatternRecognition:

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 36 of file MTTmaxPatternRecognition.h.

Constructor & Destructor Documentation

◆ MTTmaxPatternRecognition()

MuonCalib::MTTmaxPatternRecognition::MTTmaxPatternRecognition ( )
inline

Default constructor.

Definition at line 40 of file MTTmaxPatternRecognition.h.

40  :
41  m_settings(NULL),
42  m_draw_debug_graph(false),
43  m_background(0.),
44  m_a(0.),
45  m_b(0.),
46  m_fit_min(0.),
47  m_fit_max(0.),
48  m_tmax_est(0.),
49  m_t0(0.),
50  m_error(false) {}

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  }
48  if (m_draw_debug_graph) {
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
84  if (m_draw_debug_graph) {
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  }

◆ 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);
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  }

◆ 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;
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  }
32  return !m_error;
33  }

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:
MuonCalib::VariableBinwidthHistogram::GetBin
const VariableBinwidthHistogramBin & GetBin(unsigned int bin) const
Get a bin.
Definition: VariableBinwidthHistogram.h:71
generateReferenceFile.fun
fun
Definition: generateReferenceFile.py:18
MuonCalib::MTTmaxPatternRecognition::m_t0
double m_t0
t0
Definition: MTTmaxPatternRecognition.h:102
MuonCalib::T0MTSettingsTMax::WidthAB
double WidthAB() const
Width of the region in which the parameters a and b are estimated.
Definition: T0MTSettingsTMax.h:77
MuonCalib::MTTmaxPatternRecognition::m_fit_max
double m_fit_max
Definition: MTTmaxPatternRecognition.h:93
plotmaker.hist
hist
Definition: plotmaker.py:148
MuonCalib::VariableBinwidthHistogram::DiffDensityGraph
TGraph * DiffDensityGraph() const
Plot graph with differential density.
Definition: VariableBinwidthHistogram.cxx:151
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
MuonCalib::MTTmaxPatternRecognition::m_b
double m_b
Definition: MTTmaxPatternRecognition.h:90
MuonCalib::T0MTSettingsTMax::VBHBinContent
double VBHBinContent() const
Number of hits per histogram bin for the VariableBinwidthHistogram The number is given relative to th...
Definition: T0MTSettingsTMax.h:39
MuonCalib::VariableBinwidthHistogram::DenistyGraph
TGraph * DenistyGraph() const
create density graph - density vs bin center
Definition: VariableBinwidthHistogram.cxx:113
MuonCalib::VariableBinwidthHistogram::GetNumberOfBins
unsigned int GetNumberOfBins() const
Get the number of bins
Definition: VariableBinwidthHistogram.h:85
MuonCalib::T0MTSettingsTMax::MaxBinwidth
double MaxBinwidth() const
Maximum bin width for the VariableBinwidthHistogram The bins will not be wider than this even if it m...
Definition: T0MTSettingsTMax.h:43
dqt_zlumi_pandas.bin2
bin2
Definition: dqt_zlumi_pandas.py:337
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::T0MTSettingsTMax::DistAB
double DistAB() const
Distance of the a/b region from the detected falling edge.
Definition: T0MTSettingsTMax.h:73
MuonCalib::MTTmaxPatternRecognition::m_tmax_est
double m_tmax_est
t0 estimate
Definition: MTTmaxPatternRecognition.h:96
MuonCalib::VariableBinwidthHistogram::DiffBinwidthGraph
TGraph * DiffBinwidthGraph() const
Plot graph with differential binwidth.
Definition: VariableBinwidthHistogram.cxx:166
MuonCalib::T0MTSettingsTMax::DistBackground
double DistBackground() const
distance between the detected falling edge and the begin of the background region
Definition: T0MTSettingsTMax.h:59
MuonCalib::MTTmaxPatternRecognition::m_background
double m_background
background level
Definition: MTTmaxPatternRecognition.h:87
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonCalib::VariableBinwidthHistogram::Smooth
bool Smooth(double width)
Removes steps that origin in a binning effekt.
Definition: VariableBinwidthHistogram.cxx:87
bin2
Definition: KillBinsByStrip.h:34
MuonCalib::MTTmaxPatternRecognition::m_settings
const T0MTSettingsTMax * m_settings
settings
Definition: MTTmaxPatternRecognition.h:83
MuonCalib::MTTmaxPatternRecognition::m_a
double m_a
parameters a, b in a*exp(b*x)
Definition: MTTmaxPatternRecognition.h:90
MuonCalib::VariableBinwidthHistogram::Initialize
bool Initialize(TH1F *hist, double binc_r, double max_bin_width, double min_x=-9e9, double max_x=9e9)
Initialize with new input histogram Returns on error false.
Definition: VariableBinwidthHistogram.cxx:22
MuonCalib::T0MTSettingsTMax::EndMin
double EndMin() const
The range of the falling edge of the spectrum is searched in a region after t0.
Definition: T0MTSettingsTMax.h:53
MuonCalib::T0MTSettingsTMax::EndMax
double EndMax() const
Definition: T0MTSettingsTMax.h:55
MuonCalib::MTTmaxPatternRecognition::m_error
bool m_error
error flag
Definition: MTTmaxPatternRecognition.h:105
dqt_zlumi_pandas.bin1
bin1
Definition: dqt_zlumi_pandas.py:336
MuonCalib::MTTmaxPatternRecognition::m_fit_min
double m_fit_min
fit range
Definition: MTTmaxPatternRecognition.h:93
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::VariableBinwidthHistogram::BinWidthGraph
TGraph * BinWidthGraph() const
Plot binwidth graph - binwidth versus bin center.
Definition: VariableBinwidthHistogram.cxx:127
MuonCalib::MTTmaxPatternRecognition::m_draw_debug_graph
bool m_draw_debug_graph
Definition: MTTmaxPatternRecognition.h:84
MuonCalib::VariableBinwidthHistogramBin::Right
double Right() const
Get right (upper) bin border.
Definition: VariableBinwidthHistogramBin.h:114
MuonCalib::MTTmaxPatternRecognition::m_vbh
VariableBinwidthHistogram m_vbh
Variable binwidth histogram.
Definition: MTTmaxPatternRecognition.h:99
MuonCalib::myexp
Double_t myexp(Double_t *x, Double_t *p)
Definition: MTTmaxPatternRecognition.cxx:18
MuonCalib::T0MTSettingsTMax::VBHLow
double VBHLow() const
For the pattern-recognition only a part of the drift time spectrum is used for creating the VariableB...
Definition: T0MTSettingsTMax.h:48
MuonCalib::MTTmaxPatternRecognition::estimate_height
bool estimate_height(TH1F *hist)
estimates the height of the spectrum.
Definition: MTTmaxPatternRecognition.cxx:99
MuonCalib::MTTmaxPatternRecognition::estimate_background
bool estimate_background(TH1F *hist)
estimates the background level
Definition: MTTmaxPatternRecognition.cxx:39