File indexing completed on 2025-02-23 09:21:55
0001
0002
0003
0004
0005
0006
0007
0008 void SetLeafAddress(TNtuple* ntuple, const char* name, void* address);
0009
0010 void plot()
0011 {
0012 gROOT->Reset();
0013 gStyle->SetPalette(1);
0014 gROOT->SetStyle("Plain");
0015
0016 TCanvas* c1 = new TCanvas ("c1","",20,20,1000,500);
0017
0018 TFile* f = new TFile("ICSD.root");
0019 f->ls();
0020
0021 TH1D* hist1 = new TH1D("histo","ICSD", 30, 0.0, 30);
0022
0023 Double_t ion = 0.0;
0024
0025 TNtuple* ntuple1 = (TNtuple*)f->Get("ntuple_1");
0026 bool rowWise = true;
0027 TBranch* eventBranch = ntuple1->FindBranch("row_wise_branch");
0028 if ( ! eventBranch ) rowWise = false;
0029 std::cout << "rowWise: " << rowWise << std::endl;
0030
0031 if ( ! rowWise ) {
0032 ntuple1->SetBranchAddress("ionisations", &ion);
0033 } else {
0034 SetLeafAddress(ntuple1, "ionisations",&ion);
0035 }
0036
0037 Int_t nentries = ntuple1->GetEntries();
0038
0039 for (Int_t i=0; i<nentries; i++)
0040 {
0041 ntuple1->GetEntry(i);
0042 hist1->Fill(ion);
0043 }
0044
0045 hist1->Draw();
0046 hist1->GetXaxis()->SetLabelSize(0.025);
0047 hist1->GetYaxis()->SetLabelSize(0.025);
0048
0049 hist1->GetXaxis()->SetTitleSize(0.035);
0050 hist1->GetYaxis()->SetTitleSize(0.035);
0051
0052
0053
0054
0055 hist1->GetXaxis()->SetTitle("ionisation number");
0056 hist1->GetYaxis()->SetTitle("frequency");
0057
0058 c1->SaveAs("ICSD.tiff");
0059 }
0060
0061 void SetLeafAddress(TNtuple* ntuple, const char* name, void* address) {
0062 TLeaf* leaf = ntuple->FindLeaf(name);
0063 if ( ! leaf ) {
0064 std::cerr << "Error in <SetLeafAddress>: unknown leaf --> " << name << std::endl;
0065 return;
0066 }
0067 leaf->SetAddress(address);
0068 }