BOSS 7.1.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 *)
 
- Public Member Functions inherited from BesSensitiveDetector
 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
 

Detailed Description

Definition at line 28 of file BesTofSD.hh.

Constructor & Destructor Documentation

◆ BesTofSD()

BesTofSD::BesTofSD ( G4String name)

Definition at line 37 of file BesTofSD.cc.

37 : BesSensitiveDetector(name), m_besTofList(0) {
38 collectionName.insert("BesTofHitsCollection");
39 collectionName.insert("BesTofHitsList");
40 elIonPair = new G4ElectronIonPair(1);
41
42 PropertyMgr m_propMgr;
43 m_propMgr.declareProperty("FanoFactor", m_fanoFactor = 0.2);
44 m_propMgr.declareProperty("nionOff", m_nionOff = 0.5);
45
46 IJobOptionsSvc* jobSvc;
47 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
48 jobSvc->setMyProperties("BesTofSD", &m_propMgr);
49
50 cout<<"BesTofSD Property:"<<endl
51 <<" FanoFactor= "<<m_fanoFactor
52 <<" nionOff= "<<m_nionOff
53 <<endl;
54}
BesSensitiveDetector(const G4String name)

◆ ~BesTofSD()

BesTofSD::~BesTofSD ( )
virtual

Definition at line 58 of file BesTofSD.cc.

58 {
59}

Member Function Documentation

◆ BeginOfTruthEvent()

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

Reimplemented from BesSensitiveDetector.

Definition at line 69 of file BesTofSD.cc.

69 {
70 m_event = evt->GetEventID();
71 m_besTofList = new BesTofHitsCollection( SensitiveDetectorName, collectionName[1] );
72 m_trackIndexes.clear();
73 m_trackIndex = -99;
74}
G4THitsCollection< BesTofHit > BesTofHitsCollection
Definition BesTofHit.hh:116

◆ EndOfEvent()

void BesTofSD::EndOfEvent ( G4HCofThisEvent * HCE)
virtual

Definition at line 290 of file BesTofSD.cc.

290 {
291 static G4int HCID=-1;
292 if( HCID<0 ) {
293 HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
294 }
295 HCE->AddHitsCollection(HCID,m_besTofCollection);
296}

◆ EndOfTruthEvent()

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

Reimplemented from BesSensitiveDetector.

Definition at line 76 of file BesTofSD.cc.

76 {
77 static G4int HLID=-1;
78 if( HLID<0 ) {
79 HLID = G4SDManager::GetSDMpointer()->GetCollectionID( collectionName[1] );
80 }
81 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
82 HCE->AddHitsCollection( HLID, m_besTofList );
83}

◆ Initialize()

void BesTofSD::Initialize ( G4HCofThisEvent * HCE)
virtual

Definition at line 63 of file BesTofSD.cc.

63 {
64 m_besTofCollection = new BesTofHitsCollection( SensitiveDetectorName, collectionName[0] );
65 //elIonPair = G4LossTableManager::Instance()->ElectronIonPair();
66}

◆ ProcessHits()

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

Definition at line 87 of file BesTofSD.cc.

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

◆ SampleNumberOfIonsAlongStep()

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

Definition at line 300 of file BesTofSD.cc.

300 {
301 G4double FanoFactor = m_fanoFactor; //0.2; //Is this value appropiate?
302 G4double meanion = eipair->MeanNumberOfIonsAlongStep(step);
303 G4double sig = std::sqrt(FanoFactor*meanion); //Be carefull : In originally Geant4 code this calculatin is wrong!
304 G4int nion = G4int(G4RandGauss::shoot(meanion,sig) + m_nionOff); //0.5);
305 return nion;
306}

Referenced by ProcessHits().


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