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

#include <BesMucSD.hh>

Inheritance diagram for BesMucSD:

Public Member Functions

 BesMucSD (G4String, BesMucConstruction *)
 ~BesMucSD ()
void Initialize (G4HCofThisEvent *)
G4bool ProcessHits (G4Step *, G4TouchableHistory *)
void EndOfEvent (G4HCofThisEvent *)
void BeginOfTruthEvent (const G4Event *)
void EndOfTruthEvent (const G4Event *)
 BesMucSD (G4String, BesMucConstruction *)
 ~BesMucSD ()
void Initialize (G4HCofThisEvent *)
G4bool ProcessHits (G4Step *, G4TouchableHistory *)
void EndOfEvent (G4HCofThisEvent *)
void BeginOfTruthEvent (const G4Event *)
void EndOfTruthEvent (const G4Event *)
 BesMucSD (G4String, BesMucConstruction *)
 ~BesMucSD ()
void Initialize (G4HCofThisEvent *)
G4bool ProcessHits (G4Step *, G4TouchableHistory *)
void EndOfEvent (G4HCofThisEvent *)
void BeginOfTruthEvent (const G4Event *)
void EndOfTruthEvent (const G4Event *)
Public Member Functions inherited from BesSensitiveDetector
 BesSensitiveDetector (const G4String name)
virtual ~BesSensitiveDetector ()
virtual void BeginOfTrack (const G4Track *)
virtual void EndOfTrack (const G4Track *)
 BesSensitiveDetector (const G4String name)
virtual ~BesSensitiveDetector ()
virtual void BeginOfTrack (const G4Track *)
virtual void EndOfTrack (const G4Track *)
 BesSensitiveDetector (const G4String name)
virtual ~BesSensitiveDetector ()
virtual void BeginOfTrack (const G4Track *)
virtual void EndOfTrack (const G4Track *)

Additional Inherited Members

Protected Member Functions inherited from BesSensitiveDetector
void GetCurrentTrackIndex (G4int &trackIndex, G4int &g4TrackId) const
void GetCurrentTrackIndex (G4int &trackIndex, G4int &g4TrackId) const
void GetCurrentTrackIndex (G4int &trackIndex, G4int &g4TrackId) const

Detailed Description

Constructor & Destructor Documentation

◆ BesMucSD() [1/3]

BesMucSD::BesMucSD ( G4String name,
BesMucConstruction * Det )

Definition at line 41 of file BesMucSD.cc.

42 : BesSensitiveDetector( name ), detector( Det ) {
43 collectionName.insert( "BesMucHitsCollection" );
44 collectionName.insert( "BesMucHitsList" );
45 HitID = new G4int[500];
46
47 // liangyt 2006.3.1 initialize muc-efficiency;
48 G4String GeometryPath = ReadBoostRoot::GetBoostRoot();
49 G4String GeometryPath2 = GeometryPath;
50 if ( !GeometryPath )
51 {
52 G4cout << "BOOST environment not set!" << G4endl;
53 exit( -1 );
54 }
55 GeometryPath += "/dat/muc-effi.dat";
56 GeometryPath2 += "/dat/muc-noise.dat";
57
59 // m_effi->Initialize(GeometryPath);
60
61 // retrieve G4Svc
62 ISvcLocator* svcLocator = Gaudi::svcLocator();
63 IG4Svc* iG4Svc;
64 StatusCode sc = svcLocator->service( "G4Svc", iG4Svc );
65 // m_G4Svc = dynamic_cast<G4Svc *>(iG4Svc);
66 m_G4Svc = iG4Svc;
67 m_noiseMode = m_G4Svc->MucNoiseMode();
68 G4cout << "MucNoiseMode:\t" << m_noiseMode << G4endl;
69
70 if ( m_noiseMode != 0 )
71 {
72 m_noise = BesMucNoise::Instance();
73 G4LogicalVolume* logicalMuc = detector->GetPhysicalMuc()->GetLogicalVolume();
74 m_noise->Initialize( GeometryPath2, logicalMuc );
75 // m_noise->Initialize(GeometryPath2,logicalMuc,"ROOT");
76 }
77
78 m_PreviousPrimaryTrackG4Id = 0;
79 m_CurEvent = 0;
80 m_TrackCon = 0;
81}
static BesMucEfficiency * Instance(void)
static BesMucNoise * Instance(void)
BesSensitiveDetector(const G4String name)
virtual int MucNoiseMode()=0

◆ ~BesMucSD() [1/3]

BesMucSD::~BesMucSD ( )

Definition at line 83 of file BesMucSD.cc.

83{ delete[] HitID; }

◆ BesMucSD() [2/3]

BesMucSD::BesMucSD ( G4String ,
BesMucConstruction *  )

◆ ~BesMucSD() [2/3]

BesMucSD::~BesMucSD ( )

◆ BesMucSD() [3/3]

BesMucSD::BesMucSD ( G4String ,
BesMucConstruction *  )

◆ ~BesMucSD() [3/3]

BesMucSD::~BesMucSD ( )

Member Function Documentation

◆ BeginOfTruthEvent() [1/3]

void BesMucSD::BeginOfTruthEvent ( const G4Event * )
virtual

Reimplemented from BesSensitiveDetector.

Definition at line 93 of file BesMucSD.cc.

93 {
94 MucHitList = new BesMucHitsCollection( SensitiveDetectorName, collectionName[1] );
95 m_trackIndex = -99;
96 m_trackIndexes.clear();
97 m_prePart = -99;
98 m_preSeg = -99;
99 m_preGap = -99;
100 m_preStrip = -99;
101 // G4cout<<"---in BesMucSD::BeginOfTruthEvent()---"<<MucHitCollection->entries()<<"
102 // "<<MucHitList->entries()<<G4endl;
103
104 // add oise
105 if ( m_noiseMode != 0 )
106 m_noise->AddNoise( m_noiseMode, MucHitCollection, MucHitList ); // commen out 2006.10.21
107}
G4THitsCollection< BesMucHit > BesMucHitsCollection

◆ BeginOfTruthEvent() [2/3]

void BesMucSD::BeginOfTruthEvent ( const G4Event * )
virtual

Reimplemented from BesSensitiveDetector.

◆ BeginOfTruthEvent() [3/3]

void BesMucSD::BeginOfTruthEvent ( const G4Event * )
virtual

Reimplemented from BesSensitiveDetector.

◆ EndOfEvent() [1/3]

void BesMucSD::EndOfEvent ( G4HCofThisEvent * HCE)

Definition at line 375 of file BesMucSD.cc.

375 {
376 static G4int HCID = -1;
377 if ( HCID < 0 )
378 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID( collectionName[0] ); }
379 HCE->AddHitsCollection( HCID, MucHitCollection );
380}

◆ EndOfEvent() [2/3]

void BesMucSD::EndOfEvent ( G4HCofThisEvent * )

◆ EndOfEvent() [3/3]

void BesMucSD::EndOfEvent ( G4HCofThisEvent * )

◆ EndOfTruthEvent() [1/3]

void BesMucSD::EndOfTruthEvent ( const G4Event * evt)
virtual

Reimplemented from BesSensitiveDetector.

Definition at line 109 of file BesMucSD.cc.

109 {
110 static G4int HLID = -1;
111 if ( HLID < 0 ) HLID = G4SDManager::GetSDMpointer()->GetCollectionID( collectionName[1] );
112 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
113 HCE->AddHitsCollection( HLID, MucHitList );
114}

◆ EndOfTruthEvent() [2/3]

void BesMucSD::EndOfTruthEvent ( const G4Event * )
virtual

Reimplemented from BesSensitiveDetector.

◆ EndOfTruthEvent() [3/3]

void BesMucSD::EndOfTruthEvent ( const G4Event * )
virtual

Reimplemented from BesSensitiveDetector.

◆ Initialize() [1/3]

void BesMucSD::Initialize ( G4HCofThisEvent * )

Definition at line 85 of file BesMucSD.cc.

85 {
86 MucHitCollection = new BesMucHitsCollection( SensitiveDetectorName, collectionName[0] );
87 // for (G4int j=0;j<detector->GetBesMucNbOfTraps();j++) {HitID[j] = -1;};
88 TotEneDeposit = 0;
89 // G4cout<<"----------in SD::Init()---
90 // "<<detector->GetPhysicalMuc()->GetLogicalVolume()->GetName()<<G4endl;
91}

◆ Initialize() [2/3]

void BesMucSD::Initialize ( G4HCofThisEvent * )

◆ Initialize() [3/3]

void BesMucSD::Initialize ( G4HCofThisEvent * )

◆ ProcessHits() [1/3]

G4bool BesMucSD::ProcessHits ( G4Step * aStep,
G4TouchableHistory *  )

Definition at line 116 of file BesMucSD.cc.

116 {
117 G4Track* curTrack = aStep->GetTrack();
118
119 m_CurEvent = G4EventManager::GetEventManager()->GetConstCurrentEvent();
120 // if(m_CurEvent->GetEventID()<19565)return true; // ---del
121 if ( m_CurEvent )
122 {
123 m_TrackCon = m_CurEvent->GetTrajectoryContainer();
124
125 // if (!m_TrackCon) G4cout << "m_TrackCon does not exist " << G4endl;
126 // else {
127 // G4cout << "m_TrackCon size " << m_TrackCon->size() << G4endl;
128 // for (int i = 0; i < (int)m_TrackCon->size(); i++) {
129 // G4cout << "track " << i << " g4TrackId " << (*m_TrackCon)[i]->GetTrackID() << " parent
130 // ID " <<
131 // (*m_TrackCon)[i]->GetParentID() << G4endl;
132 // }
133 // }
134 }
135
136 if ( curTrack->GetDefinition()->GetPDGCharge() == 0. ) return false;
137
138 G4double edep = aStep->GetTotalEnergyDeposit();
139 // if(edep == 0.) return false;
140
141 // TotEneDeposit+=edep;
142 G4int trackIndex = -99, g4TrackId = -99;
143 GetCurrentTrackIndex( trackIndex, g4TrackId );
144
145 G4TouchableHistory* theTouchable =
146 (G4TouchableHistory*)( aStep->GetPreStepPoint()->GetTouchable() );
147
148 BesMucHit* newHit = new BesMucHit();
149
150 G4int trackID = curTrack->GetTrackID(); // G4 track ID of current track.
151 G4int parentID = curTrack->GetParentID(); // G4 track ID of parent track.
152 newHit->SetTrackID( trackID );
153 newHit->SetTrackIndex( trackIndex ); // MC truth track index
154
155 G4int pdg = curTrack->GetDefinition()->GetPDGEncoding();
156 newHit->SetPDGCode( pdg );
157
158 newHit->SetEdep( edep );
159
160 G4ThreeVector pos = 0.5 * ( aStep->GetPostStepPoint()->GetPosition() +
161 aStep->GetPreStepPoint()->GetPosition() );
162 newHit->SetPos( pos );
163
164 G4ThreeVector posInGas = theTouchable->GetHistory()->GetTopTransform().TransformPoint( pos );
165 G4int stackDepth = theTouchable->GetHistory()->GetDepth();
166 G4ThreeVector posInBox =
167 theTouchable->GetHistory()->GetTransform( stackDepth - 1 ).TransformPoint( pos );
168 newHit->SetPosLocal( posInBox );
169
170 G4ThreeVector posInGap =
171 theTouchable->GetHistory()->GetTransform( stackDepth - 2 ).TransformPoint( pos );
172 // cout<<" pos "<<pos.x()<<" "<<pos.y()<<" "<<pos.z()<<"depth= "<<stackDepth<<endl
173 // <<" posInBox(3)"<<posInBox.x()<<" "<<posInBox.y()<<" "<<posInBox.z()<<endl
174 // <<" posInGap(2)"<<posInGap.x()<<" "<<posInGap.y()<<" "<<posInGap.z()<<endl;
175
176 G4double energy = aStep->GetPreStepPoint()->GetKineticEnergy();
177 newHit->SetEnergy( energy );
178
179 G4ThreeVector dir = aStep->GetPreStepPoint()->GetMomentumDirection();
180 newHit->SetDir( dir );
181
182 G4ThreeVector momentum = aStep->GetPreStepPoint()->GetMomentum();
183 newHit->SetMomentum( momentum );
184
185 G4double GlobalTime = aStep->GetPostStepPoint()->GetGlobalTime();
186 newHit->SetTime( GlobalTime );
187
188 G4VPhysicalVolume* vl = theTouchable->GetVolume( 0 );
189 newHit->SetVolume( vl );
190
191 // G4cout<<"in SD "<<newHit->GetPart()<<" "<<newHit->GetSeg()<<" "<<newHit->GetGap()<<"
192 // "<<newHit->GetGasChamber()<<"
193 // "<<newHit->GetPanel()<<endl;
194
195 newHit->Draw();
196 // newHit->Print();
197 // MucHitCollection->insert(newHit);
198 m_PreviousPrimaryTrackG4Id = g4TrackId;
199
200 //-----------add by liangyt for efficiency
201
202 // for MC Truth
203 if ( MucHitList )
204 {
205
206 // cout <<"g4TrackId " << g4TrackId << " trackID " << trackID << " parentID " << parentID
207 // << "trackIndex " << trackIndex
208 // << endl; g4TrackId: G4 track ID of previous primary track in trackList, trackID: G4
209 // track ID of current track. parentID: G4 track ID of parent track of current track.
210 // trackIndex: track ID in MC truth
211
212 // no longer necessary to find the track's ancestor primary track,
213 // it is kept in trackIndex untill next primary track generated. So IsChildof is uncessary
214 // if ( g4TrackId == trackID ) { //|| IsChildOf(curTrack, g4TrackId) ) { // This track
215 // is the primary track & will appear in MC truth
216 G4int newTrackFlag = 0;
217 newHit->SetTrackIndex( trackIndex );
218 if ( m_trackIndex != trackIndex )
219 {
220 m_trackIndex = trackIndex;
221 G4int size = m_trackIndexes.size();
222 newTrackFlag = 1;
223 if ( size > 0 )
224 {
225 for ( G4int i = 0; i < size; i++ )
226 if ( m_trackIndexes[i] == trackIndex )
227 {
228 newTrackFlag = 0;
229 break;
230 }
231 }
232 }
233
234 if ( newTrackFlag )
235 {
236 m_trackIndexes.push_back( trackIndex );
237 m_prePart = -99;
238 m_preSeg = -99;
239 m_preGap = -99;
240 m_preStrip = -99;
241 }
242 BesMucHit* truHit = new BesMucHit();
243 *truHit = *newHit;
244 if ( g4TrackId != trackID )
245 {
246 // trackIndex += 1000; // a sencondary track
247 trackIndex += 0; // 2006.12.22 do not indicate secondary track now
248 truHit->SetTrackIndex( trackIndex );
249 }
250 // cout << "trackIndex " << trackIndex << endl;
251
252 BesMucDigit aDigit;
253 aDigit.SetHit( truHit );
254 G4int curPart, curSeg, curGap, curStrip;
255 curPart = aDigit.GetPart();
256 curSeg = aDigit.GetSeg();
257 curGap = aDigit.GetGap();
258 curStrip = aDigit.GetNearestStripNo();
259
260 m_effi->CheckCalibSvc();
261 m_effi->SetHit( truHit );
262 G4double need_eff = m_effi->GetEfficiency();
263
264 // G4cout<<"in SD effi= "<<need_eff<<endl;
265 // need_eff = 1.0; //2006.12.28
266 if ( curPart == m_prePart && curSeg == m_preSeg && curGap == m_preGap &&
267 curStrip == m_preStrip )
268 {
269 // cout<<MucHitList->entries()<<" "<<MucHitCollection->entries()<<"
270 // "<<need_eff<<"---if----curPart "<<curPart<<"curSeg
271 // "<<curSeg<<"curGap "<<curGap<<"curStrip "<<curStrip<<" momentum "<<momentum.x()<<"
272 // "<<momentum.y()<<"
273 // "<<momentum.z()<<" "<<endl;
274 delete truHit;
275 delete newHit;
276 }
277 else
278 {
279 // cout<<MucHitList->entries()<<"----else--Part "<<curPart<<" Seg "<<curSeg<<" Gap
280 // "<<curGap<<" Strip
281 // "<<curStrip<<endl;
282 truHit->SetPart( curPart );
283 truHit->SetSeg( curSeg );
284 truHit->SetGap( curGap );
285 truHit->SetStrip( curStrip );
286
287 // if a truHit with the same id(part, seg, gap, strip) and trackIndex(%1000) exist,
288 // they belong to the same primary track,(maybe one is primary, the other is secondary),
289 // dont add.
290 bool truHitExist = false;
291 G4int n_hit = MucHitList->entries();
292 for ( G4int iTru = 0; iTru < n_hit; iTru++ )
293 {
294 BesMucHit* aTruHit = ( *MucHitList )[iTru];
295 if ( aTruHit->GetTrackIndex() % 1000 == truHit->GetTrackIndex() % 1000 &&
296 aTruHit->GetPart() == truHit->GetPart() &&
297 aTruHit->GetSeg() == truHit->GetSeg() && aTruHit->GetGap() == truHit->GetGap() &&
298 aTruHit->GetStrip() == truHit->GetStrip() )
299 {
300 truHitExist = true;
301 break;
302 }
303 }
304 G4float random = G4UniformRand(); //*** use other random
305 // G4float random=(rand()%100000)/100000.0;
306 // G4cout<<"---in SD---"<<random<<endl;
307 if ( random <= need_eff ) { MucHitCollection->insert( newHit ); }
308 else delete newHit;
309 if ( !truHitExist && random <= need_eff ) { MucHitList->insert( truHit ); }
310 else delete truHit;
311 m_prePart = curPart;
312 m_preSeg = curSeg;
313 m_preGap = curGap;
314 m_preStrip = curStrip;
315 }
316 //}
317 }
318
319 return true;
320}
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon energy
Definition KK2f.h:50
G4int GetNearestStripNo()
void SetHit(BesMucHit *hit)
void SetVolume(G4VPhysicalVolume *pv)
Definition BesMucHit.cc:86
void Draw()
Definition BesMucHit.cc:131
void GetCurrentTrackIndex(G4int &trackIndex, G4int &g4TrackId) const

◆ ProcessHits() [2/3]

G4bool BesMucSD::ProcessHits ( G4Step * ,
G4TouchableHistory *  )

◆ ProcessHits() [3/3]

G4bool BesMucSD::ProcessHits ( G4Step * ,
G4TouchableHistory *  )

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