TPCCondData
TPCDistortionMeasurement.cc
Go to the documentation of this file.
1 
3 #include <Exceptions.h>
4 
5 namespace tpcconddata {
6 
8  return std::string("$Rev: 2568 $");
9 }
10 
12  return std::string("TPCDistortionMeasurement");
13 }
14 
15 TPCDistortionMeasurement::TPCDistortionMeasurement(CLHEP::Hep3Vector* truePosition, CLHEP::Hep3Vector* reconstructedPosition, int dot_id) :
16  _createObj(true) // remember that we have to delete the object in the destructor
17 {
18  // create a fixed size generic object with 5 ints
19  _myObj = new IMPL::LCGenericObjectImpl(1, 0, 6);
20 
21  // set the 4 values
22  _myObj->setDoubleVal(0, truePosition->getX());
23  _myObj->setDoubleVal(1, truePosition->getY());
24  _myObj->setDoubleVal(2, truePosition->getZ());
25  _myObj->setDoubleVal(3, reconstructedPosition->getX());
26  _myObj->setDoubleVal(4, reconstructedPosition->getY());
27  _myObj->setDoubleVal(5, reconstructedPosition->getZ());
28  _myObj->setIntVal(0, dot_id);
29 }
30 
32  _createObj(false) // we did not create the object, so we must not delete it in the d'tor
33 {
34  // initialise the object pointer
35  _myObj = dynamic_cast<IMPL::LCGenericObjectImpl*>(obj);
36 
37  if (_myObj == 0) // the cast did not succeed
38  {
39  throw lcio::Exception("Cannot create TPCDistortionMeasurement from sth."
40  " that is not LCGenericObjectImpl");
41  }
42 
43  // check the size of the generic object
44  // there have to be no ints, no floats and 6 doubles
45  if ((_myObj->getNInt() != 1)
46  || (_myObj->getNFloat() != 0) || (_myObj->getNDouble() != 6)) {
47  throw lcio::Exception(
48  "TPCDistortionMeasurement(LCObject* obj): Wrong number of elements in object");
49  }
50 
51 }
52 
54  // delete the LCGenericObjectImpl, but only if it was created in the constructor
55  if (_createObj)
56  delete (_myObj);
57 }
58 
59 void TPCDistortionMeasurement::print(std::ostream& os) const {
60  os << "TPCDistortionMeasurement: true photodot position (" << getTruePosition().getX()
61  << "," << getTruePosition().getY()
62  << "," << getTruePosition().getZ() << std::endl;
63  os << "TPCDistortionMeasurement: reconstructed photodot position (" << getReconstructedPosition().getX()
64  << "," << getReconstructedPosition().getY()
65  << "," << getReconstructedPosition().getZ() << std::endl;
66 
67 }
68 
70  CLHEP::Hep3Vector v;
71  v.set(_myObj->getDoubleVal(0),_myObj->getDoubleVal(1),_myObj->getDoubleVal(2));
72  return v;
73 }
74 
76  CLHEP::Hep3Vector v;
77  v.set(_myObj->getDoubleVal(3),_myObj->getDoubleVal(4),_myObj->getDoubleVal(5));
78  return v;
79 }
80 
81 
83  return _myObj->getIntVal(0);
84 }
85 
86 std::ostream &operator<<(std::ostream &os, const TPCDistortionMeasurement &acm) {
87  acm.print(os);
88  return os;
89 }
90 
91 }
92  //namespace
IMPL::LCGenericObjectImpl * obj() const
std::ostream & operator<<(std::ostream &os, const ADCChannelMapping &acm)
TPCDistortionMeasurement(CLHEP::Hep3Vector *truePosition, CLHEP::Hep3Vector *reconstructedPosition, int dot_id)
The constructor with all the member functions given.
virtual ~TPCDistortionMeasurement()
The desctructor.
class to store the distortions measured with the photoelectric system using a laser.
CLHEP::Hep3Vector getReconstructedPosition() const
void print(std::ostream &os=std::cout) const