StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcIstHitCollection.cc
1 /***************************************************************************
2  *
3  * $Id: StMcIstHitCollection.cc,v 2.4 2015/03/13 18:44:58 perev Exp $
4  *
5  * Author: Manuel Calderon de la Barca Sanchez, Oct 1999
6  ***************************************************************************
7  *
8  * Description: Monte Carlo Pixel Hit Collection class
9  *
10  ***************************************************************************
11  *
12  * $Log: StMcIstHitCollection.cc,v $
13  * Revision 2.4 2015/03/13 18:44:58 perev
14  * Roll back
15  *
16  * Revision 2.2 2005/05/11 20:54:29 calderon
17  * Added persistency: ClassImp, ClassDef and inheritance from StObject.
18  *
19  * Revision 2.1 2004/09/14 05:00:29 calderon
20  * Added support for Ist, Ssd and changes to Pixel, from "El Kai".
21  *
22  * Revision 2.1 2003/08/20 18:50:21 calderon
23  * Addition of Tof classes and Pixel classes. Modified track, event, and
24  * container code to reflect this.
25  * Fix bug in StMcVertex and in clearing of some hit collections.
26  *
27  * Revision 2.1 1999/12/14 07:04:49 calderon
28  * Numbering scheme as per SVT request.
29  *
30  * Revision 2.0 1999/11/17 02:00:59 calderon
31  * Completely revised for new StEvent
32  *
33  *
34  **************************************************************************/
35 #include "StMcIstHitCollection.hh"
36 #include "StMcIstHit.hh"
37 
38 static const char rcsid[] = "$Id: StMcIstHitCollection.cc,v 2.4 2015/03/13 18:44:58 perev Exp $";
39 
40 ClassImp(StMcIstHitCollection)
41 
43 
44 StMcIstHitCollection::~StMcIstHitCollection() { /* noop */ }
45 
46 bool
47 StMcIstHitCollection::addHit(StMcIstHit* hit)
48 {
49  unsigned int p;
50  if (hit && (p = hit->layer()-1) < mNumberOfLayers) {
51  mLayers[p].hits().push_back(hit);
52  return true;
53  }
54  else
55  return false;
56 }
57 
58 unsigned int
59 StMcIstHitCollection::numberOfLayers() const { return mNumberOfLayers; }
60 
61 unsigned long
62 StMcIstHitCollection::numberOfHits() const
63 {
64  unsigned long sum = 0;
65  for (int i=0; i<mNumberOfLayers; i++)
66  sum += mLayers[i].numberOfHits();
67 
68  return sum;
69 }
70 
72 StMcIstHitCollection::layer(unsigned int i)
73 {
74  if (i < mNumberOfLayers)
75  return &(mLayers[i]);
76  else
77  return 0;
78 }
79 
81 StMcIstHitCollection::layer(unsigned int i) const
82 {
83  if (i < mNumberOfLayers)
84  return &(mLayers[i]);
85  else
86  return 0;
87 }