StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcTpcHitCollection.cc
1 /***************************************************************************
2  *
3  * $Id: StMcTpcHitCollection.cc,v 2.2 2005/01/27 23:40:49 calderon Exp $
4  *
5  * Author: Manuel Calderon de la Barca Sanchez, Oct 1999
6  ***************************************************************************
7  *
8  * Description: Monte Carlo Tpc Hit Collection class
9  *
10  ***************************************************************************
11  *
12  * $Log: StMcTpcHitCollection.cc,v $
13  * Revision 2.2 2005/01/27 23:40:49 calderon
14  * Adding persistency to StMcEvent as a step for Virtual MonteCarlo.
15  *
16  * Revision 2.1 1999/12/14 07:04:49 calderon
17  * Numbering scheme as per SVT request.
18  *
19  * Revision 2.0 1999/11/17 02:01:00 calderon
20  * Completely revised for new StEvent
21  *
22  *
23  **************************************************************************/
24 #include "StMcTpcHitCollection.hh"
25 #include "StMcTpcPadrowHitCollection.hh"
26 #include "StMcTpcHit.hh"
27 
28 static const char rcsid[] = "$Id: StMcTpcHitCollection.cc,v 2.2 2005/01/27 23:40:49 calderon Exp $";
29 
30 ClassImp(StMcTpcHitCollection)
31 
33 
34 StMcTpcHitCollection::~StMcTpcHitCollection() { /* noop */ }
35 
36 bool
37 StMcTpcHitCollection::addHit(StMcTpcHit* hit)
38 {
39  unsigned int s, r;
40  if (hit &&
41  (s = hit->sector()-1) < mNumberOfSectors &&
42  (r = hit->padrow()-1) < mSectors[s].numberOfPadrows()) {
43  mSectors[s].padrow(r)->hits().push_back(hit);
44  return true;
45  }
46  else
47  return false;
48 }
49 
50 unsigned int
51 StMcTpcHitCollection::numberOfSectors() const { return mNumberOfSectors; }
52 
53 unsigned long
54 StMcTpcHitCollection::numberOfHits() const
55 {
56  unsigned long sum = 0;
57  for (int i=0; i<mNumberOfSectors; i++) {
58  sum += mSectors[i].numberOfHits();
59  }
60  return sum;
61 }
62 
64 StMcTpcHitCollection::sector(unsigned int i)
65 {
66  if (i < mNumberOfSectors)
67  return &(mSectors[i]);
68  else
69  return 0;
70 }
71 
73 StMcTpcHitCollection::sector(unsigned int i) const
74 {
75  if (i < mNumberOfSectors)
76  return &(mSectors[i]);
77  else
78  return 0;
79 }