CMS 3D CMS Logo

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

#include <BscTest.h>

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 66 of file BscTest.h.

Constructor & Destructor Documentation

BscAnalysisHistManager::BscAnalysisHistManager ( const TString &  managername)

Definition at line 105 of file BscTest.cc.

106 {
107  // The Constructor
108 
109  fTypeTitle=managername;
110  fHistArray = new TObjArray(); // Array to store histos
111  fHistNamesArray = new TObjArray(); // Array to store histos's names
112 
113  BookHistos();
114 
115  fHistArray->Compress(); // Removes empty space
116  fHistNamesArray->Compress();
117 }
TObjArray * fHistNamesArray
Definition: BscTest.h:89
TObjArray * fHistArray
Definition: BscTest.h:88
const char * fTypeTitle
Definition: BscTest.h:87
BscAnalysisHistManager::~BscAnalysisHistManager ( )
override

Definition at line 120 of file BscTest.cc.

121 {
122  // The Destructor
123 
124  if(fHistArray){
125  fHistArray->Delete();
126  delete fHistArray;
127  }
128 
129  if(fHistNamesArray){
130  fHistNamesArray->Delete();
131  delete fHistNamesArray;
132  }
133 }
TObjArray * fHistNamesArray
Definition: BscTest.h:89
TObjArray * fHistArray
Definition: BscTest.h:88

Member Function Documentation

void BscAnalysisHistManager::BookHistos ( )
private

Definition at line 136 of file BscTest.cc.

137 {
138  // at Start: (mm)
139  HistInit("TrackPhi", "Primary Phi", 100, 0.,360. );
140  HistInit("TrackTheta", "Primary Theta", 100, 0.,180. );
141  HistInit("TrackP", "Track XY position Z+ ", 80, -80., 80., 80, -80., 80. );
142  HistInit("TrackM", "Track XY position Z-", 80, -80., 80., 80, -80., 80. );
143  HistInit("DetIDs", "Track DetId - vs +", 16, -0.5, 15.5,16, 15.5, 31.5 );
144 }
void HistInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: BscTest.cc:164
TH1F * BscAnalysisHistManager::GetHisto ( Int_t  Number)

Definition at line 194 of file BscTest.cc.

References gather_cfg::cout.

Referenced by BscTest::update().

195 {
196  // Get a histogram from the array with index = Number
197 
198  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr){
199 
200  return (TH1F*)(fHistArray->At(Number));
201 
202  }else{
203 
204  std::cout << "!!!!!!!!!!!!!!!!!!GetHisto!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
205  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
206  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
207 
208  return (TH1F*)(fHistArray->At(0));
209  }
210 }
TObjArray * fHistArray
Definition: BscTest.h:88
TH1F * BscAnalysisHistManager::GetHisto ( const TObjString &  histname)

Definition at line 232 of file BscTest.cc.

233 {
234  // Get a histogram from the array with name = histname
235 
236  Int_t index = fHistNamesArray->IndexOf(&histname);
237  return GetHisto(index);
238 }
TH1F * GetHisto(Int_t Number)
Definition: BscTest.cc:194
TObjArray * fHistNamesArray
Definition: BscTest.h:89
TH2F * BscAnalysisHistManager::GetHisto2 ( Int_t  Number)

Definition at line 213 of file BscTest.cc.

References gather_cfg::cout.

214 {
215  // Get a histogram from the array with index = Number
216 
217  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)nullptr){
218 
219  return (TH2F*)(fHistArray->At(Number));
220 
221  }else{
222 
223  std::cout << "!!!!!!!!!!!!!!!!GetHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
224  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
225  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
226 
227  return (TH2F*)(fHistArray->At(0));
228  }
229 }
TObjArray * fHistArray
Definition: BscTest.h:88
TH2F * BscAnalysisHistManager::GetHisto2 ( const TObjString &  histname)

Definition at line 241 of file BscTest.cc.

242 {
243  // Get a histogram from the array with name = histname
244 
245  Int_t index = fHistNamesArray->IndexOf(&histname);
246  return GetHisto2(index);
247 }
TH2F * GetHisto2(Int_t Number)
Definition: BscTest.cc:213
TObjArray * fHistNamesArray
Definition: BscTest.h:89
void BscAnalysisHistManager::HistInit ( const char *  name,
const char *  title,
Int_t  nbinsx,
Axis_t  xlow,
Axis_t  xup 
)
private

Definition at line 164 of file BscTest.cc.

165 {
166  // Add histograms and histograms names to the array
167 
168  char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
169  strcpy(newtitle,title);
170  strcat(newtitle," (");
171  strcat(newtitle,fTypeTitle);
172  strcat(newtitle,") ");
173  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
174  fHistNamesArray->AddLast(new TObjString(name));
175 
176 }
TObjArray * fHistNamesArray
Definition: BscTest.h:89
TObjArray * fHistArray
Definition: BscTest.h:88
const char * fTypeTitle
Definition: BscTest.h:87
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 179 of file BscTest.cc.

180 {
181  // Add histograms and histograms names to the array
182 
183  char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
184  strcpy(newtitle,title);
185  strcat(newtitle," (");
186  strcat(newtitle,fTypeTitle);
187  strcat(newtitle,") ");
188  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
189  fHistNamesArray->AddLast(new TObjString(name));
190 
191 }
TObjArray * fHistNamesArray
Definition: BscTest.h:89
TObjArray * fHistArray
Definition: BscTest.h:88
const char * fTypeTitle
Definition: BscTest.h:87
void BscAnalysisHistManager::StoreWeights ( )
private

Definition at line 250 of file BscTest.cc.

References mps_fire::i.

251 {
252  // Add structure to each histogram to store the weights
253 
254  for(int i = 0; i < fHistArray->GetEntries(); i++){
255  ((TH1F*)(fHistArray->At(i)))->Sumw2();
256  }
257 }
TObjArray * fHistArray
Definition: BscTest.h:88
void BscAnalysisHistManager::WriteToFile ( const TString &  fOutputFile,
const TString &  fRecreateFile 
)

Definition at line 148 of file BscTest.cc.

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

Referenced by BscTest::~BscTest().

149 {
150 
151  //Write to file = fOutputFile
152 
153  std::cout <<"================================================================"<<std::endl;
154  std::cout <<" Write this Analysis to File "<<fOutputFile<<std::endl;
155  std::cout <<"================================================================"<<std::endl;
156 
157  TFile* file = new TFile(fOutputFile, fRecreateFile);
158 
159  fHistArray->Write();
160  file->Close();
161 }
TObjArray * fHistArray
Definition: BscTest.h:88

Member Data Documentation

TObjArray* BscAnalysisHistManager::fHistArray
private

Definition at line 88 of file BscTest.h.

TObjArray* BscAnalysisHistManager::fHistNamesArray
private

Definition at line 89 of file BscTest.h.

const char* BscAnalysisHistManager::fTypeTitle
private

Definition at line 87 of file BscTest.h.