当前位置: 首页>>代码示例>>C++>>正文


C++ TVector3::SetMag方法代码示例

本文整理汇总了C++中TVector3::SetMag方法的典型用法代码示例。如果您正苦于以下问题:C++ TVector3::SetMag方法的具体用法?C++ TVector3::SetMag怎么用?C++ TVector3::SetMag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TVector3的用法示例。


在下文中一共展示了TVector3::SetMag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetRandomMomentum

//________________________________________________________
void KVParticle::SetRandomMomentum(Double_t T, Double_t thmin,
                                   Double_t thmax, Double_t phmin,
                                   Double_t phmax, Option_t* opt)
{
   //Give randomly directed momentum to particle with kinetic energy T
   //Direction will be between (thmin,thmax) [degrees] limits in polar angle,
   //and (phmin,phmax) [degrees] limits in azimuthal angle.
   //
   //If opt = "" or "isotropic" (default) : direction is isotropically distributed over the solid angle
   //If opt = "random"                    : direction is randomly distributed over solid angle
   //
   //Based on KVPosition::GetRandomDirection().

   Double_t p = (T + M()) * (T + M()) - M2();
   if (p > 0.)
      p = (TMath::Sqrt(p));     // calculate momentum
   else
      p = 0.;

   TVector3 dir;
   KVPosition pos(thmin, thmax, phmin, phmax);
   dir = pos.GetRandomDirection(opt);   // get isotropic unit vector dir
   if (p && dir.Mag())
      dir.SetMag(p);            // set magnitude of vector to momentum required
   SetMomentum(dir);            // set momentum 4-vector
}
开发者ID:GiuseppePast,项目名称:kaliveda,代码行数:27,代码来源:KVParticle.cpp

示例2: main

int main( int argc, const char *argv[] )
{

	double momentum  = 0.2;
	double theta 	  = 0.5*M_PI;
	double phi  	  = 0.00;
	double 	     M  = 10.0;
	double 	Energy  = sqrt(momentum*momentum+M*M);
	double 	    m1  = 0.0000;
	double 	    m2  = 0.0000;
	double 	    m3  = 0.0000;

//	double x1 = 0.5;
//	double x2 = 0.2;
//	double x3 = 0.4;
//	double x4 = 0.3342;
//	double x5 = 0.75;
//

	double x1 = 0.50;
	double x2 = 0.00;
	double x3 = 0.00;
	double x4 = 0.00;
	double x5 = 0.00;

	{
	std::cout << "test_PhaseSpaceTools " << std::endl;

	TLorentzVector p1;
	TLorentzVector p2;
	TLorentzVector p3;

	TVector3 v1;

	double costheta1 = 2*x2-1;
	double sintheta1 = sqrt(1-costheta1*costheta1);
	double 	   phi1 = 2*M_PI*x3;
	double sqrt_s23  = x1*(M-m1-m2-m3) + m1+m2;

	double costheta23 = 2*x4-1;
	double sintheta23 = sqrt(1-costheta23*costheta23);
	double 	   phi23 = 2*M_PI*x5;

	double      s = M*M;
	double m1_sqr = m1*m1;
	double m2_sqr = m2*m2;
	double m3_sqr = m3*m3;
	double 	 s23 = sqrt_s23*sqrt_s23;

	double    pmag  = TwoBodyFunc::p    (s, m1_sqr, s23);
	double beta1    = TwoBodyFunc::beta (s, m1_sqr, s23);
	double 	 E1    = TwoBodyFunc::E    (M, m1_sqr, s23);
	double 	 E23   = TwoBodyFunc::E    (M, s23, m1_sqr);

	p1.SetPxPyPzE(pmag*sintheta1*cos(phi1),pmag*sintheta1*sin(phi1),pmag*costheta1,E1);

	TVector3 v;
	v = -p1.Vect();
	v.SetMag(v.Mag()/E23);

	double    p2mag  = TwoBodyFunc::p    (s23, m2_sqr, m3_sqr);
	double    	 E2  = TwoBodyFunc::E    (sqrt_s23, m2_sqr, m3_sqr);
	double    	 E3  = TwoBodyFunc::E    (sqrt_s23, m3_sqr, m2_sqr);

	p2.SetPxPyPzE(p2mag*sintheta23*cos(phi23),p2mag*sintheta23*sin(phi23),p2mag*costheta23,E2);
	p3.SetPxPyPzE(-p2mag*sintheta23*cos(phi23),-p2mag*sintheta23*sin(phi23),-p2mag*costheta23,E3);

	std::cout << "p1:" << std::endl;
	displayTLorentzVector(&p1);

	std::cout << "p2 and p3 in the 23 rest frame:" << std::endl;

	std::cout << "p2:" << std::endl;
	displayTLorentzVector(&p2);

	std::cout << "p3:" << std::endl;
	displayTLorentzVector(&p3);

	p2.Boost(v);
	p3.Boost(v);


	std::cout << "All in the lab frame:" << std::endl;

	std::cout << "p1:" << std::endl;
	displayTLorentzVector(&p1);

	std::cout << "p2:" << std::endl;
	displayTLorentzVector(&p2);

	std::cout << "p3:" << std::endl;
	displayTLorentzVector(&p3);

	TLorentzVector sum;
	sum = p1 + p2 + p3;

	std::cout << "sum in the lab frame:" << std::endl;
	displayTLorentzVector(&sum);

	}
//.........这里部分代码省略.........
开发者ID:denglert,项目名称:HelicityCalcFW,代码行数:101,代码来源:test_PhaseSpaceTools.cpp


注:本文中的TVector3::SetMag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。