CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 

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 118 of file BscTest.cc.

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

119 {
120  // The Constructor
121 
122  fTypeTitle=managername;
123  fHistArray = new TObjArray(); // Array to store histos
124  fHistNamesArray = new TObjArray(); // Array to store histos's names
125 
126  BookHistos();
127 
128  fHistArray->Compress(); // Removes empty space
129  fHistNamesArray->Compress();
130 
131  // StoreWeights(); // Store the weights
132 
133 }
TObjArray * fHistNamesArray
Definition: BscTest.h:89
TObjArray * fHistArray
Definition: BscTest.h:88
const char * fTypeTitle
Definition: BscTest.h:87
BscAnalysisHistManager::~BscAnalysisHistManager ( )

Definition at line 136 of file BscTest.cc.

References fHistArray, and fHistNamesArray.

137 {
138  // The Destructor
139 
140  if(fHistArray){
141  fHistArray->Delete();
142  delete fHistArray;
143  }
144 
145  if(fHistNamesArray){
146  fHistNamesArray->Delete();
147  delete fHistNamesArray;
148  }
149 }
TObjArray * fHistNamesArray
Definition: BscTest.h:89
TObjArray * fHistArray
Definition: BscTest.h:88

Member Function Documentation

void BscAnalysisHistManager::BookHistos ( )
private

Definition at line 152 of file BscTest.cc.

References HistInit().

Referenced by BscAnalysisHistManager().

153 {
154  // at Start: (mm)
155  HistInit("TrackPhi", "Primary Phi", 100, 0.,360. );
156  HistInit("TrackTheta", "Primary Theta", 100, 0.,180. );
157  HistInit("TrackP", "Track XY position Z+ ", 80, -80., 80., 80, -80., 80. );
158  HistInit("TrackM", "Track XY position Z-", 80, -80., 80., 80, -80., 80. );
159  HistInit("DetIDs", "Track DetId - vs +", 16, -0.5, 15.5,16, 15.5, 31.5 );
160 }
void HistInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: BscTest.cc:180
TH1F * BscAnalysisHistManager::GetHisto ( Int_t  Number)

Definition at line 210 of file BscTest.cc.

References gather_cfg::cout, and fHistArray.

Referenced by GetHisto(), and BscTest::update().

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

Definition at line 248 of file BscTest.cc.

References fHistNamesArray, GetHisto(), and cmsHarvester::index.

249 {
250  // Get a histogram from the array with name = histname
251 
252  Int_t index = fHistNamesArray->IndexOf(&histname);
253  return GetHisto(index);
254 }
TH1F * GetHisto(Int_t Number)
Definition: BscTest.cc:210
TObjArray * fHistNamesArray
Definition: BscTest.h:89
TH2F * BscAnalysisHistManager::GetHisto2 ( Int_t  Number)

Definition at line 229 of file BscTest.cc.

References gather_cfg::cout, and fHistArray.

Referenced by GetHisto2().

230 {
231  // Get a histogram from the array with index = Number
232 
233  if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)0){
234 
235  return (TH2F*)(fHistArray->At(Number));
236 
237  }else{
238 
239  std::cout << "!!!!!!!!!!!!!!!!GetHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
240  std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
241  std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
242 
243  return (TH2F*)(fHistArray->At(0));
244  }
245 }
TObjArray * fHistArray
Definition: BscTest.h:88
tuple cout
Definition: gather_cfg.py:121
TH2F * BscAnalysisHistManager::GetHisto2 ( const TObjString &  histname)

Definition at line 257 of file BscTest.cc.

References fHistNamesArray, GetHisto2(), and cmsHarvester::index.

258 {
259  // Get a histogram from the array with name = histname
260 
261  Int_t index = fHistNamesArray->IndexOf(&histname);
262  return GetHisto2(index);
263 }
TH2F * GetHisto2(Int_t Number)
Definition: BscTest.cc:229
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 180 of file BscTest.cc.

References fHistArray, fHistNamesArray, and fTypeTitle.

Referenced by BookHistos().

181 {
182  // Add histograms and histograms names to the array
183 
184  char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
185  strcpy(newtitle,title);
186  strcat(newtitle," (");
187  strcat(newtitle,fTypeTitle);
188  strcat(newtitle,") ");
189  fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
190  fHistNamesArray->AddLast(new TObjString(name));
191 
192 }
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 195 of file BscTest.cc.

References fHistArray, fHistNamesArray, and fTypeTitle.

196 {
197  // Add histograms and histograms names to the array
198 
199  char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
200  strcpy(newtitle,title);
201  strcat(newtitle," (");
202  strcat(newtitle,fTypeTitle);
203  strcat(newtitle,") ");
204  fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
205  fHistNamesArray->AddLast(new TObjString(name));
206 
207 }
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 266 of file BscTest.cc.

References fHistArray, and i.

267 {
268  // Add structure to each histogram to store the weights
269 
270  for(int i = 0; i < fHistArray->GetEntries(); i++){
271  ((TH1F*)(fHistArray->At(i)))->Sumw2();
272  }
273 }
int i
Definition: DBlmapReader.cc:9
TObjArray * fHistArray
Definition: BscTest.h:88
void BscAnalysisHistManager::WriteToFile ( const TString &  fOutputFile,
const TString &  fRecreateFile 
)

Definition at line 164 of file BscTest.cc.

References gather_cfg::cout, fHistArray, and mergeVDriftHistosByStation::file.

Referenced by BscTest::~BscTest().

165 {
166 
167  //Write to file = fOutputFile
168 
169  std::cout <<"================================================================"<<std::endl;
170  std::cout <<" Write this Analysis to File "<<fOutputFile<<std::endl;
171  std::cout <<"================================================================"<<std::endl;
172 
173  TFile* file = new TFile(fOutputFile, fRecreateFile);
174 
175  fHistArray->Write();
176  file->Close();
177 }
TObjArray * fHistArray
Definition: BscTest.h:88
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

TObjArray* BscAnalysisHistManager::fHistArray
private
TObjArray* BscAnalysisHistManager::fHistNamesArray
private
const char* BscAnalysisHistManager::fTypeTitle
private

Definition at line 87 of file BscTest.h.

Referenced by BscAnalysisHistManager(), and HistInit().