Example #1
0
void Mpdshape::SetPosition(TVector3 vec) {
  ostringstream o;
  o.precision(6);
  o.setf(ios::showpoint); 
  o.setf(ios::fixed);
  o << vec.x() << " " << vec.y() << " " << vec.z();
  fPosition.append(o.str().c_str());
}
Example #2
0
 void tv3Read2() {
   //second read example illustrating how to read one branch only
   TVector3 *v = 0;
   TFile *f = new TFile("v3.root");
   TTree *T = (TTree*)f->Get("T");
   T->SetBranchAddress("v3",&v);
   TBranch *by = T->GetBranch("fY");
   TH1F *h2 = new TH1F("y","y component of TVector3",100,-5,20);
   Int_t nentries = Int_t(T->GetEntries());
   for (Int_t i=0;i<nentries;i++) {
      by->GetEntry(i);
      h2->Fill(v->y());
   }
   h2->Draw();
}
Example #3
0
	  void qaP3(TString pre, TVector3 v, RhoTuple *n, bool skip=false){

		  if (n==0) return;

		  if(!skip){
			  n->Column(pre+"decayvx", (Float_t) v.x(), 0.0f);
			  n->Column(pre+"decayvy", (Float_t) v.y(), 0.0f);
			  n->Column(pre+"decayvz", (Float_t) v.z(), 0.0f);
		  }
		  else{
			  n->Column(pre+"decayvx", (Float_t) -999, 0.0f);
			  n->Column(pre+"decayvy", (Float_t) -999, 0.0f);
			  n->Column(pre+"decayvz", (Float_t) -999, 0.0f);
		  }

	  }
Example #4
0
double distance2(double px,double py,double pz, double *p) {
   TVector3 xp(px,py,pz);
   TVector3 x0(p[0], p[1], p[2]);
   TVector3 u (TMath::Sin(p[3])*TMath::Cos(p[4]), TMath::Sin(p[3])*TMath::Sin(p[4]), TMath::Cos(p[3]));

   double coeff = u*(xp-x0);
   TVector3 n = xp - x0 - coeff * u;

   double dx = n.x();
   double dy = n.y();
   double dz = n.z();
   double d2_x = TMath::Power(dx/weight[0], 2);
   double d2_y = TMath::Power(dy/weight[1], 2);
   double d2_z = TMath::Power(dz/weight[2], 2);
   double d2 = d2_x + d2_y + d2_z;

   return d2;
}
Example #5
0
void KVGeoNavigator::PropagateParticle(KVNucleus* part, TVector3* TheOrigin)
{
   // Propagate a particle through the geometry in the direction of its momentum,
   // until we reach the boundary of the geometry, or until fStopPropagation is set to kFALSE.
   // Propagation will also stop if we encounter a volume whose name begins with "DEADZONE"

   // Define point of origin of particles
   if (TheOrigin) fGeometry->SetCurrentPoint(TheOrigin->X(), TheOrigin->Y(), TheOrigin->Z());
   else fGeometry->SetCurrentPoint(0., 0., 0.);

   // unit vector in direction of particle's momentum
   TVector3 v = part->GetMomentum().Unit();
   // use particle's momentum direction
   fGeometry->SetCurrentDirection(v.x(), v.y(), v.z());
   fGeometry->FindNode();

   fCurrentVolume = fGeometry->GetCurrentVolume();
   fCurrentNode = fGeometry->GetCurrentNode();
   fMotherNode = fGeometry->GetMother();
   fCurrentMatrix = *(fGeometry->GetCurrentMatrix());
   fCurrentPath = fGeometry->GetPath();
   // move along trajectory until we hit a new volume
   fGeometry->FindNextBoundaryAndStep();
   fStepSize = fGeometry->GetStep();
   TGeoVolume* newVol = fGeometry->GetCurrentVolume();
   TGeoNode* newNod = fGeometry->GetCurrentNode();
   TGeoNode* newMom = fGeometry->GetMother();
   TGeoHMatrix* newMatx = fGeometry->GetCurrentMatrix();
   TString newPath = fGeometry->GetPath();

   Double_t XX, YY, ZZ;
   XX = YY = ZZ = 0.;

   // reset user flag for stopping propagation of particle
   SetStopPropagation(kFALSE);

//    Info("PropagateParticle","Beginning: i am in %s on node %s with path %s, and matrix:",
//         fCurrentVolume->GetName(),fCurrentNode->GetName(),fCurrentPath.Data());
//    fCurrentMatrix.Print();

   // track particle until we leave the geometry or until fStopPropagation
   // becomes kTRUE
   while (!fGeometry->IsOutside()) {

      const Double_t* posi = fGeometry->GetCurrentPoint();
      fEntryPoint.SetXYZ(XX, YY, ZZ);
      XX = posi[0];
      YY = posi[1];
      ZZ = posi[2];
      fExitPoint.SetXYZ(XX, YY, ZZ);

      TString vn = GetCurrentVolume()->GetName();
      if (vn.BeginsWith("DEADZONE")) {
         part->GetParameters()->SetValue("DEADZONE", Form("%s/%s", GetCurrentVolume()->GetName(), GetCurrentNode()->GetName()));
         break;
      }

//        Info("PropagateParticle","just before ParticleEntersNewVolume\nnow i am in %s on node %s with path %s and matrix:",
//             fCurrentVolume->GetName(),fCurrentNode->GetName(),fCurrentPath.Data());
//        fCurrentMatrix.Print();

      ParticleEntersNewVolume(part);

      if (StopPropagation()) break;

      fCurrentVolume = newVol;
      fCurrentNode = newNod;
      fMotherNode = newMom;
      fCurrentMatrix = *newMatx;
      fCurrentPath = newPath;

//        Info("PropagateParticle","after ParticleEntersNewVolume\nnow i am in %s on node %s with path %s and matrix:",
//             fCurrentVolume->GetName(),fCurrentNode->GetName(),fCurrentPath.Data());
//        fCurrentMatrix.Print();

      // move on to next volume crossed by trajectory
      fGeometry->FindNextBoundaryAndStep();
      fStepSize = fGeometry->GetStep();
      newVol = fGeometry->GetCurrentVolume();
      newNod = fGeometry->GetCurrentNode();
      newMom = fGeometry->GetMother();
      newMatx = fGeometry->GetCurrentMatrix();
      newPath = fGeometry->GetPath();
   }
}
Example #6
0
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;

}