76 void GenerateDataEvent(
TRandom *rnd);
77 void GenerateSignalEvent(
TRandom *rnd);
78 void GenerateBgrEvent(
TRandom *rnd);
80 inline Double_t GetMRec(
int i)
const {
return fMRec[i]; }
81 inline Double_t GetPtRec(
int i)
const {
return fPtRec[i]; }
82 inline Double_t GetEtaRec(
int i)
const {
return fEtaRec[i]; }
83 inline Double_t GetDiscriminator(
void)
const {
return fDiscriminator; }
84 inline Double_t GetPhiRec(
int i)
const {
return fPhiRec[i]; }
85 inline Bool_t IsTriggered(
void)
const {
return fIsTriggered; }
88 inline Double_t GetMGen(
int i)
const {
89 if(IsSignal())
return fMGen[i];
92 inline Double_t GetPtGen(
int i)
const {
93 if(IsSignal())
return fPtGen[i];
96 inline Double_t GetEtaGen(
int i)
const {
97 if(IsSignal())
return fEtaGen[i];
100 inline Double_t GetPhiGen(
int i)
const {
101 if(IsSignal())
return fPhiGen[i];
104 inline Bool_t IsSignal(
void)
const {
return fIsSignal; }
109 void GenerateReco(
TRandom *rnd);
125 static Double_t kDataSignalFraction;
143 Int_t neventSigmc = 250000;
144 Int_t neventBgrmc = 100000;
146 Float_t etaRec[3],ptRec[3],phiRec[3],mRec[3],discr;
147 Float_t etaGen[3],ptGen[3],phiGen[3],mGen[3];
149 Int_t istriggered,issignal;
154 TFile *dataFile=
new TFile(
"testUnfold7_data.root",
"recreate");
157 dataTree->
Branch(
"etarec",etaRec,
"etarec[3]/F");
158 dataTree->
Branch(
"ptrec",ptRec,
"ptrec[3]/F");
159 dataTree->
Branch(
"phirec",phiRec,
"phirec[3]/F");
160 dataTree->
Branch(
"mrec",mRec,
"mrec[3]/F");
161 dataTree->
Branch(
"discr",&discr,
"discr/F");
164 dataTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
166 dataTree->
Branch(
"etagen",etaGen,
"etagen[3]/F");
167 dataTree->
Branch(
"ptgen",ptGen,
"ptgen[3]/F");
168 dataTree->
Branch(
"phigen",phiGen,
"phigen[3]/F");
169 dataTree->
Branch(
"mgen",mGen,
"mgen[3]/F");
170 dataTree->
Branch(
"issignal",&issignal,
"issignal/I");
172 cout<<
"fill data tree\n";
175 for(
int ievent=0;ievent<neventData;ievent++) {
177 event.GenerateDataEvent(g_rnd);
178 for(
int i=0;i<3;i++) {
179 etaRec[i]=
event.GetEtaRec(i);
180 ptRec[i]=
event.GetPtRec(i);
181 phiRec[i]=
event.GetPhiRec(i);
182 mRec[i]=
event.GetMRec(i);
183 etaGen[i]=
event.GetEtaGen(i);
184 ptGen[i]=
event.GetPtGen(i);
185 phiGen[i]=
event.GetPhiGen(i);
186 mGen[i]=
event.GetMGen(i);
188 discr=
event.GetDiscriminator();
189 istriggered=
event.IsTriggered() ? 1 : 0;
190 issignal=
event.IsSignal() ? 1 : 0;
194 if(!(ievent%100000)) cout<<
" data event "<<ievent<<
"\n";
208 TFile *signalFile=
new TFile(
"testUnfold7_signal.root",
"recreate");
209 TTree *signalTree=
new TTree(
"signal",
"event");
211 signalTree->
Branch(
"etarec",etaRec,
"etarec[3]/F");
212 signalTree->
Branch(
"ptrec",ptRec,
"ptrec[3]/F");
213 signalTree->
Branch(
"phirec",ptRec,
"phirec[3]/F");
214 signalTree->
Branch(
"mrec",mRec,
"mrec[3]/F");
215 signalTree->
Branch(
"discr",&discr,
"discr/F");
218 signalTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
220 signalTree->
Branch(
"etagen",etaGen,
"etagen[3]/F");
221 signalTree->
Branch(
"ptgen",ptGen,
"ptgen[3]/F");
222 signalTree->
Branch(
"phigen",phiGen,
"phigen[3]/F");
223 signalTree->
Branch(
"weight",&weight,
"weight/F");
224 signalTree->
Branch(
"mgen",mGen,
"mgen[3]/F");
226 cout<<
"fill signal tree\n";
228 weight=ToyEvent7::kMCSignalFraction*muData0/neventSigmc;
230 for(
int ievent=0;ievent<neventSigmc;ievent++) {
232 event.GenerateSignalEvent(g_rnd);
234 for(
int i=0;i<3;i++) {
235 etaRec[i]=
event.GetEtaRec(i);
236 ptRec[i]=
event.GetPtRec(i);
237 phiRec[i]=
event.GetPhiRec(i);
238 mRec[i]=
event.GetMRec(i);
239 etaGen[i]=
event.GetEtaGen(i);
240 ptGen[i]=
event.GetPtGen(i);
241 phiGen[i]=
event.GetPhiGen(i);
242 mGen[i]=
event.GetMGen(i);
244 discr=
event.GetDiscriminator();
245 istriggered=
event.IsTriggered() ? 1 : 0;
247 if(!(ievent%100000)) cout<<
" signal event "<<ievent<<
"\n";
259 TFile *bgrFile=
new TFile(
"testUnfold7_background.root",
"recreate");
260 TTree *bgrTree=
new TTree(
"background",
"event");
262 bgrTree->
Branch(
"etarec",&etaRec,
"etarec[3]/F");
263 bgrTree->
Branch(
"ptrec",&ptRec,
"ptrec[3]/F");
264 bgrTree->
Branch(
"phirec",&phiRec,
"phirec[3]/F");
265 bgrTree->
Branch(
"mrec",&mRec,
"mrec[3]/F");
266 bgrTree->
Branch(
"discr",&discr,
"discr/F");
267 bgrTree->
Branch(
"istriggered",&istriggered,
"istriggered/I");
268 bgrTree->
Branch(
"weight",&weight,
"weight/F");
270 cout<<
"fill background tree\n";
272 weight=(1.-ToyEvent7::kMCSignalFraction)*muData0/neventBgrmc;
274 for(
int ievent=0;ievent<neventBgrmc;ievent++) {
276 event.GenerateBgrEvent(g_rnd);
277 for(
int i=0;i<3;i++) {
278 etaRec[i]=
event.GetEtaRec(i);
279 ptRec[i]=
event.GetPtRec(i);
280 phiRec[i]=
event.GetPhiRec(i);
282 discr=
event.GetDiscriminator();
283 istriggered=
event.IsTriggered() ? 1 : 0;
285 if(!(ievent%100000)) cout<<
" background event "<<ievent<<
"\n";
295Double_t ToyEvent7::kDataSignalFraction=0.75;
296Double_t ToyEvent7::kMCSignalFraction=0.75;
298void ToyEvent7::GenerateDataEvent(
TRandom *rnd) {
299 fIsSignal=rnd->
Uniform()<kDataSignalFraction;
301 GenerateSignalKinematics(rnd,
kTRUE);
303 GenerateBgrKinematics(rnd,
kTRUE);
308void ToyEvent7::GenerateSignalEvent(
TRandom *rnd) {
310 GenerateSignalKinematics(rnd,
kFALSE);
314void ToyEvent7::GenerateBgrEvent(
TRandom *rnd) {
316 GenerateBgrKinematics(rnd,
kFALSE);
320void ToyEvent7::GenerateSignalKinematics(
TRandom *rnd,
Bool_t isData) {
328 }
while(fMGen[2]<=0.0);
341 if(rnd->
Uniform(-1.,1.)<0.) fEtaGen[2] *= -1.;
344 fPtGen[2]=rnd->
Landau(MU_PT,SIGMA_PT);
345 }
while((fPtGen[2]<=0.0)||(fPtGen[2]>500.));
348 sum.SetPtEtaPhiM(fPtGen[2],fEtaGen[2],fPhiGen[2],fMGen[2]);
358 costh=
r*(1.+DECAY_A*
r*
r);
359 }
while(
fabs(costh)>=1.0);
361 double e=0.5*
sum.M();
363 double pz=ptot*costh;
365 double px=
pt*
cos(phi);
366 double py=
pt*
sin(phi);
369 for(
int i=0;i<2;i++) {
373 for(
int i=0;i<3;i++) {
375 fEtaGen[i]=p[i].Eta();
376 fPhiGen[i]=p[i].Phi();
381void ToyEvent7::GenerateBgrKinematics(
TRandom *rnd,
Bool_t isData) {
382 for(
int i=0;i<3;i++) {
388 for(
int i=0;i<2;i++) {
393 for(
int i=0;i<3;i++) {
395 fEtaRec[i]=p[i].Eta();
396 fPhiRec[i]=p[i].Phi();
401void ToyEvent7::GenerateReco(
TRandom *rnd) {
404 for(
int i=0;i<2;i++) {
406 Double_t coshEta=(expEta+1./expEta);
414 eRec=rnd->
Gaus(eGen,sigmaE);
418 rnd->
Gaus(fEtaGen[i],sigmaEta),
419 remainder(rnd->
Gaus(fPhiGen[i],0.03),2.*
M_PI),
423 for(
int i=0;i<3;i++) {
425 fEtaRec[i]=p[i].Eta();
426 fPhiRec[i]=p[i].Phi();
432 Double_t tauDiscr=0.08-0.04/(1.+fPtRec[2]/10.0);
434 fDiscriminator=1.0-rnd->
Exp(tauDiscr)+rnd->
Gaus(0.,sigmaDiscr);
435 }
while((fDiscriminator<=0.)||(fDiscriminator>=1.));
438 Double_t tauDiscr=0.15-0.05/(1.+fPtRec[2]/5.0)+0.1*fEtaRec[2];
439 Double_t sigmaDiscr=0.02+0.01*fEtaRec[2];
440 fDiscriminator=rnd->
Exp(tauDiscr)+rnd->
Gaus(0.,sigmaDiscr);
441 }
while((fDiscriminator<=0.)||(fDiscriminator>=1.));
444 for(
int i=0;i<2;i++) {
445 if(rnd->
Uniform()<0.92/(
TMath::Exp(-(fPtRec[i]-15.5)/2.5)+1.)) fIsTriggered=
true;
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
void SetXYZT(Double_t x, Double_t y, Double_t z, Double_t t)
void SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m)
void Boost(Double_t, Double_t, Double_t)
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 Int_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.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
TVector3 is a general three vector class, which can be used for the description of different vectors ...
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 Sqrt(Double_t x)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Double_t Gamma(Double_t z)
Computation of gamma(z) for all z.
static long int sum(long int i)