ATLAS Offline Software
Public Member Functions | Public Attributes | Private Types | Private Attributes | List of all members
RtGraph Class Reference

A class for generating a r-t and t-r graphs by binning the 2D histograms in Calibrator::rtHists in r ot t bins. More...

#include <Calibrator.h>

Collaboration diagram for RtGraph:

Public Member Functions

 RtGraph (TH2F *, int, const char *, bool, TDirectory *)
 the constructor More...
 
 ~RtGraph ()
 the destructor More...
 
 RtGraph (const RtGraph &other)=delete
 copy constructor More...
 
RtGraphoperator= (const RtGraph &other)=delete
 assignment More...
 

Public Attributes

std::vector< double > rval
 array of the histograms for all bins More...
 
std::vector< double > tval
 the r values More...
 
TGraphErrors * trgr
 the t(r) graph More...
 
TGraphErrors * rtgr
 the r(t) graph More...
 
int npoints
 the number of graph points More...
 
float mintime
 the minimum t-value More...
 

Private Types

enum  bintype { LOW, GOOD, HIGH, EMPTY }
 

Private Attributes

std::string m_chname
 the histogram name More...
 
std::string m_chtit
 the histogram title More...
 
bintypem_btype
 
float * m_rightsig
 
float * m_leftsig
 
float * m_maxval
 
float * m_leftval
 
float * m_rightval
 
float m_mean
 
float m_mindistance
 
int * m_maxbin
 
int m_ipoint
 
float m_t
 
float m_d
 
float m_et
 
float m_ed
 
float * m_tv
 
float * m_dv
 
float * m_etv
 
float * m_edv
 

Detailed Description

A class for generating a r-t and t-r graphs by binning the 2D histograms in Calibrator::rtHists in r ot t bins.

Definition at line 34 of file Calibrator.h.

Member Enumeration Documentation

◆ bintype

enum RtGraph::bintype
private
Enumerator
LOW 
GOOD 
HIGH 
EMPTY 

Definition at line 51 of file Calibrator.h.

51 {LOW, GOOD, HIGH, EMPTY};

Constructor & Destructor Documentation

◆ RtGraph() [1/2]

RtGraph::RtGraph ( TH2F *  rtHist,
int  binvar,
const char *  binlabel,
bool  pflag,
TDirectory *  dir 
)

the constructor

Definition at line 118 of file Calibrator.cxx.

118  {
119 
120  int fitresult;
121  npoints = binvar==0 ? rtHist->GetNbinsX() : rtHist->GetNbinsY() ;
122 
123 
124  m_mean = -20.0;
125  m_t = -20.0;
126  m_d = -20.0;
127  m_et = -20.0;
128  m_ed = -20.0;
129  // m_ff = nullptr ;
130 
131 
132  TH1D** hslizes = new TH1D*[npoints];
133  m_btype = new bintype[npoints];
134  m_tv = new float[npoints];
135  m_dv = new float[npoints];
136  m_etv = new float[npoints];
137  m_edv = new float[npoints];
138  m_rightsig = new float[npoints];
139  m_leftsig = new float[npoints];
140  m_leftval = new float[npoints];
141  m_rightval = new float[npoints];
142  m_maxbin = new int[npoints];
143  m_maxval = new float[npoints];
144 
145  m_ipoint=0;
146  mintime=999;
147  m_mindistance=0;
148 
149  if (pflag){
150  TDirectory* binhistdir = dir->mkdir("binhist");
151  binhistdir->cd();
152  std::cout << " Calibrator::RtGraph: " << " Directory " << std::string(binhistdir->GetPath()) << " binlabel " << std::string(binlabel) << std::endl;
153  }
154 
155  std::cout << " Calibrator::RtGraph: " << " number of points " << npoints << " binvar " << binvar << std::endl;
156  // check and classify the bin-histograms
157  for (int i=0;i<npoints;i++) {
158 
159  m_chname = std::string(Form("%s slize_%i",binlabel,i));
160  m_chtit = binvar==0 ? std::string(Form("bin %i : %4.2f < %s < %4.2f [ns]",i,rtHist->GetXaxis()->GetBinLowEdge(i+1),binlabel,rtHist->GetXaxis()->GetBinUpEdge(i+1))) :
161  std::string(Form("bin %i : %4.2f < %s < %4.2f [mm]",i,rtHist->GetYaxis()->GetBinLowEdge(i+1),binlabel,rtHist->GetYaxis()->GetBinUpEdge(i+1))) ;
162  hslizes[i] = binvar==0 ? rtHist->ProjectionY(m_chname.data(),i+1,i+1) :
163  rtHist->ProjectionX(m_chname.data(),i+1,i+1);
164  hslizes[i]->SetTitle(m_chtit.data());
165  if (!pflag){
166  hslizes[i]->SetDirectory(nullptr);
167  }
168 
169  m_maxbin[i]=1; m_maxval[i]=0;
170  for (int j=1;j<=hslizes[i]->GetNbinsX();j++) {
171  float val=hslizes[i]->GetBinContent(j);
172  if (val>m_maxval[i]){
173  m_maxval[i]=val;
174  m_maxbin[i]=j;
175  m_leftval[i] = hslizes[i]->GetBinContent(j-1);
176  m_rightval[i] = hslizes[i]->GetBinContent(j+1);
177  }
178  }
179 
180  if(m_maxval[i]==0) m_maxval[i]=1.0e-4;
181  m_rightsig[i] = m_rightval[i]==0 ? 100 : std::sqrt(m_maxval[i])/m_maxval[i] + std::sqrt(m_rightval[i])/m_rightval[i];
182  m_leftsig[i] = m_leftval[i]==0 ? 100 : std::sqrt(m_maxval[i])/m_maxval[i] + std::sqrt(m_leftval[i])/m_leftval[i];
183 
184  m_btype[i]=EMPTY;
185  if(true){
186  m_btype[i]=GOOD;
187  m_btype[i-1]=GOOD;
188  }
189  else{
190  if (hslizes[i]->GetEntries()>0){
191  if (i<(float)hslizes[i]->GetNbinsX()/2) m_btype[i]=LOW;
192  else m_btype[i]=HIGH;
193  }
194  }
195  int rtEntries = rtHist->GetEntries();
196  if(rtEntries==0) rtEntries=1;
197  printf("%s ... %8f %8i %4i %8f %8f %4i\n", m_chtit.data(), (float)hslizes[i]->GetEntries()/(float)rtEntries, (int)hslizes[i]->GetEntries(), m_maxbin[i], m_leftsig[i], m_rightsig[i], m_btype[i]);
198  }
199 
200  float frmin=0,frmax=0;
201  for (int i=0;i<npoints;i++) {
202 
203  // prepare initial fit parameters
204  m_mean=hslizes[i]->GetBinCenter(m_maxbin[i]);
205  if (m_btype[i]==LOW) {frmin = hslizes[i]->GetBinCenter(1); frmax = hslizes[i]->GetBinCenter(m_maxbin[i]+4);}
206  if (m_btype[i]==GOOD) {frmin = hslizes[i]->GetBinCenter(m_maxbin[i]-3); frmax = hslizes[i]->GetBinCenter(m_maxbin[i]+3);}
207  if (m_btype[i]==HIGH) {frmin = hslizes[i]->GetBinCenter(m_maxbin[i]-3); frmax = hslizes[i]->GetBinCenter(m_maxbin[i]+4);}
208 
209  std::unique_ptr<TF1> ff(new TF1("dtfitfunc","gaus"));
210 
211  ff->SetRange(frmin,frmax);
212 
213  m_t = binvar==0 ? rtHist->GetXaxis()->GetBinCenter(i+1) : rtHist->GetYaxis()->GetBinCenter(i+1);
214  m_et = binvar==0 ? rtHist->GetXaxis()->GetBinWidth(1)/std::sqrt(12.0) : rtHist->GetYaxis()->GetBinWidth(1)/std::sqrt(12.0);
215  m_d = 0;
216  m_ed = 0;
217 
218  if (m_btype[i]==LOW){
219  m_d = 0;
220  m_ed = 0;
221  }
222  if (m_btype[i]==HIGH){
223  m_d = 2;
224  m_ed = 0;
225  }
226  if (m_btype[i]==EMPTY){
227  m_d = 0;
228  m_ed = 0;
229  }
230  if (m_btype[i]==GOOD && hslizes[i]->GetEntries()>3){
231  if (m_btype[i-1]==GOOD){
232  fitresult=hslizes[i]->Fit("dtfitfunc","QR");
233  ff->SetRange(m_mean-1.0*ff->GetParameter(2), m_mean+1.0*ff->GetParameter(2));
234  fitresult=hslizes[i]->Fit("dtfitfunc","QR");
235  m_d = ff->GetParameter(1);
236  m_ed = ff->GetParError(1);
237  std::cout << fitresult << " " << m_ed << std::endl;
238  }
239  else{
240  m_d = 0;
241  m_ed = 0;
242  }
243  }
244 
245 
246  if (m_btype[i]==GOOD && m_ed!=0){
247  m_tv[m_ipoint]=m_t;
248  m_dv[m_ipoint]=m_d;
251  m_ipoint++;
252  if (binvar==0) {
253  rval.push_back(m_d);
254  tval.push_back(m_t);
255  }
256  else {
257  rval.push_back(m_t);
258  tval.push_back(m_d);
259  }
260  }
261 
262 
263  if(m_d>=m_mindistance && m_t<mintime) mintime = m_t;
264 
265  }
266 
267  rtgr = binvar==0 ? new TGraphErrors(m_ipoint,m_tv,m_dv,m_etv,m_edv) : new TGraphErrors(m_ipoint,m_dv,m_tv,m_edv,m_etv);
268  rtgr->SetTitle((std::string("binning in ") + binlabel).data());
269  trgr = binvar==0 ? new TGraphErrors(m_ipoint,m_dv,m_tv,m_edv,m_etv) : new TGraphErrors(m_ipoint,m_tv,m_dv,m_etv,m_edv);
270  trgr->SetTitle((std::string("binning in ") + binlabel).data());
271 
272  rtgr->SetMarkerStyle(1) ;
273  rtgr->SetMarkerColor(2) ;
274  rtgr->SetLineColor(2) ;
275  rtgr->SetName("rtgraph") ;
276  trgr->SetMarkerStyle(1) ;
277  trgr->SetMarkerColor(2) ;
278  trgr->SetLineColor(2) ;
279  trgr->SetName("trgraph") ;
280 
281  dir->cd();
282  delete [] hslizes;
283 }

◆ ~RtGraph()

RtGraph::~RtGraph ( )

the destructor

Definition at line 287 of file Calibrator.cxx.

287  {
288 
289  delete [] m_btype ;
290  delete [] m_tv ;
291  delete [] m_dv ;
292  delete [] m_etv ;
293  delete [] m_edv ;
294  delete [] m_rightsig ;
295  delete [] m_leftsig ;
296  delete [] m_leftval ;
297  delete [] m_rightval ;
298  delete [] m_maxbin ;
299  delete [] m_maxval ;
300 }

◆ RtGraph() [2/2]

RtGraph::RtGraph ( const RtGraph other)
delete

copy constructor

Member Function Documentation

◆ operator=()

RtGraph& RtGraph::operator= ( const RtGraph other)
delete

assignment

Member Data Documentation

◆ m_btype

bintype* RtGraph::m_btype
private

Definition at line 52 of file Calibrator.h.

◆ m_chname

std::string RtGraph::m_chname
private

the histogram name

Definition at line 49 of file Calibrator.h.

◆ m_chtit

std::string RtGraph::m_chtit
private

the histogram title

Definition at line 50 of file Calibrator.h.

◆ m_d

float RtGraph::m_d
private

Definition at line 63 of file Calibrator.h.

◆ m_dv

float* RtGraph::m_dv
private

Definition at line 67 of file Calibrator.h.

◆ m_ed

float RtGraph::m_ed
private

Definition at line 65 of file Calibrator.h.

◆ m_edv

float* RtGraph::m_edv
private

Definition at line 69 of file Calibrator.h.

◆ m_et

float RtGraph::m_et
private

Definition at line 64 of file Calibrator.h.

◆ m_etv

float* RtGraph::m_etv
private

Definition at line 68 of file Calibrator.h.

◆ m_ipoint

int RtGraph::m_ipoint
private

Definition at line 61 of file Calibrator.h.

◆ m_leftsig

float* RtGraph::m_leftsig
private

Definition at line 54 of file Calibrator.h.

◆ m_leftval

float* RtGraph::m_leftval
private

Definition at line 56 of file Calibrator.h.

◆ m_maxbin

int* RtGraph::m_maxbin
private

Definition at line 60 of file Calibrator.h.

◆ m_maxval

float* RtGraph::m_maxval
private

Definition at line 55 of file Calibrator.h.

◆ m_mean

float RtGraph::m_mean
private

Definition at line 58 of file Calibrator.h.

◆ m_mindistance

float RtGraph::m_mindistance
private

Definition at line 59 of file Calibrator.h.

◆ m_rightsig

float* RtGraph::m_rightsig
private

Definition at line 53 of file Calibrator.h.

◆ m_rightval

float* RtGraph::m_rightval
private

Definition at line 57 of file Calibrator.h.

◆ m_t

float RtGraph::m_t
private

Definition at line 62 of file Calibrator.h.

◆ m_tv

float* RtGraph::m_tv
private

Definition at line 66 of file Calibrator.h.

◆ mintime

float RtGraph::mintime

the minimum t-value

Definition at line 47 of file Calibrator.h.

◆ npoints

int RtGraph::npoints

the number of graph points

Definition at line 46 of file Calibrator.h.

◆ rtgr

TGraphErrors* RtGraph::rtgr

the r(t) graph

Definition at line 45 of file Calibrator.h.

◆ rval

std::vector<double> RtGraph::rval

array of the histograms for all bins

the r values

Definition at line 42 of file Calibrator.h.

◆ trgr

TGraphErrors* RtGraph::trgr

the t(r) graph

Definition at line 44 of file Calibrator.h.

◆ tval

std::vector<double> RtGraph::tval

the r values

Definition at line 43 of file Calibrator.h.


The documentation for this class was generated from the following files:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
RtGraph::HIGH
@ HIGH
Definition: Calibrator.h:51
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
RtGraph::GOOD
@ GOOD
Definition: Calibrator.h:51
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
RtGraph::m_tv
float * m_tv
Definition: Calibrator.h:66
RtGraph::tval
std::vector< double > tval
the r values
Definition: Calibrator.h:43
RtGraph::EMPTY
@ EMPTY
Definition: Calibrator.h:51
RtGraph::m_rightval
float * m_rightval
Definition: Calibrator.h:57
lumiFormat.i
int i
Definition: lumiFormat.py:85
D3PDSizeSummary.ff
ff
Definition: D3PDSizeSummary.py:305
RtGraph::m_btype
bintype * m_btype
Definition: Calibrator.h:52
RtGraph::m_mindistance
float m_mindistance
Definition: Calibrator.h:59
RtGraph::m_leftval
float * m_leftval
Definition: Calibrator.h:56
RtGraph::m_chname
std::string m_chname
the histogram name
Definition: Calibrator.h:49
RtGraph::m_d
float m_d
Definition: Calibrator.h:63
RtGraph::m_rightsig
float * m_rightsig
Definition: Calibrator.h:53
RtGraph::m_leftsig
float * m_leftsig
Definition: Calibrator.h:54
RtGraph::m_et
float m_et
Definition: Calibrator.h:64
beamspotman.dir
string dir
Definition: beamspotman.py:623
RtGraph::m_etv
float * m_etv
Definition: Calibrator.h:68
fitman.fitresult
fitresult
Definition: fitman.py:590
RtGraph::m_chtit
std::string m_chtit
the histogram title
Definition: Calibrator.h:50
RtGraph::m_mean
float m_mean
Definition: Calibrator.h:58
RtGraph::mintime
float mintime
the minimum t-value
Definition: Calibrator.h:47
RtGraph::LOW
@ LOW
Definition: Calibrator.h:51
RtGraph::trgr
TGraphErrors * trgr
the t(r) graph
Definition: Calibrator.h:44
RtGraph::m_maxval
float * m_maxval
Definition: Calibrator.h:55
RtGraph::m_dv
float * m_dv
Definition: Calibrator.h:67
RtGraph::rtgr
TGraphErrors * rtgr
the r(t) graph
Definition: Calibrator.h:45
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
RtGraph::m_edv
float * m_edv
Definition: Calibrator.h:69
RtGraph::m_ipoint
int m_ipoint
Definition: Calibrator.h:61
RtGraph::rval
std::vector< double > rval
array of the histograms for all bins
Definition: Calibrator.h:42
RtGraph::m_ed
float m_ed
Definition: Calibrator.h:65
RtGraph::npoints
int npoints
the number of graph points
Definition: Calibrator.h:46
RtGraph::m_maxbin
int * m_maxbin
Definition: Calibrator.h:60
RtGraph::bintype
bintype
Definition: Calibrator.h:51
RtGraph::m_t
float m_t
Definition: Calibrator.h:62