#define B2DPi_cxx #include "B2DPi.h" #include #include #include void setHistProp(TH1F* h, TString xtitle = " ", TString ytitle = " ") { h->SetLineWidth(2); h->SetNdivisions(505,"X"); h->SetNdivisions(505,"Y"); h->SetXTitle(xtitle); h->SetYTitle(ytitle); h->GetXaxis()->SetTitleSize(0.05); h->GetYaxis()->SetTitleSize(0.05); h->GetXaxis()->SetLabelSize(0.05); h->GetYaxis()->SetLabelSize(0.05); h->GetXaxis()->SetTitleOffset(1.0); h->GetYaxis()->SetTitleOffset(1.0); } void B2DPi::Loop() { // In a ROOT session, you can do: // Root > .L B2DPi.C // Root > B2DPi 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; TFile *fout = new TFile("temp.root","RECREATE"); TTree *newtree = fChain->CloneTree(0); Long64_t nentries = fChain->GetEntriesFast(); TH1F *bmass = new TH1F("bmass","B#rightarrowD#pi Mass",60,5000,5600); TH1F *benergy = new TH1F("benergy","B#rightarrowD#pi Energy (GeV)",50,0,500); TH1F *bdecaytime = new TH1F("bdecaytime","B#rightarrowD#pi Decay Time (ps)",50,0,10); TH1F *bflightdist = new TH1F("bflightdist","B#rightarrowD#pi Flight Distance (mm)",50,0,50); cout << " Number of entries = " << nentries << endl; Long64_t nbytes = 0, nb = 0; //for (Long64_t jentry=0; jentryGetEntry(jentry); nbytes += nb; bmass->Fill(B_M); benergy->Fill(B_PE/1000.0); bdecaytime->Fill(B_TAU*1000); bflightdist->Fill(B_FD_OWNPV); newtree->Fill(); // if (Cut(ientry) < 0) continue; } fout->Write(); gStyle->SetPadLeftMargin(0.13); gStyle->SetPadBottomMargin(0.13); setHistProp(bmass, "Mass (GeV/c^{2})", "Number/10 MeV/c^{2}"); setHistProp(benergy, "Energy (GeV)", "Number/10 GeV"); setHistProp(bdecaytime, "Decay Time (ps)", "Number/0.2 ps"); setHistProp(bflightdist, "Distance (mm)", "Number/mm"); TCanvas *c = new TCanvas("c","B Decay Properties",700,700); c->Divide(2,2); c->cd(1); bmass->Draw(); c->cd(2); benergy->Draw(); c->cd(3); bdecaytime->Draw(); c->cd(4); bflightdist->Draw(); }