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

#include <TH1TrkProp.h>

Collaboration diagram for TH1TrkProp:

Public Member Functions

 TH1TrkProp (const char *format, const char *rootFile, const char *dir, const char *ntuple, const char *xvariable, const char *xvariableName, const char *xunit, const char *cut, const char *cutName, const char *title, int nbinsx, double xlow, double xup, bool logy, bool fitGaus)
 
 ~TH1TrkProp ()
 

Private Member Functions

void setStyle (bool fitGauss)
 

Detailed Description

Definition at line 15 of file TH1TrkProp.h.

Constructor & Destructor Documentation

◆ TH1TrkProp()

TH1TrkProp::TH1TrkProp ( const char *  format,
const char *  rootFile,
const char *  dir,
const char *  ntuple,
const char *  xvariable,
const char *  xvariableName,
const char *  xunit,
const char *  cut,
const char *  cutName,
const char *  title,
int  nbinsx,
double  xlow,
double  xup,
bool  logy,
bool  fitGaus 
)

Definition at line 25 of file TH1TrkProp.cxx.

29  {
30 
31  gROOT->Reset();
32 
33  //new style
34  setStyle(fitGauss);
35 
36  //read rootFile
37  TFile* f = new TFile(rootFile,"read");
38  if (f->IsZombie()) {
39  cout<<"Error opening file"<<endl;
40  exit(-1);
41  } else {
42 
43 
44  //get directory
45  TDirectory* directory = (TDirectory*)f->Get(dir);
46 
47  //get ntuple (TTree)
48  TTree* tree = (TTree*)directory->Get(ntuple);
49 
50  //allocate the necessary memory for string concatenation
51  char* strTitle = new char[200];
52  char* strVarXUnit = new char[200];
53  char* strHist = new char[200];
54  char* strOutput = new char[200];
55  char* strHisto = new char[200];
56 
57  //concatenate strings
58  strcat(strcat(strcat(strcpy(strTitle,title)," ("),cutName),")");
59  strcat(strcat(strcpy(strVarXUnit,xvariableName)," "),xunit);
60  strcat(strcpy(strHist,xvariable)," >> histo");
61  strcat(strcat(strcat(strcat(strcpy(strOutput,title),"_"),cutName),"."),format);
62  strcat(strcat(strcpy(strHisto,title),"_"),cutName);
63 
64  //book 1D histo from ntuple(TTree)
65  TH1F* histo = new TH1F("histo",strTitle,nbinsx,xlow,xup);
66 
67  histo->GetXaxis()->SetTitle(strVarXUnit);
68  histo->GetYaxis()->SetTitle("Entries");
69 
70 
71  //create new canvas
72  TCanvas* canvas = new TCanvas("canvas",title,700,600);
73  canvas->cd();
74 
75  if (logy) {
76  canvas->SetLogy();
77  }
78 
79  //fill 1D histo
80  tree->Draw(strHist,cut,"E");
81 
82  //clone 1D histo
83  TH1F* hnew = (TH1F*)histo->Clone();
84  //hnew->SetName(strHisto);
85  //hnew->Sumw2();
86 
87  if (fitGauss){
88  histo->Fit("gaus");
89  }
90 
91  //save 1D-histo to file.format
92  canvas->Print(strOutput);
93 
94  //store histograms in root file
95  TFile *histTrkProp = new TFile("histTrkProp.root","update");
96  histTrkProp->cd();
97  hnew->Write(strHisto);
98  histTrkProp->Close();
99 
100  //close rootFile
101  f->Close();
102 
103  }
104 
105 }

◆ ~TH1TrkProp()

TH1TrkProp::~TH1TrkProp ( )

Definition at line 110 of file TH1TrkProp.cxx.

110  {
111 
112  cout<<"deleting TH1TrkProp object"<<endl;
113 
114 }

Member Function Documentation

◆ setStyle()

void TH1TrkProp::setStyle ( bool  fitGauss)
private

Definition at line 120 of file TH1TrkProp.cxx.

120  {
121  TStyle* style1D = new TStyle("style1D","Style for 1D-Histograms");
122  style1D->cd();
123  //pad
124  style1D->SetPadBorderMode(0);
125  style1D->SetPadColor(0);
126  style1D->SetPadTopMargin(0.21);
127  style1D->SetPadBottomMargin(0.12);
128  style1D->SetPadLeftMargin(0.12);
129  style1D->SetPadRightMargin(0.07);
130  //canvas
131  style1D->SetCanvasColor(0);
132  style1D->SetCanvasBorderMode(0);
133  //frame
134  style1D->SetFrameBorderMode(0);
135  //statistics
136  style1D->SetOptStat(1111110);
137  style1D->SetStatBorderSize(3);
138  style1D->SetStatColor(0);
139  style1D->SetStatFont(62);
140  style1D->SetStatFontSize(0.033);
141  style1D->SetStatTextColor(1);
142  style1D->SetStatStyle(1001);
143  style1D->SetStatX(0.993);
144  style1D->SetStatY(0.995);
145  style1D->SetStatW(0.27);
146  //histograms
147  style1D->SetMarkerColor(1);
148  style1D->SetMarkerStyle(20);
149  style1D->SetMarkerSize(0.8);
150  //title
151  style1D->SetTitleX(0.010);
152  style1D->SetTitleY(0.93);
153  style1D->SetTitleW(0.7);
154  style1D->SetTitleBorderSize(3);
155  style1D->SetTitleFont(72,"TITLE");
156  //axes
157  style1D->SetLabelFont(62,"X");
158  style1D->SetLabelFont(62,"Y");
159  style1D->SetTitleOffset(1.3,"Y");
160  //fitGauss
161  if (fitGauss){
162  style1D->SetStatFontSize(0.03);
163  style1D->SetStatW(0.2);
164  style1D->SetTitleW(0.6);
165  style1D->SetOptFit(1111);
166  }
167 
168 }

The documentation for this class was generated from the following files:
vtune_athena.format
format
Definition: vtune_athena.py:14
tree
TChain * tree
Definition: tile_monitor.h:30
TH1TrkProp::setStyle
void setStyle(bool fitGauss)
Definition: TH1TrkProp.cxx:120
logy
bool logy
Definition: listroot.cxx:45
DeMoScan.directory
string directory
Definition: DeMoScan.py:80
DeMoAtlasDataLoss.canvas
dictionary canvas
Definition: DeMoAtlasDataLoss.py:187
covarianceTool.title
title
Definition: covarianceTool.py:542
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
makeComparison.rootFile
rootFile
Definition: makeComparison.py:27
hist_file_dump.f
f
Definition: hist_file_dump.py:135
calibdata.exit
exit
Definition: calibdata.py:236
beamspotman.dir
string dir
Definition: beamspotman.py:623
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415