StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPmdDetector.cxx
1 /*******************************************************
2  *
3  * $Id: StPmdDetector.cxx,v 1.6 2010/05/28 17:24:27 rashmi Exp $
4  *
5  * Author: Subhasis Chattopadhyay, July 2002
6  *******************************************************
7  *
8  * Description: Base class for PMD detector
9  *
10  *********************************************************
11  * $Log: StPmdDetector.cxx,v $
12  * Revision 1.6 2010/05/28 17:24:27 rashmi
13  * Returns cirrect number of Hits in a module now
14  *
15  * Revision 1.5 2004/09/22 19:24:56 perev
16  * Leak fixed + mess with i,j indexes
17  *
18  * Revision 1.4 2004/06/29 17:31:41 perev
19  * Zeroing in ctr added and tests for null pointers
20  *
21  * Revision 1.3 2003/10/14 10:16:50 subhasis
22  * zeroed before delete
23  *
24  * Revision 1.2 2003/05/12 12:07:13 subhasis
25  * Mapping added
26  *
27  *********************************************************/
28 #include "StPmdDetector.h"
29 #include "StPmdHit.h"
30 #include "StPmdModule.h"
31 #include "StPmdClusterCollection.h"
32 
33 
34 ClassImp(StPmdDetector)
35 
37 {
38  mDetectorId=0;
39  mNumberOfModules=0;
40 
41  memset(mModules_NHit,0,sizeof(mModules_NHit));
42  memset(mModules ,0,sizeof(mModules ));
43  mClusters=0;
44 }
45 
46 StPmdDetector::StPmdDetector(Int_t id, unsigned int n)
47 {
48  mClusters = 0;
49  mDetectorId = id;
50  mNumberOfModules = n;
51  memset(mModules_NHit,0,sizeof(mModules_NHit));
52  memset(mModules ,0,sizeof(mModules ));
53  for(int i=0; i<12;i++)
54  {
55  StPmdModule * module = new StPmdModule();
56  setModule(module,i);
57  }
58 
59 }
60 
62 {
63  for(int i=0; i<12;i++) delete mModules[i];
64  delete mClusters; mClusters=0;
65 }
66 
67 bool
69 {
70  if (hit){
71  Int_t m = hit->module();
72  if (m > 0 && m <= 12)
73  {
74  mModules[m-1]->Hits()->Add(hit);
75  mModules_NHit[m-1]++;
76  return kTRUE;
77  }
78  }
79  return kFALSE;
80 }
81 
82 Int_t
84  if (i > 0 && i <= 12) {
85  return mModules_NHit[i-1]; }
86  else return 0;
87 }
88 
89 unsigned int
90 StPmdDetector::numberOfModules() const { return mNumberOfModules; }
91 
92 unsigned int
94 {
95  unsigned int sum = 0;
96  for(Int_t i=0;i<12;i++){
97  // cout<<" Module number "<<i+1<<" has "<<mModules_NHit[i]<<" hits."<<endl;
98  sum=sum+mModules_NHit[i];
99  }
100  return sum;
101 }
102 
104 StPmdDetector::module(unsigned int i)
105 {
106  if (i > 0 && i <= 12) return (mModules[i-1]);
107  else return 0;
108 }
109 
110 void
112 {
113  if (val)
114  {
115  if (IdMod >= 0 && IdMod < static_cast<int>(mNumberOfModules))
116  {
117  mModules_NHit[IdMod]=0;
118  delete mModules[IdMod];
119  mModules[IdMod] = val;
120  }
121  }
122 }
123 
125 StPmdDetector::cluster() {return mClusters;}
126 
127 void
129 {
130 //VP if (mClusters) mClusters=0;
131  delete mClusters;
132  mClusters = val;
133 }
134 
void setModule(StPmdModule *, int)
number of hits in the module
bool addHit(StPmdHit *)
no of modules
Int_t module_hit(Int_t)
module number
unsigned int numberOfHits() const
for adding hits to detector
void setCluster(StPmdClusterCollection *)
number of clusters
unsigned int numberOfModules() const
destructor
Int_t module()
function for supermodule no.
Definition: StPmdHit.h:92
~StPmdDetector()
constructor
StPmdModule * module(unsigned int)
number of hits