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

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

216  {
217  // The Constructor
218 
219  fTypeTitle = managername;
220  fHistArray = new TObjArray(); // Array to store histos
221  fHistNamesArray = new TObjArray(); // Array to store histos's names
222 
223  bookHistos();
224 
225  fHistArray->Compress(); // Removes empty space
226  fHistNamesArray->Compress();
227 }
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 230 of file BscTest.cc.

References fHistArray, and fHistNamesArray.

230  {
231  // The Destructor
232 
233  if (fHistArray) {
234  fHistArray->Delete();
235  delete fHistArray;
236  }
237 
238  if (fHistNamesArray) {
239  fHistNamesArray->Delete();
240  delete fHistNamesArray;
241  }
242 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:93
TObjArray * fHistArray
Definition: BscTest.cc:92

Member Function Documentation

◆ bookHistos()

void BscAnalysisHistManager::bookHistos ( )
private

Definition at line 245 of file BscTest.cc.

References histInit().

Referenced by BscAnalysisHistManager().

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

◆ getHisto() [1/2]

TH1F * BscAnalysisHistManager::getHisto ( Int_t  Number)

Definition at line 297 of file BscTest.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

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

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

◆ getHisto() [2/2]

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

Definition at line 329 of file BscTest.cc.

References fHistNamesArray, and getHisto().

329  {
330  // Get a histogram from the array with name = histname
331 
332  Int_t index = fHistNamesArray->IndexOf(&histname);
333  return getHisto(index);
334 }
TH1F * getHisto(Int_t Number)
Definition: BscTest.cc:297
TObjArray * fHistNamesArray
Definition: BscTest.cc:93

◆ getHisto2() [1/2]

TH2F * BscAnalysisHistManager::getHisto2 ( Int_t  Number)

Definition at line 313 of file BscTest.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

Referenced by getHisto2().

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

◆ getHisto2() [2/2]

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

Definition at line 337 of file BscTest.cc.

References fHistNamesArray, and getHisto2().

337  {
338  // Get a histogram from the array with name = histname
339 
340  Int_t index = fHistNamesArray->IndexOf(&histname);
341  return getHisto2(index);
342 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:93
TH2F * getHisto2(Int_t Number)
Definition: BscTest.cc:313

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

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

Referenced by bookHistos().

270  {
271  // Add histograms and histograms names to the array
272 
273  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
274  strcpy(newtitle, title);
275  strcat(newtitle, " (");
276  strcat(newtitle, fTypeTitle);
277  strcat(newtitle, ") ");
278  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
279  fHistNamesArray->AddLast(new TObjString(name));
280 }
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 283 of file BscTest.cc.

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

284  {
285  // Add histograms and histograms names to the array
286 
287  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
288  strcpy(newtitle, title);
289  strcat(newtitle, " (");
290  strcat(newtitle, fTypeTitle);
291  strcat(newtitle, ") ");
292  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
293  fHistNamesArray->AddLast(new TObjString(name));
294 }
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 345 of file BscTest.cc.

References fHistArray, and mps_fire::i.

345  {
346  // Add structure to each histogram to store the weights
347 
348  for (int i = 0; i < fHistArray->GetEntries(); i++) {
349  ((TH1F*)(fHistArray->At(i)))->Sumw2();
350  }
351 }
TObjArray * fHistArray
Definition: BscTest.cc:92

◆ writeToFile()

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

Definition at line 256 of file BscTest.cc.

References fHistArray, and geometryDiff::file.

Referenced by BscTest::~BscTest().

256  {
257  //Write to file = fOutputFile
258 
259  edm::LogVerbatim("BscTest") << "================================================================";
260  edm::LogVerbatim("BscTest") << " Write this Analysis to File " << fOutputFile;
261  edm::LogVerbatim("BscTest") << "================================================================";
262 
263  TFile* file = new TFile(fOutputFile, fRecreateFile);
264 
265  fHistArray->Write();
266  file->Close();
267 }
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().