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

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

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

Definition at line 135 of file BscTest.cc.

References fHistArray, and fHistNamesArray.

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

Member Function Documentation

void BscAnalysisHistManager::BookHistos ( )
private

Definition at line 151 of file BscTest.cc.

References HistInit().

Referenced by BscAnalysisHistManager().

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

Definition at line 209 of file BscTest.cc.

References gather_cfg::cout, and fHistArray.

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

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

Definition at line 247 of file BscTest.cc.

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

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

Definition at line 228 of file BscTest.cc.

References gather_cfg::cout, and fHistArray.

Referenced by GetHisto2().

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

Definition at line 256 of file BscTest.cc.

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

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

References fHistArray, fHistNamesArray, and fTypeTitle.

Referenced by BookHistos().

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 TH1F(name, newtitle, nbinsx, xlow, xup)));
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::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 194 of file BscTest.cc.

References fHistArray, fHistNamesArray, and fTypeTitle.

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

References fHistArray, and i.

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

Definition at line 163 of file BscTest.cc.

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

Referenced by BscTest::~BscTest().

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

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