10 #include "G4EventManager.hh" 11 #include "G4LogicalVolumeStore.hh" 12 #include "G4LogicalVolume.hh" 15 #include "G4SystemOfUnits.hh" 29 const std::vector<std::string>& fineNames,
30 const std::vector<int>& fineLevels,
31 const std::vector<int>& useFines,
36 putHistory_(putHistory),
37 doFineCalo_(doFineCalo),
45 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: Have a possibility of " << fineNames.size()
46 <<
" fine calorimeters of which " << useFines.size() <<
" are selected";
47 for (
unsigned int k = 0;
k < fineNames.size(); ++
k)
49 std::ostringstream st1;
50 for (
unsigned int k = 0;
k < useFines.size(); ++
k)
51 st1 <<
" [" <<
k <<
"] " << useFines[
k] <<
":" << fineNames[useFines[
k]];
52 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing used calorimeters" << st1.str();
59 for (
unsigned int i = 0;
i < csps.
levels_.size();
i++)
73 <<
" does not match with " << csps.
neighbours_.size() <<
" ==> illegal ";
75 <<
"Calorimeter array size does not match with size of neighbours\n";
78 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
79 std::vector<G4LogicalVolume*>::const_iterator lvcite;
82 G4LogicalVolume* lv =
nullptr;
84 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
98 <<
" too few compaerd to " << istart + csps.
neighbours_[
i]
99 <<
" requested ==> illegal ";
101 <<
"InsideNames array size does not match with list of neighbours\n";
103 std::vector<std::string> inside;
104 std::vector<G4LogicalVolume*> insideLV;
105 std::vector<int> insideLevels;
109 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
116 inside.push_back(
name);
117 insideLV.push_back(lv);
128 for (
unsigned int i = 0;
i < useFines.size();
i++) {
129 G4LogicalVolume* lv =
nullptr;
130 G4String
name =
static_cast<G4String
>(fineNames[useFines[
i]]);
131 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
142 detector.level = fineLevels[useFines[
i]];
174 G4Track* theTrack = aStep->GetTrack();
175 int id = theTrack->GetTrackID();
179 if (trkInfo ==
nullptr) {
180 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: No trk info !!!! abort ";
181 throw cms::Exception(
"Unknown",
"CaloTrkProcessing") <<
"cannot get trkInfo for Track " <<
id <<
"\n";
193 if (prestepLV < 0 && poststepLV >= 0) {
195 edm::LogVerbatim(
"DoFineCalo") <<
"Track " <<
id <<
" entered a fine volume:" 196 <<
" pdgid=" << theTrack->GetDefinition()->GetPDGEncoding()
197 <<
" theTrack->GetCurrentStepNumber()=" << theTrack->GetCurrentStepNumber()
198 <<
" prestepLV=" << prestepLV <<
" poststepLV=" << poststepLV
199 <<
" GetKineticEnergy[GeV]=" << theTrack->GetKineticEnergy() / CLHEP::GeV
200 <<
" prestepPosition[cm]=(" 201 << theTrack->GetStep()->GetPreStepPoint()->GetPosition().x() / CLHEP::cm <<
"," 202 << theTrack->GetStep()->GetPreStepPoint()->GetPosition().y() / CLHEP::cm <<
"," 203 << theTrack->GetStep()->GetPreStepPoint()->GetPosition().z() / CLHEP::cm <<
")" 204 <<
" poststepPosition[cm]=(" 205 << theTrack->GetStep()->GetPostStepPoint()->GetPosition().x() / CLHEP::cm <<
"," 206 << theTrack->GetStep()->GetPostStepPoint()->GetPosition().y() / CLHEP::cm <<
"," 207 << theTrack->GetStep()->GetPostStepPoint()->GetPosition().z() / CLHEP::cm <<
")" 208 <<
" position[cm]=(" << theTrack->GetPosition().x() / CLHEP::cm <<
"," 209 << theTrack->GetPosition().y() / CLHEP::cm <<
"," 210 << theTrack->GetPosition().z() / CLHEP::cm <<
")" 211 <<
" vertex_position[cm]=(" << theTrack->GetVertexPosition().x() / CLHEP::cm <<
"," 212 << theTrack->GetVertexPosition().y() / CLHEP::cm <<
"," 213 << theTrack->GetVertexPosition().z() / CLHEP::cm <<
")" 214 <<
" GetVertexKineticEnergy[GeV]=" 215 << theTrack->GetVertexKineticEnergy() / CLHEP::GeV;
220 edm::LogVerbatim(
"DoFineCalo") <<
"Track " <<
id <<
" marked as boundary-crossing; sanity check:" 221 <<
" theTrack->GetTrackID()=" << theTrack->GetTrackID()
227 edm::LogVerbatim(
"DoFineCalo") <<
"Track " <<
id <<
" REENTERED a fine volume;" 228 <<
" not counting this boundary crossing!";
234 else if (prestepLV >= 0 && poststepLV < 0) {
235 edm::LogVerbatim(
"DoFineCalo") <<
"Track " <<
id <<
" exited a fine volume:" 236 <<
" theTrack->GetCurrentStepNumber()=" << theTrack->GetCurrentStepNumber()
237 <<
" prestepLV=" << prestepLV <<
" poststepLV=" << poststepLV
238 <<
" GetKineticEnergy[GeV]=" << theTrack->GetKineticEnergy() / CLHEP::GeV
239 <<
" prestepPosition[cm]=(" 240 << theTrack->GetStep()->GetPreStepPoint()->GetPosition().x() / CLHEP::cm <<
"," 241 << theTrack->GetStep()->GetPreStepPoint()->GetPosition().y() / CLHEP::cm <<
"," 242 << theTrack->GetStep()->GetPreStepPoint()->GetPosition().z() / CLHEP::cm <<
")" 243 <<
" poststepPosition[cm]=(" 244 << theTrack->GetStep()->GetPostStepPoint()->GetPosition().x() / CLHEP::cm <<
"," 245 << theTrack->GetStep()->GetPostStepPoint()->GetPosition().y() / CLHEP::cm <<
"," 246 << theTrack->GetStep()->GetPostStepPoint()->GetPosition().z() / CLHEP::cm <<
")";
254 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing set IDonCaloSurface to " <<
id <<
" at step Number " 255 << theTrack->GetCurrentStepNumber();
257 trkInfo->
setIDonCaloSurface(
id, 0, 0, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
259 if (theTrack->GetKineticEnergy() / CLHEP::MeV >
eMin_)
268 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing Entered for " <<
id <<
" at stepNumber " 269 << theTrack->GetCurrentStepNumber() <<
" IDonCaloSur.. " 274 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
275 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
284 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
285 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
288 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
289 const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
291 if (inside >= 0 || (theTrack->GetCurrentStepNumber() == 1)) {
293 id, ical, inside, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
298 if (theTrack->GetKineticEnergy() / CLHEP::MeV >
eMin_)
301 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: set ID on Calo " << ical <<
" surface (Inside " << inside
302 <<
") to " <<
id <<
" of a Track with Kinetic Energy " 303 << theTrack->GetKineticEnergy() / CLHEP::MeV <<
" MeV";
313 G4LogicalVolume* lv =
nullptr;
317 lv =
detLV(touch, lastLevel);
321 name1 = lv->GetName();
322 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
342 G4LogicalVolume* lv =
nullptr;
351 for (
int it1 =
id1; it1 <
id2; it1++) {
353 for (
unsigned int it2 = 0; it2 <
detectors_[it1].fromDets.size(); it2++) {
354 if (lastLevel !=
detectors_[it1].fromLevels[it2]) {
356 lv =
detLV(touch, lastLevel);
360 name1 = lv->GetName();
361 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
378 lv =
detLV(touch, lastLevel);
382 name1 = lv->GetName();
383 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
404 return ((touch->GetHistoryDepth()) + 1);
410 G4LogicalVolume* lv =
nullptr;
412 int level = ((touch->GetHistoryDepth()) + 1);
415 lv = touch->GetVolume(
ii)->GetLogicalVolume();
428 G4VPhysicalVolume*
pv = touch->GetVolume(
i);
433 copyno[
ii] = touch->GetReplicaNumber(
i);
void update(const BeginOfEvent *evt) override
This routine will be called when the appropriate signal arrives.
Log< level::Info, true > LogVerbatim
std::vector< std::string > insideNames_
std::vector< int > levels_
G4LogicalVolume * detLV(const G4VTouchable *, int) const
std::vector< int > insideLevel_
Log< level::Error, false > LogError
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
int isItInside(const G4VTouchable *, int, int)
def detectors(dt=True, csc=True, me42=False, chambers=True, superlayers=False, layers=False)
std::vector< int > neighbours_
std::vector< Detector > fineDetectors_
int detLevels(const G4VTouchable *) const
CaloTrkProcessing(const std::string &aSDname, const CaloSimulationParameters &csps, const SensitiveDetectorCatalog &clg, bool testBeam, double eMin, bool putHistory, bool doFineCalo, double eMinFine, int addlevel, const std::vector< std::string > &fineNames, const std::vector< int > &fineLevels, const std::vector< int > &useFines, const SimTrackManager *)
int isItCalo(const G4VTouchable *, const std::vector< Detector > &)
~CaloTrkProcessing() override
std::string noNameSpace(const std::string &name)
std::vector< std::string > caloNames_
std::vector< Detector > detectors_