本文整理汇总了C++中TVector3::RotateY方法的典型用法代码示例。如果您正苦于以下问题:C++ TVector3::RotateY方法的具体用法?C++ TVector3::RotateY怎么用?C++ TVector3::RotateY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVector3
的用法示例。
在下文中一共展示了TVector3::RotateY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testRotation
void testRotation(){
//LOAD LIBS
cout << "\n";
gROOT->Macro("StRoot/LoadLibs.C");
gSystem->Load("pionPair");
cout << " loading of pionPair library done" << endl;
TFile* infile = new TFile("/star/u/klandry/ucladisk/2012IFF/schedOutputAll/all_0.root");
//SET UP TREE TO RECEIVE INPUT
pionPair* pair1 = new pionPair();
TTree* pairTree = infile->Get("pionPairTree");
pairTree->SetBranchAddress("pionPair", &pair1);
for (int iPair = 0; iPair < pairTree->GetEntries(); iPair++)
{
if (iPair%10000 == 0) {cout << "processing pair number " << iPair << endl;}
//cout << "processing pair number " << iPair << endl;
//if (iPair == 661){continue;}
pairTree->GetEntry(iPair);
TVector3 spinVec;
if (pair1->withinRadius(0.05, 0.3))
{
int spinB = pair1->spinBit();
if (spinB == 5 || spinB == 9) //yelow down
{
spinVec.SetXYZ(0, -1, 0);
}
if (spinB == 6 || spinB == 10) //yellow up
{
spinVec.SetXYZ(0, 1, 0);
}
if (spinB == 5 || spinB == 6 || spinB == 9 || spinB == 10)
{
TVector3 Ph = pair1->piPlusLV().Vect() + pair1->piMinusLV().Vect();
TVector3 Rh = pair1->piPlusLV().Vect() - pair1->piMinusLV().Vect();
TVector3 Pa;
Pa.SetXYZ(0, 0, 1); //blue is unpolarized beam
TVector3 Pb;
Pb.SetXYZ(0, 0, -1); //yellow is polarized beam
//ROTATE EVERYTHING BY PI AROUND Y AXIS
Ph.RotateY(TMath::Pi());
Rh.RotateY(TMath::Pi());
Pa.RotateY(TMath::Pi());
Pb.RotateY(TMath::Pi());
// cout << Ph << endl;
// cout << Rh << endl;
// cout << Pa << endl;
// cout << Pb << endl;
//cout << "\n";
//cout << Ph.Unit().Cross(Pa) << endl;
//cout << Ph.Unit().Cross(Rh) << endl;
double cosPhi_S = Pb.Unit().Cross(Ph).Unit() * Pb.Unit().Cross(spinVec).Unit();
double cosPhi_R = Ph.Unit().Cross(Pa).Unit() * Ph.Unit().Cross(Rh).Unit();
double sinPhi_S = Ph.Cross(spinVec) * Pb.Unit() / (Pb.Unit().Cross(Ph).Mag() * Pb.Unit().Cross(spinVec).Mag());
double sinPhi_R = Pa.Cross(Rh) * Ph.Unit() / (Ph.Unit().Cross(Pa).Mag() * Ph.Unit().Cross(Rh).Mag());
double sinPhi_S_R = sinPhi_S*cosPhi_R - cosPhi_S*sinPhi_R;
double cosPhi_S_R = cosPhi_S*cosPhi_R + sinPhi_S*sinPhi_R;
//.........这里部分代码省略.........
示例2: rotate_3vector
void rotate_3vector(void){
PI = TMath::Pi();
TVector3 beam = TVector3(0.,0.,1.);
TVector3 scat = TVector3(0.2,0.4,1.);
std::cout << "beam x : " << beam.x() << std::endl;
std::cout << "beam y : " << beam.y() << std::endl;
std::cout << "beam z : " << beam.z() << std::endl;
std::cout << "scat x : " << scat.x() << std::endl;
std::cout << "scat y : " << scat.y() << std::endl;
std::cout << "scat z : " << scat.z() << std::endl;
double bx=beam.x();
double by=beam.y();
double bz=beam.z();
double sx=scat.x();
double sy=scat.y();
double sz=scat.z();
double theta = acos((bx*sx + by*sy + bz*sz)/sqrt(bx*bx + by*by + bz*bz)/sqrt(sx*sx + sy*sy + sz*sz));
double theta_ = acos(sz/sqrt(sx*sx+sy*sy+sz*sz));
std::cout << "theta : " << theta << std::endl;
std::cout << "theta_ : " << theta_ << std::endl;
TVector3 beam2 = TVector3(0, 1, 0);
double bx2=beam2.x();
double by2=beam2.y();
double bz2=beam2.z();
std::cout << "beam2 x (nom) : " << beam2.x()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;
std::cout << "beam2 y (nom) : " << beam2.y()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;
std::cout << "beam2 z (nom) : " << beam2.z()/sqrt(bx2*bx2+by2*by2+bz2*bz2) << std::endl;
double theta_tmp = - atan(by2/sqrt(bx2*bx2 + bz2*bz2));
double phi_tmp = atan2(bx2, bz2);
std::cout << "theta_tmp : " << theta_tmp << std::endl;
std::cout << "phi_tmp : " << phi_tmp << std::endl;
beam.RotateX(theta_tmp);
beam.RotateY(phi_tmp);
scat.RotateX(theta_tmp);
scat.RotateY(phi_tmp);
bx=beam.x();
by=beam.y();
bz=beam.z();
sx=scat.x();
sy=scat.y();
sz=scat.z();
std::cout << "roteta beam x : " << bx << std::endl;
std::cout << "roteta beam y : " << by << std::endl;
std::cout << "roteta beam z : " << bz << std::endl;
std::cout << "roteta scat x : " << sx << std::endl;
std::cout << "roteta scat y : " << sy << std::endl;
std::cout << "roteta scat z : " << sz << std::endl;
double theta_rotate = acos((bx*sx + by*sy + bz*sz)/sqrt(bx*bx + by*by + bz*bz)/sqrt(sx*sx + sy*sy + sz*sz));
std::cout << "===========================" << std::endl;
std::cout << "theta : " << theta << std::endl;
std::cout << "theta_rotate : " << theta_rotate << std::endl;
}