BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMucNoise Class Reference

#include <BesMucNoise.hh>

Public Member Functions

 BesMucNoise ()
 ~BesMucNoise ()
void Initialize (G4String filename, G4LogicalVolume *logicalMuc)
void Initialize (G4String filename, G4LogicalVolume *logicalMuc, G4String temp)
void CheckCalibSvc ()
G4int AddNoise (int model, BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseByCnt (BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseByNosRatio (BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseSampling (int level, int prt, int seg, int lay, int strip)
G4int GetStripNo (G4int, G4int, G4int)
G4int IsNearestStrip (G4int, G4int, G4int, G4int, G4float)
bool IsExist (BesMucHit *aNoiseHit, BesMucHitsCollection *aMucHitList)
G4float Factorial (G4int i)
void InitProb ()
 BesMucNoise ()
 ~BesMucNoise ()
void Initialize (G4String filename, G4LogicalVolume *logicalMuc)
void Initialize (G4String filename, G4LogicalVolume *logicalMuc, G4String temp)
void CheckCalibSvc ()
G4int AddNoise (int model, BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseByCnt (BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseByNosRatio (BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseSampling (int level, int prt, int seg, int lay, int strip)
G4int GetStripNo (G4int, G4int, G4int)
G4int IsNearestStrip (G4int, G4int, G4int, G4int, G4float)
bool IsExist (BesMucHit *aNoiseHit, BesMucHitsCollection *aMucHitList)
G4float Factorial (G4int i)
void InitProb ()
 BesMucNoise ()
 ~BesMucNoise ()
void Initialize (G4String filename, G4LogicalVolume *logicalMuc)
void Initialize (G4String filename, G4LogicalVolume *logicalMuc, G4String temp)
void CheckCalibSvc ()
G4int AddNoise (int model, BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseByCnt (BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseByNosRatio (BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseSampling (int level, int prt, int seg, int lay, int strip)
G4int GetStripNo (G4int, G4int, G4int)
G4int IsNearestStrip (G4int, G4int, G4int, G4int, G4float)
bool IsExist (BesMucHit *aNoiseHit, BesMucHitsCollection *aMucHitList)
G4float Factorial (G4int i)
void InitProb ()

Static Public Member Functions

static BesMucNoiseInstance (void)
static BesMucNoiseInstance (void)
static BesMucNoiseInstance (void)

Detailed Description

Constructor & Destructor Documentation

◆ BesMucNoise() [1/3]

BesMucNoise::BesMucNoise ( )

Definition at line 38 of file BesMucNoise.cc.

38 {
39 if ( fPointer )
40 {
41 G4cout << "BesMucNoise constructed twice." << G4endl;
42 exit( -1 );
43 }
44 fPointer = this;
45}

Referenced by InitProb(), and Instance().

◆ ~BesMucNoise() [1/3]

BesMucNoise::~BesMucNoise ( )

Definition at line 47 of file BesMucNoise.cc.

47 {
48 if ( m_ptrIdTr != NULL ) delete m_ptrIdTr;
49}

◆ BesMucNoise() [2/3]

BesMucNoise::BesMucNoise ( )

◆ ~BesMucNoise() [2/3]

BesMucNoise::~BesMucNoise ( )

◆ BesMucNoise() [3/3]

BesMucNoise::BesMucNoise ( )

◆ ~BesMucNoise() [3/3]

BesMucNoise::~BesMucNoise ( )

Member Function Documentation

◆ AddNoise() [1/3]

G4int BesMucNoise::AddNoise ( int model,
BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

Definition at line 233 of file BesMucNoise.cc.

234 {
235 G4int noiseNum = 0;
236 if ( model == 1 ) noiseNum = NoiseByCnt( aMucHitCollection, aMucHitList );
237 else noiseNum = NoiseByNosRatio( aMucHitCollection, aMucHitList );
238 // G4cout << "Noise hit(s) produced:\t" << noiseNum << "\tby model:\t" << model << G4endl;
239 return noiseNum;
240}
G4int NoiseByNosRatio(BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)
G4int NoiseByCnt(BesMucHitsCollection *MucHitCollection, BesMucHitsCollection *MucHitList)

◆ AddNoise() [2/3]

G4int BesMucNoise::AddNoise ( int model,
BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

◆ AddNoise() [3/3]

G4int BesMucNoise::AddNoise ( int model,
BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

◆ CheckCalibSvc() [1/3]

void BesMucNoise::CheckCalibSvc ( )

Definition at line 209 of file BesMucNoise.cc.

209 {
210 ISvcLocator* svcLocator = Gaudi::svcLocator();
211 StatusCode sc = svcLocator->service( "MucCalibConstSvc", m_ptrCalibSvc, true );
212
213 if ( sc != StatusCode::SUCCESS ) { G4cout << "Can not use MucCalibConstSvc!" << G4endl; }
214}

Referenced by Initialize().

◆ CheckCalibSvc() [2/3]

void BesMucNoise::CheckCalibSvc ( )

◆ CheckCalibSvc() [3/3]

void BesMucNoise::CheckCalibSvc ( )

◆ Factorial() [1/3]

G4float BesMucNoise::Factorial ( G4int i)

Definition at line 404 of file BesMucNoise.cc.

404 {
405 G4float fact = 1;
406 if ( i == 0 || i == 1 ) return 1;
407 else
408 {
409 for ( G4int ii = 2; ii <= i; ii++ ) { fact = fact * ii; }
410 return fact;
411 }
412}

Referenced by NoiseSampling().

◆ Factorial() [2/3]

G4float BesMucNoise::Factorial ( G4int i)

◆ Factorial() [3/3]

G4float BesMucNoise::Factorial ( G4int i)

◆ GetStripNo() [1/3]

G4int BesMucNoise::GetStripNo ( G4int part,
G4int seg,
G4int gap )

Definition at line 414 of file BesMucNoise.cc.

414 {
415 G4int stripno;
416 // G4float random=G4UniformRand();//***use other random
417 G4float random = ( rand() % 100000 ) / 100000.0;
418 if ( part == 1 )
419 { // berrel
420 G4float width = area[part][seg][gap][3] - area[part][seg][gap][2];
421 stripno = G4int( ( random - area[part][seg][gap][1] ) / width ) + 2;
422 if ( stripno < 1 ) stripno = 1;
423 if ( stripno > 111 ) stripno = 111;
424 // G4cout<<"---in noise::GetStripNo()---stripno= "<<stripno<<"
425 // "<<(random-area[part][seg][gap][1])/width<<G4endl;
426 G4int step = IsNearestStrip( stripno, part, seg, gap, random );
427 while ( step != 0 )
428 {
429 // G4cout<<"---in noise::GetStripNo()---while "<<G4endl;
430 stripno += step;
431 step = IsNearestStrip( stripno, part, seg, gap, random );
432 } // endl while
433 stripno--; // the first element is total strip number
434 return stripno;
435 }
436 else
437 { // endcap
438 G4int max, min, mid, pass;
439 min = 1;
440 max = area[part][seg][gap][0];
441 mid = G4int( ( min + max ) / 2 );
442 // G4cout<<"---in noise first---"<<min<<" "<<mid<<" "<<max<<G4endl;
443 do {
444 // G4cout<<"-----in noise---"<<random<<" "<<area[part][seg][gap][min]<<"
445 // "<<area[part][seg][gap][mid]<<"
446 // "<<area[part][seg][gap][max]<<G4endl;
447 pass = 0;
448 if ( random > area[part][seg][gap][mid] )
449 {
450 min = mid;
451 mid = G4int( ( min + max ) / 2 );
452 }
453 else if ( random < area[part][seg][gap][mid - 1] )
454 {
455 if ( random < area[part][seg][gap][1] )
456 {
457 pass = 1;
458 mid = 1;
459 max = 1;
460 }
461 else
462 {
463 max = mid - 1;
464 mid = G4int( ( min + max ) / 2 );
465 }
466 }
467 else { pass = 1; }
468
469 if ( min == mid ) mid = max;
470 // G4cout<<"-----in noise---"<<min<<" "<<mid<<" "<<max<<G4endl;
471 } while ( pass == 0 && ( max > mid && mid > min ) );
472 // G4cout<<"-----in noise--- "<<mid-1<<G4endl;
473 return mid - 1;
474 }
475}
#define min(a, b)
#define max(a, b)
G4int IsNearestStrip(G4int, G4int, G4int, G4int, G4float)

Referenced by NoiseByCnt().

◆ GetStripNo() [2/3]

G4int BesMucNoise::GetStripNo ( G4int ,
G4int ,
G4int  )

◆ GetStripNo() [3/3]

G4int BesMucNoise::GetStripNo ( G4int ,
G4int ,
G4int  )

◆ Initialize() [1/6]

void BesMucNoise::Initialize ( G4String filename,
G4LogicalVolume * logicalMuc )

Definition at line 83 of file BesMucNoise.cc.

83 {
84 for ( G4int part = 0; part < 3; part++ )
85 {
86 for ( G4int seg = 0; seg < 8; seg++ )
87 {
88 for ( G4int gap = 0; gap < 9; gap++ )
89 {
90 m_noise[part][seg][gap] = 1; // init -1
91 }
92 }
93 }
94 // read noise from file
95 G4cout << "filename: " << filename << G4endl;
96 std::ifstream fin( filename );
97 if ( !fin ) { G4cout << "error opening muc_noise data" << G4endl; }
98 char buffer[200];
99 fin.getline( buffer, 200, '\n' ); // get info whether add noise or not!
100 std::istringstream stringBuf( buffer );
101
102 // get strip area from logicalMuc!
103 G4int tot_NoDaughter = logicalMuc->GetNoDaughters();
104 // G4cout<<"---in noise::Init()--- "<<tot_NoDaughter<<G4endl;
105 for ( G4int i = 0; i < tot_NoDaughter; i++ )
106 {
107 G4LogicalVolume* i_LogicalGap = logicalMuc->GetDaughter( i )->GetLogicalVolume();
108 G4String i_GapName = i_LogicalGap->GetName();
109
110 if ( i_GapName.find( "G" ) == 8 )
111 {
112 G4LogicalVolume* i_LogicalBox = i_LogicalGap->GetDaughter( 0 )->GetLogicalVolume();
113 G4LogicalVolume* i_LogicalStripPlane =
114 i_LogicalBox->GetDaughter( 0 )->GetLogicalVolume();
115 // G4cout<<"---in noise::Init()--- "<<i<<" "<<i_GapName<<"
116 // "<<i_LogicalStripPlane->GetDaughter(1)->GetLogicalVolume()->GetName()<<G4endl;
117 G4String strPart = i_GapName.substr( 5, 1 );
118 G4String strSeg = i_GapName.substr( 7, 1 );
119 G4String strGap = i_GapName.substr( 9, 1 );
120
121 std::istrstream partBuf( strPart.c_str(), strlen( strPart.c_str() ) );
122 std::istrstream segBuf( strSeg.c_str(), strlen( strSeg.c_str() ) );
123 std::istrstream gapBuf( strGap.c_str(), strlen( strGap.c_str() ) );
124
125 G4int part, seg, gap;
126
127 partBuf >> part;
128 segBuf >> seg;
129 gapBuf >> gap;
130 // G4cout<<"-------in noise::Init()---- "<<part<<" "<<seg<<" "<<gap<<"
131 // "<<i_LogicalStripPlane->GetNoDaughters()<<G4endl;
132 G4int tot_NoStrip = i_LogicalStripPlane->GetNoDaughters();
133 area[part][seg][gap][0] = tot_NoStrip; // the first element is the total strip number
134 G4float tot_Area = 0;
135 // get width between two strip!
136 G4LogicalVolume* i_LogicalStrip1 =
137 i_LogicalStripPlane->GetDaughter( 1 )->GetLogicalVolume();
138 G4LogicalVolume* i_LogicalStrip2 =
139 i_LogicalStripPlane->GetDaughter( 2 )->GetLogicalVolume();
140 G4Box* temp1;
141 G4Box* temp2;
142
143 temp1 = (G4Box*)i_LogicalStrip1->GetSolid();
144 temp2 = (G4Box*)i_LogicalStrip2->GetSolid();
145 G4float Width1 = temp1->GetXHalfLength() * 2;
146 G4float Width2 = temp2->GetXHalfLength() * 2;
147 G4float pos1 = i_LogicalStripPlane->GetDaughter( 1 )->GetObjectTranslation().x();
148 G4float pos2 = i_LogicalStripPlane->GetDaughter( 2 )->GetObjectTranslation().x();
149 if ( ( part == 1 && gap % 2 != 0 ) || ( part != 1 && gap % 2 == 0 ) )
150 {
151 Width1 = temp1->GetYHalfLength() * 2;
152 Width2 = temp2->GetYHalfLength() * 2;
153 pos1 = i_LogicalStripPlane->GetDaughter( 1 )->GetObjectTranslation().y();
154 pos2 = i_LogicalStripPlane->GetDaughter( 2 )->GetObjectTranslation().y();
155 }
156 G4float width_between_strip = pos2 - pos1 - Width1 / 2 - Width2 / 2;
157 // G4cout<<"-----what I want---"<<width_between_strip<<" "<<pos2<<" "<<pos1<<"
158 // "<<Width1/2<<"
159 // "<<Width2/2<<G4endl;
160
161 for ( G4int j = 0; j < tot_NoStrip; j++ )
162 {
163 G4LogicalVolume* i_LogicalStrip =
164 i_LogicalStripPlane->GetDaughter( j )->GetLogicalVolume();
165 G4Box* temp;
166 temp = (G4Box*)i_LogicalStrip->GetSolid();
167 G4float Width = temp->GetXHalfLength() * 2;
168 G4float Length = temp->GetYHalfLength() * 2;
169 if ( ( part == 1 && gap % 2 != 0 ) || ( part != 1 && gap % 2 == 0 ) )
170 {
171 Width = temp->GetYHalfLength() * 2;
172 Length = temp->GetXHalfLength() * 2;
173 } // end if
174 // G4cout<<"----in noise::init()---- "<<i_LogicalStrip->GetName()<<" "<<Width<<"
175 // "<<Length<<G4endl;
176 if ( j == 0 || j == ( tot_NoStrip - 1 ) ) Width = Width + width_between_strip / 2;
177 else Width = Width + width_between_strip;
178 G4float Strip_Area = fabs( Width * Length );
179 tot_Area = tot_Area + Strip_Area;
180 area[part][seg][gap][j + 1] = tot_Area;
181 strip_area[part][seg][gap][j] = Strip_Area;
182 // G4cout<<" id: ( "<<part<<" "<<seg<<" "<<gap<<") "<<Strip_Area<<" , w: "<<Width<<" L:
183 // "<<Length<<G4endl;
184 } // end for(j)
185 // unitary
186
187 box_area[part][seg][gap] = tot_Area;
188
189 for ( G4int k = 1; k < tot_NoStrip + 1; k++ )
190 {
191 area[part][seg][gap][k] = area[part][seg][gap][k] / tot_Area;
192 // G4cout<<"----in noise::init---"<<area[part][seg][gap][k]<<G4endl;
193 } // end for(k)
194
195 } // end if(gap)
196 } // end for(i)
197
198 // G4cout<<"---in noise::init()---area--"<<G4endl;
199 // for(G4int kk=0;kk<96;kk++){
200 // G4cout<<area[1][0][0][kk+1]-area[1][0][0][kk]<<" ,";
201 // }
202
203 // init MucIdTransform and const pointer
204 m_ptrIdTr = new MucIdTransform();
206 InitProb();
207}
void CheckCalibSvc()
void InitProb()

◆ Initialize() [2/6]

void BesMucNoise::Initialize ( G4String filename,
G4LogicalVolume * logicalMuc )

◆ Initialize() [3/6]

void BesMucNoise::Initialize ( G4String filename,
G4LogicalVolume * logicalMuc )

◆ Initialize() [4/6]

void BesMucNoise::Initialize ( G4String filename,
G4LogicalVolume * logicalMuc,
G4String temp )

Definition at line 51 of file BesMucNoise.cc.

51 {
52 // m_noiseLevel = 2; // set to 2 temporary. In future, expected to get from cal servise,
53 // like m_noiseLevel = m_ptrCalibSvc->getNoiseLevel();
54 /*
55 m_noiseLevel = m_ptrCalibSvc->getLevel();
56
57 if(m_noiseLevel!=2 && m_noiseLevel!=3){
58 G4cout<<"ERROR, In BesMucNoise, noise level should be 2 or 3 ..."<<G4endl;
59 m_noiseLevel = 2;
60 }
61
62 for(int i = 0; i < m_kPart; i++) {
63 for(int j = 0; j < m_kSegment[i]; j++) {
64 for(int k = 0; k < m_kGap[i]; k++) {
65 m_noise[i][j][k] = m_ptrCalibSvc->getBoxCnt(i,j,k);
66 int stripNum = 0;
67 if(i != 1) stripNum = 64; //endcap;
68 else{
69 if(k%2 == 0) stripNum = 48;
70 if(k%2 == 1 && j != 2) stripNum = 96;
71 if(k%2 == 1 && j == 2) stripNum = 112;
72 }
73
74 for(int strip = 0; strip < stripNum; strip++){
75 m_noise_strip[i][j][k][strip] = m_ptrCalibSvc->getStripCnt(i,j,k,strip);
76 }
77 }
78 }
79 }
80 */
81}

◆ Initialize() [5/6]

void BesMucNoise::Initialize ( G4String filename,
G4LogicalVolume * logicalMuc,
G4String temp )

◆ Initialize() [6/6]

void BesMucNoise::Initialize ( G4String filename,
G4LogicalVolume * logicalMuc,
G4String temp )

◆ InitProb() [1/3]

void BesMucNoise::InitProb ( )

Definition at line 216 of file BesMucNoise.cc.

216 {
217 m_HitMean = 0.08;
218 int NHIT = 20;
219
220 for ( int i = 0; i < NHIT; i++ ) { m_Prob[i][0] = m_Prob[i][1] = 0.; }
221
222 double sum = 0.;
223 double EU = TMath::Power( TMath::Exp( 1.0 ), -m_HitMean );
224 for ( int i = 0; i < NHIT; i++ )
225 {
226 m_Prob[i][0] = EU * TMath::Power( m_HitMean, i ) / TMath::Factorial( i );
227 sum += m_Prob[i][0];
228 m_Prob[i][1] = sum;
229 // G4cout << i << "\tProb:\t" << m_Prob[i][0] << "\tSumProb:\t" << m_Prob[i][1] << G4endl;
230 }
231}

Referenced by Initialize().

◆ InitProb() [2/3]

void BesMucNoise::InitProb ( )

◆ InitProb() [3/3]

void BesMucNoise::InitProb ( )

◆ Instance() [1/3]

BesMucNoise * BesMucNoise::Instance ( void )
static

Definition at line 33 of file BesMucNoise.cc.

33 {
34 if ( !fPointer ) fPointer = new BesMucNoise();
35 return fPointer;
36}

Referenced by BesMucSD::BesMucSD().

◆ Instance() [2/3]

BesMucNoise * BesMucNoise::Instance ( void )
static

◆ Instance() [3/3]

BesMucNoise * BesMucNoise::Instance ( void )
static

◆ IsExist() [1/3]

bool BesMucNoise::IsExist ( BesMucHit * aNoiseHit,
BesMucHitsCollection * aMucHitList )

Definition at line 356 of file BesMucNoise.cc.

356 {
357 bool isExist = false;
358 G4int n_hit = aMucHitList->entries();
359 for ( G4int iNoise = 0; iNoise < n_hit; iNoise++ )
360 {
361 if ( aNoiseHit->GetTrackIndex() % 1000 ==
362 ( *aMucHitList )[iNoise]->GetTrackIndex() % 1000 &&
363 aNoiseHit->GetPart() == ( *aMucHitList )[iNoise]->GetPart() &&
364 aNoiseHit->GetSeg() == ( *aMucHitList )[iNoise]->GetSeg() &&
365 aNoiseHit->GetGap() == ( *aMucHitList )[iNoise]->GetGap() &&
366 aNoiseHit->GetStrip() == ( *aMucHitList )[iNoise]->GetStrip() )
367 {
368 isExist = true;
369 break;
370 }
371 }
372
373 return isExist;
374}

Referenced by NoiseByCnt(), and NoiseByNosRatio().

◆ IsExist() [2/3]

bool BesMucNoise::IsExist ( BesMucHit * aNoiseHit,
BesMucHitsCollection * aMucHitList )

◆ IsExist() [3/3]

bool BesMucNoise::IsExist ( BesMucHit * aNoiseHit,
BesMucHitsCollection * aMucHitList )

◆ IsNearestStrip() [1/3]

G4int BesMucNoise::IsNearestStrip ( G4int stripno,
G4int part,
G4int seg,
G4int gap,
G4float random )

Definition at line 477 of file BesMucNoise.cc.

478 {
479 if ( stripno == 1 ) { return 0; }
480 else
481 {
482 if ( area[part][seg][gap][stripno] != 0 )
483 {
484 // G4cout<<"--in noise::IsNearestStrip()-- "<<area[part][seg][gap][stripno]<<"
485 // "<<area[part][seg][gap][stripno-1]<<" "<<random<<G4endl;
486 if ( random <= area[part][seg][gap][stripno] &&
487 random > area[part][seg][gap][stripno - 1] )
488 return 0;
489 if ( random <= area[part][seg][gap][stripno - 1] ) return -1;
490 if ( random > area[part][seg][gap][stripno] ) return 1;
491 }
492 else { return -1; }
493 } // end else
494 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
495 exit( 1 );
496}

Referenced by GetStripNo().

◆ IsNearestStrip() [2/3]

G4int BesMucNoise::IsNearestStrip ( G4int ,
G4int ,
G4int ,
G4int ,
G4float  )

◆ IsNearestStrip() [3/3]

G4int BesMucNoise::IsNearestStrip ( G4int ,
G4int ,
G4int ,
G4int ,
G4float  )

◆ NoiseByCnt() [1/3]

G4int BesMucNoise::NoiseByCnt ( BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

Definition at line 242 of file BesMucNoise.cc.

243 {
244 G4int noiseNum = 0;
245 m_noiseLevel = m_ptrCalibSvc->getLevel();
246
247 for ( int i = 0; i < m_kPart; i++ )
248 {
249 for ( int j = 0; j < m_kSegment[i]; j++ )
250 {
251 for ( int k = 0; k < m_kGap[i]; k++ )
252 {
253 if ( m_noiseLevel == 2 )
254 {
255 G4int hitNum = NoiseSampling( m_noiseLevel, i, j, k, 0 );
256 for ( G4int ii = 0; ii < hitNum; ii++ )
257 {
258 G4int strip = GetStripNo( i, j, k );
259 BesMucHit* noiseHit = new BesMucHit( i, j, k, strip, -1, -1 );
260 BesMucHit* noiseHit2 = new BesMucHit( i, j, k, strip, -1, -1 );
261 bool noiseHitExist = false;
262 noiseHitExist = IsExist( noiseHit, MucHitList );
263 MucHitCollection->insert( noiseHit );
264 if ( !noiseHitExist )
265 {
266 MucHitList->insert( noiseHit2 );
267 noiseNum += 1;
268 // G4cout<<"-------insert------- "<<" "<<noiseHit2->GetStrip()<<" "<<i<<"
269 // "<<j<<" "<<k<<" "<<l<<"
270 // "<<m<<G4endl;
271 }
272 else delete noiseHit2;
273 } // hitNum
274 } // box level
275
276 if ( m_noiseLevel == 3 )
277 {
278 int stripNum = m_ptrIdTr->GetStripMax( i, j, k );
279 for ( int strip = 0; strip < stripNum; strip++ )
280 {
281 G4int hitNum = NoiseSampling( m_noiseLevel, i, j, k, strip );
282 if ( hitNum > 0 )
283 {
284 BesMucHit* noiseHit = new BesMucHit( i, j, k, strip, -1, -1 );
285 BesMucHit* noiseHit2 = new BesMucHit( i, j, k, strip, -1, -1 );
286 bool noiseHitExist = false;
287 noiseHitExist = IsExist( noiseHit, MucHitList );
288 MucHitCollection->insert( noiseHit );
289 if ( !noiseHitExist )
290 {
291 MucHitList->insert( noiseHit2 );
292 noiseNum += 1;
293 // G4cout<<"-------insert------- "<<" "<<noiseHit2->GetStrip()<<" "<<i<<"
294 // "<<j<<" "<<k<<" "<<l<<"
295 // "<<m<<G4endl;
296 }
297 else delete noiseHit2;
298 }
299 } // stripNum
300 } // strip level
301 } // part
302 } // segment
303 } // layer
304
305 return noiseNum;
306}
bool IsExist(BesMucHit *aNoiseHit, BesMucHitsCollection *aMucHitList)
G4int NoiseSampling(int level, int prt, int seg, int lay, int strip)
G4int GetStripNo(G4int, G4int, G4int)

Referenced by AddNoise().

◆ NoiseByCnt() [2/3]

G4int BesMucNoise::NoiseByCnt ( BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

◆ NoiseByCnt() [3/3]

G4int BesMucNoise::NoiseByCnt ( BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

◆ NoiseByNosRatio() [1/3]

G4int BesMucNoise::NoiseByNosRatio ( BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

Definition at line 308 of file BesMucNoise.cc.

309 {
310 G4int noiseNum = 0;
311 G4float random = 0;
312
313 // sample noise hit number;
314 random = G4UniformRand();
315 for ( int i = 0; i < 20; i++ )
316 {
317 if ( random < m_Prob[i][1] )
318 {
319 noiseNum = i;
320 break;
321 }
322 }
323 // G4cout << "Random for noiseNum:\t" << random << "\tProbSum:\t" << m_Prob[noiseNum][1] <<
324 // "\t" << noiseNum << G4endl;
325
326 int prt, seg, lay, str, tmp_strip;
327 G4float nosRatio = 0.;
328
329 for ( int i = 0; i < noiseNum; i++ )
330 {
331 do {
332 random = G4UniformRand();
333 tmp_strip = TMath::Nint( random * STRIP_MAX ); // 9152
334 m_ptrIdTr->SetStripPos( tmp_strip, &prt, &seg, &lay, &str );
335 nosRatio = m_ptrCalibSvc->getNosRatio( prt, seg, lay, str );
336 random = G4UniformRand();
337 if ( random < nosRatio ) break;
338 } while ( 1 );
339
340 // G4cout<<"Strip:\t"<<prt<<"\t"<<seg<<"\t"<<lay<<"\t"<<str<<"\t"<<random<<"
341 // "<<nosRatio<<G4endl;
342
343 BesMucHit* noiseHit = new BesMucHit( prt, seg, lay, str, -1, -1 );
344 BesMucHit* noiseHit2 = new BesMucHit( prt, seg, lay, str, -1, -1 );
345
346 bool noiseHitExist = false;
347 noiseHitExist = IsExist( noiseHit, MucHitList );
348 MucHitCollection->insert( noiseHit );
349 if ( !noiseHitExist ) MucHitList->insert( noiseHit2 );
350 else delete noiseHit2;
351 } // noiseNum;
352
353 return noiseNum;
354}
#define prt(n)
const int STRIP_MAX

Referenced by AddNoise().

◆ NoiseByNosRatio() [2/3]

G4int BesMucNoise::NoiseByNosRatio ( BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

◆ NoiseByNosRatio() [3/3]

G4int BesMucNoise::NoiseByNosRatio ( BesMucHitsCollection * MucHitCollection,
BesMucHitsCollection * MucHitList )

◆ NoiseSampling() [1/3]

G4int BesMucNoise::NoiseSampling ( int level,
int prt,
int seg,
int lay,
int strip )

Definition at line 376 of file BesMucNoise.cc.

376 {
377 G4int hitNum = 0;
378 G4double lambda;
379 // must get the time of this event
380 G4double t = 800; // 800ns temporary!
381 G4double e = 2.71828182845904590;
382
383 if ( level == 2 )
384 lambda = m_ptrCalibSvc->getBoxCnt( prt, seg, lay ) * box_area[prt][seg][lay] * 1E-2 *
385 1E-9; // 1E-2:mm2->cm2 1E-9:ns
386 else if ( level == 3 )
387 lambda = m_ptrCalibSvc->getStripCnt( prt, seg, lay, strip ) *
388 strip_area[prt][seg][lay][strip] * 1E-2 * 1E-9; // 1E-2:mm2->cm2 1E-9:ns
389 else lambda = 0.;
390
391 // sample noise hit number;
392 G4float random = G4UniformRand(); //***use other random
393 G4double prob = 0;
394 do {
395 prob = prob + pow( e, -lambda * t ) * pow( lambda * t, hitNum ) / Factorial( hitNum );
396 if ( random < prob ) break;
397 hitNum++;
398 } while ( 1 );
399
400 // G4cout<<" hitNum: "<<hitNum<<G4endl;
401 return hitNum;
402}
G4float Factorial(G4int i)
int t()
Definition t.c:1

Referenced by NoiseByCnt().

◆ NoiseSampling() [2/3]

G4int BesMucNoise::NoiseSampling ( int level,
int prt,
int seg,
int lay,
int strip )

◆ NoiseSampling() [3/3]

G4int BesMucNoise::NoiseSampling ( int level,
int prt,
int seg,
int lay,
int strip )

The documentation for this class was generated from the following files: