BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtXsection Class Reference

#include <EvtXsection.hh>

Public Member Functions

 EvtXsection (std::vector< EvtId > evtdaugs)
 EvtXsection (int mode)
virtual ~EvtXsection ()
int getMode (std::vector< EvtId > evtdaugs)
void ini_data0 (int mode)
void ini_data (int mode)
void ini_data_diy ()
void ini_data_multimode ()
double getXsection (double mx)
double getErr (double mx)
double Xsection_a (double mx)
double Xsection_b (double mx)
double Xsection_c (double mx)
double Err_a (double mx)
double Err_b (double mx)
int getXBin (double mx, std::vector< double > vy)
int getXBin_a (double mx)
int getXBin_b (double mx)
std::string getUnit ()
std::vector< double > getXX ()
std::vector< double > getYY ()
std::vector< double > getEr ()
double getXup ()
double getXlw ()
std::string getMsg ()
void setBW (int pdg)
void setFile (std::string name)
double getVP (double mx)
void ReadVP ()
void setModes (std::vector< int > vmd)

Detailed Description

Definition at line 132 of file EvtXsection.hh.

Constructor & Destructor Documentation

◆ EvtXsection() [1/2]

EvtXsection::EvtXsection ( std::vector< EvtId > evtdaugs)
inline

Definition at line 134 of file EvtXsection.hh.

134 {
135 xx.clear();
136 yy.clear();
137 er.clear();
138 _mode = getMode( evtdaugs );
139 ini_data( _mode );
140 }
void ini_data(int mode)
int getMode(std::vector< EvtId > evtdaugs)

◆ EvtXsection() [2/2]

EvtXsection::EvtXsection ( int mode)
inline

Definition at line 141 of file EvtXsection.hh.

141 {
142 xx.clear();
143 yy.clear();
144 er.clear();
145 _mode = mode;
146 if ( mode >= 0 ) { ini_data( _mode ); }
147 else if ( mode == -1 )
148 { // calculate the correction factor with Breit-wigner
149 _unit = "nb";
150 }
151 else if ( mode == -2 )
152 { // users provide the cross section list
153 // std::cout<<"user diy"<<std::endl;
154 ini_data_diy();
155 }
156 else if ( mode == -100 )
157 { // multi-exclusive modes
158 _unit = "nb";
159 }
160 // std::cout<<"The mode is : "<<_mode<<", "<<xx[0]<<", "<<yy[0]<<std::endl;
161 }
void ini_data_diy()

◆ ~EvtXsection()

EvtXsection::~EvtXsection ( )
virtual

Definition at line 124 of file EvtXsection.cc.

124{}

Member Function Documentation

◆ Err_a()

double EvtXsection::Err_a ( double mx)

Definition at line 320 of file EvtXsection.cc.

320 {
321 if ( _mode == -1 ) return 0.;
322 if ( mx <= xx[0] ) return er[0];
323 if ( mx > xx[nbins] ) return 0.;
324 int thebin = getXBin_a( mx );
325 //-- debug
326 // std::cout<<"Mode= "<<_mode<<", thebin"<<thebin<<std::endl;
327 return er[thebin];
328}
int getXBin_a(double mx)

◆ Err_b()

double EvtXsection::Err_b ( double mx)

Definition at line 330 of file EvtXsection.cc.

330 { // interpolation of the cross section error between
331 // two bins
332 if ( mx <= xx[0] ) return er[0];
333 if ( mx > xx[nbins - 1] ) return 0.;
334 int thebin = getXBin_b( mx );
335 double ylow = er[thebin];
336 double yup = er[thebin + 1];
337
338 double xlow = xx[thebin];
339 double xup = xx[thebin + 1];
340
341 double yi = ylow + ( yup - ylow ) / ( xup - xlow ) * ( mx - xlow );
342 return yi;
343}
DOUBLE_PRECISION xup[20]
DOUBLE_PRECISION xlow[20]
int getXBin_b(double mx)

Referenced by getErr().

◆ getEr()

std::vector< double > EvtXsection::getEr ( )
inline

Definition at line 186 of file EvtXsection.hh.

186{ return er; }

◆ getErr()

double EvtXsection::getErr ( double mx)

Definition at line 288 of file EvtXsection.cc.

288 {
289 // if(_mode <= 5 && _mode !=1 ){ return Err_a(mx);}
290 // else {return Err_b(mx);}
291 return Err_b( mx );
292}
double Err_b(double mx)

Referenced by ini_data_multimode().

◆ getMode()

int EvtXsection::getMode ( std::vector< EvtId > evtdaugs)

Definition at line 241 of file EvtXsection.cc.

241 {
242 /*******************--- mode definition:
243 0: ppbar
244 1: nnbar
245 2: Lambda0 anti-Lambda0
246 3: Sigma0 anti-Sigma0
247 4: Lambda0 anti-Sigma0
248 5: Sigma0 anti-Lambda0
249 6: pi+ pi-
250 7: pi+ pi- pi0
251 8: K+K- pi0
252 9: KsK+pi-
253 10: KsK-pi+
254 11: K+K-eta
255 *************************************/
256 int pp[2] = { -2212, 2212 };
257 int nn[2] = { -2112, 2112 };
258 int pipi[2] = { -211, 211 };
259 int pi3[3] = { -211, 111, 211 };
260 int kkpi0[3] = { -321, 111, 321 }; // K+K-pi0
261 int kskpi[3] = { -211, 310, 321 }; // KsK+pi-
262
263 std::vector<int> vson;
264 vson.clear();
265 for ( int i = 0; i < evtdaugs.size(); i++ )
266 { vson.push_back( EvtPDL::getStdHep( evtdaugs[i] ) ); }
267 sort( vson.begin(), vson.end(), mysort );
268
269 if ( vson.size() == 2 )
270 {
271 if ( vson[0] == pp[0] && vson[1] == pp[1] ) { return 0; }
272 if ( vson[0] == nn[0] && vson[1] == nn[1] ) { return 1; }
273 if ( vson[0] == pipi[0] && vson[1] == pipi[1] ) { return 2; }
274 }
275 else if ( vson.size() == 3 ) {}
276
277 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
278 exit( 1 );
279}
struct myclass mysort
static int getStdHep(EvtId id)
Definition EvtPDL.hh:61

Referenced by EvtXsection().

◆ getMsg()

std::string EvtXsection::getMsg ( )
inline

Definition at line 189 of file EvtXsection.hh.

189{ return msg; }

◆ getUnit()

std::string EvtXsection::getUnit ( )
inline

Definition at line 182 of file EvtXsection.hh.

182{ return _unit; }

Referenced by ini_data_multimode().

◆ getVP()

double EvtXsection::getVP ( double mx)

◆ getXBin()

int EvtXsection::getXBin ( double mx,
std::vector< double > vy )

Definition at line 369 of file EvtXsection.cc.

369 {
370 double nbins = vy.size();
371 if ( vy[0] < mx || mx < vy[nbins - 1] )
372 {
373 std::cout << "Outside vacuum pol. value" << std::endl;
374 abort();
375 }
376 for ( int i = 0; i < nbins - 1; i++ )
377 {
378 if ( mx <= vy[i + 1] && mx > vy[i] ) return i; // mx at i to i+1 bin
379 }
380
381 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
382 exit( 1 );
383}

◆ getXBin_a()

int EvtXsection::getXBin_a ( double mx)

Definition at line 345 of file EvtXsection.cc.

345 {
346 if ( mx <= xx[0] ) return 0;
347 if ( mx > xx[nbins] ) return nbins;
348 for ( int i = 0; i < nbins; i++ )
349 {
350 if ( mx <= xx[i + 1] && mx > xx[i] ) return i; // mx at i-th bin
351 }
352
353 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
354 exit( 1 );
355}

Referenced by Err_a(), and Xsection_a().

◆ getXBin_b()

int EvtXsection::getXBin_b ( double mx)

Definition at line 357 of file EvtXsection.cc.

357 {
358 if ( mx <= xx[0] ) return 0;
359 if ( mx > xx[nbins - 1] ) return nbins;
360 for ( int i = 0; i < nbins - 1; i++ )
361 {
362 if ( mx <= xx[i + 1] && mx > xx[i] ) return i; // mx at i to i+1 bin
363 }
364
365 std::cerr << __FILE__ << ":" << __LINE__ << ": should not reach here" << std::endl;
366 exit( 1 );
367}

Referenced by Err_b(), and Xsection_b().

◆ getXlw()

double EvtXsection::getXlw ( )
inline

Definition at line 188 of file EvtXsection.hh.

188{ return xx[0]; }

Referenced by ini_data_multimode().

◆ getXsection()

double EvtXsection::getXsection ( double mx)

Definition at line 281 of file EvtXsection.cc.

281 {
282 if ( _mode == -1 ) { return Xsection_c( mx ); }
283 // else if(_mode == 0 || _mode == 2 || _mode == 3 || _mode == 4 ||_mode == 5){ return
284 // Xsection_a(mx);}
285 else { return Xsection_b( mx ); }
286}
double Xsection_b(double mx)
double Xsection_c(double mx)

Referenced by ini_data_multimode().

◆ getXup()

double EvtXsection::getXup ( )
inline

Definition at line 187 of file EvtXsection.hh.

187{ return xx[nbins - 1]; }

Referenced by ini_data_multimode().

◆ getXX()

std::vector< double > EvtXsection::getXX ( )
inline

Definition at line 184 of file EvtXsection.hh.

184{ return xx; }

◆ getYY()

std::vector< double > EvtXsection::getYY ( )
inline

Definition at line 185 of file EvtXsection.hh.

185{ return yy; }

◆ ini_data()

void EvtXsection::ini_data ( int mode)

◆ ini_data0()

void EvtXsection::ini_data0 ( int mode)

Definition at line 126 of file EvtXsection.cc.

126 {
127
128 xx.clear();
129 yy.clear();
130 er.clear();
131 nbins = yy.size();
132}

◆ ini_data_diy()

void EvtXsection::ini_data_diy ( )

Definition at line 134 of file EvtXsection.cc.

134 { // user provide xs list
135
136 xx.clear();
137 yy.clear();
138 er.clear();
139
140 ifstream file( "xs_user.txt" );
141
142 if ( !file )
143 {
144 cout << "EvtXsection.cc: The input file not found. The default file name should be "
145 "xs_user.txt!"
146 << std::endl;
147 exit( 0 );
148 }
149
150 double xm, xs, xs_er;
151
152 while ( !file.eof() )
153 {
154 file >> xm >> xs >> xs_er;
155 // std::cout<<"read XS: "<<xm<<" "<<xs<<" "<<xs_er<<std::endl;
156 xx.push_back( xm );
157 yy.push_back( xs );
158 er.push_back( xs_er );
159 }
160
161 xx.pop_back();
162 yy.pop_back();
163 er.pop_back();
164 nbins = yy.size();
165 file.close();
166 _unit = "";
167 msg = "";
168}
char * file
Definition DQA_TO_DB.cxx:16

Referenced by EvtXsection().

◆ ini_data_multimode()

void EvtXsection::ini_data_multimode ( )

Definition at line 170 of file EvtXsection.cc.

170 { // multi-exclusive modes
171 xx.clear();
172 yy.clear();
173 er.clear();
174
175 if ( _vmd.size() == 0 )
176 {
177 std::cout << "EvtXsection::ini_data_multimode: No mode indexes are available" << std::endl;
178 abort();
179 }
180
181 double xL = 10.0;
182 double xU = -1.0;
183
184 for ( int i = 0; i < _vmd.size(); i++ )
185 {
186 ini_data( _vmd[i] );
187 double x0 = getXlw();
188 double x1 = getXup();
189 if ( x0 < xL ) xL = x0;
190 if ( x1 > xU ) xU = x1;
191 }
192
193 std::cout << "The low and up end of multimodes: " << xL << " ~ " << xU << std::endl;
194 double stp = 0.0005; // 5 MeV for bin width
195 double xm;
196 double xs = 0; // xsection in nb;
197 double xs_er = 0;
198 double mypb = 1;
199 std::vector<double> uxx, uyy, uer;
200 uxx.clear();
201 uyy.clear();
202 uer.clear();
203 for ( double xxm = xL; xxm < xU; xxm += stp )
204 {
205 xm = xxm;
206 xs = 0;
207 xs_er = 0;
208 for ( int i = 0; i < _vmd.size(); i++ )
209 {
210 ini_data( _vmd[i] );
211 std::string myunit = getUnit();
212 if ( myunit == "pb" ) { mypb = 0.001; }
213 else { mypb = 1; }
214 xs += mypb * getXsection( xxm );
215 xs_er += mypb * getErr( xxm );
216 // std::cout<<_vmd[i]<< ": "<<xm<<" "<<xs<<" "<<xs_er<<std::endl;
217 } // loop over mode
218 uxx.push_back( xm );
219 uyy.push_back( xs );
220 uer.push_back( xs_er );
221 } // loop over mass
222
223 xx.clear();
224 yy.clear();
225 er.clear();
226 for ( int i = 0; i < uxx.size(); i++ )
227 {
228 xx.push_back( uxx[i] );
229 yy.push_back( uyy[i] );
230 er.push_back( uer[i] );
231 }
232 // debugging
233 // for(int i=0;i<yy.size();i++){
234 // std::cout<<xx[i]<<" "<<yy[i]<<std::endl;
235 // }
236 _unit = "nb";
237 nbins = yy.size();
238 msg = "multi-exclusive mode";
239}
double getXlw()
double getErr(double mx)
double getXup()
std::string getUnit()
double getXsection(double mx)

◆ ReadVP()

void EvtXsection::ReadVP ( )

◆ setBW()

void EvtXsection::setBW ( int pdg)

Definition at line 404 of file EvtXsection.cc.

404 {
405 pdgcode = pdg;
406 EvtId pid = EvtPDL::evtIdFromStdHep( pdgcode );
407 double maxM = EvtPDL::getMaxMass( pid );
408 double minM = EvtPDL::getMinMass( pid );
409 double meanM = EvtPDL::getMeanMass( pid );
410 double width = EvtPDL::getWidth( pid );
411 // std::cout<<minM<<" <=M<= "<<maxM<<std::endl;
412 double xstp = ( maxM - minM ) / 100.;
413 xx.clear();
414 yy.clear();
415 er.clear();
416 for ( int i = 0; i < 100; i++ )
417 {
418 double m = i * xstp;
419 EvtComplex im( 0., 1. );
420 EvtComplex bw = 1. / ( m * m - meanM * meanM + im * m * width );
421 double amps = abs2( bw );
422 xx.push_back( m );
423 yy.push_back( amps );
424 er.push_back( 0. );
425 }
426 nbins = yy.size();
427}
double abs2(const EvtComplex &c)
static double getWidth(EvtId i)
Definition EvtPDL.hh:59
static double getMeanMass(EvtId i)
Definition EvtPDL.hh:43
static EvtId evtIdFromStdHep(int stdhep)
Definition EvtPDL.cc:232
static double getMinMass(EvtId i)
Definition EvtPDL.hh:56
static double getMaxMass(EvtId i)
Definition EvtPDL.hh:55

◆ setFile()

void EvtXsection::setFile ( std::string name)
inline

Definition at line 191 of file EvtXsection.hh.

191{ file = name; }

◆ setModes()

void EvtXsection::setModes ( std::vector< int > vmd)

Definition at line 429 of file EvtXsection.cc.

429 {
430 _vmd.clear();
431 for ( int i = 0; i < vmd.size(); i++ ) { _vmd.push_back( vmd[i] ); }
432}

◆ Xsection_a()

double EvtXsection::Xsection_a ( double mx)

Definition at line 295 of file EvtXsection.cc.

295 {
296 if ( mx <= xx[0] ) return 0.;
297 if ( mx > xx[nbins] ) return 0.;
298 int thebin = getXBin_a( mx );
299 //-- debug
300 // std::cout<<"Mode= "<<_mode<<", thebin"<<thebin<<std::endl;
301 return yy[thebin];
302}

◆ Xsection_b()

double EvtXsection::Xsection_b ( double mx)

Definition at line 304 of file EvtXsection.cc.

304 { // interpolation of the cross section between two
305 // bins
306 if ( mx <= xx[0] ) return 0.;
307 if ( mx > xx[nbins - 1] ) return 0.;
308 int thebin = getXBin_b( mx );
309 double ylow = yy[thebin];
310 double yup = yy[thebin + 1];
311
312 double xlow = xx[thebin];
313 double xup = xx[thebin + 1];
314
315 double yi = ylow + ( yup - ylow ) / ( xup - xlow ) * ( mx - xlow );
316 return yi;
317}

Referenced by getXsection().

◆ Xsection_c()

double EvtXsection::Xsection_c ( double mx)

Definition at line 385 of file EvtXsection.cc.

385 { // in unit nb
386 double pi = 3.1415926;
387 double s = mx * mx;
388 EvtId pid = EvtPDL::evtIdFromStdHep( pdgcode );
389 double mass = EvtPDL::getMeanMass( pid );
390 double width = EvtPDL::getWidth( pid );
391 double mass2 = mass * mass;
392 double width2 = width * width;
393 double br = ( s - mass2 ) * ( s - mass2 ) + mass2 * width2;
394 bree = 1; // this value is canceled when calculation the correction factor;
395 double sigma = 12 * pi * bree * width2 / br;
396 double nbar = 4E05; // ! GeV-2 = 4*10^5 nbar
397 double thexs = sigma * nbar;
398 // std::cout<<"EvtXsection::Xsection_c: "<<mass<<" "<<width<<" "<<thexs<<std::endl;
399 // msg = "Calculate the correction factor for " + EvtPDL::name(pid);
400
401 return thexs;
402}
double mass
double pi
XmlRpcServer s

Referenced by getXsection().


The documentation for this class was generated from the following files: