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 ()
 

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

Constructor & Destructor Documentation

Fp420AnalysisHistManager::Fp420AnalysisHistManager ( const TString &  managername)

Definition at line 147 of file FP420Test.cc.

148 {
149  // The Constructor
150 
151  fTypeTitle=managername;
152  fHistArray = new TObjArray(); // Array to store histos
153  fHistNamesArray = new TObjArray(); // Array to store histos's names
154 
155  TH1::AddDirectory(kFALSE);
156  BookHistos();
157 
158  fHistArray->Compress(); // Removes empty space
159  fHistNamesArray->Compress();
160 
161 // StoreWeights(); // Store the weights
162 
163 }
const char * fTypeTitle
Definition: FP420Test.h:85
TObjArray * fHistArray
Definition: FP420Test.h:86
TObjArray * fHistNamesArray
Definition: FP420Test.h:87
Fp420AnalysisHistManager::~Fp420AnalysisHistManager ( )

Definition at line 166 of file FP420Test.cc.

167 {
168  // The Destructor
169 
170  if(fHistArray){
171  fHistArray->Delete();
172  delete fHistArray;
173  }
174 
175  if(fHistNamesArray){
176  fHistNamesArray->Delete();
177  delete fHistNamesArray;
178  }
179 }
TObjArray * fHistArray
Definition: FP420Test.h:86
TObjArray * fHistNamesArray
Definition: FP420Test.h:87

Member Function Documentation

void Fp420AnalysisHistManager::BookHistos ( )
private

Definition at line 182 of file FP420Test.cc.

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

Definition at line 253 of file FP420Test.cc.

References gather_cfg::cout.

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

Definition at line 291 of file FP420Test.cc.

References diffTreeTool::index.

292 {
293  // Get a histogram from the array with name = histname
294 
295  Int_t index = fHistNamesArray->IndexOf(&histname);
296  return GetHisto(index);
297 }
TH1F * GetHisto(Int_t Number)
Definition: FP420Test.cc:253
TObjArray * fHistNamesArray
Definition: FP420Test.h:87
TH2F * Fp420AnalysisHistManager::GetHisto2 ( Int_t  Number)

Definition at line 272 of file FP420Test.cc.

References gather_cfg::cout.

273 {
274  // Get a histogram from the array with index = Number
275 
276  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)0){
277 
278  return (TH2F*)(fHistArray->At(Number));
279 
280  }else{
281 
282  std::cout << "!!!!!!!!!!!!!!!!GetHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
283  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
284  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
285 
286  return (TH2F*)(fHistArray->At(0));
287  }
288 }
TObjArray * fHistArray
Definition: FP420Test.h:86
TH2F * Fp420AnalysisHistManager::GetHisto2 ( const TObjString &  histname)

Definition at line 300 of file FP420Test.cc.

References diffTreeTool::index.

301 {
302  // Get a histogram from the array with name = histname
303 
304  Int_t index = fHistNamesArray->IndexOf(&histname);
305  return GetHisto2(index);
306 }
TH2F * GetHisto2(Int_t Number)
Definition: FP420Test.cc:272
TObjArray * fHistNamesArray
Definition: FP420Test.h:87
void Fp420AnalysisHistManager::HistInit ( const char *  name,
const char *  title,
Int_t  nbinsx,
Axis_t  xlow,
Axis_t  xup 
)
private

Definition at line 223 of file FP420Test.cc.

224 {
225  // Add histograms and histograms names to the array
226 
227  char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
228  strcpy(newtitle,title);
229  strcat(newtitle," (");
230  strcat(newtitle,fTypeTitle);
231  strcat(newtitle,") ");
232  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
233  fHistNamesArray->AddLast(new TObjString(name));
234 
235 }
const char * fTypeTitle
Definition: FP420Test.h:85
TObjArray * fHistArray
Definition: FP420Test.h:86
TObjArray * fHistNamesArray
Definition: FP420Test.h:87
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 238 of file FP420Test.cc.

239 {
240  // Add histograms and histograms names to the array
241 
242  char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
243  strcpy(newtitle,title);
244  strcat(newtitle," (");
245  strcat(newtitle,fTypeTitle);
246  strcat(newtitle,") ");
247  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
248  fHistNamesArray->AddLast(new TObjString(name));
249 
250 }
const char * fTypeTitle
Definition: FP420Test.h:85
TObjArray * fHistArray
Definition: FP420Test.h:86
TObjArray * fHistNamesArray
Definition: FP420Test.h:87
void Fp420AnalysisHistManager::StoreWeights ( )
private

Definition at line 309 of file FP420Test.cc.

References mps_fire::i.

310 {
311  // Add structure to each histogram to store the weights
312 
313  for(int i = 0; i < fHistArray->GetEntries(); i++){
314  ((TH1F*)(fHistArray->At(i)))->Sumw2();
315  }
316 }
TObjArray * fHistArray
Definition: FP420Test.h:86
void Fp420AnalysisHistManager::WriteToFile ( const TString &  fOutputFile,
const TString &  fRecreateFile 
)

Definition at line 207 of file FP420Test.cc.

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

208 {
209 
210  //Write to file = fOutputFile
211 
212  std::cout <<"================================================================"<<std::endl;
213  std::cout <<" Write this Analysis to File "<<fOutputFile<<std::endl;
214  std::cout <<"================================================================"<<std::endl;
215 
216  TFile* file = new TFile(fOutputFile, fRecreateFile);
217 
218  fHistArray->Write();
219  file->Close();
220 }
TObjArray * fHistArray
Definition: FP420Test.h:86

Member Data Documentation

TObjArray* Fp420AnalysisHistManager::fHistArray
private

Definition at line 86 of file FP420Test.h.

TObjArray* Fp420AnalysisHistManager::fHistNamesArray
private

Definition at line 87 of file FP420Test.h.

const char* Fp420AnalysisHistManager::fTypeTitle
private

Definition at line 85 of file FP420Test.h.