10 #include "CLHEP/Units/GlobalPhysicalConstants.h" 11 #include "CLHEP/Units/GlobalSystemOfUnits.h" 12 #include "G4TransportationManager.hh" 31 for (
auto name : LVNames_) {
32 produces<edm::PassiveHitContainer>(Form(
"%sPassiveHits",
name.c_str()));
43 for (
unsigned int k = 0;
k <
LVNames_.size(); ++
k) {
56 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
57 for (
auto lvcite : *lvs) {
64 for (
const auto& lvs :
mapLV_) {
65 edm::LogVerbatim(
"ValidHGCal") <<
"Entry[" << k <<
"] " << lvs.first <<
": (" << (lvs.second).
first <<
", " 66 << (lvs.second).second <<
")";
75 int iev = (*evt)()->GetEventID();
76 edm::LogVerbatim(
"ValidHGCal") <<
"HGCPassive: =====> Begin event = " << iev << std::endl;
85 if (aStep !=
nullptr) {
86 G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
87 const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable();
89 if (curSD ==
nullptr) {
90 G4LogicalVolume* plv = touchable->GetVolume()->GetLogicalVolume();
92 double time = aStep->GetTrack()->GetGlobalTime();
96 if (((aStep->GetPostStepPoint() ==
nullptr) || (aStep->GetTrack()->GetNextVolume() ==
nullptr)) &&
97 (aStep->IsLastStepInVolume())) {
99 edm::LogVerbatim(
"ValidHGCal") << plv->GetName() <<
" F|L Step " << aStep->IsFirstStepInVolume() <<
":" 100 << aStep->IsLastStepInVolume() <<
" Position" 101 << aStep->GetPreStepPoint()->GetPosition() <<
" Track " 102 << aStep->GetTrack()->GetDefinition()->GetParticleName() <<
" at" 103 << aStep->GetTrack()->GetPosition() <<
" Volume " 104 << aStep->GetTrack()->GetVolume() <<
":" << aStep->GetTrack()->GetNextVolume()
105 <<
" Status " << aStep->GetTrack()->GetTrackStatus() <<
" KE " 106 << aStep->GetTrack()->GetKineticEnergy() <<
" Deposit " 107 << aStep->GetTotalEnergyDeposit() <<
" Map " << (it !=
mapLV_.end());
109 energy += (aStep->GetPreStepPoint()->GetKineticEnergy() /
CLHEP::GeV);
111 time = (aStep->GetPostStepPoint()->GetGlobalTime());
112 copy = (
unsigned int)(touchable->GetReplicaNumber(0) + 1000 * touchable->GetReplicaNumber(1));
115 storeInfo(it, plv, copy, time, energy,
true);
116 }
else if (
topLV_ !=
nullptr) {
118 if (itr !=
mapLV_.end()) {
125 int level = (touchable->GetHistoryDepth());
128 double time = (aStep->GetTrack()->GetGlobalTime());
130 for (
int i = level;
i > 0; --
i) {
131 G4LogicalVolume* plv = touchable->GetVolume(
i)->GetLogicalVolume();
134 edm::LogVerbatim(
"ValidHGCal") <<
"Level: " <<
ii <<
":" <<
i <<
" " << plv->GetName() <<
" flag in the List " 140 : (
unsigned int)(touchable->GetReplicaNumber(
i) + 1000 * touchable->GetReplicaNumber(
i + 1));
141 storeInfo(it, plv, copy, time, energy,
false);
153 unsigned int kount(0);
155 for (
const auto& element :
store_) {
156 G4LogicalVolume* lv = (element.first).
first;
157 auto it =
mapLV_.find(lv);
159 if ((it->second).first ==
k) {
161 (it->second).second, (element.first).second, (element.second)[1], (element.second)[2], (element.second)[0]);
162 hgcPH.push_back(hit);
164 edm::LogVerbatim(
"ValidHGCal") <<
"HGCPassive[" << k <<
"] Hit[" << kount <<
"] " << hit;
173 return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
177 auto itr =
mapLV_.find(plv);
178 if (itr ==
mapLV_.end()) {
180 for (
unsigned int k = 0;
k <
LVNames_.size(); ++
k) {
181 if (name.find(
LVNames_[
k]) != std::string::npos) {
182 mapLV_[plv] = std::pair<unsigned int, std::string>(
k,
name);
196 G4LogicalVolume* plv,
201 std::pair<G4LogicalVolume*, unsigned int>
key(plv, copy);
202 auto itr =
store_.find(key);
203 double ee = (
flag) ? energy : 0;
204 if (itr ==
store_.end()) {
207 (itr->second)[1] += ee;
208 (itr->second)[2] += energy;
212 edm::LogVerbatim(
"ValidHGCal") <<
"HGCPassive: Element " << (it->second).
first <<
":" << (it->second).second <<
":" 213 << copy <<
" T " << (itr->second)[0] <<
" E " << (itr->second)[1] <<
":" T getParameter(std::string const &) const
#define DEFINE_SIMWATCHER(type)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void storeInfo(const volumeIterator itr, G4LogicalVolume *plv, unsigned int copy, double time, double energy, bool flag)
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > >::iterator volumeIterator
void endOfEvent(edm::PassiveHitContainer &hgcPH, unsigned int k)
volumeIterator findLV(G4LogicalVolume *plv)
G4VPhysicalVolume * topPV_
G4VPhysicalVolume * getTopPV()
HGCPassive(const edm::ParameterSet &p)
std::vector< std::string > LVNames_
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< PassiveHit > PassiveHitContainer
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_
void update(const BeginOfRun *run) override
This routine will be called when the appropriate signal arrives.
std::map< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_