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

#include <PixelResidualHistograms.h>

Collaboration diagram for PixelCalib::PixelResidualHistograms:

Public Member Functions

 PixelResidualHistograms (const std::string &name, const std::string &title, double limits, int nbins, const std::vector< std::vector< float > > &binnage, const std::vector< std::string > &binnames)
 
virtual ~PixelResidualHistograms ()
 
void SetAxisTitle (const std::string &title)
 
void Fill (float residual, const std::vector< float > &parameters)
 
int Write (bool writebins=false)
 
int Read ()
 
TH1D * GetHisto (const int i)
 
TProfile * GetMeanProfile (const std::string &binname)
 
TProfile * GetRMSProfile (const std::string &binname)
 
TProfile * GetProfile (const int binnumber, bool RMS=false, bool savebins=false)
 
TH1D * GetGlobalHisto ()
 
std::vector< TCanvas * > * DrawProfiles (int color, int marker, float labely=0, std::vector< TCanvas * > *canvasvector=0, const std::string &name="")
 

Private Member Functions

 PixelResidualHistograms (const PixelResidualHistograms &)
 
PixelResidualHistogramsoperator= (const PixelResidualHistograms &)
 
 PixelResidualHistograms ()
 

Private Attributes

MultiHisto< TH1D > * m_HistogramsVector
 
std::vector< TProfile * > * m_MeanProfilesVector
 
std::vector< TProfile * > * m_RMSProfilesVector
 
TH1D * m_GlobalHisto
 
std::vector< std::string > m_binnames
 
std::vector< std::vector< float > > m_binnage
 
std::string m_axisName
 

Detailed Description

Definition at line 21 of file PixelResidualHistograms.h.

Constructor & Destructor Documentation

◆ PixelResidualHistograms() [1/3]

PixelCalib::PixelResidualHistograms::PixelResidualHistograms ( const std::string &  name,
const std::string &  title,
double  limits,
int  nbins,
const std::vector< std::vector< float > > &  binnage,
const std::vector< std::string > &  binnames 
)

Definition at line 25 of file PixelResidualHistograms.cxx.

30  :
34  m_GlobalHisto(0),
35  m_binnames(binnames),
36  m_binnage(binnage),
37  m_axisName(""){
38 
39  TH1D *Histomodel = new TH1D(name.c_str(),title.c_str(),nbins,-limits,limits);
41 
43 
44  m_MeanProfilesVector = new std::vector<TProfile*>(m_binnames.size());
45  m_RMSProfilesVector = new std::vector<TProfile*>(m_binnames.size());
46 
47  delete Histomodel;
48  Histomodel = 0;
49 
50 }

◆ ~PixelResidualHistograms()

PixelCalib::PixelResidualHistograms::~PixelResidualHistograms ( )
virtual

Definition at line 54 of file PixelResidualHistograms.cxx.

54  {
55 
56  delete m_HistogramsVector;
57  delete m_MeanProfilesVector;
58  delete m_RMSProfilesVector;
59 
63 
64 }

◆ PixelResidualHistograms() [2/3]

PixelCalib::PixelResidualHistograms::PixelResidualHistograms ( const PixelResidualHistograms )
private

◆ PixelResidualHistograms() [3/3]

PixelCalib::PixelResidualHistograms::PixelResidualHistograms ( )
inlineprivate

Definition at line 88 of file PixelResidualHistograms.h.

88 {};

Member Function Documentation

◆ DrawProfiles()

std::vector< TCanvas * > * PixelCalib::PixelResidualHistograms::DrawProfiles ( int  color,
int  marker,
float  labely = 0,
std::vector< TCanvas * > *  canvasvector = 0,
const std::string &  name = "" 
)

Definition at line 284 of file PixelResidualHistograms.cxx.

285  {
286 
287  SetAtlasStyle();
288  std::string drawoptions = "Psame";
289  std::string legend = name;
290  if(canvasvector == 0){
291  drawoptions = "P";
292  canvasvector = new std::vector<TCanvas*>();
293  for(unsigned int i = 0; i < 2 * m_MeanProfilesVector->size(); i++){
294  TCanvas *c1 = new TCanvas();
295  c1->UseCurrentStyle();
296  canvasvector->push_back(c1);
297  }
298  }else if( canvasvector->size() != 2 * m_MeanProfilesVector->size() ) return 0;
299 
300 
301  TProfile *swap = 0;
302  for(unsigned int i = 0; i < m_MeanProfilesVector->size(); i++){
303  // mean profile!
304  (*canvasvector)[i]->cd();
305  swap = GetProfile(i,false);
306  swap->UseCurrentStyle();
307  swap->SetLineColor(color);
308  swap->SetMarkerColor(color);
309  swap->SetMarkerStyle(marker);
310  swap->Draw(drawoptions.c_str());
311  swap->GetYaxis()->SetTitleOffset(1.2);
312  double maximum = swap->GetMaximum();
313  double minimum = swap->GetMinimum();
314  swap->SetMaximum(maximum + fabs(minimum) + fabs(maximum));
315  swap->SetMinimum(minimum - fabs(maximum) - fabs(minimum));
316 
317 
318  if(drawoptions == "P"){
319  size_t found = std::string(swap->GetTitle()).find("p_{T}");
320  if(found != std::string::npos) (*canvasvector)[i]->SetLogx();
321  (*canvasvector)[i]->SetGridy();
322  DrawTitleLatex(swap->GetTitle(), 0.2,0.87);
323  (*canvasvector)[i]->SetName(swap->GetName());
324  }
325  if(labely != 0){
326  if(legend == "") legend = swap->GetTitle();
327  DrawLegendLatex(legend.c_str(),marker,0.7,labely,color,0.04);
328  }
329 
330  // rms profile!
331  int i2 = i+m_MeanProfilesVector->size();
332  (*canvasvector)[i2]->cd();
333  swap = GetProfile(i,true);
334  swap->UseCurrentStyle();
335  swap->SetLineColor(color);
336  swap->SetMarkerColor(color);
337  swap->SetMarkerStyle(marker);
338  swap->Draw(drawoptions.c_str());
339  swap->GetYaxis()->SetTitleOffset(1.2);
340  swap->SetMaximum(2*fabs(swap->GetMaximum()));
341 
342 
343  if(drawoptions == "P"){
344  size_t found = std::string(swap->GetTitle()).find("p_{T}");
345  if(found != std::string::npos) (*canvasvector)[i2]->SetLogx();
346  (*canvasvector)[i2]->SetGridy();
347  DrawTitleLatex(swap->GetTitle(), 0.2,0.87);
348  (*canvasvector)[i2]->SetName(swap->GetName());
349  }
350  if(labely != 0){
351  if(legend == "") legend = swap->GetTitle();
352  DrawLegendLatex(legend.c_str(),marker,0.7,labely,color,0.04);
353  }
354 
355  }
356 
357  swap = 0;
358  return canvasvector;
359 }

◆ Fill()

void PixelCalib::PixelResidualHistograms::Fill ( float  residual,
const std::vector< float > &  parameters 
)

Definition at line 68 of file PixelResidualHistograms.cxx.

68  {
70 }

◆ GetGlobalHisto()

TH1D * PixelCalib::PixelResidualHistograms::GetGlobalHisto ( )

Definition at line 157 of file PixelResidualHistograms.cxx.

157  {
158 
159 
160  if( m_GlobalHisto != 0) return m_GlobalHisto;
161 
162  TH1 *swap = m_HistogramsVector->GetHisto(0);
163  double limits = swap->GetXaxis()->GetXmax();
164  int nbins = swap->GetNbinsX();
165  std::string name = m_HistogramsVector->GetName() + std::string("_global");
166  std::string title = m_HistogramsVector->GetTitle();
167 
168  m_GlobalHisto = new TH1D(name.c_str(), title.c_str(),
169  nbins,-limits,limits);
170  m_GlobalHisto->GetXaxis()->SetTitle(title.c_str());
171 
172  for(unsigned int i = 0 ; i < m_HistogramsVector->GetNhistos(); i++){
173  swap = GetHisto(i);
174  m_GlobalHisto->Add(swap);
175  }
176 
177  return m_GlobalHisto;
178 
179 }

◆ GetHisto()

TH1D * PixelCalib::PixelResidualHistograms::GetHisto ( const int  i)

Definition at line 131 of file PixelResidualHistograms.cxx.

131  {
132  return m_HistogramsVector->GetHisto(i);
133 }

◆ GetMeanProfile()

TProfile * PixelCalib::PixelResidualHistograms::GetMeanProfile ( const std::string &  binname)

Definition at line 137 of file PixelResidualHistograms.cxx.

137  {
138 
139  for(unsigned int i = 0; i < m_binnames.size(); i++)
140  if(m_binnames[i] == binname) return GetProfile(i,false);
141  return 0;
142 
143 }

◆ GetProfile()

TProfile * PixelCalib::PixelResidualHistograms::GetProfile ( const int  binnumber,
bool  RMS = false,
bool  savebins = false 
)

Definition at line 183 of file PixelResidualHistograms.cxx.

183  {
184 
185  // check if it has already been calculated!
186  if(RMS && (*m_RMSProfilesVector)[binnumber] != 0)
187  return (*m_RMSProfilesVector)[binnumber];
188  else if( (*m_MeanProfilesVector)[binnumber] != 0)
189  return (*m_MeanProfilesVector)[binnumber];
190 
191  // Allocate the new TProfile
192  int nProfileBins = ( m_binnage[binnumber] ).size() - 1;
193  float* xbins = new float[nProfileBins+1];
194  std::string Xvar_name = m_binnames[binnumber];
195  std::string Xvar_name_s = Xvar_name;
196  size_t found0 = Xvar_name_s.find('#');
197  if(found0 != std::string::npos) Xvar_name_s.erase(Xvar_name_s.begin(), Xvar_name_s.begin()+found0+1);
198  size_t found1 = Xvar_name_s.find('_');
199  if(found1 != std::string::npos) Xvar_name_s.erase(Xvar_name_s.begin()+found1,Xvar_name_s.end());
200  for(int i = 0 ; i < nProfileBins+1 ; i++)
201  xbins[i] = (m_binnage[binnumber])[i];
202  std::string name = std::string(m_HistogramsVector->GetName());
203  std::string title = std::string(m_HistogramsVector->GetTitle());
204  std::string RMSname = name + std::string("_RMS_vs_") + Xvar_name_s;
205  std::string RMStitle = std::string("Resolution of ") +
206  title + std::string(" vs ") + Xvar_name;
207  name = name + std::string("_Mean_vs_") + Xvar_name_s;
208  title = std::string("Mean of ") + title + std::string(" vs ") + Xvar_name;
209 
210  TProfile *theMeanProfile = new TProfile( name.c_str(), title.c_str(),
211  nProfileBins, xbins);
212  TProfile *theRMSProfile = new TProfile( RMSname.c_str(), RMStitle.c_str(),
213  nProfileBins, xbins);
214 
215  theMeanProfile->GetXaxis()->SetTitle( Xvar_name.c_str() );
216  theRMSProfile->GetXaxis()->SetTitle( Xvar_name.c_str() );
217  theMeanProfile->GetYaxis()->SetTitle( (std::string("Mean of ") + m_axisName).c_str() );
218  theRMSProfile->GetYaxis()->SetTitle( (std::string("RMS of ") + m_axisName).c_str() );
219 
220  // fill it bin by bin
221  std::vector<int> indexes;
222  for(int ibin = 0; ibin < nProfileBins; ibin++){
223  // creating the histogram for this bin..
224  std::string bintitle = m_HistogramsVector->GetTitle();
225  std::ostringstream binname;
226  binname << m_HistogramsVector->GetName() << "vs" << Xvar_name_s << "_" << ibin;
227  TH1 *swap = m_HistogramsVector->GetHisto(0);
228  double limits = swap->GetXaxis()->GetXmax();
229  int nbins = swap->GetNbinsX();
230  TH1D *bin = new TH1D(binname.str().c_str(), bintitle.c_str(),
231  nbins,-limits,limits);
232  for(unsigned int i = 0 ; i < m_HistogramsVector->GetNhistos(); i++){
234  if(indexes[binnumber] == ibin){
235  swap = GetHisto(i);
236  bin->Add(swap);
237  }
238  }
239 
240  double entries = 0.;
241  double mean = 0.;
242  double mean_error = 0.;
243  double rms = 0.;
244  double rms_error = 0.;
245 
246  if(bin->GetEntries() > 50){
247  GetCoreParameters(bin,mean,mean_error,rms,rms_error,entries);
248  }
249 
250  if(entries > 1){
251  rms_error = sqrt( fabs(rms_error*rms_error*entries*entries
252  - rms*rms/entries));
253  mean_error = sqrt( fabs(mean_error*mean_error*entries*entries
254  + mean*mean/entries));
255  }
256 
257  theMeanProfile->SetBinContent(ibin+1,mean*entries);
258  theMeanProfile->SetBinError(ibin+1,mean_error);
259  theMeanProfile->SetBinEntries(ibin+1,entries);
260  theRMSProfile->SetBinContent(ibin+1,rms*entries);
261  theRMSProfile->SetBinError(ibin+1,rms_error);
262  theRMSProfile->SetBinEntries(ibin+1,entries);
263 
264  //std::cout << theMeanProfile->GetBinContent(ibin+1) << " "
265  //<< theMeanProfile->GetBinError(ibin+1) << std::endl;
266 
267  if(entries > 0 && savebis) bin->Write();
268  delete bin;
269  bin = 0;
270  swap = 0;
271 
272  }
273 
274  // put the calcuated profile in he correct place and return it!
275  (*m_MeanProfilesVector)[binnumber] = theMeanProfile;
276  (*m_RMSProfilesVector)[binnumber] = theRMSProfile;
277  if(RMS) return theRMSProfile;
278  else return theMeanProfile;
279 
280 }

◆ GetRMSProfile()

TProfile * PixelCalib::PixelResidualHistograms::GetRMSProfile ( const std::string &  binname)

Definition at line 147 of file PixelResidualHistograms.cxx.

147  {
148 
149  for(unsigned int i = 0; i < m_binnames.size(); i++)
150  if(m_binnames[i] == binname) return GetProfile(i,true);
151  return 0;
152 
153 }

◆ operator=()

PixelResidualHistograms& PixelCalib::PixelResidualHistograms::operator= ( const PixelResidualHistograms )
private

◆ Read()

int PixelCalib::PixelResidualHistograms::Read ( )

Definition at line 113 of file PixelResidualHistograms.cxx.

113  {
114 
115 
116  TDirectory *current = gDirectory;
117  TDirectory *globaldir = (TDirectory *)current->Get(m_HistogramsVector->GetName());
118  globaldir->cd();
119 
120  globaldir = (TDirectory *)gDirectory->Get(m_HistogramsVector->GetName());
121 
122  int readhistos = 0;
123  readhistos += m_HistogramsVector->FillFromFile(globaldir);
124 
125  current->cd();
126  return readhistos;
127 }

◆ SetAxisTitle()

void PixelCalib::PixelResidualHistograms::SetAxisTitle ( const std::string &  title)

Definition at line 74 of file PixelResidualHistograms.cxx.

74  {
75 
76  m_axisName = title;
77  for(unsigned int i = 0 ; i < m_HistogramsVector->GetNhistos() ; i++)
78  m_HistogramsVector->GetHisto(i)->GetXaxis()->SetTitle(title.c_str());
79 
80 
81 }

◆ Write()

int PixelCalib::PixelResidualHistograms::Write ( bool  writebins = false)

Definition at line 85 of file PixelResidualHistograms.cxx.

85  {
86 
87  TDirectory *current = gDirectory;
88  current->mkdir( m_HistogramsVector->GetName() )->cd();
89 
90  int writtenhistos = 0;
92  writtenhistos += m_HistogramsVector->GetNhistos();
93 
94  TProfile *swap = 0;
95  for(unsigned int i = 0; i < m_MeanProfilesVector->size(); i++){
96  swap = GetProfile(i,true,writebins);
97  if( swap->Write() ) writtenhistos++;
98  swap = GetProfile(i,false,writebins);
99  if( swap->Write() ) writtenhistos++;
100  }
101 
102  TH1D *swap2 = GetGlobalHisto();
103  if( swap2->Write() ) writtenhistos++;
104 
105  current->cd();
106  swap = 0;
107  swap2 = 0;
108  return writtenhistos;
109 }

Member Data Documentation

◆ m_axisName

std::string PixelCalib::PixelResidualHistograms::m_axisName
private

Definition at line 86 of file PixelResidualHistograms.h.

◆ m_binnage

std::vector< std::vector < float > > PixelCalib::PixelResidualHistograms::m_binnage
private

Definition at line 85 of file PixelResidualHistograms.h.

◆ m_binnames

std::vector< std::string > PixelCalib::PixelResidualHistograms::m_binnames
private

Definition at line 84 of file PixelResidualHistograms.h.

◆ m_GlobalHisto

TH1D* PixelCalib::PixelResidualHistograms::m_GlobalHisto
private

Definition at line 83 of file PixelResidualHistograms.h.

◆ m_HistogramsVector

MultiHisto< TH1D >* PixelCalib::PixelResidualHistograms::m_HistogramsVector
private

Definition at line 80 of file PixelResidualHistograms.h.

◆ m_MeanProfilesVector

std::vector< TProfile*>* PixelCalib::PixelResidualHistograms::m_MeanProfilesVector
private

Definition at line 81 of file PixelResidualHistograms.h.

◆ m_RMSProfilesVector

std::vector< TProfile*>* PixelCalib::PixelResidualHistograms::m_RMSProfilesVector
private

Definition at line 82 of file PixelResidualHistograms.h.


The documentation for this class was generated from the following files:
MultiHisto::Write
int Write(const char *name=0, Int_t option=0, Int_t bufsize=0) const
fillPileUpNoiseLumi.current
current
Definition: fillPileUpNoiseLumi.py:52
color
Definition: jFexInputByteStreamTool.cxx:25
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
PixelCalib::PixelResidualHistograms::m_axisName
std::string m_axisName
Definition: PixelResidualHistograms.h:86
SetAtlasStyle
void SetAtlasStyle()
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:17
MultiHisto::Fill
int Fill(double xvar, double yvar, const std::vector< double > &pars)
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
MultiHisto::GetHisto
ht * GetHisto(int globalindex)
extractSporadic.c1
c1
Definition: extractSporadic.py:134
bin
Definition: BinsDiffFromStripMedian.h:43
MultiHisto::GetNhistos
unsigned int GetNhistos() const
MultiHisto::GetDivisionsIndexes
std::vector< int > GetDivisionsIndexes(int globalindex) const
PixelCalib::PixelResidualHistograms::m_MeanProfilesVector
std::vector< TProfile * > * m_MeanProfilesVector
Definition: PixelResidualHistograms.h:81
MultiHisto< TH1D >
DrawLegendLatex
void DrawLegendLatex(const char *chartitle, int markertype, float x, float y, int color=1, float textsize=0.034)
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:127
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
PixelCalib::PixelResidualHistograms::m_binnames
std::vector< std::string > m_binnames
Definition: PixelResidualHistograms.h:84
python.Include.marker
string marker
Definition: Include.py:21
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
PixelCalib::PixelResidualHistograms::m_RMSProfilesVector
std::vector< TProfile * > * m_RMSProfilesVector
Definition: PixelResidualHistograms.h:82
PixelCalib::PixelResidualHistograms::SetAxisTitle
void SetAxisTitle(const std::string &title)
Definition: PixelResidualHistograms.cxx:74
PixelCalib::PixelResidualHistograms::m_binnage
std::vector< std::vector< float > > m_binnage
Definition: PixelResidualHistograms.h:85
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition: TrigEgammaMonitorHelper.py:81
DrawTitleLatex
void DrawTitleLatex(const char *chartitle, float x, float y, int color=1, float textsize=0.04)
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:97
covarianceTool.title
title
Definition: covarianceTool.py:542
GetCoreParameters
void GetCoreParameters(const TH1 *hist, double &mean, double &mean_error, double &rms, double &rms_error, double &nentries)
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/Macro/AtlasStyle.h:144
MultiHisto::GetTitle
virtual const char * GetTitle() const
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
DiTauMassTools::HistInfo::RMS
@ RMS
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:35
plotBeamSpotVxVal.legend
legend
Definition: plotBeamSpotVxVal.py:98
PixelCalib::PixelResidualHistograms::GetHisto
TH1D * GetHisto(const int i)
Definition: PixelResidualHistograms.cxx:131
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
entries
double entries
Definition: listroot.cxx:49
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
MultiHisto::FillFromFile
int FillFromFile(TDirectory *histodir=0)
MultiHisto::GetName
virtual const char * GetName() const
PixelCalib::PixelResidualHistograms::m_GlobalHisto
TH1D * m_GlobalHisto
Definition: PixelResidualHistograms.h:83
PixelCalib::PixelResidualHistograms::GetProfile
TProfile * GetProfile(const int binnumber, bool RMS=false, bool savebins=false)
Definition: PixelResidualHistograms.cxx:183
PixelCalib::PixelResidualHistograms::GetGlobalHisto
TH1D * GetGlobalHisto()
Definition: PixelResidualHistograms.cxx:157
PixelCalib::PixelResidualHistograms::m_HistogramsVector
MultiHisto< TH1D > * m_HistogramsVector
Definition: PixelResidualHistograms.h:80