FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MyDigi.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 /*
10  * File: MyDigi.h
11  * Author: winckler
12  *
13  * Created on November 24, 2014, 1:31 PM
14  */
15 
16 #ifndef MYDIGIDATA_H
17 #define MYDIGIDATA_H
18 
19 #include "FairTimeStamp.h" // for FairTimeStamp
20 
21 #include <Rtypes.h> // for Int_t, etc
22 #include <iosfwd> // for ostream
23 #include <iostream> // for operator<<, basic_ostream, etc
24 
25 namespace boost {
26 namespace serialization {
27 class access;
28 }
29 } // namespace boost
30 #include <boost/serialization/base_object.hpp>
31 
32 class MyDigi : public FairTimeStamp
33 {
34  public:
35  MyDigi();
36  MyDigi(Int_t x, Int_t y, Int_t z, Double_t timeStamp, Double_t timeStampError = 0.0);
37  virtual ~MyDigi();
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  MyDigi* myDigi = dynamic_cast<MyDigi*>(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 MyDigi& 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, MyDigi& digi)
88  {
89  out << "MyDigi at:"
90  << " (" << digi.GetX() << "/" << digi.GetY() << "/" << digi.GetZ() << ") "
91  << " with TimeStamp: " << digi.GetTimeStamp() << std::endl;
92  return out;
93  }
94 
95  template<class Archive>
96  void serialize(Archive& ar, const unsigned int /*version*/)
97  {
98  ar& boost::serialization::base_object<FairTimeStamp>(*this);
99  ar& fX;
100  ar& fY;
101  ar& fZ;
102  }
103 
104  private:
106 
107  Int_t fX;
108  Int_t fY;
109  Int_t fZ;
110 
111  ClassDef(MyDigi, 1);
112 };
113 
114 #endif /* MYDIGIDATA_H */
friend class boost::serialization::access
Definition: MyDigi.h:105
virtual bool equal(FairTimeStamp *data)
Definition: MyDigi.h:54
void SetXYZ(Int_t x, Int_t y, Int_t z)
Definition: MyDigi.h:39
void serialize(Archive &ar, const unsigned int)
Definition: MyDigi.h:96
Int_t GetZ() const
Definition: MyDigi.h:51
Int_t GetX() const
Definition: MyDigi.h:49
virtual ~MyDigi()
Definition: MyDigi.cxx:33
Int_t GetY() const
Definition: MyDigi.h:50
Double_t fZ
friend std::ostream & operator<<(std::ostream &out, MyDigi &digi)
Definition: MyDigi.h:87
virtual bool operator<(const MyDigi &myDigi) const
Definition: MyDigi.h:67
Definition: MyDigi.h:32
void SetX(Int_t x)
Definition: MyDigi.h:45
Double_t fY
void SetZ(Int_t z)
Definition: MyDigi.h:47
Double_t GetTimeStamp() const
Definition: FairTimeStamp.h:44
Double_t fX
MyDigi()
Definition: MyDigi.cxx:19
void SetY(Int_t y)
Definition: MyDigi.h:46