BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTofSD Class Reference

#include <BesTofSD.hh>

+ Inheritance diagram for BesTofSD:

Public Member Functions

 BesTofSD (G4String name)
 
virtual ~BesTofSD ()
 
virtual void Initialize (G4HCofThisEvent *HCE)
 
virtual G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *)
 
virtual void EndOfEvent (G4HCofThisEvent *HCE)
 
void BeginOfTruthEvent (const G4Event *)
 
void EndOfTruthEvent (const G4Event *)
 
G4int SampleNumberOfIonsAlongStep (const G4Step *, G4ElectronIonPair *)
 
 BesTofSD (G4String name)
 
virtual ~BesTofSD ()
 
virtual void Initialize (G4HCofThisEvent *HCE)
 
virtual G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *)
 
virtual void EndOfEvent (G4HCofThisEvent *HCE)
 
void BeginOfTruthEvent (const G4Event *)
 
void EndOfTruthEvent (const G4Event *)
 
G4int SampleNumberOfIonsAlongStep (const G4Step *, G4ElectronIonPair *)
 
- Public Member Functions inherited from BesSensitiveDetector
 BesSensitiveDetector (const G4String name)
 
virtual ~BesSensitiveDetector ()
 
virtual void BeginOfTruthEvent (const G4Event *)
 
virtual void EndOfTruthEvent (const G4Event *)
 
virtual void BeginOfTrack (const G4Track *)
 
virtual void EndOfTrack (const G4Track *)
 
 BesSensitiveDetector (const G4String name)
 
virtual ~BesSensitiveDetector ()
 
virtual void BeginOfTruthEvent (const G4Event *)
 
virtual void EndOfTruthEvent (const G4Event *)
 
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
 

Detailed Description

Constructor & Destructor Documentation

◆ BesTofSD() [1/2]

BesTofSD::BesTofSD ( G4String  name)

Definition at line 29 of file BesTofSD.cc.

29 : BesSensitiveDetector(name), m_besTofList(0) {
30 collectionName.insert("BesTofHitsCollection");
31 collectionName.insert("BesTofHitsList");
32 elIonPair = new G4ElectronIonPair();
33}

◆ ~BesTofSD() [1/2]

BesTofSD::~BesTofSD ( )
virtual

Definition at line 37 of file BesTofSD.cc.

37 {
38}

◆ BesTofSD() [2/2]

BesTofSD::BesTofSD ( G4String  name)

◆ ~BesTofSD() [2/2]

virtual BesTofSD::~BesTofSD ( )
virtual

Member Function Documentation

◆ BeginOfTruthEvent() [1/2]

void BesTofSD::BeginOfTruthEvent ( const G4Event *  )
virtual

Reimplemented from BesSensitiveDetector.

Definition at line 48 of file BesTofSD.cc.

48 {
49 m_besTofList = new BesTofHitsCollection( SensitiveDetectorName, collectionName[1] );
50 m_trackIndexes.clear();
51 m_trackIndex = -99;
52}
G4THitsCollection< BesTofHit > BesTofHitsCollection

◆ BeginOfTruthEvent() [2/2]

void BesTofSD::BeginOfTruthEvent ( const G4Event *  )
virtual

Reimplemented from BesSensitiveDetector.

◆ EndOfEvent() [1/2]

void BesTofSD::EndOfEvent ( G4HCofThisEvent *  HCE)
virtual

Definition at line 267 of file BesTofSD.cc.

267 {
268 static G4int HCID=-1;
269 if( HCID<0 ) {
270 HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
271 }
272 HCE->AddHitsCollection(HCID,m_besTofCollection);
273}

◆ EndOfEvent() [2/2]

virtual void BesTofSD::EndOfEvent ( G4HCofThisEvent *  HCE)
virtual

◆ EndOfTruthEvent() [1/2]

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

Reimplemented from BesSensitiveDetector.

Definition at line 54 of file BesTofSD.cc.

54 {
55 static G4int HLID=-1;
56 if( HLID<0 ) {
57 HLID = G4SDManager::GetSDMpointer()->GetCollectionID( collectionName[1] );
58 }
59 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
60 HCE->AddHitsCollection( HLID, m_besTofList );
61}

◆ EndOfTruthEvent() [2/2]

void BesTofSD::EndOfTruthEvent ( const G4Event *  )
virtual

Reimplemented from BesSensitiveDetector.

◆ Initialize() [1/2]

void BesTofSD::Initialize ( G4HCofThisEvent *  HCE)
virtual

Definition at line 42 of file BesTofSD.cc.

42 {
43 m_besTofCollection = new BesTofHitsCollection( SensitiveDetectorName, collectionName[0] );
44 //elIonPair = G4LossTableManager::Instance()->ElectronIonPair();
45}

◆ Initialize() [2/2]

virtual void BesTofSD::Initialize ( G4HCofThisEvent *  HCE)
virtual

◆ ProcessHits() [1/2]

G4bool BesTofSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *   
)
virtual

Definition at line 65 of file BesTofSD.cc.

65 {
66
67 G4double chg=aStep->GetTrack()->GetDefinition()->GetPDGCharge();
68 G4double edep = aStep->GetTotalEnergyDeposit();
69 G4double stepL=aStep->GetStepLength();
70 G4double deltaT=aStep->GetDeltaTime();
71 G4StepPoint* preStep = aStep->GetPreStepPoint();
72 G4ThreeVector pDirection=preStep->GetMomentumDirection();
73 G4String particleName = aStep->GetTrack()->GetDefinition()->GetParticleName();
74 G4Material* scinMaterial = aStep->GetTrack()->GetMaterial();
75 G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
76 G4int pdgcode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
77
78 if( chg==0 && edep==0 && stepL==0 ) { return false; }
79
80 BesTofHit *newHit = new BesTofHit();
81 G4int trackId = aStep->GetTrack()->GetTrackID();
82
83 newHit->SetTrackIndex(-99);
84 newHit->SetG4Index(aStep->GetTrack()->GetTrackID());
85 newHit->SetEdep(edep);
86 newHit->SetStepL(stepL);
87 //newHit->SetPName(particleName);
88 newHit->SetTrackL(aStep->GetTrack()->GetTrackLength());
89 G4ThreeVector pos=preStep->GetPosition();
90 newHit->SetPos(pos);
91 G4double globalTime=preStep->GetGlobalTime();
92 newHit->SetTime(globalTime);
93 newHit->SetDeltaT(deltaT);
94 newHit->SetPDirection(pDirection);
95 newHit->SetMomentum(preStep->GetMomentum());
96 //newHit->SetMaterial(scinMaterial);
97 newHit->SetCharge(charge);
98 newHit->SetPDGcode(pdgcode);
99
100 //Get local position in sensitive detector, add by anff
101 G4ThreeVector locPos(0,0,0);
102 G4TouchableHistory* theTouchable = (G4TouchableHistory*)( preStep->GetTouchable() );
103 //partId: barrel(1), east endcap(0), west endcap(2);
104 //scinNb: barrel(0-175),east endcap(0-47), west endcap(0-47)
105 //partId: mrpc: east(3), west(4),
106
107 G4String name;
108 //for(G4int i=0; i<theTouchable->GetHistoryDepth(); i++)
109 //{
110 // name = theTouchable->GetVolume(i)->GetName();
111 // G4cout<<"********* name of the "<<i<<" volume: "<<name<<" ***************"<<G4endl;
112 //}
113 name = theTouchable->GetVolume(0)->GetName();
114
115 G4int partId=-1, scinNb=-1, gapNb=-1, number=-1;
116 G4int strip = -1;
117 gapNb = theTouchable->GetReplicaNumber(0);
118 number = theTouchable->GetReplicaNumber(2); //This is valid only for scintillator
119
120 //MRPC ENDCAPS construct by geant4 code
121 if(name.contains("physical_gasLayer"))
122 {
123 locPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint(pos);
124 number = theTouchable->GetReplicaNumber(3);
125 scinNb = number;
126
127 G4String name1 = theTouchable->GetVolume(4)->GetName();
128 if(name1 == "physicalEcTofEast") partId=3;
129 else if(name1 == "physicalEcTofWest") partId=4;
130 //G4cout<<"scinNb= "<<scinNb<<" gapNb= "<<gapNb<<" partId="<<partId<<G4endl;
131 }
132 //MRPC ENDCAPS construct by GDML
133 else if(name=="logical_gasLayer")
134 {
135 locPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint(pos);
136 number = theTouchable->GetReplicaNumber(3);
137 scinNb = 35-number;
138
139 G4String name1 = theTouchable->GetVolume(4)->GetName();
140 if(name1 == "logicalEcTofEast") partId=3;
141 else if(name1 == "logicalEcTofWest") partId=4;
142 //G4cout<<"scinNb= "<<scinNb<<" gapNb= "<<gapNb<<" partId="<<partId<<G4endl;
143 }
144
145
146 // Scintillator
147 else if( name=="physicalScinBr1" ) {
148 partId = 1;
149 scinNb = number;
150 //G4cout<<"scinNb= "<<scinNb<<" partId="<<partId<<G4endl;
151 }
152 else if( name=="physicalScinBr2" ) {
153 partId = 1;
154 scinNb = number+88;
155 //G4cout<<"scinNb= "<<scinNb<<" partId="<<partId<<G4endl;
156 }
157 else if( name=="physicalScinEcWest" ) {
158 partId = 2;
159 scinNb = number;
160 //G4cout<<"scinNb= "<<scinNb<<" partId="<<partId<<G4endl;
161 }
162 else if( name=="physicalScinEcEast" ) {
163 partId = 0;
164 scinNb = number;
165 //G4cout<<"scinNb= "<<scinNb<<" partId="<<partId<<G4endl;
166 }
167
168
169 //if construct by gdml files
170 else if( name=="logicalScinBr1" || name=="logicalScinBr2" ) {
171 partId = 1;
172 scinNb = (527-number)/3;
173 }
174 //copy number: east:1-95(scinNb:47-0), west:1-95(scinNb:47-0)
175 else if( name=="logicalScinEcEast" ) {
176 partId = 0;
177 scinNb = (95-number)/2;
178 }
179 else if( name=="logicalScinEcWest" ) {
180 partId = 2;
181 scinNb = (95-number)/2;
182 }
183 else { return false; }
184
185
186 if(name.contains("physical_gasLayer") || name.contains("logical_gasLayer"))
187 {
188 G4double zz = locPos.z()-0.5*mm+(24+3)*mm*6; //0.5mm is the offset between strip and gasLayer
189 if(zz<=0)
190 {
191 strip=0;
192 }
193 else if(zz>0 && zz<12*27*mm)
194 {
195 for(G4int i=0; i<12; i++)
196 {
197 if(zz>i*27*mm && zz<=(i+1)*27*mm)
198 {
199 strip = i;
200 //G4cout<<"Local z is "<<locPos.z()<<" strip number is: "<<strip<<" !!!"<<G4endl;
201 break;
202 }
203 }
204 }
205 else
206 {
207 strip=11;
208 }
209 if(strip<0) strip=0;
210 if(strip>11) strip=11;
211 }
212
213
214 newHit->SetPartId(partId);
215 newHit->SetScinNb(scinNb);
216 newHit->SetGapNb(gapNb);
217 newHit->SetLocPos(locPos);
218 newHit->SetModule(scinNb);
219 newHit->SetStrip(strip);
220 //newHit->SetIons(elIonPair->SampleNumberOfIonsAlongStep(aStep));
221 newHit->SetIons(SampleNumberOfIonsAlongStep(aStep,elIonPair));
222 //newHit->Draw();
223
224 G4int trackIndex, g4TrackId;
225 GetCurrentTrackIndex( trackIndex, g4TrackId );
226 newHit->SetTrackIndex( trackIndex );
227 //newHit->Print();
228 if( edep>0 ) {
229 m_besTofCollection->insert( newHit );
230 }
231
232 //for mc truth
233 if( m_besTofList ) {
234 G4int trackIndex, g4TrackId;
235 GetCurrentTrackIndex(trackIndex, g4TrackId);
236 newHit->SetTrackIndex(trackIndex);
237 if( m_trackIndex != trackIndex ) {
238 m_trackIndex = trackIndex;
239 //G4int size = m_trackIndexes.size();
240 //G4int flag=1;
241 //if(size>0)
242 //{
243 // for(G4int i=0;i<size;i++)
244 // if(m_trackIndexes[i] == trackIndex )
245 // {flag =0; break;}
246 //}
247 //if(flag && aStep->GetTrack()->GetTrackID()==g4TrackId )
248 G4int flag = 1;
249 G4int pdg = abs(aStep->GetTrack()->GetDefinition()->GetPDGEncoding());
250 if( pdg==12 || pdg==14 || pdg==16 ) { flag=0; }
251 if( flag && aStep->GetTrack()->GetTrackID()==g4TrackId ) {
252 m_trackIndexes.push_back(trackIndex);
253 BesTofHit* truHit = new BesTofHit();
254 *truHit = *newHit;
255 m_besTofList->insert(truHit);
256 }
257 }
258 }
259 if( edep<=0 ) { delete newHit; }
260
261 return true;
262
263}//Close Process Hits
void GetCurrentTrackIndex(G4int &trackIndex, G4int &g4TrackId) const
void SetPDirection(G4ThreeVector pDirection)
void SetLocPos(G4ThreeVector locPos)
void SetMomentum(G4ThreeVector momentum)
G4int SampleNumberOfIonsAlongStep(const G4Step *, G4ElectronIonPair *)
Definition: BesTofSD.cc:277

◆ ProcessHits() [2/2]

virtual G4bool BesTofSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *   
)
virtual

◆ SampleNumberOfIonsAlongStep() [1/2]

G4int BesTofSD::SampleNumberOfIonsAlongStep ( const G4Step *  step,
G4ElectronIonPair *  eipair 
)

Definition at line 277 of file BesTofSD.cc.

277 {
278 G4double FanoFactor = 0.2; //Is this value appropiate?
279 G4double meanion = eipair->MeanNumberOfIonsAlongStep(step);
280 G4double sig = std::sqrt(FanoFactor*meanion); //Be carefull : In originally Geant4 code this calculatin is wrong!
281 G4int nion = G4int(G4RandGauss::shoot(meanion,sig) + 0.5);
282 return nion;
283}

Referenced by ProcessHits().

◆ SampleNumberOfIonsAlongStep() [2/2]

G4int BesTofSD::SampleNumberOfIonsAlongStep ( const G4Step *  ,
G4ElectronIonPair *   
)

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