36 #include "G4SDManager.hh" 39 #include "G4VProcess.hh" 41 #include "G4PhysicalConstants.hh" 42 #include "G4SystemOfUnits.hh" 53 currentPV(
nullptr), unitID(0), previousUnitID(0), preStepPoint(
nullptr),
54 postStepPoint(
nullptr), eventno(0){
60 SetVerboseLevel(verbn);
64 if (name ==
"TotemHitsT1") {
66 }
else if (name ==
"TotemHitsT2Si") {
68 }
else if (name ==
"TotemHitsT2Gem") {
70 }
else if (name ==
"TotemHitsRP") {
73 edm::LogWarning(
"ForwardSim") <<
"TotemSD: ReadoutName not supported\n";
84 if (aStep ==
nullptr) {
108 LogDebug(
"ForwardSim") <<
"TotemSD : Initialize called for " << GetName();
122 for (
int j=0; j<
theHC->entries() && j<15000; j++) {
125 LogDebug(
"ForwardSim") <<
"HIT NUMERO " << j <<
"unit ID = " 153 LogDebug(
"ForwardSim") <<
"TotemSD: Collection " <<
theHC->GetName();
154 theHC->PrintAllHits();
162 LogDebug(
"ForwardSim") <<
" Dispatched BeginOfEvent for " << GetName()
165 eventno = (*i)()->GetEventID();
177 G4ThreeVector localPoint;
178 const G4VTouchable* touch=
preStepPoint->GetTouchable();
179 localPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
195 name.assign(name,0,4);
197 edeposit = aStep->GetTotalEnergyDeposit();
209 Pabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
210 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond;
212 Eloss = aStep->GetTotalEnergyDeposit()/
GeV;
215 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/deg;
216 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/deg;
229 <<
" maybe detector name changed";
248 for (
int j=0; j<
theHC->entries()&&!
found; j++) {
269 LogDebug(
"ForwardSim") <<
"TotemSD CreateNewHit for" 272 <<
" MVid = " <<
currentPV->GetMother()->GetCopyNo()
273 <<
" Unit " <<
unitID <<
"\n" 276 <<
" For Track " <<
theTrack->GetTrackID()
278 <<
theTrack->GetDefinition()->GetParticleName();
286 cout <<
" and created by " ;
290 LogDebug(
"ForwardSim") <<
"NO process";
343 G4ThreeVector _PosizioEvo;
359 double vz,
double pabs,
int& accettanza) {
362 G4ThreeVector PosEvo;
363 double ThetaX=atan((Pos.x()-vx)/(Pos.z()-vz));
364 double ThetaY=atan((Pos.y()-vy)/(Pos.z()-vz));
365 double X_at_0 =(vx-((Pos.x()-vx)/(Pos.z()-vz))*vz)/1000.;
366 double Y_at_0 =(vy-((Pos.y()-vy)/(Pos.z()-vz))*vz)/1000.;
374 double csi = fabs((7000.-pabs)/7000.);
378 double x_par[no_rp+1];
379 double y_par[no_rp+1];
381 double rp[no_rp]={141.,149.,198.,220.};
383 double leffx[][2]={{122.5429,-46.9312},{125.4194,-49.1849},{152.6,-81.157},{98.8914,-131.8390}};
385 double leffy[][2]={{124.2314,-55.4852},{127.7825,-57.4503},{179.455,-76.274},{273.0931,-40.4626}};
387 double avx[][2]={{0.515483,-1.0123},{0.494122,-1.0534},{0.2217,-1.483},{0.004633,-1.0719}};
389 double avy[][2]={{0.371418,-1.6327},{0.349035,-1.6955},{0.0815,-2.59},{0.007592,-4.0841}};
391 double ddx[][4]= {{-0.082336,-0.092513,112.3436,-82.5029},{-0.086927,-0.097670,114.9513,-82.9835},
392 {-0.092117,-0.0915,180.6236,-82.443},{-0.050470,0.058837,208.1106,20.8198}};
394 double detlim[][2]={{0,0},{0.0028,0.0021},{0,0},{0.0008,0.0013}};
396 double pipelim[][2]={{0.026,0.026},{0.04,0.04},{0.0226,0.0177},{0.04,0.04}};
399 for(
int j=0; j<no_rp ; j++) {
402 y_par[j]=ThetaY*(leffy[j][0]+leffy[j][1]*csi)+(avy[j][0]+avy[j][1]*csi)*Y_at_0;
403 x_par[j]=ThetaX*(leffx[j][0]+leffx[j][1]*csi)+(avx[j][0]+avx[j][1]*csi)*X_at_0-
404 csi*(ddx[j][0]+(ddx[j][1]+ddx[j][2]*ThetaX)*csi+ddx[j][3]*ThetaX);
409 if (fabs(y_par[0])<pipelim[0][1] &&
sqrt((y_par[0]*y_par[0])+(x_par[0]*x_par[0]))<pipelim[0][0]) {
411 if ((
sqrt((y_par[1]*y_par[1])+(x_par[1]*x_par[1]))<pipelim[1][0]) &&
412 (fabs(y_par[1])>detlim[1][1] || x_par[1]>detlim[1][0])) {
419 if (fabs(y_par[0])<pipelim[0][1] &&
sqrt((y_par[0])*(y_par[0])+(x_par[0])*(x_par[0]))<pipelim[0][0]) {
421 if (fabs(y_par[2])<pipelim[2][1] &&
sqrt((y_par[2]*y_par[2])+(x_par[2]*x_par[2]))<pipelim[2][0]) {
423 if ((
sqrt((y_par[3]*y_par[3])+(x_par[3]*x_par[3]))<pipelim[3][0]) &&
424 (fabs(y_par[3])>detlim[3][1] || x_par[3]>detlim[3][0])) {
427 PosEvo.setX(1000*x_par[3]);
428 PosEvo.setY(1000*y_par[3]);
429 PosEvo.setZ(1000*rp[3]);
430 if(Pos.z()<vz)PosEvo.setZ(-1000*rp[3]);
460 LogDebug(
"ForwardSim") <<
"G4TotemT1SD updateHit: add eloss " <<
Eloss 462 <<
", PostStepPoint=" 489 if (hit ==
nullptr ) {
490 edm::LogWarning(
"ForwardSim") <<
"TotemSD: hit to be stored is NULL !!";
494 theHC->insert( hit );
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void Initialize(G4HCofThisEvent *HCE) override
TotemG4HitCollection * theHC
void setEnergyLoss(float e)
G4ThreeVector entrancePoint
void setEntry(double x, double y, double z)
bool ProcessHits(G4Step *, G4TouchableHistory *) override
float getEnergyLoss() const
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
math::XYZPoint getEntry() const
TotemVDetectorOrganization * numberingScheme
type of data representation of DDCompactView
void ResetForNewPrimary()
G4StepPoint * preStepPoint
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
void setTimeSlice(double d)
G4ThreeVector SetToLocal(const G4ThreeVector &globalPoint)
G4ThreeVector PosizioEvo(const G4ThreeVector &, double, double, double, double, int &)
std::vector< PSimHit > & hits()
std::string const collectionName[nCollections]
virtual void Initialize()
float getPhiAtEntry() const
void fillHits(edm::PSimHitContainer &, const std::string &) override
int getTimeSliceID() const
virtual uint32_t GetUnitID(const G4Step *aStep) const =0
G4StepPoint * postStepPoint
G4VPhysicalVolume * currentPV
void setIncidentEnergy(double e)
uint32_t setDetUnitId(const G4Step *) override
void setThetaAtEntry(float t)
TotemSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
void setUnitID(uint32_t i)
void setPhiAtEntry(float f)
void EndOfEvent(G4HCofThisEvent *eventHC) override
uint32_t getUnitID() const
void setParticleType(short i)
void StoreHit(TotemG4Hit *)
int getParticleType() const
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
float getThetaAtEntry() const
void GetStepInfo(G4Step *aStep)
G4THitsCollection< TotemG4Hit > TotemG4HitCollection
void clearHits() override