5 |
* Author: Nicola Mori |
* Author: Nicola Mori |
6 |
*/ |
*/ |
7 |
|
|
8 |
/*! @file FluxHistoAction.cpp The FluxHistoAction class implementation file */ |
/*! @file FluxHistoAction.cpp The FluxHistoAction class implementation file. */ |
9 |
|
|
10 |
#include "FluxHistoAction.h" |
#include "FluxHistoAction.h" |
11 |
|
|
12 |
FluxHistoAction::FluxHistoAction(const char *actionName, TString outFileBase, TString rigBinsFile) : |
FluxHistoAction::FluxHistoAction(const char *actionName, TString outFileBase, TString rigBinsFile, TString mode) : |
13 |
CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0) |
CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0), _mode(mode) |
14 |
#ifdef DEBUGPAMCUT |
#ifdef DEBUGPAMCUT |
15 |
, _outUp(0), _outDown(0) |
, _outUp(0), _outDown(0) |
16 |
#endif |
#endif |
17 |
{ |
{ |
18 |
|
|
31 |
|
|
32 |
// Initializing histograms |
// Initializing histograms |
33 |
_textHisto.assign(_bins.size() - 1, 0); |
_textHisto.assign(_bins.size() - 1, 0); |
34 |
_rootHisto.SetName("rigHisto"); |
_rootHisto.SetName(GetName()); |
35 |
_rootHisto.SetTitle("Rigidity histogram"); |
_rootHisto.SetTitle("Rigidity histogram"); |
36 |
_rootHisto.GetXaxis()->SetTitle("R"); |
_rootHisto.GetXaxis()->SetTitle("R"); |
37 |
_rootHisto.GetYaxis()->SetTitle("Events"); |
_rootHisto.GetYaxis()->SetTitle("Events"); |
66 |
} |
} |
67 |
#ifdef DEBUGPAMCUT |
#ifdef DEBUGPAMCUT |
68 |
else |
else |
69 |
_outUp++; |
_outUp++; |
70 |
#endif |
#endif |
71 |
} |
} |
72 |
#ifdef DEBUGPAMCUT |
#ifdef DEBUGPAMCUT |
73 |
else |
else |
74 |
_outDown++; |
_outDown++; |
75 |
#endif |
#endif |
76 |
|
|
77 |
} |
} |
79 |
void FluxHistoAction::Finalize() { |
void FluxHistoAction::Finalize() { |
80 |
|
|
81 |
// Write the text file |
// Write the text file |
82 |
|
// Currently, text output doesn't support append. |
83 |
ofstream outTextFile((_outFileBase + ".txt").Data(), ios_base::out); |
ofstream outTextFile((_outFileBase + ".txt").Data(), ios_base::out); |
84 |
streamsize oldPrec = cout.precision(); |
streamsize oldPrec = cout.precision(); |
85 |
streamsize newPrec = 4; |
streamsize newPrec = 4; |
86 |
outTextFile.precision(newPrec); |
outTextFile.precision(newPrec); |
87 |
outTextFile.setf(ios::fixed, ios::floatfield); |
outTextFile.setf(ios::fixed, ios::floatfield); |
88 |
for (unsigned int i = 0; i < _textHisto.size(); i++) |
for (unsigned int i = 0; i < _textHisto.size(); i++) |
89 |
outTextFile << _bins[i] << " " << _bins[i + 1] << " " << _textHisto[i] << "\n"; |
outTextFile << _textHisto[i] << "\n"; |
90 |
outTextFile.close(); |
outTextFile.close(); |
91 |
outTextFile.precision(oldPrec); |
outTextFile.precision(oldPrec); |
92 |
outTextFile << resetiosflags(ios::floatfield); |
outTextFile << resetiosflags(ios::floatfield); |
93 |
|
|
94 |
// Write the ROOT file |
// Write the ROOT file |
95 |
TFile outRootFile((_outFileBase + ".root"), "RECREATE"); |
TFile outRootFile((_outFileBase + ".root"), _mode); |
96 |
outRootFile.cd(); |
outRootFile.cd(); |
97 |
_rootHisto.Write(); |
_rootHisto.Write(); |
98 |
//outRootFile.Close(); |
outRootFile.Close(); |
99 |
|
|
100 |
#ifdef DEBUGPAMCUT |
#ifdef DEBUGPAMCUT |
101 |
cout << "Debug informations from " << GetName() << ":\n"; |
cout << "Debug informations from " << GetName() << ":\n"; |