BOSS 7.0.2
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 *  evt)
virtual

Reimplemented from BesSensitiveDetector.

Definition at line 48 of file BesTofSD.cc.

48 {
49 m_event = evt->GetEventID();
50 m_besTofList = new BesTofHitsCollection( SensitiveDetectorName, collectionName[1] );
51 m_trackIndexes.clear();
52 m_trackIndex = -99;
53}
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 269 of file BesTofSD.cc.

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

◆ 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 55 of file BesTofSD.cc.

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

◆ 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 66 of file BesTofSD.cc.

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

◆ 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 279 of file BesTofSD.cc.

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

Referenced by ProcessHits().

◆ SampleNumberOfIonsAlongStep() [2/2]

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

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