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),
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";
103 LogDebug(
"ForwardSim") <<
"TotemSD : Initialize called for " << GetName();
117 for (
int j=0; j<
theHC->entries() && j<15000; j++) {
120 LogDebug(
"ForwardSim") <<
"HIT NUMERO " << j <<
"unit ID = " 141 LogDebug(
"ForwardSim") <<
"TotemSD: Collection " <<
theHC->GetName();
142 theHC->PrintAllHits();
150 LogDebug(
"ForwardSim") <<
" Dispatched BeginOfEvent for " << GetName()
161 G4ThreeVector localPoint;
162 const G4VTouchable* touch=
preStepPoint->GetTouchable();
163 localPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
177 name.assign(name,0,4);
179 edeposit = aStep->GetTotalEnergyDeposit();
190 Pabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
191 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond;
193 Eloss = aStep->GetTotalEnergyDeposit()/
GeV;
196 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/deg;
197 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/deg;
210 <<
" maybe detector name changed";
229 for (
int j=0; j<
theHC->entries()&&!
found; j++) {
251 LogDebug(
"ForwardSim") <<
"TotemSD CreateNewHit for" 254 <<
" MVid = " <<
currentPV->GetMother()->GetCopyNo()
255 <<
" Unit " <<
unitID <<
"\n" 258 <<
" For Track " <<
theTrack->GetTrackID()
260 <<
theTrack->GetDefinition()->GetParticleName();
268 if (
theTrack->GetCreatorProcess()!=
nullptr)
271 LogDebug(
"ForwardSim") <<
"NO process";
324 G4ThreeVector _PosizioEvo;
339 double vz,
double pabs,
int& accettanza) {
342 G4ThreeVector PosEvo;
343 double ThetaX=std::atan((Pos.x()-vx)/(Pos.z()-vz));
344 double ThetaY=std::atan((Pos.y()-vy)/(Pos.z()-vz));
345 double X_at_0 =(vx-((Pos.x()-vx)/(Pos.z()-vz))*vz)/1000.;
346 double Y_at_0 =(vy-((Pos.y()-vy)/(Pos.z()-vz))*vz)/1000.;
354 double csi =
std::abs((7000.-pabs)/7000.);
358 double x_par[no_rp+1];
359 double y_par[no_rp+1];
361 double rp[no_rp]={141.,149.,198.,220.};
363 double leffx[][2]={{122.5429,-46.9312},{125.4194,-49.1849},{152.6,-81.157},{98.8914,-131.8390}};
365 double leffy[][2]={{124.2314,-55.4852},{127.7825,-57.4503},{179.455,-76.274},{273.0931,-40.4626}};
367 double avx[][2]={{0.515483,-1.0123},{0.494122,-1.0534},{0.2217,-1.483},{0.004633,-1.0719}};
369 double avy[][2]={{0.371418,-1.6327},{0.349035,-1.6955},{0.0815,-2.59},{0.007592,-4.0841}};
371 double ddx[][4]= {{-0.082336,-0.092513,112.3436,-82.5029},{-0.086927,-0.097670,114.9513,-82.9835},
372 {-0.092117,-0.0915,180.6236,-82.443},{-0.050470,0.058837,208.1106,20.8198}};
374 double detlim[][2]={{0,0},{0.0028,0.0021},{0,0},{0.0008,0.0013}};
376 double pipelim[][2]={{0.026,0.026},{0.04,0.04},{0.0226,0.0177},{0.04,0.04}};
379 for(
int j=0; j<no_rp ; j++) {
382 y_par[j]=ThetaY*(leffy[j][0]+leffy[j][1]*csi)+(avy[j][0]+avy[j][1]*csi)*Y_at_0;
383 x_par[j]=ThetaX*(leffx[j][0]+leffx[j][1]*csi)+(avx[j][0]+avx[j][1]*csi)*X_at_0-
384 csi*(ddx[j][0]+(ddx[j][1]+ddx[j][2]*ThetaX)*csi+ddx[j][3]*ThetaX);
389 if (
std::abs(y_par[0])<pipelim[0][1] &&
sqrt((y_par[0]*y_par[0])+(x_par[0]*x_par[0]))<pipelim[0][0]) {
391 if ((
sqrt((y_par[1]*y_par[1])+(x_par[1]*x_par[1]))<pipelim[1][0]) &&
392 (
std::abs(y_par[1])>detlim[1][1] || x_par[1]>detlim[1][0])) {
399 if (
std::abs(y_par[0])<pipelim[0][1] &&
sqrt((y_par[0])*(y_par[0])+(x_par[0])*(x_par[0]))<pipelim[0][0]) {
401 if (
std::abs(y_par[2])<pipelim[2][1] &&
sqrt((y_par[2]*y_par[2])+(x_par[2]*x_par[2]))<pipelim[2][0]) {
403 if ((
sqrt((y_par[3]*y_par[3])+(x_par[3]*x_par[3]))<pipelim[3][0]) &&
404 (
std::abs(y_par[3])>detlim[3][1] || x_par[3]>detlim[3][0])) {
407 PosEvo.setX(1000*x_par[3]);
408 PosEvo.setY(1000*y_par[3]);
409 PosEvo.setZ(1000*rp[3]);
410 if(Pos.z()<vz)PosEvo.setZ(-1000*rp[3]);
438 LogDebug(
"ForwardSim") <<
"G4TotemT1SD updateHit: add eloss " <<
Eloss 440 <<
", PostStepPoint=" 456 if (hit ==
nullptr ) {
457 edm::LogWarning(
"ForwardSim") <<
"TotemSD: hit to be stored is NULL !!";
461 theHC->insert( hit );
G4ThreeVector setToLocal(const G4ThreeVector &globalPoint)
void resetForNewPrimary()
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void Initialize(G4HCofThisEvent *HCE) override
G4ThreeVector posizioEvo(const G4ThreeVector &, double, double, double, double, int &)
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 storeHit(TotemG4Hit *)
void update(const BeginOfEvent *) override
This routine will be called when the appropriate signal arrives.
math::XYZPoint getEntry() const
TotemVDetectorOrganization * numberingScheme
Compact representation of the geometrical detector hierarchy.
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
const G4StepPoint * preStepPoint
void setTimeSlice(double d)
std::vector< PSimHit > & hits()
std::string const collectionName[nCollections]
virtual void Initialize()
float getPhiAtEntry() const
void fillHits(edm::PSimHitContainer &, const std::string &) override
Abs< T >::type abs(const T &t)
int getTimeSliceID() const
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 *)
const G4StepPoint * postStepPoint
void setUnitID(uint32_t i)
void setPhiAtEntry(float f)
void EndOfEvent(G4HCofThisEvent *eventHC) override
uint32_t getUnitID() const
virtual uint32_t getUnitID(const G4Step *aStep) const =0
void setParticleType(short i)
int getParticleType() const
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
float getThetaAtEntry() const
G4THitsCollection< TotemG4Hit > TotemG4HitCollection
void clearHits() override
void getStepInfo(const G4Step *aStep)