#include #include #include #include #include #include #include #include "TSystem.h" #include "TChain.h" #include "TTree.h" #include "TObject.h" #include "TROOT.h" #include "TFile.h" class condTrk { public: //leaves of branch condTrk: //fheader Int_t run; //filled from standard ntuple variable Int_t subrun; //filled from standard ntuple variable Double_t var; Double_t anothervar; Int_t baz; }; void make_files(){ gROOT->Reset(); TFile *file1 = new TFile("testfile.root","NEW"); TTree *condNtpSR=(TTree*)gDirectory->FindObject("condNtpSR"); if (condNtpSR){ delete condNtpSR; condNtpSR=0; } condNtpSR = new TTree("condNtpSR","condNtpSR"); //create branch condTrk *condensed = new condTrk; condNtpSR -> Branch("condensed", &condensed); for(int i = 1; i < 10; i++){ condensed->run = i; condensed->subrun = i + 2; condNtpSR->Fill(); } condNtpSR->Write(); file1->Write(); file1->Close(); }