58 void AddPlane(
const char* name, Double_t x, Double_t y, Double_t z,
59 Double_t sizeX, Double_t sizeY, Double_t sizeZ,
60 const std::vector<Int_t>& absPdgCodes = {},
61 Bool_t keepTracks = kTRUE) {
63 {name, x, y, z, sizeX, sizeY, sizeZ, absPdgCodes, keepTracks});
68 if (!gMC->IsTrackEntering()) {
72 gMC->CurrentVolID(copyNo);
73 if (copyNo < 1 ||
static_cast<size_t>(copyNo) >
fPlanes.size()) {
74 LOG(fatal) << this->GetName() <<
": copy number " << copyNo
75 <<
" of the plane does not match any of the " <<
fPlanes.size()
76 <<
" configured planes; the geometry differs from the "
80 TParticle* p = gMC->GetStack()->GetCurrentTrack();
81 const Int_t pdgCode = p->GetPdgCode();
82 const std::vector<Int_t>& accepted = plane.
absPdgCodes;
83 if (!accepted.empty() && std::find(accepted.begin(), accepted.end(),
84 std::abs(pdgCode)) == accepted.end()) {
88 this->
fEventID = gMC->CurrentEvent();
89 this->
fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
91 this->
fTime = gMC->TrackTime() * 1.0e09;
92 this->
fLength = gMC->TrackLength();
93 gMC->TrackPosition(this->
fPos);
94 gMC->TrackMomentum(this->
fMom);
96 TVector3(this->
fPos.X(), this->fPos.Y(), this->fPos.Z()),
97 TVector3(this->
fMom.Px(), this->fMom.Py(), this->fMom.Pz()),
98 this->fTime, this->fLength, 0., pdgCode);
108 stack->AddPoint(
static_cast<DetectorId>(this->GetDetId()));
114 TGeoVolume* top = gGeoManager->GetTopVolume();
116 TGeoMedium* vacuum = gGeoManager->GetMedium(
"vacuum");
118 LOG(fatal) << this->GetName() <<
": medium 'vacuum' not found.";
121 LOG(fatal) << this->GetName() <<
": no scoring planes.";
124 for (
size_t i = 0; i <
fPlanes.size(); ++i) {
126 if (pl.sizeX <= 0. || pl.sizeY <= 0. || pl.sizeZ <= 0.) {
127 LOG(fatal) << this->GetName() <<
": invalid dimensions of " << pl.name;
129 TGeoVolume* plane = gGeoManager->MakeBox(
130 pl.name.c_str(), vacuum, pl.sizeX / 2., pl.sizeY / 2., pl.sizeZ / 2.);
132 this->AddSensitiveVolume(plane);
134 top->AddNode(plane, i + 1,
new TGeoTranslation(pl.x, pl.y, pl.z));
136 LOG(info) << pl.name <<
": " << pl.sizeX <<
" x " << pl.sizeY <<
" x "
137 << pl.sizeZ <<
" cm3 centred at (" << pl.x <<
", " << pl.y
138 <<
", " << pl.z <<
") cm"
139 << (pl.absPdgCodes.empty() ?
"" :
", PDG-filtered");