#define ZTree_cxx // The class definition in ZTree.h has been generated automatically // by the ROOT utility TTree::MakeSelector(). This class is derived // from the ROOT class TSelector. For more information on the TSelector // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. // The following methods are defined in this file: // Begin(): called every time a loop on the tree starts, // a convenient place to create your histograms. // SlaveBegin(): called after Begin(), when on PROOF called only on the // slave servers. // Process(): called for each event, in this function you decide what // to read and fill your histograms. // SlaveTerminate: called at the end of the loop on the tree, when on PROOF // called only on the slave servers. // Terminate(): called at the end of the loop on the tree, // a convenient place to draw/fit your histograms. // // To use this file, try the following session on your Tree T: // // Root > T->Process("ZTree.C") // Root > T->Process("ZTree.C","some options") // Root > T->Process("ZTree.C+") // #include "ZTree.h" #include #include #include #include #include using std::cout; using std::endl; void ZTree::Begin(TTree * /*tree*/) { TString option = GetOption(); } void ZTree::SlaveBegin(TTree * /*tree*/) { TString option = GetOption(); hNmuons= new TH1D("hNmuons","hNmuons",100,0,100); hPTmuons= new TH1D("hPTmuons","hPTmuons",1000,0,1000); hetamuons=new TH1D("hetamuons","hetamuons",50,-2.5,2.5); fOutput->Add(hNmuons); fOutput->Add(hPTmuons); fOutput->Add(hetamuons); } Bool_t ZTree::Process(Long64_t entry) { b_muon4mom->GetEntry(entry); b_electron4mom->GetEntry(entry); //using one of these- I get a crash!!!!! std::cout<size()<Fill(muon4mom->size()); return kTRUE; } void ZTree::SlaveTerminate() { } void ZTree::Terminate() { TFile *fOut=new TFile("test.root","RECREATE"); fOut->cd(); hNmuons=dynamic_cast(fOutput->FindObject(Form("hNmuons"))); hNmuons->Write(); hPTmuons=dynamic_cast(fOutput->FindObject(Form("hPTmuons"))); hPTmuons->Write(); hetamuons=dynamic_cast(fOutput->FindObject(Form("hetamuons"))); hetamuons->Write(); fOut->Close(); } void Init(TTree *tree) { tree->SetBranchStatus("muon4mom",1); tree->SetBranchStatus("electron4mom",1); }