37 #include "G4SDManager.hh"
40 #include "G4VProcess.hh"
49 hcID(-1), theHC(0), theManager(manager), currentHit(0), theTrack(0),
50 currentPV(0), unitID(0), previousUnitID(0), preStepPoint(0),
51 postStepPoint(0), eventno(0){
54 collectionName.insert(name);
60 SetVerboseLevel(verbn);
62 <<
"*******************************************************\n"
64 <<
"* Constructing a TotemSD with name " << name <<
"\n"
66 <<
"*******************************************************";
73 std::vector<std::string> lvNames = clg.
logicalNames(name);
75 for (std::vector<std::string>::iterator it=lvNames.begin();
76 it !=lvNames.end(); it++) {
78 edm::LogInfo(
"ForwardSim") <<
"TotemSD : Assigns SD to LV " << (*it);
81 if (name ==
"TotemHitsT1") {
83 }
else if (name ==
"TotemHitsT2Si") {
85 }
else if (name ==
"TotemHitsT2Gem") {
87 }
else if (name ==
"TotemHitsRP") {
90 edm::LogWarning(
"ForwardSim") <<
"TotemSD: ReadoutName not supported\n";
93 edm::LogInfo(
"ForwardSim") <<
"TotemSD: Instantiation completed";
127 LogDebug(
"ForwardSim") <<
"TotemSD : Initialize called for " <<
name;
131 hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
141 for (
int j=0;
j<
theHC->entries() &&
j<15000;
j++) {
144 LogDebug(
"ForwardSim") <<
"HIT NUMERO " <<
j <<
"unit ID = "
172 LogDebug(
"ForwardSim") <<
"TotemSD: Collection " <<
theHC->GetName();
173 theHC->PrintAllHits();
181 LogDebug(
"ForwardSim") <<
" Dispatched BeginOfEvent for " << GetName()
184 eventno = (*i)()->GetEventID();
196 G4ThreeVector localPoint;
197 const G4VTouchable* touch=
preStepPoint->GetTouchable();
198 localPoint = touch->GetHistory()->GetTopTransform().TransformPoint(global);
214 name.assign(name,0,4);
215 G4String particleType =
theTrack->GetDefinition()->GetParticleName();
216 edeposit = aStep->GetTotalEnergyDeposit();
228 Pabs = aStep->GetPreStepPoint()->GetMomentum().mag()/GeV;
229 Tof = aStep->GetPostStepPoint()->GetGlobalTime()/nanosecond;
231 Eloss = aStep->GetTotalEnergyDeposit()/GeV;
234 ThetaAtEntry = aStep->GetPreStepPoint()->GetPosition().theta()/deg;
235 PhiAtEntry = aStep->GetPreStepPoint()->GetPosition().phi()/deg;
248 <<
" maybe detector name changed";
288 LogDebug(
"ForwardSim") <<
"TotemSD CreateNewHit for"
291 <<
" MVid = " <<
currentPV->GetMother()->GetCopyNo()
292 <<
" Unit " <<
unitID <<
"\n"
295 <<
" For Track " <<
theTrack->GetTrackID()
297 <<
theTrack->GetDefinition()->GetParticleName();
305 cout <<
" and created by " ;
309 LogDebug(
"ForwardSim") <<
"NO process";
362 G4ThreeVector _PosizioEvo;
378 double vz,
double pabs,
int& accettanza) {
381 G4ThreeVector PosEvo;
382 double ThetaX=atan((Pos.x()-vx)/(Pos.z()-vz));
383 double ThetaY=atan((Pos.y()-vy)/(Pos.z()-vz));
384 double X_at_0 =(vx-((Pos.x()-vx)/(Pos.z()-vz))*vz)/1000.;
385 double Y_at_0 =(vy-((Pos.y()-vy)/(Pos.z()-vz))*vz)/1000.;
393 double csi = fabs((7000.-pabs)/7000.);
397 double x_par[no_rp+1];
398 double y_par[no_rp+1];
400 double rp[no_rp]={141.,149.,198.,220.};
402 double leffx[][2]={{122.5429,-46.9312},{125.4194,-49.1849},{152.6,-81.157},{98.8914,-131.8390}};
404 double leffy[][2]={{124.2314,-55.4852},{127.7825,-57.4503},{179.455,-76.274},{273.0931,-40.4626}};
406 double avx[][2]={{0.515483,-1.0123},{0.494122,-1.0534},{0.2217,-1.483},{0.004633,-1.0719}};
408 double avy[][2]={{0.371418,-1.6327},{0.349035,-1.6955},{0.0815,-2.59},{0.007592,-4.0841}};
410 double ddx[][4]= {{-0.082336,-0.092513,112.3436,-82.5029},{-0.086927,-0.097670,114.9513,-82.9835},
411 {-0.092117,-0.0915,180.6236,-82.443},{-0.050470,0.058837,208.1106,20.8198}};
413 double detlim[][2]={{0,0},{0.0028,0.0021},{0,0},{0.0008,0.0013}};
415 double pipelim[][2]={{0.026,0.026},{0.04,0.04},{0.0226,0.0177},{0.04,0.04}};
418 for(
int j=0;
j<no_rp ;
j++) {
421 y_par[
j]=ThetaY*(leffy[
j][0]+leffy[
j][1]*csi)+(avy[
j][0]+avy[
j][1]*csi)*Y_at_0;
422 x_par[
j]=ThetaX*(leffx[
j][0]+leffx[
j][1]*csi)+(avx[
j][0]+avx[
j][1]*csi)*X_at_0-
423 csi*(ddx[
j][0]+(ddx[
j][1]+ddx[
j][2]*ThetaX)*csi+ddx[
j][3]*ThetaX);
428 if (fabs(y_par[0])<pipelim[0][1] &&
sqrt((y_par[0]*y_par[0])+(x_par[0]*x_par[0]))<pipelim[0][0]) {
430 if ((
sqrt((y_par[1]*y_par[1])+(x_par[1]*x_par[1]))<pipelim[1][0]) &&
431 (fabs(y_par[1])>detlim[1][1] || x_par[1]>detlim[1][0])) {
438 if (fabs(y_par[0])<pipelim[0][1] &&
sqrt((y_par[0])*(y_par[0])+(x_par[0])*(x_par[0]))<pipelim[0][0]) {
440 if (fabs(y_par[2])<pipelim[2][1] &&
sqrt((y_par[2]*y_par[2])+(x_par[2]*x_par[2]))<pipelim[2][0]) {
442 if ((
sqrt((y_par[3]*y_par[3])+(x_par[3]*x_par[3]))<pipelim[3][0]) &&
443 (fabs(y_par[3])>detlim[3][1] || x_par[3]>detlim[3][0])) {
446 PosEvo.setX(1000*x_par[3]);
447 PosEvo.setY(1000*y_par[3]);
448 PosEvo.setZ(1000*rp[3]);
449 if(Pos.z()<vz)PosEvo.setZ(-1000*rp[3]);
479 LogDebug(
"ForwardSim") <<
"G4TotemT1SD updateHit: add eloss " <<
Eloss
481 <<
", PostStepPoint="
509 edm::LogWarning(
"ForwardSim") <<
"TotemSD: hit to be stored is NULL !!";
513 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)
std::vector< std::string > logicalNames(std::string &readoutName)
TotemG4HitCollection * theHC
void fillHits(edm::PSimHitContainer &, std::string use)
void setEnergyLoss(float e)
virtual uint32_t GetUnitID(const G4Step *aStep) const =0
G4ThreeVector entrancePoint
void setEntry(double x, double y, double z)
float getEnergyLoss() const
virtual uint32_t setDetUnitId(G4Step *)
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)
void update(const BeginOfEvent *)
This routine will be called when the appropriate signal arrives.
std::vector< PSimHit > & hits()
G4ThreeVector SetToLocal(G4ThreeVector globalPoint)
virtual void Initialize()
float getPhiAtEntry() const
int getTimeSliceID() const
G4StepPoint * postStepPoint
G4VPhysicalVolume * currentPV
void setIncidentEnergy(double e)
void setThetaAtEntry(float t)
void setUnitID(uint32_t i)
TotemSD(std::string, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
void setPhiAtEntry(float f)
uint32_t getUnitID() const
virtual void AssignSD(std::string &vname)
void setParticleType(short i)
void StoreHit(TotemG4Hit *)
int getParticleType() const
G4ThreeVector PosizioEvo(G4ThreeVector, double, double, double, double, int &)
virtual bool processHits(const PSimHit &)
std::vector< PSimHit > PSimHitContainer
float getThetaAtEntry() const
void GetStepInfo(G4Step *aStep)
G4THitsCollection< TotemG4Hit > TotemG4HitCollection
virtual void Initialize(G4HCofThisEvent *HCE)