StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcSvtHitCollection.cc
1 /***************************************************************************
2  *
3  * $Id: StMcSvtHitCollection.cc,v 2.4 2005/01/27 23:40:48 calderon Exp $
4  *
5  * Author: Manuel Calderon de la Barca Sanchez, Oct 1999
6  ***************************************************************************
7  *
8  * Description: Monte Carlo Svt Hit Collection class
9  *
10  ***************************************************************************
11  *
12  * $Log: StMcSvtHitCollection.cc,v $
13  * Revision 2.4 2005/01/27 23:40:48 calderon
14  * Adding persistency to StMcEvent as a step for Virtual MonteCarlo.
15  *
16  * Revision 2.3 2000/04/19 18:32:23 calderon
17  * Added check for SSD in barrel collection
18  * put default numbers for l, d, w in SvtHitCollection
19  *
20  * Revision 2.2 2000/03/06 18:05:22 calderon
21  * 1) Modified SVT Hits storage scheme from layer-ladder-wafer to
22  * barrel-ladder-wafer.
23  * 2) Added Rich Hit class and collection, and links to them in other
24  * classes.
25  *
26  * Revision 2.1 1999/12/14 07:04:49 calderon
27  * Numbering scheme as per SVT request.
28  *
29  * Revision 2.0 1999/11/17 02:00:59 calderon
30  * Completely revised for new StEvent
31  *
32  *
33  **************************************************************************/
34 #include "StMcSvtHitCollection.hh"
35 #include "StMcSvtHit.hh"
36 
37 static const char rcsid[] = "$Id: StMcSvtHitCollection.cc,v 2.4 2005/01/27 23:40:48 calderon Exp $";
38 ClassImp(StMcSvtHitCollection);
39 StMcSvtHitCollection::StMcSvtHitCollection()
40 {
41  //
42  // Barrel and ladder collections have to know
43  // their barrel number in order to return the
44  // proper numberOfLadders() and numberOfWafers().
45  //
46  for (int i=0; i<mNumberOfBarrels; i++) {
47  mBarrels[i].setBarrelNumber(i);
48  for (unsigned int j=0; j<mBarrels[i].numberOfLadders(); j++)
49  mBarrels[i].ladder(j)->setBarrelNumber(i);
50  }
51 }
52 
53 StMcSvtHitCollection::~StMcSvtHitCollection() { /* noop */ }
54 
55 unsigned int
56 StMcSvtHitCollection::numberOfBarrels() const { return mNumberOfBarrels; }
57 
58 bool
59 StMcSvtHitCollection::addHit(StMcSvtHit* hit)
60 {
61  unsigned int l, d, w;
62  l = d = w = 99999; // set to some default invalid number
63  if (hit &&
64  (l = hit->barrel()-1) < mNumberOfBarrels &&
65  (d = hit->ladder()-1) < mBarrels[l].numberOfLadders() &&
66  (w = hit->wafer()-1) < mBarrels[l].ladder(d)->numberOfWafers()) {
67  mBarrels[l].ladder(d)->wafer(w)->hits().push_back(hit);
68  return true;
69  }
70  else {
71  //cout << "\nBAD Hit:\n" << *hit << endl;
72  return false;
73  }
74 }
75 
76 unsigned long
77 StMcSvtHitCollection::numberOfHits() const
78 {
79  unsigned long sum = 0;
80  for (int i=0; i<mNumberOfBarrels; i++)
81  for (unsigned int j=0; j<mBarrels[i].numberOfLadders(); j++)
82  for (unsigned int k=0; k<mBarrels[i].ladder(j)->numberOfWafers(); k++)
83  sum += mBarrels[i].ladder(j)->wafer(k)->hits().size();
84  return sum;
85 }
86 
88 StMcSvtHitCollection::barrel(unsigned int i)
89 {
90  if (i < mNumberOfBarrels)
91  return &(mBarrels[i]);
92  else
93  return 0;
94 }
95 
97 StMcSvtHitCollection::barrel(unsigned int i) const
98 {
99  if (i < mNumberOfBarrels)
100  return &(mBarrels[i]);
101  else
102  return 0;
103 }