CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Fp420AnalysisHistManager Class Reference

#include <FP420Test.h>

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 58 of file FP420Test.h.

Constructor & Destructor Documentation

Fp420AnalysisHistManager::Fp420AnalysisHistManager ( const TString &  managername)

Definition at line 144 of file FP420Test.cc.

144  {
145  // The Constructor
146 
147  fTypeTitle = managername;
148  fHistArray = new TObjArray(); // Array to store histos
149  fHistNamesArray = new TObjArray(); // Array to store histos's names
150 
151  TH1::AddDirectory(kFALSE);
152  BookHistos();
153 
154  fHistArray->Compress(); // Removes empty space
155  fHistNamesArray->Compress();
156 
157  // StoreWeights(); // Store the weights
158 }
const char * fTypeTitle
Definition: FP420Test.h:78
TObjArray * fHistArray
Definition: FP420Test.h:79
TObjArray * fHistNamesArray
Definition: FP420Test.h:80
Fp420AnalysisHistManager::~Fp420AnalysisHistManager ( )
override

Definition at line 161 of file FP420Test.cc.

161  {
162  // The Destructor
163 
164  if (fHistArray) {
165  fHistArray->Delete();
166  delete fHistArray;
167  }
168 
169  if (fHistNamesArray) {
170  fHistNamesArray->Delete();
171  delete fHistNamesArray;
172  }
173 }
TObjArray * fHistArray
Definition: FP420Test.h:79
TObjArray * fHistNamesArray
Definition: FP420Test.h:80

Member Function Documentation

void Fp420AnalysisHistManager::BookHistos ( )
private

Definition at line 176 of file FP420Test.cc.

176  {
177  // at Start: (mm)
178  HistInit("PrimaryEta", "Primary Eta", 100, 9., 12.);
179  HistInit("PrimaryPhigrad", "Primary Phigrad", 100, 0., 360.);
180  HistInit("PrimaryTh", "Primary Th", 100, 0., 180.);
181  HistInit("PrimaryLastpoZ", "Primary Lastpo Z", 100, -200., 430000.);
182  HistInit("PrimaryLastpoX", "Primary Lastpo X Z<z4", 100, -30., 30.);
183  HistInit("PrimaryLastpoY", "Primary Lastpo Y Z<z4", 100, -30., 30.);
184  HistInit("XLastpoNumofpart", "Primary Lastpo X n>10", 100, -30., 30.);
185  HistInit("YLastpoNumofpart", "Primary Lastpo Y n>10", 100, -30., 30.);
186  HistInit("VtxX", "Vtx X", 100, -50., 50.);
187  HistInit("VtxY", "Vtx Y", 100, -50., 50.);
188  HistInit("VtxZ", "Vtx Z", 100, -200., 430000.);
189  // Book the histograms and add them to the array
190  HistInit("SumEDep", "This is sum Energy deposited", 100, -1, 199.);
191  HistInit("TrackL", "This is TrackL", 100, 0., 12000.);
192  HistInit("zHits", "z Hits all events", 100, 400000., 430000.);
193  HistInit("zHitsnoMI", "z Hits no MI", 100, 400000., 430000.);
194  HistInit("zHitsTrLoLe", "z Hits TrLength bigger 8300", 100, 400000., 430000.);
195  HistInit("NumberOfHits", "NumberOfHits", 100, 0., 300.);
196 }
void HistInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: FP420Test.cc:214
TH1F * Fp420AnalysisHistManager::GetHisto ( Int_t  Number)

Definition at line 241 of file FP420Test.cc.

References gather_cfg::cout.

241  {
242  // Get a histogram from the array with index = Number
243 
244  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
245  return (TH1F*)(fHistArray->At(Number));
246 
247  } else {
248  std::cout << "!!!!!!!!!!!!!!!!!!GetHisto!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
249  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
250  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
251 
252  return (TH1F*)(fHistArray->At(0));
253  }
254 }
TObjArray * fHistArray
Definition: FP420Test.h:79
TH1F * Fp420AnalysisHistManager::GetHisto ( const TObjString &  histname)

Definition at line 273 of file FP420Test.cc.

273  {
274  // Get a histogram from the array with name = histname
275 
276  Int_t index = fHistNamesArray->IndexOf(&histname);
277  return GetHisto(index);
278 }
TH1F * GetHisto(Int_t Number)
Definition: FP420Test.cc:241
TObjArray * fHistNamesArray
Definition: FP420Test.h:80
TH2F * Fp420AnalysisHistManager::GetHisto2 ( Int_t  Number)

Definition at line 257 of file FP420Test.cc.

References gather_cfg::cout.

257  {
258  // Get a histogram from the array with index = Number
259 
260  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr) {
261  return (TH2F*)(fHistArray->At(Number));
262 
263  } else {
264  std::cout << "!!!!!!!!!!!!!!!!GetHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
265  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
266  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
267 
268  return (TH2F*)(fHistArray->At(0));
269  }
270 }
TObjArray * fHistArray
Definition: FP420Test.h:79
TH2F * Fp420AnalysisHistManager::GetHisto2 ( const TObjString &  histname)

Definition at line 281 of file FP420Test.cc.

281  {
282  // Get a histogram from the array with name = histname
283 
284  Int_t index = fHistNamesArray->IndexOf(&histname);
285  return GetHisto2(index);
286 }
TH2F * GetHisto2(Int_t Number)
Definition: FP420Test.cc:257
TObjArray * fHistNamesArray
Definition: FP420Test.h:80
void Fp420AnalysisHistManager::HistInit ( const char *  name,
const char *  title,
Int_t  nbinsx,
Axis_t  xlow,
Axis_t  xup 
)
private

Definition at line 214 of file FP420Test.cc.

214  {
215  // Add histograms and histograms names to the array
216 
217  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
218  strcpy(newtitle, title);
219  strcat(newtitle, " (");
220  strcat(newtitle, fTypeTitle);
221  strcat(newtitle, ") ");
222  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
223  fHistNamesArray->AddLast(new TObjString(name));
224 }
const char * fTypeTitle
Definition: FP420Test.h:78
TObjArray * fHistArray
Definition: FP420Test.h:79
TObjArray * fHistNamesArray
Definition: FP420Test.h:80
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 227 of file FP420Test.cc.

228  {
229  // Add histograms and histograms names to the array
230 
231  char* newtitle = new char[strlen(title) + strlen(fTypeTitle) + 5];
232  strcpy(newtitle, title);
233  strcat(newtitle, " (");
234  strcat(newtitle, fTypeTitle);
235  strcat(newtitle, ") ");
236  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
237  fHistNamesArray->AddLast(new TObjString(name));
238 }
const char * fTypeTitle
Definition: FP420Test.h:78
TObjArray * fHistArray
Definition: FP420Test.h:79
TObjArray * fHistNamesArray
Definition: FP420Test.h:80
void Fp420AnalysisHistManager::StoreWeights ( )
private

Definition at line 289 of file FP420Test.cc.

References mps_fire::i.

289  {
290  // Add structure to each histogram to store the weights
291 
292  for (int i = 0; i < fHistArray->GetEntries(); i++) {
293  ((TH1F*)(fHistArray->At(i)))->Sumw2();
294  }
295 }
TObjArray * fHistArray
Definition: FP420Test.h:79
void Fp420AnalysisHistManager::WriteToFile ( const TString &  fOutputFile,
const TString &  fRecreateFile 
)

Definition at line 200 of file FP420Test.cc.

References gather_cfg::cout, and FrontierConditions_GlobalTag_cff::file.

200  {
201  //Write to file = fOutputFile
202 
203  std::cout << "================================================================" << std::endl;
204  std::cout << " Write this Analysis to File " << fOutputFile << std::endl;
205  std::cout << "================================================================" << std::endl;
206 
207  TFile* file = new TFile(fOutputFile, fRecreateFile);
208 
209  fHistArray->Write();
210  file->Close();
211 }
TObjArray * fHistArray
Definition: FP420Test.h:79

Member Data Documentation

TObjArray* Fp420AnalysisHistManager::fHistArray
private

Definition at line 79 of file FP420Test.h.

TObjArray* Fp420AnalysisHistManager::fHistNamesArray
private

Definition at line 80 of file FP420Test.h.

const char* Fp420AnalysisHistManager::fTypeTitle
private

Definition at line 78 of file FP420Test.h.