diff --git a/NPLib/Detectors/Samurai/CMakeLists.txt b/NPLib/Detectors/Samurai/CMakeLists.txt index 3e92858c1d53c81ea9a701c2dae50e20c2a0c19b..133a628f411f5e623f030f12d41d12a8767eec15 100644 --- a/NPLib/Detectors/Samurai/CMakeLists.txt +++ b/NPLib/Detectors/Samurai/CMakeLists.txt @@ -6,7 +6,6 @@ add_custom_command(OUTPUT TSamuraiHodoscopePhysicsDict.cxx COMMAND ${CMAKE_BINAR add_custom_command(OUTPUT TSamuraiMagnetPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSamuraiMagnetPhysics.h TSamuraiMagnetPhysicsDict.cxx TSamuraiMagnetPhysics.rootmap libNPSamurai.dylib DEPENDS TSamuraiMagnetPhysics.h) - add_custom_command(OUTPUT TSamuraiBDCDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSamuraiBDCData.h TSamuraiBDCDataDict.cxx TSamuraiBDCData.rootmap libNPSamurai.dylib DEPENDS TSamuraiBDCData.h) add_custom_command(OUTPUT TSamuraiBDCPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSamuraiBDCPhysics.h TSamuraiBDCPhysicsDict.cxx TSamuraiBDCPhysics.rootmap libNPSamurai.dylib DEPENDS TSamuraiBDCPhysics.h) @@ -19,7 +18,9 @@ add_custom_command(OUTPUT TSamuraiFDC0DataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/s add_custom_command(OUTPUT TSamuraiFDC0PhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSamuraiFDC0Physics.h TSamuraiFDC0PhysicsDict.cxx TSamuraiFDC0Physics.rootmap libNPSamurai.dylib DEPENDS TSamuraiFDC0Physics.h) -add_library(NPSamurai SHARED TSamuraiMagnetPhysicsDict.cxx TSamuraiMagnetPhysics.cxx SamuraiFieldMapDict.cxx SamuraiFieldMap.cxx TSamuraiHodoscopeData.cxx TSamuraiBDCData.cxx TSamuraiBDCPhysics.cxx TSamuraiBDCDataDict.cxx TSamuraiBDCPhysicsDict.cxx TSamuraiFDC2Data.cxx TSamuraiFDC2DataDict.cxx TSamuraiHodoscopePhysics.cxx TSamuraiHodoscopePhysicsDict.cxx TSamuraiFDC2Physics.cxx TSamuraiHodoscopeDataDict.cxx TSamuraiFDC2PhysicsDict.cxx TSamuraiFDC0Data.cxx TSamuraiFDC0DataDict.cxx TSamuraiFDC0Physics.cxx TSamuraiFDC0PhysicsDict.cxx TSamuraiIdealData.cxx) +add_custom_command(OUTPUT TSamuraiIdealDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSamuraiIdealData.h TSamuraiIdealDataDict.cxx TSamuraiIdealData.rootmap libNPSamurai.dylib DEPENDS TSamuraiIdealData.h) + +add_library(NPSamurai SHARED TSamuraiMagnetPhysicsDict.cxx TSamuraiMagnetPhysics.cxx SamuraiFieldMapDict.cxx SamuraiFieldMap.cxx TSamuraiHodoscopeData.cxx TSamuraiBDCData.cxx TSamuraiBDCPhysics.cxx TSamuraiBDCDataDict.cxx TSamuraiBDCPhysicsDict.cxx TSamuraiFDC2Data.cxx TSamuraiFDC2DataDict.cxx TSamuraiHodoscopePhysics.cxx TSamuraiHodoscopePhysicsDict.cxx TSamuraiFDC2Physics.cxx TSamuraiHodoscopeDataDict.cxx TSamuraiFDC2PhysicsDict.cxx TSamuraiFDC0Data.cxx TSamuraiFDC0DataDict.cxx TSamuraiFDC0Physics.cxx TSamuraiFDC0PhysicsDict.cxx TSamuraiIdealData.cxx TSamuraiIdealDataDict.cxx) target_link_libraries(NPSamurai ${ROOT_LIBRARIES} NPCore NPTrackReconstruction NPPhysics) install(FILES TSamuraiMagnetPhysics.h SamuraiFieldMap.h TSamuraiBDCData.h TSamuraiBDCPhysics.h TSamuraiHodoscopeData.h TSamuraiHodoscopePhysics.h TSamuraiFDC2Data.h TSamuraiFDC2Physics.h TSamuraiFDC0Data.h TSamuraiFDC0Physics.h SamuraiDCIndex.h TSamuraiIdealData.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Samurai/TSamuraiIdealData.cxx b/NPLib/Detectors/Samurai/TSamuraiIdealData.cxx index 3cb4f89c5264ee8b442832f46cde4e1c7bca8e31..19311cff8bcab30808692923ed740656eb0fcc6b 100644 --- a/NPLib/Detectors/Samurai/TSamuraiIdealData.cxx +++ b/NPLib/Detectors/Samurai/TSamuraiIdealData.cxx @@ -40,14 +40,13 @@ void TSamuraiIdealData::Clear() { Detector_Number.clear(); Dep_Energy.clear(); - /* Brho.clear(); Pos_X.clear(); Pos_Y.clear(); Pos_Z.clear(); Mom_Mag.clear(); Mom_Theta.clear(); - Mom_Phi.clear();*/ + Mom_Phi.clear(); return; } @@ -65,9 +64,9 @@ void TSamuraiIdealData::Dump() const } } -/* + void TSamuraiIdealData::SetData (short detector, double energy, double pos_x, double pos_y, - double pos_z, double mom_r, double mom_theta, double mom_phi){ + double pos_z, double mom_r, double mom_theta, double mom_phi, double brho){ Detector_Number.push_back(detector); Dep_Energy.push_back(energy); Pos_X.push_back(pos_x); @@ -78,4 +77,3 @@ void TSamuraiIdealData::SetData (short detector, double energy, double pos_x, do Mom_Phi.push_back(mom_phi); Brho.push_back(brho); } -*/ \ No newline at end of file diff --git a/NPLib/Detectors/Samurai/TSamuraiIdealData.h b/NPLib/Detectors/Samurai/TSamuraiIdealData.h index cf16b2bf6148fbaf2a745cabeab9f7348181eb39..f35a6e57dc001c14d4056744ff504fd564bb6949 100644 --- a/NPLib/Detectors/Samurai/TSamuraiIdealData.h +++ b/NPLib/Detectors/Samurai/TSamuraiIdealData.h @@ -23,6 +23,7 @@ #include <vector> #include <string> + #include "TObject.h" using namespace std ; @@ -38,7 +39,6 @@ class TSamuraiIdealData : public TObject { 2 = FDC2 */ vector <double> Dep_Energy; //Energy deposited in the detector material - /* vector <double> Brho; //Position vector <double> Pos_X; // Exit position X-axis @@ -48,7 +48,7 @@ class TSamuraiIdealData : public TObject { vector <double> Mom_Mag; //Exit momentum magnitude vector <double> Mom_Theta; //Exit momentum Theta vector <double> Mom_Phi; //Exit momentum Phi - */ + public: TSamuraiIdealData(); @@ -62,7 +62,7 @@ class TSamuraiIdealData : public TObject { unsigned int GetMult() const {return Detector_Number.size();} short GetDetNumber(int i) const {return Detector_Number[i];} double GetDepEnergy(int i) const {return Dep_Energy[i];} - /*double GetBrho(int i) const {return Brho[i];} + double GetBrho(int i) const {return Brho[i];} //Position double GetPosX(int i) const {return Pos_X[i];} double GetPosY(int i) const {return Pos_Y[i];} @@ -71,15 +71,15 @@ class TSamuraiIdealData : public TObject { double GetMomMag(int i) const {return Mom_Mag[i];} double GetMomTheta(int i) const {return Mom_Theta[i];} double GetMomPhi(int i) const {return Mom_Phi[i];} -*/ + ///////////////////// SETTERS //////////////////////// - /* void SetData (short detector, double energy, G4ThreeVector pos, G4ThreeVector mom, double brho){ - SetData(detector, energy, pos.x(), pos.y(), pos.z(), mom.getR(), mom.getTheta(), mom.getPhi(), brho); - } + //void SetData (short detector, double energy, G4ThreeVector pos, G4ThreeVector //mom, double brho){ + // SetData(detector, energy, pos.x(), pos.y(), pos.z(), mom.getR(), mom.getTheta()//, mom.getPhi(), brho); + //} void SetData (short detector, double energy, double pos_x, double pos_y, double pos_z, double mom_r, double mom_theta, double mom_phi, double brho); - */ + void SetDetectorNumber(short i) {Detector_Number.push_back(i);} void SetEnergy (double energy) {Dep_Energy.push_back(energy);} ClassDef(TSamuraiIdealData,1) // TSamuraiIdealData structure diff --git a/NPSimulation/Detectors/Samurai/SamuraiFDC2.cc b/NPSimulation/Detectors/Samurai/SamuraiFDC2.cc index f762bd80739a8975de3347c9587b0385d8ce663f..d898c2ab4de76d78c7d449c3d15dc2ca77ea2cd8 100644 --- a/NPSimulation/Detectors/Samurai/SamuraiFDC2.cc +++ b/NPSimulation/Detectors/Samurai/SamuraiFDC2.cc @@ -81,20 +81,20 @@ SamuraiFDC2::SamuraiFDC2(){ //Scorer m_FDC2Scorer = NULL; + m_Event = new TSamuraiIdealData; + } SamuraiFDC2::~SamuraiFDC2(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SamuraiFDC2::AddDetector(G4ThreeVector Mag_Pos, double Angle, G4ThreeVector Offset){ - - // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 - m_Angle = Angle; - Offset.rotateY(-m_Angle); - m_Pos = Mag_Pos + Offset; +void SamuraiFDC2::AddDetector(G4ThreeVector Mag_Pos, double Mag_Angle, G4ThreeVector Offset, double Off_Angle){ + m_Angle = Mag_Angle + (90.*deg - Off_Angle); + Offset.rotateY(-(m_Angle)); + m_Pos = Mag_Pos + Offset; return; } @@ -161,7 +161,6 @@ G4LogicalVolume* SamuraiFDC2::BuildFDC2(){ // Called in DetecorConstruction::ReadDetectorConfiguration Method void SamuraiFDC2::ReadConfiguration(NPL::InputParser parser){ - cout << "I am inside SAMURAIFDC2 read" << endl; vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Samurai"); vector<NPL::InputBlock*> blocks2 = parser.GetAllBlocksWithToken("SAMURAIFDC2"); @@ -173,11 +172,11 @@ void SamuraiFDC2::ReadConfiguration(NPL::InputParser parser){ vector<string> sphe = {"R","Theta","Phi","ANGLE"}; G4ThreeVector Mag_Pos; - double Angle; + double Mag_Angle; if(blocks[0]->HasTokenList(cart)){ Mag_Pos = NPS::ConvertVector(blocks[0]->GetTVector3("POS", "cm")); - Angle = blocks[0]->GetDouble("ANGLE","deg"); + Mag_Angle = blocks[0]->GetDouble("ANGLE","deg"); } else if(blocks[0]->HasTokenList(sphe)){ double R = blocks[0]->GetDouble("R","mm"); @@ -186,16 +185,18 @@ void SamuraiFDC2::ReadConfiguration(NPL::InputParser parser){ Mag_Pos.setMag(R); Mag_Pos.setTheta(Theta); Mag_Pos.setPhi(Phi); - Angle = blocks[0]->GetDouble("ANGLE","deg"); + Mag_Angle = blocks[0]->GetDouble("ANGLE","deg"); } G4ThreeVector Offset = NPS::ConvertVector(blocks2[0]->GetTVector3("Offset", "mm")); + double Off_Angle = blocks2[0]->GetDouble("OffAngle","deg"); + //string xml = blocks2[0]->GetString("XML"); //bool invert_x = blocks2[0]->GetBool("InvertX"); //bool invert_y = blocks2[0]->GetBool("InvertY"); //bool invert_z = blocks2[0]->GetBool("InvertD"); - AddDetector(Mag_Pos, Angle, Offset); + AddDetector(Mag_Pos, Mag_Angle, Offset, Off_Angle); } else{ @@ -212,29 +213,12 @@ void SamuraiFDC2::ReadConfiguration(NPL::InputParser parser){ // Construct detector and inialise sensitive part. // Called After DetectorConstruction::AddDetector Method void SamuraiFDC2::ConstructDetector(G4LogicalVolume* world){ - //magnet placement - /*G4double wX = m_R * sin(m_Theta) * cos(m_Phi); - G4double wY = m_R * sin(m_Theta) * sin(m_Phi); - G4double wZ = m_R * cos(m_Theta); - - G4double mX = m_R * sin(m_Theta) * cos(m_Phi); - G4double mY = m_R * sin(m_Theta) * sin(m_Phi); - G4double mZ = m_R * cos(m_Theta); - G4ThreeVector DFC0_pos = G4ThreeVector(wX+mX, wY+mY, wZ+mZ);*/ - - - - G4ThreeVector u ( cos(m_Angle) , 0, -sin(m_Angle) ); - G4ThreeVector v (0,1,0); - G4ThreeVector w ( sin(m_Angle) , 0, cos(m_Angle) ); - - G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w); - + G4RotationMatrix* Rot = new G4RotationMatrix(); + Rot->rotateY(m_Angle); new G4PVPlacement(Rot, m_Pos, BuildFDC2(), "SamuraiFDC2", world, false, 0); - return; } @@ -248,10 +232,10 @@ void SamuraiFDC2::ConstructDetector(G4LogicalVolume* world){ void SamuraiFDC2::InitializeRootOutput(){ RootOutput *pAnalysis = RootOutput::getInstance(); TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("SamuraiFDC2")){ - pTree->Branch("SamuraiFDC2", "TSamuraiData", &m_Event) ; //WATCH OUT !!!!!! + if(!pTree->FindBranch("IdealData")){ + pTree->Branch("IdealData", "TSamuraiIdealData", &m_Event) ; //WATCH OUT !!!!!! } - pTree->SetBranchAddress("SamuraiFDC2", &m_Event) ; //WATCH OUT !!!!!! + pTree->SetBranchAddress("IdealData", &m_Event) ; //WATCH OUT !!!!!! } @@ -271,8 +255,16 @@ void SamuraiFDC2::ReadSensitive(const G4Event* event){ //vector<unsigned int> level = Scorer->GetLevel(i); //double Energy = RandGauss::shoot(Scorer->GetEnergy(i),SamuraiFDC2_NS::ResoEnergy); //double Energy = Scorer->GetEnergy(i); - m_Event->SetDetectorNumber( 2 );//2 is for FDC2 - m_Event->SetEnergy(Scorer->GetEnergy(i)); + short int detector = 2; + double energy = Scorer->GetEnergy(i); + double brho = Scorer->GetBrho(i); + double posx = Scorer->GetPositionX(i); + double posy = Scorer->GetPositionY(i); + double posz = Scorer->GetPositionZ(i); + double mom_mag = brho*Scorer->GetCharge(i); + double theta = Scorer->GetTheta(i); + double phi = Scorer->GetPhi(i); + m_Event->SetData(detector, energy, posx, posy, posz, mom_mag, theta, phi, brho); } /* m_Event->Clear(); diff --git a/NPSimulation/Detectors/Samurai/SamuraiFDC2.hh b/NPSimulation/Detectors/Samurai/SamuraiFDC2.hh index aca6a41782e4fb99d3fc64562ab37e901d817923..79afe5eede1a14ed349b3b16ffdcf85006706fed 100644 --- a/NPSimulation/Detectors/Samurai/SamuraiFDC2.hh +++ b/NPSimulation/Detectors/Samurai/SamuraiFDC2.hh @@ -56,7 +56,7 @@ class SamuraiFDC2 : public NPS::VDetector{ public: // Cartesian fdc0 - void AddDetector(G4ThreeVector POS, double Angle, G4ThreeVector Offset); + void AddDetector(G4ThreeVector Mag_Pos, double Mag_Angle, G4ThreeVector Offset, double Off_Angle); // Spherical fdc0 /*void AddFDC2(double R, double Theta, double Phi, double Angle, double r, double theta, double phi);*/ @@ -120,9 +120,6 @@ class SamuraiFDC2 : public NPS::VDetector{ double m_Angle; - - - // Needed for dynamic loading of the library public: static NPS::VDetector* Construct(); diff --git a/NPSimulation/Scorers/InteractionScorers.hh b/NPSimulation/Scorers/InteractionScorers.hh index 3fec0340074e732647b230d0cd5e8908d0fd3257..b872bdfa297ec384e4cbaf8ecc08eb74beec352e 100644 --- a/NPSimulation/Scorers/InteractionScorers.hh +++ b/NPSimulation/Scorers/InteractionScorers.hh @@ -215,6 +215,13 @@ namespace InteractionScorers { public: inline unsigned int GetMult() {return m_DataVector.size();}; inline double GetEnergy(const unsigned int& i) {return m_DataVector[i]->GetEnergy();}; + inline double GetBrho(const unsigned int& i) {return m_DataVector[i]->GetBrho();}; + inline double GetPositionX(const unsigned int& i) {return m_DataVector[i]->GetPositionX();}; + inline double GetPositionY(const unsigned int& i) {return m_DataVector[i]->GetPositionY();}; + inline double GetPositionZ(const unsigned int& i) {return m_DataVector[i]->GetPositionZ();}; + inline double GetCharge(const unsigned int& i) {return m_DataVector[i]->GetCharge();}; + inline double GetTheta(const unsigned int& i) {return m_DataVector[i]->GetTheta();}; + inline double GetPhi(const unsigned int& i) {return m_DataVector[i]->GetPhi();}; }; diff --git a/Projects/Samurai/Samurai.detector b/Projects/Samurai/Samurai.detector index 07d6c80cfe94d7b3af1fdff53580c8a7b110ee46..5ce30b423c92a9667738f7eca3d44143e16b4a93 100644 --- a/Projects/Samurai/Samurai.detector +++ b/Projects/Samurai/Samurai.detector @@ -6,10 +6,10 @@ Target ANGLE= 0 deg X= 0 mm Y= 0 mm - Z= 1000 mm + Z= -10000 mm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Samurai - POS= 0 0 10000 mm + POS= 0 0 0 mm ANGLE= 30 deg % METHOD= 1 @@ -29,7 +29,8 @@ Samurai %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SAMURAIFDC2 %XML= db/SAMURAIFDC2.xml - Offset= 0 0 5000 mm + Offset= 1000 1000 5000 mm + OffAngle= 59.930 deg %-252.416 -0.228477 4122.57 mm %InvertX= 0 %InvertY= 1