#define toptree_cxx #include "../interface/toptree.h" #include #include #include #include #include #include #include using namespace TopTree; void toptree::Loop() { // In a ROOT session, you can do: // Root > .L toptree.C // Root > toptree t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); TTree *eventTree = fChain; //vector < TopTree::TRootMCParticle > MCpart; vector < TopTree::TRootJet > JetsCMS; vector < TopTree::TRootMET > METCMS; vector < TopTree::TRootElectron > ElecsCMS; vector < TopTree::TRootMuon > MuonsCMS; TBranch *CMS_jets; TClonesArray *tcjets; TBranch *CMS_met; TClonesArray *tcmet; TBranch *CMS_elecs; TClonesArray *tcelecs; TBranch *CMS_muons; TClonesArray *tcmuons; TTree * tree; TBranchClones *mc_br; TClonesArray *tcmc=0; fChain->SetBranchStatus("Jets",1); CMS_jets = (TBranch *) eventTree->GetBranch ("Jets"); tcjets = new TClonesArray ("TopTree::TRootJet", 32000); CMS_jets->SetAddress (&tcjets); //mc_br = (TBranchClones *) eventTree->GetBranch ("MCparticles_"); //tcmc = new TClonesArray ("TopTree::TRootMCParticle", 32000); //mc_br->SetAddress (&tcmc); //cout<<&tcmc<<" "<GetBranch ("MET"); tcmet = new TClonesArray ("TopTree::TRootMET", 32000); CMS_met->SetAddress (&tcmet); CMS_elecs = (TBranch *) eventTree->GetBranch ("Electrons"); tcelecs = new TClonesArray ("TopTree::TRootElectron", 32000); CMS_elecs->SetAddress (&tcelecs); CMS_muons = (TBranch *) eventTree->GetBranch ("Muons"); tcmuons = new TClonesArray ("TopTree::TRootMuon", 32000); CMS_muons->SetAddress (&tcmuons); // cout<<&tcmuons<GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; // cout<<" "<GetEntriesFast()<GetEntriesFast (); j++) //JetsCMS.push_back (*(TRootJet *) tcjets->At (j)); //for (int j = 0; j < tcmet->GetEntriesFast (); j++) //METCMS.push_back (*(TopTree::TRootMET *) tcmet->At (j)); //for (int j = 0; j < tcelecs->GetEntriesFast (); j++) //ElecsCMS.push_back (*(TopTree::TRootElectron *) tcelecs->At (j)); // for (int j = 0; j < tcmuons->GetEntriesFast (); j++){} // MuonsCMS.push_back (*(TopTree::TRootMuon *) tcmuons->At (j)); } }