Hello everyone,
I start to write my own script to analyse the Z boson decay to double muons using root.
My question is that when I open the browser (using the command new TBrowser
), I see the distributions of muonPx, muonPy and muonPz as Gausian, but when I read the browser (see my code bellow) I find only one bin in each histogram (I do not get the same resulte as in the browser)!!
Please how can I fix this problem? Is there any problem or wrong command?
Thank you
// ------------------------------
// My code
// ------------------------------
//
// This code calculate the masste of the Z boson using TTree from
// its decay to double charged muons \mu{+}\mu{-}
//
void ctr1()
{
TFile *input =new TFile("ntuple_array.root","READ");
//auto hfile = TFile("ntuple_array.root");
TTree *tree = (TTree*)input->Get("ntupleProducer/tree;1");
Float_t muonPx, muonPy, muonPz, muonPt;
tree->SetBranchAddress("muonPx",&muonPx);
tree->SetBranchAddress("muonPy",&muonPy);
tree->SetBranchAddress("muonPz",&muonPz);
tree->SetBranchAddress("muonPt",&muonPt);
Int_t entries = (Int_t)tree->GetEntries();
cout<< entries << endl;
TH1F *hist = new TH1F("hist", "Histogram", 100, -150., 150.);
TH1F *hist2 = new TH1F("hist2", "Histogram2", 100, -150., 150.);
TH1F *hist3 = new TH1F("hist3", "Histogram3", 100, -150., 150.);
TH1F *hist4 = new TH1F("hist4", "Histogram4", 100, -150., 150.);
TH1F *hist5 = new TH1F("hist5", "Histogram5", 100, 0., 150.);
for(int i = 0; i < entries; i++)
{
//tree->GetEntry(i);
//cout<< muonPx << "\t" << muonPy << "\t" << muonPz << "\t" << muonPz <<e\
ndl;
hist->Fill(muonPx);
hist2->Fill(muonPy);
hist3->Fill(muonPz);
hist4->Fill(muonPt);
hist5->Fill(2*sqrt(muonPx*muonPx+muonPy*muonPy+muonPz*muonPz));
}
TCanvas *cH1 = new TCanvas("cH1","multipads",900,900);
cH1->Divide(2,2,0,0);
cH1->SetTickx();
cH1->SetTicky();
cH1->cd(1);
hist->GetXaxis()->SetTitle("muonPx");
hist->Draw();
cH1->cd(2);
hist2->GetXaxis()->SetTitle("muonPy");
hist2->Draw();
cH1->cd(3);
hist3->GetXaxis()->SetTitle("muonPz");
hist3->Draw();
cH1->cd(4);
hist4->GetXaxis()->SetTitle("muonPt");
hist4->Draw();
TCanvas *cH2 = new TCanvas();
cH2->SetTickx();
cH2->SetTicky();
hist5->Draw();
//input->Close();
}
// ---------------------------------
// End of my code
// ---------------------------------