/[PAMELA software]/PamCut/CollectionActions/CaloChi2HistoAction/CaloChi2HistoAction.cpp
ViewVC logotype

Annotation of /PamCut/CollectionActions/CaloChi2HistoAction/CaloChi2HistoAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Tue Jul 12 15:52:49 2011 UTC (13 years, 4 months ago) by pam-fi
Branch: MAIN
CVS Tags: V9, HEAD
Changes since 1.4: +29 -8 lines
Logarithmic binning flag added.

1 pam-fi 1.1 /*
2     * CaloChi2HistoAction.cpp
3     *
4     * Created on: 04/ago/2009
5     * Author: Nicola Mori
6     */
7    
8     /*! @file CaloChi2HistoAction.cpp The CaloChi2HistoAction class implementation file. */
9    
10 pam-fi 1.4 #ifndef NO_CALOAXIS
11    
12 pam-fi 1.1 #include "CaloChi2HistoAction.h"
13    
14     CaloChi2HistoAction::CaloChi2HistoAction(const char *actionName, TString outFileName, CaloAxis *xAxis, CaloAxis *yAxis,
15 pam-fi 1.5 float min, float max, unsigned int nBins, bool logBinning, TString mode) :
16     CollectionAction(actionName), _outFileName(outFileName), _xAxis(xAxis), _yAxis(yAxis), _mode(mode), _xHisto(), _yHisto(), _xyHisto() {
17    
18     Double_t *bins = new Double_t[nBins + 1];
19    
20     if (!logBinning || (logBinning && min <= 0.)) {
21    
22     #ifdef DEBUGPAMCUT
23     if (logbinning && rigMin <= 0.)
24     cout << "Warning: logarithmic binning was chosen for X axis but min <= 0. Using linear binning."
25     #endif
26    
27     float step = (max - min) / nBins;
28     for (unsigned int i = 0; i < nBins + 1; i++) {
29     bins[i] = min + i * step;
30     }
31    
32     }
33     else {
34    
35     double maxExp = log10(max / min);
36     for (unsigned int i = 0; i < nBins + 1; i++) {
37     bins[i] = min * pow(10., (double) i / ((double) nBins) * maxExp);
38     }
39    
40     }
41 pam-fi 1.1
42     _xHisto.SetName(TString(GetName()) + TString("_x"));
43     _xHisto.SetTitle("CALO Chi2 (X view)");
44 pam-fi 1.5 _xHisto.SetBins(nBins, bins);
45 pam-fi 1.1 _xHisto.GetXaxis()->SetTitle("Chi2 (X)");
46     _xHisto.GetYaxis()->SetTitle("Events");
47    
48     _yHisto.SetName(TString(GetName()) + TString("_y"));
49 pam-fi 1.5 _yHisto.SetBins(nBins, bins);
50 pam-fi 1.1 _yHisto.SetTitle("CALO Chi2 (Y view)");
51     _xHisto.GetXaxis()->SetTitle("Chi2 (Y)");
52     _xHisto.GetYaxis()->SetTitle("Events");
53    
54     _xyHisto.SetName(TString(GetName()) + TString("_xy"));
55 pam-fi 1.5 _xyHisto.SetBins(nBins, bins, nBins, bins);
56 pam-fi 1.1 _xyHisto.SetTitle("CALO Chi2");
57     _xyHisto.GetXaxis()->SetTitle("Chi2 (X)");
58     _xyHisto.GetYaxis()->SetTitle("Chi2 (Y)");
59    
60     }
61    
62     void CaloChi2HistoAction::OnGood(PamLevel2 *event) {
63    
64     _xHisto.Fill(_xAxis->GetChi2());
65     _yHisto.Fill(_yAxis->GetChi2());
66     _xyHisto.Fill(_xAxis->GetChi2(), _yAxis->GetChi2());
67    
68     }
69    
70     void CaloChi2HistoAction::Finalize() {
71    
72     TFile outFile(_outFileName, _mode);
73     outFile.cd();
74     _xHisto.Write();
75     _yHisto.Write();
76     _xyHisto.Write();
77     outFile.Close();
78     }
79    
80 pam-fi 1.4 #endif /* NO_CALOAXIS */

  ViewVC Help
Powered by ViewVC 1.1.23