Hello,
I want to make an array of trees where each tree reads a text file and plots data from those text files onto a histogram. Does it work the same way as making an array of histograms by using a for loop? I will copy my code into this post. Root is also giving me the same message and a blank canvas every time I run the code. Here is the message:
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] cling_runtime_internal_throwIfInvalidPointer (no debug info)
[] (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] cling::IncrementalExecutor::executeWrapper(llvm::StringRef, cling::Value*) const (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] cling::Interpreter::RunFunction(clang::FunctionDecl const*, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] cling::Interpreter::EvaluateInternal(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] cling::MetaSema::actOnxCommand(llvm::StringRef, llvm::StringRef, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] cling::MetaParser::isXCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] cling::MetaParser::isCommand(cling::MetaSema::ActionResult&, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] cling::MetaProcessor::process(llvm::StringRef, cling::Interpreter::CompilationResult&, cling::Value*, bool) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] HandleInterpreterException(cling::MetaProcessor*, char const*, cling::Interpreter::CompilationResult&, cling::Value*) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCling.so] TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libCore.so] TApplication::ExecuteFile(char const*, int*, bool) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libRint.so] TRint::ProcessLineNr(char const*, char const*, int*) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/lib/root/libRint.so] TRint::Run(bool) (no debug info)
[/usr/local/Cellar/root/6.26.06_2/bin/root.exe] main (no debug info)
[/usr/lib/dyld] start (no debug info)
Error in : Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
For only on file, the code works. If I really want this to work I would have to repeat the same 3 or 4 lines of code for each text file and that. There has to be a short cut to this. Here is my code:
void RMS_mip_histogram()
{
Int_t n = 31;
TTree t[n];
TH2F * h[n];
for (Int_t i = 0; i < n; i++){
TString hist = Form("h%d",i);
t[i].ReadFile(Form("mipRMS_18%d",i+53),"cell:RMS:x:y");
t[i].Draw("RMS:y>>hist","RMS>0 && RMS<100 && y<=1");
h[i] = (TH2F*) gROOT->FindObject("hist");
h[i]->GetYaxis()->SetRangeUser(0,30);
h[i]->GetXaxis()->SetRangeUser(0,2);
}
TCanvas *c1 = new TCanvas("c1","c1",800,800);
h[0]->Draw("CANDLEX6");
for (Int_t i = 0; i < n; i++){
h[i+1]->Draw("CANDLEX6 SAME");
}
}
Hope to hear a response soon.
-Charlie Clark
_ROOT Version: ROOT 6.26/06
_Platform: MacOS