CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
BscAnalysisHistManager Class Reference

#include <BscTest.h>

Inheritance diagram for BscAnalysisHistManager:

Public Member Functions

 BscAnalysisHistManager (const TString &managername)
 
TH1F * GetHisto (const TObjString &histname)
 
TH1F * GetHisto (Int_t Number)
 
TH2F * GetHisto2 (const TObjString &histname)
 
TH2F * GetHisto2 (Int_t Number)
 
void WriteToFile (const TString &fOutputFile, const TString &fRecreateFile)
 
 ~BscAnalysisHistManager () override
 

Private Member Functions

void BookHistos ()
 
void HistInit (const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
 
void HistInit (const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup)
 
void StoreWeights ()
 

Private Attributes

TObjArray * fHistArray
 
TObjArray * fHistNamesArray
 
const char * fTypeTitle
 

Detailed Description

Definition at line 60 of file BscTest.h.

Constructor & Destructor Documentation

◆ BscAnalysisHistManager()

BscAnalysisHistManager::BscAnalysisHistManager ( const TString &  managername)

Definition at line 103 of file BscTest.cc.

103  {
104  // The Constructor
105 
106  fTypeTitle = managername;
107  fHistArray = new TObjArray(); // Array to store histos
108  fHistNamesArray = new TObjArray(); // Array to store histos's names
109 
110  BookHistos();
111 
112  fHistArray->Compress(); // Removes empty space
113  fHistNamesArray->Compress();
114 }

References BookHistos(), fHistArray, fHistNamesArray, and fTypeTitle.

◆ ~BscAnalysisHistManager()

BscAnalysisHistManager::~BscAnalysisHistManager ( )
override

Definition at line 117 of file BscTest.cc.

117  {
118  // The Destructor
119 
120  if (fHistArray) {
121  fHistArray->Delete();
122  delete fHistArray;
123  }
124 
125  if (fHistNamesArray) {
126  fHistNamesArray->Delete();
127  delete fHistNamesArray;
128  }
129 }

References fHistArray, and fHistNamesArray.

Member Function Documentation

◆ BookHistos()

void BscAnalysisHistManager::BookHistos ( )
private

Definition at line 132 of file BscTest.cc.

132  {
133  // at Start: (mm)
134  HistInit("TrackPhi", "Primary Phi", 100, 0., 360.);
135  HistInit("TrackTheta", "Primary Theta", 100, 0., 180.);
136  HistInit("TrackP", "Track XY position Z+ ", 80, -80., 80., 80, -80., 80.);
137  HistInit("TrackM", "Track XY position Z-", 80, -80., 80., 80, -80., 80.);
138  HistInit("DetIDs", "Track DetId - vs +", 16, -0.5, 15.5, 16, 15.5, 31.5);
139 }

References HistInit().

Referenced by BscAnalysisHistManager().

◆ GetHisto() [1/2]

TH1F * BscAnalysisHistManager::GetHisto ( const TObjString &  histname)

Definition at line 216 of file BscTest.cc.

216  {
217  // Get a histogram from the array with name = histname
218 
219  Int_t index = fHistNamesArray->IndexOf(&histname);
220  return GetHisto(index);
221 }

References fHistNamesArray, and GetHisto().

◆ GetHisto() [2/2]

TH1F * BscAnalysisHistManager::GetHisto ( Int_t  Number)

Definition at line 184 of file BscTest.cc.

184  {
185  // Get a histogram from the array with index = Number
186 
187  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
188  return (TH1F*)(fHistArray->At(Number));
189 
190  } else {
191  std::cout << "!!!!!!!!!!!!!!!!!!GetHisto!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
192  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
193  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
194 
195  return (TH1F*)(fHistArray->At(0));
196  }
197 }

References gather_cfg::cout, fHistArray, and HcalTBWriter_cfi::Number.

Referenced by GetHisto(), and BscTest::update().

◆ GetHisto2() [1/2]

TH2F * BscAnalysisHistManager::GetHisto2 ( const TObjString &  histname)

Definition at line 224 of file BscTest.cc.

224  {
225  // Get a histogram from the array with name = histname
226 
227  Int_t index = fHistNamesArray->IndexOf(&histname);
228  return GetHisto2(index);
229 }

References fHistNamesArray, and GetHisto2().

◆ GetHisto2() [2/2]

TH2F * BscAnalysisHistManager::GetHisto2 ( Int_t  Number)

Definition at line 200 of file BscTest.cc.

200  {
201  // Get a histogram from the array with index = Number
202 
203  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
204  return (TH2F*)(fHistArray->At(Number));
205 
206  } else {
207  std::cout << "!!!!!!!!!!!!!!!!GetHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
208  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
209  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
210 
211  return (TH2F*)(fHistArray->At(0));
212  }
213 }

References gather_cfg::cout, fHistArray, and HcalTBWriter_cfi::Number.

Referenced by GetHisto2().

◆ HistInit() [1/2]

void BscAnalysisHistManager::HistInit ( const char *  name,
const char *  title,
Int_t  nbinsx,
Axis_t  xlow,
Axis_t  xup 
)
private

Definition at line 157 of file BscTest.cc.

157  {
158  // Add histograms and histograms names to the array
159 
160  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
161  strcpy(newtitle, title);
162  strcat(newtitle, " (");
163  strcat(newtitle, fTypeTitle);
164  strcat(newtitle, ") ");
165  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
166  fHistNamesArray->AddLast(new TObjString(name));
167 }

References fHistArray, fHistNamesArray, fTypeTitle, Skims_PA_cff::name, and runGCPTkAlMap::title.

Referenced by BookHistos().

◆ HistInit() [2/2]

void BscAnalysisHistManager::HistInit ( const char *  name,
const char *  title,
Int_t  nbinsx,
Axis_t  xlow,
Axis_t  xup,
Int_t  nbinsy,
Axis_t  ylow,
Axis_t  yup 
)
private

Definition at line 170 of file BscTest.cc.

171  {
172  // Add histograms and histograms names to the array
173 
174  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
175  strcpy(newtitle, title);
176  strcat(newtitle, " (");
177  strcat(newtitle, fTypeTitle);
178  strcat(newtitle, ") ");
179  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
180  fHistNamesArray->AddLast(new TObjString(name));
181 }

References fHistArray, fHistNamesArray, fTypeTitle, Skims_PA_cff::name, and runGCPTkAlMap::title.

◆ StoreWeights()

void BscAnalysisHistManager::StoreWeights ( )
private

Definition at line 232 of file BscTest.cc.

232  {
233  // Add structure to each histogram to store the weights
234 
235  for (int i = 0; i < fHistArray->GetEntries(); i++) {
236  ((TH1F*)(fHistArray->At(i)))->Sumw2();
237  }
238 }

References fHistArray, and mps_fire::i.

◆ WriteToFile()

void BscAnalysisHistManager::WriteToFile ( const TString &  fOutputFile,
const TString &  fRecreateFile 
)

Definition at line 143 of file BscTest.cc.

143  {
144  //Write to file = fOutputFile
145 
146  std::cout << "================================================================" << std::endl;
147  std::cout << " Write this Analysis to File " << fOutputFile << std::endl;
148  std::cout << "================================================================" << std::endl;
149 
150  TFile* file = new TFile(fOutputFile, fRecreateFile);
151 
152  fHistArray->Write();
153  file->Close();
154 }

References gather_cfg::cout, fHistArray, and geometryDiff::file.

Referenced by BscTest::~BscTest().

Member Data Documentation

◆ fHistArray

TObjArray* BscAnalysisHistManager::fHistArray
private

◆ fHistNamesArray

TObjArray* BscAnalysisHistManager::fHistNamesArray
private

◆ fTypeTitle

const char* BscAnalysisHistManager::fTypeTitle
private

Definition at line 80 of file BscTest.h.

Referenced by BscAnalysisHistManager(), and HistInit().

runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
BscAnalysisHistManager::fTypeTitle
const char * fTypeTitle
Definition: BscTest.h:80
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalTBWriter_cfi.Number
Number
Definition: HcalTBWriter_cfi.py:19
BscAnalysisHistManager::BookHistos
void BookHistos()
Definition: BscTest.cc:132
BscAnalysisHistManager::GetHisto2
TH2F * GetHisto2(Int_t Number)
Definition: BscTest.cc:200
geometryDiff.file
file
Definition: geometryDiff.py:13
BscAnalysisHistManager::fHistArray
TObjArray * fHistArray
Definition: BscTest.h:81
BscAnalysisHistManager::GetHisto
TH1F * GetHisto(Int_t Number)
Definition: BscTest.cc:184
BscAnalysisHistManager::HistInit
void HistInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: BscTest.cc:157
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
BscAnalysisHistManager::fHistNamesArray
TObjArray * fHistNamesArray
Definition: BscTest.h:82