Home | News | Documentation | Download

Posting code? Read this first!

This is more addressed to the newer people of this forum, but I think it would be a good refresher for some.


What is so special about these things?
For one, they help show where you code begins and ends. Plus it doesn’t mess with your spacing or indents (a typical aesthetic in programming).

Why do you care so much?
When people are communicating code and there is no indentation and lousy spacing, code is super-hard to read.

How do I use code tags?
The code tag is simple, it is ```. So to begin a code tag, type the following: ``` . Then type all your code or copy and paste, whatever you want. When you are done, use the closing tag which is the same than previously used: ``` .

For example :

int main(int argc, char **argv)
TApplication *myApp = new TApplication(“myApp”, &argc, argv);
TH1F *h1f = new TH1F(“h1f”,“Test random numbers”, 200, 0, 10);
h1f->FillRandom(“sqroot”, 10000);
return 0;

Will display like this:

int main(int argc, char **argv)
   TApplication *myApp = new TApplication("myApp", &argc, argv);
   TH1F *h1f = new TH1F("h1f","Test random numbers", 200, 0, 10);
   h1f->FillRandom("sqroot", 10000);
   return 0;

See the difference? :wink:

Histograms in loop
Root very poor in layout of TGLabels Neet Help
Unable to compile root programs outside root environment
Compiled macro can't be executed
Gaussian fitting of multiple peaks using TSpectrum
Warning: unknown platform, assuming -mfloat-abi=soft
Changin the name of an existed histogram
RDataFrame Python string formatting
Fitting of mutiple peaks in the case of unknown number of peaks
Installing root for using pyroot in Anaconda package
ROOT 6.18 not searching under /usr/local/include for header
Problem building ROOT from source on mac os 10.15 (Catalina)
Is there a binary version of ROOT for macOS Catalina 10.5.2 I could download and use out of the box?
Error Building "makefile" : cant find some library
Maximum and minimum colour using the "COL" option in TH1::Draw
TEveCompount segfault
How to disable the invoking of C++
Arrays of Double32_t not recognized as arrays?
Writing an object to tree
Float16_t really encoded on 16 bits?
Some 'how-to' questions on Histograms
Set precision for the "TEXT" option of TH1::Draw
Ubuntu install error about xrootd
Error when installing ROOT6.18.04
Error when instaling to about 57%
Error in <TTreeFormula::Compile>: Invalid Syntax "&&"
TGPictureButton Not connected
Dynamical allocation of TString : malloc (C-like) crashes, new (C++-like) : fine : why?
TNetXNGFile::Open fails with double slash (//) in path
Marking an region with different background color in TGraph
Error messages displayed on opening root
Understanding installation of Root
Gaus generator for histograms
Error on opening root
Wait function in root
Filling maps and vectors in a single tree
Can't figure out the error
Environment variable not working
Histogram operations
Undeclared identifier error
Normalising a histogram directly
I am getting error when I am doing remainder opearation
Problem with remainder operator in root
Some doubts on Contour Plots
TAxis label math expression problem
Read problem on ULong64_t data type
SQLite tutorials
Mathmore affects result of ROOT::Fit, Roofit results unaffected
Root installation Ubuntu 18.04
Filling histogram with errors
ROOT and Catalina
Installing PyRoot, which version of Python was Root built against?
How to slim the branch array in RDataFrame
Parameter space values from Minuit
Reading TRefArray with RDataFrame in PyROOT
TGraphErrors with root 6.18
Creating and filling root tree in separate functions
Automatic pointer for a TBranch
TH3, TF3 and GL crashes
Compare histograms with Chi2Test, which option?
Turning Warnings into Errors
*** Break *** segmentation violation after certain point
TGraph2D - rebinning axis
Como instalar Root para ubuntu 14.04.3?
PYROOT: Fill histogram with numpy array
Z-axis labelling in TGraph2D
Joining TProfile end to end
Parametric range definition
Legend: fit curve entry and transparency
Set preprocessor #define values before compilation
Wrapping exec object in pyroot
Student's T-Test in ROOT
Initializing Muon Vectors: How to
Now that Python2.7 is not maintained anymore, is pre-compiled ROOT (going to be) shipped with Python3 bindings?
How to Extract Variable from Branch in ROOT
Can't open graphs from Terminal
Finding number of Muons
How to Add a Branch as a Vector to be Used in the Invariant Mass Vector
Reading Histogram from root file
WebSocket client using civetweb
ROOT v5 on CentOS8.x?
Unable extract correct data from Hits tree of ROOT file obtained from GATE simulation
Polymorphism with TClass::New() after dynamic loading of derived class library during runtime
How to initialize RVec
Can not plot graph?
Linker Error if compiling a simple graph in VS
Tips for Efficient and Successful Posting
Check for empty RDataFrame
Candle plot from mean stderr max min
"Error in <TNetXNGFile::Open>: [FATAL] Invalid address" message while accessing files
ACLiC compiling scripts and give name
Copy root file without cut events PyRoot
Accessing a dynamically allocated ROOT object after reference lost
Delete dynamically allocated TH1*'s
Root is not working and stop
Root is not working and stop
Mathematical procedure of TH1::Fit
Clear screen in CLING
Label title axis and SetOptStat
Normalization of TF1 (function) for log likelihood unbinned fit method
OriginPro and root
Root on windows (Visual studio 2010)
Problems while exiting root .q with canvas
Change marker style for some point or other solutions
Unzip a single basket to see if it is corrupted
Calculation of fit errors
Installing python bindings on an already existing root setup
Error shows on running ROOT after installing in windows 10
Error installing root on Linux device
Installing root in Windows 10
TH1::Print to show bin errors
How to change range Y-axis
TEve Beginner Question
Previous definition is here
Using a macro multiple times
Problem running root after update to Mac Catalina
Automatic exit of root in windows
How to modify the default value of arguments in context menu
Integral Error in Signal
Isodraw 7.1 issues
How to write a shell script to run a root macro created by MakeClass()?
Read from TTree
Switching code from pyroot to C++
My fiiting function for convolution crashes
Dictionary usage with Python 3
Square root of histogram
Other file types for ROOT file
Problem compiling with root
Rescale x axis of histogram
XRD GSI auth fails
ROOT::Fit vs RooFit
Compilation failed: V6.19/01(github master) with VS2019
Using data files in root
Multiple TGraph2D - Issue when using SetPoint
Error while loading shared libraries - libCore.so
Error: TFile.h: No such file or directory
ROOT master segfaults inside ubuntu18 docker container
RDF filter the content of branches
How to save my modified TH1D into my existing *.root files with TBrowser?
Error when running any Event Display tutorial/program on OSX
Facing problems while installing root 6.10/04
Invalid pointer to histograms created via TTree::Draw
How to install root without TMVA packages
TPython::Exec() crashes on root imports
Creating root file
ROOT Compilation failed with Mac OS Catalina
GUI interfaces of ROOT with high resolution display (HiDPI)
Bug in cmath pow? (typecasting, symbol unresolved)
Add 2D plot in a tree branch
Compiling ROOT 6.18.04 with GCC 9.2.0 on lxplus
Advanced TFormula and TF1 usage
Problem with RDataFrame::Fill in python
Converting file to ascii
Root catalina bug report
Problems after moving to Catalina
Compilation fails under Catalina MAC OS X
Plot with extrapolation and interpolation
RDataFrame::Snapshot and TDirectory
Color part of histogram
TList::Add(TObject *) and TList::AddLast(TObject *)
Changing the size of TCanvas on the go (Run Time)
TF1 vs TFormula parsing of "expo(0)"
Branch renaming failure (?)
Enum for TAttLine:SetLineStyle(Style_t)
OUtput file error
Error creating output file
Problem in installing root while doing cmake
Anchor TGaxis in a fixed position and zoom
Process data with saved cuts as cut.C
Increase smoothness of drawn curves
Ratio plot for multiple graphs
Saving Histograms from tree based Root file into a new root file
Pythia-root interface
Macro Runs Fine in Root 5, Seg Fault in Root 6
Histogram containing dots in name
TH2Poly::Draw("text") omitting negative numbers
Convert from .C macro to png
Error when trying to execute main()
Why is an "error: redefinition of [variable]" occurring every time I run code more than once?
Fisher distribution diverging where it shouldn't
New column RooDataSet
Multithreaded analysis doesn't seem to recognize null initialization of TH1D objects
Get data from tree's branch to txt
Read histogram from root file and do it a canvas
Multiple TGraph in a single TCanvas
Rerunning a macro error and recommendation for a bug-free ROOT version
Using cout in root
Compiling issue
Spectrum does not find and show right peaks
How to fit with non-function
Accessing the value of pi in ROOT
Setting a constant number of decimal points on plot axis
Cern root install error for ubuntu
Default Location of accessing macros
Use of THnSparse
Using examples given in documentations as a newbie
Shutdown of root window on undeclared identifier
Declaring libraries in root
Can't find $ROOTSYS directory
Plot variances in each bin
Reading order of Documents for learning root
Fill the histogram with mean=1 and sigma=2
Error in <TFile::WriteBuffer>: error writing all requested bytes to file
Changing default directory for accessing macros
How to plot Graph from text file
Get TFitResult for each slice from TH2::FitSlicesY()
Legend font and graph size
How to get the pointer of the default canvas in a TBrowser object
Integrate ROOT into my project with CMake
Creating data files for practice
How to install root on mac os x 10.15?
Trouble compiling with Python 2.7 on Fedora 31
Precision of axis labels
Not show labels
3.6f in an histogram example
TAxis::SetLabelSize documentation
Problems while exiting root .q with canvas (2)
Equalise font sizes of histograms drawn on different pads
Equalise axis title offset
Extracting a fit form a class function
Head scratching issues with RDataFrame
Persisting alias of a ttree
Draw vertical error bars of TGraphErrors
Print parameter of function (TF1)
Deregister TTreeReadeValue in TTreeReader
Problems configuring ROOT (Latest) for centos7 from cvmfs
Draw Histogram from .txt file. I tried with the already available answers, but didn't work for me
Good day . I am new to roofit and i am fiiting a crystal ball fit to my signal. Please help me
Root with xcode
PyRoot TCanvas is not persistent
How to fill two different histogram by two different colour?
gSystem->Load("mySharedLibrary.so") can not load debug info
How to extract values on the X-axis?
I draw a histogram from .txt file. The resultant histogram consist several peaks, how can i gaussian fit the histogram automatically detecting the peaks. I tried the tutorials>spectrum>peaks.C but did not succeed
Significance bin by bin
Convertying pyroot TFile in memory to c++ TFile
Scale the Xaxis
Gaussian fitting of mutiple peaks in the case of unknown number of peaks in histogram generated from .tex file (for example: test.tex). What are the change required in following code (this code is for 5 peaks)?
Fitting two peaks
Add entry to legend
Issue in compiling my code
TH2::Draw("TEXT") : set text size
How can I perform multiple Gaussian fit on a "rebinned histogram"?
Fitting two peaks alongs with the background
How to perfectly fit exp. data with 5 gaussians
Draw a plot of 2 variables
Writing data from one root file to another

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.