36 #include "G4SDManager.hh" 39 #include "G4VProcess.hh" 41 #include "G4PhysicalConstants.hh" 42 #include "G4SystemOfUnits.hh" 52 hcID(-1), theHC(0), theManager(manager), currentHit(0), theTrack(0),
53 currentPV(0), unitID(0), previousUnitID(0), preStepPoint(0),
54 postStepPoint(0), eventno(0){
63 SetVerboseLevel(verbn);
65 <<
"*******************************************************\n" 67 <<
"* Constructing a TotemSD with name " << name <<
"\n" 69 <<
"*******************************************************";
76 const std::vector<std::string>& lvNames = clg.
logicalNames(name);
78 for (std::vector<std::string>::const_iterator it=lvNames.begin();
79 it !=lvNames.end(); it++) {
81 edm::LogInfo(
"ForwardSim") <<
"TotemSD : Assigns SD to LV " << (*it);
84 if (name ==
"TotemHitsT1") {
86 }
else if (name ==
"TotemHitsT2Si") {
88 }
else if (name ==
"TotemHitsT2Gem") {
90 }
else if (name ==
"TotemHitsRP") {
93 edm::LogWarning(
"ForwardSim") <<
"TotemSD: ReadoutName not supported\n";
96 edm::LogInfo(
"ForwardSim") <<
"TotemSD: Instantiation completed";
130 LogDebug(
"ForwardSim") <<
"TotemSD : Initialize called for " <<
name;
144 for (
int j=0;
j<
theHC->entries() &&
j<15000;
j++) {
147 LogDebug(
"ForwardSim") <<
"HIT NUMERO " <<
j <<
"unit ID = " 175 LogDebug(
"ForwardSim") <<
"TotemSD: Collection " <<
theHC->GetName();
176 theHC->PrintAllHits();
184 LogDebug(
"ForwardSim") <<
" Dispatched BeginOfEvent for " << GetName()
187 eventno = (*i)()->GetEventID();
199 G4ThreeVector localPoint;
200 const G4VTouchable* touch=
preStepPoint->GetTouchable();
201 localPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
217 name.assign(name,0,4);
219 edeposit = aStep->GetTotalEnergyDeposit();
231 Pabs = aStep->GetPreStepPoint()->GetMomentum().mag()/
GeV;
232 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond;
234 Eloss = aStep->GetTotalEnergyDeposit()/
GeV;
237 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/deg;
238 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/deg;
251 <<
" maybe detector name changed";
291 LogDebug(
"ForwardSim") <<
"TotemSD CreateNewHit for" 294 <<
" MVid = " <<
currentPV->GetMother()->GetCopyNo()
295 <<
" Unit " <<
unitID <<
"\n" 298 <<
" For Track " <<
theTrack->GetTrackID()
300 <<
theTrack->GetDefinition()->GetParticleName();
308 cout <<
" and created by " ;
312 LogDebug(
"ForwardSim") <<
"NO process";
365 G4ThreeVector _PosizioEvo;
381 double vz,
double pabs,
int& accettanza) {
384 G4ThreeVector PosEvo;
385 double ThetaX=atan((Pos.x()-vx)/(Pos.z()-vz));
386 double ThetaY=atan((Pos.y()-vy)/(Pos.z()-vz));
387 double X_at_0 =(vx-((Pos.x()-vx)/(Pos.z()-vz))*vz)/1000.;
388 double Y_at_0 =(vy-((Pos.y()-vy)/(Pos.z()-vz))*vz)/1000.;
396 double csi = fabs((7000.-pabs)/7000.);
400 double x_par[no_rp+1];
401 double y_par[no_rp+1];
403 double rp[no_rp]={141.,149.,198.,220.};
405 double leffx[][2]={{122.5429,-46.9312},{125.4194,-49.1849},{152.6,-81.157},{98.8914,-131.8390}};
407 double leffy[][2]={{124.2314,-55.4852},{127.7825,-57.4503},{179.455,-76.274},{273.0931,-40.4626}};
409 double avx[][2]={{0.515483,-1.0123},{0.494122,-1.0534},{0.2217,-1.483},{0.004633,-1.0719}};
411 double avy[][2]={{0.371418,-1.6327},{0.349035,-1.6955},{0.0815,-2.59},{0.007592,-4.0841}};
413 double ddx[][4]= {{-0.082336,-0.092513,112.3436,-82.5029},{-0.086927,-0.097670,114.9513,-82.9835},
414 {-0.092117,-0.0915,180.6236,-82.443},{-0.050470,0.058837,208.1106,20.8198}};
416 double detlim[][2]={{0,0},{0.0028,0.0021},{0,0},{0.0008,0.0013}};
418 double pipelim[][2]={{0.026,0.026},{0.04,0.04},{0.0226,0.0177},{0.04,0.04}};
421 for(
int j=0;
j<no_rp ;
j++) {
424 y_par[
j]=ThetaY*(leffy[
j][0]+leffy[
j][1]*csi)+(avy[
j][0]+avy[
j][1]*csi)*Y_at_0;
425 x_par[
j]=ThetaX*(leffx[
j][0]+leffx[
j][1]*csi)+(avx[
j][0]+avx[
j][1]*csi)*X_at_0-
426 csi*(ddx[
j][0]+(ddx[
j][1]+ddx[
j][2]*ThetaX)*csi+ddx[
j][3]*ThetaX);
431 if (fabs(y_par[0])<pipelim[0][1] &&
sqrt((y_par[0]*y_par[0])+(x_par[0]*x_par[0]))<pipelim[0][0]) {
433 if ((
sqrt((y_par[1]*y_par[1])+(x_par[1]*x_par[1]))<pipelim[1][0]) &&
434 (fabs(y_par[1])>detlim[1][1] || x_par[1]>detlim[1][0])) {
441 if (fabs(y_par[0])<pipelim[0][1] &&
sqrt((y_par[0])*(y_par[0])+(x_par[0])*(x_par[0]))<pipelim[0][0]) {
443 if (fabs(y_par[2])<pipelim[2][1] &&
sqrt((y_par[2]*y_par[2])+(x_par[2]*x_par[2]))<pipelim[2][0]) {
445 if ((
sqrt((y_par[3]*y_par[3])+(x_par[3]*x_par[3]))<pipelim[3][0]) &&
446 (fabs(y_par[3])>detlim[3][1] || x_par[3]>detlim[3][0])) {
449 PosEvo.setX(1000*x_par[3]);
450 PosEvo.setY(1000*y_par[3]);
451 PosEvo.setZ(1000*rp[3]);
452 if(Pos.z()<vz)PosEvo.setZ(-1000*rp[3]);
482 LogDebug(
"ForwardSim") <<
"G4TotemT1SD updateHit: add eloss " <<
Eloss 484 <<
", PostStepPoint=" 512 edm::LogWarning(
"ForwardSim") <<
"TotemSD: hit to be stored is NULL !!";
516 theHC->insert( hit );
T getParameter(std::string const &) const
virtual bool ProcessHits(G4Step *, G4TouchableHistory *)
T getUntrackedParameter(std::string const &, T const &) const
virtual void EndOfEvent(G4HCofThisEvent *eventHC)
TotemG4HitCollection * theHC
void fillHits(edm::PSimHitContainer &, std::string use)
void setEnergyLoss(float e)
G4ThreeVector entrancePoint
void setEntry(double x, double y, double z)
float getEnergyLoss() const
virtual uint32_t setDetUnitId(G4Step *)
math::XYZPoint getEntry() const
TotemVDetectorOrganization * numberingScheme
TotemSD(std::string, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
type of data representation of DDCompactView
void ResetForNewPrimary()
virtual void AssignSD(const std::string &vname)
G4StepPoint * preStepPoint
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
void setTimeSlice(double d)
G4ThreeVector SetToLocal(const G4ThreeVector &globalPoint)
void update(const BeginOfEvent *)
This routine will be called when the appropriate signal arrives.
G4ThreeVector PosizioEvo(const G4ThreeVector &, double, double, double, double, int &)
std::vector< PSimHit > & hits()
std::string const collectionName[nCollections]
virtual void Initialize()
float getPhiAtEntry() const
int getTimeSliceID() const
virtual uint32_t GetUnitID(const G4Step *aStep) const =0
G4StepPoint * postStepPoint
G4VPhysicalVolume * currentPV
void setIncidentEnergy(double e)
void setThetaAtEntry(float t)
void setUnitID(uint32_t i)
void setPhiAtEntry(float f)
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
virtual void Initialize(G4HCofThisEvent *HCE)