AB Tips and Tricks

C++ (including CINT)

What happen when you open two files in a ROOT scripts. Where the histo end up?

You can open 2 files to write, then you have to pay attention at the booking phase that decide where the object will go. The filling phase can be at any order. For example:

//---- Open file1:
  TFile file1("SkimmedD3PD.root","recreate","Skimmed Info");
//---- This tree will end up in file1 because is the only file open
  TTree *copiedTree = fChain->CloneTree(0);
//---- Same for this histo
  TH1F *h_test1 = new TH1F("h_test1","Photon Et",100,-3.,100.);

//---- Now I open file2. Everything booked from here will end up in that file 
  // My Ntuple with Results - BOOKING
  TFile file2("analysis.root","recreate");
//---- This Tree will go in file2
  TTree *t2 = new TTree("analysis","Reconst ntuple");
//---- This histo will go in file2
  TH1F *h_test2 = new TH1F("h_test2","Photon Et",100,-3.,100.);
  h_test1->Fill(test)
  h_test2->Fill(test)
  t2->Fill();
  if (EVENT_PASS) copiedTree->Fill();


  file1->Write()
  file2->Write()
  file1->Close()
  file2->Close()




Python

ROOT

Latex

Shell/Linux

-- AndreaBocci3 - 22-Jul-2010

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r5 - 2013-11-13 - AndreaBocci3
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback