| 30 |
|
|
| 31 |
_zeroCutoffBins.resize(_bins.size() - 1, 0); |
_zeroCutoffBins.resize(_bins.size() - 1, 0); |
| 32 |
_textHisto.Resize(_bins.size() - 1, _bins.size() - 1, 0); |
_textHisto.Resize(_bins.size() - 1, _bins.size() - 1, 0); |
| 33 |
|
_totalTextHisto.resize(_bins.size() - 1, 0); |
| 34 |
} |
} |
| 35 |
|
|
| 36 |
RigFillAction::RigFillAction(const char *actionName, TString outFileBase, vector<float> &bins, float thresholdCoeff) : |
RigFillAction::RigFillAction(const char *actionName, TString outFileBase, vector<float> &bins, float thresholdCoeff) : |
| 37 |
CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0, 0, 0), |
CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0, 0, 0), |
| 38 |
_zeroCutoffBins(0), _thresholdCoeff(thresholdCoeff) { |
_zeroCutoffBins(0), _totalTextHisto(0), _thresholdCoeff(thresholdCoeff) { |
| 39 |
|
|
| 40 |
_InitHistos(bins); |
_InitHistos(bins); |
| 41 |
|
|
| 43 |
|
|
| 44 |
RigFillAction::RigFillAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff) : |
RigFillAction::RigFillAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff) : |
| 45 |
CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0, 0, 0), |
CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0, 0, 0), |
| 46 |
_zeroCutoffBins(0), _thresholdCoeff(thresholdCoeff) { |
_zeroCutoffBins(0), _totalTextHisto(0), _thresholdCoeff(thresholdCoeff) { |
| 47 |
|
|
| 48 |
// Reading the bins from file |
// Reading the bins from file |
| 49 |
ifstream rigBinListFile; |
ifstream rigBinListFile; |
| 68 |
float rigThreshold = _thresholdCoeff * event->GetOrbitalInfo()->GetCutoffSVL(); |
float rigThreshold = _thresholdCoeff * event->GetOrbitalInfo()->GetCutoffSVL(); |
| 69 |
float rig = event->GetTrack(0)->GetTrkTrack()->GetRigidity(); |
float rig = event->GetTrack(0)->GetTrkTrack()->GetRigidity(); |
| 70 |
|
|
| 71 |
_rootHisto.Fill(rigThreshold, rig); |
_rootHisto.Fill(rigThreshold, rig); // X,Y in the ROOT histogram |
| 72 |
|
|
| 73 |
//Bin identification: value must be less than (<) bin maximum |
// Event rigidity bin identification. |
| 74 |
|
|
| 75 |
|
// cout << rig << endl; |
| 76 |
|
if (rig < _bins[0] || rig >= _bins[(int) _textHisto.GetNRows()]) { |
| 77 |
|
// cout << "found!" << endl; |
| 78 |
|
return; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
int i = 1; |
int i = 1; |
| 82 |
while (rig >= _bins[i] && i < (int) _textHisto.GetNRows()) { |
while (rig >= _bins[i]) { |
| 83 |
i++; |
i++; |
| 84 |
} |
} |
| 85 |
i--; |
i--; |
| 86 |
|
|
| 87 |
//Check the zero bins |
// Threshold rigidity bin identification. |
| 88 |
if (rigThreshold < _bins[0]) |
|
| 89 |
|
if (rigThreshold < 0 || rigThreshold >= _bins[(int) _textHisto.GetNRows()]) return; |
| 90 |
|
|
| 91 |
|
if (0 <= rigThreshold && rigThreshold < _bins[0]) |
| 92 |
_zeroCutoffBins[i]++; |
_zeroCutoffBins[i]++; |
| 93 |
else { |
else { |
| 94 |
int j = 1; |
int j = 1; |
| 95 |
while (rigThreshold >= _bins[j] && j < (int) _textHisto.GetNCols()) { |
while (rigThreshold >= _bins[j]) { |
| 96 |
j++; |
j++; |
| 97 |
} |
} |
| 98 |
j--; |
j--; |
| 99 |
|
|
| 100 |
if (i < (int) _textHisto.GetNRows() && j < (int) _textHisto.GetNCols()) |
_textHisto[i][j]++; |
| 101 |
_textHisto[i][j]++; |
_totalTextHisto[i]++; |
| 102 |
|
|
| 103 |
} |
} |
| 104 |
} |
} |
| 105 |
|
|
| 121 |
outTextFile.open((_outFileBase + "-report.txt").Data(), ios_base::out); |
outTextFile.open((_outFileBase + "-report.txt").Data(), ios_base::out); |
| 122 |
outTextFile << "Zero bins for cutoff rigidity: \n"; |
outTextFile << "Zero bins for cutoff rigidity: \n"; |
| 123 |
for (unsigned int i = 0; i < _zeroCutoffBins.size(); i++) |
for (unsigned int i = 0; i < _zeroCutoffBins.size(); i++) |
| 124 |
cout << GetCutoffZeroBins()[i] << "\n"; |
outTextFile << GetHistoThreshInfBin()[i] << "\n"; |
| 125 |
|
outTextFile.close(); |
| 126 |
|
|
| 127 |
// Write the ROOT file |
// Write the ROOT file |
| 128 |
TFile outRootFile((_outFileBase + ".root"), "RECREATE"); |
TFile outRootFile((_outFileBase + ".root"), "RECREATE"); |