21 #include <calobase/TowerInfo.h>
22 #include <calobase/TowerInfoContainer.h>
23 #include <calobase/TowerInfoContainerv1.h>
24 #include <calobase/TowerInfoDefs.h>
42 #include <phparameter/PHParameters.h>
44 #include <Geant4/G4IonisParamMat.hh>
45 #include <Geant4/G4Material.hh>
46 #include <Geant4/G4MaterialCutsCouple.hh>
47 #include <Geant4/G4ParticleDefinition.hh>
48 #include <Geant4/G4ReferenceCountedHandle.hh>
49 #include <Geant4/G4Step.hh>
50 #include <Geant4/G4StepPoint.hh>
51 #include <Geant4/G4StepStatus.hh>
52 #include <Geant4/G4String.hh>
53 #include <Geant4/G4SystemOfUnits.hh>
54 #include <Geant4/G4ThreeVector.hh>
55 #include <Geant4/G4TouchableHandle.hh>
56 #include <Geant4/G4Track.hh>
57 #include <Geant4/G4TrackStatus.hh>
58 #include <Geant4/G4TransportationManager.hh>
59 #include <Geant4/G4Types.hh>
60 #include <Geant4/G4VTouchable.hh>
61 #include <Geant4/G4VUserTrackInformation.hh>
76 , m_Detector(indetector)
77 , m_Params(parameters)
78 , m_doG4Hit(m_Params->get_int_param(
"saveg4hit"))
79 , m_tmin(m_Params->get_double_param(
"tmin"))
80 , m_tmax(m_Params->get_double_param(
"tmax"))
81 , m_dt(m_Params->get_double_param(
"dt"))
104 std::cout <<
PHWHERE <<
"DST Node missing, doing nothing." << std::endl;
137 std::cout <<
"PHG4SpacalSteppingAction::InitWithNode - Fatal Error - Could not locate sim geometry node "
145 std::cout <<
"PHG4FullProjSpacalCellReco::process_event - Fatal Error - could not locate cell geometry node "
164 G4VPhysicalVolume *volume = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume();
168 G4StepPoint *prePoint = aStep->GetPreStepPoint();
169 G4StepPoint *postPoint = aStep->GetPostStepPoint();
171 double pretime = prePoint->GetGlobalTime() / nanosecond;
172 double posttime = postPoint->GetGlobalTime() / nanosecond;
173 if (posttime < m_tmin || pretime >
m_tmax)
return false;
174 if ((posttime - pretime) >
m_dt)
return false;
192 fiber_ID = prePoint->GetTouchable()->GetReplicaNumber(1);
193 tower_ID = prePoint->GetTouchable()->GetReplicaNumber(2);
194 sector_ID = prePoint->GetTouchable()->GetReplicaNumber(3);
210 scint_id = prePoint->GetTouchable()->GetReplicaNumber(2);
222 const int &tower_ID_z = tower_z_phi_ID.first;
223 const int &tower_ID_phi = tower_z_phi_ID.second;
225 PHG4CylinderGeom_Spacalv3::tower_map_t::const_iterator it_tower =
235 catch (std::exception &
e)
237 std::cout <<
"Print cell geometry:" << std::endl;
239 std::cout <<
"Print scint_id_coder:" << std::endl;
241 std::cout <<
"PHG4SpacalSteppingAction::UserSteppingAction::"
242 <<
" - Fatal Error - " << e.what() << std::endl;
246 const int sub_tower_ID_x = it_tower->second.get_sub_tower_ID_x(decoder.
fiber_ID);
247 const int sub_tower_ID_y = it_tower->second.get_sub_tower_ID_y(decoder.
fiber_ID);
256 const G4TouchableHandle &theTouchable0 = prePoint->GetTouchableHandle();
257 const G4ThreeVector &worldPosition0 = prePoint->GetPosition();
258 G4ThreeVector localPosition = theTouchable0->GetHistory()->GetTopTransform().TransformPoint(worldPosition0);
259 const double localz0 = localPosition.z();
261 const G4TouchableHandle &theTouchable1 = postPoint->GetTouchableHandle();
262 const G4ThreeVector &worldPosition1 = postPoint->GetPosition();
263 localPosition = theTouchable1->GetHistory()->GetTopTransform().TransformPoint(worldPosition1);
264 const double localz1 = localPosition.z();
266 const double z = 0.5 * (localz0 + localz1);
267 assert(not std::isnan(z));
275 const double x = it_tower->second.get_position_fraction_x_in_sub_tower(decoder.
fiber_ID);
276 const double y = it_tower->second.get_position_fraction_y_in_sub_tower(decoder.
fiber_ID);
284 const G4Track *aTrack = aStep->GetTrack();
287 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
312 G4VPhysicalVolume *volume = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume();
315 G4double edep = aStep->GetTotalEnergyDeposit() /
GeV;
316 G4double eion = (aStep->GetTotalEnergyDeposit() - aStep->GetNonIonizingEnergyDeposit()) /
GeV;
318 const G4Track *aTrack = aStep->GetTrack();
327 bool geantino =
false;
331 if (aTrack->GetParticleDefinition()->GetPDGEncoding() == 0 && aTrack->GetParticleDefinition()->GetParticleName().find(
"geantino") != std::string::npos)
335 G4StepPoint *prePoint = aStep->GetPreStepPoint();
336 G4StepPoint *postPoint = aStep->GetPostStepPoint();
353 fiber_ID = prePoint->GetTouchable()->GetReplicaNumber(1);
354 tower_ID = prePoint->GetTouchable()->GetReplicaNumber(2);
355 sector_ID = prePoint->GetTouchable()->GetReplicaNumber(3);
360 fiber_ID = prePoint->GetTouchable()->GetReplicaNumber(0);
361 tower_ID = prePoint->GetTouchable()->GetReplicaNumber(1);
362 sector_ID = prePoint->GetTouchable()->GetReplicaNumber(2);
367 tower_ID = prePoint->GetTouchable()->GetReplicaNumber(0);
368 sector_ID = prePoint->GetTouchable()->GetReplicaNumber(1);
373 tower_ID = prePoint->GetTouchable()->GetReplicaNumber(0);
374 sector_ID = prePoint->GetTouchable()->GetReplicaNumber(1);
388 scint_id = prePoint->GetTouchable()->GetReplicaNumber(2);
392 scint_id = prePoint->GetTouchable()->GetReplicaNumber(1);
396 scint_id = prePoint->GetTouchable()->GetReplicaNumber(0);
403 switch (prePoint->GetStepStatus())
421 m_Hit->
set_t(0, prePoint->GetGlobalTime() / nanosecond);
440 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
452 std::cout <<
"PHG4SpacalSteppingAction: hit outside acceptance, layer: "
453 << layer_id << std::endl;
464 std::cout <<
GetName() <<
": hit was not created" << std::endl;
465 std::cout <<
"prestep status: " << prePoint->GetStepStatus()
473 std::cout <<
GetName() <<
": hits do not belong to the same track" << std::endl;
475 <<
", current trackid: " << aTrack->GetTrackID()
486 m_Hit->
set_t(1, postPoint->GetGlobalTime() / nanosecond);
499 static bool once =
true;
500 if (once and edep > 0)
506 std::cout <<
"PHG4SpacalSteppingAction::UserSteppingAction::"
509 <<
" use scintillating light model at each Geant4 steps. "
512 << aTrack->GetMaterialCutsCouple()->GetMaterial()->GetName()
514 <<
"Birk Constant = "
515 << aTrack->GetMaterialCutsCouple()->GetMaterial()->GetIonisation()->GetBirksConstant()
517 <<
"edep = " << edep <<
", "
520 <<
"light_yield = " << light_yield << std::endl;
529 std::cout <<
"PHG4SpacalSteppingAction: hit outside acceptance get_zmin() "
541 if (G4VUserTrackInformation *
p = aTrack->GetUserInformation())
555 if (postPoint->GetStepStatus() == fGeomBoundary ||
556 postPoint->GetStepStatus() == fWorldBoundary ||
557 postPoint->GetStepStatus() == fAtRestDoItProc ||
558 aTrack->GetTrackStatus() == fStopAndKill)
602 std::cout <<
"PHG4SpacalSteppingAction::SetTopNode - unable to find " <<
m_HitNodeName << std::endl;
606 if (!m_AbsorberHitContainer)
610 std::cout <<
"PHG4SpacalSteppingAction::SetTopNode - unable to find " <<
m_AbsorberNodeName << std::endl;
648 else if (type ==
"G4HIT_ABSORBER")
653 std::cout <<
"Invalid output hit node type " << type << std::endl;