10 #include "G4TransportationManager.hh" 11 #include "CLHEP/Units/GlobalSystemOfUnits.h" 12 #include "CLHEP/Units/GlobalPhysicalConstants.h" 23 count_(0), init_(
false) {
30 std::cout <<
"Name of the mother volume " << motherName_ << std::endl;
33 for (
auto name : LVNames_) {
34 produces<edm::PassiveHitContainer>(Form(
"%sPassiveHits",
name.c_str()));
36 std::cout <<
"Collection name[" << k <<
"] " <<
name << std::endl;
61 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
62 for (
auto lvcite : *lvs) {
67 std::cout <<
"HGCPassive::Finds " <<
mapLV_.size() <<
" logical volumes\n";
69 for (
const auto& lvs :
mapLV_) {
70 std::cout <<
"Entry[" << k <<
"] " << lvs.first <<
": (" 71 << (lvs.second).
first <<
", " << (lvs.second).second <<
")\n";
81 int iev = (*evt)()->GetEventID();
82 edm::LogInfo(
"ValidHGCal") <<
"HGCPassive: =====> Begin event = " 92 if (aStep !=
nullptr) {
94 G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
97 G4TouchableHistory* touchable = (G4TouchableHistory*)aStep->GetPreStepPoint()->GetTouchable();
98 G4LogicalVolume* plv = (G4LogicalVolume*)touchable->GetVolume()->GetLogicalVolume();
100 if (((aStep->GetPostStepPoint() ==
nullptr) ||
101 (aStep->GetTrack()->GetNextVolume() ==
nullptr)) &&
102 (aStep->IsLastStepInVolume())) {
104 std::cout << plv->GetName() <<
" F|L Step " 105 << aStep->IsFirstStepInVolume() <<
":" 106 << aStep->IsLastStepInVolume() <<
" Position" 107 << aStep->GetPreStepPoint()->GetPosition() <<
" Track " 108 << aStep->GetTrack()->GetDefinition()->GetParticleName()
109 <<
" at" << aStep->GetTrack()->GetPosition() <<
" Volume " 110 << aStep->GetTrack()->GetVolume() <<
":" 111 << aStep->GetTrack()->GetNextVolume() <<
" Status " 112 << aStep->GetTrack()->GetTrackStatus() <<
" KE " 113 << aStep->GetTrack()->GetKineticEnergy() <<
" Deposit " 114 << aStep->GetTotalEnergyDeposit() <<
" Map " 115 << (it !=
mapLV_.end()) << std::endl;
117 double time = aStep->GetTrack()->GetGlobalTime();
118 double energy = (aStep->GetPreStepPoint()->GetKineticEnergy() +
122 }
else if (
topLV_ !=
nullptr) {
124 if (itr !=
mapLV_.end()) {
128 }
else if (it !=
mapLV_.end()) {
129 unsigned int copy = (
unsigned int)(touchable->GetReplicaNumber(0) +
130 1000*touchable->GetReplicaNumber(1));
131 double time = (aStep->GetPostStepPoint()->GetGlobalTime());
132 double edeposit = (aStep->GetTotalEnergyDeposit())/
CLHEP::GeV;
133 storeInfo(it, plv, copy, time, edeposit);
134 }
else if (
topLV_ !=
nullptr) {
136 if (itr !=
mapLV_.end()) {
137 double time = (aStep->GetPostStepPoint()->GetGlobalTime());
138 double edeposit = (aStep->GetTotalEnergyDeposit())/
CLHEP::GeV;
152 unsigned int kount(0);
154 for (
const auto& element :
store_) {
155 G4LogicalVolume* lv = (element.first).
first;
156 auto it =
mapLV_.find(lv);
158 if ((it->second).first ==
k) {
160 (element.second).second,(element.second).first);
161 hgcPH.push_back(hit);
163 std::cout <<
"HGCPassive[" << k <<
"] Hit[" << kount <<
"] " << hit
173 return G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
177 auto itr =
mapLV_.find(plv);
178 if (itr ==
mapLV_.end()) {
181 if (name.find(
LVNames_[
k]) != std::string::npos) {
182 mapLV_[plv] = std::pair<unsigned int,std::string>(
k,
name);
195 G4LogicalVolume* plv,
unsigned int copy,
196 double time,
double energy) {
198 std::pair<G4LogicalVolume*,unsigned int>
key(plv,copy);
199 auto itr =
store_.find(key);
200 if (itr ==
store_.end()) {
203 (itr->second).
second += energy;
207 << (it->second).second <<
":" << copy <<
" T " 208 << (itr->second).
first <<
" E " << (itr->second).second
T getParameter(std::string const &) const
#define DEFINE_SIMWATCHER(type)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void endOfEvent(edm::PassiveHitContainer &hgcPH, unsigned int k)
volumeIterator findLV(G4LogicalVolume *plv)
std::map< std::pair< G4LogicalVolume *, unsigned int >, std::pair< double, double > > store_
G4VPhysicalVolume * topPV_
U second(std::pair< T, U > const &p)
G4VPhysicalVolume * getTopPV()
HGCPassive(const edm::ParameterSet &p)
std::vector< std::string > LVNames_
void storeInfo(const volumeIterator itr, G4LogicalVolume *plv, unsigned int copy, double time, double energy)
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