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

slightly more convenient legend class More...

#include <computils.h>

Collaboration diagram for Legend:

Public Member Functions

 Legend ()
 
 Legend (double x1, double x2, double y1, double y2)
 
 Legend (const Legend &legend)
 
 ~Legend ()
 
TLegend * legend ()
 
size_t size () const
 
double TextSize () const
 
int TextFont () const
 
double height () const
 
double width () const
 
void AddEntry (TObject *tobj, const std::string &s, const std::string &type="p")
 
void Draw ()
 

Private Attributes

TLegend * m_leg
 
double m_x [2]
 
double m_y [2]
 
std::vector< TObject * > m_obj
 
std::vector< std::string > m_entries
 
std::vector< std::string > m_type
 

Detailed Description

slightly more convenient legend class

Definition at line 333 of file computils.h.

Constructor & Destructor Documentation

◆ Legend() [1/3]

Legend::Legend ( )
inline

Definition at line 337 of file computils.h.

337  : m_leg(nullptr){
338  m_x[0]=0.0;
339  m_y[0]=0.0;
340  m_x[1]=0.0;
341  m_y[1]=0.0;
342  }

◆ Legend() [2/3]

Legend::Legend ( double  x1,
double  x2,
double  y1,
double  y2 
)
inline

Definition at line 344 of file computils.h.

344  : m_leg(nullptr) {
345  m_x[0]=x1;
346  m_y[0]=y1;
347  m_x[1]=x2;
348  m_y[1]=y2;
349  }

◆ Legend() [3/3]

Legend::Legend ( const Legend legend)
inline

Definition at line 354 of file computils.h.

354  : m_leg(legend.m_leg),
355  m_x{legend.m_x[0], legend.m_x[1]},
356  m_y{legend.m_y[0], legend.m_y[1]} { }

◆ ~Legend()

Legend::~Legend ( )
inline

Definition at line 358 of file computils.h.

358 { }

Member Function Documentation

◆ AddEntry()

void Legend::AddEntry ( TObject *  tobj,
const std::string &  s,
const std::string &  type = "p" 
)
inline

Definition at line 374 of file computils.h.

374  {
375  m_obj.push_back( tobj );
376  m_entries.push_back( s );
377  m_type.push_back( type );
378  }

◆ Draw()

void Legend::Draw ( )
inline

ha ! don't actually create the legend until we want to draw it, then we can determine the size etc automatically

Definition at line 380 of file computils.h.

380  {
381 
384 
385  double y0 = 0;
386 
387  if ( m_y[0]>0.5 ) {
388  y0 = m_y[1] - m_entries.size()*0.05;
389  }
390  else {
391  y0 = m_y[0];
392  m_y[1] = y0 + m_entries.size()*0.05;
393  }
394 
395  m_leg = new TLegend( m_x[0], y0, m_x[1], m_y[1] );
396 
397  m_leg->SetBorderSize(0);
398  m_leg->SetTextFont(42);
399  m_leg->SetTextSize(0.04);
400  m_leg->SetFillStyle(3000);
401  m_leg->SetFillColor(0);
402  m_leg->SetLineColor(0);
403 
404  for ( size_t i=0 ; i<m_entries.size() ; i++ ) {
405  m_leg->AddEntry( m_obj[i], m_entries[i].c_str(), m_type[i].c_str() );
406  }
407 
408  m_leg->Draw();
409  }

◆ height()

double Legend::height ( ) const
inline

Definition at line 370 of file computils.h.

370 { return m_y[1]-m_y[0]; }

◆ legend()

TLegend* Legend::legend ( )
inline

Definition at line 360 of file computils.h.

360 { return m_leg; }

◆ size()

size_t Legend::size ( ) const
inline

Definition at line 362 of file computils.h.

362  {
363  return m_entries.size();
364  }

◆ TextFont()

int Legend::TextFont ( ) const
inline

Definition at line 368 of file computils.h.

368 { return m_leg->GetTextFont(); }

◆ TextSize()

double Legend::TextSize ( ) const
inline

Definition at line 366 of file computils.h.

366 { return m_leg->GetTextSize(); }

◆ width()

double Legend::width ( ) const
inline

Definition at line 372 of file computils.h.

372 { return m_x[1]-m_x[0]; }

Member Data Documentation

◆ m_entries

std::vector<std::string> Legend::m_entries
private

Definition at line 420 of file computils.h.

◆ m_leg

TLegend* Legend::m_leg
private

Definition at line 414 of file computils.h.

◆ m_obj

std::vector<TObject*> Legend::m_obj
private

Definition at line 419 of file computils.h.

◆ m_type

std::vector<std::string> Legend::m_type
private

Definition at line 421 of file computils.h.

◆ m_x

double Legend::m_x[2]
private

Definition at line 416 of file computils.h.

◆ m_y

double Legend::m_y[2]
private

Definition at line 417 of file computils.h.


The documentation for this class was generated from the following file:
Legend::m_x
double m_x[2]
Definition: computils.h:416
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Legend::m_obj
std::vector< TObject * > m_obj
Definition: computils.h:419
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
Legend::m_type
std::vector< std::string > m_type
Definition: computils.h:421
Legend::legend
TLegend * legend()
Definition: computils.h:360
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
lumiFormat.i
int i
Definition: lumiFormat.py:85
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
Legend::m_entries
std::vector< std::string > m_entries
Definition: computils.h:420
MuonR4::SegmentFit::ParamDefs::y0
@ y0
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Legend::m_y
double m_y[2]
Definition: computils.h:417
Legend::m_leg
TLegend * m_leg
Definition: computils.h:414