ATLAS Offline Software
Loading...
Searching...
No Matches
AFP_SiDSensitiveDetector Class Reference

#include <AFP_SiDSensitiveDetector.h>

Inheritance diagram for AFP_SiDSensitiveDetector:
Collaboration diagram for AFP_SiDSensitiveDetector:

Public Member Functions

 AFP_SiDSensitiveDetector (const std::string &name, const std::string &hitCollectionName)
 ~AFP_SiDSensitiveDetector ()
void StartOfAthenaEvent ()
void Initialize (G4HCofThisEvent *) override final
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override final
void EndOfAthenaEvent ()
template<class... Args>
void AddHit (Args &&... args)
 Templated method to stuff a single hit into the sensitive detector class.

Static Public Attributes

static constexpr int SiDMaxCnt = 1000

Private Member Functions

 FRIEND_TEST (AFP_SiDSensitiveDetectortest, Initialize)
 FRIEND_TEST (AFP_SiDSensitiveDetectortest, ProcessHits)
 FRIEND_TEST (AFP_SiDSensitiveDetectortest, StartOfAthenaEvent)
 FRIEND_TEST (AFP_SiDSensitiveDetectortest, EndOfAthenaEvent)
 FRIEND_TEST (AFP_SiDSensitiveDetectortest, AddHit)

Private Attributes

int m_nHitID
int m_nEventNumber
int m_nNumberOfSIDSimHits
int m_nNOfSIDSimHits [4]
float m_delta_pixel_x
float m_delta_pixel_y
float m_death_edge [4][10]
float m_lower_edge [4][10]
SG::WriteHandle< AFP_SIDSimHitCollectionm_HitColl

Detailed Description

Definition at line 22 of file AFP_SiDSensitiveDetector.h.

Constructor & Destructor Documentation

◆ AFP_SiDSensitiveDetector()

AFP_SiDSensitiveDetector::AFP_SiDSensitiveDetector ( const std::string & name,
const std::string & hitCollectionName )

Definition at line 31 of file AFP_SiDSensitiveDetector.cxx.

32 : G4VSensitiveDetector( name )
33 , m_nHitID(-1)
36 , m_delta_pixel_x(0.050)
37 , m_delta_pixel_y(0.250)
38 , m_HitColl(hitCollectionName)
39{
40 for( int i=0; i < 4; i++){
42 for( int j=0; j < 10; j++){
43 m_death_edge[i][j] = AFP_CONSTANTS::SiT_DeathEdge; //in mm, it is left edge as the movement is horizontal
45 }
46 }
47}
SG::WriteHandle< AFP_SIDSimHitCollection > m_HitColl
static constexpr double SiT_LowerEdge
static constexpr double SiT_DeathEdge

◆ ~AFP_SiDSensitiveDetector()

AFP_SiDSensitiveDetector::~AFP_SiDSensitiveDetector ( )
inline

Definition at line 35 of file AFP_SiDSensitiveDetector.h.

35{ /* I don't own myHitColl if all has gone well */ }

Member Function Documentation

◆ AddHit()

template<class... Args>
void AFP_SiDSensitiveDetector::AddHit ( Args &&... args)
inline

Templated method to stuff a single hit into the sensitive detector class.

This could get rather tricky, but the idea is to allow fast simulations to use the very same SD classes as the standard simulation.

Definition at line 48 of file AFP_SiDSensitiveDetector.h.

◆ EndOfAthenaEvent()

void AFP_SiDSensitiveDetector::EndOfAthenaEvent ( )

Definition at line 535 of file AFP_SiDSensitiveDetector.cxx.

536{
537 if(verboseLevel>5)
538 {
539 G4cout << "AFP_SiDSensitiveDetector::EndOfAthenaEvent: Total number of hits in SiD: " << m_nNumberOfSIDSimHits << G4endl;
540 G4cout << "AFP_SiDSensitiveDetector::EndOfAthenaEvent: *************************************************************" << G4endl;
541 }
544
545 for( int i=0; i < 4; i++){
546 m_nNOfSIDSimHits[i] = 0;
547 }
548}

◆ FRIEND_TEST() [1/5]

AFP_SiDSensitiveDetector::FRIEND_TEST ( AFP_SiDSensitiveDetectortest ,
AddHit  )
private

◆ FRIEND_TEST() [2/5]

AFP_SiDSensitiveDetector::FRIEND_TEST ( AFP_SiDSensitiveDetectortest ,
EndOfAthenaEvent  )
private

◆ FRIEND_TEST() [3/5]

AFP_SiDSensitiveDetector::FRIEND_TEST ( AFP_SiDSensitiveDetectortest ,
Initialize  )
private

◆ FRIEND_TEST() [4/5]

AFP_SiDSensitiveDetector::FRIEND_TEST ( AFP_SiDSensitiveDetectortest ,
ProcessHits  )
private

◆ FRIEND_TEST() [5/5]

AFP_SiDSensitiveDetector::FRIEND_TEST ( AFP_SiDSensitiveDetectortest ,
StartOfAthenaEvent  )
private

◆ Initialize()

void AFP_SiDSensitiveDetector::Initialize ( G4HCofThisEvent * )
finaloverride

Definition at line 62 of file AFP_SiDSensitiveDetector.cxx.

63{
64 if (!m_HitColl.isValid())m_HitColl = std::make_unique<AFP_SIDSimHitCollection>();
65}

◆ ProcessHits()

bool AFP_SiDSensitiveDetector::ProcessHits ( G4Step * pStep,
G4TouchableHistory *  )
finaloverride

Definition at line 69 of file AFP_SiDSensitiveDetector.cxx.

70{
71 if(verboseLevel>5)
72 {
73 G4cout << "AFP_SiDSensitiveDetector::ProcessHits" << G4endl;
74 }
75
76 int nTrackID=-1;
77 int nParticleEncoding=-1;
78 float fKineticEnergy=0.0;
79 float fEnergyDeposit=0.0;
80 float fPreStepX=0.0;
81 float fPreStepY=0.0;
82 float fPreStepZ=0.0;
83 float fPostStepX=0.0;
84 float fPostStepY=0.0;
85 float fPostStepZ=0.0;
86 float fGlobalTime=0.0;
87 int nStationID=-1;
88 int nDetectorID=-1;
89 // int nPixelRow=-1;
90 // int nPixelCol=-1;
91
92 bool bIsSIDAuxVSID=false;
93
94 // step, track and particle info
95 G4Track* pTrack = pStep->GetTrack();
96 G4ParticleDefinition* pParticleDefinition = pTrack->GetDefinition();
97 G4StepPoint* pPreStepPoint = pStep->GetPreStepPoint();
98 G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
99 G4ThreeVector PreStepPointPos = pPreStepPoint->GetPosition();
100 G4ThreeVector PostStepPointPos = pPostStepPoint->GetPosition();
101
102 nTrackID=pTrack->GetTrackID();
103 fKineticEnergy = pPreStepPoint->GetKineticEnergy();
104 fEnergyDeposit = pStep->GetTotalEnergyDeposit();
105
106 fPreStepX = PreStepPointPos.x();
107 fPreStepY = PreStepPointPos.y();
108 fPreStepZ = PreStepPointPos.z();
109 fPostStepX = PostStepPointPos.x();
110 fPostStepY = PostStepPointPos.y();
111 fPostStepZ = PostStepPointPos.z();
112 nParticleEncoding = pParticleDefinition->GetPDGEncoding();
113 fGlobalTime = pStep->GetPreStepPoint()->GetGlobalTime()/CLHEP::picosecond; // time w.r.t. prestep or poststep ??
114
115 // name of physical volume
116 G4TouchableHandle touch1 = pPreStepPoint->GetTouchableHandle();
117 G4VPhysicalVolume* volume = touch1->GetVolume();
118 G4String VolumeName = volume->GetName();
119
120 //G4ThreeVector ph0 = pStep->GetDeltaPosition().unit();
121 //if (fKineticEnergy<10000. && ph0.y()>.2) pTrack->SetTrackStatus(fKillTrackAndSecondaries);
122 //if (VolumeName.contains("TDQuarticBar")) return 1;
123
124 if(verboseLevel>5)
125 {
126 G4cout << "hit volume name is " << VolumeName << G4endl;
127
128 G4cout << "global, x_pre: " << fPreStepX << ", y_pre: " << fPreStepY << ", z_pre: " << fPreStepZ << G4endl;
129 G4cout << "global, x_post: " << fPostStepX << ", y_post: " << fPostStepY << ", z_post: " << fPostStepZ << G4endl;
130 }
131 //scan station and detector id
132 char* ppv1, *ppv2;
133 char szbuff[32];
134 memset(&szbuff[0],0,sizeof(szbuff));
135 strncpy(szbuff,VolumeName.data(),sizeof(szbuff));
136 szbuff[sizeof(szbuff)-1] = '\0'; // idiomatic use of strncpy...
137 ppv1=strchr(szbuff,'[');
138 ppv2=strchr(szbuff,']');
139 if(!ppv2 || !ppv1){
140 G4cout << "ERROR: Invalid format of volume name " << VolumeName << G4endl;
141 return false;
142 }
143 else *ppv2='\0';
144
145 nStationID=10*(szbuff[3]-0x30)+(szbuff[4]-0x30);
146 nDetectorID=atoi(ppv1+1);
147
148 m_nHitID++;
149
151#if G4VERSION_NUMBER < 1100
152 if (VolumeName.contains("SIDSensor") || (bIsSIDAuxVSID=VolumeName.contains("SIDVacuumSensor"))){
153#else
154 if (G4StrUtil::contains(VolumeName, "SIDSensor") || (bIsSIDAuxVSID=G4StrUtil::contains(VolumeName, "SIDVacuumSensor"))){
155#endif
156
157 if(!bIsSIDAuxVSID && !(fEnergyDeposit>0.0))
158 {
159 //hit in SID sensor but with zero deposited energy (transportation)
160 }
161 else
162 {
163 if (bIsSIDAuxVSID)
164 {
165 m_HitColl->Emplace(m_nHitID,nTrackID,nParticleEncoding,fKineticEnergy,fEnergyDeposit,
166 fPreStepX,fPreStepY,fPreStepZ,fPostStepX,fPostStepY,fPostStepZ,
167 fGlobalTime,nStationID,nDetectorID,bIsSIDAuxVSID,-1,-1);
168 // G4cout << "pixel["<< act_pixel_x - n_death_pixels <<"]["<< act_pixel_y - n_lower_pixels
169 // << "] will be stored, with energy "<< fEnergyDeposit*(pixel_track_length_XY/track_length_XY)
170 // << G4endl;
171 // m_nNumberOfSIDSimHits++;
172 }
173 else
174 {
175 // Cut on maximum number of SID hits/station
176 if(m_nNOfSIDSimHits[nStationID] >= SiDMaxCnt) return 1;
177
178 // Get the Touchable History:
179 const G4TouchableHistory* myTouch = static_cast<const G4TouchableHistory*>(pPreStepPoint->GetTouchable());
180 // Calculate the local step position.
181 // From a G4 FAQ:
182 // http://geant4-hn.slac.stanford.edu:5090/HyperNews/public/get/geometry/17/1.html
183
184 const G4AffineTransform transformation = myTouch->GetHistory()->GetTopTransform();
185 const G4ThreeVector localPosition_pre = transformation.TransformPoint(PreStepPointPos);
186 const G4ThreeVector localPosition_post = transformation.TransformPoint(PostStepPointPos);
187
188 const G4ThreeVector normpX( 1., 0., 0.);
189 const G4ThreeVector normnX(-1., 0., 0.);
190 const G4ThreeVector normpY( 0., 1., 0.);
191 const G4ThreeVector normnY( 0.,-1., 0.);
192 const G4ThreeVector normpZ( 0., 0., 1.);
193 const G4ThreeVector normnZ( 0., 0.,-1.);
194
195 G4double BarpX = static_cast<G4ReflectedSolid *>(myTouch->GetSolid())->DistanceToOut(localPosition_pre, normpX);
196 G4double BarnX = static_cast<G4ReflectedSolid *>(myTouch->GetSolid())->DistanceToOut(localPosition_pre, normnX);
197 G4double BarpY = static_cast<G4ReflectedSolid *>(myTouch->GetSolid())->DistanceToOut(localPosition_pre, normpY);
198 G4double BarnY = static_cast<G4ReflectedSolid *>(myTouch->GetSolid())->DistanceToOut(localPosition_pre, normnY);
199 G4double BarpZ = static_cast<G4ReflectedSolid *>(myTouch->GetSolid())->DistanceToOut(localPosition_pre, normpZ);
200 G4double BarnZ = static_cast<G4ReflectedSolid *>(myTouch->GetSolid())->DistanceToOut(localPosition_pre, normnZ);
201
202 G4double BarHalfX = .5 * (BarpX+BarnX);
203 G4double BarHalfY = .5 * (BarpY+BarnY);
204 G4double BarHalfZ = .5 * (BarpZ+BarnZ);
205
206 // x should be 50 mu, y should be 250 mu, z should be 250mu
207
208 G4double x_det = BarHalfX + localPosition_pre.x(); // we will remove death edge later - death_edge[nStationID][nDetectorID];
209 G4double y_det = BarHalfY + localPosition_pre.y(); // we will remove lower edge later - lower_edge[nStationID][nDetectorID];
210 G4double z_det = BarHalfZ + localPosition_pre.z();
211
212 G4double x_det_post = BarHalfX + localPosition_post.x(); //- death_edge[nStationID][nDetectorID];
213 G4double y_det_post = BarHalfY + localPosition_post.y(); //- lower_edge[nStationID][nDetectorID];
214 G4double z_det_post = BarHalfZ + localPosition_post.z();
215
216 //G4double track_length_XY = sqrt(pow(fPostStepX-fPreStepX,2)+pow(fPostStepY-fPreStepY,2));
217 G4double track_length_XY = sqrt(pow(x_det_post-x_det,2)+pow(y_det_post-y_det,2));
218
219 G4double angle_phi_global = atan2(fPostStepY-fPreStepY,fPostStepX-fPreStepX);
220 G4double angle_phi = atan2(y_det_post-y_det,x_det_post-x_det);
221
222 //G4double tan_phi_global = (fPostStepY-fPreStepY)/(fPostStepX-fPreStepX);
223 G4double tan_phi = (y_det_post-y_det)/(x_det_post-x_det);
224
225 if(verboseLevel>5)
226 {
227 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: local, x_det: " << x_det << ", y_det: " << y_det << ", z_det: " << z_det << G4endl;
228 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: local, x_det_post: " << x_det_post << ", y_det_post: " << y_det_post << ", z_det_post: " << z_det_post << G4endl;
229 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: angle_phi_global in -pi:pi = " << angle_phi_global << G4endl;
230 }
231 if (angle_phi_global < 0.) angle_phi_global = 2.*M_PI + angle_phi_global;
232 if(verboseLevel>5)
233 {
234 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: angle_phi_global in 0:2pi = " << angle_phi_global << G4endl;
235 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: angle_phi in -pi:pi = " << angle_phi << G4endl;
236 }
237 if (angle_phi < 0.) angle_phi = 2.*M_PI + angle_phi;
238 if(verboseLevel>5)
239 {
240 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: angle_phi in 0:2pi = " << angle_phi << G4endl;
241 }
242 signed int pre_pixel_x = (signed int)(x_det / m_delta_pixel_x);
243 signed int pre_pixel_y = (signed int)(y_det / m_delta_pixel_y);
244 signed int post_pixel_x = (signed int)(x_det_post / m_delta_pixel_x);
245 signed int post_pixel_y = (signed int)(y_det_post / m_delta_pixel_y);
246
247 signed int sign_pixels_x = 0;
248 signed int sign_pixels_y = 0;
249
250 int number_pixels_x = (int) (std::abs((post_pixel_x-pre_pixel_x)*1.0));
251 int number_pixels_y = (int) (std::abs((post_pixel_y-pre_pixel_y)*1.0));
252
253 if (number_pixels_x > 0)
254 {
255 sign_pixels_x = (post_pixel_x-pre_pixel_x)/number_pixels_x;
256 }
257 if (number_pixels_y > 0)
258 {
259 sign_pixels_y = (post_pixel_y-pre_pixel_y)/number_pixels_y;
260 }
261
262 int n_death_pixels = (int)(m_death_edge[nStationID][nDetectorID]/m_delta_pixel_x);
263 int n_lower_pixels = (int)(m_lower_edge[nStationID][nDetectorID]/m_delta_pixel_y);
264
265 if(verboseLevel>5)
266 {
267 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: pre: pixel["<< pre_pixel_x - n_death_pixels <<"]["<< pre_pixel_y - n_lower_pixels <<"] was hit" << G4endl;
268 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: post: pixel["<< post_pixel_x - n_death_pixels<<"]["<< post_pixel_y - n_lower_pixels<<"] was hit" << G4endl;
269 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: chip's length in x: " << 2.*BarHalfX << ", in y: " << 2.*BarHalfY << ", in z: " << 2.*BarHalfZ << G4endl;
270 }
271 signed int first = -1;
272
273 G4double x_next_pixel = -9999.;
274 G4double y_next_pixel = -9999.;
275
276 G4double x_border = -9999.;
277 G4double y_border = -9999.;
278
279 G4double pixel_track_length_XY = -1.;
280 G4double angle_2pixel = 10.;
281
282 //number of pixel in death and lower edge
283
284 int act_pixel_x = pre_pixel_x;
285 int act_pixel_y = pre_pixel_y;
286
287 //G4double act_pos_x = x_det;
288 //G4double act_pos_y = y_det;
289
290 if(verboseLevel>5)
291 {
292 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: actual pixel in x = " << act_pixel_x << ", in y = " << act_pixel_y << G4endl;
293 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: actual compensated pixel in x = " << act_pixel_x - n_death_pixels << ", in y = " << act_pixel_y - n_lower_pixels << G4endl;
294 }
295 if ((number_pixels_x == 0) && (number_pixels_y == 0))
296 {
297
298 if(verboseLevel>5)
299 {
300 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: pre and post in the same pixel " << G4endl;
301 }
302 if (( pre_pixel_y - n_lower_pixels <= 80) && (pre_pixel_x -n_death_pixels <= 336) && ( pre_pixel_y - n_lower_pixels > 0) && (pre_pixel_x - n_death_pixels > 0))
303 {
304 m_HitColl->Emplace(m_nHitID,nTrackID,nParticleEncoding,fKineticEnergy,fEnergyDeposit,
305 fPreStepX,fPreStepY,fPreStepZ,fPostStepX,fPostStepY,fPostStepZ,
306 fGlobalTime,nStationID,nDetectorID,bIsSIDAuxVSID,
307 (pre_pixel_y - n_lower_pixels - 1),
308 (pre_pixel_x - n_death_pixels - 1));
310
311 m_nNOfSIDSimHits[nStationID]++;
312 }
313 else if(verboseLevel>5)
314 {
315 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: hit outside of pixel's sensitive area " << G4endl;
316 }
317 }
318 else
319 {
320 if(verboseLevel>5)
321 {
322 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: pre and post in diferent pixels " << G4endl;
323 }
324 // still not complete logic, last step must be cut
325
326 while ( (number_pixels_x >= 0) && (number_pixels_y >= 0) )
327 {
328
329 if ((angle_phi >= 0.) && (angle_phi < M_PI_2))
330 {
331 x_next_pixel = (act_pixel_x+1)*m_delta_pixel_x; //- death_edge[nStationID][nDetectorID];
332 y_next_pixel = (act_pixel_y+1)*m_delta_pixel_y; //- death_edge[nStationID][nDetectorID];
333 angle_2pixel = atan2(y_next_pixel-y_det,x_next_pixel-x_det);
334
335 if (angle_2pixel < 0.) angle_2pixel = 2*M_PI + angle_2pixel;
336 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: angle_2pixel in 0:2pi = " << angle_2pixel << G4endl; }
337
338 if (angle_2pixel > angle_phi)
339 {
340 first = 0; // x border will be hit first
341 }
342 else
343 {
344 first = 1;
345 }
346 }
347
348 else if ((angle_phi >= M_PI_2) && (angle_phi < M_PI))
349 {
350 x_next_pixel = (act_pixel_x+0)*m_delta_pixel_x; //- death_edge[nStationID][nDetectorID];
351 y_next_pixel = (act_pixel_y+1)*m_delta_pixel_y; //- death_edge[nStationID][nDetectorID];
352 angle_2pixel = atan2(y_next_pixel-y_det,x_next_pixel-x_det);
353
354 if (angle_2pixel < 0.) angle_2pixel = 2*M_PI + angle_2pixel;
355 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: angle_2pixel in 0:2pi = " << angle_2pixel << G4endl; }
356
357 if (angle_2pixel > angle_phi)
358 {
359 first = 1; // y border will be hit first
360 }
361 else
362 {
363 first = 0;
364 }
365 }
366
367 else if ((angle_phi >= M_PI) && (angle_phi < 3.*M_PI_2))
368 {
369 x_next_pixel = (act_pixel_x+0)*m_delta_pixel_x; //- death_edge[nStationID][nDetectorID];
370 y_next_pixel = (act_pixel_y+0)*m_delta_pixel_y; //- death_edge[nStationID][nDetectorID];
371 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: next pixel corner, x = " << x_next_pixel << ", y =" << y_next_pixel << G4endl; }
372
373 angle_2pixel = atan2(y_next_pixel-y_det,x_next_pixel-x_det);
374
375 if (angle_2pixel < 0.) angle_2pixel = 2*M_PI + angle_2pixel;
376 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: angle_2pixel in 0:2pi = " << angle_2pixel << G4endl; }
377
378 if (angle_2pixel > angle_phi)
379 {
380 first = 0; // x border will be hit first
381 }
382 else
383 {
384 first = 1;
385 }
386 }
387
388 else if ((angle_phi >= 3.*M_PI_2) && (angle_phi < 2.*M_PI))
389 {
390 x_next_pixel = (act_pixel_x+1)*m_delta_pixel_x; //- death_edge[nStationID][nDetectorID];
391 y_next_pixel = (act_pixel_y+0)*m_delta_pixel_y; //- death_edge[nStationID][nDetectorID];
392 angle_2pixel = atan2(y_next_pixel-y_det,x_next_pixel-x_det);
393
394 if (angle_2pixel < 0.) angle_2pixel = 2*M_PI + angle_2pixel;
395 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: angle_2pixel in 0:2pi = " << angle_2pixel << G4endl; }
396
397 if (angle_2pixel > angle_phi)
398 {
399 first = 1; // y border will be hit first
400 }
401 else
402 {
403 first = 0;
404 }
405 }
406
407 else
408 {
409 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: something is wrong here!!! " << G4endl; }
410 }
411
412
413 if (first == -1 ) {
414 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: something is wrong here!!! " << G4endl; }
415 throw std::runtime_error("AFP_SiSensitiveDetector::ProcessHits: something is wrong here");
416 }
417
418 if(verboseLevel>5)
419 {
420 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: actual pixel in x = " << act_pixel_x << ", in y = " << act_pixel_y << G4endl;
421 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: actual compensated pixel in x = " << act_pixel_x - n_death_pixels << ", in y = " << act_pixel_y - n_lower_pixels << G4endl;
422 }
423
424 if (first == 0 )
425 {
426
427 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: cross is x, " << G4endl; }
428 x_border = x_next_pixel;
429
430 if ((sign_pixels_x >= 0) && (x_border > x_det_post)) x_border = x_det_post;
431 if ((sign_pixels_x < 0) && (x_border < x_det_post)) x_border = x_det_post;
432
433 y_border = tan_phi*(x_border-x_det) + y_det;
434
435 if (( act_pixel_y - n_lower_pixels <= 80) && (act_pixel_x -n_death_pixels <= 336) && ( act_pixel_y - n_lower_pixels > 0) && (act_pixel_x - n_death_pixels > 0))
436 {
437 pixel_track_length_XY = sqrt(pow(x_border-x_det,2)+pow(y_border-y_det,2));
438
439 if(verboseLevel>5)
440 {
441 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: overall energy = " << fEnergyDeposit << G4endl;
442 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: track XY length = " << track_length_XY << G4endl;
443 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: actual XY length = " << pixel_track_length_XY << G4endl;
444 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: deposited energy = " << fEnergyDeposit*(pixel_track_length_XY/track_length_XY) << G4endl;
445 }
446
447 // this logic has to be still checked, tracks is necessary fully in sensitive area, but logic is probably ok
448 m_HitColl->Emplace(m_nHitID,nTrackID,nParticleEncoding,fKineticEnergy,
449 fEnergyDeposit*(pixel_track_length_XY/track_length_XY),
450 fPreStepX,fPreStepY,fPreStepZ,fPostStepX,fPostStepY,fPostStepZ,
451 fGlobalTime,nStationID,nDetectorID,bIsSIDAuxVSID,
452 (act_pixel_y - n_lower_pixels - 1),
453 (act_pixel_x - n_death_pixels - 1));
454
455 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits:pixel["<< act_pixel_x - n_death_pixels <<"]["<< act_pixel_y - n_lower_pixels <<"] will be stored, with energy "
456 << fEnergyDeposit*(pixel_track_length_XY/track_length_XY) << G4endl; }
457
459
460 m_nNOfSIDSimHits[nStationID]++;
461 }
462
463 x_det = x_border;
464 y_det = y_border;
465
466 x_next_pixel = x_next_pixel + sign_pixels_x*m_delta_pixel_x;
467 number_pixels_x = number_pixels_x - 1;
468
469 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: remaining number of pixels in x = " << number_pixels_x << ", in y = " << number_pixels_y << G4endl; }
470
471 act_pixel_x = act_pixel_x + sign_pixels_x;
472 }
473
474 if (first == 1 )
475 {
476
477 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: cross is y, " << G4endl; }
478 y_border = y_next_pixel;
479
480 if ((sign_pixels_y >= 0) && (y_border > y_det_post)) y_border = y_det_post;
481 if ((sign_pixels_y < 0) && (y_border < y_det_post)) y_border = y_det_post;
482
483 x_border = (y_border-y_det)/tan_phi + x_det;
484
485 if (( act_pixel_y - n_lower_pixels <= 80) && (act_pixel_x -n_death_pixels <= 336) && ( act_pixel_y - n_lower_pixels > 0) && (act_pixel_x - n_death_pixels > 0))
486 {
487 pixel_track_length_XY = sqrt(pow(x_border-x_det,2)+pow(y_border-y_det,2));
488
489 if(verboseLevel>5)
490 {
491 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: overall energy = " << fEnergyDeposit << G4endl;
492 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: track XY length = " << track_length_XY << G4endl;
493 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: actual XY length = " << pixel_track_length_XY << G4endl;
494 G4cout << "AFP_SiDSensitiveDetector::ProcessHits: deposited energy = " << fEnergyDeposit*(pixel_track_length_XY/track_length_XY) << G4endl;
495 }
496
497 // this logic has to be still checked, tracks is necessary fully in sensitive area, but logic is probably ok
498 m_HitColl->Emplace(m_nHitID,nTrackID,nParticleEncoding,fKineticEnergy,
499 fEnergyDeposit*(pixel_track_length_XY/track_length_XY),
500 fPreStepX,fPreStepY,fPreStepZ,fPostStepX,fPostStepY,fPostStepZ,
501 fGlobalTime,nStationID,nDetectorID,bIsSIDAuxVSID,
502 (act_pixel_y - n_lower_pixels - 1),
503 (act_pixel_x - n_death_pixels - 1));
504
505 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits:pixel["<< act_pixel_x - n_death_pixels <<"]["<< act_pixel_y - n_lower_pixels <<"] will be stored, with energy "
506 << fEnergyDeposit*(pixel_track_length_XY/track_length_XY) << G4endl; }
507
509
510 m_nNOfSIDSimHits[nStationID]++;
511 }
512
513 y_det = y_border;
514 x_det = x_border;
515
516 y_next_pixel = y_next_pixel + sign_pixels_y*m_delta_pixel_y;
517 number_pixels_y = number_pixels_y - 1;
518
519 if(verboseLevel>5) { G4cout << "AFP_SiDSensitiveDetector::ProcessHits: remaining number of pixels in x = " << number_pixels_x << ", in y = " << number_pixels_y << G4endl; }
520
521
522 act_pixel_y = act_pixel_y + sign_pixels_y;
523 }
524 }
525 }
526 }
527 }
528 }
529
530 return true;
531}
#define M_PI
constexpr int pow(int base, int exp) noexcept
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
bool first
Definition DeMoScan.py:534

◆ StartOfAthenaEvent()

void AFP_SiDSensitiveDetector::StartOfAthenaEvent ( )

Definition at line 51 of file AFP_SiDSensitiveDetector.cxx.

52{
54 for( int i=0; i < 4; i++)
55 {
57 }
58}

Member Data Documentation

◆ m_death_edge

float AFP_SiDSensitiveDetector::m_death_edge[4][10]
private

Definition at line 60 of file AFP_SiDSensitiveDetector.h.

◆ m_delta_pixel_x

float AFP_SiDSensitiveDetector::m_delta_pixel_x
private

Definition at line 59 of file AFP_SiDSensitiveDetector.h.

◆ m_delta_pixel_y

float AFP_SiDSensitiveDetector::m_delta_pixel_y
private

Definition at line 59 of file AFP_SiDSensitiveDetector.h.

◆ m_HitColl

SG::WriteHandle<AFP_SIDSimHitCollection> AFP_SiDSensitiveDetector::m_HitColl
private

Definition at line 64 of file AFP_SiDSensitiveDetector.h.

◆ m_lower_edge

float AFP_SiDSensitiveDetector::m_lower_edge[4][10]
private

Definition at line 61 of file AFP_SiDSensitiveDetector.h.

◆ m_nEventNumber

int AFP_SiDSensitiveDetector::m_nEventNumber
private

Definition at line 54 of file AFP_SiDSensitiveDetector.h.

◆ m_nHitID

int AFP_SiDSensitiveDetector::m_nHitID
private

Definition at line 53 of file AFP_SiDSensitiveDetector.h.

◆ m_nNOfSIDSimHits

int AFP_SiDSensitiveDetector::m_nNOfSIDSimHits[4]
private

Definition at line 57 of file AFP_SiDSensitiveDetector.h.

◆ m_nNumberOfSIDSimHits

int AFP_SiDSensitiveDetector::m_nNumberOfSIDSimHits
private

Definition at line 55 of file AFP_SiDSensitiveDetector.h.

◆ SiDMaxCnt

int AFP_SiDSensitiveDetector::SiDMaxCnt = 1000
staticconstexpr

Definition at line 50 of file AFP_SiDSensitiveDetector.h.


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