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

Diff of /PamCut/CollectionActions/LiveTimeAction/LiveTimeAction.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by pam-fi, Wed Aug 5 17:43:15 2009 UTC revision 1.4 by pam-fi, Wed Aug 26 16:34:14 2009 UTC
# Line 33  void LiveTimeAction::_InitHistos(vector< Line 33  void LiveTimeAction::_InitHistos(vector<
33    
34  LiveTimeAction::LiveTimeAction(const char *actionName, TString outFileBase, vector<float> &bins, float thresholdCoeff) :  LiveTimeAction::LiveTimeAction(const char *actionName, TString outFileBase, vector<float> &bins, float thresholdCoeff) :
35    CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0), _thresholdCoeff(    CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0), _thresholdCoeff(
36        thresholdCoeff), _total(0.), _zeroBin(0.)        thresholdCoeff), _totalNorm(0.), _infBin(0.), _nGoodHisto(0), _nGoodInfBin(0)
37  #ifdef DEBUGPAMCUT  #ifdef DEBUGPAMCUT
38  , _outUp(0), _outDown(0)  , _outUp(0), _outDown(0)
39  #endif  #endif
# Line 43  LiveTimeAction::LiveTimeAction(const cha Line 43  LiveTimeAction::LiveTimeAction(const cha
43    
44  LiveTimeAction::LiveTimeAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff) :  LiveTimeAction::LiveTimeAction(const char *actionName, TString outFileBase, TString rigBinsFile, float thresholdCoeff) :
45    CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0), _thresholdCoeff(    CollectionAction(actionName), _outFileBase(outFileBase), _bins(0), _rootHisto(), _textHisto(0), _thresholdCoeff(
46        thresholdCoeff), _total(0.), _zeroBin(0.)        thresholdCoeff), _totalNorm(0.), _infBin(0.), _nGoodHisto(0), _nGoodInfBin(0)
47  #ifdef DEBUGPAMCUT  #ifdef DEBUGPAMCUT
48  , _outUp(0), _outDown(0)  , _outUp(0), _outDown(0)
49  #endif  #endif
# Line 69  LiveTimeAction::LiveTimeAction(const cha Line 69  LiveTimeAction::LiveTimeAction(const cha
69    
70  void LiveTimeAction::OnGood(PamLevel2 *event) {  void LiveTimeAction::OnGood(PamLevel2 *event) {
71    
72    float lt = 0.16 * (float) event->GetTrigLevel2()->dltime[0] / 1000.; // In seconds    double lt = 0.16 * (double) event->GetTrigLevel2()->dltime[0] / 1000.; // In seconds
73    _total += lt;    
74    //  cout << 0.16 * event->GetTrigLevel2()->dltime[0] / 1000. << endl;
75    //  cout << lt << endl;
76    
77    float cRig = _thresholdCoeff * event->GetOrbitalInfo()->GetCutoffSVL();    float cRig = _thresholdCoeff * event->GetOrbitalInfo()->GetCutoffSVL();
78    if (cRig >= _bins[0]) {    if (cRig >= _bins[0]) {
79      int i = 1;      int i = 1;
80      int binningSize = _bins.size();      int binningSize = _bins.size();
81      bool found = false;      bool found = false;
82      while (!found && i < binningSize) {      while (!found && i < binningSize) {
83        if (cRig < _bins[i])        if (cRig < _bins[i]) // less than bin[i-1] maximum edge
84          found = true;          found = true;
85        else        else
86          i++;          i++;
87      }      }
88      if (found) {      if (found) {
89        _textHisto[i - 1] += lt;        _totalNorm += lt; // use double for sums of many real numbers
90          _textHisto[i - 1] += lt; // use double for sums of many real numbers
91        _rootHisto.Fill(cRig, lt);        _rootHisto.Fill(cRig, lt);
92          _nGoodHisto++;
93      }      }
94    
95  #ifdef DEBUGPAMCUT  #ifdef DEBUGPAMCUT
# Line 93  void LiveTimeAction::OnGood(PamLevel2 *e Line 98  void LiveTimeAction::OnGood(PamLevel2 *e
98  #endif  #endif
99    }    }
100    
101    else {    else if (cRig > 0.) {
102      _zeroBin += lt;      _infBin += lt;
103        _nGoodInfBin++;
104  #ifdef DEBUGPAMCUT  #ifdef DEBUGPAMCUT
105      _outDown++;      _outDown++;
106  #endif  #endif
# Line 115  void LiveTimeAction::Finalize() { Line 121  void LiveTimeAction::Finalize() {
121        outTextFile << _textHisto[i] << "\n";        outTextFile << _textHisto[i] << "\n";
122      outTextFile.close();      outTextFile.close();
123      outTextFile.open((_outFileBase + "-report.txt").Data(), ios_base::out);      outTextFile.open((_outFileBase + "-report.txt").Data(), ios_base::out);
124      outTextFile << "Zero bin: " << GetZeroBin() << "\n";      outTextFile << "Inferior bin: " << GetLTInfBin() << "\n";
125      outTextFile << "Total live time: " << GetTotalLT() << "\n";      outTextFile << "Total live time within normal bins: " << GetTotalLTHisto() << "\n";
126      outTextFile.close();      outTextFile.close();
127      outTextFile.precision(oldPrec);      outTextFile.precision(oldPrec);
128      outTextFile << resetiosflags(ios::floatfield);      outTextFile << resetiosflags(ios::floatfield);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.23