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 62 of file FP420Test.cc.

Constructor & Destructor Documentation

◆ Fp420AnalysisHistManager()

Fp420AnalysisHistManager::Fp420AnalysisHistManager ( const TString &  managername)

Definition at line 250 of file FP420Test.cc.

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

250  {
251  // The Constructor
252 
253  fTypeTitle = managername;
254  fHistArray = new TObjArray(); // Array to store histos
255  fHistNamesArray = new TObjArray(); // Array to store histos's names
256 
257  TH1::AddDirectory(kFALSE);
258  bookHistos();
259 
260  fHistArray->Compress(); // Removes empty space
261  fHistNamesArray->Compress();
262 
263  // storeWeights(); // Store the weights
264 }
const char * fTypeTitle
Definition: FP420Test.cc:82
TObjArray * fHistArray
Definition: FP420Test.cc:83
TObjArray * fHistNamesArray
Definition: FP420Test.cc:84

◆ ~Fp420AnalysisHistManager()

Fp420AnalysisHistManager::~Fp420AnalysisHistManager ( )
override

Definition at line 267 of file FP420Test.cc.

References fHistArray, and fHistNamesArray.

267  {
268  // The Destructor
269 
270  if (fHistArray) {
271  fHistArray->Delete();
272  delete fHistArray;
273  }
274 
275  if (fHistNamesArray) {
276  fHistNamesArray->Delete();
277  delete fHistNamesArray;
278  }
279 }
TObjArray * fHistArray
Definition: FP420Test.cc:83
TObjArray * fHistNamesArray
Definition: FP420Test.cc:84

Member Function Documentation

◆ bookHistos()

void Fp420AnalysisHistManager::bookHistos ( )
private

Definition at line 282 of file FP420Test.cc.

References histInit().

Referenced by Fp420AnalysisHistManager().

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

◆ getHisto() [1/2]

TH1F * Fp420AnalysisHistManager::getHisto ( Int_t  Number)

Definition at line 347 of file FP420Test.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

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

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

◆ getHisto() [2/2]

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

Definition at line 379 of file FP420Test.cc.

References fHistNamesArray, and getHisto().

379  {
380  // Get a histogram from the array with name = histname
381 
382  Int_t index = fHistNamesArray->IndexOf(&histname);
383  return getHisto(index);
384 }
TH1F * getHisto(Int_t Number)
Definition: FP420Test.cc:347
TObjArray * fHistNamesArray
Definition: FP420Test.cc:84

◆ getHisto2() [1/2]

TH2F * Fp420AnalysisHistManager::getHisto2 ( Int_t  Number)

Definition at line 363 of file FP420Test.cc.

References fHistArray, and HcalTBWriter_cfi::Number.

Referenced by getHisto2().

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

◆ getHisto2() [2/2]

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

Definition at line 387 of file FP420Test.cc.

References fHistNamesArray, and getHisto2().

387  {
388  // Get a histogram from the array with name = histname
389 
390  Int_t index = fHistNamesArray->IndexOf(&histname);
391  return getHisto2(index);
392 }
TH2F * getHisto2(Int_t Number)
Definition: FP420Test.cc:363
TObjArray * fHistNamesArray
Definition: FP420Test.cc:84

◆ 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 320 of file FP420Test.cc.

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

Referenced by bookHistos().

320  {
321  // Add histograms and histograms names to the array
322 
323  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
324  strcpy(newtitle, title);
325  strcat(newtitle, " (");
326  strcat(newtitle, fTypeTitle);
327  strcat(newtitle, ") ");
328  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
329  fHistNamesArray->AddLast(new TObjString(name));
330 }
const char * fTypeTitle
Definition: FP420Test.cc:82
TObjArray * fHistArray
Definition: FP420Test.cc:83
TObjArray * fHistNamesArray
Definition: FP420Test.cc:84

◆ 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 333 of file FP420Test.cc.

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

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

◆ storeWeights()

void Fp420AnalysisHistManager::storeWeights ( )
private

Definition at line 395 of file FP420Test.cc.

References fHistArray, and mps_fire::i.

395  {
396  // Add structure to each histogram to store the weights
397 
398  for (int i = 0; i < fHistArray->GetEntries(); i++) {
399  ((TH1F*)(fHistArray->At(i)))->Sumw2();
400  }
401 }
TObjArray * fHistArray
Definition: FP420Test.cc:83

◆ writeToFile()

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

Definition at line 306 of file FP420Test.cc.

References fHistArray, and geometryDiff::file.

Referenced by FP420Test::~FP420Test().

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

Member Data Documentation

◆ fHistArray

TObjArray* Fp420AnalysisHistManager::fHistArray
private

◆ fHistNamesArray

TObjArray* Fp420AnalysisHistManager::fHistNamesArray
private

◆ fTypeTitle

const char* Fp420AnalysisHistManager::fTypeTitle
private

Definition at line 82 of file FP420Test.cc.

Referenced by Fp420AnalysisHistManager(), and histInit().