CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
BscAnalysisHistManager Class Reference
Inheritance diagram for BscAnalysisHistManager:

Public Member Functions

 BscAnalysisHistManager (const TString &managername)
 
TH1F * getHisto (Int_t Number)
 
TH1F * getHisto (const TObjString &histname)
 
TH2F * getHisto2 (Int_t Number)
 
TH2F * getHisto2 (const TObjString &histname)
 
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 71 of file BscTest.cc.

Constructor & Destructor Documentation

◆ BscAnalysisHistManager()

BscAnalysisHistManager::BscAnalysisHistManager ( const TString &  managername)

Definition at line 211 of file BscTest.cc.

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

211  {
212  // The Constructor
213 
214  fTypeTitle = managername;
215  fHistArray = new TObjArray(); // Array to store histos
216  fHistNamesArray = new TObjArray(); // Array to store histos's names
217 
218  bookHistos();
219 
220  fHistArray->Compress(); // Removes empty space
221  fHistNamesArray->Compress();
222 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:93
TObjArray * fHistArray
Definition: BscTest.cc:92
const char * fTypeTitle
Definition: BscTest.cc:91

◆ ~BscAnalysisHistManager()

BscAnalysisHistManager::~BscAnalysisHistManager ( )
override

Definition at line 225 of file BscTest.cc.

References fHistArray, and fHistNamesArray.

225  {
226  // The Destructor
227 
228  if (fHistArray) {
229  fHistArray->Delete();
230  delete fHistArray;
231  }
232 
233  if (fHistNamesArray) {
234  fHistNamesArray->Delete();
235  delete fHistNamesArray;
236  }
237 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:93
TObjArray * fHistArray
Definition: BscTest.cc:92

Member Function Documentation

◆ bookHistos()

void BscAnalysisHistManager::bookHistos ( )
private

Definition at line 240 of file BscTest.cc.

References histInit().

Referenced by BscAnalysisHistManager().

240  {
241  // at Start: (mm)
242  histInit("TrackPhi", "Primary Phi", 100, 0., 360.);
243  histInit("TrackTheta", "Primary Theta", 100, 0., 180.);
244  histInit("TrackP", "Track XY position Z+ ", 80, -80., 80., 80, -80., 80.);
245  histInit("TrackM", "Track XY position Z-", 80, -80., 80., 80, -80., 80.);
246  histInit("DetIDs", "Track DetId - vs +", 16, -0.5, 15.5, 16, 15.5, 31.5);
247 }
void histInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: BscTest.cc:265

◆ getHisto() [1/2]

TH1F * BscAnalysisHistManager::getHisto ( Int_t  Number)

Definition at line 292 of file BscTest.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

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

292  {
293  // Get a histogram from the array with index = Number
294 
295  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
296  return (TH1F*)(fHistArray->At(Number));
297 
298  } else {
299  edm::LogVerbatim("BscTest") << "!!!!!!!!!!!!!!!!!!getHisto!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
300  edm::LogVerbatim("BscTest") << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number;
301  edm::LogVerbatim("BscTest") << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
302 
303  return (TH1F*)(fHistArray->At(0));
304  }
305 }
Log< level::Info, true > LogVerbatim
TObjArray * fHistArray
Definition: BscTest.cc:92

◆ getHisto() [2/2]

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

Definition at line 324 of file BscTest.cc.

References fHistNamesArray, and getHisto().

324  {
325  // Get a histogram from the array with name = histname
326 
327  Int_t index = fHistNamesArray->IndexOf(&histname);
328  return getHisto(index);
329 }
TH1F * getHisto(Int_t Number)
Definition: BscTest.cc:292
TObjArray * fHistNamesArray
Definition: BscTest.cc:93

◆ getHisto2() [1/2]

TH2F * BscAnalysisHistManager::getHisto2 ( Int_t  Number)

Definition at line 308 of file BscTest.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

Referenced by getHisto2().

308  {
309  // Get a histogram from the array with index = Number
310 
311  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
312  return (TH2F*)(fHistArray->At(Number));
313 
314  } else {
315  edm::LogVerbatim("BscTest") << "!!!!!!!!!!!!!!!!getHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!";
316  edm::LogVerbatim("BscTest") << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number;
317  edm::LogVerbatim("BscTest") << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
318 
319  return (TH2F*)(fHistArray->At(0));
320  }
321 }
Log< level::Info, true > LogVerbatim
TObjArray * fHistArray
Definition: BscTest.cc:92

◆ getHisto2() [2/2]

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

Definition at line 332 of file BscTest.cc.

References fHistNamesArray, and getHisto2().

332  {
333  // Get a histogram from the array with name = histname
334 
335  Int_t index = fHistNamesArray->IndexOf(&histname);
336  return getHisto2(index);
337 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:93
TH2F * getHisto2(Int_t Number)
Definition: BscTest.cc:308

◆ 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 265 of file BscTest.cc.

References fHistArray, fHistNamesArray, fTypeTitle, mergeVDriftHistosByStation::name, totemT2DQMSource_cfi::nbinsx, and runGCPTkAlMap::title.

Referenced by bookHistos().

265  {
266  // Add histograms and histograms names to the array
267 
268  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
269  strcpy(newtitle, title);
270  strcat(newtitle, " (");
271  strcat(newtitle, fTypeTitle);
272  strcat(newtitle, ") ");
273  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
274  fHistNamesArray->AddLast(new TObjString(name));
275 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:93
TObjArray * fHistArray
Definition: BscTest.cc:92
const char * fTypeTitle
Definition: BscTest.cc:91

◆ 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 278 of file BscTest.cc.

References fHistArray, fHistNamesArray, fTypeTitle, mergeVDriftHistosByStation::name, totemT2DQMSource_cfi::nbinsx, totemT2DQMSource_cfi::nbinsy, and runGCPTkAlMap::title.

279  {
280  // Add histograms and histograms names to the array
281 
282  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
283  strcpy(newtitle, title);
284  strcat(newtitle, " (");
285  strcat(newtitle, fTypeTitle);
286  strcat(newtitle, ") ");
287  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
288  fHistNamesArray->AddLast(new TObjString(name));
289 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:93
TObjArray * fHistArray
Definition: BscTest.cc:92
const char * fTypeTitle
Definition: BscTest.cc:91

◆ storeWeights()

void BscAnalysisHistManager::storeWeights ( )
private

Definition at line 340 of file BscTest.cc.

References fHistArray, and mps_fire::i.

340  {
341  // Add structure to each histogram to store the weights
342 
343  for (int i = 0; i < fHistArray->GetEntries(); i++) {
344  ((TH1F*)(fHistArray->At(i)))->Sumw2();
345  }
346 }
TObjArray * fHistArray
Definition: BscTest.cc:92

◆ writeToFile()

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

Definition at line 251 of file BscTest.cc.

References fHistArray, and geometryDiff::file.

Referenced by BscTest::~BscTest().

251  {
252  //Write to file = fOutputFile
253 
254  edm::LogVerbatim("BscTest") << "================================================================";
255  edm::LogVerbatim("BscTest") << " Write this Analysis to File " << fOutputFile;
256  edm::LogVerbatim("BscTest") << "================================================================";
257 
258  TFile* file = new TFile(fOutputFile, fRecreateFile);
259 
260  fHistArray->Write();
261  file->Close();
262 }
Log< level::Info, true > LogVerbatim
TObjArray * fHistArray
Definition: BscTest.cc:92

Member Data Documentation

◆ fHistArray

TObjArray* BscAnalysisHistManager::fHistArray
private

◆ fHistNamesArray

TObjArray* BscAnalysisHistManager::fHistNamesArray
private

◆ fTypeTitle

const char* BscAnalysisHistManager::fTypeTitle
private

Definition at line 91 of file BscTest.cc.

Referenced by BscAnalysisHistManager(), and histInit().