Basic Root

  • To open root, simply type:
  • root

  • Within root:
  • TLorentzVector blah0;

    (Declares a 4-Vector named blah0)

    blah0.SetPtEtaPhiM(myPt, myEta, myPhi, myMass);

    (Sets the values of blah0 as shown)

    blah0.SetPxPyPzE(myPx, myPy, myPz, myEnergy);

    (Alternate way to blah0)


    (Prints the Px of the 4-vector blah0)

  • Check out this root page for the full documentation about TLorentzVector

  • More detailed root stuff

    Plotting Histograms in root

    There are three steps to plotting a histogram:

    1) Declare the histogram before the event loop

    TH1D* histogram_name = new TH1D("histogram_name","histogram_name",Nbins,left_edge,right_edge);

    where histogram_name is a name you choose, while Nbins, left_edge, right_edge are values (Nbins is an integer, while left_edge and right_edge can value, integer or real).

    2) Fill the histogram in the event loop


    where fill_value is whatever you want to fill the histogram with in this event.

    3) Write out the histogram after the event loop


    Now run the job

    Opening a histogram file in root

    Once you have run the job, there should be a file: QuarkNet_test_RPV2012_Tag.root (the middle term might be something other than "test" depending on the data file). To open this file in root:

    root QuarkNet_test_RPV2012_Tag.root

    Some commands to use within root

    To quit out of root.


    To get a help list of all the "dot" commands in root


    To list all the histograms there are to look at


    To draw a histogram called histogram_name (if it exists)


    You can also do a tab-complete for a command. If you type


    then it will list all the things you can do with that histogram name (for instance: Draw(), Rebin(x), etc).