16 #include "G4LogicalVolumeStore.hh" 19 #include "G4TransportationManager.hh" 20 #include "DD4hep/Filter.h" 22 #include "CLHEP/Units/GlobalPhysicalConstants.h" 23 #include "CLHEP/Units/GlobalSystemOfUnits.h" 38 public Observer<const BeginOfEvent*>,
39 public Observer<const BeginOfTrack*>,
65 int findLV(
const G4VTouchable*);
74 std::map<int, std::pair<G4LogicalVolume*, int> >
mapLV_;
76 std::vector<MaterialInformation>
store_;
89 <<
" volumes with addLevel " <<
iaddLevel_ <<
" and with rMax " <<
rMax_ 90 <<
" mm; zMax " <<
zMax_ <<
" mm";
91 std::ostringstream st1;
94 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolume: Volumes" << st1.str();
96 produces<edm::MaterialInformationContainer>(
"MaterialInformation");
98 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolume: will produce MaterialInformationContainer";
105 e.put(
std::move(matbg),
"MaterialInformation");
113 <<
" logical volumes with return flag " <<
init_;
119 int iev = (*evt)()->GetEventID();
120 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolume: =====> Begin event = " <<
iev << std::endl;
132 const G4Track* aTrack = (*trk)();
133 const G4ThreeVector& mom = aTrack->GetMomentum();
134 double theEnergy = aTrack->GetTotalEnergy();
135 int theID =
static_cast<int>(aTrack->GetDefinition()->GetPDGEncoding());
136 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolumme: Track " << aTrack->GetTrackID() <<
" Code " << theID
137 <<
" Energy " << theEnergy / CLHEP::GeV <<
" GeV; Momentum " << mom / CLHEP::GeV
143 G4Material* material = aStep->GetPreStepPoint()->GetMaterial();
144 double step = aStep->GetStepLength();
145 double radl = material->GetRadlen();
146 double intl = material->GetNuclearInterLength();
147 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
156 << touch->GetVolume(0)->GetLogicalVolume()->GetName() <<
" Index " <<
index 157 <<
" Step " <<
step <<
" RadL " <<
step / radl <<
" IntL " <<
step / intl;
162 G4Track*
track = aStep->GetTrack();
163 track->SetTrackStatus(fStopAndKill);
168 const G4Track* aTrack = (*trk)();
169 int id = aTrack->GetTrackID();
170 double eta = aTrack->GetMomentumDirection().eta();
171 double phi = aTrack->GetMomentumDirection().phi();
172 for (
unsigned int k = 0;
k <
lengths_.size(); ++
k) {
183 unsigned int kount(0);
185 for (
const auto& element :
store_) {
190 element.stepLength(),
191 element.radiationLength(),
192 element.interactionLength());
193 matbg.push_back(
info);
202 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
204 if (lvs !=
nullptr) {
205 std::vector<G4LogicalVolume*>::const_iterator lvcite;
206 for (
unsigned int i = 0;
i <
lvNames_.size();
i++) {
207 G4LogicalVolume* lv =
nullptr;
209 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
210 std::string namx(dd4hep::dd::noNamespace((*lvcite)->GetName()));
221 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolume::Finds " <<
mapLV_.size() <<
" logical volumes";
223 for (
const auto& lvs :
mapLV_) {
224 edm::LogVerbatim(
"MaterialBudget") <<
"Entry[" <<
k <<
"] " << lvs.first <<
": (" << (lvs.second).
first <<
", " 225 << (lvs.second).second <<
") : " <<
lvNames_[lvs.first];
235 int levels = ((touch->GetHistoryDepth()) + 1);
236 for (
const auto& lvs :
mapLV_) {
237 if ((lvs.second).second <=
levels) {
239 if ((touch->GetVolume(
ii)->GetLogicalVolume()) == (lvs.second).first) {
250 <<
" : " << touch->GetVolume(
i)->GetLogicalVolume()->GetName();
259 G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
260 double rr = hitPoint.perp();
265 edm::LogVerbatim(
"MaterialBudget") <<
" MaterialBudgetHcal::StopAfter R = " <<
rr <<
" and Z = " <<
zz;
Log< level::Info, true > LogVerbatim
#define DEFINE_SIMWATCHER(type)
T getParameter(std::string const &) const
TkSoAView< TrackerTraits > HitToTuple< TrackerTraits > const *__restrict__ int32_t int32_t int iev
MaterialBudgetVolume(const edm::ParameterSet &p)
std::vector< MatInfo > lengths_
void produce(edm::Event &, const edm::EventSetup &) override
std::map< int, std::pair< G4LogicalVolume *, int > > mapLV_
U second(std::pair< T, U > const &p)
std::vector< MaterialInformation > store_
std::vector< std::string > lvNames_
Abs< T >::type abs(const T &t)
int findLV(const G4VTouchable *)
std::vector< MaterialInformation > MaterialInformationContainer
const MaterialBudgetVolume & operator=(const MaterialBudgetVolume &)=delete
void update(const BeginOfRun *run) override
This routine will be called when the appropriate signal arrives.
std::vector< int > lvLevel_
void endOfEvent(edm::MaterialInformationContainer &matbg)
bool stopAfter(const G4Step *)
MatInfo(double s=0, double r=0, double l=0)
~MaterialBudgetVolume() override