1 #ifndef __JROOT__JROOTTOOLKIT__
2 #define __JROOT__JROOTTOOLKIT__
12 #include "TObjString.h"
17 #include "TStreamerInfo.h"
19 #include "TIterator.h"
24 #include "TGraphErrors.h"
26 #include "TGraph2DErrors.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) {
157 for (
int i = 0; i !=
object->GetN(); ++i) {
158 object->SetPoint(i, 0.0, 0.0, 0.0);
178 if (
object != NULL) {
181 for (
int i = 0; i !=
object->GetN(); ++i) {
182 object->SetPoint (i, 0.0, 0.0, 0.0);
183 object->SetPointError(i, 0.0, 0.0, 0.0);
203 if (
object != NULL) {
205 object->SetDirectory(0);
229 const Int_t
n = g1->GetN();
232 g1->SetPoint(n, x, y);
249 const Int_t
n = g1->GetN();
252 g1->SetPoint(n, x, y, z);
271 const Int_t
n = g1->GetN();
274 g1->SetPoint(n, x, y);
275 g1->SetPointError(n, ex, ey);
298 const Int_t
n = g1->GetN();
301 g1->SetPoint(n, x, y, z);
302 g1->SetPointError(n, ex, ey, ez);
315 file.WriteTObject(&
object);
331 if (file != NULL && file->IsOpen()) {
333 const TString buffer(name);
335 TIter iter(file->GetStreamerInfoList());
337 for (
const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
338 if (buffer == TString(pStreamerInfo->GetName())) {
339 return pStreamerInfo;
376 if (pStreamerInfo != NULL)
377 return pStreamerInfo->GetClassVersion();
409 inline TString
parse(
const TPRegexp& regexp,
const TString&
string,
const int index = 1)
411 TPRegexp buffer = regexp;
412 TObjArray* array = buffer.MatchS(
string);
414 if (index - 1 < array->GetLast())
415 return ((TObjString*) array->At(index))->GetName();
441 const Double_t
value) :
453 inline operator Int_t()
const
472 if (parameter.
index >= 0 && parameter.
index < f1.GetNpar()) {
474 f1.SetParameter(parameter.
index, parameter.
value);
493 if (parameter.
index >= 0 && parameter.
index < f1.GetNpar()) {
495 f1.FixParameter(parameter.
index, parameter.
value);
514 if (index >= 0 && index < f1.GetNpar()) {
516 f1.ReleaseParameter(index);
535 inline bool setParLimits(TF1& f1,
const Int_t index, Double_t xmin, Double_t xmax)
539 if (index >= 0 && index < f1.GetNpar()) {
541 if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
542 if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
544 f1.SetParLimits(index, xmin, xmax);
563 if (index >= 0 && index < f1.GetNpar()) {
568 f1.GetParLimits(index, xmin, xmax);
570 return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
601 string buffer = (
const char*) text;
603 for (string::size_type pos = 0; pos != buffer.size(); ) {
605 if (isalpha(buffer[pos]) || buffer[pos] ==
'_') {
607 string::size_type len = 1;
609 while (pos + len != buffer.size() && (isalnum(buffer[pos+len]) || buffer[pos+len] ==
'_' || buffer[pos+len] ==
'.')) {
620 buffer.replace(pos, len, os.str());
622 pos += os.str().size();
630 return TFormula(
"/tmp", buffer.c_str()).Eval(0.0);
642 const int N = in.GetNbinsX();
646 for (
int i = 0; i <
N; i++) {
647 x[i] = in.GetBinCenter (i + 1);
648 y[i] = in.GetBinContent(i + 1);
651 TGraph* out =
new TGraph(N, &x[0], &y[0]);
665 inline TH1*
projectHistogram(
const TH2&
in, Double_t inf, Double_t sup,
const char coordinate =
'x') {
667 int inf_bin, sup_bin;
673 inf_bin = in.GetYaxis()->FindBin(inf);
674 sup_bin = in.GetYaxis()->FindBin(sup);
675 return in.ProjectionX(
"_px", inf_bin, sup_bin);
679 inf_bin = in.GetXaxis()->FindBin(inf);
680 sup_bin = in.GetXaxis()->FindBin(sup);
681 return in.ProjectionY(
"_py", inf_bin, sup_bin);
705 object = TRegexp(buffer.c_str());
719 std::ostream&
operator<<(std::ostream& out,
const TRegexp&
object)
JFitParameter_t(const Int_t index, const Double_t value)
Constructor.
void AddPoint(TGraph *g1, const Double_t x, const Double_t y)
Add point to TGraph.
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.
Auxiliary class for a type holder.
bool resetObject(JManager< JKey_t, JValue_t > *object, const bool reset=false)
Reset JManager object.
bool isParameterFixed(const 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.
TH1 * projectHistogram(const TH2 &in, Double_t inf, Double_t sup, const char coordinate= 'x')
Helper method for ROOT Projection(X|Y) based on a JRange object and a coordinate. ...
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static void print(JRootWriter &writer, const JRootWritableClass &cls)
Write class contents to output.
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 I/O.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
static data_type & getInstance()
Get unique instance of template class.
alias put_queue eval echo n
bool fixParameter(TF1 &f1, const JFitParameter_t ¶meter)
Fix fit parameter.
const char * getName()
Get ROOT name of given data type.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
then usage $script[input file[working directory[option]]] nWhere option can be N
Double_t g1(const Double_t x)
Function.