Skip to content

Commit

Permalink
fixed warning of static analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
civanch committed Sep 2, 2015
1 parent 23b38f9 commit 0f7fe9f
Show file tree
Hide file tree
Showing 23 changed files with 109 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@ EcalSelectiveReadoutSuppressor::run(const edm::EventSetup& eventSetup,
}

if(ievt_ <= 10){
int neb = (selectedBarrelDigis?selectedBarrelDigis->size():0);
if(selectedEndcapDigis) LogDebug("EcalSelectiveReadout")
// << __FILE__ << ":" << __LINE__ << ": "
<< "Number of EB digis passing the SR: "
<< selectedBarrelDigis->size()
<< "Number of EB digis passing the SR: " << neb
<< " / " << barrelDigis.size() << "\n";
if(selectedEndcapDigis) LogDebug("EcalSelectiveReadout")
// << __FILE__ << ":" << __LINE__ << ": "
Expand Down
48 changes: 1 addition & 47 deletions SimG4CMS/Calo/src/HFFibreFiducial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,18 @@

#include<iostream>

//#define DebugLog
//#define mkodebug

int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect)
{
#ifdef mkodebug
static double mX=0.;
static double mY=0.;
static double mZ=0.;
#endif
double xv = pe_effect.x(); // X in global system
double yv = pe_effect.y(); // Y in global system
#ifdef DebugLog
double zv = pe_effect.z(); // Z in global system
#endif
double phi = atan2(yv, xv); // In global system
if (phi < 0.) phi+=CLHEP::pi; // Just for security
double dph = CLHEP::pi/18; // 10 deg = a half sector width
double sph = dph+dph; // 20 deg = a sector width
int nphi = phi/dph; // 10 deg sector #
#ifdef DebugLog
edm::LogInfo("HFShower") <<"HFFibreFiducial:***> P = " << pe_effect
<< ", phi = " << phi/CLHEP::deg;
#endif
if (nphi > 35) nphi=35; // Just for security
double xl=0.; // local sector coordinates (left/right)
double yl=0.; // local sector coordinates (down/up)
Expand Down Expand Up @@ -58,16 +46,12 @@ int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect)
double sinr= sin(phir);
yl= xv*cosr+yv*sinr;
xl= yv*cosr-xv*sinr;
#ifdef DebugLog
edm::LogInfo("HFShower") << "HFFibreFiducial: nr " << nr << " phi " << phir/CLHEP::deg;
#endif
}
if (yl < 0) yl =-yl;
#ifdef DebugLog
edm::LogInfo("HFShower") << "HFFibreFiducial: Global Point " << pe_effect
<< " nphi " << nphi << " Local Sector Coordinates ("
<< xl << ", " << yl << "), widget # " << nwid;
#endif
// Provides a PMT # for the (x,y) hit in the widget # nwid (M. Kosov, 11.2010)
// Send comments/questions to [email protected]
// nwid = 1-18 for Forward HF, 19-36 for Backward HF (all equal now)
Expand All @@ -76,24 +60,20 @@ int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect)
static const int nWidM=36;
if (nwid > nWidM || nwid <= 0)
{
#ifdef DebugLog
edm::LogInfo("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: "
<< nwid << " == wrong widget number";
#endif
return 0;
}
static const double yMin= 13.1*CLHEP::cm; // start of the active area (Conv to mm?)
static const double yMax=129.6*CLHEP::cm; // finish of the active area (Conv to mm?)
if( yl < yMin || yl >= yMax )
{
#ifdef DebugLog
edm::LogInfo("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: Point "
<< "with y = " << yl << " outside acceptance ["
<< yMin << ":" << yMax << "], X = " << xv
<< ", Y = " << yv << ", x = " << xl << ", nW = "
<< nwid << ", phi = " << phi/CLHEP::deg
<< ", phir = " << phir/CLHEP::deg;
#endif
return 0; // ===> out of the acceptance
}
bool left=true; // flag of the left part of the widget
Expand All @@ -106,11 +86,9 @@ int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect)
static const double tg10=.17632698070847; // phi-angular acceptance of the widget
if (r > tg10)
{
#ifdef DebugLog
edm::LogInfo("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: (x = "
<< xl << ", y = " << yl << ", tg = " << r
<< ") out of the widget acceptance tg(10) " << tg10;
#endif
return 0;
}

Expand Down Expand Up @@ -1534,27 +1512,11 @@ int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect)
int ny=static_cast<int>((yl-yMin)/cellSize); // Layer number (starting from 0)
if (ny < 0 || ny >= nLay) // Sould never happen as was checked beforehand
{
#ifdef DebugLog
edm::LogInfo("HFShower") << "-Warning-HFFibreFiducial::PMTNumber: "
<< "check limits y = " << yl << ", nL=" << nLay;
#endif
return 0;
}
int nx=static_cast<int>(fx); // Cell number (starting from 0)
#ifdef mkodebug
double phist=atan2(xl, yl)/CLHEP::deg;
if(sqr(mX-xv)+sqr(mY-yv)+sqr(mZ-zv) > 9.)
{
std::cout<<"HFFibreFiducial::PMTNumber:X="<<xv<<",Y="<<yv<<",Z="<<zv<<",fX="<<fx
<<"->nX="<<nx<<",nY="<<ny<<",mX="<<nSL[ny]<<",x="<<xl<<",y="<<yl<<",s="
<<cellSize<<",nW="<<nwid<<",phi="<<phi/CLHEP::deg<<",phist="<<phist
<<",phir="<<phir/CLHEP::deg<<std::endl;
mX=xv;
mY=yv;
mZ=zv;
}
#endif
#ifdef DebugLog
double phis=atan2(xl, yl)/CLHEP::deg;
edm::LogInfo("HFShower") << "HFFibreFiducial::PMTNumber:X = " << xv
<< ", Y = " << yv << ", Z = " << zv << ", fX = "
Expand All @@ -1564,13 +1526,10 @@ int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect)
<< nwid << ", phi = " << phi/CLHEP::deg
<< ", phis = " << phis << ", phir = "
<< phir/CLHEP::deg;
#endif
if (nx >= nSL[ny])
{
#ifdef DebugLog
edm::LogInfo("HFShower") << "-Warning-HFFibreFiducial::nx/ny (" << nx
<< "," << ny <<") " << " above limit " << nSL[ny];
#endif
return 0; // ===> out of the acceptance
}
int code=0; // a prototype
Expand All @@ -1579,21 +1538,16 @@ int HFFibreFiducial::PMTNumber(const G4ThreeVector& pe_effect)
int flag= code%10;
int npmt= code/10;
bool src= false; // by default: not a source-tube
#ifdef DebugLog
edm::LogInfo("HFShower") << "HFFibreFiducial::nx/ny (" << nx << ","
<< ny << ") code/flag/npmt " << code << "/" << flag
<< "/" << npmt;
#endif
if (!flag) return 0; // ===> no fiber in the cell
else if (flag==1) npmt += 24;
else if (flag==3 || flag==4) {
flag-=2;
src=true;
}
#ifdef DebugLog
edm::LogInfo("HFShower") << "HFFibreFiducial::PMTNumber: src = " << src
<< ", npmt =" << npmt;
#endif
if (src) return -npmt; // return the negative number for the source
if (src) return -npmt; // return the negative number for the source
return npmt;
} // End of PMTNumber
9 changes: 4 additions & 5 deletions SimG4CMS/FP420/plugins/FP420Test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ void FP420Test::update(const EndOfTrack * trk) {
G4ThreeVector vert_pos = (*trk)()->GetVertexPosition(); // vertex ,where this track was created

// float eta = 0.5 * log( (1.+vert_mom.z()) / (1.-vert_mom.z()) );
float phi = atan2(vert_mom.y(),vert_mom.x());
if (phi < 0.) phi += twopi;
// float phi = atan2(vert_mom.y(),vert_mom.x());
// if (phi < 0.) phi += twopi;
// float phigrad = phi*180./pi;

// float XV = vert_pos.x(); // mm
Expand Down Expand Up @@ -1082,7 +1082,6 @@ void FP420Test::update(const EndOfEvent * evt) {
// Silicon Hit collection start
//0) if particle goes into flat beam pipe below detector:
int varia ; // = 0 -all; =1 - MI; =2 - noMI
varia = 0;
// Select MI or noMI over all 3 stations
// 1)MI:
// if particle goes through window into detector:
Expand Down Expand Up @@ -1154,8 +1153,8 @@ void FP420Test::update(const EndOfEvent * evt) {

// double th_hit = hitPoint.theta();
// double eta_hit = -log(tan(th_hit/2));
double phi_hit = hitPoint.phi();
if (phi_hit < 0.) phi_hit += twopi;
// double phi_hit = hitPoint.phi();
// if (phi_hit < 0.) phi_hit += twopi;
// double phigrad_hit = phi_hit*180./pi;
//UserNtuples->fillg60(eta_hit,losenergy);
//UserNtuples->fillg61(eta_hit,1.);
Expand Down
14 changes: 5 additions & 9 deletions SimG4CMS/Forward/src/BscTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,13 @@ void BscTest::update(const EndOfTrack * trk) {
G4ThreeVector vert_pos = (*trk)()->GetVertexPosition(); // vertex ,where this track was created

// float eta = 0.5 * log( (1.+vert_mom.z()) / (1.-vert_mom.z()) );
/*
float phi = atan2(vert_mom.y(),vert_mom.x());
if (phi < 0.) phi += twopi;
if(tracklength < z4) {
}

*/
// last step information
const G4Step* aStep = (*trk)()->GetStep();
G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
Expand Down Expand Up @@ -715,14 +716,13 @@ void BscTest::update(const EndOfEvent * evt) {
std::cout << "BscTest: theCAFI->entries = " << theCAFI->entries() << std::endl;
}
int varia ; // = 0 -all; =1 - MI; =2 - noMI
varia = 0;
//varia = 0;
if( lastpo.z()< z4) {
varia = 1;
}
else{
varia = 2;
} // no MI end:

for (int j=0; j<theCAFI->entries(); j++) {
BscG4Hit* aHit = (*theCAFI)[j];
CLHEP::Hep3Vector hitPoint = aHit->getEntry();
Expand All @@ -746,8 +746,8 @@ void BscTest::update(const EndOfEvent * evt) {
int trackIDhit = aHit->getTrackID();
unsigned int unitID = aHit->getUnitID();
double losenergy = aHit->getEnergyLoss();
double phi_hit = hitPoint.phi();
if (phi_hit < 0.) phi_hit += twopi;
//double phi_hit = hitPoint.phi();
//if (phi_hit < 0.) phi_hit += twopi;

double zz = hitPoint.z();

Expand Down Expand Up @@ -937,11 +937,7 @@ void BscTest::update(const EndOfEvent * evt) {
}
else{ //UserNtuples->fillp212(vy,float(0.),1.);
}

} // MI or no MI or all - end



} // primary end

if (verbosity > 0) {
Expand Down
6 changes: 1 addition & 5 deletions SimG4CMS/Forward/src/CastorSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ double CastorSD::getEnergyDeposit(G4Step * aStep) {
// if((thcher + DelFibPart ) > thFullReflRad &&
// thcher < (DelFibPart+thFullReflRad) )
// {
d_qz = 0.;
#ifdef debugLog
variant=3.;
#endif
Expand All @@ -422,10 +421,7 @@ double CastorSD::getEnergyDeposit(G4Step * aStep) {
if(tan_arcos != 0.) arg_arcos =(r*r-a*a-d*d)/tan_arcos;
arg_arcos = fabs(arg_arcos);
double th_arcos = acos(std::min(std::max(arg_arcos,double(-1.)),double(1.)));
d_qz = th_arcos/pi/2.;
d_qz = fabs(d_qz);


d_qz = fabs(th_arcos/pi/2.);

// }
// else
Expand Down
9 changes: 5 additions & 4 deletions SimG4CMS/Forward/src/CastorShowerLibrary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "G4Track.hh"
#include "G4ParticleTable.hh"
#include "Randomize.hh"
#include "G4PhysicalConstants.hh"
#include "CLHEP/Units/GlobalSystemOfUnits.h"

//#define DebugLog
Expand Down Expand Up @@ -233,14 +234,14 @@ CastorShowerEvent CastorShowerLibrary::getShowerHits(G4Step * aStep, bool & ok)
ok = true;

double pin = preStepPoint->GetTotalEnergy();
double etain = momDir.getEta();
double phiin = momDir.getPhi();
// double etain = momDir.getEta();
//double phiin = momDir.getPhi();

double zint = hitPoint.z();
double R=sqrt(hitPoint.x()*hitPoint.x() + hitPoint.y()*hitPoint.y());
double theta = atan2(R,std::abs(zint));
phiin = atan2(hitPoint.y(),hitPoint.x());
etain = -1*(std::log(std::tan((M_PI-theta)/2)));
double phiin = atan2(hitPoint.y(),hitPoint.x());
double etain = -std::log(std::tan((pi-theta)*0.5));

// Replace "interpolation/extrapolation" by new method "select" that just randomly
// selects a record from the appropriate energy bin and fills its content to
Expand Down
1 change: 1 addition & 0 deletions SimG4CMS/Forward/src/DoCastorAnalysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ void DoCastorAnalysis::update(const EndOfEvent * evt) {
CastorTree->Fill();

} // nentries > 0
delete theCastorNumScheme;
}

void DoCastorAnalysis::update(const EndOfRun * run) {;}
Expand Down
14 changes: 8 additions & 6 deletions SimG4CMS/Forward/src/ZdcTestAnalysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,16 @@ void ZdcTestAnalysis::update(const EndOfEvent * evt) {
for (int i = 0 ; i<nvertex; i++) {

G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
if (avertex == 0)
if (avertex == 0) {
std::cout << "ZdcTest End Of Event ERR: pointer to vertex = 0"
<< std::endl;
std::cout << "Vertex number :" <<i << std::endl;
int npart = avertex->GetNumberOfParticle();
if (npart ==0)
std::cout << "ZdcTest End Of Event ERR: no primary!" << std::endl;
if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
} else {
std::cout << "Vertex number :" <<i << std::endl;
int npart = avertex->GetNumberOfParticle();
if (npart ==0)
std::cout << "ZdcTest End Of Event ERR: no primary!" << std::endl;
if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
}
}

double px=0.,py=0.,pz=0.;
Expand Down
2 changes: 2 additions & 0 deletions SimG4CMS/HcalTestBeam/plugins/HcalTB02Analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ void HcalTB02Analysis::update(const EndOfEvent * evt) {
std::cout << " Event " << iEvt << std::endl;
else if ((iEvt < 10000) && (iEvt%1000 == 0))
std::cout << " Event " << iEvt << std::endl;

delete org;
}

void HcalTB02Analysis::fillEvent(HcalTB02HistoClass& product) {
Expand Down
4 changes: 2 additions & 2 deletions SimG4Core/Application/src/RunManagerMTWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@ void RunManagerMTWorker::initializeRun() {
}

void RunManagerMTWorker::terminateRun() {
if(m_tls->userRunAction) {
if(m_tls && m_tls->userRunAction) {
m_tls->userRunAction->EndOfRunAction(m_tls->currentRun.get());
m_tls->userRunAction.reset();
}

G4RunManagerKernel *kernel = G4WorkerRunManagerKernel::GetRunManagerKernel();
if(!kernel && !m_tls->runTerminated) {
if(kernel && m_tls && !m_tls->runTerminated) {
m_tls->currentEvent.reset();
m_simEvent.reset();
kernel->RunTermination();
Expand Down
10 changes: 5 additions & 5 deletions SimG4Core/CustomPhysics/src/CustomParticleFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void CustomParticleFactory::addCustomParticle(int pdgCode, double mass, const st
/////////////////////// Check!!!!!!!!!!!!!
G4String pType="custom";
G4String pSubType="";
G4double spectatormass;
G4ParticleDefinition* spectator;
G4double spectatormass = 0.0;
G4ParticleDefinition* spectator = nullptr;
//////////////////////
if(CustomPDGParser::s_isRHadron(pdgCode)) pType = "rhadron";
if(CustomPDGParser::s_isSLepton(pdgCode)) pType = "sLepton";
Expand Down Expand Up @@ -127,7 +127,7 @@ void CustomParticleFactory::addCustomParticle(int pdgCode, double mass, const st
bool stable = true;
double lifetime = -1;

G4DecayTable *decaytable = NULL;
G4DecayTable *decaytable = nullptr;
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();

CustomParticle *particle = new CustomParticle(name, massGeV, width, charge, spin,
Expand Down Expand Up @@ -170,11 +170,11 @@ void CustomParticleFactory::addCustomParticle(int pdgCode, double mass, const st
if (CustomPDGParser::s_issbottomHadron(pdgCode)) {
spectator = theParticleTable->FindParticle(1000005*sign);
} else {
spectator = 0;
spectator = nullptr;
edm::LogError("SimG4CoreCustomPhysics")<< "CustomParticleFactory: Cannot find spectator parton";
}
}
spectatormass = spectator->GetPDGMass();
if(spectator) spectatormass = spectator->GetPDGMass();
G4double cloudmass = mass-spectatormass/GeV;
CustomParticle *tmpParticle = new CustomParticle(
cloudname, cloudmass * GeV , 0.0*MeV, 0 ,
Expand Down
Loading

0 comments on commit 0f7fe9f

Please sign in to comment.