14 #include "G4EventManager.hh" 16 #include "G4LogicalVolumeStore.hh" 17 #include "G4LogicalVolume.hh" 21 #include "G4SystemOfUnits.hh" 40 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: Initailised with TestBeam = " << testBeam_ <<
" Emin = " << eMin_
41 <<
":" << eMinFine_ <<
":" << eMinFinePhoton_ <<
" MeV and Flags " << putHistory_
42 <<
" (History), " << doFineCalo_ <<
" (Special Calorimeter)";
54 for (
unsigned int i = 0;
i < csp->
levels_.size();
i++)
66 <<
" entries for fineCalorimeterNames:";
70 <<
" entries for fineCalorimeterLevels:";
71 for (
unsigned int i = 0;
i < csp->
fLevels_.size();
i++)
77 <<
" does not match with " << csp->
neighbours_.size() <<
" ==> illegal ";
79 <<
"Calorimeter array size does not match with size of neighbours\n";
82 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
83 std::vector<G4LogicalVolume*>::const_iterator lvcite;
86 G4LogicalVolume* lv =
nullptr;
87 G4String name =
static_cast<G4String
>(csp->
caloNames_[
i]);
88 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
89 if ((*lvcite)->GetName() ==
name) {
101 <<
" too few compaerd to " << istart + csp->
neighbours_[
i]
102 <<
" requested ==> illegal ";
104 <<
"InsideNames array size does not match with list of neighbours\n";
106 std::vector<std::string> inside;
107 std::vector<G4LogicalVolume*> insideLV;
108 std::vector<int> insideLevels;
112 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
113 if ((*lvcite)->GetName() ==
name) {
118 inside.push_back(name);
119 insideLV.push_back(lv);
131 G4LogicalVolume* lv =
nullptr;
132 G4String name =
static_cast<G4String
>(csp->
fCaloNames_[
i]);
133 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
134 if ((*lvcite)->GetName() ==
name) {
151 edm::LogError(
"HcalSim") <<
"CaloTrkProcessing: Cannot find CaloSimulationParameters";
152 throw cms::Exception(
"Unknown",
"CaloSD") <<
"Cannot find CaloSimulationParameters\n";
179 G4Track* theTrack = aStep->GetTrack();
180 int id = theTrack->GetTrackID();
184 if (trkInfo ==
nullptr) {
185 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: No trk info !!!! abort ";
186 throw cms::Exception(
"Unknown",
"CaloTrkProcessing") <<
"cannot get trkInfo for Track " <<
id <<
"\n";
192 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing set IDonCaloSurface to " <<
id <<
" at step Number " 193 << theTrack->GetCurrentStepNumber();
195 trkInfo->
setIDonCaloSurface(
id, 0, 0, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
197 if (theTrack->GetKineticEnergy() /
MeV >
eMin_)
206 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing Entered for " <<
id <<
" at stepNumber " 207 << theTrack->GetCurrentStepNumber() <<
" IDonCaloSur.. " 212 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
213 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
222 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
223 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
226 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
227 const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
229 if (inside >= 0 || (theTrack->GetCurrentStepNumber() == 1)) {
231 id, ical, inside, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
234 if (theTrack->GetKineticEnergy() /
MeV >
eMin_)
237 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: set ID on Calo " << ical <<
" surface (Inside " << inside
238 <<
") to " <<
id <<
" of a Track with Kinetic Energy " 239 << theTrack->GetKineticEnergy() /
MeV <<
" MeV";
246 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
248 int pdg = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
250 if (aStep->GetTrack()->GetKineticEnergy() /
MeV >
cut)
253 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: the track with PDGID " << pdg <<
" and kinetic energy " 254 << aStep->GetTrack()->GetKineticEnergy() /
MeV <<
" is tested against " << cut
255 <<
" to be put in history";
263 G4LogicalVolume* lv =
nullptr;
264 for (
unsigned int it = 0; it < detectors.size(); it++) {
265 if (lastLevel != detectors[it].
level) {
266 lastLevel = detectors[it].level;
267 lv =
detLV(touch, lastLevel);
271 name1 = lv->GetName();
272 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
283 bool ok = (lv == detectors[it].lv);
292 G4LogicalVolume* lv =
nullptr;
301 for (
int it1 = id1; it1 <
id2; it1++) {
303 for (
unsigned int it2 = 0; it2 <
detectors_[it1].fromDets.size(); it2++) {
304 if (lastLevel !=
detectors_[it1].fromLevels[it2]) {
306 lv =
detLV(touch, lastLevel);
310 name1 = lv->GetName();
311 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
328 lv =
detLV(touch, lastLevel);
332 name1 = lv->GetName();
333 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
354 return ((touch->GetHistoryDepth()) + 1);
360 G4LogicalVolume* lv =
nullptr;
362 int level = ((touch->GetHistoryDepth()) + 1);
363 if (level > 0 && level >= currentlevel) {
364 int ii = level - currentlevel;
365 lv = touch->GetVolume(ii)->GetLogicalVolume();
377 int i = level -
ii - 1;
378 G4VPhysicalVolume*
pv = touch->GetVolume(i);
380 name[
ii] = pv->GetName();
383 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
std::vector< std::string > insideNames_
int detLevels(const G4VTouchable *) const
std::vector< int > levels_
std::vector< int > insideLevel_
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
std::vector< int > fLevels_
std::vector< std::string > fCaloNames_
int isItInside(const G4VTouchable *, int, int)
CaloTrkProcessing(const std::string &aSDname, const edm::EventSetup &es, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *)
def detectors(dt=True, csc=True, me42=False, chambers=True, superlayers=False, layers=False)
std::vector< int > neighbours_
std::vector< int > fromLevels
std::vector< Detector > fineDetectors_
std::vector< G4LogicalVolume * > fromDetL
std::vector< std::string > fromDets
int isItCalo(const G4VTouchable *, const std::vector< Detector > &)
~CaloTrkProcessing() override
T const * product() const
std::vector< std::string > caloNames_
std::vector< Detector > detectors_