StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtHitCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StSvtHitCollection.cxx,v 2.5 2001/04/05 04:00:55 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtHitCollection.cxx,v $
13  * Revision 2.5 2001/04/05 04:00:55 ullrich
14  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
15  *
16  * Revision 2.4 2000/02/17 18:13:11 ullrich
17  * Changed the SVT hit storage model. Hits are now stored according
18  * to barrel/ladder/wafer not by layer/ladder/wafer.
19  *
20  * Revision 2.3 1999/12/13 20:16:24 ullrich
21  * Changed numbering scheme for hw_position unpack methods (STAR conventions).
22  *
23  * Revision 2.2 1999/10/28 22:26:47 ullrich
24  * Adapted new StArray version. First version to compile on Linux and Sun.
25  *
26  * Revision 2.1 1999/10/13 19:45:13 ullrich
27  * Initial Revision
28  *
29  **************************************************************************/
30 #include "StSvtHitCollection.h"
31 #include "StSvtHit.h"
32 
33 static const char rcsid[] = "$Id: StSvtHitCollection.cxx,v 2.5 2001/04/05 04:00:55 ullrich Exp $";
34 
35 ClassImp(StSvtHitCollection)
36 
38 {
39  //
40  // Barrel and ladder collections have to know
41  // their barrel number in order to return the
42  // proper numberOfLadders() and numberOfWafers().
43  //
44  for (int i=0; i<mNumberOfBarrels; i++) {
45  mBarrels[i].setBarrelNumber(i);
46  for (unsigned int j=0; j<mBarrels[i].numberOfLadders(); j++)
47  mBarrels[i].ladder(j)->setBarrelNumber(i);
48  }
49 }
50 
51 StSvtHitCollection::~StSvtHitCollection() { /* noop */ }
52 
53 unsigned int
54 StSvtHitCollection::numberOfBarrels() const { return mNumberOfBarrels; }
55 
56 bool
57 StSvtHitCollection::addHit(StSvtHit* hit)
58 {
59  unsigned int l, d, w;
60  if (hit &&
61  (l = hit->barrel()-1) < mNumberOfBarrels &&
62  (d = hit->ladder()-1) < mBarrels[l].numberOfLadders() &&
63  (w = hit->wafer()-1) < mBarrels[l].ladder(d)->numberOfWafers()) {
64  mBarrels[l].ladder(d)->wafer(w)->hits().push_back(hit);
65  return kTRUE;
66  }
67  else
68  return kFALSE;
69 }
70 
71 unsigned int
72 StSvtHitCollection::numberOfHits() const
73 {
74  unsigned int sum = 0;
75  for (int i=0; i<mNumberOfBarrels; i++)
76  for (unsigned int j=0; j<mBarrels[i].numberOfLadders(); j++)
77  for (unsigned int k=0; k<mBarrels[i].ladder(j)->numberOfWafers(); k++)
78  sum += mBarrels[i].ladder(j)->wafer(k)->hits().size();
79  return sum;
80 }
81 
83 StSvtHitCollection::barrel(unsigned int i)
84 {
85  if (i < mNumberOfBarrels)
86  return &(mBarrels[i]);
87  else
88  return 0;
89 }
90 
92 StSvtHitCollection::barrel(unsigned int i) const
93 {
94  if (i < mNumberOfBarrels)
95  return &(mBarrels[i]);
96  else
97  return 0;
98 }
99