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 =
"";
111 if (pathToGet ==
"" && calibArea !=
"")
114 if (pathToGet ==
"" && calibArea ==
"")
124 if (TString(gSystem->Getenv(
"ROOTCOREBIN")) !=
"" &&
fileExists(TString(gSystem->Getenv(
"ROOTCOREBIN"))+
"/data/JetUncertainties/"+
fileName))
125 pathToGet = TString(gSystem->Getenv(
"ROOTCOREBIN"))+
"/data/JetUncertainties/"+
fileName;
127 else if (TString(gSystem->Getenv(
"ROOTCOREDIR")) !=
"" &&
fileExists(TString(gSystem->Getenv(
"ROOTCOREDIR"))+
"/data/JetUncertainties/"+
fileName))
128 pathToGet = TString(gSystem->Getenv(
"ROOTCOREDIR"))+
"/data/JetUncertainties/"+
fileName;
130 else if (TString(gSystem->Getenv(
"TestArea")) !=
"" &&
fileExists(TString(gSystem->Getenv(
"TestArea"))+
"/Reconstruction/Jet/JetUncertainties/share/"+
fileName))
131 pathToGet = TString(gSystem->Getenv(
"TestArea"))+
"/Reconstruction/Jet/JetUncertainties/share/"+
fileName;
147 rootFile =
new TFile(pathToGet,
"READ");
152 std::vector<double>
getLogBins(
const size_t numBins,
const double minVal,
const double maxVal)
154 std::vector<double>
bins;
155 bins.resize(numBins+1);
157 const double dx = (
log(maxVal)-
log(minVal))/numBins;
158 for (
size_t iBin = 0; iBin <= numBins; ++iBin)
164 std::vector<double>
getUniformBins(
const size_t numBins,
const double minVal,
const double maxVal)
166 std::vector<double>
bins;
167 bins.resize(numBins+1);
169 const double dx = (maxVal-minVal)/numBins;
170 for (
size_t iBin = 0; iBin <= numBins; ++iBin)
171 bins[iBin] = minVal+iBin*
dx;
177 void scaleHistoAxes(TH1* toScale,
const double factorX,
const double factorY,
const double factorZ)
179 const int dim = toScale->GetDimension();
182 bool returnDuplicate =
false;
183 if (
dim == 1 && (factorX < 0 || fabs(factorX-1) < 1.
e-4) )
184 returnDuplicate =
true;
185 else if (
dim == 2 && (factorX < 0 || fabs(factorX-1) < 1.
e-4)
186 && (factorY < 0 || fabs(factorY-1) < 1.
e-4) )
187 returnDuplicate =
true;
188 else if (
dim == 3 && (factorX < 0 || fabs(factorX-1) < 1.
e-4)
189 && (factorY < 0 || fabs(factorY-1) < 1.
e-4)
190 && (factorZ < 0 || fabs(factorZ-1) < 1.
e-4) )
191 returnDuplicate =
true;
194 printf(
"ScaleHistoAxes: Doing nothing, as all scale factors require no changes\n");
199 const double facX = factorX < 0 ? 1 : factorX;
200 const double facY = factorY < 0 ? 1 : factorY;
201 const double facZ = factorZ < 0 ? 1 : factorZ;
204 if (fabs(facX-1) > 1.
e-4)
206 std::vector<double>
binsX;
207 for (
int iBin = 1; iBin <= toScale->GetNbinsX()+1; ++iBin)
208 binsX.push_back(toScale->GetXaxis()->GetBinLowEdge(iBin)*facX);
209 toScale->GetXaxis()->Set(
binsX.size()-1,&
binsX[0]);
212 if (
dim > 1 && fabs(facY-1) > 1.
e-4)
214 std::vector<double>
binsY;
215 for (
int iBin = 1; iBin <= toScale->GetNbinsY()+1; ++iBin)
216 binsY.push_back(toScale->GetYaxis()->GetBinLowEdge(iBin)*facY);
217 toScale->GetYaxis()->Set(
binsY.size()-1,&
binsY[0]);
220 if (
dim > 2 && fabs(facZ-1) > 1.
e-4)
222 std::vector<double>
binsZ;
223 for (
int iBin = 1; iBin <= toScale->GetNbinsZ()+1; ++iBin)
224 binsZ.push_back(toScale->GetZaxis()->GetBinLowEdge(iBin)*facZ);
225 toScale->GetZaxis()->Set(
binsZ.size()-1,&
binsZ[0]);