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*);
72 std::map<int, std::pair<G4LogicalVolume*, int> >
mapLV_;
74 std::vector<MaterialInformation>
store_;
86 std::ostringstream st1;
89 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolume: Volumes" << st1.str();
91 produces<edm::MaterialInformationContainer>(
"MaterialInformation");
93 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolume: will produce MaterialInformationContainer";
100 e.put(
std::move(matbg),
"MaterialInformation");
108 <<
" logical volumes with return flag " <<
init_;
114 int iev = (*evt)()->GetEventID();
115 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolume: =====> Begin event = " <<
iev << std::endl;
127 const G4Track* aTrack = (*trk)();
128 const G4ThreeVector& mom = aTrack->GetMomentum();
129 double theEnergy = aTrack->GetTotalEnergy();
130 int theID =
static_cast<int>(aTrack->GetDefinition()->GetPDGEncoding());
131 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolumme: Track " << aTrack->GetTrackID() <<
" Code " << theID
132 <<
" Energy " << theEnergy / CLHEP::GeV <<
" GeV; Momentum " << mom / CLHEP::GeV
138 G4Material* material = aStep->GetPreStepPoint()->GetMaterial();
139 double step = aStep->GetStepLength();
140 double radl = material->GetRadlen();
141 double intl = material->GetNuclearInterLength();
142 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
151 << touch->GetVolume(0)->GetLogicalVolume()->GetName() <<
" Index " <<
index 152 <<
" Step " <<
step <<
" RadL " <<
step / radl <<
" IntL " <<
step / intl;
157 const G4Track* aTrack = (*trk)();
158 int id = aTrack->GetTrackID();
159 double eta = aTrack->GetMomentumDirection().eta();
160 double phi = aTrack->GetMomentumDirection().phi();
161 for (
unsigned int k = 0;
k <
lengths_.size(); ++
k) {
172 unsigned int kount(0);
174 for (
const auto& element :
store_) {
179 element.stepLength(),
180 element.radiationLength(),
181 element.interactionLength());
182 matbg.push_back(
info);
191 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
193 if (lvs !=
nullptr) {
194 std::vector<G4LogicalVolume*>::const_iterator lvcite;
195 for (
unsigned int i = 0;
i <
lvNames_.size();
i++) {
196 G4LogicalVolume* lv =
nullptr;
198 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
199 std::string namx(dd4hep::dd::noNamespace((*lvcite)->GetName()));
210 edm::LogVerbatim(
"MaterialBudget") <<
"MaterialBudgetVolume::Finds " <<
mapLV_.size() <<
" logical volumes";
212 for (
const auto& lvs :
mapLV_) {
213 edm::LogVerbatim(
"MaterialBudget") <<
"Entry[" <<
k <<
"] " << lvs.first <<
": (" << (lvs.second).
first <<
", " 214 << (lvs.second).second <<
") : " <<
lvNames_[lvs.first];
224 int levels = ((touch->GetHistoryDepth()) + 1);
225 for (
const auto& lvs :
mapLV_) {
226 if ((lvs.second).second <=
levels) {
228 if ((touch->GetVolume(
ii)->GetLogicalVolume()) == (lvs.second).first) {
239 <<
" : " << touch->GetVolume(
i)->GetLogicalVolume()->GetName();
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_
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)
MatInfo(double s=0, double r=0, double l=0)
~MaterialBudgetVolume() override