but this means when i am wanting to look at different ROOT files i need to change it. How is the easiest way to a) use the root file that i load with root and B) is it easy to ask the user for the file that he wants to be analysed?
I do not understand the relationship between this post and your original post.
What is the problem?
Could you provide a short data file such that we can run your script?
I might have an idea what Gareth is looking for. Put your code into a file called e.g. LoadTree.C, and replace your code with void LoadTree(const char* filename){
TChain chain("100");
chain.Add(filename); Now users can call .x LoadTree.C+("somefile.root")
Is that what you need?
Axel, that is indeed the sort of thing i wanted. When i tried to replace my code with yours there seemed to be a few errors coming up (see below)
[quote]
root [5] .x LoadTree.C+(“500Eventsb.ntup.root”)
Info in : creating shared library /net/unixfsrv/hep/gbrown/./LoadTree_C.so
In file included from /net/unixfsrv/hep/gbrown/filevDYB64.h:32,
from /net/unixfsrv/hep/gbrown/filevDYB64.cxx:16:
/net/unixfsrv/hep/gbrown/LoadTree.C: In function void LoadTree(const char*)': /net/unixfsrv/hep/gbrown/LoadTree.C:5:TChain’ undeclared (first use this
function)
/net/unixfsrv/hep/gbrown/LoadTree.C:5: (Each undeclared identifier is reported
only once for each function it appears in.)
/net/unixfsrv/hep/gbrown/LoadTree.C:5: syntax error before (' token /net/unixfsrv/hep/gbrown/LoadTree.C:8:chain’ undeclared (first use this
function)
/net/unixfsrv/hep/gbrown/LoadTree.C:24: TH1F' undeclared (first use this function) /net/unixfsrv/hep/gbrown/LoadTree.C:24:h_ptsecond’ undeclared (first use this
function)
/net/unixfsrv/hep/gbrown/LoadTree.C:24: syntax error before (' token /net/unixfsrv/hep/gbrown/LoadTree.C:28:cout’ undeclared (first use this
function)
/net/unixfsrv/hep/gbrown/LoadTree.C:28: endl' undeclared (first use this function) /net/unixfsrv/hep/gbrown/LoadTree.C:15: warning: unused variableint sec’
g++: /net/unixfsrv/hep/gbrown/./filevDYB64.o: No such file or directory
Error in : Compilation failed!
Error: Function LoadTree(“500Eventsb.ntup.root”) is not defined in current scope :0:
Possible candidates are…
filename line:size busy function type and name
*** Interpreter error recovered ***[/quote]
i dont know if it means much too you. it might just be me making a mistake.
[quote]root [2] .x LoadTree.C+(“500Events.ntup.root”)
Info in TUnixSystem::ACLiC: creating shared library /net/unixfsrv/hep/gbrown/./LoadTree_C.so
In file included from /usr/include/c++/3.2.3/backward/iostream.h:31,
from /net/unixfsrv/hep/gbrown/LoadTree.C:1,
from /net/unixfsrv/hep/gbrown/file9pDntH.h:32,
from /net/unixfsrv/hep/gbrown/file9pDntH.cxx:16:
/usr/include/c++/3.2.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the <X.h> header for C++ includes, or instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
In file included from /net/unixfsrv/hep/gbrown/file9pDntH.h:32,
from /net/unixfsrv/hep/gbrown/file9pDntH.cxx:16:
/net/unixfsrv/hep/gbrown/LoadTree.C: In function void LoadTree(const char*)': /net/unixfsrv/hep/gbrown/LoadTree.C:11:TChain’ undeclared (first use this
function)
/net/unixfsrv/hep/gbrown/LoadTree.C:11: (Each undeclared identifier is reported
only once for each function it appears in.)
/net/unixfsrv/hep/gbrown/LoadTree.C:11: syntax error before (' token /net/unixfsrv/hep/gbrown/LoadTree.C:14:chain’ undeclared (first use this
function)
/net/unixfsrv/hep/gbrown/LoadTree.C:21: warning: unused variable `int sec’
g++: /net/unixfsrv/hep/gbrown/./file9pDntH.o: No such file or directory
Error in : Compilation failed!
Error: Function LoadTree(“500Events.ntup.root”) is not defined in current scope :0:
Possible candidates are…
filename line:size busy function type and name
*** Interpreter error recovered ***[/quote]
[quote]In file included from /net/unixfsrv/hep/gbrown/fileXjLmkQ.h:32,
from /net/unixfsrv/hep/gbrown/fileXjLmkQ.cxx:16:
/net/unixfsrv/hep/gbrown/LoadTree.C: In function void LoadTree(const char*)': /net/unixfsrv/hep/gbrown/LoadTree.C:23: base operand of->’ has non-pointer
type TChain' /net/unixfsrv/hep/gbrown/LoadTree.C:25: base operand of->’ has non-pointer
type TChain' /net/unixfsrv/hep/gbrown/LoadTree.C:26: base operand of->’ has non-pointer
type TChain' /net/unixfsrv/hep/gbrown/LoadTree.C:27: base operand of->’ has non-pointer
type TChain' /net/unixfsrv/hep/gbrown/LoadTree.C:28: base operand of->’ has non-pointer
type TChain' /net/unixfsrv/hep/gbrown/LoadTree.C:33: base operand of->’ has non-pointer
type TChain' /net/unixfsrv/hep/gbrown/LoadTree.C:21: warning: unused variableint sec’
g++: /net/unixfsrv/hep/gbrown/./fileXjLmkQ.o: No such file or directory
Error in : Compilation failed!
Error: Function LoadTree(“500Events.ntup.root”) is not defined in current scope :0:
Possible candidates are…
filename line:size busy function type and name
*** Interpreter error recovered ***
[/quote]
A futher question slightly away from the original would be if it would be possible to save all the cout to a .txt file so i can view all of the data, because at the moment there is too much data and some is lost.
[quote]what i would like it to do is copy all the text that i have outputed into a file.[/quote]I am sorry but this is too vague of a description for me to be able to give any help that might be remotely useful .
Where does ‘all the text’ comes from? How is it ‘outputed’ and by which part of your application?
Cheers,
Philippe.
PS. Still the closest answer is to use TSystem::RedirectOutput, did you try it out?
[quote=“pcanal”][quote]what i would like it to do is copy all the text that i have outputed into a file.[/quote]I am sorry but this is too vague of a description for me to be able to give any help that might be remotely useful .
Where does ‘all the text’ comes from? How is it ‘outputed’ and by which part of your application?
Cheers,
Philippe.
PS. Still the closest answer is to use TSystem::RedirectOutput, did you try it out?[/quote]
using TSystem::RedirectOutput do i just need to add that to the top of my code.
Sorry about the vague description, maybe this will be better
in my code i read from an ntup. i read through the event in a loop and Cout certain bits of information like “id”. now all text i have “cout”'ed to the screen i want to put into a text file.
dont know if that is better. I will try your earlier suggestion