--- PamCut/CollectionActions/CaloChi2HistoAction/CaloChi2HistoAction.cpp 2010/07/08 14:00:17 1.4 +++ PamCut/CollectionActions/CaloChi2HistoAction/CaloChi2HistoAction.cpp 2011/07/12 15:52:49 1.5 @@ -12,30 +12,51 @@ #include "CaloChi2HistoAction.h" CaloChi2HistoAction::CaloChi2HistoAction(const char *actionName, TString outFileName, CaloAxis *xAxis, CaloAxis *yAxis, - float min, float max, unsigned int nBins, TString mode) : - CollectionAction(actionName), _outFileName(outFileName), _xAxis(xAxis), _yAxis(yAxis), _mode(mode), _xHisto(), - _yHisto(), _xyHisto() { + float min, float max, unsigned int nBins, bool logBinning, TString mode) : + CollectionAction(actionName), _outFileName(outFileName), _xAxis(xAxis), _yAxis(yAxis), _mode(mode), _xHisto(), _yHisto(), _xyHisto() { + + Double_t *bins = new Double_t[nBins + 1]; + + if (!logBinning || (logBinning && min <= 0.)) { + +#ifdef DEBUGPAMCUT + if (logbinning && rigMin <= 0.) + cout << "Warning: logarithmic binning was chosen for X axis but min <= 0. Using linear binning." +#endif + + float step = (max - min) / nBins; + for (unsigned int i = 0; i < nBins + 1; i++) { + bins[i] = min + i * step; + } + + } + else { + + double maxExp = log10(max / min); + for (unsigned int i = 0; i < nBins + 1; i++) { + bins[i] = min * pow(10., (double) i / ((double) nBins) * maxExp); + } + + } _xHisto.SetName(TString(GetName()) + TString("_x")); _xHisto.SetTitle("CALO Chi2 (X view)"); - _xHisto.SetBins(nBins, min, max); + _xHisto.SetBins(nBins, bins); _xHisto.GetXaxis()->SetTitle("Chi2 (X)"); _xHisto.GetYaxis()->SetTitle("Events"); - _yHisto.SetName(TString(GetName()) + TString("_y")); - _yHisto.SetBins(nBins, min, max); + _yHisto.SetBins(nBins, bins); _yHisto.SetTitle("CALO Chi2 (Y view)"); _xHisto.GetXaxis()->SetTitle("Chi2 (Y)"); _xHisto.GetYaxis()->SetTitle("Events"); _xyHisto.SetName(TString(GetName()) + TString("_xy")); - _xyHisto.SetBins(nBins, min, max, nBins, min, max); + _xyHisto.SetBins(nBins, bins, nBins, bins); _xyHisto.SetTitle("CALO Chi2"); _xyHisto.GetXaxis()->SetTitle("Chi2 (X)"); _xyHisto.GetYaxis()->SetTitle("Chi2 (Y)"); - } void CaloChi2HistoAction::OnGood(PamLevel2 *event) {