39{
41 G4Exception("MicromegasSensitiveDetector::ProcessHits", "MicromegasHitCollectionMissing", FatalException,
42 "Hit collection not initialized; did SetupEvent run?");
43 return false;
44 }
45 G4Track* currentTrack = aStep->GetTrack();
46 int charge=currentTrack->GetDefinition()->GetPDGCharge();
47 bool geantinoHit = (currentTrack->GetDefinition()==G4Geantino::GeantinoDefinition()) ||
48 (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition());
49
50 if (!
charge && (!geantinoHit))
return false;
51
52 G4StepPoint* postStep=aStep->GetPostStepPoint();
53 const G4Step* post_Step=aStep->GetTrack()->GetStep();
54
56
57 int pdgCode=currentTrack->GetDefinition()->GetPDGEncoding();
58
59 float globalTime=postStep->GetGlobalTime();
60 float eKin=postStep->GetKineticEnergy();
61 if (eKin<= 0. && (!geantinoHit)) return false;
62
64 float depositEnergy=post_Step->GetTotalEnergyDeposit();
65
66 if (depositEnergy<0.0001 && (!geantinoHit)) return false;
67
68 const G4TouchableHistory* touchHist = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
69
70
71
72 int nLayer=touchHist->GetVolume(0)->GetCopyNo();
73 std::string
chName=touchHist->GetVolume(1)->GetLogicalVolume()->GetName();
75 if (subType[0]!='M') G4cout << " something is wrong, this is no Micromegas!" << G4endl;
76 std::string temp(&subType[1]);
77 std::istringstream is(temp);
78 int iRing;
79 is>>iRing;
80
81 iRing--;
82
83
84 G4ThreeVector posH=postStep->GetPosition();
85 if (subType[2]==
'L') posH.rotateZ(
M_PI/8.);
86 double phiHit=posH.phi();
87 if(phiHit<=0) phiHit+=2.*
M_PI;
90 if (subType[2]==
'L')
iPhi-=1;
91
92 int iSide=1;
93 if (position.z()<0) iSide=-1;
94
95 int mLayer=
atoi((subType.substr(3,1)).c_str());
96 if (mLayer != 1 && mLayer !=2) G4cout << " something is wrong - multilayer index is " << mLayer << G4endl;
97
98
99 int MmId =
m_muonHelper->BuildMicromegasHitId(subType, iPhi, iRing, mLayer,nLayer, iSide);
100
101 TrackHelper trHelp(aStep->GetTrack());
102
105
106
107
108
109
110
111
112
113
114
115
116 return true;
117}
double charge(const T &p)
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
Eigen::Matrix< double, 3, 1 > Vector3D
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
const std::string & chName(ChIndex index)
convert ChIndex into a string