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

Annotation of /PamCut/CollectionActions/TrkChi2VsDeflHistoAction/TrkChi2VsDeflHistoAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Fri Sep 25 15:36:39 2009 UTC (15 years, 2 months ago) by pam-fi
Branch: MAIN
CVS Tags: Root_V8, MergedToHEAD_1, nuclei_reproc, MergedFromV8_1, BeforeMergingFromV8_1, V9, HEAD
Branch point for: V8
Added to repository.

1 pam-fi 1.1 /*
2     * TrkChi2VsDeflHistoAction.cpp
3     *
4     * Created on: 14/ago/2009
5     * Author: Nicola Mori
6     */
7    
8     /*! @file TrkChi2VsDeflHistoAction.cpp The TrkChi2VsDeflHistoAction class implementation file. */
9    
10     #include "TrkChi2VsDeflHistoAction.h"
11    
12     TrkChi2VsDeflHistoAction::TrkChi2VsDeflHistoAction(const char *actionName, TString outFileName, TString mode,
13     bool logChi2, float minDefl, float maxDefl, unsigned int nBinsDefl, float minChi2, float maxChi2,
14     unsigned int nBinsChi2) :
15     CollectionAction(actionName), _outFileName(outFileName), _histo(), _histoX(0), _histoY(0), _mode(mode), _logChi2(
16     logChi2), _cout_sbuf(cout.rdbuf()), _fout("/dev/null"){
17    
18     double deflBins[nBinsDefl + 1];
19     double maxExp = log10(maxDefl / minDefl);
20     for (unsigned int i = 0; i < nBinsDefl + 1; i++) {
21     deflBins[i] = minDefl * pow(10., (double) i / ((double) nBinsDefl) * maxExp);
22     }
23    
24     double chi2Bins[nBinsChi2 + 1];
25     if (_logChi2) {
26     //LINEAR scale for log10(chi2) values
27     double chi2Step = (log10(maxChi2 / minChi2)) / (double) nBinsChi2;
28     minChi2 = log10(minChi2);
29     for (unsigned int i = 0; i < nBinsChi2 + 1; i++) {
30     chi2Bins[i] = minChi2 + i * chi2Step;
31     }
32     }
33     else {
34     //LOG scale for chi2 values
35     maxExp = log10(maxChi2 / minChi2);
36     for (unsigned int i = 0; i < nBinsChi2 + 1; i++) {
37     chi2Bins[i] = minChi2 * pow(10., (double) i / ((double) nBinsChi2) * maxExp);
38     }
39     }
40     _histo.SetBins(nBinsDefl, deflBins, nBinsChi2, chi2Bins);
41    
42     // Set labels
43     _histo.SetName(GetName());
44     _histoX = (TH2F*) _histo.Clone(TString(GetName()) + TString("_X"));
45     _histoY = (TH2F*) _histo.Clone(TString(GetName()) + TString("_Y"));
46     if (_logChi2) {
47     _histo.SetTitle("Trk log10(Chi2) Vs Deflection");
48     _histo.GetYaxis()->SetTitle("log10(Chi2)");
49     _histoX->SetTitle("Trk log10(Chi2 X) Vs Deflection");
50     _histoX->GetYaxis()->SetTitle("log10(Chi2 X)");
51     _histoY->SetTitle("Trk log10(Chi2 Y) Vs Deflection");
52     _histoY->GetYaxis()->SetTitle("log10(Chi2 Y)");
53     }
54     else {
55     _histo.SetTitle("Trk Chi2 Vs Deflection");
56     _histo.GetYaxis()->SetTitle("Chi2");
57     _histoX->SetTitle("Trk Chi2 X Vs Deflection");
58     _histoX->GetYaxis()->SetTitle("Chi2 X");
59     _histoY->SetTitle("Trk Chi2 Y Vs Deflection");
60     _histoY->GetYaxis()->SetTitle("Chi2 Y");
61     }
62    
63     //_histo.SetBins(nBinsDefl, minDefl, maxDefl, nBinsChi2, minChi2, maxChi2);
64    
65    
66     }
67    
68     void TrkChi2VsDeflHistoAction::OnGood(PamLevel2 *event) {
69    
70     cout.rdbuf(_fout.rdbuf());
71    
72     if (_logChi2) {
73     if (event->GetTrack(0)->GetTrkTrack()->chi2 > 0.) {
74     _histo.Fill(event->GetTrack(0)->GetTrkTrack()->GetDeflection(), log10(event->GetTrack(0)->GetTrkTrack()->chi2));
75     _histoX->Fill(event->GetTrack(0)->GetTrkTrack()->GetDeflection(), log10(
76     event->GetTrack(0)->GetTrkTrack()->GetChi2X()));
77     _histoY->Fill(event->GetTrack(0)->GetTrkTrack()->GetDeflection(), log10(
78     event->GetTrack(0)->GetTrkTrack()->GetChi2Y()));
79     }
80     }
81     else {
82     _histo.Fill(event->GetTrack(0)->GetTrkTrack()->GetDeflection(), event->GetTrack(0)->GetTrkTrack()->chi2);
83     _histoX->Fill(event->GetTrack(0)->GetTrkTrack()->GetDeflection(), event->GetTrack(0)->GetTrkTrack()->GetChi2X());
84     _histoY->Fill(event->GetTrack(0)->GetTrkTrack()->GetDeflection(), event->GetTrack(0)->GetTrkTrack()->GetChi2Y());
85     }
86    
87     cout.rdbuf(_cout_sbuf);
88     }
89     void TrkChi2VsDeflHistoAction::Finalize() {
90    
91     TFile outFile(_outFileName, _mode);
92     outFile.cd();
93     _histo.Write();
94     _histoX->Write();
95     _histoY->Write();
96     outFile.Close();
97     }

  ViewVC Help
Powered by ViewVC 1.1.23