From 980fe3edeb3500759312651197b4affdb03d027b Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Mon, 16 Dec 2019 14:49:07 +0100 Subject: [PATCH 1/6] [Geant] Additional changes for Geant 10.6 --- SimG4CMS/Calo/src/CaloSD.cc | 4 ++-- SimG4CMS/Calo/src/HcalTestAnalysis.cc | 2 +- SimG4CMS/FP420/plugins/FP420SD.cc | 4 ++-- SimG4CMS/FP420/plugins/FP420Test.cc | 6 +++--- SimG4CMS/Forward/src/BscTest.cc | 6 +++--- SimG4CMS/Forward/src/TimingSD.cc | 2 +- SimG4CMS/Forward/src/TotemSD.cc | 4 ++-- SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc | 2 +- SimG4CMS/PPS/src/PPSPixelSD.cc | 2 +- .../ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc | 8 ++++---- SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc | 2 +- SimG4Core/GFlash/src/GflashHadronWrapperProcess.cc | 2 +- Validation/EcalHits/src/EcalSimHitsValidProducer.cc | 6 +++--- Validation/HcalHits/src/SimG4HcalValidation.cc | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/SimG4CMS/Calo/src/CaloSD.cc b/SimG4CMS/Calo/src/CaloSD.cc index da109078f9ef9..a7c8f12263dc5 100644 --- a/SimG4CMS/Calo/src/CaloSD.cc +++ b/SimG4CMS/Calo/src/CaloSD.cc @@ -321,7 +321,7 @@ bool CaloSD::checkHit() { found = true; } } else if (nCheckedHits > 0) { - int minhit = (theHC->entries() > nCheckedHits ? theHC->entries() - nCheckedHits : 0); + size_t minhit = (theHC->entries() > nCheckedHits ? theHC->entries() - nCheckedHits : 0); int maxhit = theHC->entries() - 1; for (int j = maxhit; j > minhit; --j) { @@ -504,7 +504,7 @@ void CaloSD::update(const ::EndOfEvent*) { double zglob(0.0); double ee(0.0); - for (int i = 0; i < theHC->entries(); ++i) { + for (size_t i = 0; i < theHC->entries(); ++i) { if (!saveHit((*theHC)[i])) { ++wrong; } diff --git a/SimG4CMS/Calo/src/HcalTestAnalysis.cc b/SimG4CMS/Calo/src/HcalTestAnalysis.cc index e37ed31c7e0e0..2b0c096927312 100644 --- a/SimG4CMS/Calo/src/HcalTestAnalysis.cc +++ b/SimG4CMS/Calo/src/HcalTestAnalysis.cc @@ -317,7 +317,7 @@ void HcalTestAnalysis::fill(const EndOfEvent* evt) { // access to the G4 hit collections G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent(); - int nhc = 0, neb = 0, nef = 0, j = 0; + int nhc = 0, neb = 0, nef = 0; size_t j = 0; caloHitCache_.erase(caloHitCache_.begin(), caloHitCache_.end()); // Hcal diff --git a/SimG4CMS/FP420/plugins/FP420SD.cc b/SimG4CMS/FP420/plugins/FP420SD.cc index 705cd4564aadc..8fd4054d6c6ff 100644 --- a/SimG4CMS/FP420/plugins/FP420SD.cc +++ b/SimG4CMS/FP420/plugins/FP420SD.cc @@ -196,7 +196,7 @@ G4bool FP420SD::HitExists() { // LogDebug("FP420Sim") << "FP420SD: HCollection= " << theHC->entries() <entries() && !found; j++) { + for (size_t j = 0; j < theHC->entries() && !found; j++) { FP420G4Hit* aPreviousHit = (*theHC)[j]; if (aPreviousHit->getTrackID() == primaryID && aPreviousHit->getTimeSliceID() == tSliceID && aPreviousHit->getUnitID() == unitID) { @@ -333,7 +333,7 @@ void FP420SD::EndOfEvent(G4HCofThisEvent*) { // for (int j=0; jentries() && j<100; j++) { int nhitsHPS240 = 0; int nhitsFP420 = 0; - for (int j = 0; j < theHC->entries(); j++) { + for (size_t j = 0; j < theHC->entries(); j++) { FP420G4Hit* aHit = (*theHC)[j]; if ((fabs(aHit->getTof()) > 780. && fabs(aHit->getTof()) < 840.)) ++nhitsHPS240; diff --git a/SimG4CMS/FP420/plugins/FP420Test.cc b/SimG4CMS/FP420/plugins/FP420Test.cc index 3c4379dfad5ba..10cbf23aded1a 100644 --- a/SimG4CMS/FP420/plugins/FP420Test.cc +++ b/SimG4CMS/FP420/plugins/FP420Test.cc @@ -954,7 +954,7 @@ void FP420Test::update(const EndOfEvent* evt) { varia = 2; } // no MI end: - for (int j = 0; j < theCAFI->entries(); j++) { + for (size_t j = 0; j < theCAFI->entries(); j++) { FP420G4Hit* aHit = (*theCAFI)[j]; G4ThreeVector hitPoint = aHit->getEntry(); double zz = hitPoint.z(); @@ -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 (size_t j = 0; j < theCAFI->entries(); j++) { FP420G4Hit* aHit = (*theCAFI)[j]; G4ThreeVector hitEntryLocalPoint = aHit->getEntryLocalP(); @@ -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 (size_t j = 0; j < theCAFI->entries(); j++) { FP420G4Hit* aHit = (*theCAFI)[j]; double losenergy = aHit->getEnergyLoss(); std::cout << " j hits = " << j << "losenergy = " << losenergy << std::endl; diff --git a/SimG4CMS/Forward/src/BscTest.cc b/SimG4CMS/Forward/src/BscTest.cc index 1d3221dda4cab..13417e8d35c56 100644 --- a/SimG4CMS/Forward/src/BscTest.cc +++ b/SimG4CMS/Forward/src/BscTest.cc @@ -627,7 +627,7 @@ void BscTest::update(const EndOfEvent* evt) { } else { varia = 2; } // no MI end: - for (int j = 0; j < theCAFI->entries(); j++) { + for (size_t j = 0; j < theCAFI->entries(); j++) { BscG4Hit* aHit = (*theCAFI)[j]; const CLHEP::Hep3Vector& hitPoint = aHit->getEntry(); double zz = hitPoint.z(); @@ -639,7 +639,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 (size_t j = 0; j < theCAFI->entries(); j++) { BscG4Hit* aHit = (*theCAFI)[j]; const CLHEP::Hep3Vector& hitEntryLocalPoint = aHit->getEntryLocalP(); @@ -782,7 +782,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 (size_t j = 0; j < theCAFI->entries(); j++) { BscG4Hit* aHit = (*theCAFI)[j]; double losenergy = aHit->getEnergyLoss(); std::cout << " j hits = " << j << "losenergy = " << losenergy << std::endl; diff --git a/SimG4CMS/Forward/src/TimingSD.cc b/SimG4CMS/Forward/src/TimingSD.cc index 540102b77490e..74493187e0530 100644 --- a/SimG4CMS/Forward/src/TimingSD.cc +++ b/SimG4CMS/Forward/src/TimingSD.cc @@ -201,7 +201,7 @@ bool TimingSD::hitExists(const G4Step* aStep) { //tSliceID already exists: bool found = false; - for (int j = 0; j < theHC->entries(); ++j) { + for (size_t j = 0; j < theHC->entries(); ++j) { BscG4Hit* aHit = (*theHC)[j]; if (aHit->getTimeSliceID() == tSliceID && aHit->getUnitID() == unitID) { if (checkHit(aStep, aHit)) { diff --git a/SimG4CMS/Forward/src/TotemSD.cc b/SimG4CMS/Forward/src/TotemSD.cc index 4ec17a85a6851..b7c2f6bb77b5f 100644 --- a/SimG4CMS/Forward/src/TotemSD.cc +++ b/SimG4CMS/Forward/src/TotemSD.cc @@ -117,7 +117,7 @@ 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++) { + for (size_t j = 0; j < theHC->entries() && j < 15000; j++) { TotemG4Hit* aHit = (*theHC)[j]; #ifdef ddebug LogDebug("ForwardSim") << "HIT NUMERO " << j << "unit ID = " << aHit->getUnitID() << "\n" @@ -224,7 +224,7 @@ bool TotemSD::hitExists() { bool found = false; - for (int j = 0; j < theHC->entries() && !found; j++) { + for (size_t j = 0; j < theHC->entries() && !found; j++) { TotemG4Hit* aPreviousHit = (*theHC)[j]; if (aPreviousHit->getTrackID() == primaryID && aPreviousHit->getTimeSliceID() == tSliceID && aPreviousHit->getUnitID() == unitID) { diff --git a/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc b/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc index 55a33282527b7..2faa4a31857e5 100644 --- a/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc +++ b/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc @@ -459,7 +459,7 @@ void HcalTB04Analysis::update(const EndOfEvent* evt) { void HcalTB04Analysis::fillBuffer(const EndOfEvent* evt) { std::vector hhits, hhitl; - int idHC, j; + int idHC;unsigned j; CaloG4HitCollection* theHC; std::map > primaries; double etot1 = 0, etot2 = 0; diff --git a/SimG4CMS/PPS/src/PPSPixelSD.cc b/SimG4CMS/PPS/src/PPSPixelSD.cc index 954b476cebb4d..d2491f1116f6f 100644 --- a/SimG4CMS/PPS/src/PPSPixelSD.cc +++ b/SimG4CMS/PPS/src/PPSPixelSD.cc @@ -228,7 +228,7 @@ bool PPSPixelSD::hitExists() { //tSliceID_ already exists: bool found = false; - for (int j = 0; j < theHC_->entries() && !found; j++) { + for (unsigned j = 0; j < theHC_->entries() && !found; j++) { PPSPixelG4Hit* aPreviousHit = (*theHC_)[j]; if (aPreviousHit->trackID() == primaryID_ && aPreviousHit->timeSliceID() == tSliceID_ && aPreviousHit->unitID() == unitID_) { diff --git a/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc b/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc index b3c36740e25cb..6aed6f258dcc9 100644 --- a/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc +++ b/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc @@ -320,7 +320,7 @@ 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++) { + for (size_t 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; @@ -358,7 +358,7 @@ 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++) { + for (size_t 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; @@ -442,7 +442,7 @@ void CastorShowerLibraryMaker::update(const EndOfEvent* evt) { // Loop over primaries int NEvtAccepted = 0; - int NHitInEvent = 0; + size_t NHitInEvent = 0; for (unsigned int i = 0; i < thePrims.size(); i++) { G4PrimaryParticle* thePrim = thePrims.at(i); if (!thePrim) { @@ -1025,7 +1025,7 @@ 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++) { + for (unsigned ihit = 0; ihit < theCAFI->entries(); ihit++) { int id = (*theCAFI)[ihit]->getTrackID(); tot_energy += (*theCAFI)[ihit]->getEnergyDeposit(); int hit_prim = 0; diff --git a/SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc b/SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc index 29d36fc59ff90..d921f11f07dbb 100644 --- a/SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc +++ b/SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc @@ -116,7 +116,7 @@ void HcalForwardAnalysis::update(const EndOfEvent* evt) { } void HcalForwardAnalysis::setPhotons(const EndOfEvent* evt) { - int idHC, j; + int idHC; size_t j; FiberG4HitsCollection* theHC; // Look for the Hit Collection of HCal G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent(); diff --git a/SimG4Core/GFlash/src/GflashHadronWrapperProcess.cc b/SimG4Core/GFlash/src/GflashHadronWrapperProcess.cc index 495cb6fccffaa..ac49ae3edba24 100644 --- a/SimG4Core/GFlash/src/GflashHadronWrapperProcess.cc +++ b/SimG4Core/GFlash/src/GflashHadronWrapperProcess.cc @@ -97,7 +97,7 @@ G4VParticleChange *GflashHadronWrapperProcess::PostStepDoIt(const G4Track &track (const_cast(&track))->SetTrackStatus(fPostponeToNextEvent); - for (G4int ipm = 0; ipm < fProcessVector->entries(); ipm++) { + for (size_t ipm = 0; ipm < fProcessVector->entries(); ipm++) { fProcess = (*fProcessVector)(ipm); if (fProcess->GetProcessType() == fParameterisation) { diff --git a/Validation/EcalHits/src/EcalSimHitsValidProducer.cc b/Validation/EcalHits/src/EcalSimHitsValidProducer.cc index 8ad22f8dc28ab..d00b50af9b4f2 100644 --- a/Validation/EcalHits/src/EcalSimHitsValidProducer.cc +++ b/Validation/EcalHits/src/EcalSimHitsValidProducer.cc @@ -283,7 +283,7 @@ void EcalSimHitsValidProducer::update(const EndOfEvent *evt) { // EB Hit collection start MapType ebmap; - for (int j = 0; j < theEBHC->entries(); j++) { + for (size_t j = 0; j < theEBHC->entries(); j++) { CaloG4Hit *aHit = (*theEBHC)[j]; totalEInEB += aHit->getEnergyDeposit(); float he = aHit->getEnergyDeposit(); @@ -307,7 +307,7 @@ void EcalSimHitsValidProducer::update(const EndOfEvent *evt) { // EE Hit collection start MapType eemap, eezpmap, eezmmap; - for (int j = 0; j < theEEHC->entries(); j++) { + for (size_t j = 0; j < theEEHC->entries(); j++) { CaloG4Hit *aHit = (*theEEHC)[j]; totalEInEE += aHit->getEnergyDeposit(); float he = aHit->getEnergyDeposit(); @@ -342,7 +342,7 @@ void EcalSimHitsValidProducer::update(const EndOfEvent *evt) { nCrystalInEEzp = eezpmap.size(); // Hits from ES - for (int j = 0; j < theSEHC->entries(); j++) { + for (size_t j = 0; j < theSEHC->entries(); j++) { CaloG4Hit *aHit = (*theSEHC)[j]; totalEInES += aHit->getEnergyDeposit(); ESDetId esid = ESDetId(aHit->getUnitID()); diff --git a/Validation/HcalHits/src/SimG4HcalValidation.cc b/Validation/HcalHits/src/SimG4HcalValidation.cc index dc8d7a421ae21..6a9cef95f6c3b 100644 --- a/Validation/HcalHits/src/SimG4HcalValidation.cc +++ b/Validation/HcalHits/src/SimG4HcalValidation.cc @@ -268,7 +268,7 @@ void SimG4HcalValidation::fill(const EndOfEvent *evt) { // access to the G4 hit collections G4HCofThisEvent *allHC = (*evt)()->GetHCofThisEvent(); - int nhc = 0, j = 0; + int nhc = 0; size_t j = 0; // Hcal int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names[0]); From 3dff029cacc13c72ad4aa775f8fb2a013fc9b3e9 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Mon, 16 Dec 2019 15:05:37 +0100 Subject: [PATCH 2/6] Move all to size_t for consistency --- SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc | 2 +- SimG4CMS/PPS/src/PPSPixelSD.cc | 2 +- SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc b/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc index 2faa4a31857e5..a5bf0ffbbe93e 100644 --- a/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc +++ b/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc @@ -459,7 +459,7 @@ void HcalTB04Analysis::update(const EndOfEvent* evt) { void HcalTB04Analysis::fillBuffer(const EndOfEvent* evt) { std::vector hhits, hhitl; - int idHC;unsigned j; + int idHC;size_t j; CaloG4HitCollection* theHC; std::map > primaries; double etot1 = 0, etot2 = 0; diff --git a/SimG4CMS/PPS/src/PPSPixelSD.cc b/SimG4CMS/PPS/src/PPSPixelSD.cc index d2491f1116f6f..afa41be370e5b 100644 --- a/SimG4CMS/PPS/src/PPSPixelSD.cc +++ b/SimG4CMS/PPS/src/PPSPixelSD.cc @@ -228,7 +228,7 @@ bool PPSPixelSD::hitExists() { //tSliceID_ already exists: bool found = false; - for (unsigned j = 0; j < theHC_->entries() && !found; j++) { + for (size_t j = 0; j < theHC_->entries() && !found; j++) { PPSPixelG4Hit* aPreviousHit = (*theHC_)[j]; if (aPreviousHit->trackID() == primaryID_ && aPreviousHit->timeSliceID() == tSliceID_ && aPreviousHit->unitID() == unitID_) { diff --git a/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc b/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc index 6aed6f258dcc9..56436a9d07953 100644 --- a/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc +++ b/SimG4CMS/ShowerLibraryProducer/src/CastorShowerLibraryMaker.cc @@ -1025,7 +1025,7 @@ 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 (unsigned ihit = 0; ihit < theCAFI->entries(); ihit++) { + for (size_t ihit = 0; ihit < theCAFI->entries(); ihit++) { int id = (*theCAFI)[ihit]->getTrackID(); tot_energy += (*theCAFI)[ihit]->getEnergyDeposit(); int hit_prim = 0; From e61b9fce999d1912b14fdcdcaac26cce4e6427eb Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Mon, 16 Dec 2019 15:14:06 +0100 Subject: [PATCH 3/6] apply code format --- SimG4CMS/Calo/src/HcalTestAnalysis.cc | 3 ++- SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc | 3 ++- SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc | 3 ++- Validation/HcalHits/src/SimG4HcalValidation.cc | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SimG4CMS/Calo/src/HcalTestAnalysis.cc b/SimG4CMS/Calo/src/HcalTestAnalysis.cc index 2b0c096927312..3f588f0542a64 100644 --- a/SimG4CMS/Calo/src/HcalTestAnalysis.cc +++ b/SimG4CMS/Calo/src/HcalTestAnalysis.cc @@ -317,7 +317,8 @@ void HcalTestAnalysis::fill(const EndOfEvent* evt) { // access to the G4 hit collections G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent(); - int nhc = 0, neb = 0, nef = 0; size_t j = 0; + int nhc = 0, neb = 0, nef = 0; + size_t j = 0; caloHitCache_.erase(caloHitCache_.begin(), caloHitCache_.end()); // Hcal diff --git a/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc b/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc index a5bf0ffbbe93e..9cf9b93cbd864 100644 --- a/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc +++ b/SimG4CMS/HcalTestBeam/plugins/HcalTB04Analysis.cc @@ -459,7 +459,8 @@ void HcalTB04Analysis::update(const EndOfEvent* evt) { void HcalTB04Analysis::fillBuffer(const EndOfEvent* evt) { std::vector hhits, hhitl; - int idHC;size_t j; + int idHC; + size_t j; CaloG4HitCollection* theHC; std::map > primaries; double etot1 = 0, etot2 = 0; diff --git a/SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc b/SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc index d921f11f07dbb..82f91ee307b54 100644 --- a/SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc +++ b/SimG4CMS/ShowerLibraryProducer/src/HcalForwardAnalysis.cc @@ -116,7 +116,8 @@ void HcalForwardAnalysis::update(const EndOfEvent* evt) { } void HcalForwardAnalysis::setPhotons(const EndOfEvent* evt) { - int idHC; size_t j; + int idHC; + size_t j; FiberG4HitsCollection* theHC; // Look for the Hit Collection of HCal G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent(); diff --git a/Validation/HcalHits/src/SimG4HcalValidation.cc b/Validation/HcalHits/src/SimG4HcalValidation.cc index 6a9cef95f6c3b..91fcd62d36ae7 100644 --- a/Validation/HcalHits/src/SimG4HcalValidation.cc +++ b/Validation/HcalHits/src/SimG4HcalValidation.cc @@ -268,7 +268,8 @@ void SimG4HcalValidation::fill(const EndOfEvent *evt) { // access to the G4 hit collections G4HCofThisEvent *allHC = (*evt)()->GetHCofThisEvent(); - int nhc = 0; size_t j = 0; + int nhc = 0; + size_t j = 0; // Hcal int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(names[0]); From 74d29135c06c122f8ec69d247d4408253a4931c0 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Mon, 16 Dec 2019 16:09:08 +0100 Subject: [PATCH 4/6] Update CaloSD.cc add proposed changes --- SimG4CMS/Calo/src/CaloSD.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SimG4CMS/Calo/src/CaloSD.cc b/SimG4CMS/Calo/src/CaloSD.cc index a7c8f12263dc5..9b0f172d4e102 100644 --- a/SimG4CMS/Calo/src/CaloSD.cc +++ b/SimG4CMS/Calo/src/CaloSD.cc @@ -321,8 +321,9 @@ bool CaloSD::checkHit() { found = true; } } else if (nCheckedHits > 0) { - size_t 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 = - 1; for (int j = maxhit; j > minhit; --j) { if ((*theHC)[j]->getID() == currentID) { From b4ba5184b215d6c459fe32a52d439194c6bf2cee Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Mon, 16 Dec 2019 16:19:02 +0100 Subject: [PATCH 5/6] Update CaloSD.cc --- SimG4CMS/Calo/src/CaloSD.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimG4CMS/Calo/src/CaloSD.cc b/SimG4CMS/Calo/src/CaloSD.cc index 9b0f172d4e102..0050e5e5be662 100644 --- a/SimG4CMS/Calo/src/CaloSD.cc +++ b/SimG4CMS/Calo/src/CaloSD.cc @@ -323,7 +323,7 @@ bool CaloSD::checkHit() { } else if (nCheckedHits > 0) { int nhits = theHC->entries(); int minhit = std::max(nhits - nCheckedHits, 0); - int maxhit = - 1; + int maxhit = -1; for (int j = maxhit; j > minhit; --j) { if ((*theHC)[j]->getID() == currentID) { From f1617275b19b7546e5f10a88fcca9f028a15eb63 Mon Sep 17 00:00:00 2001 From: Mircho Rodozov Date: Tue, 17 Dec 2019 11:01:53 +0100 Subject: [PATCH 6/6] Fix the build errors and add te discussed suggestions --- SimG4CMS/Calo/src/CaloSD.cc | 6 +++--- SimG4CMS/Calo/src/HcalTestAnalysis.cc | 12 +++++++----- SimG4CMS/FP420/plugins/FP420SD.cc | 7 ++++--- SimG4CMS/Forward/src/BscTest.cc | 5 +++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/SimG4CMS/Calo/src/CaloSD.cc b/SimG4CMS/Calo/src/CaloSD.cc index 0050e5e5be662..eedb48d30ad4f 100644 --- a/SimG4CMS/Calo/src/CaloSD.cc +++ b/SimG4CMS/Calo/src/CaloSD.cc @@ -323,7 +323,7 @@ bool CaloSD::checkHit() { } else if (nCheckedHits > 0) { int nhits = theHC->entries(); int minhit = std::max(nhits - nCheckedHits, 0); - int maxhit = -1; + int maxhit = nhits - 1; for (int j = maxhit; j > minhit; --j) { if ((*theHC)[j]->getID() == currentID) { @@ -504,8 +504,8 @@ void CaloSD::update(const ::EndOfEvent*) { double zloc(0.0); double zglob(0.0); double ee(0.0); - - for (size_t i = 0; i < theHC->entries(); ++i) { + int hc_entries = theHC->entries(); + for (int i = 0; i < hc_entries; ++i) { if (!saveHit((*theHC)[i])) { ++wrong; } diff --git a/SimG4CMS/Calo/src/HcalTestAnalysis.cc b/SimG4CMS/Calo/src/HcalTestAnalysis.cc index 3f588f0542a64..d46278523ff28 100644 --- a/SimG4CMS/Calo/src/HcalTestAnalysis.cc +++ b/SimG4CMS/Calo/src/HcalTestAnalysis.cc @@ -317,8 +317,7 @@ void HcalTestAnalysis::fill(const EndOfEvent* evt) { // access to the G4 hit collections G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent(); - int nhc = 0, neb = 0, nef = 0; - size_t j = 0; + int nhc = 0, neb = 0, nef = 0, j = 0; caloHitCache_.erase(caloHitCache_.begin(), caloHitCache_.end()); // Hcal @@ -326,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; @@ -372,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; @@ -408,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; diff --git a/SimG4CMS/FP420/plugins/FP420SD.cc b/SimG4CMS/FP420/plugins/FP420SD.cc index 8fd4054d6c6ff..6b97d731ed5aa 100644 --- a/SimG4CMS/FP420/plugins/FP420SD.cc +++ b/SimG4CMS/FP420/plugins/FP420SD.cc @@ -195,8 +195,8 @@ G4bool FP420SD::HitExists() { G4bool found = false; // LogDebug("FP420Sim") << "FP420SD: HCollection= " << theHC->entries() <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) { @@ -333,7 +333,8 @@ void FP420SD::EndOfEvent(G4HCofThisEvent*) { // for (int j=0; jentries() && j<100; j++) { int nhitsHPS240 = 0; int nhitsFP420 = 0; - for (size_t 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; diff --git a/SimG4CMS/Forward/src/BscTest.cc b/SimG4CMS/Forward/src/BscTest.cc index 13417e8d35c56..e7f2ce0823688 100644 --- a/SimG4CMS/Forward/src/BscTest.cc +++ b/SimG4CMS/Forward/src/BscTest.cc @@ -627,7 +627,8 @@ void BscTest::update(const EndOfEvent* evt) { } else { varia = 2; } // no MI end: - for (size_t 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(); @@ -639,7 +640,7 @@ void BscTest::update(const EndOfEvent* evt) { if (varia == 2) { int nhit11 = 0, nhit12 = 0, nhit13 = 0; double totallosenergy = 0.; - for (size_t j = 0; j < theCAFI->entries(); j++) { + for (int j = 0; j < nhits; j++) { BscG4Hit* aHit = (*theCAFI)[j]; const CLHEP::Hep3Vector& hitEntryLocalPoint = aHit->getEntryLocalP();