BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
MucRecHitContainer.cxx
Go to the documentation of this file.
1//$id$
2//
3//$log$
4
5/*
6 * 2003/12/13 Zhengyun You Peking University
7 *
8 * 2004/09/12 Zhengyun You Peking University
9 * transplanted to Gaudi framework
10 */
11
12#include "MucRecEvent/MucRecHitContainer.h"
13
14// Constructor.
16{ }
17
18// Destructor.
20{
21 //Clear();
22}
23
24// Initializes the MucRecHitContainer.
25void
27{
28 // cout << "MucRecHitContainer::Init-I1 hello world" << endl;
29
30 Clear();
31
32 //cout << "*********** Hit Container Initialized! *********** " << endl;
33}
34
35void
37{
38 for (int part = 0; part < (int)MucID::getPartNum(); part++) {
39 for (int seg = 0; seg < (int)MucID::getSegNum(part); seg++) {
40 for (int gap = 0; gap < (int)MucID::getGapNum(part); gap++) {
41 MucRecHitID gapID(part, seg, gap);
42 m_GapHitCount[gapID] = 0;
43 }
44 }
45 }
46
47 //m_pMucRecHitCol->clear();
48 m_pHit.clear();
49}
50
51int
53{
54 int count = 0;
55 for (int part = 0; part < (int)MucID::getPartNum(); part++) {
56 for (int seg = 0; seg < (int)MucID::getSegNum(part); seg++) {
57 for (int gap = 0; gap < (int)MucID::getGapNum(part); gap++) {
58 MucRecHitID gapID(part, seg, gap);
59 count += m_GapHitCount[gapID];
60 }
61 }
62 }
63
64 return count;
65}
66
67int
69{
70 if (m_GapHitCount.count(gapID)) return m_GapHitCount[gapID];
71 return 0;
72}
73
74int
76 const int seg,
77 const int gap)
78{
79 MucRecHitID gapID(part, seg, gap);
80 return m_GapHitCount[gapID];
81}
82
85{
86 if (m_pHit.count(id)) return m_pHit[id];
87 else return 0;
88}
89
92 const int seg,
93 const int gap,
94 const int hit)
95{
96 MucRecHitID id(part, seg, gap, hit);
97 return m_pHit[id];
98}
99
100MucRecHit*
102{
103 int part = MucID::part(id);
104 int seg = MucID::seg(id);
105 int gap = MucID::gap(id);
106 int strip = MucID::strip(id);
107
108 return GetHitByIdentifier(part, seg, gap, strip);
109}
110
111MucRecHit*
113 const int seg,
114 const int gap,
115 const int strip)
116{
117 Identifier id = MucID::channel_id(part, seg, gap, strip);
118 for(int i = 0; i < GetGapHitCount(part, seg, gap); i++) {
119 MucRecHit *hit = GetHit(part, seg, gap, i);
120 if(id == hit->GetID()) {
121 return hit;
122 }
123 }
124
125 return 0;
126}
127
128// Place a new hit object in the container.
129void
131{
132 int part = MucID::part(id);
133 int seg = MucID::seg(id);
134 int gap = MucID::gap(id);
135 int strip = MucID::strip(id);
136
137 AddHit(part, seg, gap, strip);
138}
139
140// Place a new hit object in the container.
141void
143 const int seg,
144 const int gap,
145 const int strip)
146{
147 if ( (part >= 0) && (part < (int)MucID::getPartNum()) &&
148 (seg >= 0) && (seg < (int)MucID::getSegNum(part)) &&
149 (gap >= 0) && (gap < (int)MucID::getGapNum(part)) &&
150 (strip >= 0) && (strip < (int)MucID::getStripNum(part, seg, gap)) )
151 {
152 MucRecHitID gapID(part, seg, gap);
153 // cout << "MucRecHitContainer::AddHit-I1 " << idGap << endl;
154
155 int hitCount = m_GapHitCount[gapID];
156 MucRecHitID id(part, seg, gap, hitCount);
157 // cout << "MucRecHitContainer::AddHit-I2 hit id = " << id << endl;
158
159 MucRecHit *pHit = new MucRecHit(part, seg, gap, strip);
160 m_pMucRecHitCol->push_back(pHit);
161
162 m_pHit[id] = pHit;
163 if(!m_pHit[id]) {
164 cout << "MucRecHitContainer::AddHit-F1 failed to create new MucRecHit" << endl;
165 }
166 else {
167 m_GapHitCount[gapID]++;
168 }
169 }
170}
171
172void
174{
175 m_pMucRecHitCol = p;
176
177 MucRecHitCol::iterator imuchit;
178 for(imuchit = p->begin();
179 imuchit != p->end();
180 imuchit++){
181 int part = (*imuchit)->Part();
182 int seg = (*imuchit)->Seg();
183 int gap = (*imuchit)->Gap();
184 int strip= (*imuchit)->Strip();
185
186 MucRecHitID gapID(part, seg, gap);
187 int hitCount = m_GapHitCount[gapID];
188 MucRecHitID id(part, seg, gap, hitCount);
189
190 m_pHit[id] = *imuchit;
191 if(!m_pHit[id]) {
192 cout << "MucRecHitContainer::AddHit-F1 failed to create new MucRecHit" << endl;
193 }
194 else {
195 m_GapHitCount[gapID]++;
196 }
197
198
199 }
200
201}
202
DOUBLE_PRECISION count[3]
ObjectVector< MucRecHit > MucRecHitCol
static int part(const Identifier &id)
Definition: MucID.cxx:46
static value_type getPartNum()
Definition: MucID.cxx:159
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
Definition: MucID.cxx:135
static int gap(const Identifier &id)
Definition: MucID.cxx:66
static int seg(const Identifier &id)
Definition: MucID.cxx:56
static value_type getSegNum(int part)
Definition: MucID.cxx:164
static value_type getStripNum(int part, int seg, int gap)
Definition: MucID.cxx:178
static int strip(const Identifier &id)
Definition: MucID.cxx:76
static value_type getGapNum(int part)
Definition: MucID.cxx:171
void Clear()
Remove all hit objects from the container, and destroy them.
int GetHitCount()
How many hits are there in this event?
MucRecHit * GetHit(const MucRecHitID hitID)
Get a MucRecHit object by hit identifier.
void AddHit(const Identifier id)
void Init()
Points to the single instance of MucRecHitContainer.
MucRecHit * GetHitByIdentifier(const Identifier id)
void SetMucRecHitCol(MucRecHitCol *p)
int GetGapHitCount(const MucRecHitID gapID)
How many hits are there in this gap?
Identifier GetID() const
Get soft identifier of this hit.