13 #ifndef LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALOREFROMPID_H 14 #define LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALOREFROMPID_H 23 #include "cetlib_except/exception.h" 26 #include "Math/Interpolator.h" 27 #include "TDirectory.h" 36 #include <type_traits> 37 #include <initializer_list> 55 template <
typename ROOTobj>
57 (TDirectory* sourceDir, std::string name);
63 std::pair<std::string, std::string>
splitROOTpath(std::string path);
131 Name(
"CalibrationFile"),
133 "path to calibration file and ROOT directory" 134 " (e.g. path/to/file.root:Dir/Dir)" 170 virtual float correctionFactor
188 virtual std::string
report()
const override 189 { std::ostringstream sstr; reportTo(sstr);
return sstr.str(); }
193 void readCalibration(std::string path);
197 template <
typename Stream>
198 void reportTo(Stream&& out)
const;
203 static void verifyOrder(TGraph
const* graph);
215 std::unique_ptr<ROOT::Math::Interpolator>
factor;
218 std::unique_ptr<ROOT::Math::Interpolator>
error;
220 double evalFactor(
double E)
const;
221 double evalError(
double E)
const;
230 template <
typename Stream>
231 void reportTo(Stream&& out)
const;
247 (TDirectory* SourceDir, std::string GraphName)
const;
252 (TDirectory* SourceDir, std::string GraphName,
PDGID_t id)
const;
257 TDirectory* SourceDir, std::string GraphName,
258 std::initializer_list<PDGID_t> ids
262 static TDirectory* OpenROOTdirectory(std::string path);
265 static std::unique_ptr<ROOT::Math::Interpolator>
266 createInterpolator(
unsigned int N,
double const*
x,
double const*
y);
282 template <
typename ROOTobj>
284 (TDirectory* sourceDir, std::string name)
288 <<
"Invalid source ROOT directory\n";
292 TObject* pObj = sourceDir->Get(name.c_str());
295 <<
"No object '" << name <<
"' in ROOT directory '" 296 << sourceDir->GetPath() <<
"'\n";
299 if (std::is_base_of<TH1, std::decay_t<ROOTobj>>::
value)
300 static_cast<TH1*
>(pObj)->SetDirectory(
nullptr);
303 std::unique_ptr<TObject> obj(pObj);
306 if (!obj->InheritsFrom(ROOTobj::Class())) {
308 <<
"Object '" << name <<
"' in ROOT directory '" 309 << sourceDir->GetPath() <<
"' is a " << obj->IsA()->GetName()
310 <<
", not derived from " << ROOTobj::Class()->GetName() <<
"\n";
315 return std::unique_ptr<ROOTobj>(
static_cast<ROOTobj*
>(obj.release()));
321 template <
typename Stream>
324 out <<
"Corrections for:";
325 out <<
"\n - neutral pion: ";
326 Calibration_pi0.reportTo(std::forward<Stream>(out));
327 out <<
"\n - photon: ";
328 Calibration_photon.reportTo(std::forward<Stream>(out));
329 out <<
"\n - electron/positron: ";
330 Calibration_electron.reportTo(std::forward<Stream>(out));
331 out <<
"\n - muon/antimuon: ";
332 Calibration_muon.reportTo(std::forward<Stream>(out));
333 out <<
"\n - other (default): ";
334 Calibration_other.reportTo(std::forward<Stream>(out));
340 template <
typename Stream>
345 out <<
"not present";
349 out <<
"uniform correction " << factor->Eval(
minE) <<
" +/- " 350 <<
error->Eval(
minE) <<
" for all energies";
353 out <<
"correction valid from E=" <<
minE 354 <<
" GeV (" << factor->Eval(
minE) <<
" +/- " <<
error->Eval(
minE)
356 <<
" GeV (" << factor->Eval(
maxE) <<
" +/- " <<
error->Eval(
maxE)
359 if (!appliesTo.empty()) {
360 out <<
"; covers particles ID={";
361 for (
auto id: appliesTo) out <<
" " << id;
371 #endif // LAREXAMPLES_SERVICES_SHOWERCALIBRATIONGALORE_PROVIDERS_SHOWERCALIBRATIONGALOREFROMPID_H CalibrationInfo_t Calibration_pi0
neutral pion calibration
CalibrationInfo_t Calibration_electron
electron/positron calibration
Internal structure containing the calibration information.
std::unique_ptr< ROOT::Math::Interpolator > error
parametrisation of the correction uncertainty
fhicl::Atom< std::string > CalibrationFile
Collection of configuration parameters for the service.
std::vector< PDGID_t > appliesTo
PID it applies to; unused.
A correction factor with global uncertainty.
Shower calibration service provider correcting according to PID.
CalibrationInfo_t Calibration_photon
photon calibration
ShowerCalibrationGaloreFromPID(fhicl::ParameterSet const &pset)
Constructor from a parameter set.
CalibrationInfo_t Calibration_other
default calibration
CalibrationInfo_t Calibration_muon
muon/antimuon calibration
std::unique_ptr< ROOT::Math::Interpolator > factor
parametrisation of the correction factor
std::string value(boost::any const &)
int PDGID_t
A type representing a particle ID in Particle Data Group convention.
Interface for a shower calibration service provider.
LArSoft-specific namespace.
virtual std::string report() const override
Returns a string with a short report of the current corrections.
std::unique_ptr< ROOTobj > readROOTobject(TDirectory *sourceDir, std::string name)
std::pair< std::string, std::string > splitROOTpath(std::string path)
Splits path into ROOT file name and directory path.
void reportTo(Stream &&out) const
Prints a short report of this correction.
ShowerCalibrationGaloreFromPID(Config const &config)
Constructor from the complete configuration object.
void reportTo(Stream &&out) const
Prints a short report of the current corrections.
cet::coded_exception< error, detail::translate > exception
Interface for a shower calibration service provider.