79 void GenerateDataEvent(
TRandom *rnd);
80 void GenerateSignalEvent(
TRandom *rnd);
81 void GenerateBgrEvent(
TRandom *rnd);
83 inline Double_t GetPtRec(
void)
const {
return fPtRec; }
84 inline Double_t GetEtaRec(
void)
const {
return fEtaRec; }
85 inline Double_t GetDiscriminator(
void)
const {
return fDiscriminator; }
86 inline Bool_t IsTriggered(
void)
const {
return fIsTriggered; }
89 inline Double_t GetPtGen(
void)
const {
90 if(IsSignal())
return fPtGen;
93 inline Double_t GetEtaGen(
void)
const {
94 if(IsSignal())
return fEtaGen;
97 inline Bool_t IsSignal(
void)
const {
return fIsSignal; }
102 void GenerateReco(
TRandom *rnd);
114 static Double_t kDataSignalFraction;
124 const Int_t neventData = 20000;
125 Double_t const neventSignalMC =2000000;
126 Double_t const neventBgrMC =2000000;
128 Float_t etaRec,ptRec,discr,etaGen,ptGen;
129 Int_t istriggered,issignal;
134 TFile *dataFile=
new TFile(
"testUnfold5_data.root",
"recreate");
137 dataTree->
Branch(
"etarec",&etaRec,
"etarec/F");
138 dataTree->
Branch(
"ptrec",&ptRec,
"ptrec/F");
139 dataTree->
Branch(
"discr",&discr,
"discr/F");
142 dataTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
144 dataTree->
Branch(
"etagen",&etaGen,
"etagen/F");
145 dataTree->
Branch(
"ptgen",&ptGen,
"ptgen/F");
146 dataTree->
Branch(
"issignal",&issignal,
"issignal/I");
148 cout<<
"fill data tree\n";
150 Int_t nEvent=0,nTriggered=0;
151 while(nTriggered<neventData) {
153 event.GenerateDataEvent(g_rnd);
155 etaRec=
event.GetEtaRec();
156 ptRec=
event.GetPtRec();
157 discr=
event.GetDiscriminator();
158 istriggered=
event.IsTriggered() ? 1 : 0;
159 etaGen=
event.GetEtaGen();
160 ptGen=
event.GetPtGen();
161 issignal=
event.IsSignal() ? 1 : 0;
165 if(!(nEvent%100000)) cout<<
" data event "<<nEvent<<
"\n";
167 if(istriggered) nTriggered++;
179 TFile *signalFile=
new TFile(
"testUnfold5_signal.root",
"recreate");
180 TTree *signalTree=
new TTree(
"signal",
"event");
182 signalTree->
Branch(
"etarec",&etaRec,
"etarec/F");
183 signalTree->
Branch(
"ptrec",&ptRec,
"ptrec/F");
184 signalTree->
Branch(
"discr",&discr,
"discr/F");
185 signalTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
186 signalTree->
Branch(
"etagen",&etaGen,
"etagen/F");
187 signalTree->
Branch(
"ptgen",&ptGen,
"ptgen/F");
189 cout<<
"fill signal tree\n";
191 for(
int ievent=0;ievent<neventSignalMC;ievent++) {
193 event.GenerateSignalEvent(g_rnd);
195 etaRec=
event.GetEtaRec();
196 ptRec=
event.GetPtRec();
197 discr=
event.GetDiscriminator();
198 istriggered=
event.IsTriggered() ? 1 : 0;
199 etaGen=
event.GetEtaGen();
200 ptGen=
event.GetPtGen();
202 if(!(ievent%100000)) cout<<
" signal event "<<ievent<<
"\n";
214 TFile *bgrFile=
new TFile(
"testUnfold5_background.root",
"recreate");
215 TTree *bgrTree=
new TTree(
"background",
"event");
217 bgrTree->
Branch(
"etarec",&etaRec,
"etarec/F");
218 bgrTree->
Branch(
"ptrec",&ptRec,
"ptrec/F");
219 bgrTree->
Branch(
"discr",&discr,
"discr/F");
220 bgrTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
222 cout<<
"fill background tree\n";
224 for(
int ievent=0;ievent<neventBgrMC;ievent++) {
226 event.GenerateBgrEvent(g_rnd);
227 etaRec=
event.GetEtaRec();
228 ptRec=
event.GetPtRec();
229 discr=
event.GetDiscriminator();
230 istriggered=
event.IsTriggered() ? 1 : 0;
232 if(!(ievent%100000)) cout<<
" background event "<<ievent<<
"\n";
242Double_t ToyEvent::kDataSignalFraction=0.8;
244void ToyEvent::GenerateDataEvent(
TRandom *rnd) {
245 fIsSignal=rnd->
Uniform()<kDataSignalFraction;
247 GenerateSignalKinematics(rnd,
kTRUE);
249 GenerateBgrKinematics(rnd,
kTRUE);
254void ToyEvent::GenerateSignalEvent(
TRandom *rnd) {
256 GenerateSignalKinematics(rnd,
kFALSE);
260void ToyEvent::GenerateBgrEvent(
TRandom *rnd) {
262 GenerateBgrKinematics(rnd,
kFALSE);
266void ToyEvent::GenerateSignalKinematics(
TRandom *rnd,
Bool_t isData) {
282 if(rnd->
Uniform()>=0.5) fEtaGen= -fEtaGen;
284 fEtaGen=rnd->
Uniform(-etaMax,etaMax);
287 Double_t T0=e_T0 + e_T0_eta*fEtaGen;
298void ToyEvent::GenerateBgrKinematics(
TRandom *rnd,
Bool_t isData) {
301 fPtRec=rnd->
Exp(isData ? 2.5 : 2.5);
305void ToyEvent::GenerateReco(
TRandom *rnd) {
308 Double_t eGen=fPtGen*(expEta+1./expEta);
313 eRec=rnd->
Gaus(eGen,sigmaE);
316 fEtaRec=rnd->
Gaus(fEtaGen,sigmaEta);
317 fPtRec=eRec/(expEta+1./expEta);
319 Double_t tauDiscr=0.08-0.04/(1.+fPtRec/10.0);
321 fDiscriminator=1.0-rnd->
Exp(tauDiscr)+rnd->
Gaus(0.,sigmaDiscr);
322 }
while((fDiscriminator<=0.)||(fDiscriminator>=1.));
332 Double_t tauDiscr=0.15-0.05/(1.+fPtRec/5.0)+0.1*fEtaRec;
333 Double_t sigmaDiscr=0.02+0.01*fEtaRec;
334 fDiscriminator=rnd->
Exp(tauDiscr)+rnd->
Gaus(0.,sigmaDiscr);
335 }
while((fDiscriminator<=0.)||(fDiscriminator>=1.));
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
Random number generator class based on M.
This is the base class for the ROOT Random number generators.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
virtual Double_t Exp(Double_t tau)
Returns an exponential deviate.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override
Write this object to the current directory.
T etaMax()
Function providing the maximum possible value of pseudorapidity for a non-zero rho,...
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.