Skip to content

Commit

Permalink
fix warnings reported by the latest Apple LLVM 4.2 clang++ (based
Browse files Browse the repository at this point in the history
on llvm 3.2svn). Mostly were:
warning: private field 'fOneDim' is not used [-Wunused-private-field]


git-svn-id: https://root.cern.ch/svn/root/trunk@48467 27541ba8-7e3a-0410-8455-c3a389f83636
  • Loading branch information
rdm committed Feb 4, 2013
1 parent 87ea663 commit de7d1fc
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 215 deletions.
3 changes: 2 additions & 1 deletion graf2d/asimage/src/libAfterImage/afterbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ double asim_parse_math(const char* str, char** endptr, double size) {
num = asim_parse_math(str + 1, &ptr, size);
else if (*str == '$')
{
for (ptr = (char*)str + 1 ; *ptr && !isspace(*ptr) && *ptr != '+' && *ptr != '-' && *ptr != '*' && *ptr != '!' && *ptr != '/' && *ptr != ')' ; ptr++);
for (ptr = (char*)str + 1 ; *ptr && !isspace(*ptr) && *ptr != '+' && *ptr != '-' && *ptr != '*' && *ptr != '!' && *ptr != '/' && *ptr != ')' ; ptr++)
;
num = asim_asxml_var_nget((char*)str + 1, ptr - (str + 1));
}else
num = strtod(str, &ptr);
Expand Down
6 changes: 3 additions & 3 deletions hist/hbook/src/THbookFile.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ THbookFile::THbookFile(const char *fname, Int_t lrecl)
char topdir[20];
snprintf(topdir,19,"lun%d",fLun);

Int_t ier;
Int_t ier = 0;
#ifndef WIN32
hropen(fLun,PASSCHAR(topdir),PASSCHAR(fname),PASSCHAR("p"),lrecl,ier,strlen(topdir),strlen(fname),1);
#else
Expand Down Expand Up @@ -885,7 +885,7 @@ TObject *THbookFile::ConvertProfile(Int_t id)

const Int_t kCON1 = 9;
Int_t i;
Float_t x;
Float_t x = 0.0;
Float_t y = 0.5*(ymin+ymax);
for (i=1;i<=ncx;i++) {
Int_t n = Int_t(q[ln+i]);
Expand Down Expand Up @@ -974,7 +974,7 @@ TObject *THbookFile::Convert2D(Int_t id)
Int_t lw = lq[lcont];
if (lw) h2->Sumw2();

Float_t x,y;
Float_t x = 0.0, y = 0.0;
for (Int_t j=0;j<=ncy+1;j++) {
for (Int_t i=0;i<=ncx+1;i++) {
hijxy(id,i,j,x,y);
Expand Down
2 changes: 1 addition & 1 deletion main/src/h2root.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ void convert_2d(Int_t id)
Int_t lw = lq[lcont];
if (lw) h2->Sumw2();

Float_t x,y;
Float_t x = 0.0, y = 0.0;
for (Int_t j=0;j<=ncy+1;j++) {
for (Int_t i=0;i<=ncx+1;i++) {
hijxy(id,i,j,x,y);
Expand Down
2 changes: 1 addition & 1 deletion math/foam/inc/TFoamSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class TFoamSampler : public ROOT::Math::DistSampler {
private:

// private member
bool fOneDim; // flag to indicate if the function is 1 dimension
// bool fOneDim; // flag to indicate if the function is 1 dimension
// bool fHasMode; // flag to indicate if a mode is set
// bool fHasArea; // flag to indicate if a area is set
// double fMode; // mode of dist
Expand Down
108 changes: 54 additions & 54 deletions math/foam/src/TFoamSampler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#include <cassert>
#include <cmath>

class FoamDistribution : public TFoamIntegrand {
class FoamDistribution : public TFoamIntegrand {

public:

FoamDistribution(const ROOT::Math::IMultiGenFunction & f, const ROOT::Fit::DataRange & range) :
fFunc(f),
fX(std::vector<double>(f.NDim() ) ),
FoamDistribution(const ROOT::Math::IMultiGenFunction & f, const ROOT::Fit::DataRange & range) :
fFunc(f),
fX(std::vector<double>(f.NDim() ) ),
fMinX(std::vector<double>(f.NDim() ) ),
fDeltaX(std::vector<double>(f.NDim() ) )
{
Expand All @@ -41,33 +41,33 @@ class FoamDistribution : public TFoamIntegrand {
for (unsigned int i = 0; i < range.NDim(); ++i) {
if (range.Size(i) == 0)
Error("FoamDistribution","Range is not set for coordinate dim %d",i);
else if (range.Size(i)>1)
else if (range.Size(i)>1)
Warning("FoamDistribution","Using only first range in coordinate dim %d",i);

std::pair<double,double> r = range(i);
std::pair<double,double> r = range(i);
fMinX[i] = r.first;
fDeltaX[i] = r.second - r.first;
fDeltaX[i] = r.second - r.first;
}
}
}
// in principle function does not need to be cloned

virtual double Density(int ndim, double * x) {
assert(ndim == (int) fFunc.NDim() );
for (int i = 0; i < ndim; ++i)
fX[i] = fMinX[i] + x[i] * fDeltaX[i];
fX[i] = fMinX[i] + x[i] * fDeltaX[i];

return (fFunc)(&fX[0]);
}

double MinX(unsigned int i) { return fMinX[i]; }
double DeltaX(unsigned int i) { return fDeltaX[i]; }

private:

const ROOT::Math::IMultiGenFunction & fFunc;
std::vector<double> fX;
std::vector<double> fMinX;
std::vector<double> fDeltaX;
std::vector<double> fX;
std::vector<double> fMinX;
std::vector<double> fDeltaX;

};

Expand All @@ -80,12 +80,12 @@ ClassImp(TFoamSampler)
/**
TFoamSampler class
class implementing the ROOT::Math::DistSampler interface using FOAM
for sampling arbitrary distributions.
for sampling arbitrary distributions.
*/
TFoamSampler::TFoamSampler() : ROOT::Math::DistSampler(),
fOneDim(false),
TFoamSampler::TFoamSampler() : ROOT::Math::DistSampler(),
// fOneDim(false)
// fDiscrete(false),
// fHasMode(false), fHasArea(false),
// fMode(0), fArea(0),
Expand All @@ -96,45 +96,45 @@ TFoamSampler::TFoamSampler() : ROOT::Math::DistSampler(),

TFoamSampler::~TFoamSampler() {
assert(fFoam != 0);
delete fFoam;
if (fFoamDist) delete fFoamDist;
delete fFoam;
if (fFoamDist) delete fFoamDist;
}

bool TFoamSampler::Init(const char *) {
bool TFoamSampler::Init(const char *) {

// initialize using default options
ROOT::Math::DistSamplerOptions opt(0);
ROOT::Math::IOptions * foamOpt = ROOT::Math::DistSamplerOptions::FindDefault("Foam");
if (foamOpt) opt.SetExtraOptions(*foamOpt);
ROOT::Math::IOptions * foamOpt = ROOT::Math::DistSamplerOptions::FindDefault("Foam");
if (foamOpt) opt.SetExtraOptions(*foamOpt);
return Init(opt);
}

bool TFoamSampler::Init(const ROOT::Math::DistSamplerOptions & opt) {
bool TFoamSampler::Init(const ROOT::Math::DistSamplerOptions & opt) {
// initialize foam classes using the given algorithm
assert (fFoam != 0 );
if (NDim() == 0) {
Error("TFoamSampler::Init","Distribution function has not been set ! Need to call SetFunction first.");
return false;
}

// initialize the foam
// initialize the foam
fFoam->SetkDim(NDim() );

// initialize random number
// initialize random number
if (!GetRandom()) SetRandom(gRandom);

// create TFoamIntegrand class
if (fFoamDist) delete fFoamDist;
// create TFoamIntegrand class
if (fFoamDist) delete fFoamDist;
fFoamDist = new FoamDistribution(ParentPdf(),PdfRange());

fFoam->SetRho(fFoamDist);
// set print level
fFoam->SetChat(opt.PrintLevel());

// get extra options
ROOT::Math::IOptions * fopt = opt.ExtraOptions();
if (fopt) {
int nval = 0;
// get extra options
ROOT::Math::IOptions * fopt = opt.ExtraOptions();
if (fopt) {
int nval = 0;
double fval = 0;
if (fopt->GetIntValue("nCells", nval) ) fFoam->SetnCells(nval);
if (fopt->GetIntValue("nCell1D", nval) && NDim() ==1) fFoam->SetnCells(nval);
Expand All @@ -154,55 +154,55 @@ bool TFoamSampler::Init(const ROOT::Math::DistSamplerOptions & opt) {
fFoam->Initialize();

return true;

}


void TFoamSampler::SetFunction(TF1 * pdf) {
// set function from a TF1 pointer
void TFoamSampler::SetFunction(TF1 * pdf) {
// set function from a TF1 pointer
SetFunction<TF1>(*pdf, pdf->GetNdim());
}
}

void TFoamSampler::SetRandom(TRandom * r) {
void TFoamSampler::SetRandom(TRandom * r) {
// set random generator (must be called before Init to have effect)
fFoam->SetPseRan(r);
}
fFoam->SetPseRan(r);
}

void TFoamSampler::SetSeed(unsigned int seed) {
void TFoamSampler::SetSeed(unsigned int seed) {
// set random generator seed (must be called before Init to have effect)
TRandom * r = fFoam->GetPseRan();
if (r) r->SetSeed(seed);
}
}

TRandom * TFoamSampler::GetRandom() {
// get random generator used
return fFoam->GetPseRan();
}
TRandom * TFoamSampler::GetRandom() {
// get random generator used
return fFoam->GetPseRan();
}

// double TFoamSampler::Sample1D() {
// double TFoamSampler::Sample1D() {
// // sample 1D distributions
// return (fDiscrete) ? (double) fFoam->SampleDiscr() : fFoam->Sample();
// return (fDiscrete) ? (double) fFoam->SampleDiscr() : fFoam->Sample();
// }

bool TFoamSampler::Sample(double * x) {
bool TFoamSampler::Sample(double * x) {
// sample multi-dim distributions

fFoam->MakeEvent();
fFoam->GetMCvect(x);
// adjust for the range
for (unsigned int i = 0; i < NDim(); ++i)
// adjust for the range
for (unsigned int i = 0; i < NDim(); ++i)
x[i] = ( (FoamDistribution*)fFoamDist)->MinX(i) + ( ( (FoamDistribution*) fFoamDist)->DeltaX(i))*x[i];

return true;
}
return true;
}


bool TFoamSampler::SampleBin(double prob, double & value, double *error) {
// sample a bin according to Poisson statistics

TRandom * r = GetRandom();
if (!r) return false;
value = r->Poisson(prob);
TRandom * r = GetRandom();
if (!r) return false;
value = r->Poisson(prob);
if (error) *error = std::sqrt(value);
return true;
return true;
}
Loading

0 comments on commit de7d1fc

Please sign in to comment.