Thread: Quick Question on ROOT and C++

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    23

    Quick Question on ROOT and C++

    Just a quick question. I was asked to do a set of things with ROOT to create a macro:

    1) Create histogram using this command TH1F *h = new TH1F("h", "h", 60,0,60);
    2) Open a root file
    3) Then from flasher in this root file use Draw function to draw om number in this histogram under the condition that we have string number 62 and om number 2
    4) Use command GetEntries() to get number of events


    Now I created the histogram with that TH1F command, then I opened the ROOT file with TFile...after that though I don't know how to use the Draw function. I can seperately do mytree->Draw(...) but how do I get that plot into my *h histogram I created? That way when I input h.Draw() I will see the plot of my unique histogram that has the required conditions. Step 4 is simple but step 3 is confusing.

    I can draw the histogram and have it printed out, but how do i have it saved into my TH1F historgram? is it just a simple command? like something that needs to be put into the parentheses?


    Thanks in advance
    Drew

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What's ROOT?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    23
    Quote Originally Posted by laserlight View Post
    What's ROOT?
    ROOT is a data analysis tool. It's not well known outside of scientists


    http://root.cern.ch/drupal/
    Last edited by dciampa; 10-15-2012 at 10:09 PM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > It's not well known outside of scientists
    So what makes you think we would know anything about it?

    If you've got a question about C++ (like how does new call constructors), then write your question in standard C++ terms.

    If you've got specific library issues, then the best place would be the documentation and support forums for the library you're using.
    Quick Question on ROOT and C++-screenshot-2012-10-16-05-26-59-png

    There are many 1000's of libraries in the world. The chance that you could pick a random programming forum and find experts in your chosen library is pretty well zero. Especially as you already admit is "not well known".
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Oct 2012
    Posts
    23
    Quote Originally Posted by Salem View Post
    > It's not well known outside of scientists
    So what makes you think we would know anything about it?

    If you've got a question about C++ (like how does new call constructors), then write your question in standard C++ terms.

    If you've got specific library issues, then the best place would be the documentation and support forums for the library you're using.
    Quick Question on ROOT and C++-screenshot-2012-10-16-05-26-59-png

    There are many 1000's of libraries in the world. The chance that you could pick a random programming forum and find experts in your chosen library is pretty well zero. Especially as you already admit is "not well known".
    Well most of the commands in ROOT are written in C++, I have used this site for C++ training. So I wanted to come here to get help. Obviously that was a bad choice though, thanks for informing me.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    We can help you with specific C++ questions, but considering that most here are not familiar with your specific library/tool, asking questions regarding that will probably net you few responses.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-17-2007, 03:47 PM
  2. Quick question...
    By Queatrix in forum C++ Programming
    Replies: 12
    Last Post: 05-30-2007, 05:59 AM
  3. Quick Question
    By Necrofear in forum Tech Board
    Replies: 9
    Last Post: 12-04-2005, 09:14 AM
  4. Quick Question
    By SinAmerica in forum C++ Programming
    Replies: 2
    Last Post: 10-23-2002, 02:28 AM
  5. quick question (please help
    By CBeginner in forum C++ Programming
    Replies: 11
    Last Post: 10-22-2002, 01:31 PM