14 #include "G4EventManager.hh" 16 #include "G4LogicalVolumeStore.hh" 17 #include "G4LogicalVolume.hh" 21 #include "G4SystemOfUnits.hh" 31 m_trackManager(manager) {
39 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Initailised with TestBeam = " 40 << testBeam <<
" Emin = " << eMin <<
" MeV and" 44 G4String attribute =
"ReadOutName";
50 G4String
value =
"Calorimeter";
51 std::vector<std::string> caloNames =
getNames (value,
sv);
53 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
54 for (
unsigned int i=0;
i<caloNames.size();
i++)
55 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << caloNames[
i];
61 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
62 for (
unsigned int i=0;
i<levels.size();
i++)
63 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << levels[
i];
69 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
70 for (
unsigned int i=0;
i<neighbours.size();
i++)
71 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << neighbours[
i];
75 std::vector<std::string> insideNames =
getNames (value,
sv);
77 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
78 for (
unsigned int i=0;
i<insideNames.size();
i++)
79 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << insideNames[
i];
82 value =
"InsideLevel";
83 std::vector<double> insideLevel =
getNumbers (value,
sv);
85 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: Names for " << value <<
":";
86 for (
unsigned int i=0;
i<insideLevel.size();
i++)
87 LogDebug(
"CaloSim") <<
" (" <<
i <<
") " << insideLevel[
i];
90 if (caloNames.size() < neighbours.size()) {
91 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of Calorimeter bins " 92 << caloNames.size() <<
" does not match with " 93 << neighbours.size() <<
" ==> illegal ";
95 <<
"Calorimeter array size does not match with size of neighbours\n";
98 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
99 std::vector<G4LogicalVolume *>::const_iterator lvcite;
101 for (
unsigned int i=0;
i<caloNames.size();
i++) {
102 G4LogicalVolume* lv =
nullptr;
103 G4String name = caloNames[
i];
104 int number =
static_cast<int>(neighbours[
i]);
105 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
106 if ((*lvcite)->GetName() ==
name) {
115 detector.
level =
static_cast<int>(levels[
i]);
116 if (istart+number > (
int)(insideNames.size())) {
117 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of InsideNames bins " 118 << insideNames.size() <<
" too few compaerd to " 119 << istart+number <<
" requested ==> illegal ";
121 <<
"InsideNames array size does not match with list of neighbours\n";
123 std::vector<std::string> inside;
124 std::vector<G4LogicalVolume*> insideLV;
125 std::vector<int> insideLevels;
126 for (
int k = 0;
k < number;
k++) {
128 name = insideNames[istart+
k];
129 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
130 if ((*lvcite)->GetName() ==
name) {
134 inside.push_back(name);
135 insideLV.push_back(lv);
136 insideLevels.push_back(static_cast<int>(insideLevel[istart+
k]));
147 <<
" calorimetric volumes";
149 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Calorimeter volume " <<
i 153 <<
detectors[
i].fromDets.size() <<
" neighbours";
163 edm::LogInfo(
"CaloSim") <<
"CaloTrkProcessing: Deleted";
174 G4Track* theTrack = aStep->GetTrack();
175 int id = theTrack->GetTrackID();
178 (theTrack->GetUserInformation());
180 if (trkInfo ==
nullptr) {
181 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: No trk info !!!! abort ";
183 <<
"cannot get trkInfo for Track " <<
id <<
"\n";
189 LogDebug(
"CaloSim") <<
"CaloTrkProcessing set IDonCaloSurface to " <<
id 190 <<
" at step Number " 191 << theTrack->GetCurrentStepNumber();
194 theTrack->GetDefinition()->GetPDGEncoding(),
195 theTrack->GetMomentum().mag());
197 if (theTrack->GetKineticEnergy()/
MeV >
eMin)
206 LogDebug(
"CaloSim") <<
"CaloTrkProcessing Entered for " <<
id 207 <<
" at stepNumber "<< theTrack->GetCurrentStepNumber()
213 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
214 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
224 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
225 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
228 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
229 const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
231 if (inside >= 0 || (theTrack->GetCurrentStepNumber()==1)) {
233 theTrack->GetDefinition()->GetPDGEncoding(),
234 theTrack->GetMomentum().mag());
239 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: set ID on Calo " << ical
240 <<
" surface (Inside " << inside <<
") to " 241 <<
id <<
" of a Track with Kinetic Energy " 242 << theTrack->GetKineticEnergy()/
MeV <<
" MeV";
254 LogDebug(
"CaloSim") <<
"CaloTrkProcessing::getNames called for " <<
str;
261 const std::vector<std::string> & fvec = value.
strings();
262 int nval = fvec.size();
265 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of " << str
266 <<
" bins " << nval <<
" < 1 ==> illegal ";
268 <<
"nval < 2 for array " << str <<
"\n";
275 <<
"cannot get array " << str <<
"\n";
283 LogDebug(
"CaloSim") <<
"CaloTrkProcessing::getNumbers called for " <<
str;
290 const std::vector<double> & fvec = value.
doubles();
291 int nval = fvec.size();
293 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: # of " << str
294 <<
" bins " << nval <<
" < 1 ==> illegal ";
296 <<
"nval < 2 for array " << str <<
"\n";
303 <<
"cannot get array " << str <<
"\n";
310 G4LogicalVolume* lv=
nullptr;
311 for (
unsigned int it=0; it <
detectors.size(); it++) {
314 lv =
detLV(touch, lastLevel);
317 if (lv != 0) name1 = lv->GetName();
318 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
319 <<
" at Level " << lastLevel;
322 G4String name2[20];
int copyno2[20];
324 for (
int i2=0; i2<
levels; i2++)
325 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" " 339 G4LogicalVolume* lv=
nullptr;
341 if (idcal < 0) {id1 = 0; id2 =
static_cast<int>(
detectors.size());}
342 else {id1 = idcal; id2 = id1+1;}
343 for (
int it1 = id1; it1 <
id2; it1++) {
345 for (
unsigned int it2 = 0; it2 <
detectors[it1].fromDets.size(); it2++) {
346 if (lastLevel !=
detectors[it1].fromLevels[it2]) {
347 lastLevel =
detectors[it1].fromLevels[it2];
348 lv =
detLV(touch,lastLevel);
351 if (lv != 0) name1 = lv->GetName();
352 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
353 <<
" at Level " << lastLevel;
356 G4String name2[20];
int copyno2[20];
358 for (
int i2=0; i2<
levels; i2++)
359 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" " 368 lastLevel =
detectors[it1].fromLevels[idin];
369 lv =
detLV(touch,lastLevel);
372 if (lv != 0) name1 = lv->GetName();
373 LogDebug(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1
374 <<
" at Level " << lastLevel;
377 G4String name2[20];
int copyno2[20];
379 for (
int i2=0; i2<
levels; i2++)
380 LogDebug(
"CaloSim") <<
" " << i2 <<
" " << name2[i2] <<
" " 395 return ((touch->GetHistoryDepth())+1);
401 int currentlevel)
const {
403 G4LogicalVolume* lv=
nullptr;
405 int level = ((touch->GetHistoryDepth())+1);
406 if (level > 0 && level >= currentlevel) {
407 int ii = level - currentlevel;
408 lv = touch->GetVolume(ii)->GetLogicalVolume();
416 int* copyno, G4String*
name)
const {
422 int i = level -
ii - 1;
423 G4VPhysicalVolume*
pv = touch->GetVolume(i);
425 name[
ii] = pv->GetName();
428 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< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
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
bool firstChild()
set the current node to the first child ...