Skip to content

Commit d414a41

Browse files
committed
Move Xsection (barn) calculation to TGenEpEmv1
1 parent 21224f3 commit d414a41

File tree

4 files changed

+58
-43
lines changed

4 files changed

+58
-43
lines changed

TEPEMGEN/TGenEpEmv1.cxx

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ TGenEpEmv1::TGenEpEmv1():
8989
fYMin(-100.), fYMax(100.),
9090
fPhiMin(0.), fPhiMax(360.),
9191
fPtMin(0.), fPtMax(1.e10),
92-
fTimeOrigin(0.)
92+
fTimeOrigin(0.),
93+
fXSection(-1.),
94+
fXSectionEps(1e-2),
95+
fMinXSTest(1000),
96+
fMaxXSTest(10000000)
9397
{
9498
// Default constructor
9599
for (Int_t i = 0; i < 3; ++i) {
@@ -115,8 +119,46 @@ void TGenEpEmv1::Init()
115119
if (fPtMin == 0) fPtMin = 1.E-04; // avoid zero pT
116120
Initialize(fYMin, fYMax, fPtMin, fPtMax);
117121
fEvent = 0;
122+
//
123+
// calculate XSection
124+
double err = 0;
125+
fXSection = CalcXSection(fXSectionEps,fMinXSTest,fMaxXSTest,err);
126+
if (fXSection<=0 || err/fXSection>fXSectionEps) {
127+
abort();
128+
}
129+
fXSectionEps = err/fXSection;
118130
}
119131

132+
//____________________________________________________________
133+
double TGenEpEmv1::CalcXSection(double eps, int triMin, int triMax, double& err)
134+
{
135+
if (eps<1e-4) {
136+
eps = 1e-4;
137+
}
138+
int ngen = 0;
139+
printf("Estimating x-section with min.relative precision of %f and min/max test: %d/%d\n",
140+
eps,triMin,triMax);
141+
double yElectron,yPositron,xElectron,xPositron,phi12,weight;
142+
double xSect = -1;
143+
err = -1;
144+
//
145+
do {
146+
TEpEmGen::GenerateEvent(fYMin,fYMax,fPtMin,fPtMax,yElectron,yPositron,xElectron,xPositron,phi12,weight);
147+
if (++ngen>triMin) { // ensure min number of tests
148+
xSect = TEpEmGen::GetXsection()*1000;
149+
err = TEpEmGen::GetDsection()*1000;
150+
}
151+
} while(!((xSect>0 && err/xSect<eps) || ngen>triMax));
152+
//
153+
if (xSect<=0) {
154+
printf("Failed to estimate X-section after %d trials\n",ngen);
155+
abort();
156+
}
157+
printf("X-section = %e with %e error after %d trials",xSect,err,ngen);
158+
return xSect;
159+
}
160+
161+
120162
//____________________________________________________________
121163
void TGenEpEmv1::GenerateEvent()
122164
{

TEPEMGEN/TGenEpEmv1.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,19 @@ class TGenEpEmv1 : public TEpEmGen {
3232
void SetOrigin(Float_t ox, Float_t oy, Float_t oz) {fOrigin[0]=ox; fOrigin[1]=oy; fOrigin[2]=oz;};
3333
void SetSigma(Float_t sx, Float_t sy, Float_t sz) {fOsigma[0]=sx; fOsigma[1]=sy; fOsigma[2]=sz;};
3434
void SetTimeOrigin(Float_t timeorig) {fTimeOrigin = timeorig;};
35+
void SetXSectionEps(double eps=1e-2) {fXSectionEps = eps>0 ? eps:1e-2;}
36+
void SetMinMaxXSTest(int mn,int mx);
37+
double CalcXSection(double eps, int triMin, int triMax, double& err);
38+
double GetXSection() const {return fXSection;}
39+
double GetXSectionEps() const {return fXSectionEps;}
3540

3641
protected:
3742
TGenEpEmv1(const TGenEpEmv1 & gen);
3843
TGenEpEmv1 & operator=(const TGenEpEmv1 & gen);
3944
void GeneratePair(Double_t vx, Double_t vy, Double_t vz, Double_t vt);
4045
void Rndm(Float_t *array, Int_t n) {gRandom->RndmArray(n, array);};
4146
void Rndm(Double_t *array, Int_t n) {gRandom->RndmArray(n, array);};
42-
47+
4348
Float_t fMass; // electron mass
4449
Int_t fDebug; // debug level
4550
Int_t fEvent; // internal event number
@@ -49,6 +54,12 @@ class TGenEpEmv1 : public TEpEmGen {
4954
Double_t fPtMin, fPtMax;
5055
Double_t fTimeOrigin, fOrigin[3], fOsigma[3];
5156

57+
Double_t fXSection; // estimated cross section in barns
58+
Double_t fXSectionEps; // error with wich Xsection is calculated
59+
int fMinXSTest; // min number of generator calls for Xsection estimate
60+
int fMaxXSTest; // max number of generator calls for Xsection estimate
61+
62+
5263
ClassDef(TGenEpEmv1,1) // Generator of single e+e- pair production in PbPb ultra-peripheral collisions
5364
};
5465
#endif

TEPEMGEN/TGenQEDBg.cxx

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,8 @@ ClassImp(TGenQEDBg);
8989

9090
TGenQEDBg::TGenQEDBg()
9191
: fLumi(0)
92-
,fXSection(0)
93-
,fXSectionEps(1e-2)
9492
,fIntTime(0)
9593
,fPairsInt(-1)
96-
,fMinXSTest(1e3)
97-
,fMaxXSTest(1e7)
9894
{
9995
}
10096

@@ -118,27 +114,9 @@ void TGenQEDBg::Init()
118114
TGenEpEmv1::Init();
119115
//
120116
fPairsInt = 0;
121-
int ngen = 0;
122-
printf("Estimating x-section with min.relative precision of %f and min/max test: %d/%d",
123-
fXSectionEps,int(fMinXSTest),int(fMaxXSTest));
124-
//
125-
double yElectron,yPositron,xElectron,xPositron,phi12,weight,err=0;
126-
fXSection = -1;
127-
do {
128-
TEpEmGen::GenerateEvent(fYMin,fYMax,fPtMin,fPtMax,yElectron,yPositron,xElectron,xPositron,phi12,weight);
129-
if (++ngen>fMinXSTest) { // ensure min number of tests
130-
fXSection = GetXsection();
131-
err = GetDsection();
132-
}
133-
} while(!((fXSection>0 && err/fXSection<fXSectionEps) || ngen>fMaxXSTest));
134-
//
135-
if (fXSection<=0) {
136-
printf("X-section = %e after %d trials, cannot generate",fXSection,ngen);
137-
abort();
138-
}
139-
fPairsInt = fXSection*1e-21*fLumi*fIntTime; // xsestion is in kbarn!
140-
printf("Estimated x-secion: %e+-%ekb in %d tests, <Npairs>=%e per %e time interval",
141-
fXSection,err,ngen,fPairsInt,fIntTime);
117+
fPairsInt = fXSection*1e-24*fLumi*fIntTime; // xsestion is in barn!
118+
printf("Estimated x-secion: %e+-%eb, <Npairs>=%e per %e time interval",
119+
fXSection,fXSectionEps*fXSection,fPairsInt,fIntTime);
142120
//
143121
}
144122

@@ -192,11 +170,3 @@ void TGenQEDBg::SetLumiIntTime(double lumi, double intTime)
192170
fIntTime = intTime;
193171
//
194172
}
195-
196-
//__________________________________________________________
197-
void TGenQEDBg::SetMinMaxXSTest(double mn,double mx)
198-
{
199-
// set min,max number of generator calls for xsection estimates
200-
fMinXSTest = mn>100 ? mn : 100.;
201-
fMaxXSTest = mx>mx ? mx : mx+100.;
202-
}

TEPEMGEN/TGenQEDBg.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,17 @@ class TGenQEDBg : public TGenEpEmv1
2727
//
2828
Double_t GetLuminosity() const {return fLumi;}
2929
Double_t GetIntegrationTime() const {return fIntTime;}
30-
Double_t GetXSection() const {return fXSection;}
31-
Double_t GetXSectionEps() const {return fXSectionEps;}
3230
Double_t GetMeanNPairs() const {return fPairsInt;}
3331
//
3432
void SetLumiIntTime(double lumi, double intTime);
35-
void SetXSectionEps(double eps=1e-2) {fXSectionEps = eps>0 ? eps:1e-2;}
36-
void SetMinMaxXSTest(double mn,double mx);
3733
//
3834
protected:
3935
TGenQEDBg(const TGenQEDBg & gen);
4036
TGenQEDBg & operator=(const TGenQEDBg & gen);
4137
//
4238
Double_t fLumi; // beam luminsity
43-
Double_t fXSection; // estimated cross section in k-barns
44-
Double_t fXSectionEps; // error with wich Xsection is calculated
4539
Double_t fIntTime; // integration time in seconds
4640
Double_t fPairsInt; // estimated average number of pairs in IntTime
47-
Double_t fMinXSTest; // min number of generator calls for Xsection estimate
48-
Double_t fMaxXSTest; // max number of generator calls for Xsection estimate
4941

5042
//
5143
ClassDef(TGenQEDBg,1) // Generator e+e- pair background from PbPb QED interactions

0 commit comments

Comments
 (0)