86 for(G4int part=0;part<3;part++){
87 for(G4int seg=0;seg<8;seg++){
88 for(G4int gap=0;gap<9;gap++){
89 m_noise[part][seg][gap]=1;
94 G4cout<<
"filename: "<<filename<<G4endl;
95 std::ifstream fin(filename);
97 G4cout<<
"error opening muc_noise data"<<G4endl;
100 fin.getline(buffer,200,
'\n');
101 std::istringstream stringBuf(buffer);
104 G4int tot_NoDaughter = logicalMuc->GetNoDaughters();
106 for(G4int i=0; i<tot_NoDaughter;i++){
107 G4LogicalVolume* i_LogicalGap = logicalMuc->GetDaughter(i)->GetLogicalVolume();
108 G4String i_GapName = i_LogicalGap->GetName();
110 if(i_GapName.find(
"G")==8){
111 G4LogicalVolume* i_LogicalBox = i_LogicalGap->GetDaughter(0)->GetLogicalVolume();
112 G4LogicalVolume* i_LogicalStripPlane = i_LogicalBox->GetDaughter(0)->GetLogicalVolume();
114 G4String strPart = i_GapName.substr(5,1);
115 G4String strSeg = i_GapName.substr(7,1);
116 G4String strGap = i_GapName.substr(9,1);
118 std::istrstream partBuf(strPart.c_str(), strlen(strPart.c_str()));
119 std::istrstream segBuf(strSeg.c_str(), strlen(strSeg.c_str()));
120 std::istrstream gapBuf(strGap.c_str(), strlen(strGap.c_str()));
128 G4int tot_NoStrip = i_LogicalStripPlane->GetNoDaughters();
129 area[part][seg][gap][0]=tot_NoStrip;
132 G4LogicalVolume* i_LogicalStrip1 = i_LogicalStripPlane->GetDaughter(1)->GetLogicalVolume();
133 G4LogicalVolume* i_LogicalStrip2 = i_LogicalStripPlane->GetDaughter(2)->GetLogicalVolume();
134 G4Box *temp1; G4Box *temp2;
136 temp1=(G4Box *)i_LogicalStrip1->GetSolid();temp2=(G4Box *)i_LogicalStrip2->GetSolid();
137 G4float Width1 =temp1->GetXHalfLength()*2;G4float Width2 =temp2->GetXHalfLength()*2;
138 G4float pos1 =i_LogicalStripPlane->GetDaughter(1)->GetObjectTranslation().x();
139 G4float pos2 =i_LogicalStripPlane->GetDaughter(2)->GetObjectTranslation().x();
140 if ( (part == 1 && gap%2 != 0) || (part != 1 && gap%2 == 0) ) {
141 Width1=temp1->GetYHalfLength()*2; Width2 =temp2->GetYHalfLength()*2;
142 pos1 =i_LogicalStripPlane->GetDaughter(1)->GetObjectTranslation().y();
143 pos2 =i_LogicalStripPlane->GetDaughter(2)->GetObjectTranslation().y();
145 G4float width_between_strip=pos2-pos1-Width1/2-Width2/2;
148 for(G4int j=0;j<tot_NoStrip;j++){
149 G4LogicalVolume* i_LogicalStrip = i_LogicalStripPlane->GetDaughter(j)->GetLogicalVolume();
151 temp=(G4Box *)i_LogicalStrip->GetSolid();
152 G4float
Width =temp->GetXHalfLength()*2;
153 G4float Length=temp->GetYHalfLength()*2;
154 if ( (part == 1 && gap%2 != 0) || (part != 1 && gap%2 == 0) ) {
155 Width =temp->GetYHalfLength()*2;
156 Length=temp->GetXHalfLength()*2;
159 if(j==0||j==(tot_NoStrip-1))
Width=
Width+width_between_strip/2;
161 G4float Strip_Area=fabs(
Width*Length);
162 tot_Area=tot_Area+Strip_Area;
163 area[part][seg][gap][j+1]=tot_Area;
164 strip_area[part][seg][gap][j] = Strip_Area;
169 box_area[part][seg][gap] = tot_Area;
171 for(G4int k=1;k<tot_NoStrip+1;k++){
172 area[part][seg][gap][k]=area[part][seg][gap][k]/tot_Area;
233 m_noiseLevel = m_ptrCalibSvc->
getLevel();
235 for(
int i = 0; i < m_kPart; i++) {
236 for(
int j = 0; j < m_kSegment[i]; j++) {
237 for(
int k = 0; k < m_kGap[i]; k++) {
238 if(m_noiseLevel == 2)
241 for(G4int ii=0;ii<hitNum;ii++)
246 bool noiseHitExist =
false;
247 noiseHitExist =
IsExist(noiseHit, MucHitList);
248 MucHitCollection->insert(noiseHit);
250 MucHitList->insert(noiseHit2);
254 else delete noiseHit2;
258 if(m_noiseLevel == 3)
261 for(
int strip = 0; strip < stripNum; strip++)
263 G4int hitNum =
NoiseSampling( m_noiseLevel, i, j, k, strip );
267 bool noiseHitExist =
false;
268 noiseHitExist =
IsExist(noiseHit, MucHitList);
269 MucHitCollection->insert(noiseHit);
271 MucHitList->insert(noiseHit2);
275 else delete noiseHit2;
292 random = G4UniformRand();
293 for(
int i=0; i<20; i++) {
294 if(random<m_Prob[i][1]) {noiseNum = i;
break;}
298 int prt, seg, lay, str, tmp_strip;
299 G4float nosRatio = 0.;
301 for(
int i=0; i<noiseNum; i++)
304 random = G4UniformRand();
305 tmp_strip = TMath::Nint(random*
STRIP_MAX);
308 random = G4UniformRand();
309 if( random<nosRatio )
break;
317 bool noiseHitExist =
false;
318 noiseHitExist =
IsExist(noiseHit, MucHitList);
319 MucHitCollection->insert(noiseHit);
320 if(!noiseHitExist) MucHitList->insert(noiseHit2);
321 else delete noiseHit2;
390 G4float random=(rand()%100000)/100000.0;
392 G4float width=area[part][seg][gap][3]-area[part][seg][gap][2];
393 stripno=G4int((random-area[part][seg][gap][1])/width)+2;
394 if(stripno<1)stripno=1;
395 if(stripno>111)stripno=111;
407 G4int max,min,mid,pass;
409 max=area[part][seg][gap][0];
410 mid=G4int((min+max)/2);
415 if(random>area[part][seg][gap][mid]){
417 mid=G4int((min+max)/2);
419 else if(random<area[part][seg][gap][mid-1]){
420 if(random<area[part][seg][gap][1]){
424 mid=G4int((min+max)/2);
430 }
while(pass==0&&(max>mid&&mid>min));