BOSS 8.0.0
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#include "Identifier/MucID.h"
14
15// Constructor.
17
18// Destructor.
22
23// Initializes the MucRecHitContainer.
25 // cout << "MucRecHitContainer::Init-I1 hello world" << endl;
26
27 Clear();
28
29 // cout << "*********** Hit Container Initialized! *********** " << endl;
30}
31
33 for ( int part = 0; part < (int)MucID::getPartNum(); part++ )
34 {
35 for ( int seg = 0; seg < (int)MucID::getSegNum( part ); seg++ )
36 {
37 for ( int gap = 0; gap < (int)MucID::getGapNum( part ); gap++ )
38 {
39 MucRecHitID gapID( part, seg, gap );
40 m_GapHitCount[gapID] = 0;
41 }
42 }
43 }
44
45 // m_pMucRecHitCol->clear();
46 m_pHit.clear();
47}
48
50 int count = 0;
51 for ( int part = 0; part < (int)MucID::getPartNum(); part++ )
52 {
53 for ( int seg = 0; seg < (int)MucID::getSegNum( part ); seg++ )
54 {
55 for ( int gap = 0; gap < (int)MucID::getGapNum( part ); gap++ )
56 {
57 MucRecHitID gapID( part, seg, gap );
58 count += m_GapHitCount[gapID];
59 }
60 }
61 }
62
63 return count;
64}
65
67 if ( m_GapHitCount.count( gapID ) ) return m_GapHitCount[gapID];
68 return 0;
69}
70
71int MucRecHitContainer::GetGapHitCount( const int part, const int seg, const int gap ) {
72 MucRecHitID gapID( part, seg, gap );
73 return m_GapHitCount[gapID];
74}
75
77 if ( m_pHit.count( id ) ) return m_pHit[id];
78 else return 0;
79}
80
81MucRecHit* MucRecHitContainer::GetHit( const int part, const int seg, const int gap,
82 const int hit ) {
83 MucRecHitID id( part, seg, gap, hit );
84 return m_pHit[id];
85}
86
88 int part = MucID::part( id );
89 int seg = MucID::seg( id );
90 int gap = MucID::gap( id );
91 int strip = MucID::strip( id );
92
93 return GetHitByIdentifier( part, seg, gap, strip );
94}
95
96MucRecHit* MucRecHitContainer::GetHitByIdentifier( const int part, const int seg,
97 const int gap, const int strip ) {
98 Identifier id = MucID::channel_id( part, seg, gap, strip );
99 for ( int i = 0; i < GetGapHitCount( part, seg, gap ); i++ )
100 {
101 MucRecHit* hit = GetHit( part, seg, gap, i );
102 if ( id == hit->GetID() ) { return hit; }
103 }
104
105 return 0;
106}
107
108// Place a new hit object in the container.
110 int part = MucID::part( id );
111 int seg = MucID::seg( id );
112 int gap = MucID::gap( id );
113 int strip = MucID::strip( id );
114
115 AddHit( part, seg, gap, strip );
116}
117
118// Place a new hit object in the container.
119void MucRecHitContainer::AddHit( const int part, const int seg, const int gap,
120 const int strip ) {
121 if ( ( part >= 0 ) && ( part < (int)MucID::getPartNum() ) && ( seg >= 0 ) &&
122 ( seg < (int)MucID::getSegNum( part ) ) && ( gap >= 0 ) &&
123 ( gap < (int)MucID::getGapNum( part ) ) && ( strip >= 0 ) &&
124 ( strip < (int)MucID::getStripNum( part, seg, gap ) ) )
125 {
126 MucRecHitID gapID( part, seg, gap );
127 // cout << "MucRecHitContainer::AddHit-I1 " << idGap << endl;
128
129 int hitCount = m_GapHitCount[gapID];
130 MucRecHitID id( part, seg, gap, hitCount );
131 // cout << "MucRecHitContainer::AddHit-I2 hit id = " << id << endl;
132
133 MucRecHit* pHit = new MucRecHit( part, seg, gap, strip );
134 m_pMucRecHitCol->push_back( pHit );
135
136 m_pHit[id] = pHit;
137 if ( !m_pHit[id] )
138 { cout << "MucRecHitContainer::AddHit-F1 failed to create new MucRecHit" << endl; }
139 else { m_GapHitCount[gapID]++; }
140 }
141}
142
144 m_pMucRecHitCol = p;
145
146 MucRecHitCol::iterator imuchit;
147 for ( imuchit = p->begin(); imuchit != p->end(); imuchit++ )
148 {
149 int part = ( *imuchit )->Part();
150 int seg = ( *imuchit )->Seg();
151 int gap = ( *imuchit )->Gap();
152 int strip = ( *imuchit )->Strip();
153
154 MucRecHitID gapID( part, seg, gap );
155 int hitCount = m_GapHitCount[gapID];
156 MucRecHitID id( part, seg, gap, hitCount );
157
158 m_pHit[id] = *imuchit;
159 if ( !m_pHit[id] )
160 { cout << "MucRecHitContainer::AddHit-F1 failed to create new MucRecHit" << endl; }
161 else { m_GapHitCount[gapID]++; }
162 }
163}
DOUBLE_PRECISION count[3]
static int part(const Identifier &id)
Definition MucID.cxx:43
static value_type getPartNum()
Definition MucID.cxx:131
static Identifier channel_id(int barrel_ec, int segment, int layer, int channel)
For a single crystal.
Definition MucID.cxx:114
static int gap(const Identifier &id)
Definition MucID.cxx:63
static int seg(const Identifier &id)
Definition MucID.cxx:53
static value_type getSegNum(int part)
Definition MucID.cxx:134
static value_type getStripNum(int part, int seg, int gap)
Definition MucID.cxx:148
static int strip(const Identifier &id)
Definition MucID.cxx:73
static value_type getGapNum(int part)
Definition MucID.cxx:141
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.