Make a root framework clone

Hi all,

sorry about the general topic… But I don’t want a detailed answer, more like a
"yes you can without rewriting it all…" type of answer (or “no, you can’t” :wink:. As for
c++, I’m more than familiar with it.

So what I would like to do is to build, on top of root, my own “root” framework, that
is cint etc. It should provide me with all the functionalities of root, i.e. be 100%
compatible with old scripts, new scripts etc. But some default behaviour should
be different. As an example, do not open a TCanvas as default when drawing
something but MyCanvas. And so on. Is this doable or an enormous amount of

kind regards


I am not sure to understand what you want to do (at least your title is misleading).
From the standard root you can always load your own classes, these classes can derive from root classes or use them.



I’ll give an example. To me it is annoying that there is no good peak fitter
by default in root (gaussian+convoluted exponetial+bkg). So of course I have
written something that I like, that I can include in the list of action of executables
in a canvas object. This way I can fit peak with three four key strokes and I’m
happy. But, I have to add this executable to every TCanvas object… boring. So
I would like to replace the TCanvas with MyCanvas. This is of course easy if
I do it “by hand”. But I also like that I can do histo->Draw() and root will create
the canvas for me if there is non, but that will be a TCanvas and not “MyCanvas”.
Or, let say I like to create pads in a TCanvas with “Divide” but would like it to create
MyPad and not TPad… Or, I sort of like the histograms in
root but have added some extras and I would like TTree::Draw to create MyH1
and not TH1… and so on.

Dear Joa,

From your mail, I conclude that:
-you are new to C++
-you do not understand object-oriented programming, overloading and polymorphism.
-you did not look into the ROOt tutorials

so, I strongly recommend to you to reinvent the wheel and implement your own framework from scratch as it is unlikely that you will find anything suiting your needs on the market ::slight_smile:


Hi again,

If I want to draw a histogram, but no canvas is open… root will do

void TObject::AppendPad(Option_t *option)
// Append graphics object to current pad. In case no current pad is set
// yet, create a default canvas with the name “c1”.

if (!gPad) {
if (!gPad->IsEditable()) return;

TCanvas *TROOT::MakeDefCanvas() const
// Return a default canvas.

return (TCanvas*)gROOT->ProcessLine(“TCanvas::MakeDefCanvas();”);

Now, why is the type of object created in “TCanvas::MakeDefCanvas()” hard coded? Any object inheriting
from TCanvas could be used, no? A small option in rootrc could be used
together with a dynamic_cast<TCanvas*>(MyCanvas).

As for my example with TTree::Draw and the possibility to customize the
type of histogram (anything inheriting from TH1 should do?) it is enough to make a few changes around line 530 in TSelectorDraw.cxx and an user who wants to could change the default type of histogram that is created. Note, I’m not talking about number of bins etc.

A small comment, it seems as my language skills not are sufficient for the
ROOT forum. Neither my English nor my c++. I blame my Swedish origins and having learned Pascal and BASIC as a youngster. I do however enjoy
reinventing the wheel: I believe that moving from an somewhat round
construction in wood to a light wheel with spikes out of rubber and metal improved the performance of my bike!



[quote]Now, why is the type of object created in “TCanvas::MakeDefCanvas()” hard coded?[/quote]Because in our code TCanvas::MakeDefCanvas returns a TCanvas* and so the hard coded cast is correct and consistent (and do not imply anything about what is actually created inside MakeDefCanvas ; if it was to create a different type the C++ compiler would cast it to a TCanvas at the time of the execution of return).

[quote]As for my example with TTree::Draw and the possibility to customize the
type of histogram (anything inheriting from TH1 should do?) it is enough to make a few changes around line 530 in TSelectorDraw.cxx[/quote]Sure, however this only does it for TH1F histogram. Also note that you can already do:TH1 *histo = new MyTH1F("myhist","title",.....); mytree->Draw("...>myhist",....);