{ "cells": [ { "cell_type": "markdown", "id": "05eba90d", "metadata": {}, "source": [ "# testUnfold7a\n", "Test program for the classes TUnfoldDensity and TUnfoldBinning.\n", "\n", "A toy test of the TUnfold package\n", "\n", "This example is documented in conference proceedings:\n", "\n", " arXiv:1611.01927\n", " 12th Conference on Quark Confinement and the Hadron Spectrum (Confinement XII)\n", "\n", "This is an example of unfolding a two-dimensional distribution\n", "also using an auxiliary measurement to constrain some background\n", "\n", "The example comprises several macros\n", " - testUnfold7a.C create root files with TTree objects for\n", " signal, background and data\n", " - write files testUnfold7_signal.root\n", " testUnfold7_background.root\n", " testUnfold7_data.root\n", "\n", " - testUnfold7b.C loop over trees and fill histograms based on the\n", " TUnfoldBinning objects\n", " - read testUnfold7binning.xml\n", " testUnfold7_signal.root\n", " testUnfold7_background.root\n", " testUnfold7_data.root\n", "\n", " - write testUnfold7_histograms.root\n", "\n", " - testUnfold7c.C run the unfolding\n", " - read testUnfold7_histograms.root\n", " - write testUnfold7_result.root\n", " testUnfold7_result.ps\n", "\n", "\n", " **Version 17.6, in parallel to changes in TUnfold**\n", "\n", " This file is part of TUnfold.\n", "\n", " TUnfold is free software: you can redistribute it and/or modify\n", " it under the terms of the GNU General Public License as published by\n", " the Free Software Foundation, either version 3 of the License, or\n", " (at your option) any later version.\n", "\n", " TUnfold is distributed in the hope that it will be useful,\n", " but WITHOUT ANY WARRANTY; without even the implied warranty of\n", " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n", " GNU General Public License for more details.\n", "\n", " You should have received a copy of the GNU General Public License\n", " along with TUnfold. If not, see .\n", "\n", "\n", "\n", "**Author:** Stefan Schmitt DESY, 14.10.2008 \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:11 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "45b22ed1", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:33.794786Z", "iopub.status.busy": "2026-05-19T20:11:33.794654Z", "iopub.status.idle": "2026-05-19T20:11:33.801635Z", "shell.execute_reply": "2026-05-19T20:11:33.801141Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "\n", "#include \n", "#include \n", "#include \n", "#include \n", "#include \n", "#include \n", "#include \n", "\n", "#define MASS1 0.511E-3\n", "\n", "using std::cout;\n", "\n", "TRandom *g_rnd=nullptr;\n", "\n", "class ToyEvent7 {\n", "public:\n", " void GenerateDataEvent(TRandom *rnd);\n", " void GenerateSignalEvent(TRandom *rnd);\n", " void GenerateBgrEvent(TRandom *rnd);\n", " // reconstructed quantities\n", " inline Double_t GetMRec(int i) const { return fMRec[i]; }\n", " inline Double_t GetPtRec(int i) const { return fPtRec[i]; }\n", " inline Double_t GetEtaRec(int i) const { return fEtaRec[i]; }\n", " inline Double_t GetDiscriminator(void) const {return fDiscriminator; }\n", " inline Double_t GetPhiRec(int i) const { return fPhiRec[i]; }\n", " inline Bool_t IsTriggered(void) const { return fIsTriggered; }\n", "\n", " // generator level quantities\n", " inline Double_t GetMGen(int i) const {\n", " if(IsSignal()) return fMGen[i];\n", " else return -1.0;\n", " }\n", " inline Double_t GetPtGen(int i) const {\n", " if(IsSignal()) return fPtGen[i];\n", " else return -1.0;\n", " }\n", " inline Double_t GetEtaGen(int i) const {\n", " if(IsSignal()) return fEtaGen[i];\n", " else return 999.0;\n", " }\n", " inline Double_t GetPhiGen(int i) const {\n", " if(IsSignal()) return fPhiGen[i];\n", " else return 999.0;\n", " }\n", " inline Bool_t IsSignal(void) const { return fIsSignal; }\n", "protected:\n", "\n", " void GenerateSignalKinematics(TRandom *rnd,Bool_t isData);\n", " void GenerateBgrKinematics(TRandom *rnd,Bool_t isData);\n", " void GenerateReco(TRandom *rnd);\n", "\n", " // reconstructed quantities\n", " Double_t fMRec[3];\n", " Double_t fPtRec[3];\n", " Double_t fEtaRec[3];\n", " Double_t fPhiRec[3];\n", " Double_t fDiscriminator;\n", " Bool_t fIsTriggered;\n", " // generated quantities\n", " Double_t fMGen[3];\n", " Double_t fPtGen[3];\n", " Double_t fEtaGen[3];\n", " Double_t fPhiGen[3];\n", " Bool_t fIsSignal;\n", "public:\n", " static Double_t kDataSignalFraction;\n", " static Double_t kMCSignalFraction;\n", "\n", "};\n", "Double_t ToyEvent7::kDataSignalFraction=0.75;\n", "Double_t ToyEvent7::kMCSignalFraction=0.75;" ] }, { "cell_type": "markdown", "id": "29e13911", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 2, "id": "d98cf071", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:33.802725Z", "iopub.status.busy": "2026-05-19T20:11:33.802591Z", "iopub.status.idle": "2026-05-19T20:11:33.806053Z", "shell.execute_reply": "2026-05-19T20:11:33.805565Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "void ToyEvent7::GenerateDataEvent(TRandom *rnd) {\n", " fIsSignal=rnd->Uniform()BreitWigner(M0,Gamma);\n", " } while(fMGen[2]<=0.0);\n", "\n", " double N_ETA=3.0;\n", " double MU_PT=5.;\n", " double SIGMA_PT=2.0;\n", " double DECAY_A=0.2;\n", " if(isData) {\n", " //N_ETA=2.5;\n", " MU_PT=6.;\n", " SIGMA_PT=1.8;\n", " //DECAY_A=0.5;\n", " }\n", " fEtaGen[2]=TMath::Power(rnd->Uniform(0,1.5),N_ETA);\n", " if(rnd->Uniform(-1.,1.)<0.) fEtaGen[2] *= -1.;\n", " fPhiGen[2]=rnd->Uniform(-M_PI,M_PI);\n", " do {\n", " fPtGen[2]=rnd->Landau(MU_PT,SIGMA_PT);\n", " } while((fPtGen[2]<=0.0)||(fPtGen[2]>500.));\n", " //========================== decay\n", " TLorentzVector sum;\n", " sum.SetPtEtaPhiM(fPtGen[2],fEtaGen[2],fPhiGen[2],fMGen[2]);\n", " // boost into lab-frame\n", " TVector3 boost=sum.BoostVector();\n", " // decay in rest-frame\n", "\n", " TLorentzVector p[3];\n", " double m=MASS1;\n", " double costh;\n", " do {\n", " double r=rnd->Uniform(-1.,1.);\n", " costh=r*(1.+DECAY_A*r*r);\n", " } while(fabs(costh)>=1.0);\n", " double phi=rnd->Uniform(-M_PI,M_PI);\n", " double e=0.5*sum.M();\n", " double ptot=TMath::Sqrt(e+m)*TMath::Sqrt(e-m);\n", " double pz=ptot*costh;\n", " double pt=TMath::Sqrt(ptot+pz)*TMath::Sqrt(ptot-pz);\n", " double px=pt*cos(phi);\n", " double py=pt*sin(phi);\n", " p[0].SetXYZT(px,py,pz,e);\n", " p[1].SetXYZT(-px,-py,-pz,e);\n", " for(int i=0;i<2;i++) {\n", " p[i].Boost(boost);\n", " }\n", " p[2]=p[0]+p[1];\n", " for(int i=0;i<3;i++) {\n", " fPtGen[i]=p[i].Pt();\n", " fEtaGen[i]=p[i].Eta();\n", " fPhiGen[i]=p[i].Phi();\n", " fMGen[i]=p[i].M();\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "73bdce39", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 6, "id": "a9a30226", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:33.830058Z", "iopub.status.busy": "2026-05-19T20:11:33.829944Z", "iopub.status.idle": "2026-05-19T20:11:33.838147Z", "shell.execute_reply": "2026-05-19T20:11:33.837690Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "void ToyEvent7::GenerateBgrKinematics(TRandom *rnd,Bool_t isData) {\n", " for(int i=0;i<3;i++) {\n", " fPtGen[i]=0.0;\n", " fEtaGen[i]=0.0;\n", " fPhiGen[i]=0.0;\n", " }\n", " TLorentzVector p[3];\n", " for(int i=0;i<2;i++) {\n", " p[i].SetPtEtaPhiM(rnd->Exp(15.0),rnd->Uniform(-3.,3.),\n", " rnd->Uniform(-M_PI,M_PI),isData ? MASS1 : MASS1);\n", " }\n", " p[2]=p[0]+p[1];\n", " for(int i=0;i<3;i++) {\n", " fPtRec[i]=p[i].Pt();\n", " fEtaRec[i]=p[i].Eta();\n", " fPhiRec[i]=p[i].Phi();\n", " fMRec[i]=p[i].M();\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "1c392847", "metadata": {}, "source": [ " Definition of a helper function: " ] }, { "cell_type": "code", "execution_count": 7, "id": "4684cdc4", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:33.839222Z", "iopub.status.busy": "2026-05-19T20:11:33.839106Z", "iopub.status.idle": "2026-05-19T20:11:33.896787Z", "shell.execute_reply": "2026-05-19T20:11:33.879372Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "void ToyEvent7::GenerateReco(TRandom *rnd) {\n", " if(fIsSignal) {\n", " TLorentzVector p[3];\n", " for(int i=0;i<2;i++) {\n", " Double_t expEta=TMath::Exp(fEtaGen[i]);\n", " Double_t coshEta=(expEta+1./expEta);\n", " Double_t eGen=fPtGen[i]*coshEta;\n", " Double_t sigmaE=\n", " 0.1*TMath::Sqrt(eGen)\n", " +1.0*coshEta\n", " +0.01*eGen;\n", " Double_t eRec;\n", " do {\n", " eRec=rnd->Gaus(eGen,sigmaE);\n", " } while(eRec<=0.0);\n", " Double_t sigmaEta=0.1+0.02*TMath::Abs(fEtaGen[i]);\n", " p[i].SetPtEtaPhiM(eRec/(expEta+1./expEta),\n", " rnd->Gaus(fEtaGen[i],sigmaEta),\n", " remainder(rnd->Gaus(fPhiGen[i],0.03),2.*M_PI),\n", " MASS1);\n", " }\n", " p[2]=p[0]+p[1];\n", " for(int i=0;i<3;i++) {\n", " fPtRec[i]=p[i].Pt();\n", " fEtaRec[i]=p[i].Eta();\n", " fPhiRec[i]=p[i].Phi();\n", " fMRec[i]=p[i].M();\n", " }\n", " }\n", " if(fIsSignal) {\n", " do {\n", " Double_t tauDiscr=0.08-0.04/(1.+fPtRec[2]/10.0);\n", " Double_t sigmaDiscr=0.01;\n", " fDiscriminator=1.0-rnd->Exp(tauDiscr)+rnd->Gaus(0.,sigmaDiscr);\n", " } while((fDiscriminator<=0.)||(fDiscriminator>=1.));\n", " } else {\n", " do {\n", " Double_t tauDiscr=0.15-0.05/(1.+fPtRec[2]/5.0)+0.1*fEtaRec[2];\n", " Double_t sigmaDiscr=0.02+0.01*fEtaRec[2];\n", " fDiscriminator=rnd->Exp(tauDiscr)+rnd->Gaus(0.,sigmaDiscr);\n", " } while((fDiscriminator<=0.)||(fDiscriminator>=1.));\n", " }\n", " fIsTriggered=false;\n", " for(int i=0;i<2;i++) {\n", " if(rnd->Uniform()<0.92/(TMath::Exp(-(fPtRec[i]-15.5)/2.5)+1.)) fIsTriggered=true;\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "89895a70", "metadata": {}, "source": [ "random generator" ] }, { "cell_type": "code", "execution_count": 8, "id": "6933abdd", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:33.898251Z", "iopub.status.busy": "2026-05-19T20:11:33.898125Z", "iopub.status.idle": "2026-05-19T20:11:34.231539Z", "shell.execute_reply": "2026-05-19T20:11:34.226691Z" } }, "outputs": [], "source": [ "g_rnd=new TRandom3(4711);" ] }, { "cell_type": "markdown", "id": "f2921369", "metadata": {}, "source": [ "data and MC number of events" ] }, { "cell_type": "code", "execution_count": 9, "id": "b827718e", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:34.233687Z", "iopub.status.busy": "2026-05-19T20:11:34.233507Z", "iopub.status.idle": "2026-05-19T20:11:34.449113Z", "shell.execute_reply": "2026-05-19T20:11:34.448567Z" } }, "outputs": [], "source": [ "Double_t muData0=5000.;" ] }, { "cell_type": "markdown", "id": "688ca220", "metadata": {}, "source": [ "luminosity error" ] }, { "cell_type": "code", "execution_count": 10, "id": "817024c6", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:34.452688Z", "iopub.status.busy": "2026-05-19T20:11:34.452483Z", "iopub.status.idle": "2026-05-19T20:11:34.657144Z", "shell.execute_reply": "2026-05-19T20:11:34.656452Z" } }, "outputs": [], "source": [ "Double_t muData=muData0*g_rnd->Gaus(1.0,0.03);" ] }, { "cell_type": "markdown", "id": "521b0fb9", "metadata": {}, "source": [ "stat error" ] }, { "cell_type": "code", "execution_count": 11, "id": "91ca63e8", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:34.659195Z", "iopub.status.busy": "2026-05-19T20:11:34.659076Z", "iopub.status.idle": "2026-05-19T20:11:34.863097Z", "shell.execute_reply": "2026-05-19T20:11:34.862348Z" } }, "outputs": [], "source": [ "Int_t neventData = g_rnd->Poisson( muData);" ] }, { "cell_type": "markdown", "id": "bb298cbf", "metadata": {}, "source": [ "generated number of MC events" ] }, { "cell_type": "code", "execution_count": 12, "id": "b0471bf5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:34.865000Z", "iopub.status.busy": "2026-05-19T20:11:34.864879Z", "iopub.status.idle": "2026-05-19T20:11:35.068852Z", "shell.execute_reply": "2026-05-19T20:11:35.068098Z" } }, "outputs": [], "source": [ "Int_t neventSigmc = 250000;\n", "Int_t neventBgrmc = 100000;\n", "\n", "Float_t etaRec[3],ptRec[3],phiRec[3],mRec[3],discr;\n", "Float_t etaGen[3],ptGen[3],phiGen[3],mGen[3];\n", "Float_t weight;\n", "Int_t istriggered,issignal;" ] }, { "cell_type": "markdown", "id": "3c2a758a", "metadata": {}, "source": [ "==================================================================\n", "Step 1: generate data TTree" ] }, { "cell_type": "code", "execution_count": 13, "id": "2a5fa016", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:35.072539Z", "iopub.status.busy": "2026-05-19T20:11:35.072384Z", "iopub.status.idle": "2026-05-19T20:11:35.283659Z", "shell.execute_reply": "2026-05-19T20:11:35.283057Z" } }, "outputs": [], "source": [ "TFile *dataFile=new TFile(\"testUnfold7_data.root\",\"recreate\");\n", "TTree *dataTree=new TTree(\"data\",\"event\");\n", "\n", "dataTree->Branch(\"etarec\",etaRec,\"etarec[3]/F\");\n", "dataTree->Branch(\"ptrec\",ptRec,\"ptrec[3]/F\");\n", "dataTree->Branch(\"phirec\",phiRec,\"phirec[3]/F\");\n", "dataTree->Branch(\"mrec\",mRec,\"mrec[3]/F\");\n", "dataTree->Branch(\"discr\",&discr,\"discr/F\");" ] }, { "cell_type": "markdown", "id": "0d6d80ca", "metadata": {}, "source": [ "for real data, only the triggered events are available" ] }, { "cell_type": "code", "execution_count": 14, "id": "9a229f2d", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:35.285752Z", "iopub.status.busy": "2026-05-19T20:11:35.285621Z", "iopub.status.idle": "2026-05-19T20:11:35.499496Z", "shell.execute_reply": "2026-05-19T20:11:35.498946Z" } }, "outputs": [], "source": [ "dataTree->Branch(\"istriggered\",&istriggered,\"istriggered/I\");" ] }, { "cell_type": "markdown", "id": "3ded4823", "metadata": {}, "source": [ "data truth parameters" ] }, { "cell_type": "code", "execution_count": 15, "id": "f44ea90d", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:35.520635Z", "iopub.status.busy": "2026-05-19T20:11:35.520460Z", "iopub.status.idle": "2026-05-19T20:11:35.724713Z", "shell.execute_reply": "2026-05-19T20:11:35.723986Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "fill data tree\n" ] } ], "source": [ "dataTree->Branch(\"etagen\",etaGen,\"etagen[3]/F\");\n", "dataTree->Branch(\"ptgen\",ptGen,\"ptgen[3]/F\");\n", "dataTree->Branch(\"phigen\",phiGen,\"phigen[3]/F\");\n", "dataTree->Branch(\"mgen\",mGen,\"mgen[3]/F\");\n", "dataTree->Branch(\"issignal\",&issignal,\"issignal/I\");\n", "\n", "cout<<\"fill data tree\\n\";" ] }, { "cell_type": "markdown", "id": "1de489f3", "metadata": {}, "source": [ "Int_t nEvent=0,nTriggered=0;" ] }, { "cell_type": "code", "execution_count": 16, "id": "049741bc", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:35.726249Z", "iopub.status.busy": "2026-05-19T20:11:35.726122Z", "iopub.status.idle": "2026-05-19T20:11:35.933297Z", "shell.execute_reply": "2026-05-19T20:11:35.932568Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " data event 0\n" ] } ], "source": [ "for(int ievent=0;ieventFill();\n", "\n", " if(!(ievent%100000)) cout<<\" data event \"<Write();\n", "delete dataTree;\n", "delete dataFile;" ] }, { "cell_type": "markdown", "id": "edf30137", "metadata": {}, "source": [ "==================================================================\n", "Step 2: generate signal TTree" ] }, { "cell_type": "code", "execution_count": 17, "id": "2732ec21", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:35.934909Z", "iopub.status.busy": "2026-05-19T20:11:35.934780Z", "iopub.status.idle": "2026-05-19T20:11:36.137874Z", "shell.execute_reply": "2026-05-19T20:11:36.136785Z" } }, "outputs": [], "source": [ "TFile *signalFile=new TFile(\"testUnfold7_signal.root\",\"recreate\");\n", "TTree *signalTree=new TTree(\"signal\",\"event\");\n", "\n", "signalTree->Branch(\"etarec\",etaRec,\"etarec[3]/F\");\n", "signalTree->Branch(\"ptrec\",ptRec,\"ptrec[3]/F\");\n", "signalTree->Branch(\"phirec\",ptRec,\"phirec[3]/F\");\n", "signalTree->Branch(\"mrec\",mRec,\"mrec[3]/F\");\n", "signalTree->Branch(\"discr\",&discr,\"discr/F\");" ] }, { "cell_type": "markdown", "id": "a8470ce5", "metadata": {}, "source": [ "for real data, only the triggered events are available" ] }, { "cell_type": "code", "execution_count": 18, "id": "72456a2c", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:36.139795Z", "iopub.status.busy": "2026-05-19T20:11:36.139626Z", "iopub.status.idle": "2026-05-19T20:11:36.342028Z", "shell.execute_reply": "2026-05-19T20:11:36.341485Z" } }, "outputs": [], "source": [ "signalTree->Branch(\"istriggered\",&istriggered,\"istriggered/I\");" ] }, { "cell_type": "markdown", "id": "874f4edb", "metadata": {}, "source": [ "data truth parameters" ] }, { "cell_type": "code", "execution_count": 19, "id": "35773c92", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:36.348200Z", "iopub.status.busy": "2026-05-19T20:11:36.348058Z", "iopub.status.idle": "2026-05-19T20:11:37.216405Z", "shell.execute_reply": "2026-05-19T20:11:37.215990Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "fill signal tree\n", " signal event 0\n", " signal event 100000\n", " signal event 200000\n" ] } ], "source": [ "signalTree->Branch(\"etagen\",etaGen,\"etagen[3]/F\");\n", "signalTree->Branch(\"ptgen\",ptGen,\"ptgen[3]/F\");\n", "signalTree->Branch(\"phigen\",phiGen,\"phigen[3]/F\");\n", "signalTree->Branch(\"weight\",&weight,\"weight/F\");\n", "signalTree->Branch(\"mgen\",mGen,\"mgen[3]/F\");\n", "\n", "cout<<\"fill signal tree\\n\";\n", "\n", "weight=ToyEvent7::kMCSignalFraction*muData0/neventSigmc;\n", "\n", "for(int ievent=0;ieventFill();\n", "}\n", "\n", "signalTree->Write();\n", "delete signalTree;\n", "delete signalFile;" ] }, { "cell_type": "markdown", "id": "7bff4074", "metadata": {}, "source": [ "==============================================================\n", "Step 3: generate background MC TTree" ] }, { "cell_type": "code", "execution_count": 20, "id": "a6c30381", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:37.217697Z", "iopub.status.busy": "2026-05-19T20:11:37.217560Z", "iopub.status.idle": "2026-05-19T20:11:37.771084Z", "shell.execute_reply": "2026-05-19T20:11:37.763514Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "fill background tree\n", " background event 0\n" ] } ], "source": [ "TFile *bgrFile=new TFile(\"testUnfold7_background.root\",\"recreate\");\n", "TTree *bgrTree=new TTree(\"background\",\"event\");\n", "\n", "bgrTree->Branch(\"etarec\",&etaRec,\"etarec[3]/F\");\n", "bgrTree->Branch(\"ptrec\",&ptRec,\"ptrec[3]/F\");\n", "bgrTree->Branch(\"phirec\",&phiRec,\"phirec[3]/F\");\n", "bgrTree->Branch(\"mrec\",&mRec,\"mrec[3]/F\");\n", "bgrTree->Branch(\"discr\",&discr,\"discr/F\");\n", "bgrTree->Branch(\"istriggered\",&istriggered,\"istriggered/I\");\n", "bgrTree->Branch(\"weight\",&weight,\"weight/F\");\n", "\n", "cout<<\"fill background tree\\n\";\n", "\n", "weight=(1.-ToyEvent7::kMCSignalFraction)*muData0/neventBgrmc;\n", "\n", "for(int ievent=0;ieventFill();\n", "}\n", "\n", "bgrTree->Write();\n", "delete bgrTree;\n", "delete bgrFile;" ] }, { "cell_type": "markdown", "id": "58b1bad6", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 21, "id": "d29b19a4", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:11:37.772515Z", "iopub.status.busy": "2026-05-19T20:11:37.772393Z", "iopub.status.idle": "2026-05-19T20:11:37.991878Z", "shell.execute_reply": "2026-05-19T20:11:37.990329Z" } }, "outputs": [], "source": [ "gROOT->GetListOfCanvases()->Draw()" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }