CbmRoot
CbmTrdCluster.cxx
Go to the documentation of this file.
1 
6 #include "CbmTrdCluster.h"
7 
8 #include <FairLogger.h> // for LOG, Logger
9 
10 #include <TMathBase.h> // for Min, Abs
11 #
12 #include <iostream> // for operator<<, basic_ostream, stringstream
13 
14 using std::endl;
15 using std::string;
16 using std::stringstream;
17 using std::vector;
18 //____________________________________________________________________
20  : CbmCluster()
21  , fNCols(0)
22  , fNRows(0xff)
23  , fStartCh(0xffff)
24  , fStartTime(0xffff) {}
25 
26 //____________________________________________________________________
28  : CbmCluster(ref.GetDigis(), ref.GetAddress())
29  , fNCols(ref.fNCols)
30  , fNRows(ref.fNRows)
31  , fStartCh(ref.fStartCh)
32  , fStartTime(ref.fStartTime) {}
33 
34 //____________________________________________________________________
35 CbmTrdCluster::CbmTrdCluster(const std::vector<Int_t>& indices, Int_t address)
36  : CbmCluster(indices, address)
37  , fNCols(0)
38  , fNRows(0xff)
39  , fStartCh(0xffff)
40  , fStartTime(0xffff) {}
41 
42 //____________________________________________________________________
44  Int_t idx,
45  Int_t ch,
46  Int_t row,
47  Int_t time)
48  : CbmCluster()
49  , fNCols(0)
50  , fNRows(0xff)
51  , fStartCh(0xffff)
52  , fStartTime(0xffff) {
53  ReInit(address, row, time);
54  AddDigi(idx, ch);
55 }
56 
57 //____________________________________________________________________
59 
60 //____________________________________________________________________
61 Bool_t
62 CbmTrdCluster::AddDigi(Int_t idx, Int_t channel, Int_t terminator, Int_t dt) {
67  if (channel < 0) { // basic functionality for rectangular pads
69  return kTRUE;
70  }
71 
72  if (channel >= 0xffff)
73  LOG(warn) << GetName() << "::AddDigi: pad-channel truncated to 2bytes.";
74 
75  // assume triangular pads only
76  if (!fNCols) { // first digi
77  fStartCh = channel;
79  if (terminator < 0)
81  else if (terminator > 0)
83  } else if (channel > GetEndCh()) { // digi @ end
84  if (HasOpenStop()) return kFALSE;
86  if (terminator > 0) SetProfileStop();
87  } else if (channel < fStartCh) { // digi @ beginning
88  if (HasOpenStart()) return kFALSE;
89  fStartCh = channel;
90  vector<Int_t> vec = GetDigis();
91  ClearDigis();
93  AddDigis(vec);
94  if (terminator < 0) SetProfileStart();
95  }
96  fNCols++;
97  if (dt > 0) fStartTime -= dt;
98 
99  return kTRUE;
100 }
101 
102 //____________________________________________________________________
103 void CbmTrdCluster::Clear(Option_t*) {
105  fNCols = 0;
106  fNRows = 0xff;
107  fStartCh = 0xffff;
108  fStartTime = 0xffff;
109 }
110 
111 //____________________________________________________________________
112 void CbmTrdCluster::ReInit(Int_t address, Int_t row, Int_t time) {
113  SetAddress(address);
114  fNCols = 0;
115  fStartCh = 0xffff;
116  // check truncation
117  if (row >= 0x1f)
118  LOG(warn) << GetName() << "::ReInit: pad-row truncated to 5bits.";
119  SetNRows(row);
120  SetProfileStart(0);
121  SetProfileStop(0);
122  if (time >= 0xffff)
123  LOG(warn) << GetName() << "::ReInit: buffer time truncated to 2bytes.";
124  fStartTime = time;
125 }
126 
127 //____________________________________________________________________
128 Int_t CbmTrdCluster::IsChannelInRange(Int_t ch) const {
129  if (!fNCols) return -2;
130  // if(IsTerminatedLeft() && fAddressCh[0]>ch) return -1;
131  // if(IsTerminatedRight() && fAddressCh[clSize-1]<ch) return 1;
132 
133  if (fStartCh > ch + 1) return -1;
134  if (fStartCh + fNCols < ch) return 1;
135  return 0;
136 }
137 
138 //____________________________________________________________________
140  if (GetRow() != second->GetRow()) return kFALSE;
141  if (TMath::Abs(second->fStartTime - fStartTime) > 20) return kFALSE;
142  // look before current
143  if (second->fStartCh + second->fNCols == fStartCh && !second->HasOpenStop()
144  && !HasOpenStart()) {
145  // cout<<"Merge before with "<<second->ToString();
146  fStartCh = second->fStartCh;
147  fNCols += second->fNCols;
148  fStartTime = TMath::Min(fStartTime, second->fStartTime);
149 
150  vector<Int_t> vec = GetDigis();
151  ClearDigis();
152  AddDigis(second->GetDigis());
153  AddDigis(vec);
154  if (second->HasOpenStart()) SetProfileStart();
155  return kTRUE;
156  }
157  // special care for FASP clusters which can be merged also on pairing neighboring
158  if (HasTrianglePads()) {
159  if ((second->fStartCh + second->fNCols - 1 == fStartCh)
160  && second->HasOpenStop() && HasOpenStart()) { // need to merge digi
161  fStartCh = second->fStartCh;
162  fNCols += second->fNCols - 1;
163  fStartTime = TMath::Min(fStartTime, second->fStartTime);
164 
165  vector<Int_t> vec = GetDigis();
166  ClearDigis();
167  AddDigis(second->GetDigis());
168  AddDigis(vec);
169  SetProfileStart(kFALSE);
170  return kTRUE;
171  }
172  }
173 
174  // look after current
175  if (fStartCh + fNCols == second->fStartCh && !HasOpenStop()
176  && !second->HasOpenStart()) {
177  // cout<<"Merge after with "<<second->ToString();
178  fNCols += second->fNCols;
179  fStartTime = TMath::Min(fStartTime, second->fStartTime);
180  AddDigis(second->GetDigis());
181  if (second->HasOpenStop()) SetProfileStop();
182  return kTRUE;
183  }
184 
185  // special care for FASP clusters which can be merged also on pairing neighboring
186  if (HasTrianglePads()) {
187  if ((fStartCh + fNCols - 1 == second->fStartCh) && HasOpenStop()
188  && second->HasOpenStart()) { // need to merge digi
189  fNCols += second->fNCols - 1;
190  fStartTime = TMath::Min(fStartTime, second->fStartTime);
191  AddDigis(second->GetDigis());
192  SetProfileStop(kFALSE);
193  return kTRUE;
194  }
195  }
196 
197  return kFALSE;
198 }
199 
200 //____________________________________________________________________
201 string CbmTrdCluster::ToString() const {
202  stringstream ss;
203  ss << CbmCluster::ToString();
204  ss << "CbmTrdCluster: mod=" << GetAddress() << " t0=" << fStartTime
205  << " R=" << (Int_t) GetRow() << " " << (HasTrianglePads() ? "T" : "R")
206  << "Chs=";
207  ss << (HasOpenStart() ? "/" : "|");
208  for (Int_t i(0); i < fNCols; i++)
209  ss << fStartCh + i << " ";
210  ss << (HasOpenStop() ? "\\" : "|");
211  ss << endl;
212  return ss.str();
213 }
214 
CbmTrdCluster::fNRows
UChar_t fNRows
Definition: CbmTrdCluster.h:112
CbmStsAddress::GetAddress
Int_t GetAddress(UInt_t unit=0, UInt_t ladder=0, UInt_t halfladder=0, UInt_t module=0, UInt_t sensor=0, UInt_t side=0, UInt_t version=kCurrentVersion)
Construct address.
Definition: CbmStsAddress.cxx:90
CbmTrdCluster::ReInit
void ReInit(Int_t address, Int_t row, Int_t time)
Initialize basic parameters of the cluster.
Definition: CbmTrdCluster.cxx:112
CbmTrdCluster::GetRow
UShort_t GetRow() const
Definition: CbmTrdCluster.h:67
CbmCluster::AddDigi
void AddDigi(Int_t index)
Add digi to cluster.
Definition: CbmCluster.h:47
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmTrdCluster::GetEndCh
UShort_t GetEndCh() const
Definition: CbmTrdCluster.h:66
CbmTrdCluster::IsChannelInRange
Int_t IsChannelInRange(Int_t ch) const
Query on RO channel list.
Definition: CbmTrdCluster.cxx:128
CbmTrdCluster::ToString
virtual std::string ToString() const
Extended functionality.
Definition: CbmTrdCluster.cxx:201
CbmCluster::ToString
virtual std::string ToString() const
Return string representation of the object.
Definition: CbmCluster.cxx:74
CbmTrdCluster
Data Container for TRD clusters.
Definition: CbmTrdCluster.h:23
CbmCluster::ClearDigis
void ClearDigis()
Remove all digis.
Definition: CbmCluster.h:87
CbmTrdCluster::CbmTrdCluster
CbmTrdCluster()
Default constructor.
Definition: CbmTrdCluster.cxx:19
CbmCluster::GetDigis
const std::vector< Int_t > & GetDigis() const
Get array of digi indices.
Definition: CbmCluster.h:82
CbmCluster::GetAddress
Int_t GetAddress() const
Definition: CbmCluster.h:90
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTrdCluster::AddDigi
Bool_t AddDigi(Int_t idx, Int_t channel=-1, Int_t terminator=0, Int_t dt=0)
Append digi to cluster.
Definition: CbmTrdCluster.cxx:62
CbmTrdCluster::SetProfileStart
void SetProfileStart(Bool_t set=kTRUE)
Definition: CbmTrdCluster.h:99
CbmTrdCluster::~CbmTrdCluster
virtual ~CbmTrdCluster()
Destructor.
Definition: CbmTrdCluster.cxx:58
CbmTrdCluster::SetProfileStop
void SetProfileStop(Bool_t set=kTRUE)
Definition: CbmTrdCluster.h:102
CbmCluster::SetAddress
void SetAddress(Int_t address)
Definition: CbmCluster.h:94
CbmTrdCluster::HasOpenStop
Bool_t HasOpenStop() const
Definition: CbmTrdCluster.h:72
CbmCluster
Base class for cluster objects.
Definition: CbmCluster.h:26
CbmTrdCluster::Clear
void Clear(Option_t *)
reset cluster data
Definition: CbmTrdCluster.cxx:103
CbmTrdCluster::HasOpenStart
Bool_t HasOpenStart() const
Definition: CbmTrdCluster.h:71
CbmTrdCluster::HasTrianglePads
Bool_t HasTrianglePads() const
Definition: CbmTrdCluster.h:70
CbmTrdCluster::Merge
Bool_t Merge(CbmTrdCluster *second)
Merge current cluster with info from second.
Definition: CbmTrdCluster.cxx:139
CbmTrdCluster::fStartTime
UShort_t fStartTime
channel address of first channel
Definition: CbmTrdCluster.h:114
CbmTrdCluster.h
Data Container for TRD clusters.
CbmCluster::AddDigis
void AddDigis(const std::vector< Int_t > &indices)
Add array of digi to cluster.
Definition: CbmCluster.h:53
CbmTrdCluster::fNCols
UChar_t fNCols
Definition: CbmTrdCluster.h:110
CbmTrdCluster::SetNRows
void SetNRows(UShort_t nrows)
Definition: CbmTrdCluster.h:92
CbmTrdCluster::fStartCh
UShort_t fStartCh
Definition: CbmTrdCluster.h:113