| 143 |
return _histo; |
return _histo; |
| 144 |
} |
} |
| 145 |
|
|
| 146 |
|
/*! @brief Returns a pointer to the ROOT histogram. |
| 147 |
|
* |
| 148 |
|
* @return A pointer to the root histogram |
| 149 |
|
*/ |
| 150 |
|
TH2 *GetRootHisto() { |
| 151 |
|
return _rootHisto; |
| 152 |
|
} |
| 153 |
|
|
| 154 |
/*! Fills the ROOT and the vector histogram. |
/*! Fills the ROOT and the vector histogram. |
| 155 |
* |
* |
| 156 |
* @param xValue The value of the X coordinate associated to the event. |
* @param xValue The value of the X coordinate associated to the event. |
| 260 |
/*! @brief The ROOT histogram. */ |
/*! @brief The ROOT histogram. */ |
| 261 |
TH2 *_rootHisto; |
TH2 *_rootHisto; |
| 262 |
|
|
| 263 |
|
TString _outFileBase; |
| 264 |
|
TString _mode; |
| 265 |
|
TString _title, _xLabel, _yLabel; |
| 266 |
|
|
| 267 |
private: |
private: |
| 268 |
|
|
| 269 |
vector<HistoType> _xUnderflow, _xOverflow, _yUnderflow, _yOverflow; |
vector<HistoType> _xUnderflow, _xOverflow, _yUnderflow, _yOverflow; |
| 270 |
HistoType _xUnderYUnderflow, _xOverYOverflow, _xUnderYOverflow, _xOverYUnderflow; |
HistoType _xUnderYUnderflow, _xOverYOverflow, _xUnderYOverflow, _xOverYUnderflow; |
|
TString _outFileBase; |
|
|
TString _mode; |
|
|
TString _title, _xLabel, _yLabel; |
|
| 271 |
bool _outRoot; |
bool _outRoot; |
| 272 |
bool _outText; |
bool _outText; |
|
|
|
| 273 |
void _CreateHisto(); |
void _CreateHisto(); |
| 274 |
void _InitHistos(); |
void _InitHistos(); |
| 275 |
}; |
}; |
| 281 |
_rootHisto = NULL; |
_rootHisto = NULL; |
| 282 |
} |
} |
| 283 |
|
|
| 284 |
|
// Specializations for _CreateHistos(). See Histo2DAction.cpp |
| 285 |
|
template<> |
| 286 |
|
void Histo2DAction<Int_t>::_CreateHisto(); |
| 287 |
|
|
| 288 |
|
template<> |
| 289 |
|
void Histo2DAction<Float_t>::_CreateHisto(); |
| 290 |
|
|
| 291 |
|
template<> |
| 292 |
|
void Histo2DAction<Double_t>::_CreateHisto(); |
| 293 |
|
|
| 294 |
template<class HistoType> |
template<class HistoType> |
| 295 |
void Histo2DAction<HistoType>::_InitHistos() { |
void Histo2DAction<HistoType>::_InitHistos() { |
| 296 |
|
|
| 297 |
_CreateHisto(); |
_CreateHisto(); |
| 298 |
|
if (_xBins.size() < 2) // SetXAxis not called by the main program, or wrongly filled (only 1 bin limit) |
| 299 |
if (_xBins.size() < 2) { |
SetXAxis("Default X", 10, 0., 1.); |
| 300 |
_xBins.resize(2); |
if (_yBins.size() < 2) // SetYAxis not called by the main program, or wrongly filled (only 1 bin limit) |
| 301 |
_xBins[0] = 0.; |
SetYAxis("Default Y", 10, 0., 1.); |
|
_xBins[1] = 1.; |
|
|
} |
|
|
|
|
|
if (_yBins.size() < 2) { |
|
|
_yBins.resize(2); |
|
|
_yBins[0] = 0.; |
|
|
_yBins[1] = 1.; |
|
|
} |
|
| 302 |
|
|
| 303 |
if (_rootHisto) { |
if (_rootHisto) { |
| 304 |
Double_t *auxXArray = new Double_t[_xBins.size()]; |
Double_t *auxXArray = new Double_t[_xBins.size()]; |
| 326 |
/* The row index (first) corresponds to the position on the vertical (Y) axis. */ |
/* The row index (first) corresponds to the position on the vertical (Y) axis. */ |
| 327 |
_histo.Resize(_yBins.size() - 1, _xBins.size() - 1); |
_histo.Resize(_yBins.size() - 1, _xBins.size() - 1); |
| 328 |
|
|
| 329 |
_xUnderflow.resize(_yBins.size()); |
_xUnderflow.resize(_yBins.size() - 1); |
| 330 |
_xOverflow.resize(_yBins.size()); |
_xOverflow.resize(_yBins.size() - 1); |
| 331 |
_yUnderflow.resize(_xBins.size()); |
_yUnderflow.resize(_xBins.size() - 1); |
| 332 |
_yOverflow.resize(_xBins.size()); |
_yOverflow.resize(_xBins.size() - 1); |
| 333 |
|
|
| 334 |
} |
} |
| 335 |
|
|
| 343 |
template<class HistoType> |
template<class HistoType> |
| 344 |
Histo2DAction<HistoType>::Histo2DAction(const char *actionName, TString title, TString outFileBase, TString mode, |
Histo2DAction<HistoType>::Histo2DAction(const char *actionName, TString title, TString outFileBase, TString mode, |
| 345 |
bool outRoot, bool outText) : |
bool outRoot, bool outText) : |
| 346 |
CollectionAction(actionName), _xBins(0), _yBins(0), _histo(0, 0), _rootHisto(NULL), _xUnderflow(0), _xOverflow(0), |
CollectionAction(actionName), _xBins(0), _yBins(0), _histo(0, 0), _rootHisto(NULL), _outFileBase(outFileBase), _mode( |
| 347 |
_yUnderflow(0), _yOverflow(0), _outFileBase(outFileBase), _mode(mode), _title(title), _xLabel(""), _yLabel(""), |
mode), _title(title), _xLabel(""), _yLabel(""), _xUnderflow(0), _xOverflow(0), _yUnderflow(0), _yOverflow(0), |
| 348 |
_outRoot(outRoot), _outText(outText) { |
_xUnderYUnderflow((HistoType) 0), _xOverYOverflow((HistoType) 0), _xUnderYOverflow((HistoType) 0), |
| 349 |
|
_xOverYUnderflow((HistoType) 0), _outRoot(outRoot), _outText(outText) { |
| 350 |
|
|
| 351 |
} |
} |
| 352 |
|
|
| 469 |
} |
} |
| 470 |
|
|
| 471 |
template<class HistoType> |
template<class HistoType> |
| 472 |
inline void Histo2DAction<HistoType>::Fill(double xValue, double yValue, double weight) { |
void Histo2DAction<HistoType>::Fill(double xValue, double yValue, double weight) { |
| 473 |
|
|
| 474 |
_rootHisto->Fill(xValue, yValue, weight); |
_rootHisto->Fill(xValue, yValue, weight); |
| 475 |
|
|
| 482 |
UOflow = true; |
UOflow = true; |
| 483 |
} |
} |
| 484 |
|
|
| 485 |
if (xValue > _xBins.back()) { |
if (xValue >= _xBins.back()) { |
| 486 |
xBin = _xBins.size(); |
xBin = _xBins.size(); |
| 487 |
UOflow = true; |
UOflow = true; |
| 488 |
} |
} |
| 492 |
UOflow = true; |
UOflow = true; |
| 493 |
} |
} |
| 494 |
|
|
| 495 |
if (yValue > _yBins.back()) { |
if (yValue >= _yBins.back()) { |
| 496 |
yBin = _yBins.size(); |
yBin = _yBins.size(); |
| 497 |
UOflow = true; |
UOflow = true; |
| 498 |
} |
} |
| 528 |
else { |
else { |
| 529 |
if (yBin == (int) _yBins.size()) { |
if (yBin == (int) _yBins.size()) { |
| 530 |
_xUnderYOverflow += (HistoType) weight; |
_xUnderYOverflow += (HistoType) weight; |
| 531 |
|
cout << "_xUnderYOverflow: " << GetXUnderYOverflow() << ", weight: " << weight << ", (HistoType) weight: " |
| 532 |
|
<< (HistoType) weight << endl; |
| 533 |
return; |
return; |
| 534 |
} |
} |
| 535 |
else { |
else { |
| 586 |
ofstream outTextFile((_outFileBase + ".txt").Data(), ios_base::out); |
ofstream outTextFile((_outFileBase + ".txt").Data(), ios_base::out); |
| 587 |
for (unsigned int i = 0; i < _histo.GetNRows(); i++) { |
for (unsigned int i = 0; i < _histo.GetNRows(); i++) { |
| 588 |
for (unsigned int j = 0; j < _histo.GetNCols(); j++) { |
for (unsigned int j = 0; j < _histo.GetNCols(); j++) { |
| 589 |
outTextFile << _histo[i][j] << " "; |
outTextFile << setw(7) << _histo[i][j] << " "; |
| 590 |
} |
} |
| 591 |
outTextFile << "\n"; |
outTextFile << "\n"; |
| 592 |
} |
} |
|
outTextFile << endl; |
|
| 593 |
outTextFile.close(); |
outTextFile.close(); |
| 594 |
} |
} |
| 595 |
} |
} |