Belle II Software development
Wire.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9//-----------------------------------------------------------------------------
10// Description : A class to represent a wire in CDC.
11//-----------------------------------------------------------------------------
12
13#define TRG_SHORT_NAMES
14#define TRGCDC_SHORT_NAMES
15
16#include "trg/trg/Clock.h"
17#include "trg/trg/Utilities.h"
18#include "trg/cdc/TRGCDC.h"
19#include "trg/cdc/Wire.h"
20#include "trg/cdc/WireHit.h"
21#include "trg/cdc/WireHitMC.h"
22#include "trg/cdc/Segment.h"
23
24#define P3D HepGeom::Point3D<double>
25
26using namespace std;
27
28namespace Belle2 {
35 unsigned localId,
36 const TCLayer& l,
37 const P3D& fp,
38 const P3D& bp,
39 const TRGClock& clock)
40 : TCCell(id, localId, l, fp, bp),
41 _mcHits(),
42 _signal(clock),
43 _signal_adc(clock)
44 {
45 _signal.name(name());
47 }
48
50 {
51 }
52
53 void
54 TRGCDCWire::dump(const string& msg, const string& pre) const
55 {
56 cout << pre;
57 cout << "w " << id();
58 cout << ",local " << localId();
59 cout << ",layer " << layerId();
60 cout << ",super layer " << superLayerId();
61 cout << ",local layer " << localLayerId();
62 cout << endl;
63 if (msg.find("neighbor") != string::npos) {
64 for (unsigned i = 0; i < 7; i++)
65 if (neighbor(i))
66 neighbor(i)->dump("", pre + TRGUtil::itostring(i) + " ");
67 }
68 if (msg.find("trigger") != string::npos ||
69 msg.find("detail") != string::npos) {
70 signal().dump(msg, pre + " ");
71 }
72 }
73
74 const TRGCDCWire*
75 TRGCDCWire::neighbor(unsigned i) const
76 {
77 static bool first = false;
78 if (first)
79 cout << "TRGCDCWire::neighbor !!! "
80 << "this function is not tested yet"
81 << endl;
82
83 const TRGCDC& cdc = * TRGCDC::getTRGCDC();
84 const unsigned layerId = layer().id();
85 const unsigned superLayerId = layer().superLayerId();
86 const unsigned localLayerId = layer().localLayerId();
87 const unsigned nLayers = cdc.superLayer(superLayerId)->size();
88 const int local = int(localId());
89
90 if (i == WireInnerLeft || i == WireInnerRight) {
91 if (localLayerId == 0)
92 return 0;
93 if (layer().offset() != 0) {
94 if (i == WireInnerLeft)
95 return cdc.wire(layerId - 1, local);
96 else
97 return cdc.wire(layerId - 1, local + 1);
98 } else {
99 if (i == WireInnerLeft)
100 return cdc.wire(layerId - 1, local - 1);
101 else
102 return cdc.wire(layerId - 1, local);
103 }
104 } else if (i == WireLeft || i == WireRight) {
105 if (i == WireLeft)
106 return cdc.wire(layerId, local - 1);
107 else
108 return cdc.wire(layerId, local + 1);
109 } else if (i == WireOuterLeft || i == WireOuterRight) {
110 if (localLayerId == (nLayers - 1))
111 return 0;
112 if (layer().offset() != 0) {
113 if (i == WireOuterLeft)
114 return cdc.wire(layerId + 1, local);
115 else
116 return cdc.wire(layerId + 1, local + 1);
117 } else {
118 if (i == WireOuterLeft)
119 return cdc.wire(layerId + 1, local - 1);
120 else
121 return cdc.wire(layerId + 1, local);
122 }
123 }
124 return 0;
125 }
126
127// int
128// TRGCDCWire::localIdForPlus(void) const {
129
130// const unsigned li = layerId();
131
132// //
133// // used in curl finder
134// //
135// // new version by NK
136// //
137// const TCLayer &l = *layer();
138// const int nw = l.nWires();
139// if(_localId+1==nw) return -1;
140// else return _localId;
141// #if 0
142// if (ms_smallcell) {
143// if ((li == 1) || (li == 2)) {
144// if (_localId == 127) return -1;
145// else return _localId;
146// }
147// if(_localId == 63) return -1;
148// else return _localId;
149// }
150// else {
151// if (li <= 5) {
152// if(_localId == 63)
153// return -1;
154// else return _localId;
155// }
156// }
157
158// if(li >= 6 && li <= 8){
159// if(_localId == 79)
160// return -1;
161// else return _localId;
162// }
163
164// if(li >= 9 && li <= 14){
165// if(_localId == 95)
166// return -1;
167// else return _localId;
168// }
169
170// if(li >= 15 && li <= 17){
171// if(_localId == 127)
172// return -1;
173// else return _localId;
174// }
175
176// if(li >= 18 && li <= 22){
177// if(_localId == 143)
178// return -1;
179// else return _localId;
180// }
181
182// if(li >= 23 && li <= 26){
183// if(_localId == 159)
184// return -1;
185// else return _localId;
186// }
187
188// if(li >= 27 && li <= 31){
189// if(_localId == 191)
190// return -1;
191// else return _localId;
192// }
193
194// if(li >= 32 && li <= 35){
195// if(_localId == 207)
196// return -1;
197// else return _localId;
198// }
199
200// if(li >= 36 && li <= 40){
201// if(_localId == 239)
202// return -1;
203// else return _localId;
204// }
205
206// if(li >= 41 && li <= 44){
207// if(_localId == 255)
208// return -1;
209// else return _localId;
210// }
211
212// if(li >= 45){
213// if(_localId == 287)
214// return -1;
215// else return _localId;
216// }
217// #endif
218
219// return -1;
220// }
221
222// int
223// TRGCDCWire::localIdForMinus(void) const {
224
225// const unsigned li = layerId();
226
227// //
228// // used in curl finder
229// //
230// // new version ny NK
231// //
232// const TCLayer &l = *layer();
233// const int nw = l.nWires();
234// if(0==_localId) return nw;
235// else return _localId;
236// #if 0
237// if (ms_smallcell) {
238// if ((li == 1) || (li == 2)) {
239// if (_localId == 0) return 128;
240// else return _localId;
241// }
242// if(_localId == 63) return -1;
243// else return _localId;
244// }
245// else {
246// if (li <= 5){
247// if(_localId == 0)
248// return 64;
249// else return _localId;
250// }
251// }
252
253// if(li >= 6 && li <= 8){
254// if(_localId == 0)
255// return 80;
256// else return _localId;
257// }
258
259// if(li >= 9 && li <= 14){
260// if(_localId == 0)
261// return 96;
262// else return _localId;
263// }
264
265// if(li >= 15 && li <= 17){
266// if(_localId == 0)
267// return 128;
268// else return _localId;
269// }
270
271// if(li >= 18 && li <= 22){
272// if(_localId == 0)
273// return 144;
274// else return _localId;
275// }
276
277// if(li >= 23 && li <= 26){
278// if(_localId == 0)
279// return 160;
280// else return _localId;
281// }
282
283// if(li >= 27 && li <= 31){
284// if(_localId == 0)
285// return 192;
286// else return _localId;
287// }
288
289// if(li >= 32 && li <= 35){
290// if(_localId == 0)
291// return 208;
292// else return _localId;
293// }
294
295// if(li >= 36 && li <= 40){
296// if(_localId == 0)
297// return 240;
298// else return _localId;
299// }
300
301// if(li >= 41 && li <= 44){
302// if(_localId == 0)
303// return 256;
304// else return _localId;
305// }
306
307// if(li >= 45){
308// if(_localId == 0)
309// return 288;
310// else return _localId;
311// }
312// #endif
313
314// return -1;
315// }
316
317// void
318// TRGCDCWire::wirePosition(float z,
319// HepGeom::Point3D<double> & xy,
320// HepGeom::Point3D<double> & back,
321// Vector3D & dir) const {
322// cout << "TRGCDCWire::wirePosition !!! this function is not test yet"
323// << endl;
324
325// back = _backwardPosition;
326
327// //...Check z position...
328// if (! (z > _backwardPosition.z() && z < _forwardPosition.z())) {
329// xy = _xyPosition;
330// dir = _direction;
331// }
332
333// //...Setup...
334// int wireID = id();
335// float wirePosition[3] = {0., 0., 0.};
336// float dydz = 0;
337// float ybSag = 0;
338// float yfSag = 0;
339
340// //...Get corrections...
341// if(ms_superb) {
342// double dz = _forwardPosition.z() - _backwardPosition.z();
343// double dzb = (z - _backwardPosition.z()) / dz;
344// double dzf = (_forwardPosition.z() - z) / dz;
345
346// xy = dzb * _forwardPosition + dzf * _backwardPosition;
347// cout << "f=" << _forwardPosition << endl;
348// cout << "b=" << _backwardPosition << endl;
349// cout << "p" << xy << endl;
350// cout << "z=" << z << " dz=" << dz << " dzb=" << dzb << " dzf=" << dzf << endl;
351// dir = _direction;
352// return;
353// }
354// calcdc_sag3_(& wireID, & z, wirePosition, & dydz, & ybSag, & yfSag);
355
356// //...Wire position...
357// xy.setX((double) wirePosition[0]);
358// xy.setY((double) wirePosition[1]);
359// xy.setZ((double) wirePosition[2]);
360// back.setY((double) ybSag);
361// Vector3D v_aux(_forwardPosition.x() - _backwardPosition.x(),
362// yfSag - ybSag,
363// _forwardPosition.z() - _backwardPosition.z());
364// dir = v_aux.unit();
365
366// return;
367// }
368
369 void
371 {
372 TCCell::clear();
373
374 for (unsigned i = 0; i < _mcHits.size(); i++)
375 delete _mcHits[i];
376 _mcHits.clear();
377
378 _signal.clear();
379 _signal.name(name());
382 }
383
384 string
386 {
387 if (axial())
388 return string("w") +
389 TRGUtil::itostring(layerId()) +
390 string("-") +
391 TRGUtil::itostring(localId());
392 return string("w") +
393 TRGUtil::itostring(layerId()) +
394 string("=") +
395 TRGUtil::itostring(localId());
396 }
397
399} // namespace Belle2
400
A class to represent a wire in CDC.
Definition: Wire.h:56
TRGSignal _signal
Trigger output.
Definition: Wire.h:132
std::vector< const TRGCDCWireHitMC * > _mcHits
MC wire hit.
Definition: Wire.h:129
TRGSignal _signal_adc
Trigger output. with adc cut.
Definition: Wire.h:135
The instance of TRGCDC is a singleton.
Definition: TRGCDC.h:69
A class to represent a digitized signal. Unit is nano second.
Definition: Clock.h:38
#define WireInnerRight
type of the wire
Definition: Wire.h:38
#define WireLeft
type of the wire
Definition: Wire.h:40
static TRGCDC * getTRGCDC(void)
returns TRGCDC object.
Definition: TRGCDC.cc:192
virtual ~TRGCDCWire()
Destructor.
Definition: Wire.cc:49
unsigned id(void) const
returns id.
Definition: Cell.h:200
#define WireRight
type of the wire
Definition: Wire.h:42
#define WireInnerLeft
type of the wire
Definition: Wire.h:36
unsigned layerId(void) const
returns layer id.
Definition: Cell.h:214
unsigned localLayerId(void) const
returns local layer id in a super layer.
Definition: Cell.h:228
#define WireOuterRight
type of the wire
Definition: Wire.h:46
const std::string & name(void) const
returns name.
Definition: Signal.h:188
unsigned superLayerId(void) const
returns super layer id.
Definition: Cell.h:221
const TRGSignal & signal(void) const override
returns an input to the trigger. This is sync'ed to 1GHz clock.
Definition: Wire.h:242
const TRGCDCWire * neighbor(unsigned) const
returns a pointer to a neighbor wire. This function is expensive.
Definition: Wire.cc:75
std::string name(void) const override
returns name.
Definition: Wire.cc:385
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const override
dumps debug information.
Definition: Wire.cc:54
TRGCDCWire(unsigned id, unsigned localId, const TRGCDCLayer &, const HepGeom::Point3D< double > &forwardPosition, const HepGeom::Point3D< double > &backwardPosition, const TRGClock &clock)
Constructor.
Definition: Wire.cc:34
void clear(void) override
clears information.
Definition: Wire.cc:370
#define WireOuterLeft
type of the wire
Definition: Wire.h:44
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
Definition: Cell.h:235
void clear(void)
clears contents.
Definition: Signal.h:265
bool axial(void) const
returns true if this wire is in an axial layer.
Definition: Cell.h:256
unsigned localId(void) const
returns local id in a layer.
Definition: Cell.h:207
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Definition: Signal.cc:139
Abstract base class for different kinds of events.
STL namespace.