PandaRoot
PndGemDigi.h
Go to the documentation of this file.
1 //* $Id: */
2 
3 // -------------------------------------------------------------------------
4 // ----- PndGemDigi header file -----
5 // ----- Adapted in 2010 by R. Karabowicz -----
6 // -------------------------------------------------------------------------
7 
19 #ifndef PNDGEMDIGI_H
20 #define PNDGEMDIGI_H 1
21 
22 #include <vector>
23 
24 #include "FairTimeStamp.h"
25 
26 #include "PndDetectorList.h"
27 
28 #include "TObject.h"
29 
30 class PndGemDigi : public FairTimeStamp {
31  friend std::ostream &operator<<(std::ostream &out, PndGemDigi &digi)
32  {
33  out << "PndGemDigi in: " << digi.GetDetectorId() << "( system = " << digi.GetSystemId() << ", station = " << digi.GetStationNr() << ", sensor = " << digi.GetSensorNr()
34  << ", side = " << digi.GetSide() << "), channelNr = " << digi.GetChannelNr() << ", charge = " << digi.GetCharge() << ", cor = " << digi.GetCor() << ", timestamp "
35  << digi.GetTimeStamp() << ", from Point(s) ";
36  std::vector<Int_t> indices = digi.GetIndices();
37  for (unsigned int i = 0; i < indices.size(); i++) {
38  out << indices[i] << " ";
39  }
40  out << std::endl;
41 
42  return out;
43  }
44 
45  public:
47  PndGemDigi();
48 
56  PndGemDigi(Int_t iDetectorId, Double_t iChannel, Int_t index);
57  PndGemDigi(Int_t iDetectorId, Double_t iChannel, Int_t index, Double_t signal, Double_t time);
58 
60  virtual ~PndGemDigi();
61 
62  void SetCharge(Double_t iCharge) { fDigiCharge = iCharge; }
63  void SetCor(Double_t iCor) { fDigiCor = iCor; }
64 
65  void AddCharge(Double_t iCharge) { fDigiCharge += iCharge; }
66 
68  Int_t GetDetectorId() const { return fDetectorId; }
69  Double_t GetChannelNr() const { return fChannelNr; }
70 
71  Int_t GetSystemId() const { return ((fDetectorId & (31 << 27)) >> 27); }
72  Int_t GetStationNr() const { return ((fDetectorId & (8191 << 8)) >> 8); }
73  Int_t GetSensorNr() const
74  { // sensor number within station
75  return ((fDetectorId & (3 << 6)) >> 6);
76  }
77  Int_t GetSide() const { return ((fDetectorId & (1 << 5)) >> 5); } // 0=front, 1=back
78 
79  Double_t GetCharge() const { return fDigiCharge; }
80  Double_t GetCor() const { return fDigiCor; }
81 
82  std::vector<Int_t> GetIndices() const
83  {
84  std::vector<Int_t> result;
85  std::set<FairLink> myLinks = GetLinks();
86  for (std::set<FairLink>::iterator it = myLinks.begin(); it != myLinks.end(); it++) {
87  result.push_back(it->GetIndex());
88  }
89  return result;
90  }
91  Int_t GetNIndices() { return GetNLinks(); }
92  Int_t GetIndex(int i = 0) const { return GetLink(i).GetIndex(); }
93 
94  void AddIndex(int index) { AddLink(FairLink("GEMPoint", index)); }
95  void AddIndex(std::vector<Int_t> index) { SetLinks(FairMultiLinkedData("GEMPoint", index)); }
96 
97  virtual bool equal(FairTimeStamp *data)
98  {
99  PndGemDigi *myDigi = dynamic_cast<PndGemDigi *>(data);
100  if (myDigi != nullptr) {
101  if (fDetectorId == myDigi->GetDetectorId())
102  return kTRUE;
103  }
104  return false;
105  }
106 
107  virtual bool operator<(const PndGemDigi &myDigi) const
108  {
109  if (fDetectorId < myDigi.GetDetectorId())
110  return true;
111  else if (fDetectorId > myDigi.GetDetectorId())
112  return false;
113  if (fChannelNr < myDigi.GetChannelNr())
114  return true;
115  else if (fChannelNr > myDigi.GetChannelNr())
116  return false;
117  return false;
118  }
119 
120  virtual bool operator>(const PndGemDigi &myDigi) const
121  {
122  if (fDetectorId > myDigi.GetDetectorId())
123  return true;
124  else if (fDetectorId < myDigi.GetDetectorId())
125  return false;
126  if (fChannelNr > myDigi.GetChannelNr())
127  return true;
128  else if (fChannelNr < myDigi.GetChannelNr())
129  return false;
130  return false;
131  }
132 
133  virtual bool operator==(const PndGemDigi &myDigi) const
134  {
135  if (fDetectorId == myDigi.GetDetectorId())
136  if (fChannelNr == myDigi.GetChannelNr())
137  return true;
138  return false;
139  }
140 
141  private:
142  Int_t fDetectorId; // detectorId * 256 + stationId * 16 + sensorId
143  Double_t fChannelNr; // channel number
144 
145  Double_t fDigiCharge; // charge in the digi
146  Double_t fDigiCor; // correlation between digis
147 
148  ClassDef(PndGemDigi, 2);
149 };
150 
151 #endif
Int_t GetSystemId() const
Definition: PndGemDigi.h:71
Int_t GetSide() const
Definition: PndGemDigi.h:77
virtual ~PndGemDigi()
friend std::ostream & operator<<(std::ostream &out, PndGemDigi &digi)
Definition: PndGemDigi.h:31
Double_t GetCharge() const
Definition: PndGemDigi.h:79
virtual bool operator==(const PndGemDigi &myDigi) const
Definition: PndGemDigi.h:133
unsigned int i
Definition: P4_F32vec4.h:21
Int_t GetDetectorId() const
Definition: PndGemDigi.h:68
Int_t GetNIndices()
Definition: PndGemDigi.h:91
void SetCharge(Double_t iCharge)
Definition: PndGemDigi.h:62
Double_t GetChannelNr() const
Definition: PndGemDigi.h:69
void AddCharge(Double_t iCharge)
Definition: PndGemDigi.h:65
void AddIndex(int index)
Definition: PndGemDigi.h:94
virtual bool operator>(const PndGemDigi &myDigi) const
Definition: PndGemDigi.h:120
Int_t GetIndex(int i=0) const
Definition: PndGemDigi.h:92
std::vector< Int_t > GetIndices() const
Definition: PndGemDigi.h:82
void SetCor(Double_t iCor)
Definition: PndGemDigi.h:63
virtual bool equal(FairTimeStamp *data)
Definition: PndGemDigi.h:97
Int_t GetSensorNr() const
Definition: PndGemDigi.h:73
Int_t GetStationNr() const
Definition: PndGemDigi.h:72
void AddIndex(std::vector< Int_t > index)
Definition: PndGemDigi.h:95
Double_t GetCor() const
Definition: PndGemDigi.h:80
virtual bool operator<(const PndGemDigi &myDigi) const
Definition: PndGemDigi.h:107