CMS 3D CMS Logo

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

Public Member Functions

 Fp420AnalysisHistManager (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)
 
 ~Fp420AnalysisHistManager () 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 66 of file FP420Test.cc.

Constructor & Destructor Documentation

◆ Fp420AnalysisHistManager()

Fp420AnalysisHistManager::Fp420AnalysisHistManager ( const TString &  managername)

Definition at line 254 of file FP420Test.cc.

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

254  {
255  // The Constructor
256 
257  fTypeTitle = managername;
258  fHistArray = new TObjArray(); // Array to store histos
259  fHistNamesArray = new TObjArray(); // Array to store histos's names
260 
261  TH1::AddDirectory(kFALSE);
262  bookHistos();
263 
264  fHistArray->Compress(); // Removes empty space
265  fHistNamesArray->Compress();
266 
267  // storeWeights(); // Store the weights
268 }
const char * fTypeTitle
Definition: FP420Test.cc:86
TObjArray * fHistArray
Definition: FP420Test.cc:87
TObjArray * fHistNamesArray
Definition: FP420Test.cc:88

◆ ~Fp420AnalysisHistManager()

Fp420AnalysisHistManager::~Fp420AnalysisHistManager ( )
override

Definition at line 271 of file FP420Test.cc.

References fHistArray, and fHistNamesArray.

271  {
272  // The Destructor
273 
274  if (fHistArray) {
275  fHistArray->Delete();
276  delete fHistArray;
277  }
278 
279  if (fHistNamesArray) {
280  fHistNamesArray->Delete();
281  delete fHistNamesArray;
282  }
283 }
TObjArray * fHistArray
Definition: FP420Test.cc:87
TObjArray * fHistNamesArray
Definition: FP420Test.cc:88

Member Function Documentation

◆ bookHistos()

void Fp420AnalysisHistManager::bookHistos ( )
private

Definition at line 286 of file FP420Test.cc.

References histInit().

Referenced by Fp420AnalysisHistManager().

286  {
287  // at Start: (mm)
288  histInit("PrimaryEta", "Primary Eta", 100, 9., 12.);
289  histInit("PrimaryPhigrad", "Primary Phigrad", 100, 0., 360.);
290  histInit("PrimaryTh", "Primary Th", 100, 0., 180.);
291  histInit("PrimaryLastpoZ", "Primary Lastpo Z", 100, -200., 430000.);
292  histInit("PrimaryLastpoX", "Primary Lastpo X Z<z4", 100, -30., 30.);
293  histInit("PrimaryLastpoY", "Primary Lastpo Y Z<z4", 100, -30., 30.);
294  histInit("XLastpoNumofpart", "Primary Lastpo X n>10", 100, -30., 30.);
295  histInit("YLastpoNumofpart", "Primary Lastpo Y n>10", 100, -30., 30.);
296  histInit("VtxX", "Vtx X", 100, -50., 50.);
297  histInit("VtxY", "Vtx Y", 100, -50., 50.);
298  histInit("VtxZ", "Vtx Z", 100, -200., 430000.);
299  // Book the histograms and add them to the array
300  histInit("SumEDep", "This is sum Energy deposited", 100, -1, 199.);
301  histInit("TrackL", "This is TrackL", 100, 0., 12000.);
302  histInit("zHits", "z Hits all events", 100, 400000., 430000.);
303  histInit("zHitsnoMI", "z Hits no MI", 100, 400000., 430000.);
304  histInit("zHitsTrLoLe", "z Hits TrLength bigger 8300", 100, 400000., 430000.);
305  histInit("NumberOfHits", "NumberOfHits", 100, 0., 300.);
306 }
void histInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: FP420Test.cc:324

◆ getHisto() [1/2]

TH1F * Fp420AnalysisHistManager::getHisto ( Int_t  Number)

Definition at line 351 of file FP420Test.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

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

351  {
352  // Get a histogram from the array with index = Number
353 
354  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
355  return (TH1F*)(fHistArray->At(Number));
356 
357  } else {
358  edm::LogVerbatim("FP420Test") << "!!!!!!!!!!!!!!!!!!getHisto!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
359  edm::LogVerbatim("FP420Test") << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number;
360  edm::LogVerbatim("FP420Test") << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
361 
362  return (TH1F*)(fHistArray->At(0));
363  }
364 }
Log< level::Info, true > LogVerbatim
TObjArray * fHistArray
Definition: FP420Test.cc:87

◆ getHisto() [2/2]

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

Definition at line 383 of file FP420Test.cc.

References fHistNamesArray, and getHisto().

383  {
384  // Get a histogram from the array with name = histname
385 
386  Int_t index = fHistNamesArray->IndexOf(&histname);
387  return getHisto(index);
388 }
TH1F * getHisto(Int_t Number)
Definition: FP420Test.cc:351
TObjArray * fHistNamesArray
Definition: FP420Test.cc:88

◆ getHisto2() [1/2]

TH2F * Fp420AnalysisHistManager::getHisto2 ( Int_t  Number)

Definition at line 367 of file FP420Test.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

Referenced by getHisto2().

367  {
368  // Get a histogram from the array with index = Number
369 
370  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
371  return (TH2F*)(fHistArray->At(Number));
372 
373  } else {
374  edm::LogVerbatim("FP420Test") << "!!!!!!!!!!!!!!!!getHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!";
375  edm::LogVerbatim("FP420Test") << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number;
376  edm::LogVerbatim("FP420Test") << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
377 
378  return (TH2F*)(fHistArray->At(0));
379  }
380 }
Log< level::Info, true > LogVerbatim
TObjArray * fHistArray
Definition: FP420Test.cc:87

◆ getHisto2() [2/2]

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

Definition at line 391 of file FP420Test.cc.

References fHistNamesArray, and getHisto2().

391  {
392  // Get a histogram from the array with name = histname
393 
394  Int_t index = fHistNamesArray->IndexOf(&histname);
395  return getHisto2(index);
396 }
TH2F * getHisto2(Int_t Number)
Definition: FP420Test.cc:367
TObjArray * fHistNamesArray
Definition: FP420Test.cc:88

◆ histInit() [1/2]

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

Definition at line 324 of file FP420Test.cc.

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

Referenced by bookHistos().

324  {
325  // Add histograms and histograms names to the array
326 
327  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
328  strcpy(newtitle, title);
329  strcat(newtitle, " (");
330  strcat(newtitle, fTypeTitle);
331  strcat(newtitle, ") ");
332  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
333  fHistNamesArray->AddLast(new TObjString(name));
334 }
const char * fTypeTitle
Definition: FP420Test.cc:86
TObjArray * fHistArray
Definition: FP420Test.cc:87
TObjArray * fHistNamesArray
Definition: FP420Test.cc:88

◆ histInit() [2/2]

void Fp420AnalysisHistManager::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 337 of file FP420Test.cc.

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

338  {
339  // Add histograms and histograms names to the array
340 
341  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
342  strcpy(newtitle, title);
343  strcat(newtitle, " (");
344  strcat(newtitle, fTypeTitle);
345  strcat(newtitle, ") ");
346  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
347  fHistNamesArray->AddLast(new TObjString(name));
348 }
const char * fTypeTitle
Definition: FP420Test.cc:86
TObjArray * fHistArray
Definition: FP420Test.cc:87
TObjArray * fHistNamesArray
Definition: FP420Test.cc:88

◆ storeWeights()

void Fp420AnalysisHistManager::storeWeights ( )
private

Definition at line 399 of file FP420Test.cc.

References fHistArray, and mps_fire::i.

399  {
400  // Add structure to each histogram to store the weights
401 
402  for (int i = 0; i < fHistArray->GetEntries(); i++) {
403  ((TH1F*)(fHistArray->At(i)))->Sumw2();
404  }
405 }
TObjArray * fHistArray
Definition: FP420Test.cc:87

◆ writeToFile()

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

Definition at line 310 of file FP420Test.cc.

References fHistArray, and geometryDiff::file.

Referenced by FP420Test::~FP420Test().

310  {
311  //Write to file = fOutputFile
312 
313  edm::LogVerbatim("FP420Test") << "================================================================";
314  edm::LogVerbatim("FP420Test") << " Write this Analysis to File " << fOutputFile;
315  edm::LogVerbatim("FP420Test") << "================================================================";
316 
317  TFile* file = new TFile(fOutputFile, fRecreateFile);
318 
319  fHistArray->Write();
320  file->Close();
321 }
Log< level::Info, true > LogVerbatim
TObjArray * fHistArray
Definition: FP420Test.cc:87

Member Data Documentation

◆ fHistArray

TObjArray* Fp420AnalysisHistManager::fHistArray
private

◆ fHistNamesArray

TObjArray* Fp420AnalysisHistManager::fHistNamesArray
private

◆ fTypeTitle

const char* Fp420AnalysisHistManager::fTypeTitle
private

Definition at line 86 of file FP420Test.cc.

Referenced by Fp420AnalysisHistManager(), and histInit().