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"
27 #include "TMultiGraph.h"
44 namespace JPP {
using namespace JROOT; }
72 return T::Class_Name();
87 object->SetDirectory(0);
109 if (
object != NULL) {
112 for (
int i = 0; i !=
object->GetN(); ++i) {
113 object->SetPoint(i, 0.0, 0.0);
133 if (
object != NULL) {
137 for (
int i = 0; i !=
object->GetN(); ++i) {
138 object->SetPoint (i, 0.0, 0.0);
139 object->SetPointError(i, 0.0, 0.0);
159 if (
object != NULL) {
162 for (
int i = 0; i !=
object->GetN(); ++i) {
163 object->SetPoint(i, 0.0, 0.0, 0.0);
183 if (
object != NULL) {
186 for (
int i = 0; i !=
object->GetN(); ++i) {
187 object->SetPoint (i, 0.0, 0.0, 0.0);
188 object->SetPointError(i, 0.0, 0.0, 0.0);
208 if (
object != NULL) {
214 TIter next(object->GetListOfGraphs());
216 while (TGraph* graph = (TGraph*)next()) {
244 if (
object != NULL) {
246 object->SetDirectory(0);
270 const Int_t
n = g1->GetN();
273 g1->SetPoint(n, x, y);
290 const Int_t
n = g1->GetN();
293 g1->SetPoint(n, x, y, z);
312 const Int_t
n = g1->GetN();
315 g1->SetPoint(n, x, y);
316 g1->SetPointError(n, ex, ey);
339 const Int_t
n = g1->GetN();
342 g1->SetPoint(n, x, y, z);
343 g1->SetPointError(n, ex, ey, ez);
356 file.WriteTObject(&
object);
372 if (file != NULL && file->IsOpen()) {
374 const TString buffer(name);
376 TIter iter(file->GetStreamerInfoList());
378 for (
const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
379 if (buffer == TString(pStreamerInfo->GetName())) {
380 return pStreamerInfo;
417 if (pStreamerInfo != NULL)
418 return pStreamerInfo->GetClassVersion();
450 inline TString
parse(
const TPRegexp& regexp,
const TString&
string,
const int index = 1)
452 TPRegexp buffer = regexp;
453 TObjArray* array = buffer.MatchS(
string);
455 if (index - 1 < array->GetLast())
456 return ((TObjString*) array->At(index))->GetName();
482 const Double_t
value) :
494 inline operator Int_t()
const
513 if (parameter.
index >= 0 && parameter.
index < f1.GetNpar()) {
515 f1.SetParameter(parameter.
index, parameter.
value);
534 if (parameter.
index >= 0 && parameter.
index < f1.GetNpar()) {
536 f1.FixParameter(parameter.
index, parameter.
value);
555 if (index >= 0 && index < f1.GetNpar()) {
557 f1.ReleaseParameter(index);
576 inline bool setParLimits(TF1& f1,
const Int_t index, Double_t xmin, Double_t xmax)
580 if (index >= 0 && index < f1.GetNpar()) {
582 if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
583 if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
585 f1.SetParLimits(index, xmin, xmax);
604 if (index >= 0 && index < f1.GetNpar()) {
609 f1.GetParLimits(index, xmin, xmax);
611 return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
644 string buffer = (
const char*) text;
646 for (string::size_type pos = 0; pos != buffer.size(); ) {
648 if (isalpha(buffer[pos]) || buffer[pos] ==
'_') {
650 string::size_type len = 1;
652 while (pos + len != buffer.size() && (isalnum(buffer[pos+len]) || buffer[pos+len] ==
'_' || buffer[pos+len] ==
'.')) {
663 buffer.replace(pos, len, os.str());
665 pos += os.str().size();
673 return TFormula(
"/tmp", buffer.c_str()).Eval(0.0);
691 const int N = h1.GetNbinsX();
695 for (
int i = 0; i <
N; i++) {
696 x[i] = h1.GetBinCenter (i + 1);
697 y[i] = h1.GetBinContent(i + 1);
700 return new TGraph(N, &
x[0], &y[0]);
713 inline TH1*
projectHistogram(
const TH2& h2,
const Double_t xmin,
const Double_t xmax,
const char projection)
715 switch (projection) {
719 return h2.ProjectionX(
"_px", h2.GetYaxis()->FindBin(xmin), h2.GetYaxis()->FindBin(xmax));
723 return h2.ProjectionY(
"_py", h2.GetXaxis()->FindBin(xmin), h2.GetXaxis()->FindBin(xmax));
744 object = TRegexp(buffer.c_str());
758 inline 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.
then echo Enter input within $TIMEOUT_S seconds echo n User name
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
then for HISTOGRAM in h0 h1
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.
I/O formatting auxiliaries.
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.
bool setParLimits(TF1 &f1, const Int_t index, Double_t xmin, Double_t xmax)
Set fit parameter limits.
TGraph * histogramToGraph(const TH1 &h1)
Helper method to convert a 1D histogram to a graph.
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.
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 CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
then usage $script< string identifier >< detectorfile > event file(toashort file)+" "\nNote that the event files and toashort files should be one-to-one related." fi if (( $
TH1 * projectHistogram(const TH2 &h2, const Double_t xmin, const Double_t xmax, const char projection)
Helper method for ROOT histogram projections.
Double_t g1(const Double_t x)
Function.