1 #ifndef __JROOT__JROOTTOOLKIT__
2 #define __JROOT__JROOTTOOLKIT__
11 #pragma GCC diagnostic push
12 #pragma GCC diagnostic ignored "-Wall"
14 #include "TObjString.h"
19 #include "TStreamerInfo.h"
21 #include "TIterator.h"
26 #include "TGraphErrors.h"
28 #include "TGraph2DErrors.h"
29 #include "TMultiGraph.h"
31 #pragma GCC diagnostic pop
47 namespace JPP {
using namespace JROOT; }
75 return T::Class_Name();
90 object->SetDirectory(0);
112 if (
object != NULL) {
115 for (
int i = 0;
i !=
object->GetN(); ++
i) {
116 object->SetPoint(
i, 0.0, 0.0);
136 if (
object != NULL) {
140 for (
int i = 0;
i !=
object->GetN(); ++
i) {
141 object->SetPoint (
i, 0.0, 0.0);
142 object->SetPointError(
i, 0.0, 0.0);
162 if (
object != NULL) {
165 for (
int i = 0;
i !=
object->GetN(); ++
i) {
166 object->SetPoint(
i, 0.0, 0.0, 0.0);
186 if (
object != NULL) {
189 for (
int i = 0;
i !=
object->GetN(); ++
i) {
190 object->SetPoint (
i, 0.0, 0.0, 0.0);
191 object->SetPointError(
i, 0.0, 0.0, 0.0);
211 if (
object != NULL) {
217 TIter next(object->GetListOfGraphs());
219 while (TGraph* graph = (TGraph*)next()) {
247 if (
object != NULL) {
249 object->SetDirectory(0);
273 const Int_t
n = g1->GetN();
276 g1->SetPoint(n, x, y);
293 const Int_t
n = g1->GetN();
296 g1->SetPoint(n, x, y, z);
315 const Int_t
n = g1->GetN();
318 g1->SetPoint(n, x, y);
319 g1->SetPointError(n, ex, ey);
342 const Int_t
n = g1->GetN();
345 g1->SetPoint(n, x, y, z);
346 g1->SetPointError(n, ex, ey, ez);
359 file.WriteTObject(&
object);
375 if (file != NULL && file->IsOpen()) {
377 const TString buffer(name);
379 TIter iter(file->GetStreamerInfoList());
381 for (
const TStreamerInfo* pStreamerInfo; (pStreamerInfo = (TStreamerInfo*) iter.Next()) != NULL; ) {
382 if (buffer == TString(pStreamerInfo->GetName())) {
383 return pStreamerInfo;
420 if (pStreamerInfo != NULL)
421 return pStreamerInfo->GetClassVersion();
453 inline TString
parse(
const TPRegexp& regexp,
const TString&
string,
const int index = 1)
455 TPRegexp buffer = regexp;
456 TObjArray* array = buffer.MatchS(
string);
459 if (index - 1 < array->GetLast()) {
460 result = ((TObjString*) array->At(index))->GetName();
489 const Double_t
value) :
501 inline operator Int_t()
const
520 if (parameter.
index >= 0 && parameter.
index < f1.GetNpar()) {
522 f1.SetParameter(parameter.
index, parameter.
value);
541 if (parameter.
index >= 0 && parameter.
index < f1.GetNpar()) {
543 f1.FixParameter(parameter.
index, parameter.
value);
562 if (index >= 0 && index < f1.GetNpar()) {
564 f1.ReleaseParameter(index);
587 if (index >= 0 && index < f1.GetNpar()) {
589 if (xmin == 0.0) { xmin = -numeric_limits<Double_t>::min(); }
590 if (xmax == 0.0) { xmax = +numeric_limits<Double_t>::min(); }
592 f1.SetParLimits(index, xmin, xmax);
611 if (index >= 0 && index < f1.GetNpar()) {
616 f1.GetParLimits(index, xmin, xmax);
618 return (xmin != 0.0 && xmax != 0.0 && xmin >= xmax);
651 const TRegexp DOUBLE(
"[0-9.][eE][+-0-9]");
653 string buffer = (
const char*) text;
655 for (string::size_type pos = 0; pos != buffer.size(); ) {
657 if (isalpha(buffer[pos]) || buffer[pos] ==
'_') {
659 string::size_type len = 1;
661 while (pos + len != buffer.size() && (isalnum(buffer[pos+len]) || buffer[pos+len] ==
'_' || buffer[pos+len] ==
'.')) {
665 if (len != 1 || pos == 0 || TString(buffer.substr(pos-1).c_str()).Index(DOUBLE) != 0) {
674 buffer.replace(pos, len, os.str());
676 pos += os.str().size();
685 return TFormula(
"/tmp", buffer.c_str()).Eval(0.0);
703 const int N = h1.GetNbinsX();
707 for (
int i = 0;
i <
N;
i++) {
708 x[
i] = h1.GetBinCenter (
i + 1);
709 y[
i] = h1.GetBinContent(
i + 1);
712 return new TGraph(N, &
x[0], &y[0]);
727 switch (projection) {
731 return h2.ProjectionX(
"_px", h2.GetYaxis()->FindBin(xmin), h2.GetYaxis()->FindBin(xmax));
735 return h2.ProjectionY(
"_py", h2.GetXaxis()->FindBin(xmin), h2.GetXaxis()->FindBin(xmax));
756 object = TRegexp(buffer.c_str());
770 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.
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
bool releaseParameter(TF1 &f1, const Int_t index)
Release fit parameter.
Print objects in ASCII format using ROOT dictionary.
JFitParameter_t()
Default constructor.
int getStreamerVersion(TFile *file, const char *const name)
Get ROOT streamer version of class with given name.
const TStreamerInfo * getStreamerInfo(TFile *file, const char *const name)
Get ROOT streamer information of class with given name.
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)
const JPolynome f1(1.0, 2.0, 3.0)
Function.
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.
then fatal The output file must have the wildcard in the name
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.
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
static data_type & getInstance()
Get unique instance of template class.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
bool fixParameter(TF1 &f1, const JFitParameter_t ¶meter)
Fix fit parameter.
then set_variable DETECTOR set_variable OUTPUT_FILE set_variable DAQ_FILE set_variable PMT_FILE else fatal Wrong number of arguments fi JPrintTree f $DAQ_FILE type
const char * getName()
Get ROOT name of given data type.
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.