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()); }
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); } }
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; }
void fill(int const kf, TLorentzVector* b, double weight, TLorentzVector const& p1Mom, TLorentzVector const& p2Mom, TVector3 v00) { int const centrality = floor(nCent * gRandom->Rndm()); TVector3 const vertex = getVertex(centrality); // smear primary vertex // float const sigmaVertex = sigmaVertexCent[cent]; // TVector3 const vertex(gRandom->Gaus(0, sigmaVertex), gRandom->Gaus(0, sigmaVertex), gRandom->Gaus(0, sigmaVertex)); v00 += vertex; // smear momentum TLorentzVector const p1RMom = smearMom(0, p1Mom); TLorentzVector const p2RMom = smearMom(0, p2Mom); // smear position TVector3 const p1RPos = smearPosData(0, vertex.z(), centrality, p1RMom, v00); TVector3 const p2RPos = smearPosData(0, vertex.z(), centrality, p2RMom, v00); // TVector3 const kRPos = smearPos(kMom, kRMom, v00); // TVector3 const pRPos = smearPos(pMom, pRMom, v00); // reconstruct TLorentzVector const rMom = p1RMom + p2RMom; float const p1Dca = dca(p1Mom.Vect(), v00, vertex); float const p2Dca = dca(p2Mom.Vect(), v00, vertex); float const p1RDca = dca(p1RMom.Vect(), p1RPos, vertex); float const p2RDca = dca(p2RMom.Vect(), p2RPos, vertex); TVector3 v0; float const dca12 = dca1To2(p1RMom.Vect(), p1RPos, p2RMom.Vect(), p2RPos, v0); float const decayLength = (v0 - vertex).Mag(); float const dcaD0ToPv = dca(rMom.Vect(), v0, vertex); float const cosTheta = (v0 - vertex).Unit().Dot(rMom.Vect().Unit()); float const angle12 = p1RMom.Vect().Angle(p2RMom.Vect()); TLorentzVector p1RMomRest = p1RMom; TVector3 beta; beta.SetMagThetaPhi(rMom.Beta(), rMom.Theta(), rMom.Phi()); p1RMomRest.Boost(-beta); float const cosThetaStar = rMom.Vect().Unit().Dot(p1RMomRest.Vect().Unit()); // save float arr[100]; int iArr = 0; arr[iArr++] = centrality; arr[iArr++] = vertex.X(); arr[iArr++] = vertex.Y(); arr[iArr++] = vertex.Z(); arr[iArr++] = kf; arr[iArr++] = b->M(); arr[iArr++] = b->Perp(); arr[iArr++] = b->PseudoRapidity(); arr[iArr++] = b->Rapidity(); arr[iArr++] = b->Phi(); arr[iArr++] = v00.X(); arr[iArr++] = v00.Y(); arr[iArr++] = v00.Z(); arr[iArr++] = rMom.M(); arr[iArr++] = rMom.Perp(); arr[iArr++] = rMom.PseudoRapidity(); arr[iArr++] = rMom.Rapidity(); arr[iArr++] = rMom.Phi(); arr[iArr++] = v0.X(); arr[iArr++] = v0.Y(); arr[iArr++] = v0.Z(); arr[iArr++] = dca12; arr[iArr++] = decayLength; arr[iArr++] = dcaD0ToPv; arr[iArr++] = cosTheta; arr[iArr++] = angle12; arr[iArr++] = cosThetaStar; arr[iArr++] = p1Mom.M(); arr[iArr++] = p1Mom.Perp(); arr[iArr++] = p1Mom.PseudoRapidity(); arr[iArr++] = p1Mom.Rapidity(); arr[iArr++] = p1Mom.Phi(); arr[iArr++] = p1Dca; arr[iArr++] = p1RMom.M(); arr[iArr++] = p1RMom.Perp(); arr[iArr++] = p1RMom.PseudoRapidity(); arr[iArr++] = p1RMom.Rapidity(); arr[iArr++] = p1RMom.Phi(); arr[iArr++] = p1RPos.X(); arr[iArr++] = p1RPos.Y(); arr[iArr++] = p1RPos.Z(); arr[iArr++] = p1RDca; arr[iArr++] = tpcReconstructed(0,1,centrality,p1RMom); arr[iArr++] = p2Mom.M(); arr[iArr++] = p2Mom.Perp(); arr[iArr++] = p2Mom.PseudoRapidity(); arr[iArr++] = p2Mom.Rapidity(); arr[iArr++] = p2Mom.Phi(); arr[iArr++] = p2Dca; arr[iArr++] = p2RMom.M(); arr[iArr++] = p2RMom.Perp(); arr[iArr++] = p2RMom.PseudoRapidity(); arr[iArr++] = p2RMom.Rapidity(); arr[iArr++] = p2RMom.Phi(); arr[iArr++] = p2RPos.X(); arr[iArr++] = p2RPos.Y(); arr[iArr++] = p2RPos.Z(); arr[iArr++] = p2RDca; arr[iArr++] = tpcReconstructed(0,-1,centrality,p2RMom); arr[iArr++] = matchHft(1, vertex.z(), centrality, p1RMom); arr[iArr++] = matchHft(0, vertex.z(), centrality, p2RMom); nt->Fill(arr); }
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(); } }
void KVElasticCountRates::CalculateScattering(Int_t N) { //Perform scattering 'N' times for current values //of particle Z, A and energy, target excited state, and detector. //Print out for each hit detector the mean energy loss & counting rate //for a beam intensity of 10**7 pps fNtirages = N; fHistos.Delete(); fRates.clear(); if (!fProj) { cout << "<KVElasticCountRates::CalculateScattering> : Set projectile properties first" << endl; return; } if (!fEnergy) { cout << "<KVElasticCountRates::CalculateScattering> : Set projectile energy first" << endl; return; } if (!fTarget) { cout << "<KVElasticCountRates::CalculateScattering> : No target set. Set run first." << endl; return; } /* -------------------------------------------------------------------------------------------------------------------------- */ //set up histograms /* -------------------------------------------------------------------------------------------------------------------------- */ // -- histograms for debugging: depth in target and angular distribution if (fDepth) delete fDepth; if (fTheta) delete fTheta; fDepth = new TH1F("hDepth", "Depth (mg/cm2)", 500, 0., fTarget->GetTotalEffectiveThickness()); fTheta = new TH1F("hTheta", "Theta (deg.)", 500, 0., 0.); /* -------------------------------------------------------------------------------------------------------------------------- */ //set up kinematics if (!fKinematics) fKinematics = new KV2Body; fProj->SetEnergy(fEnergy); fProj->SetTheta(0); /* -------------------------------------------------------------------------------------------------------------------------- */ //set random interaction point for scattering if (fIntLayer) { fTarget->SetInteractionLayer(fIntLayer, fBeamDirection); } else { fTarget->GetInteractionPoint(fProj); } /* -------------------------------------------------------------------------------------------------------------------------- */ //get target nucleus properties from scattering layer TVector3 IP = fTarget->GetInteractionPoint(); KVMaterial* targ_mat = fTarget->GetLayer(IP); if (!fTarg) fTarg = new KVNucleus; fTarg->SetZ((Int_t) targ_mat->GetZ()); fTarg->SetA((Int_t) targ_mat->GetMass()); fKinematics->SetTarget(fTarg); /* -------------------------------------------------------------------------------------------------------------------------- */ //set excited state of target nucleus - in other words, dissipated energy for //reaction due to excitation of target fKinematics->SetEDiss(fExx); /* -------------------------------------------------------------------------------------------------------------------------- */ for (int i = 0; i < N; i++) { //calculate slowing of incoming projectile fTarget->SetIncoming(); fTarget->DetectParticle(fProj); fKinematics->SetProjectile(fProj); fKinematics->SetOutgoing(fProj); fKinematics->CalculateKinematics(); //set random direction of outgoing projectile fAngularRange.GetRandomAngles(theta, phi, "random"); xsec = TMath::Abs(fKinematics->GetXSecRuthLab(theta)); //set energy of scattered nucleus //WARNING: for inverse kinematics reactions, their are two energies for //each angle below the maximum scattering angle. //We only use the highest energy corresponding to the most forward CM angle. Double_t e1, e2; fKinematics->GetELab(3, theta, 3, e1, e2); fProj->SetEnergy(TMath::Max(e1, e2)); fProj->SetTheta(theta); fProj->SetPhi(phi); fTheta->Fill(theta, xsec); //slowing of outgoing projectile in target fTarget->SetOutgoing(); fTarget->DetectParticle(fProj); //now detect particle in array KVNameValueList* detectors = gMultiDetArray->DetectParticle(fProj); //fill histograms fDepth->Fill(IP.z()); FillHistograms(detectors); fProj->GetParameters()->Clear(); fProj->SetEnergy(fEnergy); fProj->SetTheta(0); //set random interaction point for scattering if (fIntLayer) { fTarget->SetInteractionLayer(fIntLayer, fBeamDirection); } else { fTarget->GetInteractionPoint(fProj); //if target is multilayer and the interaction layer is not fixed, //the layer & hence the target nucleus may change if (fMultiLayer) { targ_mat = fTarget->GetLayer(fTarget->GetInteractionPoint()); fTarg->SetZ((Int_t) targ_mat->GetZ()); fTarg->SetA((Int_t) targ_mat->GetMass()); fKinematics->SetTarget(fTarg); fKinematics->SetOutgoing(fProj); } } IP = fTarget->GetInteractionPoint(); } PrintResults(); }
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; }