StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GainVoltCoeffCalculator.cxx
1 #include "GainVoltCoeffCalculator.h"
10 #include "GainVoltPmtParameters.h"
11 using namespace std;
12 //ClassImp(GainVoltCoeffCalculator)
13 
14 GainVoltCoeffCalculator::GainVoltCoeffCalculator()
15 {}
16 
17 GainVoltCoeffCalculator::GainVoltCoeffCalculator(const GainVoltCoeffCalculator&calculator)
18  : _pmts(calculator._pmts)
19 {}
20 
21 GainVoltCoeffCalculator::~GainVoltCoeffCalculator()
22 {}
23 
24 GainVoltCoeffCalculator & GainVoltCoeffCalculator::operator=(const GainVoltCoeffCalculator&calculator)
25 {
26  _pmts = calculator._pmts;
27  return *this;
28 }
29 
30 void GainVoltCoeffCalculator::setIoMode(int mode)
31 {
32  GainVoltPmtParameters::ioMode = mode;
33 }
34 
35 vector<GainVoltPmtParameters*>::iterator GainVoltCoeffCalculator::begin()
36 {
37  return _pmts.begin();
38 }
39 
40 vector<GainVoltPmtParameters*>::iterator GainVoltCoeffCalculator::end()
41 {
42  return _pmts.end();
43 }
44 
45 vector<GainVoltPmtParameters*>::const_iterator GainVoltCoeffCalculator::begin() const
46 {
47  return _pmts.begin();
48 }
49 
50 vector<GainVoltPmtParameters*>::const_iterator GainVoltCoeffCalculator::end() const
51 {
52  return _pmts.end();
53 }
54 
55 
56 void GainVoltCoeffCalculator::process()
57 {
58  setIoMode(3);
59  try
60  {
61  // loop over all PMTs, and perform a fit.
62  GVP_iterator i;
63  //VPunused int count=0;
64  for (i=_pmts.begin();i!=_pmts.end();i++)
65  {
66  (*i)->fit();
67  //cout << count++ << "\t"<< *(*i);
68  }
69  }
70  catch (runtime_error & err)
71  {
72  cout << "GainVoltCoeffCalculator::process() - RunTimeError -"<< err.what() << endl;
73  }
74 }
75 
77 istream& operator>>(istream& is, GainVoltCoeffCalculator& object)
78 {
79  int n;
80  is >> n;
81  if (n<=0)
82  {
83  cout << "GainVoltCoeffCalculator::operator>>() - FATAL - nPmt<=0";
84  return is;
85  }
87  //Loop n times
88  //For each, instantiate, read, and add to container
89  for (int i=0;i<n;i++)
90  {
91  pmt = new GainVoltPmtParameters();
92  is >> *pmt;
93  object._pmts.push_back(pmt);
94  //cout << *pmt;
95  }
96  return is;
97 }
98 
99 ostream& operator<<(ostream& os, GainVoltCoeffCalculator& object)
100 {
101  vector<GainVoltPmtParameters*>::iterator i;
102  for (i=object._pmts.begin();i!=object._pmts.end();i++)
103  os << *(*i);
104  return os;
105 }
106