Belle II Software  release-08-01-10
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 
22 using namespace std;
23 
24 namespace Belle2 {
30  TRGCDCCell::TRGCDCCell(unsigned id,
31  unsigned localId,
32  const TCLayer& l,
33  const P3D& fp,
34  const P3D& bp)
35  : _id(id),
36  _localId(localId),
37  _layer(l),
38  _xyPosition(0.5 * (fp + bp)),
39  _forwardPosition(fp),
40  _backwardPosition(bp),
41  _direction((fp - bp).unit()),
42  _state(0),
43  _hit(0)
44  {
45  }
46 
48  {
49  }
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 
A class to represent a wire in CDC.
Definition: Cell.h:40
const unsigned _id
ID.
Definition: Cell.h:163
const unsigned _localId
Local ID.
Definition: Cell.h:166
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
Definition: Cell.cc:52
virtual ~TRGCDCCell()
Destructor.
Definition: Cell.cc:47
unsigned layerId(void) const
returns layer id.
Definition: Cell.h:211
unsigned localLayerId(void) const
returns local layer id in a super layer.
Definition: Cell.h:225
unsigned superLayerId(void) const
returns super layer id.
Definition: Cell.h:218
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
Definition: Cell.h:232
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:204
Abstract base class for different kinds of events.