From 57793428f5cf3438670d9d8d4434265654b0dd1a Mon Sep 17 00:00:00 2001 From: shuyaota <shuyan_timeslip@hotmail.com> Date: Wed, 16 May 2018 17:40:34 -0500 Subject: [PATCH] Fixing the Phi defined in different coordinates between Analysis and Simulation. --- NPSimulation/Detectors/Tiara/Tiara.cc | 32 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/NPSimulation/Detectors/Tiara/Tiara.cc b/NPSimulation/Detectors/Tiara/Tiara.cc index dad2aa797..70ac121b5 100644 --- a/NPSimulation/Detectors/Tiara/Tiara.cc +++ b/NPSimulation/Detectors/Tiara/Tiara.cc @@ -116,7 +116,9 @@ void Tiara::ReadConfiguration(NPL::InputParser parser){ } blocks.clear(); +//by Shuya 180426 blocks = parser.GetAllBlocksWithToken("TiaraHyballWedge"); + //blocks = parser.GetAllBlocksWithToken("HyballWedge"); if(NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; @@ -177,21 +179,27 @@ void Tiara::ReadSensitive(const G4Event* event){ G4double* Info = *(InnerBarrel_itr->second); // Downstream Energy - double ED = RandGauss::shoot(Info[0],ResoEnergyInnerBarrel); + //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + //double ED = RandGauss::shoot(Info[0],ResoEnergyInnerBarrel); + double ED = RandGauss::shoot(Info[0]/keV,ResoEnergyInnerBarrel); if(ED>EnergyThreshold){ m_EventBarrel->SetFrontDownstreamE(Info[3],Info[4],ED); m_EventBarrel->SetFrontDownstreamT(Info[3],Info[4],Info[2]); } // Upstream Energy - double EU = RandGauss::shoot(Info[1],ResoEnergyInnerBarrel); + //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + //double EU = RandGauss::shoot(Info[1],ResoEnergyInnerBarrel); + double EU = RandGauss::shoot(Info[1]/keV,ResoEnergyInnerBarrel); if(EU>EnergyThreshold){ m_EventBarrel->SetFrontUpstreamE(Info[3],Info[4],EU); m_EventBarrel->SetFrontUpstreamT(Info[3],Info[4],Info[2]); } // Back Energy - double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyInnerBarrel); + //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + //double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyInnerBarrel); + double EB = RandGauss::shoot(Info[1]/keV+Info[0]*keV,ResoEnergyInnerBarrel); if(EB>EnergyThreshold){ m_EventBarrel->SetBackE(Info[3],EB); m_EventBarrel->SetBackT(Info[3],Info[2]); @@ -216,7 +224,7 @@ void Tiara::ReadSensitive(const G4Event* event){ for (OuterBarrel_itr = OuterBarrelHitMap->GetMap()->begin() ; OuterBarrel_itr != OuterBarrelHitMap->GetMap()->end() ; OuterBarrel_itr++){ G4double* Info = *(OuterBarrel_itr->second); - double E = RandGauss::shoot(Info[0],ResoEnergyOuterBarrel); + double E = RandGauss::shoot(Info[0]/keV,ResoEnergyOuterBarrel); if(E>EnergyThreshold){ m_EventBarrel->SetOuterE(Info[7],Info[9],E); m_EventBarrel->SetOuterT(Info[7],Info[9],Info[1]); @@ -263,12 +271,21 @@ void Tiara::ReadSensitive(const G4Event* event){ double m_axis = -100.0; double m_phi = Info[6]; if(Info[6]<0) m_phi = Info[6]+2.0*M_PI; + //by Shuya 180516. Now the latter ones are the right angle. The angles are seen from (0,0,1) vector, so you if you set 210 deg in your .Detector file (which is seen from (0,0,-1) axis), the angle is 330 deg in (0,0,1) axis. + /* if(Info[7]==1) m_axis = 210.0/180.0*M_PI; else if(Info[7]==2) m_axis = 150.0/180.0*M_PI; else if(Info[7]==3) m_axis = 90.0/180.0*M_PI; else if(Info[7]==4) m_axis = 30.0/180.0*M_PI; else if(Info[7]==5) m_axis = 330.0/180.0*M_PI; else if(Info[7]==6) m_axis = 270.0/180.0*M_PI; + */ + if(Info[7]==1) m_axis = 330.0/180.0*M_PI; + else if(Info[7]==2) m_axis = 30.0/180.0*M_PI; + else if(Info[7]==3) m_axis = 90.0/180.0*M_PI; + else if(Info[7]==4) m_axis = 150.0/180.0*M_PI; + else if(Info[7]==5) m_axis = 210.0/180.0*M_PI; + else if(Info[7]==6) m_axis = 270.0/180.0*M_PI; double m_StripPitchSector_Tiara = (0.5*HYBALL_ActiveWafer_Angle-(-0.5*HYBALL_ActiveWafer_Angle))/HYBALL_NumberOfRadialStrip; Info[9] = (int)((m_phi - (m_axis - 0.5*HYBALL_ActiveWafer_Angle)) / m_StripPitchSector_Tiara ) + 1 ; //by Shuya 171009 @@ -787,7 +804,12 @@ void Tiara::ConstructHyball(G4LogicalVolume* world){ for(unsigned int i = 0 ; i < m_HyballZ.size() ; i++){ // Place mother volume - new G4PVPlacement(new G4RotationMatrix(0,0,m_HyballPhi[i]), + //by Shuya 180516. In the following G4RotationMatrix (or Geant4 in general), the rotation phi is defined by (0,0,1) axis (not (0,0,-1) axis which is seeing from beam downstream to upstream). I.e., if you place a detector at 210 deg in your .Detector file, the x-y position of the detector must be (>0,<0). Remember, however, the 210 degree you set is the angle from (0,0,-1) axis in your analysis (<0,<0). I.e., if you want to set these detectors at the same angle, you have to conver one to the other angle. + double m_HyballPhiConversion = m_HyballPhi[i]; + if(m_HyballPhi[i]>=0.0 && m_HyballPhi[i]<M_PI) m_HyballPhiConversion = M_PI - m_HyballPhi[i]; //ex., 0deg -> 180deg, 30deg -> 150deg, 90deg -> 90deg, 150deg -> 30 deg. + else if(m_HyballPhi[i]>=M_PI && m_HyballPhi[i]<(2.0*M_PI)) m_HyballPhiConversion = 2.0*M_PI + (M_PI - m_HyballPhi[i]); //ex., 180deg -> 360 deg, 210deg -> 330 deg, 270 deg -> 270 deg, 330 deg -> 210 deg. + //new G4PVPlacement(new G4RotationMatrix(0,0,m_HyballPhi[i]), + new G4PVPlacement(new G4RotationMatrix(0,0,m_HyballPhiConversion), G4ThreeVector(0,0,m_HyballZ[i]), logicHyball,"Hyball", world,false,i+1); -- GitLab