FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairTestDetectorDigi.h
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 /*
9  * FairTestDetectorDigi.h
10  *
11  * Created on: 20.07.2012
12  * Author: stockman
13  */
14 
15 #ifndef FAIRTESTDETECTORDIGI_H_
16 #define FAIRTESTDETECTORDIGI_H_
17 
18 #include "FairTimeStamp.h" // for FairTimeStamp
19 
20 #include <Rtypes.h> // for Int_t, etc
21 #include <boost/serialization/base_object.hpp>
22 #include <iosfwd> // for ostream
23 #include <iostream> // for operator<<, basic_ostream, etc
24 #include <sstream>
25 #include <string>
26 namespace boost {
27 namespace serialization {
28 class access;
29 }
30 } // namespace boost
31 
33 {
34  public:
36  FairTestDetectorDigi(Int_t x, Int_t y, Int_t z, Double_t timeStamp);
37  virtual ~FairTestDetectorDigi();
38 
39  void SetXYZ(Int_t x, Int_t y, Int_t z)
40  {
41  SetX(x);
42  SetY(y);
43  SetZ(z);
44  }
45  void SetX(Int_t x) { fX = x; }
46  void SetY(Int_t y) { fY = y; }
47  void SetZ(Int_t z) { fZ = z; }
48 
49  Int_t GetX() const { return fX; }
50  Int_t GetY() const { return fY; }
51  Int_t GetZ() const { return fZ; }
52 
53  // temporary to avoid serialisation of the parent class
54  virtual bool equal(FairTimeStamp* data)
55  {
56  FairTestDetectorDigi* myDigi = dynamic_cast<FairTestDetectorDigi*>(data);
57  if (myDigi != 0) {
58  if (fX == myDigi->GetX())
59  if (fY == myDigi->GetY())
60  if (fZ == myDigi->GetZ()) {
61  return true;
62  }
63  }
64  return false;
65  }
66 
67  virtual bool operator<(const FairTestDetectorDigi& myDigi) const
68  {
69  if (fX < myDigi.GetX()) {
70  return true;
71  } else if (fX > myDigi.GetX()) {
72  return false;
73  }
74  if (fY < myDigi.GetY()) {
75  return true;
76  } else if (fY > myDigi.GetY()) {
77  return false;
78  }
79  if (fZ < myDigi.GetZ()) {
80  return true;
81  } else if (fZ > myDigi.GetZ()) {
82  return false;
83  }
84  return false;
85  }
86 
87  friend std::ostream& operator<<(std::ostream& out, FairTestDetectorDigi& digi)
88  {
89  out << "FairTestDetectorDigi at:"
90  << " (" << digi.GetX() << "/" << digi.GetY() << "/" << digi.GetZ() << ") "
91  << " with TimeStamp: " << digi.GetTimeStamp() << std::endl;
92  return out;
93  }
94 
95  template<class T>
96  std::string ToString(const T& value)
97  {
98  std::stringstream ss;
99  ss.precision(5);
100  ss << value;
101  return ss.str();
102  }
103 
104  std::string ToString()
105  {
106  std::string out = "FairTestDetectorDigi at: (" + ToString(GetX()) + "/" + ToString(GetY()) + "/"
107  + ToString(GetZ()) + ") " + " with TimeStamp: " + ToString(GetTimeStamp());
108  return out;
109  }
110 
111  template<class Archive>
112  void serialize(Archive& ar, const unsigned int /*version*/)
113  {
114  ar& boost::serialization::base_object<FairTimeStamp>(*this);
115  ar& fX;
116  ar& fY;
117  ar& fZ;
118  }
119 
120  private:
122 
123  Int_t fX;
124  Int_t fY;
125  Int_t fZ;
126 
127  ClassDef(FairTestDetectorDigi, 1);
128 };
129 
130 #endif /* FAIRTESTDETECTORDIGI_H_ */
virtual bool equal(FairTimeStamp *data)
friend std::ostream & operator<<(std::ostream &out, FairTestDetectorDigi &digi)
friend class boost::serialization::access
std::string ToString(const T &value)
void serialize(Archive &ar, const unsigned int)
Double_t fZ
virtual bool operator<(const FairTestDetectorDigi &myDigi) const
Double_t fY
Double_t GetTimeStamp() const
Definition: FairTimeStamp.h:44
void SetXYZ(Int_t x, Int_t y, Int_t z)
Double_t fX