PandaRoot
PndGemDigi.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 //* $Id: */
14 
15 // -------------------------------------------------------------------------
16 // ----- PndGemDigi header file -----
17 // ----- Adapted in 2010 by R. Karabowicz -----
18 // -------------------------------------------------------------------------
19 
31 #ifndef PNDGEMDIGI_H
32 #define PNDGEMDIGI_H 1
33 
34 #include <vector>
35 
36 #include "FairTimeStamp.h"
37 
38 #include "PndDetectorList.h"
39 
40 #include "TObject.h"
41 
42 class PndGemDigi : public FairTimeStamp {
43  friend std::ostream &operator<<(std::ostream &out, PndGemDigi &digi)
44  {
45  out << "PndGemDigi in: " << digi.GetDetectorId() << "( system = " << digi.GetSystemId() << ", station = " << digi.GetStationNr() << ", sensor = " << digi.GetSensorNr()
46  << ", side = " << digi.GetSide() << "), channelNr = " << digi.GetChannelNr() << ", charge = " << digi.GetCharge() << ", cor = " << digi.GetCor() << ", timestamp "
47  << digi.GetTimeStamp() << ", from Point(s) ";
48  std::vector<Int_t> indices = digi.GetIndices();
49  for (unsigned int i = 0; i < indices.size(); i++) {
50  out << indices[i] << " ";
51  }
52  out << std::endl;
53 
54  return out;
55  }
56 
57  public:
59  PndGemDigi();
60 
68  PndGemDigi(Int_t iDetectorId, Double_t iChannel, Int_t index);
69  PndGemDigi(Int_t iDetectorId, Double_t iChannel, Int_t index, Double_t signal, Double_t time);
70 
72  virtual ~PndGemDigi();
73 
74  void SetCharge(Double_t iCharge) { fDigiCharge = iCharge; }
75  void SetCor(Double_t iCor) { fDigiCor = iCor; }
76 
77  void AddCharge(Double_t iCharge) { fDigiCharge += iCharge; }
78 
80  Int_t GetDetectorId() const { return fDetectorId; }
81  Double_t GetChannelNr() const { return fChannelNr; }
82 
83  Int_t GetSystemId() const { return ((fDetectorId & (31 << 27)) >> 27); }
84  Int_t GetStationNr() const { return ((fDetectorId & (8191 << 8)) >> 8); }
85  Int_t GetSensorNr() const
86  { // sensor number within station
87  return ((fDetectorId & (3 << 6)) >> 6);
88  }
89  Int_t GetSide() const { return ((fDetectorId & (1 << 5)) >> 5); } // 0=front, 1=back
90 
91  Double_t GetCharge() const { return fDigiCharge; }
92  Double_t GetCor() const { return fDigiCor; }
93 
94  std::vector<Int_t> GetIndices() const
95  {
96  std::vector<Int_t> result;
97  std::set<FairLink> myLinks = GetLinks();
98  for (std::set<FairLink>::iterator it = myLinks.begin(); it != myLinks.end(); it++) {
99  result.push_back(it->GetIndex());
100  }
101  return result;
102  }
103  Int_t GetNIndices() { return GetNLinks(); }
104  Int_t GetIndex(int i = 0) const { return GetLink(i).GetIndex(); }
105 
106  void AddIndex(int index) { AddLink(FairLink("GEMPoint", index)); }
107  void AddIndex(std::vector<Int_t> index) { SetLinks(FairMultiLinkedData("GEMPoint", index)); }
108 
109  virtual bool equal(FairTimeStamp *data)
110  {
111  PndGemDigi *myDigi = dynamic_cast<PndGemDigi *>(data);
112  if (myDigi != nullptr) {
113  if (fDetectorId == myDigi->GetDetectorId())
114  return kTRUE;
115  }
116  return false;
117  }
118 
119  virtual bool operator<(const PndGemDigi &myDigi) const
120  {
121  if (fDetectorId < myDigi.GetDetectorId())
122  return true;
123  else if (fDetectorId > myDigi.GetDetectorId())
124  return false;
125  if (fChannelNr < myDigi.GetChannelNr())
126  return true;
127  else if (fChannelNr > myDigi.GetChannelNr())
128  return false;
129  return false;
130  }
131 
132  virtual bool operator>(const PndGemDigi &myDigi) const
133  {
134  if (fDetectorId > myDigi.GetDetectorId())
135  return true;
136  else if (fDetectorId < myDigi.GetDetectorId())
137  return false;
138  if (fChannelNr > myDigi.GetChannelNr())
139  return true;
140  else if (fChannelNr < myDigi.GetChannelNr())
141  return false;
142  return false;
143  }
144 
145  virtual bool operator==(const PndGemDigi &myDigi) const
146  {
147  if (fDetectorId == myDigi.GetDetectorId())
148  if (fChannelNr == myDigi.GetChannelNr())
149  return true;
150  return false;
151  }
152 
153  private:
154  Int_t fDetectorId; // detectorId * 256 + stationId * 16 + sensorId
155  Double_t fChannelNr; // channel number
156 
157  Double_t fDigiCharge; // charge in the digi
158  Double_t fDigiCor; // correlation between digis
159 
160  ClassDef(PndGemDigi, 2);
161 };
162 
163 #endif
Int_t GetSystemId() const
Definition: PndGemDigi.h:83
Int_t GetSide() const
Definition: PndGemDigi.h:89
virtual ~PndGemDigi()
friend std::ostream & operator<<(std::ostream &out, PndGemDigi &digi)
Definition: PndGemDigi.h:43
Double_t GetCharge() const
Definition: PndGemDigi.h:91
virtual bool operator==(const PndGemDigi &myDigi) const
Definition: PndGemDigi.h:145
unsigned int i
Definition: P4_F32vec4.h:33
Int_t GetDetectorId() const
Definition: PndGemDigi.h:80
Int_t GetNIndices()
Definition: PndGemDigi.h:103
void SetCharge(Double_t iCharge)
Definition: PndGemDigi.h:74
Double_t GetChannelNr() const
Definition: PndGemDigi.h:81
void AddCharge(Double_t iCharge)
Definition: PndGemDigi.h:77
void AddIndex(int index)
Definition: PndGemDigi.h:106
virtual bool operator>(const PndGemDigi &myDigi) const
Definition: PndGemDigi.h:132
Int_t GetIndex(int i=0) const
Definition: PndGemDigi.h:104
std::vector< Int_t > GetIndices() const
Definition: PndGemDigi.h:94
void SetCor(Double_t iCor)
Definition: PndGemDigi.h:75
virtual bool equal(FairTimeStamp *data)
Definition: PndGemDigi.h:109
Int_t GetSensorNr() const
Definition: PndGemDigi.h:85
Int_t GetStationNr() const
Definition: PndGemDigi.h:84
void AddIndex(std::vector< Int_t > index)
Definition: PndGemDigi.h:107
Double_t GetCor() const
Definition: PndGemDigi.h:92
virtual bool operator<(const PndGemDigi &myDigi) const
Definition: PndGemDigi.h:119