Belle II Software development
Cell.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 cell (a wire or a track segment) in CDC.
11//-----------------------------------------------------------------------------
12
13#define TRG_SHORT_NAMES
14#define TRGCDC_SHORT_NAMES
15
16#include "trg/trg/Utilities.h"
17#include "trg/cdc/Cell.h"
18#include "trg/cdc/Segment.h"
19
20#define P3D HepGeom::Point3D<double>
21
22using namespace std;
23
24namespace Belle2 {
29
31 unsigned localId,
32 const TCLayer& l,
33 const P3D& fp,
34 const P3D& bp)
35 : _id(id),
37 _layer(l),
38 _xyPosition(0.5 * (fp + bp)),
41 _direction((fp - bp).unit()),
42 _state(0),
43 _hit(0)
44 {
45 }
46
50
51 void
52 TRGCDCCell::dump(const string& msg, const string& pre) const
53 {
54 cout << pre;
55 cout << "w " << _id;
56 cout << ",local " << _localId;
57 cout << ",layer " << layerId();
58 cout << ",super layer " << superLayerId();
59 cout << ",local layer " << localLayerId();
60 cout << endl;
61 if (msg.find("neighbor") != string::npos) {
62// for (unsigned i = 0; i < 7; i++)
63// if (neighbor(i))
64// neighbor(i)->dump("", pre + TRGUtil::itostring(i) + " ");
65 }
66 }
67
68 int
70 {
71
72 if (superLayerId() != a.superLayerId()) {
73 cout << "TRGCDCCell::localIdDifference !!!";
74 cout << "super layer assumption violation" << endl;
75 }
76
77 int diff = int(a.localId()) - int(localId());
78 unsigned nCells = layer().nCells();
79 if (diff > 0) {
80 int difR = nCells - diff;
81 if (diff < difR) return diff;
82 else return - difR;
83 } else {
84 int difR = nCells + diff;
85 if (- diff < difR) return diff;
86 else return difR;
87 }
88 }
89
91} // namespace Belle2
92
const HepGeom::Point3D< double > _forwardPosition
Wire forward position.
Definition Cell.h:178
const HepGeom::Point3D< double > _xyPosition
Wire center(?) position.
Definition Cell.h:175
const unsigned _id
ID.
Definition Cell.h:166
const unsigned _localId
Local ID.
Definition Cell.h:169
const HepGeom::Point3D< double > _backwardPosition
Wire backward position.
Definition Cell.h:181
const TRGCDCCellHit * _hit
Cell hit.
Definition Cell.h:190
const Vector3D _direction
Direction vector.
Definition Cell.h:184
const TRGCDCLayer & _layer
Layer.
Definition Cell.h:172
unsigned _state
Status in this event.
Definition Cell.h:187
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition Cell.cc:52
unsigned id(void) const
returns id.
Definition Cell.h:200
virtual ~TRGCDCCell()
Destructor.
Definition Cell.cc:47
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
unsigned superLayerId(void) const
returns super layer id.
Definition Cell.h:221
TRGCDCCell(unsigned id, unsigned localId, const TRGCDCLayer &layer, const HepGeom::Point3D< double > &forwardPosition, const HepGeom::Point3D< double > &backwardPosition)
Constructor.
Definition Cell.cc:30
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
Definition Cell.h:235
unsigned nCells(void) const
returns # of cells.
Definition Layer.h:194
int localIdDifference(const TRGCDCCell &) const
returns local id difference.
Definition Cell.cc:69
unsigned localId(void) const
returns local id in a layer.
Definition Cell.h:207
Abstract base class for different kinds of events.
STL namespace.