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

Constructor & Destructor Documentation

◆ BscAnalysisHistManager()

BscAnalysisHistManager::BscAnalysisHistManager ( const TString &  managername)

Definition at line 220 of file BscTest.cc.

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

220  {
221  // The Constructor
222 
223  fTypeTitle = managername;
224  fHistArray = new TObjArray(); // Array to store histos
225  fHistNamesArray = new TObjArray(); // Array to store histos's names
226 
227  bookHistos();
228 
229  fHistArray->Compress(); // Removes empty space
230  fHistNamesArray->Compress();
231 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:97
TObjArray * fHistArray
Definition: BscTest.cc:96
const char * fTypeTitle
Definition: BscTest.cc:95

◆ ~BscAnalysisHistManager()

BscAnalysisHistManager::~BscAnalysisHistManager ( )
override

Definition at line 234 of file BscTest.cc.

References fHistArray, and fHistNamesArray.

234  {
235  // The Destructor
236 
237  if (fHistArray) {
238  fHistArray->Delete();
239  delete fHistArray;
240  }
241 
242  if (fHistNamesArray) {
243  fHistNamesArray->Delete();
244  delete fHistNamesArray;
245  }
246 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:97
TObjArray * fHistArray
Definition: BscTest.cc:96

Member Function Documentation

◆ bookHistos()

void BscAnalysisHistManager::bookHistos ( )
private

Definition at line 249 of file BscTest.cc.

References histInit().

Referenced by BscAnalysisHistManager().

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

◆ getHisto() [1/2]

TH1F * BscAnalysisHistManager::getHisto ( Int_t  Number)

Definition at line 301 of file BscTest.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

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

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

◆ getHisto() [2/2]

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

Definition at line 333 of file BscTest.cc.

References fHistNamesArray, and getHisto().

333  {
334  // Get a histogram from the array with name = histname
335 
336  Int_t index = fHistNamesArray->IndexOf(&histname);
337  return getHisto(index);
338 }
TH1F * getHisto(Int_t Number)
Definition: BscTest.cc:301
TObjArray * fHistNamesArray
Definition: BscTest.cc:97

◆ getHisto2() [1/2]

TH2F * BscAnalysisHistManager::getHisto2 ( Int_t  Number)

Definition at line 317 of file BscTest.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

Referenced by getHisto2().

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

◆ getHisto2() [2/2]

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

Definition at line 341 of file BscTest.cc.

References fHistNamesArray, and getHisto2().

341  {
342  // Get a histogram from the array with name = histname
343 
344  Int_t index = fHistNamesArray->IndexOf(&histname);
345  return getHisto2(index);
346 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:97
TH2F * getHisto2(Int_t Number)
Definition: BscTest.cc:317

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

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

Referenced by bookHistos().

274  {
275  // Add histograms and histograms names to the array
276 
277  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
278  strcpy(newtitle, title);
279  strcat(newtitle, " (");
280  strcat(newtitle, fTypeTitle);
281  strcat(newtitle, ") ");
282  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
283  fHistNamesArray->AddLast(new TObjString(name));
284 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:97
TObjArray * fHistArray
Definition: BscTest.cc:96
const char * fTypeTitle
Definition: BscTest.cc:95

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

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

288  {
289  // Add histograms and histograms names to the array
290 
291  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
292  strcpy(newtitle, title);
293  strcat(newtitle, " (");
294  strcat(newtitle, fTypeTitle);
295  strcat(newtitle, ") ");
296  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
297  fHistNamesArray->AddLast(new TObjString(name));
298 }
TObjArray * fHistNamesArray
Definition: BscTest.cc:97
TObjArray * fHistArray
Definition: BscTest.cc:96
const char * fTypeTitle
Definition: BscTest.cc:95

◆ storeWeights()

void BscAnalysisHistManager::storeWeights ( )
private

Definition at line 349 of file BscTest.cc.

References fHistArray, and mps_fire::i.

349  {
350  // Add structure to each histogram to store the weights
351 
352  for (int i = 0; i < fHistArray->GetEntries(); i++) {
353  ((TH1F*)(fHistArray->At(i)))->Sumw2();
354  }
355 }
TObjArray * fHistArray
Definition: BscTest.cc:96

◆ writeToFile()

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

Definition at line 260 of file BscTest.cc.

References fHistArray, and geometryDiff::file.

Referenced by BscTest::~BscTest().

260  {
261  //Write to file = fOutputFile
262 
263  edm::LogVerbatim("BscTest") << "================================================================";
264  edm::LogVerbatim("BscTest") << " Write this Analysis to File " << fOutputFile;
265  edm::LogVerbatim("BscTest") << "================================================================";
266 
267  TFile* file = new TFile(fOutputFile, fRecreateFile);
268 
269  fHistArray->Write();
270  file->Close();
271 }
Log< level::Info, true > LogVerbatim
TObjArray * fHistArray
Definition: BscTest.cc:96

Member Data Documentation

◆ fHistArray

TObjArray* BscAnalysisHistManager::fHistArray
private

◆ fHistNamesArray

TObjArray* BscAnalysisHistManager::fHistNamesArray
private

◆ fTypeTitle

const char* BscAnalysisHistManager::fTypeTitle
private

Definition at line 95 of file BscTest.cc.

Referenced by BscAnalysisHistManager(), and histInit().