StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPxlHitCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StPxlHitCollection.cxx,v 2.1 2013/03/05 14:40:21 ullrich Exp $
4  *
5  * Author: X. Dong, Jan 2013
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StPxlHitCollection.cxx,v $
13  * Revision 2.1 2013/03/05 14:40:21 ullrich
14  * Initial Revision.
15  *
16  **************************************************************************/
17 #include "StPxlHitCollection.h"
18 #include "StPxlSectorHitCollection.h"
19 #include "StPxlLadderHitCollection.h"
20 #include "StPxlSensorHitCollection.h"
21 #include "StPxlHit.h"
22 
23 ClassImp(StPxlHitCollection)
24 
25 StPxlHitCollection::StPxlHitCollection() { /* noop */ }
26 
27 StPxlHitCollection::~StPxlHitCollection() { /* noop */}
28 
29 bool
30 StPxlHitCollection::addHit(StPxlHit* hit)
31 {
32  unsigned int s, l, w;
33  if (hit &&
34  (s = hit->sector()-1) < mNumberOfSectors &&
35  (l = hit->ladder()-1) < mSectors[s].numberOfLadders() &&
36  (w = hit->sensor()-1) < mSectors[s].ladder(l)->numberOfSensors()) {
37  mSectors[s].ladder(l)->sensor(w)->hits().push_back(hit);
38  return true;
39  }
40  else
41  return false;
42 }
43 
44 unsigned int
45 StPxlHitCollection::numberOfHits() const
46 {
47  unsigned int sum = 0;
48  for (int i=0; i<mNumberOfSectors; i++) {
49  for (unsigned int j=0; j<mSectors[i].numberOfLadders(); j++) {
50  for (unsigned int k=0; k<mSectors[i].ladder(j)->numberOfSensors(); k++) {
51  sum += mSectors[i].ladder(j)->sensor(k)->hits().size();
52  }
53  }
54  }
55  return sum;
56 }
57 
59 StPxlHitCollection::sector(unsigned int i)
60 {
61  return (i < mNumberOfSectors) ? &(mSectors[i]) : 0;
62 }
63 
65 StPxlHitCollection::sector(unsigned int i) const
66 {
67  return (i < mNumberOfSectors) ? &(mSectors[i]) : 0;
68 }