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


C++ TVector2::Rotate方法代码示例

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


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

示例1: getD0RedMet

// D0 RedMET with CMG trees
double getD0RedMet(double lpx1, double lpy1, double lpterr1, 
		   double lpx2, double lpy2, double lpterr2, 
		   double sumjpx, double sumjpy, 
		   double pfmet, double pfmetphi, 
		   int flav, int pickAFlav = 1) {
			   


  if( flav==3 ) { 
    if( pickAFlav!=1 && pickAFlav!=2 ) {
      cout << " *** ERROR *** " << endl;
      cout << "  You need to pick a flavor in getD0RedMet(...)! " << endl;
      throw std::exception();
      return -1.;
    }
    else {
      flav = pickAFlav;
    }
  }

  // double wPerpMu = 1.0;
  // double wRecMu  = 2.0;
  // double wUncMu  = 2.5;
  double wPerpMu = 1.0;
  double wRecMu  = 1.5;
  double wUncMu  = 2.75;

  // double wPerpEl = 1.5;
  // double wRecEl  = 2.25;
  // double wUncEl  = 0.0;
  double wPerpEl = 0.75;
  double wRecEl  = 1.0;
  double wUncEl  = 0.25;
  
  int seplep = 1;
  
  if (seplep == 0){
		wPerpMu = 1.0;
		wRecMu  = 1.25;
		wUncMu  = 0.0;
		wPerpEl = wPerpMu;
		wRecEl  = wRecMu;
		wUncEl  = wUncMu;
  }

  double kPerp = 1.;
  double kRecoil_l = 1.;
  double kRecoil_t = 1.;
  double kSigmaPt_l = 1.;
  double kSigmaPt_t = 1.;

  if( flav==1 ) {        // mm
    kPerp = wPerpMu;
    kRecoil_l = kRecoil_t = wRecMu;
    kSigmaPt_l = kSigmaPt_t = wUncMu;
  }
  else if( flav==2 ) {  // ee
    kPerp = wPerpEl;
    kRecoil_l = kRecoil_t = wRecEl;
    kSigmaPt_l = kSigmaPt_t = wUncEl;
  }
  else {}

  double pt1 = sqrt(lpx1*lpx1 + lpy1*lpy1);
  double pt2 = sqrt(lpx2*lpx2 + lpy2*lpy2);

  TVector2 lead, subl;
  double leadpt, sublpt, leadpterr, sublpterr;
  if(pt1>pt2) {
    lead = TVector2(lpx1, lpy1);
    subl = TVector2(lpx2, lpy2);
    leadpt = pt1;
    leadpterr = lpterr1;
    sublpt = pt2;
    sublpterr = lpterr2;
  }
  else {
    lead = TVector2(lpx2, lpy2);
    subl = TVector2(lpx1, lpy1);
    leadpt = pt2;
    leadpterr = lpterr2;
    sublpt = pt1;
    sublpterr = lpterr1;
  }

  // Define the thrust and dilepton
  TVector2 dil = lead+subl;
  TVector2 thr = lead-subl;
  TVector2 longi;
  TVector2 perpe;
  double deltaPhi = fabs(lead.DeltaPhi(subl));

  if( deltaPhi>(3.141592654/2.) ) {
    longi = thr.Unit();
    perpe = longi.Rotate(3.141592654/2.);
    if(perpe*lead<0) perpe *= -1;
  }
  else {
    perpe = dil.Unit();
//.........这里部分代码省略.........
开发者ID:beknapp,项目名称:usercode,代码行数:101,代码来源:plotting_functions.C

示例2: SetA

void PMCSZCand::SetA(PMCSEMObj &elec1, PMCSEMObj &elec2) {

  // First we need to calculate the thrust axis
  //
  TVector2 e1(elec1.ppx(),elec1.ppy());
  TVector2 e2(elec2.ppx(),elec2.ppy());

  // Calculate the two phi angles
  double phi1=e1.Phi();
  double phi2=e2.Phi();

  // Order in phi
  if (phi1<phi2) {
    TVector2 dummy=e1;
    e1=e2;
    e2=dummy;
    double dummy2=phi1;
    phi1=phi2;
    phi2=dummy2;
  }

  // Calculate lengths as well
  double len1=e1.Mod();
  double len2=e2.Mod();

  // Good old Newton
  //
  // initial guess
  TVector2 bisector=(e1.Unit()+e2.Unit()).Unit();
  double alpha=bisector.Phi()-TMath::Pi()/2.;
  double alphaBackup=alpha;
  int nIt=0;
  // iterate
  double oldAlpha=9999.;
  while (fabs(alpha-oldAlpha)>0.000001) {
    oldAlpha=alpha;
    double f=len2*sin(phi2-oldAlpha)+len1*sin(oldAlpha-phi1);
    double fp=-len2*cos(phi2-oldAlpha)+len1*cos(oldAlpha-phi1);
    alpha=oldAlpha-f/fp;
    nIt++;
    if (nIt>1000) {
      cout<<"Newton did not converge in search for thrust axis"<<endl;
      alpha=alphaBackup;
      break;
    }
  }

  // Build unit vector
  TVector2 r;
  r.SetMagPhi(1.,alpha);
  TVector2 rPerp=r.Rotate(TMath::Pi()/2.);

  // Checks
  if (fabs(e1*rPerp-e2*rPerp)>0.001) {
    cout<<"Looks like Newton was imprecise in calculation of thrust axis: "<<e1*rPerp<<" "<<e2*rPerp<<endl;
  }

  // now we can do the projections
  TVector2 Z=e1+e2;
  _pat=Z*rPerp;
  _pal=Z*r;
}
开发者ID:hengne,项目名称:d0wmass,代码行数:62,代码来源:PMCSZCand.cpp


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