19 bool getTypeObjFromString<std::string>(
const std::string&
str, std::string&
obj)
35 bool toReturn =
false;
36 if (
str ==
"true" ||
str ==
"True" ||
str ==
"TRUE")
41 else if (
str ==
"false" ||
str ==
"False" ||
str ==
"FALSE")
49 toReturn = getTypeObjFromString<int>(
str,
value);
57 bool getTypeObjFromString<std::string>(
const TString&
str, std::string&
obj)
73 bool toReturn =
false;
74 if (
str.EqualTo(
"true",TString::kIgnoreCase))
79 else if (
str.EqualTo(
"false",TString::kIgnoreCase))
87 toReturn = getTypeObjFromString<int>(
str,
value);
96 return !gSystem->AccessPathName(
fileName);
101 TString pathToGet =
"";
112 if (pathToGet ==
"" && calibArea !=
"")
115 if (pathToGet ==
"" && calibArea ==
"")
125 if (TString(gSystem->Getenv(
"ROOTCOREBIN")) !=
"" &&
fileExists(TString(gSystem->Getenv(
"ROOTCOREBIN"))+
"/data/JetUncertainties/"+
fileName))
126 pathToGet = TString(gSystem->Getenv(
"ROOTCOREBIN"))+
"/data/JetUncertainties/"+
fileName;
128 else if (TString(gSystem->Getenv(
"ROOTCOREDIR")) !=
"" &&
fileExists(TString(gSystem->Getenv(
"ROOTCOREDIR"))+
"/data/JetUncertainties/"+
fileName))
129 pathToGet = TString(gSystem->Getenv(
"ROOTCOREDIR"))+
"/data/JetUncertainties/"+
fileName;
131 else if (TString(gSystem->Getenv(
"TestArea")) !=
"" &&
fileExists(TString(gSystem->Getenv(
"TestArea"))+
"/Reconstruction/Jet/JetUncertainties/share/"+
fileName))
132 pathToGet = TString(gSystem->Getenv(
"TestArea"))+
"/Reconstruction/Jet/JetUncertainties/share/"+
fileName;
148 rootFile =
new TFile(pathToGet,
"READ");
153 std::vector<double>
getLogBins(
const size_t numBins,
const double minVal,
const double maxVal)
155 std::vector<double>
bins;
156 bins.resize(numBins+1);
158 const double dx = (
log(maxVal)-
log(minVal))/numBins;
159 for (
size_t iBin = 0; iBin <= numBins; ++iBin)
165 std::vector<double>
getUniformBins(
const size_t numBins,
const double minVal,
const double maxVal)
167 std::vector<double>
bins;
168 bins.resize(numBins+1);
170 const double dx = (maxVal-minVal)/numBins;
171 for (
size_t iBin = 0; iBin <= numBins; ++iBin)
172 bins[iBin] = minVal+iBin*
dx;
178 void scaleHistoAxes(TH1* toScale,
const double factorX,
const double factorY,
const double factorZ)
180 const int dim = toScale->GetDimension();
183 bool returnDuplicate =
false;
184 if (
dim == 1 && (factorX < 0 || fabs(factorX-1) < 1.
e-4) )
185 returnDuplicate =
true;
186 else if (
dim == 2 && (factorX < 0 || fabs(factorX-1) < 1.
e-4)
187 && (factorY < 0 || fabs(factorY-1) < 1.
e-4) )
188 returnDuplicate =
true;
189 else if (
dim == 3 && (factorX < 0 || fabs(factorX-1) < 1.
e-4)
190 && (factorY < 0 || fabs(factorY-1) < 1.
e-4)
191 && (factorZ < 0 || fabs(factorZ-1) < 1.
e-4) )
192 returnDuplicate =
true;
195 printf(
"ScaleHistoAxes: Doing nothing, as all scale factors require no changes\n");
200 const double facX = factorX < 0 ? 1 : factorX;
201 const double facY = factorY < 0 ? 1 : factorY;
202 const double facZ = factorZ < 0 ? 1 : factorZ;
205 if (fabs(facX-1) > 1.
e-4)
207 std::vector<double>
binsX;
208 for (
int iBin = 1; iBin <= toScale->GetNbinsX()+1; ++iBin)
209 binsX.push_back(toScale->GetXaxis()->GetBinLowEdge(iBin)*facX);
210 toScale->GetXaxis()->Set(
binsX.size()-1,&
binsX[0]);
213 if (
dim > 1 && fabs(facY-1) > 1.
e-4)
215 std::vector<double>
binsY;
216 for (
int iBin = 1; iBin <= toScale->GetNbinsY()+1; ++iBin)
217 binsY.push_back(toScale->GetYaxis()->GetBinLowEdge(iBin)*facY);
218 toScale->GetYaxis()->Set(
binsY.size()-1,&
binsY[0]);
221 if (
dim > 2 && fabs(facZ-1) > 1.
e-4)
223 std::vector<double>
binsZ;
224 for (
int iBin = 1; iBin <= toScale->GetNbinsZ()+1; ++iBin)
225 binsZ.push_back(toScale->GetZaxis()->GetBinLowEdge(iBin)*facZ);
226 toScale->GetZaxis()->Set(
binsZ.size()-1,&
binsZ[0]);