arXiv:1611.01927 12th Conference on Quark Confinement and the Hadron Spectrum (Confinement XII)
This is an example of unfolding a two-dimensional distribution also using an auxiliary measurement to constrain some background
#include <iostream>
#include <map>
#include <cmath>
using namespace std;
void testUnfold7b()
{
TFile *outputFile=
new TFile(
"testUnfold7_histograms.root",
"recreate");
if(error) {
cout<<"error="<<error<<" from TDOMParser\n";
cout<<"==============================================================\n";
cout<<"Maybe the file testUnfold7binning.xml is missing?\n";
cout<<"The content of the file is included in the comments section\n";
cout<<"of this macro \"testUnfold7b.C\"\n";
cout<<"==============================================================\n";
}
fineBinningRoot=
coarseBinningRoot=
fineBinningRoot->
Write();
coarseBinningRoot->
Write();
if(fineBinningRoot) {
} else {
cout<<"could not read 'detector' binning\n";
}
if(coarseBinningRoot) {
} else {
cout<<"could not read 'generator' binning\n";
}
Int_t isTriggered,isSignal;
TFile *dataFile=
new TFile(
"testUnfold7_data.root");
if(!dataTree) {
cout<<"could not read 'data' tree\n";
}
cout<<"loop over data events\n";
#define VAR_REC (ptRec[2])
#define VAR_GEN (ptGen[2])
if(dataTree->
GetEntry(ievent)<=0)
break;
if(isTriggered) {
histDataRecF->
Fill(binF);
histDataRecC->
Fill(binC);
if(!isSignal) {
histDataBgrF->
Fill(binF);
histDataBgrC->
Fill(binC);
}
}
if(isSignal) {
histDataGen->
Fill(binGen);
}
}
delete dataTree;
delete dataFile;
(coarseBinning,fineBinning,"histMcsigGenRecF");
(coarseBinning,coarseBinning,"histMcsigGenRecC");
TFile *signalFile=
new TFile(
"testUnfold7_signal.root");
if(!signalTree) {
cout<<"could not read 'signal' tree\n";
}
cout<<"loop over MC signal events\n";
if(signalTree->
GetEntry(ievent)<=0)
break;
int binC=0,binF=0;
if(isTriggered) {
}
histMcsigGenRecF->
Fill(binGen,binF,weight);
histMcsigGenRecC->
Fill(binGen,binC,weight);
histMcsigRecF->
Fill(binF,weight);
histMcsigRecC->
Fill(binC,weight);
histMcsigGen->
Fill(binGen,weight);
}
delete signalTree;
delete signalFile;
TFile *bgrFile=
new TFile(
"testUnfold7_background.root");
if(!bgrTree) {
cout<<"could not read 'background' tree\n";
}
cout<<"loop over MC background events\n";
if(isTriggered) {
histMcbgrRecF->
Fill(binF,weight);
histMcbgrRecC->
Fill(binC,weight);
}
}
delete bgrTree;
delete bgrFile;
delete outputFile;
}
R__EXTERN TSystem * gSystem
virtual TXMLDocument * GetXMLDocument() const
Returns the TXMLDocument.
virtual Int_t ParseFile(const char *filename)
Parse the XML file where filename is the XML file name.
Bool_t cd(const char *path=nullptr) override
Change current directory to "this" directory.
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) override
Write memory objects to this file.
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
static void SetDefaultSumw2(Bool_t sumw2=kTRUE)
When this static function is called with sumw2=kTRUE, all new histograms will automatically activate ...
Service class for 2-Dim histogram classes.
Int_t Fill(Double_t)
Invalid Fill method.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
A TTree represents a columnar dataset.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual Long64_t GetEntriesFast() const
virtual void ResetBranchAddresses()
Tell all of our branches to drop their current objects and allocate new ones.
virtual void SetBranchStatus(const char *bname, Bool_t status=1, UInt_t *found=0)
Set branch status to Process or DoNotProcess.
static TUnfoldBinningXML * ImportXML(const TXMLDocument *document, const char *name)
Import a binning scheme from an XML file.
Binning schemes for use with the unfolding algorithm TUnfoldDensity.
void PrintStream(std::ostream &out, Int_t indent=0, int debug=0) const
Print some information about this binning tree.
TH1 * CreateHistogram(const char *histogramName, Bool_t originalAxisBinning=kFALSE, Int_t **binMap=0, const char *histogramTitle=0, const char *axisSteering=0) const
Create a THxx histogram capable to hold the bins of this binning node and its children.
Int_t GetGlobalBinNumber(Double_t x) const
Locate a bin in a one-dimensional distribution.
static TH2D * CreateHistogramOfMigrations(TUnfoldBinning const *xAxis, TUnfoldBinning const *yAxis, char const *histogramName, Bool_t originalXAxisBinning=kFALSE, Bool_t originalYAxisBinning=kFALSE, char const *histogramTitle=0)
Create a TH2D histogram capable to hold the bins of the two input binning schemes on the x and y axes...
TXMLDocument contains a pointer to an xmlDoc structure, after the parser returns a tree built during ...