75 void GenerateDataEvent(
TRandom *rnd);
76 void GenerateSignalEvent(
TRandom *rnd);
77 void GenerateBgrEvent(
TRandom *rnd);
79 inline Double_t GetMRec(
int i)
const {
return fMRec[i]; }
80 inline Double_t GetPtRec(
int i)
const {
return fPtRec[i]; }
81 inline Double_t GetEtaRec(
int i)
const {
return fEtaRec[i]; }
82 inline Double_t GetDiscriminator(
void)
const {
return fDiscriminator; }
83 inline Double_t GetPhiRec(
int i)
const {
return fPhiRec[i]; }
84 inline Bool_t IsTriggered(
void)
const {
return fIsTriggered; }
87 inline Double_t GetMGen(
int i)
const {
88 if(IsSignal())
return fMGen[i];
91 inline Double_t GetPtGen(
int i)
const {
92 if(IsSignal())
return fPtGen[i];
95 inline Double_t GetEtaGen(
int i)
const {
96 if(IsSignal())
return fEtaGen[i];
99 inline Double_t GetPhiGen(
int i)
const {
100 if(IsSignal())
return fPhiGen[i];
103 inline Bool_t IsSignal(
void)
const {
return fIsSignal; }
108 void GenerateReco(
TRandom *rnd);
124 static Double_t kDataSignalFraction;
142 Int_t neventSigmc = 250000;
143 Int_t neventBgrmc = 100000;
145 Float_t etaRec[3],ptRec[3],phiRec[3],mRec[3],discr;
146 Float_t etaGen[3],ptGen[3],phiGen[3],mGen[3];
148 Int_t istriggered,issignal;
153 TFile *dataFile=
new TFile(
"testUnfold7_data.root",
"recreate");
156 dataTree->
Branch(
"etarec",etaRec,
"etarec[3]/F");
157 dataTree->
Branch(
"ptrec",ptRec,
"ptrec[3]/F");
158 dataTree->
Branch(
"phirec",phiRec,
"phirec[3]/F");
159 dataTree->
Branch(
"mrec",mRec,
"mrec[3]/F");
160 dataTree->
Branch(
"discr",&discr,
"discr/F");
163 dataTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
165 dataTree->
Branch(
"etagen",etaGen,
"etagen[3]/F");
166 dataTree->
Branch(
"ptgen",ptGen,
"ptgen[3]/F");
167 dataTree->
Branch(
"phigen",phiGen,
"phigen[3]/F");
168 dataTree->
Branch(
"mgen",mGen,
"mgen[3]/F");
169 dataTree->
Branch(
"issignal",&issignal,
"issignal/I");
171 cout<<
"fill data tree\n";
174 for(
int ievent=0;ievent<neventData;ievent++) {
176 event.GenerateDataEvent(g_rnd);
177 for(
int i=0;i<3;i++) {
178 etaRec[i]=
event.GetEtaRec(i);
179 ptRec[i]=
event.GetPtRec(i);
180 phiRec[i]=
event.GetPhiRec(i);
181 mRec[i]=
event.GetMRec(i);
182 etaGen[i]=
event.GetEtaGen(i);
183 ptGen[i]=
event.GetPtGen(i);
184 phiGen[i]=
event.GetPhiGen(i);
185 mGen[i]=
event.GetMGen(i);
187 discr=
event.GetDiscriminator();
188 istriggered=
event.IsTriggered() ? 1 : 0;
189 issignal=
event.IsSignal() ? 1 : 0;
193 if(!(ievent%100000)) cout<<
" data event "<<ievent<<
"\n";
207 TFile *signalFile=
new TFile(
"testUnfold7_signal.root",
"recreate");
208 TTree *signalTree=
new TTree(
"signal",
"event");
210 signalTree->
Branch(
"etarec",etaRec,
"etarec[3]/F");
211 signalTree->
Branch(
"ptrec",ptRec,
"ptrec[3]/F");
212 signalTree->
Branch(
"phirec",ptRec,
"phirec[3]/F");
213 signalTree->
Branch(
"mrec",mRec,
"mrec[3]/F");
214 signalTree->
Branch(
"discr",&discr,
"discr/F");
217 signalTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
219 signalTree->
Branch(
"etagen",etaGen,
"etagen[3]/F");
220 signalTree->
Branch(
"ptgen",ptGen,
"ptgen[3]/F");
221 signalTree->
Branch(
"phigen",phiGen,
"phigen[3]/F");
222 signalTree->
Branch(
"weight",&weight,
"weight/F");
223 signalTree->
Branch(
"mgen",mGen,
"mgen[3]/F");
225 cout<<
"fill signal tree\n";
227 weight=ToyEvent7::kMCSignalFraction*muData0/neventSigmc;
229 for(
int ievent=0;ievent<neventSigmc;ievent++) {
231 event.GenerateSignalEvent(g_rnd);
233 for(
int i=0;i<3;i++) {
234 etaRec[i]=
event.GetEtaRec(i);
235 ptRec[i]=
event.GetPtRec(i);
236 phiRec[i]=
event.GetPhiRec(i);
237 mRec[i]=
event.GetMRec(i);
238 etaGen[i]=
event.GetEtaGen(i);
239 ptGen[i]=
event.GetPtGen(i);
240 phiGen[i]=
event.GetPhiGen(i);
241 mGen[i]=
event.GetMGen(i);
243 discr=
event.GetDiscriminator();
244 istriggered=
event.IsTriggered() ? 1 : 0;
246 if(!(ievent%100000)) cout<<
" signal event "<<ievent<<
"\n";
258 TFile *bgrFile=
new TFile(
"testUnfold7_background.root",
"recreate");
259 TTree *bgrTree=
new TTree(
"background",
"event");
261 bgrTree->
Branch(
"etarec",&etaRec,
"etarec[3]/F");
262 bgrTree->
Branch(
"ptrec",&ptRec,
"ptrec[3]/F");
263 bgrTree->
Branch(
"phirec",&phiRec,
"phirec[3]/F");
264 bgrTree->
Branch(
"mrec",&mRec,
"mrec[3]/F");
265 bgrTree->
Branch(
"discr",&discr,
"discr/F");
266 bgrTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
267 bgrTree->
Branch(
"weight",&weight,
"weight/F");
269 cout<<
"fill background tree\n";
271 weight=(1.-ToyEvent7::kMCSignalFraction)*muData0/neventBgrmc;
273 for(
int ievent=0;ievent<neventBgrmc;ievent++) {
275 event.GenerateBgrEvent(g_rnd);
276 for(
int i=0;i<3;i++) {
277 etaRec[i]=
event.GetEtaRec(i);
278 ptRec[i]=
event.GetPtRec(i);
279 phiRec[i]=
event.GetPhiRec(i);
281 discr=
event.GetDiscriminator();
282 istriggered=
event.IsTriggered() ? 1 : 0;
284 if(!(ievent%100000)) cout<<
" background event "<<ievent<<
"\n";
294Double_t ToyEvent7::kDataSignalFraction=0.75;
295Double_t ToyEvent7::kMCSignalFraction=0.75;
297void ToyEvent7::GenerateDataEvent(
TRandom *rnd) {
298 fIsSignal=rnd->
Uniform()<kDataSignalFraction;
300 GenerateSignalKinematics(rnd,
kTRUE);
302 GenerateBgrKinematics(rnd,
kTRUE);
307void ToyEvent7::GenerateSignalEvent(
TRandom *rnd) {
309 GenerateSignalKinematics(rnd,
kFALSE);
313void ToyEvent7::GenerateBgrEvent(
TRandom *rnd) {
315 GenerateBgrKinematics(rnd,
kFALSE);
319void ToyEvent7::GenerateSignalKinematics(
TRandom *rnd,
Bool_t isData) {
327 }
while(fMGen[2]<=0.0);
340 if(rnd->
Uniform(-1.,1.)<0.) fEtaGen[2] *= -1.;
343 fPtGen[2]=rnd->
Landau(MU_PT,SIGMA_PT);
344 }
while((fPtGen[2]<=0.0)||(fPtGen[2]>500.));
357 costh=
r*(1.+DECAY_A*
r*
r);
358 }
while(
fabs(costh)>=1.0);
360 double e=0.5*
sum.M();
362 double pz=ptot*costh;
364 double px=
pt*
cos(phi);
365 double py=
pt*
sin(phi);
366 p[0].SetXYZT(px,py,pz,
e);
367 p[1].SetXYZT(-px,-py,-pz,
e);
368 for(
int i=0;i<2;i++) {
372 for(
int i=0;i<3;i++) {
374 fEtaGen[i]=
p[i].Eta();
375 fPhiGen[i]=
p[i].Phi();
380void ToyEvent7::GenerateBgrKinematics(
TRandom *rnd,
Bool_t isData) {
381 for(
int i=0;i<3;i++) {
387 for(
int i=0;i<2;i++) {
388 p[i].SetPtEtaPhiM(rnd->
Exp(15.0),rnd->
Uniform(-3.,3.),
392 for(
int i=0;i<3;i++) {
394 fEtaRec[i]=
p[i].Eta();
395 fPhiRec[i]=
p[i].Phi();
400void ToyEvent7::GenerateReco(
TRandom *rnd) {
403 for(
int i=0;i<2;i++) {
405 Double_t coshEta=(expEta+1./expEta);
413 eRec=rnd->
Gaus(eGen,sigmaE);
416 p[i].SetPtEtaPhiM(eRec/(expEta+1./expEta),
417 rnd->
Gaus(fEtaGen[i],sigmaEta),
422 for(
int i=0;i<3;i++) {
424 fEtaRec[i]=
p[i].Eta();
425 fPhiRec[i]=
p[i].Phi();
431 Double_t tauDiscr=0.08-0.04/(1.+fPtRec[2]/10.0);
433 fDiscriminator=1.0-rnd->
Exp(tauDiscr)+rnd->
Gaus(0.,sigmaDiscr);
434 }
while((fDiscriminator<=0.)||(fDiscriminator>=1.));
437 Double_t tauDiscr=0.15-0.05/(1.+fPtRec[2]/5.0)+0.1*fEtaRec[2];
438 Double_t sigmaDiscr=0.02+0.01*fEtaRec[2];
439 fDiscriminator=rnd->
Exp(tauDiscr)+rnd->
Gaus(0.,sigmaDiscr);
440 }
while((fDiscriminator<=0.)||(fDiscriminator>=1.));
443 for(
int i=0;i<2;i++) {
444 if(rnd->
Uniform()<0.92/(
TMath::Exp(-(fPtRec[i]-15.5)/2.5)+1.)) fIsTriggered=
true;
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
void SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m)
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 ULong64_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
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).
virtual Double_t Landau(Double_t mean=0, Double_t sigma=1)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
virtual Double_t BreitWigner(Double_t mean=0, Double_t gamma=1)
Return a number distributed following a BreitWigner function with mean and gamma.
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.
RVec< PromoteTypes< T0, T1 > > remainder(const T0 &x, const RVec< T1 > &v)
RVec< PromoteType< T > > cos(const RVec< T > &v)
RVec< PromoteType< T > > sin(const RVec< T > &v)
LVector boost(const LVector &v, const BoostVector &b)
Boost a generic Lorentz Vector class using a generic 3D Vector class describing the boost The only re...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
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.
static uint64_t sum(uint64_t i)