Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed static analizer warnings #24144

Merged
merged 3 commits into from Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion SimG4Core/Application/interface/ExceptionHandler.h
@@ -1,6 +1,6 @@
// ------------------------------------------------------------
//
// Author: V.Ivanchenko - 01.11.2018 - old code re-written
// Author: V.Ivanchenko - 01.11.2017 - old code re-written
//
// ------------------------------------------------------------
//
Expand Down
29 changes: 15 additions & 14 deletions SimG4Core/Application/src/OscarMTMasterThread.cc
Expand Up @@ -45,7 +45,7 @@ OscarMTMasterThread::OscarMTMasterThread(const edm::ParameterSet& iConfig):
// Lock the mutex (i.e. wait until the creating thread has called cv.wait()
std::unique_lock<std::mutex> lk2(m_threadMutex);

edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: initializing RunManagerMT";

//UIsession manager for message handling
Expand All @@ -55,7 +55,7 @@ OscarMTMasterThread::OscarMTMasterThread(const edm::ParameterSet& iConfig):
runManagerMaster = std::make_shared<RunManagerMT>(iConfig);
m_runManagerMaster = runManagerMaster;

edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: initialization of RunManagerMT finished";

/////////////
Expand All @@ -73,7 +73,8 @@ OscarMTMasterThread::OscarMTMasterThread(const edm::ParameterSet& iConfig):
m_notifyMasterCv.wait(lk2, [&]{return m_masterCanProceed;});

// Act according to the state
LogDebug("OscarMTMasterThread") << "Master thread: Woke up, state is " << static_cast<int>(m_masterThreadState);
LogDebug("OscarMTMasterThread") << "Master thread: Woke up, state is "
<< static_cast<int>(m_masterThreadState);
if(m_masterThreadState == ThreadState::BeginRun) {
// Initialize Geant4
LogDebug("OscarMTMasterThread") << "Master thread: Initializing Geant4";
Expand Down Expand Up @@ -102,8 +103,8 @@ OscarMTMasterThread::OscarMTMasterThread(const edm::ParameterSet& iConfig):

//////////
// Cleanup
edm::LogInfo("SimG4CoreApplication")
<< "OscarMTMasterThread: start RunManagerMT destruction";
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: start RunManagerMT destruction";
LogDebug("OscarMTMasterThread")
<< "Master thread: Am I unique owner of runManagerMaster? "
<< runManagerMaster.unique();
Expand All @@ -114,7 +115,7 @@ OscarMTMasterThread::OscarMTMasterThread(const edm::ParameterSet& iConfig):

LogDebug("OscarMTMasterThread") << "Master thread: Reseted shared_ptr";
lk2.unlock();
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: Master thread is finished";
});

Expand All @@ -125,7 +126,7 @@ OscarMTMasterThread::OscarMTMasterThread(const edm::ParameterSet& iConfig):
m_notifyMainCv.wait(lk, [&](){return m_mainCanProceed;});

lk.unlock();
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: Master thread is constructed";
}

Expand All @@ -146,13 +147,13 @@ void OscarMTMasterThread::beginRun(const edm::EventSetup& iSetup) const {
m_masterThreadState = ThreadState::BeginRun;
m_masterCanProceed = true;
m_mainCanProceed = false;
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: Signal master for BeginRun";
m_notifyMasterCv.notify_one();
m_notifyMainCv.wait(lk2, [&](){return m_mainCanProceed;});

lk2.unlock();
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: finish BeginRun";
}

Expand All @@ -163,20 +164,20 @@ void OscarMTMasterThread::endRun() const {
m_masterThreadState = ThreadState::EndRun;
m_mainCanProceed = false;
m_masterCanProceed = true;
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: Signal master for EndRun";
m_notifyMasterCv.notify_one();
m_notifyMainCv.wait(lk2, [&](){return m_mainCanProceed;});
lk2.unlock();
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread: finish EndRun";
}

void OscarMTMasterThread::stopThread() {
if(m_stopped) {
return;
}
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread::stopTread: stop main thread";

// Release our instance of the shared master run manager, so that
Expand All @@ -188,14 +189,14 @@ void OscarMTMasterThread::stopThread() {

m_masterThreadState = ThreadState::Destruct;
m_masterCanProceed = true;
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread::stopTread: stop main thread";
m_notifyMasterCv.notify_one();
lk2.unlock();

LogDebug("OscarMTMasterThread") << "Main thread: joining master thread";
m_masterThread.join();
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "OscarMTMasterThread::stopTread: main thread finished";
m_stopped = true;
}
Expand Down
28 changes: 13 additions & 15 deletions SimG4Core/Application/src/RunManagerMTWorker.cc
Expand Up @@ -181,7 +181,7 @@ void RunManagerMTWorker::initializeThread(RunManagerMT& runManagerMaster, const

int thisID = getThreadIndex();

edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "RunManagerMTWorker::initializeThread " << thisID;

// Initialize per-thread output
Expand Down Expand Up @@ -254,27 +254,25 @@ void RunManagerMTWorker::initializeThread(RunManagerMT& runManagerMaster, const
m_tls->sensTkDets.swap(sensDets.first);
m_tls->sensCaloDets.swap(sensDets.second);

edm::LogInfo("SimG4CoreApplication")
<< " RunManagerMTWorker: Sensitive Detector "
<< "building finished; found "
<< m_tls->sensTkDets.size()
<< " Tk type Producers, and "
<< m_tls->sensCaloDets.size()
<< " Calo type producers ";
edm::LogVerbatim("SimG4CoreApplication")
<< " RunManagerMTWorker: Sensitive Detector building finished; found "
<< m_tls->sensTkDets.size() << " Tk type Producers, and "
<< m_tls->sensCaloDets.size() << " Calo type producers ";

// Set the physics list for the worker, share from master
PhysicsList *physicsList = runManagerMaster.physicsListForWorker();

edm::LogInfo("SimG4CoreApplication")
<< "RunManagerMTWorker: start initialisation of PhysicsList for a thread";
edm::LogVerbatim("SimG4CoreApplication")
<< "RunManagerMTWorker: start initialisation of PhysicsList for the thread";

physicsList->InitializeWorker();
m_tls->kernel->SetPhysics(physicsList);
m_tls->kernel->InitializePhysics();

const bool kernelInit = m_tls->kernel->RunInitialization();
if(!kernelInit) {
throw SimG4Exception("G4WorkerRunManagerKernel initialization failed");
throw edm::Exception(edm::errors::Configuration)
<< "RunManagerMTWorker: Geant4 kernel initialization failed";
}
//tell all interesting parties that we are beginning the job
BeginOfJob aBeginOfJob(&es);
Expand All @@ -291,11 +289,11 @@ void RunManagerMTWorker::initializeThread(RunManagerMT& runManagerMaster, const
}
initializeUserActions();

edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "RunManagerMTWorker::initializeThread done for the thread " << thisID;

for(const std::string& command: runManagerMaster.G4Commands()) {
edm::LogInfo("SimG4CoreApplication") << "RunManagerMTWorker:: Requests UI: "
edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker:: Requests UI: "
<< command;
G4UImanager::GetUIpointer()->ApplyCommand(command);
}
Expand Down Expand Up @@ -452,7 +450,7 @@ void RunManagerMTWorker::produce(const edm::Event& inpevt, const edm::EventSetup
throw SimG4Exception(ss.str());
}

edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< " RunManagerMTWorker::produce: start Event " << inpevt.id().event()
<< " stream id " << inpevt.streamID()
<< " thread index " << getThreadIndex()
Expand All @@ -463,7 +461,7 @@ void RunManagerMTWorker::produce(const edm::Event& inpevt, const edm::EventSetup

m_tls->kernel->GetEventManager()->ProcessOneEvent(m_tls->currentEvent.get());

edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< " RunManagerMTWorker::produce: ended Event " << inpevt.id().event();
}
}
Expand Down
62 changes: 29 additions & 33 deletions SimG4Core/Application/src/StackingAction.cc
Expand Up @@ -95,61 +95,56 @@ StackingAction::StackingAction(const TrackingAction* trka, const edm::ParameterS
<< " *** Kill secondaries in Calorimetetrs volume = " << killInCalo << "\n"
<< " *** Kill electromagnetic secondaries from hadrons in Calorimeters volume= "
<< killInCaloEfH;

}

initPointer();
newTA = new NewTrackAction();

edm::LogInfo("SimG4CoreApplication") << "StackingAction initiated with"
<< " flag for saving decay products in "
<< " Tracker: " << savePDandCinTracker
<< " in Calo: " << savePDandCinCalo
<< " in Muon: " << savePDandCinMuon
<< " everywhere: " << savePDandCinAll
<< "\n saveFirstSecondary"
<< ": " << saveFirstSecondary
<< " Tracking neutrino flag: "
<< trackNeutrino
<< " Kill Delta Ray flag: "
<< killDeltaRay
<< " Kill hadrons/ions flag: "
<< killHeavy;

edm::LogVerbatim("SimG4CoreApplication")
<< "StackingAction initiated with" << " flag for saving decay products in "
<< " Tracker: " << savePDandCinTracker
<< " in Calo: " << savePDandCinCalo
<< " in Muon: " << savePDandCinMuon
<< " everywhere: " << savePDandCinAll << "\n saveFirstSecondary"
<< ": " << saveFirstSecondary
<< " Tracking neutrino flag: " << trackNeutrino
<< " Kill Delta Ray flag: " << killDeltaRay
<< " Kill hadrons/ions flag: " << killHeavy;

if(killHeavy) {
edm::LogInfo("SimG4CoreApplication") << "StackingAction kill protons below "
<< kmaxProton/MeV <<" MeV, neutrons below "
<< kmaxNeutron/MeV << " MeV and ions"
<< " below " << kmaxIon/MeV << " MeV";
edm::LogVerbatim("SimG4CoreApplication")
<< "StackingAction kill protons below "
<< kmaxProton/MeV <<" MeV, neutrons below "
<< kmaxNeutron/MeV << " MeV and ions"
<< " below " << kmaxIon/MeV << " MeV";
}
killExtra = killDeltaRay || killHeavy || killInCalo || killInCaloEfH;

edm::LogInfo("SimG4CoreApplication") << "StackingAction kill tracks with "
edm::LogVerbatim("SimG4CoreApplication") << "StackingAction kill tracks with "
<< "time larger than " << maxTrackTime/ns
<< " ns ";
numberTimes = maxTimeNames.size();
if(0 < numberTimes) {
for (unsigned int i=0; i<numberTimes; ++i) {
edm::LogInfo("SimG4CoreApplication") << "StackingAction MaxTrackTime for "
edm::LogVerbatim("SimG4CoreApplication") << "StackingAction MaxTrackTime for "
<< maxTimeNames[i] << " is "
<< maxTrackTimes[i] << " ns ";
maxTrackTimes[i] *= ns;
}
}
if(limitEnergyForVacuum > 0.0) {
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "StackingAction LowDensity regions - kill if E < "
<< limitEnergyForVacuum/MeV << " MeV";
printRegions(lowdensRegions,"LowDensity");
}
if(deadRegions.size() > 0.0) {
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "StackingAction Dead regions - kill all secondaries ";
printRegions(deadRegions, "Dead");
}
if(gRRactive) {
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "StackingAction: "
<< "Russian Roulette for gamma Elimit(MeV)= "
<< gRusRoEnerLim/MeV << "\n"
Expand All @@ -161,7 +156,7 @@ StackingAction::StackingAction(const TrackingAction* trka, const edm::ParameterS
<< " World Prob= " << gRusRoWorld;
}
if(nRRactive) {
edm::LogInfo("SimG4CoreApplication")
edm::LogVerbatim("SimG4CoreApplication")
<< "StackingAction: "
<< "Russian Roulette for neutron Elimit(MeV)= "
<< nRusRoEnerLim/MeV << "\n"
Expand All @@ -174,15 +169,15 @@ StackingAction::StackingAction(const TrackingAction* trka, const edm::ParameterS
}

if(savePDandCinTracker) {
edm::LogInfo("SimG4CoreApplication") << "StackingAction Tracker regions: ";
edm::LogVerbatim("SimG4CoreApplication") << "StackingAction Tracker regions: ";
printRegions(trackerRegions,"Tracker");
}
if(savePDandCinCalo) {
edm::LogInfo("SimG4CoreApplication") << "StackingAction Calo regions: ";
edm::LogVerbatim("SimG4CoreApplication") << "StackingAction Calo regions: ";
printRegions(caloRegions, "Calo");
}
if(savePDandCinMuon) {
edm::LogInfo("SimG4CoreApplication") << "StackingAction Muon regions: ";
edm::LogVerbatim("SimG4CoreApplication") << "StackingAction Muon regions: ";
printRegions(muonRegions,"Muon");
}
worldSolid = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume()->GetSolid();
Expand Down Expand Up @@ -252,7 +247,8 @@ G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track * aTra
classification = fKill;
}
if (killInCaloEfH && classification != fKill) {
int pdgMother = std::abs(trackAction->geant4Track()->GetDefinition()->GetPDGEncoding());
int pdgMother =
std::abs(trackAction->geant4Track()->GetDefinition()->GetPDGEncoding());
if ((pdg == 22 || abspdg == 11) && pdgMother != 11 && pdgMother != 22 &&
isThisRegion(reg,caloRegions)) {
classification = fKill;
Expand Down Expand Up @@ -478,8 +474,8 @@ void StackingAction::printRegions(const std::vector<const G4Region*>& reg,
const std::string& word) const
{
for (unsigned int i=0; i<reg.size(); ++i) {
edm::LogInfo("SimG4CoreApplication") << " StackingAction: " << word
<< "Region " << i
<< ". " << reg[i]->GetName();
edm::LogVerbatim("SimG4CoreApplication")
<< " StackingAction: " << word << "Region " << i
<< ". " << reg[i]->GetName();
}
}