diff --git a/NPLib/InitialConditions/TInitialConditions.cxx b/NPLib/InitialConditions/TInitialConditions.cxx index bed1dd313efc807fd58384d2e276ab903284e2a8..e76622b63d814b5b222b18969e06f52342a0b207 100644 --- a/NPLib/InitialConditions/TInitialConditions.cxx +++ b/NPLib/InitialConditions/TInitialConditions.cxx @@ -9,7 +9,7 @@ * Original Author: N. de Sereville contact address: deserevi@ipno.in2p3.fr * * * * Creation Date : 10/06/09 * - * Last update : * + * Last update : 04/09/09 * *---------------------------------------------------------------------------* * Decription: This class records all the information concerning the event * * generators, e.g. vertex of interaction, angles of emitted * @@ -18,6 +18,7 @@ * stored in the output TTree of the G4 simulation * *---------------------------------------------------------------------------* * Comment: * + * + 04/09/09: Add private members for emittance (N. de Sereville) * * * * * *****************************************************************************/ @@ -46,6 +47,9 @@ void TInitialConditions::Clear() fIC_Position_X.clear(); fIC_Position_Y.clear(); fIC_Position_Z.clear(); + // Theta and Phi angles for the emittance + fIC_Incident_Emittance_Theta.clear(); + fIC_Incident_Emittance_Phi.clear(); // Incident particle angles fIC_Incident_Angle_Theta.clear(); fIC_Incident_Angle_Phi.clear(); @@ -72,6 +76,9 @@ void TInitialConditions::Dump() cout << "\tX : " << fIC_Position_X[0] << endl; cout << "\tY : " << fIC_Position_Y[0] << endl; cout << "\tZ : " << fIC_Position_Z[0] << endl; + cout << "Theta and Phi angles for the emittance : " << endl; + cout << "\tTheta : " << fIC_Incident_Emittance_Theta[0] << endl; + cout << "\tPhi : " << fIC_Incident_Emittance_Phi[0] << endl; cout << "Incident particle angles : " << endl; cout << "\tTheta : " << fIC_Incident_Angle_Theta[0] << endl; cout << "\tPhi : " << fIC_Incident_Angle_Phi[0] << endl; diff --git a/NPLib/InitialConditions/TInitialConditions.h b/NPLib/InitialConditions/TInitialConditions.h index 86db26ad31b7f5faaea8198d0e00481bb2e471bc..ab3a94278a5406358a7e493728c3aad251668f63 100644 --- a/NPLib/InitialConditions/TInitialConditions.h +++ b/NPLib/InitialConditions/TInitialConditions.h @@ -9,7 +9,7 @@ * Original Author: N. de Sereville contact address: deserevi@ipno.in2p3.fr * * * * Creation Date : 10/06/09 * - * Last update : * + * Last update : 04/09/09 * *---------------------------------------------------------------------------* * Decription: This class records all the information concerning the event * * generators, e.g. vertex of interaction, angles of emitted * @@ -18,6 +18,7 @@ * stored in the output TTree of the G4 simulation * *---------------------------------------------------------------------------* * Comment: * + * + 04/09/09: Add private members for emittance (N. de Sereville) * * * * * *****************************************************************************/ @@ -39,6 +40,9 @@ private: vector<Double_t> fIC_Position_X; vector<Double_t> fIC_Position_Y; vector<Double_t> fIC_Position_Z; + // Theta and Phi angles for the emittance + vector<Double_t> fIC_Incident_Emittance_Theta; + vector<Double_t> fIC_Incident_Emittance_Phi; // Incident particle angles vector<Double_t> fIC_Incident_Angle_Theta; vector<Double_t> fIC_Incident_Angle_Phi; @@ -70,6 +74,9 @@ public: void SetICPositionX(Double_t PositionX) {fIC_Position_X.push_back(PositionX);} void SetICPositionY(Double_t PositionY) {fIC_Position_Y.push_back(PositionY);} void SetICPositionZ(Double_t PositionZ) {fIC_Position_Z.push_back(PositionZ);} + // Theta and Phi angles for the emittance + void SetICIncidentEmittanceTheta(Double_t Theta) {fIC_Incident_Emittance_Theta.push_back(Theta);} + void SetICIncidentEmittancePhi(Double_t Phi) {fIC_Incident_Emittance_Phi.push_back(Phi);} // Incident particle angles void SetICIncidentAngleTheta(Double_t AngleTheta) {fIC_Incident_Angle_Theta.push_back(AngleTheta);} void SetICIncidentAnglePhi(Double_t AnglePhi) {fIC_Incident_Angle_Phi.push_back(AnglePhi);} @@ -94,9 +101,12 @@ public: // Vertex of interaction Double_t GetICPositionX(Int_t i) {return fIC_Position_X.at(i);} Double_t GetICPositionY(Int_t i) {return fIC_Position_Y.at(i);} - Double_t GetICPositionZ(Int_t i) {return fIC_Position_Z.at(i);} + Double_t GetICPositionZ(Int_t i) {return fIC_Position_Z.at(i);} + // Theta and Phi angles for the emittance + Double_t GetICIncidentEmittanceTheta(Int_t i) {return fIC_Incident_Emittance_Theta.at(i);} + Double_t GetICIncidentEmittancePhi(Int_t i) {return fIC_Incident_Emittance_Phi.at(i);} // Incident particle angles - Double_t GetICIncidentAngleTheta(Int_t i){return fIC_Incident_Angle_Theta.at(i);} + Double_t GetICIncidentAngleTheta(Int_t i) {return fIC_Incident_Angle_Theta.at(i);} Double_t GetICIncidentAnglePhi(Int_t i) {return fIC_Incident_Angle_Phi.at(i);} // Incident particle energy Double_t GetICIncidentEnergy(Int_t i) {return fIC_Incident_Energy.at(i);} diff --git a/NPSimulation/src/EventGeneratorTransfert.cc b/NPSimulation/src/EventGeneratorTransfert.cc index 85b6a3fe84a204d0cae5a699a65c2596aeb1ff35..7d8b4a38b61db53d472fc3ea4f8df1c96a701d84 100644 --- a/NPSimulation/src/EventGeneratorTransfert.cc +++ b/NPSimulation/src/EventGeneratorTransfert.cc @@ -316,28 +316,27 @@ void EventGeneratorTransfert::GenerateEvent(G4Event* anEvent , G4ParticleGun* pa //shoot inside the target with correlated angle if (m_TargetRadius != 0) { - while (sqrt(x0*x0 + y0*y0) > m_TargetRadius) - { - RandomGaussian2D(0,0,m_BeamFWHMX / 2.35,m_BeamEmmitanceTheta,x0,Beam_thetaX); - RandomGaussian2D(0,0,m_BeamFWHMY / 2.35,m_BeamEmmitancePhi ,y0,Beam_phiY ); - } + while (sqrt(x0*x0 + y0*y0) > m_TargetRadius) { + RandomGaussian2D(0,0,m_BeamFWHMX / 2.35,m_BeamEmmitanceTheta,x0,Beam_thetaX); + RandomGaussian2D(0,0,m_BeamFWHMY / 2.35,m_BeamEmmitancePhi ,y0,Beam_phiY ); + } } - - else - { - RandomGaussian2D(0,0,0,m_BeamEmmitanceTheta,x0,Beam_thetaX); - RandomGaussian2D(0,0,0,m_BeamEmmitancePhi ,y0,Beam_phiY ); + else { + RandomGaussian2D(0,0,0,m_BeamEmmitanceTheta,x0,Beam_thetaX); + RandomGaussian2D(0,0,0,m_BeamEmmitancePhi ,y0,Beam_phiY ); } - // Calculate Angle in spherical coordinate, passing by the direction vector dir - G4double Xdir = cos( pi/2. - Beam_thetaX ) ; - G4double Ydir = cos( pi/2. - Beam_phiY ) ; - G4double Zdir = sin( pi/2. - Beam_thetaX ) + sin( pi/2. - Beam_phiY) ; - - - G4double Beam_theta = acos ( Zdir / sqrt( Xdir*Xdir + Ydir*Ydir + Zdir*Zdir ) ); + // write emittance angles to ROOT file + m_InitConditions->SetICIncidentEmittanceTheta(Beam_thetaX / deg); + m_InitConditions->SetICIncidentEmittancePhi(Beam_phiY / deg); + + // Calculate Angle in spherical coordinate, passing by the direction vector dir + G4double Xdir = cos( pi/2. - Beam_thetaX ); + G4double Ydir = cos( pi/2. - Beam_phiY ); + G4double Zdir = sin( pi/2. - Beam_thetaX ) + sin( pi/2. - Beam_phiY); - G4double Beam_phi = atan2( Ydir , Xdir ) ; + G4double Beam_theta = acos ( Zdir / sqrt( Xdir*Xdir + Ydir*Ydir + Zdir*Zdir ) ); + G4double Beam_phi = atan2( Ydir , Xdir ) ; // write angles to ROOT file m_InitConditions->SetICIncidentAngleTheta(Beam_theta / deg);