10 #include "G4TransportationManager.hh" 11 #include "CLHEP/Units/GlobalSystemOfUnits.h" 12 #include "CLHEP/Units/GlobalPhysicalConstants.h" 23 count_(0), init_(
false) {
33 for (
auto name : LVNames_) {
34 produces<edm::PassiveHitContainer>(Form(
"%sPassiveHits",
name.c_str()));
60 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
61 for (
auto lvcite : *lvs) {
67 <<
" logical volumes";
69 for (
const auto& lvs :
mapLV_) {
71 <<
": (" << (lvs.second).
first <<
", " 72 << (lvs.second).second <<
")";
82 int iev = (*evt)()->GetEventID();
93 if (aStep !=
nullptr) {
95 G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
96 const G4VTouchable* touchable = aStep->GetPreStepPoint()->GetTouchable();
99 G4LogicalVolume* plv = touchable->GetVolume()->GetLogicalVolume();
101 double time = aStep->GetTrack()->GetGlobalTime();
102 double energy = (aStep->GetTotalEnergyDeposit())/
CLHEP::GeV;
104 unsigned int copy(0);
105 if (((aStep->GetPostStepPoint() ==
nullptr) ||
106 (aStep->GetTrack()->GetNextVolume() ==
nullptr)) &&
107 (aStep->IsLastStepInVolume())) {
110 << aStep->IsFirstStepInVolume() <<
":" 111 << aStep->IsLastStepInVolume()
112 <<
" Position" << aStep->GetPreStepPoint()->GetPosition()
113 <<
" Track " << aStep->GetTrack()->GetDefinition()->GetParticleName()
114 <<
" at" << aStep->GetTrack()->GetPosition()
115 <<
" Volume " << aStep->GetTrack()->GetVolume()
116 <<
":" << aStep->GetTrack()->GetNextVolume()
117 <<
" Status " << aStep->GetTrack()->GetTrackStatus()
118 <<
" KE " << aStep->GetTrack()->GetKineticEnergy()
119 <<
" Deposit " << aStep->GetTotalEnergyDeposit()
120 <<
" Map " << (it !=
mapLV_.end());
122 energy += (aStep->GetPreStepPoint()->GetKineticEnergy()/
CLHEP::GeV);
124 time = (aStep->GetPostStepPoint()->GetGlobalTime());
125 copy = (
unsigned int)(touchable->GetReplicaNumber(0) +
126 1000*touchable->GetReplicaNumber(1));
129 storeInfo(it, plv, copy, time, energy,
true);
130 }
else if (
topLV_ !=
nullptr) {
132 if (itr !=
mapLV_.end()) {
139 int level = (touchable->GetHistoryDepth());
141 double energy = (aStep->GetTotalEnergyDeposit())/
CLHEP::GeV;
142 double time = (aStep->GetTrack()->GetGlobalTime());
144 for (
int i=level;
i>0; --
i) {
145 G4LogicalVolume* plv = touchable->GetVolume(
i)->GetLogicalVolume();
149 << plv->GetName() <<
" flag in the List " 154 (
unsigned int)(touchable->GetReplicaNumber(
i) +
155 1000*touchable->GetReplicaNumber(
i+1));
156 storeInfo(it, plv, copy, time, energy,
false);
169 unsigned int kount(0);
171 for (
const auto& element :
store_) {
172 G4LogicalVolume* lv = (element.first).
first;
173 auto it =
mapLV_.find(lv);
175 if ((it->second).first ==
k) {
177 (element.second)[1],(element.second)[2],
178 (element.second)[0]);
179 hgcPH.push_back(hit);
182 << kount <<
"] " << hit;
191 return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
195 auto itr =
mapLV_.find(plv);
196 if (itr ==
mapLV_.end()) {
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,
214 double time,
double energy,
bool flag) {
216 std::pair<G4LogicalVolume*,unsigned int>
key(plv,copy);
217 auto itr =
store_.find(key);
218 double ee = (
flag) ? energy : 0;
219 if (itr ==
store_.end()) {
222 (itr->second)[1] += ee;
223 (itr->second)[2] += energy;
228 << (it->second).
first <<
":" 229 << (it->second).second <<
":" << copy <<
" T " 230 << (itr->second)[0] <<
" E " 231 << (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)
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< G4LogicalVolume *, std::pair< unsigned int, std::string > > mapLV_
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 > >::iterator volumeIterator
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::array< double, 3 > > store_