1 #ifndef __JROOT__JROOTTOOLKIT__
2 #define __JROOT__JROOTTOOLKIT__
16 #include "TStreamerInfo.h"
18 #include "TIterator.h"
23 #include "TGraphErrors.h"
40 namespace JPP {
using namespace JROOT; }
68 return T::Class_Name();
83 object->SetDirectory(0);
105 if (
object != NULL) {
108 for (
int i = 0; i !=
object->GetN(); ++i) {
109 object->SetPoint(i, 0.0, 0.0);
129 if (
object != NULL) {
132 for (
int i = 0; i !=
object->GetN(); ++i) {
133 object->SetPoint (i, 0.0, 0.0);
134 object->SetPointError(i, 0.0, 0.0);
154 if (
object != NULL) {
156 object->SetDirectory(0);
178 file.WriteTObject(&
object);
194 if (file != NULL && file->IsOpen()) {
196 const TString buffer(name);
198 TIter iter(file->GetStreamerInfoList());
200 for (
const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
201 if (buffer == TString(pStreamerInfo->GetName())) {
202 return pStreamerInfo;
239 if (pStreamerInfo != NULL)
240 return pStreamerInfo->GetClassVersion();
272 inline TString
parse(
const TPRegexp& regexp,
const TString&
string,
const int index = 1)
274 TPRegexp buffer = regexp;
275 TObjArray* array = buffer.MatchS(
string);
277 if (index - 1 < array->GetLast())
278 return ((TObjString*) array->At(index))->GetName();
304 const Double_t
value) :
316 inline operator Int_t()
const
335 if (parameter.
index >= 0 && parameter.
index < f1.GetNpar()) {
337 f1.SetParameter(parameter.
index, parameter.
value);
356 if (parameter.
index >= 0 && parameter.
index < f1.GetNpar()) {
358 f1.FixParameter(parameter.
index, parameter.
value);
377 if (index >= 0 && index < f1.GetNpar()) {
379 f1.ReleaseParameter(index);
398 inline bool setParLimits(TF1& f1,
const Int_t index, Double_t xmin, Double_t xmax)
402 if (index >= 0 && index < f1.GetNpar()) {
404 if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
405 if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
407 f1.SetParLimits(index, xmin, xmax);
426 if (index >= 0 && index < f1.GetNpar()) {
431 f1.GetParLimits(index, xmin, xmax);
433 return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
464 string buffer = (
const char*) text;
466 for (string::size_type pos = 0; pos != buffer.size(); ) {
468 if (isalpha(buffer[pos]) || buffer[pos] ==
'_') {
470 string::size_type len = 1;
472 while (pos + len != buffer.size() && (isalnum(buffer[pos+len]) || buffer[pos+len] ==
'_' || buffer[pos+len] ==
'.')) {
482 buffer.replace(pos, len, os.str());
484 pos += os.str().size();
492 return TFormula(
"/tmp", buffer.c_str()).Eval(0.0);
504 const int N = in.GetNbinsX();
508 for (
int i = 0; i <
N; i++) {
509 x[i] = in.GetBinCenter (i + 1);
510 y[i] = in.GetBinContent(i + 1);
513 TGraph* out =
new TGraph(N, &x[0], &y[0]);
536 return in.ProjectionX(
"_px", inf, sup);
542 return in.ProjectionY(
"_py", inf, sup);
566 object = TRegexp(buffer.c_str());
580 std::ostream&
operator<<(std::ostream& out,
const TRegexp&
object)
JFitParameter_t(const Int_t index, const Double_t value)
Constructor.
int getStreamerVersion(TFile *file, const char *name)
Get ROOT streamer version of class with given name.
const TStreamerInfo * getStreamerInfo(TFile *file, const char *name)
Get ROOT streamer information of class with given name.
bool releaseParameter(TF1 &f1, const Int_t index)
Release fit parameter.
Print objects in ASCII format using ROOT dictionary.
JFitParameter_t()
Default constructor.
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Auxiliary class for a type holder.
bool isParameterFixed(TF1 &f1, const Int_t index)
Check if fit parameter is fixed.
boost::property_tree::ptree parse(std::string str)
Auxiliary data structure for a parameter index and its value.
TFile * getFile() const
Get file.
TGraph * histogramToGraph(const TH1 &in)
Converts a 1D histogram to a TGraph with:
Double_t getResult(const TString &text, TObject *object=NULL)
Get result of given textual formula.
bool setParameter(TF1 &f1, const JFitParameter_t ¶meter)
Set fit parameter.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static void print(JRootWriter &writer, const JRootWritableClass &cls)
Write class contents to output.
then usage $script[distance] fi case set_variable R
bool setParLimits(TF1 &f1, const Int_t index, Double_t xmin, Double_t xmax)
Set fit parameter limits.
Type definition of ROOT based dictionary for ASCII O.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Auxiliary class to define a range between two values.
static data_type & getInstance()
Get unique instance of template class.
bool fixParameter(TF1 &f1, const JFitParameter_t ¶meter)
Fix fit parameter.
const char * getName()
Get ROOT name of given data type.
bool resetObject(JManager< JKey_t, JValue_t > *object, const bool reset=false)
Reset JManager object.
then usage $script[input file[working directory[option]]] nWhere option can be N
TH1 * projectHistogram(const TH2 &in, const JTOOLS::JRange< int > R, const char coordinate= 'x')
Helper method for ROOT Projection(X|Y) based on a JRange object and a coordinate. ...