Need some help with script please:

This is a discussion on Need some help with script please: within the C Programming forums, part of the General Programming Boards category; So I have to write a script that involves opening a histogram and reading the information within. This may seem ...

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

    Need some help with script please:

    So I have to write a script that involves opening a histogram and reading the information within. This may seem a bit cryptic since I'm using .ROOT files but this is what needs to be done in C/C++...

    1) open and read timediff*.root file
    - get number of events for flasher 62-2 (e.g. by plotting a hist with requiring only flasher 62-2 and reading number of events in the histogram) - best print it to the output file

    2) open and read newtimeDiff*.root file
    - read histograms for flasher 62 (string number) and dom number 2 and print number of events and overflows for string-dom pairs from 62-1 to 62-5 and put them into an output file

    Now the actual unique information obviously means nothing to you, but how would I go about writing something that will do what is being asked? If you need more information please ask.

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,444
    When dealing with specialized stuff like you are, it usually helps to give a little more context and possibly some links to whatever tools, tutorials, etc you're using. Are these files binary or text-based (i.e. can you open them in notepad and read them)?

    That aside, this sounds like a fairly basic file reading/writing program. Start of with some simple tutorials to get the handle of file IO in C/C++.

    Note, you need to pick one of C or C++, they are two different languages. When you decide, read some tutorials for that language (we have some for each here: C, C++ Programming Tutorials - Cprogramming.com), and if you have questions, post in the appropriate forum.

  3. #3
    Registered User
    Join Date
    Oct 2012
    Posts
    23
    Quote Originally Posted by anduril462 View Post
    When dealing with specialized stuff like you are, it usually helps to give a little more context and possibly some links to whatever tools, tutorials, etc you're using. Are these files binary or text-based (i.e. can you open them in notepad and read them)?

    That aside, this sounds like a fairly basic file reading/writing program. Start of with some simple tutorials to get the handle of file IO in C/C++.

    Note, you need to pick one of C or C++, they are two different languages. When you decide, read some tutorials for that language (we have some for each here: C, C++ Programming Tutorials - Cprogramming.com), and if you have questions, post in the appropriate forum.
    Thanks for the response. So I'm using Ubuntu, working with a bunch of ROOT files that have a bunch of information poured into histograms. These histograms plot numerous events. Now I need to read the histograms, take the number of events with given parameters and output it.

    A little more on the histograms...they record the number of times that a light was seen(events) and then the brightness of it. so the files usually have a couple thousand events with varying brightness's. So need to print out the mean brightness of the events and the number of events.

    Did that help a bit?

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    First:
    Are you able to open the file? Did you confirm it's open?

    Second:
    What is the problem you're having with reading the file?

    You are dancing around the specifics, so far, quite nicely!

  5. #5
    Registered User
    Join Date
    Oct 2012
    Posts
    23
    Quote Originally Posted by Adak View Post
    First:
    Are you able to open the file? Did you confirm it's open?

    Second:
    What is the problem you're having with reading the file?

    You are dancing around the specifics, so far, quite nicely!
    Well I haven't really written any type of script yet, I am sort of a beginner when it comes to this type of coding, I previously worked in FORTRAN so im only used to that. But yea I don't even know how to open the file...i mean the file isn't necessarily being opened, its contents and statistics just need to be read and then output. Sorry if this is a bit confusing.

    Currently reading more on I/O with C++ so maybe I'll wait and come back after getting acquainted with that.

    Thanks

  6. #6
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Are you talking about this "ROOT" framework?

    Then you are really better off doing it in C++ than C.

    Bye, Andreas

  7. #7
    Registered User
    Join Date
    Oct 2012
    Posts
    23
    Quote Originally Posted by AndiPersti View Post
    Are you talking about this "ROOT" framework?

    Then you are really better off doing it in C++ than C.

    Bye, Andreas

    Thank you, if anyone has any more tips then thank you in advance!

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    But you didn't answer Andreas' question!!

  9. #9
    Registered User
    Join Date
    Oct 2012
    Posts
    23
    Quote Originally Posted by AndiPersti View Post
    Are you talking about this "ROOT" framework?

    Then you are really better off doing it in C++ than C.

    Bye, Andreas
    meant to say yes! haha sorry

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    So you are making a thread on this, inside our C++ forum, right?

  11. #11
    Registered User
    Join Date
    Oct 2012
    Posts
    23
    Quote Originally Posted by Adak View Post
    So you are making a thread on this, inside our C++ forum, right?
    yea, i need to write a script in C++ that utilizes ROOT files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 06-16-2011, 05:17 AM
  2. Replies: 0
    Last Post: 02-05-2009, 05:59 PM
  3. help with script
    By munna_dude in forum Linux Programming
    Replies: 1
    Last Post: 10-24-2007, 01:06 PM
  4. help with script
    By falcons7 in forum C Programming
    Replies: 2
    Last Post: 09-30-2007, 01:26 PM
  5. Which script fit me well ?
    By black in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 08-14-2002, 07:31 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21