/[PAMELA software]/PamCut/CollectionActions/Histo1DActions/LiveTimeAction/LiveTimeAction.cpp
ViewVC logotype

Contents of /PamCut/CollectionActions/Histo1DActions/LiveTimeAction/LiveTimeAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Thu Mar 11 19:11:28 2010 UTC (14 years, 8 months ago) by pam-fi
Branch: MAIN
CVS Tags: Root_V8, MergedToHEAD_1, nuclei_reproc, MergedFromV8_1, BeforeMergingFromV8_1
Branch point for: V8
Added to repository. Replacing old version.

1 /*
2 * LiveTimeAction.cpp
3 *
4 * Created on: 13/lug/2009
5 * Author: Nicola Mori
6 */
7
8 /*! @file LiveTimeAction.cpp The LiveTimeAction class implementation file. */
9
10 #include "LiveTimeAction.h"
11
12 LiveTimeAction::LiveTimeAction(const char *actionName, TString outFileBase, vector<float> &bins, float thresholdCoeff) :
13 Histo1DAction<Double_t> (actionName, "", outFileBase, "RECREATE", false, true), _thresholdCoeff(thresholdCoeff),
14 _totalNorm(0.), _nGoodHisto(0), _nGoodInfBin(0) {
15 SetXAxis("Live Time [s]", bins);
16 }
17
18 LiveTimeAction::LiveTimeAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff) :
19 Histo1DAction<Double_t> (actionName, "", outFileBase, "RECREATE", false, true), _thresholdCoeff(thresholdCoeff),
20 _totalNorm(0.), _nGoodHisto(0), _nGoodInfBin(0) {
21 SetXAxis("Live Time [s]", rigBinsFile);
22 }
23
24 void LiveTimeAction::OnGood(PamLevel2 *event) {
25
26 double lt = 0.16 * (double) event->GetTrigLevel2()->dltime[0] / 1000.; // In seconds
27 float cRig = _thresholdCoeff * event->GetOrbitalInfo()->GetCutoffSVL();
28
29 Fill(cRig, lt);
30
31 if (cRig >= _bins[0]) {
32
33 if (cRig < _bins.back()) {
34 _totalNorm += lt; // use double for sums of many real numbers
35 _nGoodHisto++;
36 }
37 }
38
39 else if (cRig > 0.) {
40 _nGoodInfBin++;
41 }
42 }
43
44 void LiveTimeAction::Finalize() {
45
46 if (_outFileBase != "") {
47
48 // Write the text file
49 // Using custom output procedure (instead of standard Histo1D::Finalize) to set output precision
50 ofstream outTextFile((_outFileBase + ".txt").Data(), ios_base::out);
51 streamsize oldPrec = cout.precision();
52 streamsize newPrec = 4;
53 outTextFile.precision(newPrec);
54 outTextFile.setf(ios::fixed, ios::floatfield);
55 for (unsigned int i = 0; i < GetHisto().size(); i++)
56 outTextFile << GetHisto()[i] << "\n";
57 outTextFile.close();
58 outTextFile.open((_outFileBase + "-InfBin.txt").Data(), ios_base::out);
59 outTextFile << GetLTInfBin() << endl;
60 outTextFile.close();
61 outTextFile.precision(oldPrec);
62 outTextFile << resetiosflags(ios::floatfield);
63
64 }
65 }

  ViewVC Help
Powered by ViewVC 1.1.23