Logo ROOT   6.07/09
Reference Guide
testUnfold5b.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_unfold5
3 /// \notebook -nodraw
4 ///
5 /// Version 17.0 example for multi-dimensional unfolding
6 ///
7 /// \macro_output
8 /// \macro_code
9 ///
10 /// \author Stefan Schmitt, DESY
11 
12 #include <iostream>
13 #include <fstream>
14 #include <TFile.h>
15 #include "TUnfoldBinning.h"
16 
17 using namespace std;
18 
19 void testUnfold5b()
20 {
21 
22  // write binning schemes to root file
23  TFile *binningSchemes=new TFile("testUnfold5_binning.root","recreate");
24 
25  // reconstructed pt, eta, discriminator
26 #define NBIN_PT_FINE 8
27 #define NBIN_ETA_FINE 10
28 #define NBIN_DISCR 4
29 
30  // generated pt, eta
31 #define NBIN_PT_COARSE 3
32 #define NBIN_ETA_COARSE 3
33 
34  // pt binning
35  Double_t ptBinsFine[NBIN_PT_FINE+1]=
36  {3.5,4.0,4.5,5.0,6.0,7.0,8.0,10.0,13.0};
37  Double_t ptBinsCoarse[NBIN_PT_COARSE+1]=
38  { 4.0, 5.0, 7.0, 10.0};
39  // eta binning
40  Double_t etaBinsFine[NBIN_ETA_FINE+1]=
41  {-3.,-2.5,-2.0,-1.,-0.5,0.0,0.5,1.,2.,2.5,3.};
42  Double_t etaBinsCoarse[NBIN_ETA_COARSE+1]=
43  { -2.0, -0.5, 0.5, 2. };
44 
45  // discriminator bins
46  Double_t discrBins[NBIN_DISCR+1]={0.,0.15,0.5,0.85,1.0};
47 
48  //=======================================================================
49  // detector level binning scheme
50 
51  TUnfoldBinning *detectorBinning=new TUnfoldBinning("detector");
52  // highest discriminator bin has fine binning
53  TUnfoldBinning *detectorDistribution=
54  detectorBinning->AddBinning("detectordistribution");
55  detectorDistribution->AddAxis("pt",NBIN_PT_FINE,ptBinsFine,
56  false, // no underflow bin (not reconstructed)
57  true // overflow bin
58  );
59  detectorDistribution->AddAxis("eta",NBIN_ETA_FINE,etaBinsFine,
60  false, // no underflow bin (not reconstructed)
61  false // no overflow bin (not reconstructed)
62  );
63  detectorDistribution->AddAxis("discriminator",NBIN_DISCR,discrBins,
64  false, // no underflow bin (empty)
65  false // no overflow bin (empty)
66  );
67  /* TUnfoldBinning *detectorExtra=
68  detectorBinning->AddBinning("detectorextra",7,"one;zwei;three"); */
69  detectorBinning->PrintStream(cout);
70 
71  //=======================================================================
72  // generator level binning
73  TUnfoldBinning *generatorBinning=new TUnfoldBinning("generator");
74 
75  // signal distribution is measured with coarse binning
76  // underflow and overflow bins are needed ot take care of
77  // what happens outside the phase-space
78  TUnfoldBinning *signalBinning = generatorBinning->AddBinning("signal");
79  signalBinning->AddAxis("ptgen",NBIN_PT_COARSE,ptBinsCoarse,
80  true, // underflow bin
81  true // overflow bin
82  );
83  signalBinning->AddAxis("etagen",NBIN_ETA_COARSE,etaBinsCoarse,
84  true, // underflow bin
85  true // overflow bin
86  );
87  // background distribution is unfolded with fine binning
88  // !!! in the reconstructed variable !!!
89  //
90  // This has the effect of "normalizing" the background in each
91  // pt,eta bin to the low discriminator values
92  // Only the shape of the discriminator in each (pt,eta) bin
93  // is taken from Monte Carlo
94  //
95  // This method has been applied e.g. in
96  // H1 Collaboration, "Prompt photons in Photoproduction"
97  // Eur.Phys.J. C66 (2010) 17
98  //
99  TUnfoldBinning *bgrBinning = generatorBinning->AddBinning("background");
100  bgrBinning->AddAxis("ptrec",NBIN_PT_FINE,ptBinsFine,
101  false, // no underflow bin (not reconstructed)
102  true // overflow bin
103  );
104  bgrBinning->AddAxis("etarec",NBIN_ETA_FINE,etaBinsFine,
105  false, // no underflow bin (not reconstructed)
106  false // no overflow bin (not reconstructed)
107  );
108  generatorBinning->PrintStream(cout);
109 
110  detectorBinning->Write();
111  generatorBinning->Write();
112 
113  delete binningSchemes;
114 }
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:830
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
STL namespace.
Bool_t AddAxis(const char *name, Int_t nBins, const Double_t *binBorders, Bool_t hasUnderflow, Bool_t hasOverflow)
void PrintStream(std::ostream &out, Int_t indent=0) const
This class serves as a container of analysis bins analysis bins are specified by defining the axes of...
double Double_t
Definition: RtypesCore.h:55
TUnfoldBinning * AddBinning(TUnfoldBinning *binning)