14 #include "G4EventManager.hh" 16 #include "G4LogicalVolumeStore.hh" 17 #include "G4LogicalVolume.hh" 21 #include "G4SystemOfUnits.hh" 37 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: Initailised with TestBeam = " << testBeam <<
" Emin = " << eMin
42 G4String attribute =
"ReadOutName";
48 G4String
value =
"Calorimeter";
49 std::vector<std::string> caloNames =
getNames(value,
sv);
51 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
52 for (
unsigned int i = 0;
i < caloNames.size();
i++)
59 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
60 for (
unsigned int i = 0;
i < levels.size();
i++)
67 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
68 for (
unsigned int i = 0;
i < neighbours.size();
i++)
73 std::vector<std::string> insideNames =
getNames(value,
sv);
75 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
76 for (
unsigned int i = 0;
i < insideNames.size();
i++)
80 value =
"InsideLevel";
83 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
84 for (
unsigned int i = 0;
i < insideLevel.size();
i++)
88 if (caloNames.size() < neighbours.size()) {
89 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of Calorimeter bins " << caloNames.size()
90 <<
" does not match with " << neighbours.size() <<
" ==> illegal ";
92 <<
"Calorimeter array size does not match with size of neighbours\n";
95 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
96 std::vector<G4LogicalVolume*>::const_iterator lvcite;
98 for (
unsigned int i = 0;
i < caloNames.size();
i++) {
99 G4LogicalVolume* lv =
nullptr;
100 G4String name = caloNames[
i];
101 int number =
static_cast<int>(neighbours[
i]);
102 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
103 if ((*lvcite)->GetName() ==
name) {
112 detector.
level =
static_cast<int>(levels[
i]);
113 if (istart + number > (
int)(insideNames.size())) {
114 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of InsideNames bins " << insideNames.size()
115 <<
" too few compaerd to " << istart + number <<
" requested ==> illegal ";
117 <<
"InsideNames array size does not match with list of neighbours\n";
119 std::vector<std::string> inside;
120 std::vector<G4LogicalVolume*> insideLV;
121 std::vector<int> insideLevels;
122 for (
int k = 0;
k < number;
k++) {
124 name = insideNames[istart +
k];
125 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
126 if ((*lvcite)->GetName() ==
name) {
130 inside.push_back(name);
131 insideLV.push_back(lv);
132 insideLevels.push_back(static_cast<int>(insideLevel[istart +
k]));
146 <<
detectors[
i].fromDets.size() <<
" neighbours";
147 for (
unsigned int k = 0;
k <
detectors[
i].fromDets.size();
k++)
160 G4Track* theTrack = aStep->GetTrack();
161 int id = theTrack->GetTrackID();
165 if (trkInfo ==
nullptr) {
166 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: No trk info !!!! abort ";
167 throw cms::Exception(
"Unknown",
"CaloTrkProcessing") <<
"cannot get trkInfo for Track " <<
id <<
"\n";
173 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing set IDonCaloSurface to " <<
id <<
" at step Number " 174 << theTrack->GetCurrentStepNumber();
176 trkInfo->
setIDonCaloSurface(
id, 0, 0, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
178 if (theTrack->GetKineticEnergy() /
MeV >
eMin)
187 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing Entered for " <<
id <<
" at stepNumber " 188 << theTrack->GetCurrentStepNumber() <<
" IDonCaloSur.. " 193 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
194 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
203 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
204 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
207 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
208 const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
210 if (inside >= 0 || (theTrack->GetCurrentStepNumber() == 1)) {
212 id, ical, inside, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
215 if (theTrack->GetKineticEnergy() /
MeV >
eMin)
218 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: set ID on Calo " << ical <<
" surface (Inside " << inside
219 <<
") to " <<
id <<
" of a Track with Kinetic Energy " 220 << theTrack->GetKineticEnergy() /
MeV <<
" MeV";
237 const std::vector<std::string>& fvec = value.
strings();
238 int nval = fvec.size();
240 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of " << str <<
" bins " << nval <<
" < 1 ==> illegal ";
241 throw cms::Exception(
"Unknown",
"CaloTrkProcessing") <<
"nval < 2 for array " << str <<
"\n";
247 throw cms::Exception(
"Unknown",
"CaloTrkProcessing") <<
"cannot get array " << str <<
"\n";
260 const std::vector<double>& fvec = value.
doubles();
261 int nval = fvec.size();
263 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of " << str <<
" bins " << nval <<
" < 1 ==> illegal ";
264 throw cms::Exception(
"Unknown",
"CaloTrkProcessing") <<
"nval < 2 for array " << str <<
"\n";
270 throw cms::Exception(
"Unknown",
"CaloTrkProcessing") <<
"cannot get array " << str <<
"\n";
276 G4LogicalVolume* lv =
nullptr;
277 for (
unsigned int it = 0; it <
detectors.size(); it++) {
280 lv =
detLV(touch, lastLevel);
284 name1 = lv->GetName();
285 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
291 for (
int i2 = 0; i2 <
levels; i2++)
292 edm::LogVerbatim(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" " << copyno2[i2];
305 G4LogicalVolume* lv =
nullptr;
309 id2 =
static_cast<int>(
detectors.size());
314 for (
int it1 = id1; it1 <
id2; it1++) {
316 for (
unsigned int it2 = 0; it2 <
detectors[it1].fromDets.size(); it2++) {
317 if (lastLevel !=
detectors[it1].fromLevels[it2]) {
318 lastLevel =
detectors[it1].fromLevels[it2];
319 lv =
detLV(touch, lastLevel);
323 name1 = lv->GetName();
324 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
330 for (
int i2 = 0; i2 <
levels; i2++)
331 edm::LogVerbatim(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" " << copyno2[i2];
340 lastLevel =
detectors[it1].fromLevels[idin];
341 lv =
detLV(touch, lastLevel);
345 name1 = lv->GetName();
346 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
352 for (
int i2 = 0; i2 <
levels; i2++)
353 edm::LogVerbatim(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" " << copyno2[i2];
367 return ((touch->GetHistoryDepth()) + 1);
373 G4LogicalVolume* lv =
nullptr;
375 int level = ((touch->GetHistoryDepth()) + 1);
376 if (level > 0 && level >= currentlevel) {
377 int ii = level - currentlevel;
378 lv = touch->GetVolume(ii)->GetLogicalVolume();
390 int i = level -
ii - 1;
391 G4VPhysicalVolume*
pv = touch->GetVolume(i);
393 name[
ii] = pv->GetName();
396 copyno[
ii] = touch->GetReplicaNumber(i);
void update(const BeginOfEvent *evt) override
This routine will be called when the appropriate signal arrives.
T getParameter(std::string const &) const
G4LogicalVolume * detLV(const G4VTouchable *, int) const
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
CaloTrkProcessing(const std::string &aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *)
int detLevels(const G4VTouchable *) const
int isItCalo(const G4VTouchable *)
Compact representation of the geometrical detector hierarchy.
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
int isItInside(const G4VTouchable *, int, int)
const std::vector< std::string > & getNames() const
std::vector< int > fromLevels
std::vector< Detector > detectors
std::vector< double > getNumbers(G4String, const DDsvalues_type &)
std::vector< G4LogicalVolume * > fromDetL
std::vector< std::string > fromDets
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
~CaloTrkProcessing() override
DDsvalues_type mergedSpecifics() const
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
bool firstChild()
set the current node to the first child ...