BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMucDigit.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oriented Simulation Tool //
3//---------------------------------------------------------------------------//
4//Description:
5//Author: Youzy Peking University mail: [email protected]
6//Created: Dec, 2003
7//Modified:
8//Comment:
9//---------------------------------------------------------------------------//
10
11//
12// $Id: BesMucDigit
13
14#include "BesMucDigit.hh"
15#include "G4ios.hh"
16#include "G4Box.hh"
17#include "G4VSolid.hh"
18#include "strstream"
19class G4VSolid;
20
22{
23}
24
26{
27}
28
30{
31 m_pHit = hit;
32
33 G4int part = m_pHit->GetPart();
34 G4int seg = m_pHit->GetSeg();
35 G4int gap = m_pHit->GetGap();
36 m_Pos = m_pHit->GetPosLocal().x();
37 if ( (part == 1 && gap%2 != 0) || (part != 1 && gap%2 == 0) ) {
38 m_Pos = m_pHit->GetPosLocal().y();
39 }
40
41 if(part == 1 && seg == 2 &&gap%2 != 0) m_Pos2 = m_pHit->GetPosLocal().x();
42
43 G4VPhysicalVolume* pvGasChamber = m_pHit->GetVolume();
44 if(m_pHit->GetTrackID()!=-1){
45 m_lvGap = pvGasChamber->GetMotherLogical(); //after update gdml, mother of gaschamber change to be aluminumbox, but i still use the name m_lvGap
46 m_lvGapName = m_lvGap->GetName();
47
48 //G4cout<<"in digit----"<<m_lvGapName<<" "<<m_lvGap->GetDaughter(1)->GetLogicalVolume()->GetName()<<G4endl;
49 }
50}
51
52G4VPhysicalVolume*
54{
55 m_pvStripDigit = GetStrip( GetNearestStripNo() );
56 if(!m_pvStripDigit) {
57 G4cerr << "Nearest Strip is not found." << G4endl;
58 }
59
60 return m_pvStripDigit;
61}
62
64{
65 if(m_pHit->GetTrackID()!=-1){
66 G4float posStrip0 = GetStripPos( GetStrip(0) );
67 G4float posStrip1 = GetStripPos( GetStrip(1) );
68 G4float width = posStrip1 - posStrip0;
69 //G4cout << "posStrip0 " << posStrip0 << " posStrip1 " << posStrip1 << G4endl;
70
71 G4int iGuessStrip = G4int( (m_Pos - posStrip0)/width + 0.5 );
72 // confine iGuessStrip to an extend before check IsNearest.
73 if(iGuessStrip < 0) {
74 iGuessStrip = 0;
75 }
76 else if(iGuessStrip >= 112) {
77 iGuessStrip = 112;
78 }
79 //G4cout << "m_pos=" << m_Pos << "firstly, I guess: " << iGuessStrip << G4endl;
80
81 G4int step = IsNearest(iGuessStrip);
82 while(step != 0) {
83 //G4cout << "guess " << iGuessStrip << " wrong , iGuess " << step << G4endl;
84 iGuessStrip += step;
85 step = IsNearest(iGuessStrip);
86 }
87 //G4cout << " guess " << iGuessStrip << " right " << G4endl;
88
89 //deal with barrel segment 2 gap%2!=0
90 G4int part = m_pHit->GetPart();
91 G4int seg = m_pHit->GetSeg();
92 G4int gap = m_pHit->GetGap();
93 //G4cout<<" in Digit iGuessStrip = "<< iGuessStrip <<G4endl;
94 if(part == 1 && seg == 2 &&gap%2 != 0 && iGuessStrip > 79 ){
95 if(iGuessStrip > 79 && iGuessStrip <= 95 && m_Pos2 < 0) iGuessStrip += 16 ;
96 if(iGuessStrip > 95 && iGuessStrip <= 111 && m_Pos2 > 0) iGuessStrip -= 16 ;
97 //G4cout<<" in barrel segment 2 and gap%2!=0, and strip > 79 strip="<< iGuessStrip<<" posx="<<m_Pos2<<" "<<" posy="<<m_Pos<<G4endl;
98 }
99
100 return iGuessStrip;
101 }
102 else return m_pHit->GetStrip();
103}
104
105G4VPhysicalVolume*
107{
108 // If no strip get, return 0.
109 // If i > daughtersNo, there will be run error.
110 G4LogicalVolume *lvStripPlane = m_lvGap->GetDaughter(0)->GetLogicalVolume();
111 G4int daughtersNo = lvStripPlane->GetNoDaughters();
112
113 if(i >= 0 && i < daughtersNo) {
114 G4VPhysicalVolume* pvStrip = lvStripPlane->GetDaughter(i);
115 G4String strStrip = pvStrip->GetLogicalVolume()->GetName();
116 //G4cout << "length " << strStrip.length() << G4endl;
117 //if(strStrip.length() == 30) { //use name length to determine whether it is a strip
118
119 if (strStrip.find("s") == 10) { //"Strip" at 23 of "logicalMucPart1Seg0Gap0Strip111"
120 //"s" at 10 of lMucP0S0G0s001
121 return pvStrip;
122 }
123 //return pvStrip;
124 }
125
126 return 0;
127}
128
129G4float BesMucDigit::GetStripPos(G4VPhysicalVolume* pvStrip)
130{
131 G4float pos = 1.0e38;
132 if (!pvStrip) return pos;
133
134 G4int part = m_pHit->GetPart();
135 G4int gap = m_pHit->GetGap();
136
137 pos = pvStrip->GetObjectTranslation().x();
138 if ( (part == 1 && gap%2 != 0) || (part != 1 && gap%2 == 0) ) {
139 pos = pvStrip->GetObjectTranslation().y();
140 }
141
142 G4String striptype= pvStrip->GetLogicalVolume()->GetSolid()->GetEntityType();
143// G4String striplenght= pvStrip->GetLogicalVolume()->GetName();
144 G4Box *temp;
145 temp=(G4Box *)pvStrip->GetLogicalVolume()->GetSolid();
146 G4double length=temp->GetXHalfLength();
147// std::ostream length;
148// pvStrip->GetLogicalVolume()->GetSolid()->StreamInfo( length);
149
150 G4float box1,box2,box3;
151// length>>box1>>box2>>box3;
152 //G4cout<<length<<" "<<striptype<<" in GetStripPos "<<pvStrip->GetObjectTranslation().x()<<" "<<pvStrip->GetObjectTranslation().y()<<" "<<pvStrip->GetObjectTranslation().z()<<G4endl;
153 return pos;
154}
155
156
157
159{
160 G4float posMax = 1.0e38;
161 G4float posLeftStrip;
162 G4float posRightStrip;
163 G4float posCurrentStrip;
164
165 G4VPhysicalVolume* pvLeftStrip = GetStrip(i-1);
166 G4VPhysicalVolume* pvRightStrip = GetStrip(i+1);
167 G4VPhysicalVolume* pvCurrentStrip = GetStrip(i);
168
169 if(i < 0) {
170 return i;
171 }
172 else if(i == 0) {
173 posLeftStrip = -1.0*posMax;
174 posRightStrip = GetStripPos( pvRightStrip );
175 }
176 else if(!pvCurrentStrip) {
177 // i > Max.
178 return -1;
179 }
180 else if(!pvRightStrip) {
181 // i = Max.
182 posLeftStrip = GetStripPos( pvLeftStrip );
183 posRightStrip = posMax;
184 }
185 else {
186 // 0 < i < Max.
187 posLeftStrip = GetStripPos( pvLeftStrip );
188 posRightStrip = GetStripPos( pvRightStrip );
189 }
190 posCurrentStrip = GetStripPos( pvCurrentStrip );
191
192 G4float distCurrent = std::abs(m_Pos - posCurrentStrip);
193 G4float distLeft = std::abs(m_Pos - posLeftStrip);
194 G4float distRight = std::abs(m_Pos - posRightStrip);
195
196 //G4cout << "left " << distLeft << " current " << distCurrent << " right " << distRight << G4endl;
197
198 if( (distCurrent <= distLeft) && (distCurrent <= distRight) ) {
199 return 0;
200 }
201 else if(distCurrent > distLeft) {
202 return -1;
203 }
204 else {
205 return 1;
206 }
207
208}
G4VPhysicalVolume * GetStrip(G4int i)
Definition: BesMucDigit.cc:106
G4float GetStripPos(G4VPhysicalVolume *pvStrip)
Definition: BesMucDigit.cc:129
G4int GetNearestStripNo()
Definition: BesMucDigit.cc:63
G4VPhysicalVolume * GetNearestStrip()
Definition: BesMucDigit.cc:53
G4int IsNearest(G4int i)
Definition: BesMucDigit.cc:158
void SetHit(BesMucHit *hit)
Definition: BesMucDigit.cc:29