Belle II Software  release-05-01-25
Cell.cc
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : Cell.cc
5 // Section : TRG CDC
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : A class to represent a cell (a wire or a track segment) in CDC.
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #define TRG_SHORT_NAMES
15 #define TRGCDC_SHORT_NAMES
16 
17 #include "trg/trg/Utilities.h"
18 #include "trg/cdc/Cell.h"
19 #include "trg/cdc/Segment.h"
20 
21 #define P3D HepGeom::Point3D<double>
22 
23 using namespace std;
24 
25 namespace Belle2 {
31  TRGCDCCell::TRGCDCCell(unsigned id,
32  unsigned localId,
33  const TCLayer& l,
34  const P3D& fp,
35  const P3D& bp)
36  : _id(id),
37  _localId(localId),
38  _layer(l),
39  _xyPosition(0.5 * (fp + bp)),
40  _forwardPosition(fp),
41  _backwardPosition(bp),
42  _direction((fp - bp).unit()),
43  _state(0),
44  _hit(0)
45  {
46  }
47 
49  {
50  }
51 
52  void
53  TRGCDCCell::dump(const string& msg, const string& pre) const
54  {
55  cout << pre;
56  cout << "w " << _id;
57  cout << ",local " << _localId;
58  cout << ",layer " << layerId();
59  cout << ",super layer " << superLayerId();
60  cout << ",local layer " << localLayerId();
61  cout << endl;
62  if (msg.find("neighbor") != string::npos) {
63 // for (unsigned i = 0; i < 7; i++)
64 // if (neighbor(i))
65 // neighbor(i)->dump("", pre + TRGUtil::itostring(i) + " ");
66  }
67  }
68 
69  int
71  {
72 
73  if (superLayerId() != a.superLayerId()) {
74  cout << "TRGCDCCell::localIdDifference !!!";
75  cout << "super layer assumption violation" << endl;
76  }
77 
78  int diff = int(a.localId()) - int(localId());
79  unsigned nCells = layer().nCells();
80  if (diff > 0) {
81  int difR = nCells - diff;
82  if (diff < difR) return diff;
83  else return - difR;
84  } else {
85  int difR = nCells + diff;
86  if (- diff < difR) return diff;
87  else return difR;
88  }
89  }
90 
92 } // namespace Belle2
93 
Belle2::TRGCDCCell::localId
unsigned localId(void) const
returns local id in a layer.
Definition: Cell.h:205
Belle2::TRGCDCCell::dump
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: Cell.cc:53
Belle2::TRGCDCLayer::nCells
unsigned nCells(void) const
returns # of cells.
Definition: Layer.h:192
Belle2::TRGCDCCell::layer
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
Definition: Cell.h:233
Belle2::TRGCDCCell::~TRGCDCCell
virtual ~TRGCDCCell()
Destructor.
Definition: Cell.cc:48
Belle2::TRGCDCCell::localLayerId
unsigned localLayerId(void) const
returns local layer id in a super layer.
Definition: Cell.h:226
Belle2::TRGCDCCell::localIdDifference
int localIdDifference(const TRGCDCCell &) const
returns local id difference.
Definition: Cell.cc:70
Belle2::TRGCDCCell
A class to represent a wire in CDC.
Definition: Cell.h:41
Belle2::TRGCDCCell::_id
const unsigned _id
ID.
Definition: Cell.h:164
Belle2::TRGCDCCell::_localId
const unsigned _localId
Local ID.
Definition: Cell.h:167
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TRGCDCCell::superLayerId
unsigned superLayerId(void) const
returns super layer id.
Definition: Cell.h:219
Belle2::TRGCDCCell::layerId
unsigned layerId(void) const
returns layer id.
Definition: Cell.h:212