10 #include "CLHEP/Units/GlobalPhysicalConstants.h" 11 #include "CLHEP/Units/GlobalSystemOfUnits.h" 12 #include "G4TransportationManager.hh" 32 for (
auto name : LVNames_) {
33 produces<edm::PassiveHitContainer>(Form(
"%sPassiveHits",
name.c_str()));
44 for (
unsigned int k = 0;
k <
LVNames_.size(); ++
k) {
45 std::unique_ptr<edm::PassiveHitContainer> hgcPH(
58 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
59 for (
auto lvcite : *lvs) {
65 <<
"HGCPassive::Finds " <<
mapLV_.size() <<
" logical volumes";
67 for (
const auto& lvs :
mapLV_) {
69 <<
"Entry[" << k <<
"] " << lvs.first <<
": (" << (lvs.second).
first 70 <<
", " << (lvs.second).second <<
")";
79 int iev = (*evt)()->GetEventID();
81 <<
"HGCPassive: =====> Begin event = " << iev << std::endl;
90 if (aStep !=
nullptr) {
91 G4VSensitiveDetector* curSD =
92 aStep->GetPreStepPoint()->GetSensitiveDetector();
93 const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable();
95 if (curSD ==
nullptr) {
96 G4LogicalVolume* plv = touchable->GetVolume()->GetLogicalVolume();
98 double time = aStep->GetTrack()->GetGlobalTime();
99 double energy = (aStep->GetTotalEnergyDeposit()) /
CLHEP::GeV;
101 unsigned int copy(0);
102 if (((aStep->GetPostStepPoint() ==
nullptr) ||
103 (aStep->GetTrack()->GetNextVolume() ==
nullptr)) &&
104 (aStep->IsLastStepInVolume())) {
107 << plv->GetName() <<
" F|L Step " << aStep->IsFirstStepInVolume()
108 <<
":" << aStep->IsLastStepInVolume() <<
" Position" 109 << aStep->GetPreStepPoint()->GetPosition() <<
" Track " 110 << aStep->GetTrack()->GetDefinition()->GetParticleName() <<
" at" 111 << aStep->GetTrack()->GetPosition() <<
" Volume " 112 << aStep->GetTrack()->GetVolume() <<
":" 113 << aStep->GetTrack()->GetNextVolume() <<
" Status " 114 << aStep->GetTrack()->GetTrackStatus() <<
" KE " 115 << aStep->GetTrack()->GetKineticEnergy() <<
" Deposit " 116 << aStep->GetTotalEnergyDeposit() <<
" Map " 119 energy += (aStep->GetPreStepPoint()->GetKineticEnergy() /
CLHEP::GeV);
121 time = (aStep->GetPostStepPoint()->GetGlobalTime());
122 copy = (
unsigned int)(touchable->GetReplicaNumber(0) +
123 1000 * touchable->GetReplicaNumber(1));
126 storeInfo(it, plv, copy, time, energy,
true);
127 }
else if (
topLV_ !=
nullptr) {
129 if (itr !=
mapLV_.end()) {
136 int level = (touchable->GetHistoryDepth());
138 double energy = (aStep->GetTotalEnergyDeposit()) /
CLHEP::GeV;
139 double time = (aStep->GetTrack()->GetGlobalTime());
141 for (
int i = level;
i > 0; --
i) {
142 G4LogicalVolume* plv = touchable->GetVolume(
i)->GetLogicalVolume();
146 <<
"Level: " <<
ii <<
":" <<
i <<
" " << plv->GetName()
147 <<
" flag in the List " << (it !=
mapLV_.end());
153 : (
unsigned int)(touchable->GetReplicaNumber(
i) +
154 1000 * touchable->GetReplicaNumber(
i + 1));
155 storeInfo(it, plv, copy, time, energy,
false);
167 unsigned int kount(0);
169 for (
const auto& element :
store_) {
170 G4LogicalVolume* lv = (element.first).
first;
171 auto it =
mapLV_.find(lv);
173 if ((it->second).first ==
k) {
175 (element.second)[1], (element.second)[2],
176 (element.second)[0]);
177 hgcPH.push_back(hit);
180 <<
"HGCPassive[" << k <<
"] Hit[" << kount <<
"] " << hit;
189 return G4TransportationManager::GetTransportationManager()
190 ->GetNavigatorForTracking()
195 auto itr =
mapLV_.find(plv);
196 if (itr ==
mapLV_.end()) {
198 for (
unsigned int k = 0;
k <
LVNames_.size(); ++
k) {
199 if (name.find(
LVNames_[
k]) != std::string::npos) {
200 mapLV_[plv] = std::pair<unsigned int, std::string>(
k,
name);
213 G4LogicalVolume* plv,
unsigned int copy,
double time,
214 double energy,
bool flag) {
215 std::pair<G4LogicalVolume*, unsigned int>
key(plv, copy);
216 auto itr =
store_.find(key);
217 double ee = (
flag) ? energy : 0;
218 if (itr ==
store_.end()) {
221 (itr->second)[1] += ee;
222 (itr->second)[2] += energy;
227 <<
"HGCPassive: Element " << (it->second).
first <<
":" 228 << (it->second).second <<
":" << copy <<
" T " << (itr->second)[0]
229 <<
" E " << (itr->second)[1] <<
":" << (itr->second)[2];
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_