Skip to content

Commit

Permalink
Merge pull request #28637 from mrodozov/update-geant-branch-to-41060-…
Browse files Browse the repository at this point in the history
…second-try

[Geant4] Code adjustment for new Geant4 version
  • Loading branch information
cmsbuild committed Dec 19, 2019
2 parents ec4c535 + 06c80ed commit fb33c64
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 43 deletions.
9 changes: 5 additions & 4 deletions SimG4CMS/Calo/src/CaloSD.cc
Expand Up @@ -321,8 +321,9 @@ bool CaloSD::checkHit() {
found = true;
}
} else if (nCheckedHits > 0) {
int minhit = (theHC->entries() > nCheckedHits ? theHC->entries() - nCheckedHits : 0);
int maxhit = theHC->entries() - 1;
int nhits = theHC->entries();
int minhit = std::max(nhits - nCheckedHits, 0);
int maxhit = nhits - 1;

for (int j = maxhit; j > minhit; --j) {
if ((*theHC)[j]->getID() == currentID) {
Expand Down Expand Up @@ -503,8 +504,8 @@ void CaloSD::update(const ::EndOfEvent*) {
double zloc(0.0);
double zglob(0.0);
double ee(0.0);

for (int i = 0; i < theHC->entries(); ++i) {
int hc_entries = theHC->entries();
for (int i = 0; i < hc_entries; ++i) {
if (!saveHit((*theHC)[i])) {
++wrong;
}
Expand Down
9 changes: 6 additions & 3 deletions SimG4CMS/Calo/src/HcalTestAnalysis.cc
Expand Up @@ -325,8 +325,9 @@ void HcalTestAnalysis::fill(const EndOfEvent* evt) {
CaloG4HitCollection* theHCHC = (CaloG4HitCollection*)allHC->GetHC(HCHCid);
edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[0] << " of ID " << HCHCid
<< " is obtained at " << theHCHC;
int hchc_entries = theHCHC->entries();
if (HCHCid >= 0 && theHCHC != nullptr) {
for (j = 0; j < theHCHC->entries(); j++) {
for (j = 0; j < hchc_entries; j++) {
CaloG4Hit* aHit = (*theHCHC)[j];

double e = aHit->getEnergyDeposit() / GeV;
Expand Down Expand Up @@ -371,8 +372,9 @@ void HcalTestAnalysis::fill(const EndOfEvent* evt) {
CaloG4HitCollection* theEBHC = (CaloG4HitCollection*)allHC->GetHC(EBHCid);
edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[1] << " of ID " << EBHCid
<< " is obtained at " << theEBHC;
int ebhc_entries = theEBHC->entries();
if (EBHCid >= 0 && theEBHC != nullptr) {
for (j = 0; j < theEBHC->entries(); j++) {
for (j = 0; j < ebhc_entries; j++) {
CaloG4Hit* aHit = (*theEBHC)[j];

double e = aHit->getEnergyDeposit() / GeV;
Expand Down Expand Up @@ -407,8 +409,9 @@ void HcalTestAnalysis::fill(const EndOfEvent* evt) {
CaloG4HitCollection* theEEHC = (CaloG4HitCollection*)allHC->GetHC(EEHCid);
edm::LogVerbatim("HcalSim") << "HcalTestAnalysis :: Hit Collection for " << names_[2] << " of ID " << EEHCid
<< " is obtained at " << theEEHC;
int eehc_entries = theEEHC->entries();
if (EEHCid >= 0 && theEEHC != nullptr) {
for (j = 0; j < theEEHC->entries(); j++) {
for (j = 0; j < eehc_entries; j++) {
CaloG4Hit* aHit = (*theEEHC)[j];

double e = aHit->getEnergyDeposit() / GeV;
Expand Down
7 changes: 4 additions & 3 deletions SimG4CMS/FP420/plugins/FP420SD.cc
Expand Up @@ -195,8 +195,8 @@ G4bool FP420SD::HitExists() {
G4bool found = false;

// LogDebug("FP420Sim") << "FP420SD: HCollection= " << theHC->entries() <<std::endl;

for (int j = 0; j < theHC->entries() && !found; j++) {
int nhits = theHC->entries();
for (int j = 0; j < nhits && !found; j++) {
FP420G4Hit* aPreviousHit = (*theHC)[j];
if (aPreviousHit->getTrackID() == primaryID && aPreviousHit->getTimeSliceID() == tSliceID &&
aPreviousHit->getUnitID() == unitID) {
Expand Down Expand Up @@ -333,7 +333,8 @@ void FP420SD::EndOfEvent(G4HCofThisEvent*) {
// for (int j=0; j<theHC->entries() && j<100; j++) {
int nhitsHPS240 = 0;
int nhitsFP420 = 0;
for (int j = 0; j < theHC->entries(); j++) {
int nhits = theHC->entries();
for (int j = 0; j < nhits; j++) {
FP420G4Hit* aHit = (*theHC)[j];
if ((fabs(aHit->getTof()) > 780. && fabs(aHit->getTof()) < 840.))
++nhitsHPS240;
Expand Down
8 changes: 4 additions & 4 deletions SimG4CMS/FP420/plugins/FP420Test.cc
Expand Up @@ -953,8 +953,8 @@ void FP420Test::update(const EndOfEvent* evt) {
//UserNtuples->fillg67(theCAFI->entries(),1.);
varia = 2;
} // no MI end:

for (int j = 0; j < theCAFI->entries(); j++) {
int nhits = theCAFI->entries();
for (int j = 0; j < nhits; j++) {
FP420G4Hit* aHit = (*theCAFI)[j];
G4ThreeVector hitPoint = aHit->getEntry();
double zz = hitPoint.z();
Expand All @@ -973,7 +973,7 @@ void FP420Test::update(const EndOfEvent* evt) {
// .............
int nhit11 = 0, nhit12 = 0, nhit13 = 0;
double totallosenergy = 0.;
for (int j = 0; j < theCAFI->entries(); j++) {
for (int j = 0; j < nhits; j++) {
FP420G4Hit* aHit = (*theCAFI)[j];

G4ThreeVector hitEntryLocalPoint = aHit->getEntryLocalP();
Expand Down Expand Up @@ -1297,7 +1297,7 @@ void FP420Test::update(const EndOfEvent* evt) {
//======================================================================================================CHECK
if (totallosenergy == 0.0) {
std::cout << "FP420Test: number of hits = " << theCAFI->entries() << std::endl;
for (int j = 0; j < theCAFI->entries(); j++) {
for (int j = 0; j < nhits; j++) {
FP420G4Hit* aHit = (*theCAFI)[j];
double losenergy = aHit->getEnergyLoss();
std::cout << " j hits = " << j << "losenergy = " << losenergy << std::endl;
Expand Down
7 changes: 4 additions & 3 deletions SimG4CMS/Forward/src/BscTest.cc
Expand Up @@ -627,7 +627,8 @@ void BscTest::update(const EndOfEvent* evt) {
} else {
varia = 2;
} // no MI end:
for (int j = 0; j < theCAFI->entries(); j++) {
int nhits = theCAFI->entries();
for (int j = 0; j < nhits; j++) {
BscG4Hit* aHit = (*theCAFI)[j];
const CLHEP::Hep3Vector& hitPoint = aHit->getEntry();
double zz = hitPoint.z();
Expand All @@ -639,7 +640,7 @@ void BscTest::update(const EndOfEvent* evt) {
if (varia == 2) {
int nhit11 = 0, nhit12 = 0, nhit13 = 0;
double totallosenergy = 0.;
for (int j = 0; j < theCAFI->entries(); j++) {
for (int j = 0; j < nhits; j++) {
BscG4Hit* aHit = (*theCAFI)[j];

const CLHEP::Hep3Vector& hitEntryLocalPoint = aHit->getEntryLocalP();
Expand Down Expand Up @@ -782,7 +783,7 @@ void BscTest::update(const EndOfEvent* evt) {
} // MIonly or noMIonly ENDED
if (totallosenergy == 0.0) {
std::cout << "BscTest: number of hits = " << theCAFI->entries() << std::endl;
for (int j = 0; j < theCAFI->entries(); j++) {
for (int j = 0; j < nhits; j++) {
BscG4Hit* aHit = (*theCAFI)[j];
double losenergy = aHit->getEnergyLoss();
std::cout << " j hits = " << j << "losenergy = " << losenergy << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion SimG4CMS/Forward/src/TimingSD.cc
Expand Up @@ -201,7 +201,8 @@ bool TimingSD::hitExists(const G4Step* aStep) {
//tSliceID already exists:

bool found = false;
for (int j = 0; j < theHC->entries(); ++j) {
int thehc_entries = theHC->entries();
for (int j = 0; j < thehc_entries; ++j) {
BscG4Hit* aHit = (*theHC)[j];
if (aHit->getTimeSliceID() == tSliceID && aHit->getUnitID() == unitID) {
if (checkHit(aStep, aHit)) {
Expand Down
7 changes: 4 additions & 3 deletions SimG4CMS/Forward/src/TotemSD.cc
Expand Up @@ -117,7 +117,8 @@ void TotemSD::Initialize(G4HCofThisEvent* HCE) {

void TotemSD::EndOfEvent(G4HCofThisEvent*) {
// here we loop over transient hits and make them persistent
for (int j = 0; j < theHC->entries() && j < 15000; j++) {
int thehc_entries = theHC->entries();
for (int j = 0; j < thehc_entries && j < 15000; j++) {
TotemG4Hit* aHit = (*theHC)[j];
#ifdef ddebug
LogDebug("ForwardSim") << "HIT NUMERO " << j << "unit ID = " << aHit->getUnitID() << "\n"
Expand Down Expand Up @@ -223,8 +224,8 @@ bool TotemSD::hitExists() {
//tSliceID already exists:

bool found = false;

for (int j = 0; j < theHC->entries() && !found; j++) {
int thehc_entries = theHC->entries();
for (int j = 0; j < thehc_entries && !found; j++) {
TotemG4Hit* aPreviousHit = (*theHC)[j];
if (aPreviousHit->getTrackID() == primaryID && aPreviousHit->getTimeSliceID() == tSliceID &&
aPreviousHit->getUnitID() == unitID) {
Expand Down
6 changes: 3 additions & 3 deletions SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc
Expand Up @@ -471,11 +471,11 @@ void HcalTB04Analysis::fillBuffer(const EndOfEvent* evt) {
theHC = (CaloG4HitCollection*)allHC->GetHC(idHC);
LogDebug("HcalTBSim") << "HcalTB04Analysis:: Hit Collection for " << sdName << " of ID " << idHC << " is obtained at "
<< theHC;

int thehc_entries = theHC->entries();
if (idHC >= 0 && theHC != nullptr) {
hhits.reserve(theHC->entries());
hhitl.reserve(theHC->entries());
for (j = 0; j < theHC->entries(); j++) {
for (j = 0; j < thehc_entries; j++) {
CaloG4Hit* aHit = (*theHC)[j];
double e = aHit->getEnergyDeposit() / GeV;
double time = aHit->getTimeSlice();
Expand Down Expand Up @@ -589,7 +589,7 @@ void HcalTB04Analysis::fillBuffer(const EndOfEvent* evt) {
<< theHC;
if (idHC >= 0 && theHC != nullptr) {
ehits.reserve(theHC->entries());
for (j = 0; j < theHC->entries(); j++) {
for (j = 0; j < thehc_entries; j++) {
CaloG4Hit* aHit = (*theHC)[j];
double e = aHit->getEnergyDeposit() / GeV;
double time = aHit->getTimeSlice();
Expand Down
4 changes: 2 additions & 2 deletions SimG4CMS/PPS/src/PPSPixelSD.cc
Expand Up @@ -227,8 +227,8 @@ bool PPSPixelSD::hitExists() {
//look in the HitContainer whether a hit with the same primID_, unitID_,
//tSliceID_ already exists:
bool found = false;

for (int j = 0; j < theHC_->entries() && !found; j++) {
int nhits = theHC_->entries();
for (int j = 0; j < nhits && !found; j++) {
PPSPixelG4Hit* aPreviousHit = (*theHC_)[j];
if (aPreviousHit->trackID() == primaryID_ && aPreviousHit->timeSliceID() == tSliceID_ &&
aPreviousHit->unitID() == unitID_) {
Expand Down
14 changes: 9 additions & 5 deletions SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc
Expand Up @@ -310,6 +310,7 @@ void CastorShowerLibraryMaker::update(const BeginOfEvent* evt) {
void CastorShowerLibraryMaker::update(const G4Step* aStep) {
static thread_local int CurrentPrimary = 0;
G4Track* trk = aStep->GetTrack();
int pvec_size;
if (trk->GetCurrentStepNumber() == 1) {
if (trk->GetParentID() == 0) {
CurrentPrimary = (int)trk->GetDynamicParticle()->GetPDGcode();
Expand All @@ -320,7 +321,8 @@ void CastorShowerLibraryMaker::update(const G4Step* aStep) {
if (DeActivatePhysicsProcess) {
G4ProcessManager* p_mgr = trk->GetDefinition()->GetProcessManager();
G4ProcessVector* pvec = p_mgr->GetProcessList();
for (int i = 0; i < pvec->size(); i++) {
pvec_size = pvec->size();
for (int i = 0; i < pvec_size; i++) {
G4VProcess* proc = (*pvec)(i);
if (proc->GetProcessName() != "Transportation" && proc->GetProcessName() != "Decay") {
std::cout << "DeActivating process: " << proc->GetProcessName() << std::endl;
Expand Down Expand Up @@ -358,7 +360,8 @@ void CastorShowerLibraryMaker::update(const G4Step* aStep) {
if (trk->GetParentID() == 0 && DeActivatePhysicsProcess) {
G4ProcessManager* p_mgr = trk->GetDefinition()->GetProcessManager();
G4ProcessVector* pvec = p_mgr->GetProcessList();
for (int i = 0; i < pvec->size(); i++) {
pvec_size = pvec->size();
for (int i = 0; i < pvec_size; i++) {
G4VProcess* proc = (*pvec)(i);
if (proc->GetProcessName() != "Transportation" && proc->GetProcessName() != "Decay") {
std::cout << " Activating process: " << proc->GetProcessName() << std::endl;
Expand Down Expand Up @@ -524,8 +527,8 @@ void CastorShowerLibraryMaker::update(const EndOfEvent* evt) {
}
}
// Check for unassociated energy

if (NEvtAccepted == int(thePrims.size()) && theCAFI->entries() != NHitInEvent) {
int thecafi_entries = theCAFI->entries();
if (NEvtAccepted == int(thePrims.size()) && thecafi_entries != NHitInEvent) {
std::cout << "WARNING: Inconsistent Number of Hits -> Hits in collection: " << theCAFI->entries()
<< " Hits in the showers: " << NHitInEvent << std::endl;
double miss_energy = 0;
Expand Down Expand Up @@ -1025,7 +1028,8 @@ void CastorShowerLibraryMaker::GetMissingEnergy(CaloG4HitCollection* theCAFI, do
// Get the total deposited energy and the one from hit not associated to a primary
miss_energy = 0;
tot_energy = 0;
for (int ihit = 0; ihit < theCAFI->entries(); ihit++) {
int nhits = theCAFI->entries();
for (int ihit = 0; ihit < nhits; ihit++) {
int id = (*theCAFI)[ihit]->getTrackID();
tot_energy += (*theCAFI)[ihit]->getEnergyDeposit();
int hit_prim = 0;
Expand Down
8 changes: 5 additions & 3 deletions SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc
Expand Up @@ -129,9 +129,10 @@ void HcalForwardAnalysis::setPhotons(const EndOfEvent* evt) {
std::vector<HFShowerPhoton> LongFiberPhotons;
LongFiberPhotons.clear();
ShortFiberPhotons.clear();
int thehc_entries = theHC->entries();
if (idHC >= 0 && theHC != nullptr) {
std::cout << "FiberhitSize " << theHC->entries() << std::endl;
for (j = 0; j < theHC->entries(); j++) {
std::cout << "FiberhitSize " << thehc_entries << std::endl;
for (j = 0; j < thehc_entries; j++) {
FiberG4Hit* aHit = (*theHC)[j];
std::vector<HFShowerPhoton> thePhotonsFromHit = aHit->photon();
std::cout << "Fiberhit " << j << " has " << thePhotonsFromHit.size() << " photons." << std::endl;
Expand Down Expand Up @@ -172,7 +173,8 @@ void HcalForwardAnalysis::setPhotons(const EndOfEvent* evt) {
// multiple hits. We want to take last one which is close the HF absorber
if (idHC >= 0 && theChamberHC != nullptr) {
LogDebug("HcalForwardLib") << "HcalForwardAnalysis::setPhotons() Chamber Hits size: " << theChamberHC->entries();
for (j = 0; j < theChamberHC->entries(); ++j) {
int thec_hc_entries = theChamberHC->entries();
for (j = 0; j < thec_hc_entries; ++j) {
HFShowerG4Hit* aHit = (*theChamberHC)[j];
LogDebug("HcalForwardLib") << "HcalForwardAnalysis::setPhotons() Chamber Hit id " << aHit->hitId() << " track id "
<< aHit->trackId() << " prim. pos. " << aHit->globalPosition() << " prom mom. dir. "
Expand Down
4 changes: 2 additions & 2 deletions SimG4Core/GFlash/src/GflashHadronWrapperProcess.cc
Expand Up @@ -96,8 +96,8 @@ G4VParticleChange *GflashHadronWrapperProcess::PostStepDoIt(const G4Track &track
const G4TrackStatus keepStatus = track.GetTrackStatus();

(const_cast<G4Track *>(&track))->SetTrackStatus(fPostponeToNextEvent);

for (G4int ipm = 0; ipm < fProcessVector->entries(); ipm++) {
int fpv_entries = fProcessVector->entries();
for (G4int ipm = 0; ipm < fpv_entries; ipm++) {
fProcess = (*fProcessVector)(ipm);

if (fProcess->GetProcessType() == fParameterisation) {
Expand Down
3 changes: 2 additions & 1 deletion SimG4Core/PrintGeomInfo/src/PrintGeomInfoAction.cc
Expand Up @@ -173,7 +173,8 @@ void PrintGeomInfoAction::dumpG4LVLeaf(G4LogicalVolume *lv,
//--- If a volume is placed n types as daughter of this LV, it should only be counted once
std::map<G4LogicalVolume *, unsigned int> lvCount;
std::map<G4LogicalVolume *, unsigned int>::const_iterator cite;
for (int ii = 0; ii < lv->GetNoDaughters(); ii++) {
int siz = lv->GetNoDaughters();
for (int ii = 0; ii < siz; ii++) {
cite = lvCount.find(lv->GetDaughter(ii)->GetLogicalVolume());
if (cite != lvCount.end())
lvCount[cite->first] = (cite->second) + 1;
Expand Down
10 changes: 6 additions & 4 deletions Validation/EcalHits/src/EcalSimHitsValidProducer.cc
Expand Up @@ -283,7 +283,8 @@ void EcalSimHitsValidProducer::update(const EndOfEvent *evt) {

// EB Hit collection start
MapType ebmap;
for (int j = 0; j < theEBHC->entries(); j++) {
int theebhc_entries = theEBHC->entries();
for (int j = 0; j < theebhc_entries; j++) {
CaloG4Hit *aHit = (*theEBHC)[j];
totalEInEB += aHit->getEnergyDeposit();
float he = aHit->getEnergyDeposit();
Expand All @@ -306,8 +307,8 @@ void EcalSimHitsValidProducer::update(const EndOfEvent *evt) {

// EE Hit collection start
MapType eemap, eezpmap, eezmmap;

for (int j = 0; j < theEEHC->entries(); j++) {
int theeehc_entries = theEEHC->entries();
for (int j = 0; j < theeehc_entries; j++) {
CaloG4Hit *aHit = (*theEEHC)[j];
totalEInEE += aHit->getEnergyDeposit();
float he = aHit->getEnergyDeposit();
Expand Down Expand Up @@ -342,7 +343,8 @@ void EcalSimHitsValidProducer::update(const EndOfEvent *evt) {
nCrystalInEEzp = eezpmap.size();

// Hits from ES
for (int j = 0; j < theSEHC->entries(); j++) {
int thesehc_entries = theSEHC->entries();
for (int j = 0; j < thesehc_entries; j++) {
CaloG4Hit *aHit = (*theSEHC)[j];
totalEInES += aHit->getEnergyDeposit();
ESDetId esid = ESDetId(aHit->getUnitID());
Expand Down
6 changes: 4 additions & 2 deletions Validation/HcalHits/src/SimG4HcalValidation.cc
Expand Up @@ -276,7 +276,8 @@ void SimG4HcalValidation::fill(const EndOfEvent *evt) {
LogDebug("ValidHcal") << "SimG4HcalValidation :: Hit Collection for " << names[0] << " of ID " << HCHCid
<< " is obtained at " << theHCHC;
if (HCHCid >= 0 && theHCHC != nullptr) {
for (j = 0; j < theHCHC->entries(); j++) {
int nhits = theHCHC->entries();
for (j = 0; j < nhits; j++) {
CaloG4Hit *aHit = (*theHCHC)[j];

double e = aHit->getEnergyDeposit() / GeV;
Expand Down Expand Up @@ -353,8 +354,9 @@ void SimG4HcalValidation::fill(const EndOfEvent *evt) {
CaloG4HitCollection *theECHC = (CaloG4HitCollection *)allHC->GetHC(ECHCid);
LogDebug("ValidHcal") << "SimG4HcalValidation:: Hit Collection for " << names[idty] << " of ID " << ECHCid
<< " is obtained at " << theECHC;
int theechc_entries = theECHC->entries();
if (ECHCid >= 0 && theECHC != nullptr) {
for (j = 0; j < theECHC->entries(); j++) {
for (j = 0; j < theechc_entries; j++) {
CaloG4Hit *aHit = (*theECHC)[j];

double e = aHit->getEnergyDeposit() / GeV;
Expand Down

0 comments on commit fb33c64

Please sign in to comment.