--- PamCut/CollectionActions/RigFillAction/RigFillAction.cpp 2009/08/05 17:43:36 1.3 +++ PamCut/CollectionActions/RigFillAction/RigFillAction.cpp 2009/08/26 16:34:15 1.4 @@ -30,11 +30,12 @@ _zeroCutoffBins.resize(_bins.size() - 1, 0); _textHisto.Resize(_bins.size() - 1, _bins.size() - 1, 0); + _totalTextHisto.resize(_bins.size() - 1, 0); } RigFillAction::RigFillAction(const char *actionName, TString outFileBase, vector &bins, float thresholdCoeff) : CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0, 0, 0), - _zeroCutoffBins(0), _thresholdCoeff(thresholdCoeff) { + _zeroCutoffBins(0), _totalTextHisto(0), _thresholdCoeff(thresholdCoeff) { _InitHistos(bins); @@ -42,7 +43,7 @@ RigFillAction::RigFillAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff) : CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0, 0, 0), - _zeroCutoffBins(0), _thresholdCoeff(thresholdCoeff) { + _zeroCutoffBins(0), _totalTextHisto(0), _thresholdCoeff(thresholdCoeff) { // Reading the bins from file ifstream rigBinListFile; @@ -67,28 +68,38 @@ float rigThreshold = _thresholdCoeff * event->GetOrbitalInfo()->GetCutoffSVL(); float rig = event->GetTrack(0)->GetTrkTrack()->GetRigidity(); - _rootHisto.Fill(rigThreshold, rig); + _rootHisto.Fill(rigThreshold, rig); // X,Y in the ROOT histogram - //Bin identification: value must be less than (<) bin maximum + // Event rigidity bin identification. + +// cout << rig << endl; + if (rig < _bins[0] || rig >= _bins[(int) _textHisto.GetNRows()]) { +// cout << "found!" << endl; + return; + } int i = 1; - while (rig >= _bins[i] && i < (int) _textHisto.GetNRows()) { + while (rig >= _bins[i]) { i++; } i--; - //Check the zero bins - if (rigThreshold < _bins[0]) + // Threshold rigidity bin identification. + + if (rigThreshold < 0 || rigThreshold >= _bins[(int) _textHisto.GetNRows()]) return; + + if (0 <= rigThreshold && rigThreshold < _bins[0]) _zeroCutoffBins[i]++; else { int j = 1; - while (rigThreshold >= _bins[j] && j < (int) _textHisto.GetNCols()) { + while (rigThreshold >= _bins[j]) { j++; } j--; - if (i < (int) _textHisto.GetNRows() && j < (int) _textHisto.GetNCols()) - _textHisto[i][j]++; + _textHisto[i][j]++; + _totalTextHisto[i]++; + } } @@ -110,7 +121,7 @@ outTextFile.open((_outFileBase + "-report.txt").Data(), ios_base::out); outTextFile << "Zero bins for cutoff rigidity: \n"; for (unsigned int i = 0; i < _zeroCutoffBins.size(); i++) - outTextFile << GetCutoffZeroBins()[i] << "\n"; + outTextFile << GetHistoThreshInfBin()[i] << "\n"; outTextFile.close(); // Write the ROOT file