From cc429773ae47f2df5174daa752bfe2a2a66d6fbe Mon Sep 17 00:00:00 2001 From: Thomas Pohl <thomas.pohl@riken.jp> Date: Thu, 24 Oct 2024 18:23:04 +0900 Subject: [PATCH] TOGAXSI SI and GAGG detectors --- NPLib/Detectors/TOGAXSI_GAGG/CMakeLists.txt | 6 + .../TOGAXSI_GAGG/TTOGAXSI_GAGGData.cxx | 88 + .../TOGAXSI_GAGG/TTOGAXSI_GAGGData.h | 144 ++ .../TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.cxx | 436 ++++ .../TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.h | 199 ++ .../TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.cxx | 183 ++ .../TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.h | 65 + NPLib/Detectors/TOGAXSI_SI/CMakeLists.txt | 6 + .../Detectors/TOGAXSI_SI/TTOGAXSI_SIData.cxx | 108 + NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.h | 231 ++ .../TOGAXSI_SI/TTOGAXSI_SIPhysics.cxx | 1941 +++++++++++++++++ .../Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.h | 531 +++++ .../TOGAXSI_SI/TTOGAXSI_SISpectra.cxx | 150 ++ .../Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.h | 62 + .../Detectors/TOGAXSI_GAGG/CMakeLists.txt | 2 + .../Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.cc | 488 +++++ .../Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.hh | 149 ++ .../Detectors/TOGAXSI_SI/CMakeLists.txt | 2 + .../Detectors/TOGAXSI_SI/TOGAXSI_SI.cc | 1790 +++++++++++++++ .../Detectors/TOGAXSI_SI/TOGAXSI_SI.hh | 236 ++ Projects/TOGAXSI_GAGG/Analysis.cxx | 136 ++ Projects/TOGAXSI_GAGG/Analysis.h | 112 + Projects/TOGAXSI_GAGG/CMakeLists.txt | 5 + Projects/TOGAXSI_GAGG/TOGAXSI_GAGG.detector | 37 + Projects/TOGAXSI_SI/Analysis.cxx | 900 ++++++++ Projects/TOGAXSI_SI/Analysis.h | 175 ++ Projects/TOGAXSI_SI/CMakeLists.txt | 5 + Projects/TOGAXSI_SI/TOGAXSI_SI.detector | 87 + 28 files changed, 8274 insertions(+) create mode 100644 NPLib/Detectors/TOGAXSI_GAGG/CMakeLists.txt create mode 100644 NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGData.cxx create mode 100644 NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGData.h create mode 100644 NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.cxx create mode 100644 NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.h create mode 100644 NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.cxx create mode 100644 NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.h create mode 100644 NPLib/Detectors/TOGAXSI_SI/CMakeLists.txt create mode 100644 NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.cxx create mode 100644 NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.h create mode 100644 NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.cxx create mode 100644 NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.h create mode 100644 NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.cxx create mode 100644 NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.h create mode 100644 NPSimulation/Detectors/TOGAXSI_GAGG/CMakeLists.txt create mode 100644 NPSimulation/Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.cc create mode 100644 NPSimulation/Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.hh create mode 100644 NPSimulation/Detectors/TOGAXSI_SI/CMakeLists.txt create mode 100644 NPSimulation/Detectors/TOGAXSI_SI/TOGAXSI_SI.cc create mode 100644 NPSimulation/Detectors/TOGAXSI_SI/TOGAXSI_SI.hh create mode 100644 Projects/TOGAXSI_GAGG/Analysis.cxx create mode 100644 Projects/TOGAXSI_GAGG/Analysis.h create mode 100644 Projects/TOGAXSI_GAGG/CMakeLists.txt create mode 100644 Projects/TOGAXSI_GAGG/TOGAXSI_GAGG.detector create mode 100644 Projects/TOGAXSI_SI/Analysis.cxx create mode 100644 Projects/TOGAXSI_SI/Analysis.h create mode 100644 Projects/TOGAXSI_SI/CMakeLists.txt create mode 100644 Projects/TOGAXSI_SI/TOGAXSI_SI.detector diff --git a/NPLib/Detectors/TOGAXSI_GAGG/CMakeLists.txt b/NPLib/Detectors/TOGAXSI_GAGG/CMakeLists.txt new file mode 100644 index 000000000..ed23e8e6f --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_GAGG/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TTOGAXSI_GAGGPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTOGAXSI_GAGGPhysics.h TTOGAXSI_GAGGPhysicsDict.cxx TTOGAXSI_GAGGPhysics.rootmap libNPTOGAXSI_GAGG.dylib DEPENDS TTOGAXSI_GAGGPhysics.h) +add_custom_command(OUTPUT TTOGAXSI_GAGGDataDict.cxx COMMAND ../../scripts/build_dict.sh TTOGAXSI_GAGGData.h TTOGAXSI_GAGGDataDict.cxx TTOGAXSI_GAGGData.rootmap libNPTOGAXSI_GAGG.dylib DEPENDS TTOGAXSI_GAGGData.h) +add_library(NPTOGAXSI_GAGG SHARED TTOGAXSI_GAGGSpectra.cxx TTOGAXSI_GAGGData.cxx TTOGAXSI_GAGGPhysics.cxx TTOGAXSI_GAGGDataDict.cxx TTOGAXSI_GAGGPhysicsDict.cxx ) +target_link_libraries(NPTOGAXSI_GAGG ${ROOT_LIBRARIES} NPCore) +install(FILES TTOGAXSI_GAGGData.h TTOGAXSI_GAGGPhysics.h TTOGAXSI_GAGGSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGData.cxx b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGData.cxx new file mode 100644 index 000000000..96aca543b --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGData.cxx @@ -0,0 +1,88 @@ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_GAGG Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TTOGAXSI_GAGGData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TTOGAXSI_GAGGData) + + +////////////////////////////////////////////////////////////////////// +TTOGAXSI_GAGGData::TTOGAXSI_GAGGData() { +} + + + +////////////////////////////////////////////////////////////////////// +TTOGAXSI_GAGGData::~TTOGAXSI_GAGGData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGData::Clear() { + // Energy + fRecoil_E_DetectorNbr.clear(); + fRecoil_Energy.clear(); + // Time + fRecoil_T_DetectorNbr.clear(); + fRecoil_Time.clear(); + + // Energy + fCluster_E_DetectorNbr.clear(); + fCluster_Energy.clear(); + // Time + fCluster_T_DetectorNbr.clear(); + fCluster_Time.clear(); +} + + + +////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGData::Dump() const { + // This method is very useful for debuging and worth the dev. + + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TTOGAXSI_GAGGData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = fRecoil_E_DetectorNbr.size(); + cout << "Recoil GAGG_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fRecoil_E_DetectorNbr[i] + << " Energy: " << fRecoil_Energy[i]; + } + + // Time + mysize = fRecoil_T_DetectorNbr.size(); + cout << "Recoil GAGG_T_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fRecoil_T_DetectorNbr[i] + << " Time: " << fRecoil_Time[i]; + } + +} diff --git a/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGData.h b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGData.h new file mode 100644 index 000000000..2799ef346 --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGData.h @@ -0,0 +1,144 @@ +#ifndef __TOGAXSI_GAGGDATA__ +#define __TOGAXSI_GAGGDATA__ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_GAGG Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TTOGAXSI_GAGGData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + //private: + public: + //Recoil detector + // Energy + vector<UShort_t> fRecoil_E_DetectorNbr; + vector<Double_t> fRecoil_Energy; + + // Time + vector<UShort_t> fRecoil_T_DetectorNbr; + vector<Double_t> fRecoil_Time; + + //Cluster detector + // Energy + vector<UShort_t> fCluster_E_DetectorNbr; + vector<Double_t> fCluster_Energy; + + // Time + vector<UShort_t> fCluster_T_DetectorNbr; + vector<Double_t> fCluster_Time; + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TTOGAXSI_GAGGData(); + ~TTOGAXSI_GAGGData(); + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + + ////////////////////////////////////////////////////////////// + // Getters and Setters + // Prefer inline declaration to avoid unnecessary called of + // frequently used methods + // add //! to avoid ROOT creating dictionnary for the methods + public: + ////////////////////// SETTERS //////////////////////// + // Recoil detector + // Energy + inline void SetRecoilEnergy(const unsigned& DetNbr,const Double_t& Energy) { + fRecoil_E_DetectorNbr.push_back(DetNbr); + fRecoil_Energy.push_back(Energy); + };//! + + // Time + inline void SetRecoilTime(const unsigned& DetNbr,const Double_t& Time) { + fRecoil_T_DetectorNbr.push_back(DetNbr); + fRecoil_Time.push_back(Time); + };//! + + //Cluster detector + // Energy + inline void SetClusterEnergy(const unsigned& DetNbr,const Double_t& Energy) { + fCluster_E_DetectorNbr.push_back(DetNbr); + fCluster_Energy.push_back(Energy); + };//! + + // Time + inline void SetClusterTime(const unsigned& DetNbr,const Double_t& Time) { + fCluster_T_DetectorNbr.push_back(DetNbr); + fCluster_Time.push_back(Time); + };//! + + ////////////////////// GETTERS //////////////////////// + // Recoil detector + // Energy + inline UShort_t GetRecoilMultEnergy() const + {return fRecoil_E_DetectorNbr.size();} + inline UShort_t GetRecoil_E_DetectorNbr(const unsigned int &i) const + {return fRecoil_E_DetectorNbr[i];}//! + inline Double_t GetRecoil_Energy(const unsigned int &i) const + {return fRecoil_Energy[i];}//! + + // Time + inline UShort_t GetRecoilMultTime() const + {return fRecoil_T_DetectorNbr.size();} + inline UShort_t GetRecoil_T_DetectorNbr(const unsigned int &i) const + {return fRecoil_T_DetectorNbr[i];}//! + inline Double_t GetRecoil_Time(const unsigned int &i) const + {return fRecoil_Time[i];}//! + + // Cluster detector + // Energy + inline UShort_t GetClusterMultEnergy() const + {return fCluster_E_DetectorNbr.size();} + inline UShort_t GetCluster_E_DetectorNbr(const unsigned int &i) const + {return fCluster_E_DetectorNbr[i];}//! + inline Double_t GetCluster_Energy(const unsigned int &i) const + {return fCluster_Energy[i];}//! + + // Time + inline UShort_t GetClusterMultTime() const + {return fCluster_T_DetectorNbr.size();} + inline UShort_t GetCluster_T_DetectorNbr(const unsigned int &i) const + {return fCluster_T_DetectorNbr[i];}//! + inline Double_t GetCluster_Time(const unsigned int &i) const + {return fCluster_Time[i];}//! + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TTOGAXSI_GAGGData,1) // TOGAXSI_GAGGData structure +}; + +#endif diff --git a/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.cxx b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.cxx new file mode 100644 index 000000000..0c4479c60 --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.cxx @@ -0,0 +1,436 @@ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_GAGG Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TTOGAXSI_GAGGPhysics.h" + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> +using namespace std; + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "NPDetectorFactory.h" +#include "NPOptionManager.h" +#include "NPSystemOfUnits.h" +using namespace NPUNITS; + +// ROOT +#include "TChain.h" + +ClassImp(TTOGAXSI_GAGGPhysics) + + +/////////////////////////////////////////////////////////////////////////// +TTOGAXSI_GAGGPhysics::TTOGAXSI_GAGGPhysics() { +/* + m_EventData = new TTOGAXSI_GAGGData; + m_PreTreatedData = new TTOGAXSI_GAGGData; + m_EventPhysics = this; + m_Spectra = NULL; + m_E_RAW_Threshold = 0; // adc channels + m_E_Threshold = 0; // MeV + m_NumberOfRecoilDetectors = 0; + m_NumberOfClusterDetectors = 0; + EventMultiplicity = 0; + + //Detector + Crystal_Length = 3.5*mm; + Crystal_Width = 3.5*mm; + Crystal_Height = 12*mm; +*/ +} + +/////////////////////////////////////////////////////////////////////////// +/// A usefull method to bundle all operation to add a detector +//void TTOGAXSI_GAGGPhysics::AddDetector(TVector3 , string ){ + // In That simple case nothing is done + // Typically for more complex detector one would calculate the relevant + // positions (stripped silicon) or angles (gamma array) +// m_NumberOfDetectors++; +//} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::AddRecoilDetector(TVector3 Pos, double Phi, TVector3 Ref) { +// m_NumberOfRecoilDetectors++; +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::AddClusterDetector(TVector3 Pos, double Phi, TVector3 Ref) { +// m_NumberOfClusterDetectors++; +} + +/////////////////////////////////////////////////////////////////////////// +//void TTOGAXSI_GAGGPhysics::AddDetector(double R, double Theta, double Phi, string shape){ + // Compute the TVector3 corresponding +// TVector3 Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); + // Call the cartesian method +// AddDetector(Pos,shape); +//} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::BuildPhysicalEvent() { +/* + // apply thresholds and calibration + PreTreat(); + + // match energy and time together + unsigned int mysizeRecoilE = m_PreTreatedData->GetRecoilMultEnergy(); + unsigned int mysizeRecoilT = m_PreTreatedData->GetRecoilMultTime(); + + unsigned int mysizeClusterE = m_PreTreatedData->GetClusterMultEnergy(); + unsigned int mysizeClusterT = m_PreTreatedData->GetClusterMultTime(); + + for (UShort_t e = 0; e < mysizeRecoilE ; e++) { + for (UShort_t t = 0; t < mysizeRecoilT ; t++) { + if (m_PreTreatedData->GetRecoil_E_DetectorNbr(e) == m_PreTreatedData->GetRecoil_T_DetectorNbr(t)) { + RecoilDetectorNumber.push_back(m_PreTreatedData->GetRecoil_E_DetectorNbr(e)); + RecoilE.push_back(m_PreTreatedData->GetRecoil_Energy(e)); + RecoilT.push_back(m_PreTreatedData->GetRecoil_Time(t)); + } + } + } + + for (UShort_t e = 0; e < mysizeClusterE ; e++) { + for (UShort_t t = 0; t < mysizeClusterT ; t++) { + if (m_PreTreatedData->GetCluster_E_DetectorNbr(e) == m_PreTreatedData->GetCluster_T_DetectorNbr(t)) { + ClusterDetectorNumber.push_back(m_PreTreatedData->GetCluster_E_DetectorNbr(e)); + ClusterE.push_back(m_PreTreatedData->GetCluster_Energy(e)); + ClusterT.push_back(m_PreTreatedData->GetCluster_Time(t)); + } + } + } +*/ +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::PreTreat() { + // This method typically applies thresholds and calibrations + // Might test for disabled channels for more complex detector +/* + // clear pre-treated object + ClearPreTreatedData(); + + // instantiate CalibrationManager + static CalibrationManager* Cal = CalibrationManager::getInstance(); + + // Recoil Detector + // Energy + unsigned int mysize = m_EventData->GetRecoilMultEnergy(); + for (UShort_t i = 0; i < mysize ; ++i) { + if (m_EventData->GetRecoil_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetRecoil_Energy(i); + //Double_t Energy = Cal->ApplyCalibration("TOGAXSI_GAGG/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetRecoilEnergy(m_EventData->GetRecoil_E_DetectorNbr(i), Energy); + } + } + } + + // Time + mysize = m_EventData->GetRecoilMultTime(); + for (UShort_t i = 0; i < mysize; ++i) { + Double_t Time = m_EventData->GetRecoil_Time(i); + //Double_t Time= Cal->ApplyCalibration("TOGAXSI_GAGG/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); + m_PreTreatedData->SetRecoilTime(m_EventData->GetRecoil_T_DetectorNbr(i), Time); + } + + // Cluster Detector + // Energy + mysize = m_EventData->GetClusterMultEnergy(); + for (UShort_t i = 0; i < mysize ; ++i) { + if (m_EventData->GetCluster_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetCluster_Energy(i); + //Double_t Energy = Cal->ApplyCalibration("TOGAXSI_GAGG/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetClusterEnergy(m_EventData->GetCluster_E_DetectorNbr(i), Energy); + } + } + } + + // Time + mysize = m_EventData->GetClusterMultTime(); + for (UShort_t i = 0; i < mysize; ++i) { + Double_t Time = m_EventData->GetCluster_Time(i); + //Double_t Time= Cal->ApplyCalibration("TOGAXSI_GAGG/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); + m_PreTreatedData->SetClusterTime(m_EventData->GetCluster_T_DetectorNbr(i), Time); + } + +*/ +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigTOGAXSI_GAGG.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigTOGAXSI_GAGG.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigTOGAXSI_GAGG.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigTOGAXSI_GAGG.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer,DataBuffer,whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + string name = "ConfigTOGAXSI_GAGG"; + if (LineBuffer.compare(0, name.length(), name) == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus ) { + whatToDo=""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + } + + else if (whatToDo=="E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_RAW_Threshold << endl; + } + + else if (whatToDo=="E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_Threshold << endl; + } + + else { + ReadingStatus = false; + } + } + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::Clear() { +/* + EventMultiplicity = 0; + + RecoilDetectorNumber.clear(); + RecoilE.clear(); + RecoilT.clear(); + + ClusterDetectorNumber.clear(); + ClusterE.clear(); + ClusterT.clear(); +*/ +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::ReadConfiguration(NPL::InputParser parser) { +/* + // Recoil Detector + vector<NPL::InputBlock*> blocks_recoil = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_GAGG","RecoilArray"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_recoil.size() << " recoil detectors found " << endl; + + vector<string> coord = {"Pos","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_recoil.size() ; i++){ + if(blocks_recoil[i]->HasTokenList(coord)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_GAGG Recoil " << i+1 << endl; + TVector3 Pos = blocks_recoil[i]->GetTVector3("Pos","mm"); + double Phi = blocks_recoil[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_recoil[i]->GetTVector3("Ref","mm"); + AddRecoilDetector(Pos,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + // Recoil Detector + vector<NPL::InputBlock*> blocks_cluster = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_GAGG","ClusterArray"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_cluster.size() << " cluster detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_cluster.size() ; i++){ + if(blocks_cluster[i]->HasTokenList(coord)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_GAGG Cluster " << i+1 << endl; + TVector3 Pos = blocks_cluster[i]->GetTVector3("Pos","mm"); + double Phi = blocks_cluster[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_cluster[i]->GetTVector3("Ref","mm"); + AddClusterDetector(Pos,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +*/ + +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::InitSpectra() { +// m_Spectra = new TTOGAXSI_GAGGSpectra(m_NumberOfRecoilDetectors, m_NumberOfClusterDetectors); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TTOGAXSI_GAGGPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); +/* + for (int i = 0; i < m_NumberOfRecoilDetectors; ++i) { + Cal->AddParameter("TOGAXSI_GAGG", "D"+ NPL::itoa(i+1)+"_ENERGY","TOGAXSI_GAGG_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("TOGAXSI_GAGG", "D"+ NPL::itoa(i+1)+"_TIME","TOGAXSI_GAGG_D"+ NPL::itoa(i+1)+"_TIME"); + } + + for (int i = 0; i < m_NumberOfClusterDetectors; ++i) { + Cal->AddParameter("TOGAXSI_GAGG", "D"+ NPL::itoa(i+1)+"_ENERGY","TOGAXSI_GAGG_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("TOGAXSI_GAGG", "D"+ NPL::itoa(i+1)+"_TIME","TOGAXSI_GAGG_D"+ NPL::itoa(i+1)+"_TIME"); + } +*/ +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("TOGAXSI_GAGG", true ); + inputChain->SetBranchAddress("TOGAXSI_GAGG", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("TOGAXSI_GAGG", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("TOGAXSI_GAGG", "TTOGAXSI_GAGGPhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TTOGAXSI_GAGGPhysics::Construct() { + return (NPL::VDetector*) new TTOGAXSI_GAGGPhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy_TOGAXSI_GAGG{ + public: + proxy_TOGAXSI_GAGG(){ + NPL::DetectorFactory::getInstance()->AddToken("TOGAXSI_GAGG","TOGAXSI_GAGG"); + NPL::DetectorFactory::getInstance()->AddDetector("TOGAXSI_GAGG",TTOGAXSI_GAGGPhysics::Construct); + } +}; + +proxy_TOGAXSI_GAGG p_TOGAXSI_GAGG; +} + diff --git a/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.h b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.h new file mode 100644 index 000000000..63c65e3e0 --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGPhysics.h @@ -0,0 +1,199 @@ +#ifndef TTOGAXSI_GAGGPHYSICS_H +#define TTOGAXSI_GAGGPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_GAGG Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <vector> +#include <map> +#include <string> +using namespace std; + +// ROOT headers +#include "TObject.h" +#include "TH1.h" +#include "TVector3.h" +// NPTool headers +#include "TTOGAXSI_GAGGData.h" +#include "TTOGAXSI_GAGGSpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +// forward declaration +class TTOGAXSI_GAGGSpectra; + + + +class TTOGAXSI_GAGGPhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TTOGAXSI_GAGGPhysics(); + ~TTOGAXSI_GAGGPhysics() {}; + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + + + ////////////////////////////////////////////////////////////// + // data obtained after BuildPhysicalEvent() and stored in + // output ROOT file + public: + Int_t EventMultiplicity; + vector<int> RecoilDetectorNumber; + vector<double> RecoilE; + vector<double> RecoilT; + + vector<int> ClusterDetectorNumber; + vector<double> ClusterE; + vector<double> ClusterT; + + /// A usefull method to bundle all operation to add a detector + //void AddDetector(TVector3 POS, string shape); + //void AddDetector(double R, double Theta, double Phi, string shape); + + ////////////////////////////////////////////////////////////// + // methods inherited from the VDetector ABC class + public: + // read stream from ConfigFile to pick-up detector parameters + void ReadConfiguration(NPL::InputParser); + + // A useful method to bundle all operation to add a detector + void AddRecoilDetector(TVector3 Pos, double Phi, TVector3 Ref); + void AddClusterDetector(TVector3 Pos, double Phi, TVector3 Ref); + + // add parameters to the CalibrationManger + void AddParameterToCalibrationManager(); + + // method called event by event, aiming at extracting the + // physical information from detector + void BuildPhysicalEvent(); + + // same as BuildPhysicalEvent() method but with a simpler + // treatment + void BuildSimplePhysicalEvent(); + + // same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; + + // activate raw data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputRaw(); + + // activate physics data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputPhysics(); + + // create branches of output ROOT file + void InitializeRootOutput(); + + // clear the raw and physical data objects event by event + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // methods related to the TTOGAXSI_GAGGSpectra class + // instantiate the TTOGAXSI_GAGGSpectra class and + // declare list of histograms + void InitSpectra(); + + // fill the spectra + void FillSpectra(); + + // used for Online mainly, sanity check for histograms and + // change their color if issues are found, for example + void CheckSpectra(); + + // used for Online only, clear all the spectra + void ClearSpectra(); + + // write spectra to ROOT output file + void WriteSpectra(); + + + ////////////////////////////////////////////////////////////// + // specific methods to TOGAXSI_GAGG array + public: + // remove bad channels, calibrate the data and apply thresholds + void PreTreat(); + + // clear the pre-treated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // read the user configuration file. If no file is found, load standard one + void ReadAnalysisConfig(); + + // give and external TTOGAXSI_GAGGData object to TTOGAXSI_GAGGPhysics. + // needed for online analysis for example + void SetRawDataPointer(TTOGAXSI_GAGGData* rawDataPointer) {m_EventData = rawDataPointer;} + + double GetNumberOfRecoilDetector() const {return m_NumberOfRecoilDetectors;} + double GetNumberOfClusterDetector() const {return m_NumberOfClusterDetectors;} + int GetEventMultiplicity() const {return EventMultiplicity;} + + // objects are not written in the TTree + private: + TTOGAXSI_GAGGData* m_EventData; //! + TTOGAXSI_GAGGData* m_PreTreatedData; //! + TTOGAXSI_GAGGPhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TTOGAXSI_GAGGData* GetRawData() const {return m_EventData;} + TTOGAXSI_GAGGData* GetPreTreatedData() const {return m_PreTreatedData;} + + // parameters used in the analysis + private: + int m_NumberOfRecoilDetectors; //! + int m_NumberOfClusterDetectors; //! + + // thresholds + double m_E_RAW_Threshold; //! + double m_E_Threshold; //! + + // spectra class + private: + TTOGAXSI_GAGGSpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TTOGAXSI_GAGGPhysics,1) // TOGAXSI_GAGGPhysics structure + + private: //geometry + + double Crystal_Length; + double Crystal_Width; + double Crystal_Height; + +}; +#endif diff --git a/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.cxx b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.cxx new file mode 100644 index 000000000..4e25adc10 --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.cxx @@ -0,0 +1,183 @@ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_GAGG Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TTOGAXSI_GAGGSpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TTOGAXSI_GAGGSpectra::TTOGAXSI_GAGGSpectra() +// : fNumberOfRecoilDetectors(0) { + : fNumberOfDetectors(0) { + SetName("TOGAXSI_GAGG"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +//TTOGAXSI_GAGGSpectra::TTOGAXSI_GAGGSpectra(unsigned int NumberOfRecoilDetectors, unsigned int NumberOfClusterDetectors) { +TTOGAXSI_GAGGSpectra::TTOGAXSI_GAGGSpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TTOGAXSI_GAGGSpectra : Initalizing control spectra for " +// << NumberOfRecoilDetectors << "Recoil Detectors" << endl +// << NumberOfClusterDetectors << "Cluster Detectors" << endl + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("TOGAXSI_GAGG"); +// fNumberOfRecoilDetectors = NumberOfRecoilDetectors; +// fNumberOfClusterDetectors = NumberOfClusterDetectors; + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); + +} + + + +//////////////////////////////////////////////////////////////////////////////// +TTOGAXSI_GAGGSpectra::~TTOGAXSI_GAGGSpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGSpectra::InitRawSpectra() { + static string name; +// for (unsigned int i = 0; i < fNumberOfRecoilDetectors; i++) { // loop on number of detectors + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "TOGAXSI_GAGG"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "TOGAXSI_GAGG/RAW"); + // Time + name = "TOGAXSI_GAGG"+NPL::itoa(i+1)+"_TIME_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "TOGAXSI_GAGG/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGSpectra::InitPreTreatedSpectra() { + static string name; +// for (unsigned int i = 0; i < fNumberOfRecoilDetectors; i++) { // loop on number of detectors + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "TOGAXSI_GAGG"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "TOGAXSI_GAGG/CAL"); + // Time + name = "TOGAXSI_GAGG"+NPL::itoa(i+1)+"_TIME_CAL"; + AddHisto1D(name, name, 500, 0, 25, "TOGAXSI_GAGG/CAL"); + + + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGSpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "TOGAXSI_GAGG_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "TOGAXSI_GAGG/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGSpectra::FillRawSpectra(TTOGAXSI_GAGGData* RawData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetRecoilMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "TOGAXSI_GAGG"+NPL::itoa(RawData->GetRecoil_E_DetectorNbr(i))+"_ENERGY_RAW"; + family = "TOGAXSI_GAGG/RAW"; + + FillSpectra(family,name,RawData->GetRecoil_Energy(i)); + } + + // Time + unsigned int sizeT = RawData->GetRecoilMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "TOGAXSI_GAGG"+NPL::itoa(RawData->GetRecoil_T_DetectorNbr(i))+"_TIME_RAW"; + family = "TOGAXSI_GAGG/RAW"; + + FillSpectra(family,name,RawData->GetRecoil_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGSpectra::FillPreTreatedSpectra(TTOGAXSI_GAGGData* PreTreatedData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetRecoilMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "TOGAXSI_GAGG"+NPL::itoa(PreTreatedData->GetRecoil_E_DetectorNbr(i))+"_ENERGY_CAL"; + family = "TOGAXSI_GAGG/CAL"; + + FillSpectra(family,name,PreTreatedData->GetRecoil_Energy(i)); + } + + // Time + unsigned int sizeT = PreTreatedData->GetRecoilMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "TOGAXSI_GAGG"+NPL::itoa(PreTreatedData->GetRecoil_T_DetectorNbr(i))+"_TIME_CAL"; + family = "TOGAXSI_GAGG/CAL"; + + FillSpectra(family,name,PreTreatedData->GetRecoil_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_GAGGSpectra::FillPhysicsSpectra(TTOGAXSI_GAGGPhysics* Physics) { + static string name; + static string family; + family= "TOGAXSI_GAGG/PHY"; + + // Energy vs time + unsigned int sizeE = Physics->RecoilE.size(); + for(unsigned int i = 0 ; i < sizeE ; i++){ + name = "TOGAXSI_GAGG_ENERGY_TIME"; + FillSpectra(family,name,Physics->RecoilE[i],Physics->RecoilT[i]); + } +} + diff --git a/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.h b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.h new file mode 100644 index 000000000..5514db0d3 --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_GAGG/TTOGAXSI_GAGGSpectra.h @@ -0,0 +1,65 @@ +#ifndef TTOGAXSI_GAGGSPECTRA_H +#define TTOGAXSI_GAGGSPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_GAGG Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TTOGAXSI_GAGGData.h" +#include "TTOGAXSI_GAGGPhysics.h" + +// Forward Declaration +class TTOGAXSI_GAGGPhysics; + + +class TTOGAXSI_GAGGSpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TTOGAXSI_GAGGSpectra(); +// TTOGAXSI_GAGGSpectra(unsigned int NumberOfRecoilDetectors,unsigned int NumberOfClusterDetectors); + TTOGAXSI_GAGGSpectra(unsigned int NumberOfDetectors); + ~TTOGAXSI_GAGGSpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TTOGAXSI_GAGGData*); + void FillPreTreatedSpectra(TTOGAXSI_GAGGData*); + void FillPhysicsSpectra(TTOGAXSI_GAGGPhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: +// unsigned int fNumberOfRecoilDetectors; +// unsigned int fNumberOfClusterDetectors; + unsigned int fNumberOfDetectors; +}; + +#endif diff --git a/NPLib/Detectors/TOGAXSI_SI/CMakeLists.txt b/NPLib/Detectors/TOGAXSI_SI/CMakeLists.txt new file mode 100644 index 000000000..a16600432 --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_SI/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TTOGAXSI_SIPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TTOGAXSI_SIPhysics.h TTOGAXSI_SIPhysicsDict.cxx TTOGAXSI_SIPhysics.rootmap libNPTOGAXSI_SI.dylib DEPENDS TTOGAXSI_SIPhysics.h) +add_custom_command(OUTPUT TTOGAXSI_SIDataDict.cxx COMMAND ../../scripts/build_dict.sh TTOGAXSI_SIData.h TTOGAXSI_SIDataDict.cxx TTOGAXSI_SIData.rootmap libNPTOGAXSI_SI.dylib DEPENDS TTOGAXSI_SIData.h) +add_library(NPTOGAXSI_SI SHARED TTOGAXSI_SISpectra.cxx TTOGAXSI_SIData.cxx TTOGAXSI_SIPhysics.cxx TTOGAXSI_SIDataDict.cxx TTOGAXSI_SIPhysicsDict.cxx ) +target_link_libraries(NPTOGAXSI_SI ${ROOT_LIBRARIES} NPCore) +install(FILES TTOGAXSI_SIData.h TTOGAXSI_SIPhysics.h TTOGAXSI_SISpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.cxx b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.cxx new file mode 100644 index 000000000..9a0d8faad --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.cxx @@ -0,0 +1,108 @@ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_SI Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TTOGAXSI_SIData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TTOGAXSI_SIData) + + +////////////////////////////////////////////////////////////////////// +TTOGAXSI_SIData::TTOGAXSI_SIData() { +} + + + +////////////////////////////////////////////////////////////////////// +TTOGAXSI_SIData::~TTOGAXSI_SIData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIData::Clear() { + // Energy X + fInnerX_E_DetectorNbr.clear(); + fInnerX_E_StripNbr.clear(); + fInnerX_E_Energy.clear(); + // Energy Z + fInnerZ_E_DetectorNbr.clear(); + fInnerZ_E_StripNbr.clear(); + fInnerZ_E_Energy.clear(); + + // Energy X + fOuterX_E_DetectorNbr.clear(); + fOuterX_E_StripNbr.clear(); + fOuterX_E_Energy.clear(); + // Energy Z + fOuterZ_E_DetectorNbr.clear(); + fOuterZ_E_StripNbr.clear(); + fOuterZ_E_Energy.clear(); + + // Energy X + fClusterInner_E_DetectorNbr.clear(); + fClusterInner_E_StripNbr.clear(); + fClusterInner_E_Energy.clear(); + + // Energy X1 + fClusterX1_E_DetectorNbr.clear(); + fClusterX1_E_StripNbr.clear(); + fClusterX1_E_Energy.clear(); + + // Energy Y1 + fClusterY1_E_DetectorNbr.clear(); + fClusterY1_E_StripNbr.clear(); + fClusterY1_E_Energy.clear(); + + // Energy X2 + fClusterX2_E_DetectorNbr.clear(); + fClusterX2_E_StripNbr.clear(); + fClusterX2_E_Energy.clear(); + + // Energy Y2 + fClusterY2_E_DetectorNbr.clear(); + fClusterY2_E_StripNbr.clear(); + fClusterY2_E_Energy.clear(); + +} + + + +////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIData::Dump() const { + // This method is very useful for debuging and worth the dev. + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TTOGAXSI_SIData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = fInnerX_E_DetectorNbr.size(); + cout << "TOGAXSI_SI_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fInnerX_E_DetectorNbr[i] + << " Energy: " << fInnerX_E_Energy[i]; + } + +} diff --git a/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.h b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.h new file mode 100644 index 000000000..9ba3ffabc --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIData.h @@ -0,0 +1,231 @@ +#ifndef __TOGAXSI_SIDATA__ +#define __TOGAXSI_SIDATA__ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_SI Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TTOGAXSI_SIData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + + public: + // InnerX Energy + vector<unsigned short> fInnerX_E_DetectorNbr; + vector<unsigned short> fInnerX_E_StripNbr; + vector<double> fInnerX_E_Energy; + // InnerZ Energy + vector<unsigned short> fInnerZ_E_DetectorNbr; + vector<unsigned short> fInnerZ_E_StripNbr; + vector<double> fInnerZ_E_Energy; + + // OuterX Energy + vector<unsigned short> fOuterX_E_DetectorNbr; + vector<unsigned short> fOuterX_E_StripNbr; + vector<double> fOuterX_E_Energy; + // OuterZ Energy + vector<unsigned short> fOuterZ_E_DetectorNbr; + vector<unsigned short> fOuterZ_E_StripNbr; + vector<double> fOuterZ_E_Energy; + + // ClusterInner Energy + vector<unsigned short> fClusterInner_E_DetectorNbr; + vector<unsigned short> fClusterInner_E_StripNbr; + vector<double> fClusterInner_E_Energy; + + // ClusterX Energy + vector<unsigned short> fClusterX1_E_DetectorNbr; + vector<unsigned short> fClusterX1_E_StripNbr; + vector<double> fClusterX1_E_Energy; + + // ClusteY Energy + vector<unsigned short> fClusterY1_E_DetectorNbr; + vector<unsigned short> fClusterY1_E_StripNbr; + vector<double> fClusterY1_E_Energy; + + // ClusterX Energy + vector<unsigned short> fClusterX2_E_DetectorNbr; + vector<unsigned short> fClusterX2_E_StripNbr; + vector<double> fClusterX2_E_Energy; + + // ClusteY Energy + vector<unsigned short> fClusterY2_E_DetectorNbr; + vector<unsigned short> fClusterY2_E_StripNbr; + vector<double> fClusterY2_E_Energy; + + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TTOGAXSI_SIData(); + ~TTOGAXSI_SIData(); + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + + ////////////////////////////////////////////////////////////// + // Getters and Setters + // Prefer inline declaration to avoid unnecessary called of + // frequently used methods + // add //! to avoid ROOT creating dictionnary for the methods + public: + ////////////////////// SETTERS //////////////////////// + // InnerX Energy + inline void SetInnerXE(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fInnerX_E_DetectorNbr.push_back(DetNbr); + fInnerX_E_StripNbr.push_back(StripNbr); + fInnerX_E_Energy.push_back(Energy); + };//! + + // InnerZ Energy + inline void SetInnerZE(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fInnerZ_E_DetectorNbr.push_back(DetNbr); + fInnerZ_E_StripNbr.push_back(StripNbr); + fInnerZ_E_Energy.push_back(Energy); + };//! + + // OuterX Energy + inline void SetOuterXE(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fOuterX_E_DetectorNbr.push_back(DetNbr); + fOuterX_E_StripNbr.push_back(StripNbr); + fOuterX_E_Energy.push_back(Energy); + };//! + + // OuterZ Energy + inline void SetOuterZE(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fOuterZ_E_DetectorNbr.push_back(DetNbr); + fOuterZ_E_StripNbr.push_back(StripNbr); + fOuterZ_E_Energy.push_back(Energy); + };//! + + // ClusterInner Energy Front + inline void SetClusterInnerE(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fClusterInner_E_DetectorNbr.push_back(DetNbr); + fClusterInner_E_StripNbr.push_back(StripNbr); + fClusterInner_E_Energy.push_back(Energy); + };//! + + // ClusterX Energy Front + inline void SetClusterX1E(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fClusterX1_E_DetectorNbr.push_back(DetNbr); + fClusterX1_E_StripNbr.push_back(StripNbr); + fClusterX1_E_Energy.push_back(Energy); + };//! + + // ClusterY Energy Front + inline void SetClusterY1E(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fClusterY1_E_DetectorNbr.push_back(DetNbr); + fClusterY1_E_StripNbr.push_back(StripNbr); + fClusterY1_E_Energy.push_back(Energy); + };//! + + // ClusterX Energy Front + inline void SetClusterX2E(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fClusterX2_E_DetectorNbr.push_back(DetNbr); + fClusterX2_E_StripNbr.push_back(StripNbr); + fClusterX2_E_Energy.push_back(Energy); + };//! + + // ClusterY Energy Front + inline void SetClusterY2E(const unsigned& DetNbr, const unsigned short& StripNbr, const Double_t& Energy){ + fClusterY2_E_DetectorNbr.push_back(DetNbr); + fClusterY2_E_StripNbr.push_back(StripNbr); + fClusterY2_E_Energy.push_back(Energy); + };//! + + + ////////////////////// GETTERS //////////////////////// + // InnerX Energy + inline unsigned short GetInnerXMultEnergy() const {return fInnerX_E_DetectorNbr.size();} + inline unsigned short GetInnerX_E_DetectorNbr(const unsigned int &i) const {return fInnerX_E_DetectorNbr[i];}//! + inline unsigned short GetInnerX_E_StripNbr(const unsigned int &i) const {return fInnerX_E_StripNbr[i];}//! + inline Double_t GetInnerX_E_Energy(const unsigned int &i) const {return fInnerX_E_Energy[i];}//! + + // InnerZ Energy + inline unsigned short GetInnerZMultEnergy() const {return fInnerZ_E_DetectorNbr.size();} + inline unsigned short GetInnerZ_E_DetectorNbr(const unsigned int &i) const {return fInnerZ_E_DetectorNbr[i];}//! + inline unsigned short GetInnerZ_E_StripNbr(const unsigned int &i) const {return fInnerZ_E_StripNbr[i];}//! + inline Double_t GetInnerZ_E_Energy(const unsigned int &i) const {return fInnerZ_E_Energy[i];}//! + + // OuterX Energy + inline unsigned short GetOuterXMultEnergy() const {return fOuterX_E_DetectorNbr.size();} + inline unsigned short GetOuterX_E_DetectorNbr(const unsigned int &i) const {return fOuterX_E_DetectorNbr[i];}//! + inline unsigned short GetOuterX_E_StripNbr(const unsigned int &i) const {return fOuterX_E_StripNbr[i];}//! + inline Double_t GetOuterX_E_Energy(const unsigned int &i) const {return fOuterX_E_Energy[i];}//! + + // OuterZ Energy + inline unsigned short GetOuterZMultEnergy() const {return fOuterZ_E_DetectorNbr.size();} + inline unsigned short GetOuterZ_E_DetectorNbr(const unsigned int &i) const {return fOuterZ_E_DetectorNbr[i];}//! + inline unsigned short GetOuterZ_E_StripNbr(const unsigned int &i) const {return fOuterZ_E_StripNbr[i];}//! + inline Double_t GetOuterZ_E_Energy(const unsigned int &i) const {return fOuterZ_E_Energy[i];}//! + + // ClusterInner Energy + inline unsigned short GetClusterInnerMultEnergy() const {return fClusterInner_E_DetectorNbr.size();} + inline unsigned short GetClusterInner_E_DetectorNbr(const unsigned int &i) const {return fClusterInner_E_DetectorNbr[i];}//! + inline unsigned short GetClusterInner_E_StripNbr(const unsigned int &i) const {return fClusterInner_E_StripNbr[i];}//! + inline Double_t GetClusterInner_E_Energy(const unsigned int &i) const {return fClusterInner_E_Energy[i];}//! + + // ClusterX1 Energy + inline unsigned short GetClusterX1MultEnergy() const {return fClusterX1_E_DetectorNbr.size();} + inline unsigned short GetClusterX1_E_DetectorNbr(const unsigned int &i) const {return fClusterX1_E_DetectorNbr[i];}//! + inline unsigned short GetClusterX1_E_StripNbr(const unsigned int &i) const {return fClusterX1_E_StripNbr[i];}//! + inline Double_t GetClusterX1_E_Energy(const unsigned int &i) const {return fClusterX1_E_Energy[i];}//! + + // ClusterY1 Energy + inline unsigned short GetClusterY1MultEnergy() const {return fClusterY1_E_DetectorNbr.size();} + inline unsigned short GetClusterY1_E_DetectorNbr(const unsigned int &i) const {return fClusterY1_E_DetectorNbr[i];}//! + inline unsigned short GetClusterY1_E_StripNbr(const unsigned int &i) const {return fClusterY1_E_StripNbr[i];}//! + inline Double_t GetClusterY1_E_Energy(const unsigned int &i) const {return fClusterY1_E_Energy[i];}//! + + // ClusterX2 Energy + inline unsigned short GetClusterX2MultEnergy() const {return fClusterX2_E_DetectorNbr.size();} + inline unsigned short GetClusterX2_E_DetectorNbr(const unsigned int &i) const {return fClusterX2_E_DetectorNbr[i];}//! + inline unsigned short GetClusterX2_E_StripNbr(const unsigned int &i) const {return fClusterX2_E_StripNbr[i];}//! + inline Double_t GetClusterX2_E_Energy(const unsigned int &i) const {return fClusterX2_E_Energy[i];}//! + + // ClusterY2 Energy + inline unsigned short GetClusterY2MultEnergy() const {return fClusterY2_E_DetectorNbr.size();} + inline unsigned short GetClusterY2_E_DetectorNbr(const unsigned int &i) const {return fClusterY2_E_DetectorNbr[i];}//! + inline unsigned short GetClusterY2_E_StripNbr(const unsigned int &i) const {return fClusterY2_E_StripNbr[i];}//! + inline Double_t GetClusterY2_E_Energy(const unsigned int &i) const {return fClusterY2_E_Energy[i];}//! + + + + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TTOGAXSI_SIData,1) // TOGAXSI_SIData structure +}; + +#endif diff --git a/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.cxx b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.cxx new file mode 100644 index 000000000..17906f19e --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.cxx @@ -0,0 +1,1941 @@ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_SI Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TTOGAXSI_SIPhysics.h" + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> +using namespace std; + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "NPDetectorFactory.h" +#include "NPOptionManager.h" + +#include "Math/Transform3D.h" +#include "Math/RotationZYX.h" +#include "NPSystemOfUnits.h" +using namespace NPUNITS; + +// ROOT +#include "TChain.h" + +ClassImp(TTOGAXSI_SIPhysics) + + +/////////////////////////////////////////////////////////////////////////// +/* +TTOGAXSI_SIPhysics::TTOGAXSI_SIPhysics() + : m_EventData(new TTOGAXSI_SIData), + m_PreTreatedData(new TTOGAXSI_SIData), + m_EventPhysics(this), + m_Spectra(0), + m_E_RAW_Threshold(0), // adc channels + m_E_Threshold(0), // MeV + m_NumberOfDetectors(0) { +} +*/ +TTOGAXSI_SIPhysics::TTOGAXSI_SIPhysics(){ + EventMultiplicity = 0; + EventMultiplicity_cluster = 0; + m_EventData = new TTOGAXSI_SIData; + m_PreTreatedData = new TTOGAXSI_SIData; + m_EventPhysics = this; + m_Spectra = NULL; + m_E_RAW_Threshold = 0; // adc channels + m_E_Threshold = 0; + + m_NumberOfInnerXDetectors = 0; + m_NumberOfInnerZDetectors = 0; + m_NumberOfOuterXDetectors = 0; + m_NumberOfOuterZDetectors = 0; + m_NumberOfClusterInnerDetectors = 0; + m_NumberOfClusterX1Detectors = 0; + m_NumberOfClusterY1Detectors = 0; + m_NumberOfClusterX2Detectors = 0; + m_NumberOfClusterY2Detectors = 0; + + m_MaximumStripMultiplicityAllowed = 10; + m_StripEnergyMatching = 0.100; + /////////////////// + //Inner Detector // + /////////////////// + //WaferX parameter + InnerX_Wafer_Length=78.4*mm; + InnerX_Wafer_Width=51*mm; + InnerX_Wafer_Thickness=0.1*mm; + + // PCB parameter + InnerX_PCB_Thickness=3*mm; + InnerX_Wafer_LongitudinalStrips = 255; +// InnerX_Wafer_LongitudinalStrips = 64; + InnerX_Wafer_TransverseStrips = 1; + + InnerX_PCB_Length = 84.9*mm; + InnerX_PCB_Width = 55.83*mm; + + //WaferZ parameter + InnerZ_Wafer_Length=78.4*mm; + InnerZ_Wafer_Width=51*mm; + InnerZ_Wafer_Thickness=0.1*mm; + + // PCB parameter + InnerZ_PCB_Thickness=3*mm; + InnerZ_Wafer_LongitudinalStrips = 1; + InnerZ_Wafer_TransverseStrips = 392; +// InnerZ_Wafer_TransverseStrips = 98; + + InnerZ_PCB_Length = 84.9*mm; + InnerZ_PCB_Width = 55.83*mm; + + /////////////////// + //Outer Detector // + /////////////////// + //WaferX parameter + OuterX_Wafer_Length=78.4*mm; + OuterX_Wafer_Width=51*mm; + OuterX_Wafer_Thickness=0.1*mm; + + // PCB parameter + OuterX_PCB_Thickness=3*mm; + OuterX_Wafer_LongitudinalStrips = 392; +// OuterX_Wafer_LongitudinalStrips = 98; + OuterX_Wafer_TransverseStrips = 1; + + OuterX_PCB_Length = 107.16*mm; + OuterX_PCB_Width = 84.9*mm; + OuterX_PCB_gap = 3.5*mm; + + //WaferZ parameter + OuterZ_Wafer_Length=78.4*mm; + OuterZ_Wafer_Width=51*mm; + OuterZ_Wafer_Thickness=0.1*mm; + + // PCB parameter + OuterZ_PCB_Thickness=3*mm; + OuterZ_Wafer_LongitudinalStrips = 1; + OuterZ_Wafer_TransverseStrips = 255; +// OuterZ_Wafer_TransverseStrips = 64; + + OuterZ_PCB_Length = 108.6*mm; + OuterZ_PCB_Width = 83.3*mm; + OuterZ_PCB_gap = 3.5*mm; + + ///////////////////// + //Cluster Detector // + ///////////////////// + //Wafer parameter + ClusterInner_Wafer_Base = 56*mm; + ClusterInner_Wafer_Top = 7*mm; + ClusterInner_Wafer_Height = 80*mm; + ClusterInner_Wafer_Thickness = 0.1*mm; + + ClusterInner_ActiveWafer_Base = 88.*mm; + ClusterInner_ActiveWafer_Top = 12.*mm; + ClusterInner_ActiveWafer_Height = 66.*mm; + ClusterInner_ActiveWafer_Thickness = 100*mm; + + ClusterInner_Wafer_TransverseStrips = 128; + ClusterInner_Wafer_LongitudinalStrips = 128; + + + //Cluster X Parameter + ClusterX_Wafer_Length=78.4*mm; + ClusterX_Wafer_Width=51*mm; + ClusterX_Wafer_Thickness=0.1*mm; + + // PCB parameter + ClusterX_PCB_Thickness=3*mm; + ClusterX_Wafer_LongitudinalStrips = 392; +// ClusterX_Wafer_LongitudinalStrips = 98; + ClusterX_Wafer_TransverseStrips = 1; + + ClusterX_PCB_Length = 107.16*mm; + ClusterX_PCB_Width = 84.9*mm; + ClusterX_PCB_gap = 3.5*mm; + + + //Cluster Y Parameter + ClusterY_Wafer_Length=78.4*mm; + ClusterY_Wafer_Width=51*mm; + ClusterY_Wafer_Thickness=0.1*mm; + + // PCB parameter + ClusterY_PCB_Thickness=3*mm; + ClusterY_Wafer_LongitudinalStrips = 1; + ClusterY_Wafer_TransverseStrips = 255; +// ClusterY_Wafer_TransverseStrips = 64; + + ClusterY_PCB_Length = 108.6*mm; + ClusterY_PCB_Width = 83.3*mm; + ClusterY_PCB_gap = 3.5*mm; +} + +/////////////////////////////////////////////////////////////////////////// +/// A usefull method to bundle all operation to add a detector +/* void TTOGAXSI_SIPhysics::AddDetector(TVector3 , string ){ + // In That simple case nothing is done + // Typically for more complex detector one would calculate the relevant + // positions (stripped silicon) or angles (gamma array) + m_NumberOfDetectors++; +} +*/ + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddInnerXDetector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfInnerXDetectors++; + cout << m_NumberOfInnerXDetectors << endl; + + double LongitudinalPitch = InnerX_Wafer_Width/InnerX_Wafer_LongitudinalStrips; + + // Vector C position of detector face center + double Recess = 0.5*InnerX_Wafer_Thickness; + TVector3 C(0,R-Recess,Z); + C.RotateZ(-Phi); + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + + //Position inner silicon detector + //Moving to corner of the silicon + TVector3 P_1_1 = C + -V*0.5*InnerX_Wafer_Width + +V*0.5*LongitudinalPitch; // middle of strip + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<InnerX_Wafer_LongitudinalStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + P = P_1_1 + Ref + i*V*LongitudinalPitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + +// cout << i << ": " << lineX[0] << endl; + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_InnerXStripPositionX.push_back(OneDetectorStripPositionX); + m_InnerXStripPositionY.push_back(OneDetectorStripPositionY); + m_InnerXStripPositionZ.push_back(OneDetectorStripPositionZ); + +} + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddInnerZDetector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfInnerZDetectors++; + + double TransversePitch = InnerZ_Wafer_Length/InnerZ_Wafer_TransverseStrips; + + // Vector C position of detector face center + double Recess = 0.5*InnerZ_Wafer_Thickness; + TVector3 C(0,R-Recess,Z); + C.RotateZ(-Phi); + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + + //Position inner silicon detector + //Moving to corner of the silicon +/* + TVector3 P_1_1 = C + -U*0.5*InnerZ_Wafer_Length + +U*0.5*TransversePitch // middle of strip + -V*0.5*InnerZ_Wafer_Width + +V*0.5*LongitudinalPitch; // middle of strip +*/ + TVector3 P_1_1 = C + -U*0.5*InnerZ_Wafer_Length + +U*0.5*TransversePitch; // middle of strip + + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<InnerZ_Wafer_TransverseStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + P = P_1_1 + Ref + i*U*TransversePitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_InnerZStripPositionX.push_back(OneDetectorStripPositionX); + m_InnerZStripPositionY.push_back(OneDetectorStripPositionY); + m_InnerZStripPositionZ.push_back(OneDetectorStripPositionZ); + +} + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddOuterXDetector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfOuterXDetectors++; + + double LongitudinalPitch = OuterX_Wafer_Length/OuterX_Wafer_LongitudinalStrips; + + // Vector C position of detector face center + double Recess = 0.5*OuterX_Wafer_Thickness; + TVector3 C(0,R-Recess,Z); + C.RotateZ(-Phi); + + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + + //Position 1st outer silicon detector: + //Moving to corner of the silicon + TVector3 P_1_1 = C + -V*0.5*OuterX_Wafer_Length + +V*0.5*LongitudinalPitch; // middle of strip + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<OuterX_Wafer_LongitudinalStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + P = P_1_1 + Ref + i*V*LongitudinalPitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + + cout << i << ": " << lineX[0] << endl; + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_OuterXStripPositionX.push_back(OneDetectorStripPositionX); + m_OuterXStripPositionY.push_back(OneDetectorStripPositionY); + m_OuterXStripPositionZ.push_back(OneDetectorStripPositionZ); + + // Position 2nd outer silicon outer detector + // Moving to corner of the silicon + P_1_1 = C + -V*0.5*OuterX_Wafer_Length + +V*0.5*LongitudinalPitch; // middle of strip + + for(int i=0; i<OuterX_Wafer_LongitudinalStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + P = P_1_1 + Ref + i*V*LongitudinalPitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + + cout << i << ": " << lineX[0] << endl; + + m_OuterXStripPositionX[m_NumberOfOuterXDetectors-1].push_back(lineX); + m_OuterXStripPositionY[m_NumberOfOuterXDetectors-1].push_back(lineY); + m_OuterXStripPositionZ[m_NumberOfOuterXDetectors-1].push_back(lineZ); + + } + +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddOuterZDetector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfOuterZDetectors++; + + double TransversePitch = OuterZ_Wafer_Width/OuterZ_Wafer_TransverseStrips; + + // Vector C position of detector face center + double Recess = 0.5*OuterZ_Wafer_Thickness; + TVector3 C(0,R-Recess,Z); + C.RotateZ(-Phi); + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + + //Position 1st outer silicon detector: + //Moving to corner of the silicon + TVector3 P_1_1 = C + -U*0.5*OuterZ_PCB_gap //In between wafer + -U*OuterZ_Wafer_Width // External wafer edge + +U*0.5*TransversePitch; // middle of strip + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<OuterZ_Wafer_TransverseStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + P = P_1_1 + Ref + i*U*TransversePitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_OuterZStripPositionX.push_back(OneDetectorStripPositionX); + m_OuterZStripPositionY.push_back(OneDetectorStripPositionY); + m_OuterZStripPositionZ.push_back(OneDetectorStripPositionZ); + + // Position 2nd outer silicon outer detector + // Moving to corner of the silicon + P_1_1 = C + +U*0.5*OuterZ_PCB_gap //In between wafer + +U*0.5*TransversePitch; // middle of strip + + for(int i=0; i<OuterZ_Wafer_TransverseStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + P = P_1_1 + Ref + i*U*TransversePitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + + + m_OuterZStripPositionX[m_NumberOfOuterZDetectors-1].push_back(lineX); + m_OuterZStripPositionY[m_NumberOfOuterZDetectors-1].push_back(lineY); + m_OuterZStripPositionZ[m_NumberOfOuterZDetectors-1].push_back(lineZ); + + } + +} + + +/////////////////////////////////////////////////////////////////////////// +/* +void TTOGAXSI_SIPhysics::AddClusterDetector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfClusterDetectors++; + + double LongitudinalPitch = Cluster_ActiveWafer_Height/Cluster_ActiveWafer_LongitudinalStrips; + double TransversePitch = Cluster_ActiveWafer_Base/Cluster_ActiveWafer_TransverseStrips; + + // Vector C position of detector face center + //double Recess = (Inner_PCB_Thickness-Inner_PCB_Step-Inner_Wafer_Thickness); + double Recess = (Cluster_ActiveWafer_Thickness); + TVector3 C(0,R+Recess,Z); + C.RotateZ(-Phi); + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + + //Position inner silicon detector + //Moving to corner of the silicon + TVector3 P_1_1 = C + -U*0.5*Cluster_ActiveWafer_Height + +U*0.5*TransversePitch // middle of strip + -V*0.5*Cluster_ActiveWafer_Base + +V*0.5*LongitudinalPitch; // middle of strip + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<Cluster_ActiveWafer_TransverseStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + for(int j=0; j<Cluster_ActiveWafer_LongitudinalStrips; j++){ + P = P_1_1 + Ref + i*U*TransversePitch + j*V*LongitudinalPitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + } + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_ClusterStripPositionX.push_back(OneDetectorStripPositionX); + m_ClusterStripPositionY.push_back(OneDetectorStripPositionY); + m_ClusterStripPositionZ.push_back(OneDetectorStripPositionZ); + +} +*/ + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddClusterX1Detector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfClusterX1Detectors++; + + double LongitudinalPitch = ClusterX_Wafer_Length/ClusterX_Wafer_LongitudinalStrips; + + + // Vector C position of detector face center + double Recess = 0.5*ClusterX_Wafer_Thickness; + TVector3 C(R,0,Z - Recess); +// TVector3 C(0,R,Z); + + C.RotateZ(-Phi); + cout << "C vector: " << C.x() << endl; + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + + cout << "W vector: " << W.y() << endl; + + + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + cout << "V vector: " << V.x() << endl; + + //Position 1st outer silicon detector: + //Moving to corner of the silicon + TVector3 P_1_1 = C + -V*0.5*ClusterX_Wafer_Length + +V*0.5*LongitudinalPitch; // middle of strip + + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<ClusterX_Wafer_LongitudinalStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + P = P_1_1 + i*V*LongitudinalPitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + + cout << i << ": " << lineX[0] << endl; + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_ClusterX1StripPositionX.push_back(OneDetectorStripPositionX); + m_ClusterX1StripPositionY.push_back(OneDetectorStripPositionY); + m_ClusterX1StripPositionZ.push_back(OneDetectorStripPositionZ); + + // Position 2nd outer silicon outer detector + // Moving to corner of the silicon + P_1_1 = C + -V*0.5*ClusterX_Wafer_Length + +V*0.5*LongitudinalPitch; // middle of strip + + for(int i=0; i<ClusterX_Wafer_LongitudinalStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + P = P_1_1 + i*V*LongitudinalPitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + +// cout << i << ": " << lineX[0] << endl; + + m_ClusterX1StripPositionX[m_NumberOfClusterX1Detectors-1].push_back(lineX); + m_ClusterX1StripPositionY[m_NumberOfClusterX1Detectors-1].push_back(lineY); + m_ClusterX1StripPositionZ[m_NumberOfClusterX1Detectors-1].push_back(lineZ); + + } + +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddClusterY1Detector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfClusterY1Detectors++; + + double TransversePitch = ClusterY_Wafer_Width/ClusterY_Wafer_TransverseStrips; + + // Vector C position of detector face center + double Recess = 0.5*ClusterY_Wafer_Thickness; + TVector3 C(R,0,Z-Recess); + + C.RotateZ(-Phi); + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + + //Position 1st outer silicon detector: + //Moving to corner of the silicon + TVector3 P_1_1 = C + -W*0.5*ClusterY_PCB_gap //In between wafer + -W*ClusterY_Wafer_Width + +W*0.5*TransversePitch; // middle of strip + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<ClusterY_Wafer_TransverseStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + P = P_1_1 + i*W*TransversePitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + +// cout << i << ": " << lineY[0] << endl; + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_ClusterY1StripPositionX.push_back(OneDetectorStripPositionX); + m_ClusterY1StripPositionY.push_back(OneDetectorStripPositionY); + m_ClusterY1StripPositionZ.push_back(OneDetectorStripPositionZ); + + // Position 2nd outer silicon outer detector + // Moving to corner of the silicon + P_1_1 = C + +W*0.5*ClusterY_PCB_gap //In between wafer + +W*0.5*TransversePitch; // middle of strip + + for(int i=0; i<ClusterY_Wafer_TransverseStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + P = P_1_1 + i*W*TransversePitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + +// cout << i << ": " << lineY[0] << endl; + + m_ClusterY1StripPositionX[m_NumberOfClusterY1Detectors-1].push_back(lineX); + m_ClusterY1StripPositionY[m_NumberOfClusterY1Detectors-1].push_back(lineY); + m_ClusterY1StripPositionZ[m_NumberOfClusterY1Detectors-1].push_back(lineZ); + + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddClusterX2Detector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfClusterX2Detectors++; + + double LongitudinalPitch = ClusterX_Wafer_Length/ClusterX_Wafer_LongitudinalStrips; + + // Vector C position of detector face center + double Recess = 0.5*ClusterX_Wafer_Thickness; + TVector3 C(R,0,Z-Recess); +// TVector3 C(0,R,Z); + C.RotateZ(-Phi); + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + + //Position 1st outer silicon detector: + //Moving to corner of the silicon + TVector3 P_1_1 = C + -V*0.5*ClusterX_Wafer_Length + +V*0.5*LongitudinalPitch; // middle of strip + + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<ClusterX_Wafer_LongitudinalStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + P = P_1_1 + i*V*LongitudinalPitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + +// cout << i << ": " << lineX[0] << endl; + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_ClusterX2StripPositionX.push_back(OneDetectorStripPositionX); + m_ClusterX2StripPositionY.push_back(OneDetectorStripPositionY); + m_ClusterX2StripPositionZ.push_back(OneDetectorStripPositionZ); + + // Position 2nd outer silicon outer detector + // Moving to corner of the silicon + P_1_1 = C + -V*0.5*ClusterX_Wafer_Length + +V*0.5*LongitudinalPitch; // middle of strip + + for(int i=0; i<ClusterX_Wafer_LongitudinalStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + P = P_1_1 + i*V*LongitudinalPitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + +// cout << i << ": " << lineX[0] << endl; + + m_ClusterX2StripPositionX[m_NumberOfClusterX2Detectors-1].push_back(lineX); + m_ClusterX2StripPositionY[m_NumberOfClusterX2Detectors-1].push_back(lineY); + m_ClusterX2StripPositionZ[m_NumberOfClusterX2Detectors-1].push_back(lineZ); + + } + +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddClusterY2Detector(double R, double Z, double Phi, TVector3 Ref){ + m_NumberOfClusterY2Detectors++; + + double TransversePitch = ClusterY_Wafer_Width/ClusterY_Wafer_TransverseStrips; + + // Vector C position of detector face center + double Recess = 0.5*ClusterY_Wafer_Thickness; + TVector3 C(R,0,Z-Recess); + C.RotateZ(-Phi); + + + // Vector W normal to detector face (pointing to the back) + TVector3 W(0,1,0); + W.RotateZ(-Phi); + // Vector U on detector face (parallel to Z axis/longitudinal strips) + TVector3 U = TVector3(0,0,1); + // Vector V on detector face (parallel to transverse strips) + TVector3 V = W.Cross(U); + + //Position 1st outer silicon detector: + //Moving to corner of the silicon + TVector3 P_1_1 = C + -W*0.5*ClusterY_PCB_gap //In between wafer + -W*ClusterY_Wafer_Width + +W*0.5*TransversePitch; // middle of strip + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneDetectorStripPositionX; + vector<vector<double>> OneDetectorStripPositionY; + vector<vector<double>> OneDetectorStripPositionZ; + + TVector3 P; + for(int i=0; i<ClusterY_Wafer_TransverseStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + P = P_1_1 + i*W*TransversePitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + + + OneDetectorStripPositionX.push_back(lineX); + OneDetectorStripPositionY.push_back(lineY); + OneDetectorStripPositionZ.push_back(lineZ); + } + + m_ClusterY2StripPositionX.push_back(OneDetectorStripPositionX); + m_ClusterY2StripPositionY.push_back(OneDetectorStripPositionY); + m_ClusterY2StripPositionZ.push_back(OneDetectorStripPositionZ); + + // Position 2nd outer silicon outer detector + // Moving to corner of the silicon + P_1_1 = C + +W*0.5*ClusterY_PCB_gap //In between wafer + +W*0.5*TransversePitch; // middle of strip + + for(int i=0; i<ClusterY_Wafer_TransverseStrips; i++){ + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + P = P_1_1 + i*W*TransversePitch; + lineX.push_back(P.X()); + lineY.push_back(P.Y()); + lineZ.push_back(P.Z()); + + + m_ClusterY2StripPositionX[m_NumberOfClusterY2Detectors-1].push_back(lineX); + m_ClusterY2StripPositionY[m_NumberOfClusterY2Detectors-1].push_back(lineY); + m_ClusterY2StripPositionZ[m_NumberOfClusterY2Detectors-1].push_back(lineZ); + + } + +} + + + + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetInnerXPositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetInnerXStripPositionX(DetectorNumberInnerX[i], InnerXStrip[i], 1), + GetInnerXStripPositionY(DetectorNumberInnerX[i], InnerXStrip[i], 1), + GetInnerXStripPositionZ(DetectorNumberInnerX[i], InnerXStrip[i], 1)); + + return Position; +} + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetInnerZPositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetInnerZStripPositionX(DetectorNumberInnerZ[i], InnerZStrip[i], 1), + GetInnerZStripPositionY(DetectorNumberInnerZ[i], InnerZStrip[i], 1), + GetInnerZStripPositionZ(DetectorNumberInnerZ[i], InnerZStrip[i], 1)); + + return Position; +} + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetOuterXPositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetOuterXStripPositionX(DetectorNumberOuterX[i], OuterXStrip[i], 1), + GetOuterXStripPositionY(DetectorNumberOuterX[i], OuterXStrip[i], 1), + GetOuterXStripPositionZ(DetectorNumberOuterX[i], OuterXStrip[i], 1)); + + return Position; +} + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetOuterZPositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetOuterZStripPositionX(DetectorNumberOuterZ[i], OuterZStrip[i], 1), + GetOuterZStripPositionY(DetectorNumberOuterZ[i], OuterZStrip[i], 1), + GetOuterZStripPositionZ(DetectorNumberOuterZ[i], OuterZStrip[i], 1)); + + return Position; +} + +/////////////////////////////////////////////////////////////////////////// +/* +TVector3 TTOGAXSI_SIPhysics::GetClusterPositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetClusterStripPositionX(DetectorNumber[i], ClusterStripT[i], ClusterStripL[i]), + GetClusterStripPositionY(DetectorNumber[i], ClusterStripT[i], ClusterStripL[i]), + GetClusterStripPositionZ(DetectorNumber[i], ClusterStripT[i], ClusterStripL[i])); + + return Position; +} +*/ + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetClusterX1PositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetClusterX1StripPositionX(DetectorNumberClusterX1[i], ClusterX1Strip[i], 1), + GetClusterX1StripPositionY(DetectorNumberClusterX1[i], ClusterX1Strip[i], 1), + GetClusterX1StripPositionZ(DetectorNumberClusterX1[i], ClusterX1Strip[i], 1)); + + return Position; +} + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetClusterY1PositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetClusterY1StripPositionX(DetectorNumberClusterY1[i], ClusterY1Strip[i], 1), + GetClusterY1StripPositionY(DetectorNumberClusterY1[i], ClusterY1Strip[i], 1), + GetClusterY1StripPositionZ(DetectorNumberClusterY1[i], ClusterY1Strip[i], 1)); + + return Position; +} + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetClusterX2PositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetClusterX2StripPositionX(DetectorNumberClusterX2[i], ClusterX2Strip[i], 1), + GetClusterX2StripPositionY(DetectorNumberClusterX2[i], ClusterX2Strip[i], 1), + GetClusterX2StripPositionZ(DetectorNumberClusterX2[i], ClusterX2Strip[i], 1)); + + return Position; +} + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetClusterY2PositionOfInteraction(const int i){ + TVector3 Position = TVector3( + GetClusterY2StripPositionX(DetectorNumberClusterY2[i], ClusterY2Strip[i], 1), + GetClusterY2StripPositionY(DetectorNumberClusterY2[i], ClusterY2Strip[i], 1), + GetClusterY2StripPositionZ(DetectorNumberClusterY2[i], ClusterY2Strip[i], 1)); + + return Position; +} + + +/////////////////////////////////////////////////////////////////////////// +TVector3 TTOGAXSI_SIPhysics::GetDetectorNormal(const int i){ + return TVector3(0,0,0); +} + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::BuildPhysicalEvent() { + // apply thresholds and calibration + PreTreat(); + + + vector<TVector2> inner = MatchInner(); + vector<TVector2> outer = MatchOuter(); + vector<TVector2> cluster1 = MatchCluster1(); + vector<TVector2> cluster2 = MatchCluster2(); + + +// cout << inner.size() << endl; +// cout << outer.size() << endl; + + for(unsigned int i=0; i<inner.size(); i++){ + int N = m_PreTreatedData->GetInnerX_E_DetectorNbr(inner[i].X()); + int innerX = m_PreTreatedData->GetInnerX_E_StripNbr(inner[i].X()); + int innerZ = m_PreTreatedData->GetInnerZ_E_StripNbr(inner[i].Y()); + + double innerXE = m_PreTreatedData->GetInnerX_E_Energy(inner[i].X()); + double innerZE = m_PreTreatedData->GetInnerZ_E_Energy(inner[i].Y()); + // look for outer + double outerXE = 0; + double outerZE = 0; + int outerX=0; + int outerZ=0; +// cout << outer.size() << endl; + for(unsigned int j=0; j<outer.size(); j++){ + if(m_PreTreatedData->GetInnerX_E_DetectorNbr(outer[j].X())==N){ + outerXE = m_PreTreatedData->GetOuterX_E_Energy(outer[j].X()); + outerZE = m_PreTreatedData->GetOuterZ_E_Energy(outer[j].Y()); + outerX = m_PreTreatedData->GetOuterX_E_StripNbr(outer[j].X()); + outerZ = m_PreTreatedData->GetOuterZ_E_StripNbr(outer[j].Y()); + } + } + + if(outerXE) { + + EventMultiplicity++; + DetectorNumberInnerX.push_back(N); + DetectorNumberInnerZ.push_back(N); + DetectorNumberOuterX.push_back(N); + DetectorNumberOuterZ.push_back(N); + + InnerXStrip.push_back(innerX); + InnerXE.push_back(innerXE); + InnerXPosX.push_back(GetInnerXPositionOfInteraction(EventMultiplicity-1).x()); + InnerXPosY.push_back(GetInnerXPositionOfInteraction(EventMultiplicity-1).y()); + InnerXPosZ.push_back(GetInnerXPositionOfInteraction(EventMultiplicity-1).z()); + + InnerZStrip.push_back(innerZ); + InnerZE.push_back(innerZE); + InnerZPosX.push_back(GetInnerZPositionOfInteraction(EventMultiplicity-1).x()); + InnerZPosY.push_back(GetInnerZPositionOfInteraction(EventMultiplicity-1).y()); + InnerZPosZ.push_back(GetInnerZPositionOfInteraction(EventMultiplicity-1).z()); + + + OuterXStrip.push_back(outerX); + OuterXE.push_back(outerXE); + OuterXPosX.push_back(GetOuterXPositionOfInteraction(EventMultiplicity-1).x()); + OuterXPosY.push_back(GetOuterXPositionOfInteraction(EventMultiplicity-1).y()); + OuterXPosZ.push_back(GetOuterXPositionOfInteraction(EventMultiplicity-1).z()); + + + OuterZStrip.push_back(outerZ); + OuterZE.push_back(outerZE); + OuterZPosX.push_back(GetOuterZPositionOfInteraction(EventMultiplicity-1).x()); + OuterZPosY.push_back(GetOuterZPositionOfInteraction(EventMultiplicity-1).y()); + OuterZPosZ.push_back(GetOuterZPositionOfInteraction(EventMultiplicity-1).z()); + + } + + } + + + for(unsigned int i=0; i<cluster1.size(); i++){ + int N_cluster = m_PreTreatedData->GetClusterX1_E_DetectorNbr(cluster1[i].X()); + int clusterX1 = m_PreTreatedData->GetClusterX1_E_StripNbr(cluster1[i].X()); + int clusterY1 = m_PreTreatedData->GetClusterY1_E_StripNbr(cluster1[i].Y()); + + double clusterX1E = m_PreTreatedData->GetClusterX1_E_Energy(cluster1[i].X()); + double clusterY1E = m_PreTreatedData->GetClusterY1_E_Energy(cluster1[i].Y()); + + + // look for outer + double clusterX2E = 0; + double clusterY2E = 0; + int clusterX2=0; + int clusterY2=0; + + for(unsigned int j=0; j<cluster2.size(); j++){ + if(m_PreTreatedData->GetClusterX1_E_DetectorNbr(cluster2[j].X())==N_cluster){ + clusterX2E = m_PreTreatedData->GetClusterX2_E_Energy(cluster2[j].X()); + clusterY2E = m_PreTreatedData->GetClusterY2_E_Energy(cluster2[j].Y()); + clusterX2 = m_PreTreatedData->GetClusterX2_E_StripNbr(cluster2[j].X()); + clusterY2 = m_PreTreatedData->GetClusterY2_E_StripNbr(cluster2[j].Y()); + } + } + + if(clusterX2E) { + EventMultiplicity_cluster++; + DetectorNumberClusterX1.push_back(N_cluster); + DetectorNumberClusterY1.push_back(N_cluster); + DetectorNumberClusterX2.push_back(N_cluster); + DetectorNumberClusterY2.push_back(N_cluster); + + + ClusterX1Strip.push_back(clusterX1); + ClusterX1E.push_back(clusterX1E); + ClusterX1PosX.push_back(GetClusterX1PositionOfInteraction(EventMultiplicity_cluster-1).x()); + ClusterX1PosY.push_back(GetClusterX1PositionOfInteraction(EventMultiplicity_cluster-1).y()); + ClusterX1PosZ.push_back(GetClusterX1PositionOfInteraction(EventMultiplicity_cluster-1).z()); + + ClusterY1Strip.push_back(clusterY1); + ClusterY1E.push_back(clusterY1E); + ClusterY1PosX.push_back(GetClusterY1PositionOfInteraction(EventMultiplicity_cluster-1).x()); + ClusterY1PosY.push_back(GetClusterY1PositionOfInteraction(EventMultiplicity_cluster-1).y()); + ClusterY1PosZ.push_back(GetClusterY1PositionOfInteraction(EventMultiplicity_cluster-1).z()); + + ClusterX2Strip.push_back(clusterX2); + ClusterX2E.push_back(clusterX2E); + ClusterX2PosX.push_back(GetClusterX2PositionOfInteraction(EventMultiplicity_cluster-1).x()); + ClusterX2PosY.push_back(GetClusterX2PositionOfInteraction(EventMultiplicity_cluster-1).y()); + ClusterX2PosZ.push_back(GetClusterX2PositionOfInteraction(EventMultiplicity_cluster-1).z()); + + ClusterY2Strip.push_back(clusterY2); + ClusterY2E.push_back(clusterY2E); + ClusterY2PosX.push_back(GetClusterY2PositionOfInteraction(EventMultiplicity_cluster-1).x()); + ClusterY2PosY.push_back(GetClusterY2PositionOfInteraction(EventMultiplicity_cluster-1).y()); + ClusterY2PosZ.push_back(GetClusterY2PositionOfInteraction(EventMultiplicity_cluster-1).z()); + + } + + } + + +} + + +/////////////////////////////////////////////////////////////////////////// +vector<TVector2> TTOGAXSI_SIPhysics::MatchInner(){ + vector<TVector2> ArrayOfGoodCouple; + + + static unsigned int m_XEMult, m_ZEMult; + m_XEMult = m_PreTreatedData->GetInnerXMultEnergy(); + m_ZEMult = m_PreTreatedData->GetInnerZMultEnergy(); + + + if(m_XEMult>m_MaximumStripMultiplicityAllowed || m_ZEMult>m_MaximumStripMultiplicityAllowed){ + return ArrayOfGoodCouple; + } + + for(unsigned int i=0; i<m_XEMult; i++){ +// cout << "_____X: " << i << endl; + for(unsigned int j=0; j<m_ZEMult; j++){ + + // Declaration of variable for clarity + int XDetNbr = m_PreTreatedData->GetInnerX_E_DetectorNbr(i); + int YDetNbr = m_PreTreatedData->GetInnerZ_E_DetectorNbr(j); + +// cout << "X Det Inner: " << XDetNbr << endl; +// cout << "Z Det Inner: " << YDetNbr << endl; + +// cout << "X Energy Inner: " << m_PreTreatedData->GetInnerX_E_Energy(i) << endl; +// cout << "Z Energy Inner : " << m_PreTreatedData->GetInnerZ_E_Energy(i) << endl; +// cout << "Diff Energy Inner: " << abs(m_PreTreatedData->GetInnerX_E_Energy(i)-m_PreTreatedData->GetInnerZ_E_Energy(i))/2 << endl; + + // if same detector check energy + if(XDetNbr == YDetNbr){ + // Declaration of variable for clarity + double XE = m_PreTreatedData->GetInnerX_E_Energy(i); + double ZE = m_PreTreatedData->GetInnerZ_E_Energy(j); + + // look if energy matches + if(abs(XE-ZE)/2.<m_StripEnergyMatching){ + ArrayOfGoodCouple.push_back(TVector2(i,j)); + } + } + } + } + + return ArrayOfGoodCouple; +} + +/////////////////////////////////////////////////////////////////////////// +vector<TVector2> TTOGAXSI_SIPhysics::MatchOuter(){ + vector<TVector2> ArrayOfGoodCouple; + + static unsigned int m_XEMult, m_ZEMult; + m_XEMult = m_PreTreatedData->GetOuterXMultEnergy(); + m_ZEMult = m_PreTreatedData->GetOuterZMultEnergy(); + + if(m_XEMult>m_MaximumStripMultiplicityAllowed || m_ZEMult>m_MaximumStripMultiplicityAllowed){ + return ArrayOfGoodCouple; + } + + for(unsigned int i=0; i<m_XEMult; i++){ + for(unsigned int j=0; j<m_ZEMult; j++){ + + // Declaration of variable for clarity + int XDetNbr = m_PreTreatedData->GetOuterX_E_DetectorNbr(i); + int YDetNbr = m_PreTreatedData->GetOuterZ_E_DetectorNbr(j); + + // if same detector check energy + if(XDetNbr == YDetNbr){ + // Declaration of variable for clarity + double XE = m_PreTreatedData->GetOuterX_E_Energy(i); + double ZE = m_PreTreatedData->GetOuterZ_E_Energy(j); + + // look if energy matches + if(abs(XE-ZE)/2.<m_StripEnergyMatching){ + ArrayOfGoodCouple.push_back(TVector2(i,j)); + } + } + } + } + + return ArrayOfGoodCouple; +} + +/////////////////////////////////////////////////////////////////////////// +vector<TVector2> TTOGAXSI_SIPhysics::MatchCluster1(){ + vector<TVector2> ArrayOfGoodCouple; + +// cout << "______Event start________" << endl; + + static unsigned int m_XEMult, m_YEMult; + m_XEMult = m_PreTreatedData->GetClusterX1MultEnergy(); + m_YEMult = m_PreTreatedData->GetClusterY1MultEnergy(); + +// cout << m_XEMult << endl; +// cout << m_ZEMult << endl; + + if(m_XEMult>m_MaximumStripMultiplicityAllowed || m_YEMult>m_MaximumStripMultiplicityAllowed){ + return ArrayOfGoodCouple; + } + + for(unsigned int i=0; i<m_XEMult; i++){ +// cout << "_____X: " << i << endl; + for(unsigned int j=0; j<m_YEMult; j++){ + + // Declaration of variable for clarity + int XDetNbr = m_PreTreatedData->GetClusterX1_E_DetectorNbr(i); + int YDetNbr = m_PreTreatedData->GetClusterY1_E_DetectorNbr(j); + +// cout << "X Det: " << XDetNbr << endl; +// cout << "Y Det: " << YDetNbr << endl; + +// cout << "X Energy: " << m_PreTreatedData->GetClusterX1_E_Energy(i) << endl; +// cout << "Y Energy: " << m_PreTreatedData->GetClusterY1_E_Energy(i) << endl; +// cout << "Diff Energy: " << abs(m_PreTreatedData->GetClusterX1_E_Energy(i)-m_PreTreatedData->GetClusterY1_E_Energy(i))/2 << endl; + + // if same detector check energy + if(XDetNbr == YDetNbr){ + // Declaration of variable for clarity + double XE = m_PreTreatedData->GetClusterX1_E_Energy(i); + double YE = m_PreTreatedData->GetClusterY1_E_Energy(j); + + // look if energy matches + if(abs(XE-YE)/2.<m_StripEnergyMatching){ + ArrayOfGoodCouple.push_back(TVector2(i,j)); + } + } + } + } + + return ArrayOfGoodCouple; +} + + +/////////////////////////////////////////////////////////////////////////// +vector<TVector2> TTOGAXSI_SIPhysics::MatchCluster2(){ + vector<TVector2> ArrayOfGoodCouple; + +// cout << "______Event start________" << endl; + + static unsigned int m_XEMult, m_YEMult; + m_XEMult = m_PreTreatedData->GetClusterX2MultEnergy(); + m_YEMult = m_PreTreatedData->GetClusterY2MultEnergy(); + +// cout << m_XEMult << endl; +// cout << m_ZEMult << endl; + + if(m_XEMult>m_MaximumStripMultiplicityAllowed || m_YEMult>m_MaximumStripMultiplicityAllowed){ + return ArrayOfGoodCouple; + } + + for(unsigned int i=0; i<m_XEMult; i++){ +// cout << "_____X: " << i << endl; + for(unsigned int j=0; j<m_YEMult; j++){ + + // Declaration of variable for clarity + int XDetNbr = m_PreTreatedData->GetClusterX2_E_DetectorNbr(i); + int YDetNbr = m_PreTreatedData->GetClusterY2_E_DetectorNbr(j); + +// cout << "X Det Cluster 2: " << XDetNbr << endl; +// cout << "Y Det Cluster 2: " << YDetNbr << endl; + +// cout << "X Energy Cluster 2: " << m_PreTreatedData->GetClusterX2_E_Energy(i) << endl; +// cout << "Y Energy Cluster 2: " << m_PreTreatedData->GetClusterY2_E_Energy(i) << endl; +// cout << "Diff Energy Cluster 2: " << abs(m_PreTreatedData->GetClusterX2_E_Energy(i)-m_PreTreatedData->GetClusterY2_E_Energy(i))/2 << endl; + + // if same detector check energy + if(XDetNbr == YDetNbr){ + // Declaration of variable for clarity + double XE = m_PreTreatedData->GetClusterX2_E_Energy(i); + double YE = m_PreTreatedData->GetClusterY2_E_Energy(j); + + // look if energy matches + if(abs(XE-YE)/2.<m_StripEnergyMatching){ + ArrayOfGoodCouple.push_back(TVector2(i,j)); + } + } + } + } + + return ArrayOfGoodCouple; +} + + + + +/////////////////////////////////////////////////////////////////////////// +int TTOGAXSI_SIPhysics::CheckEvent(){ + //Check the size of the different elements + if(m_PreTreatedData->GetInnerXMultEnergy() == m_PreTreatedData->GetInnerZMultEnergy() ) + return 1; + else + return -1; +} + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::PreTreat() { + // This method typically applies thresholds and calibrations + // Migh + + // clear pre-treated object + ClearPreTreatedData(); + + // instantiate CalibrationManager + static CalibrationManager* Cal = CalibrationManager::getInstance(); + + ////// + // InnerX Energy + unsigned int sizeX = m_EventData->GetInnerXMultEnergy(); + for (UShort_t i = 0; i < sizeX ; ++i) { + if (m_EventData->GetInnerX_E_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetInnerX_E_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetInnerXE(m_EventData->GetInnerX_E_DetectorNbr(i), m_EventData->GetInnerX_E_StripNbr(i), Energy); + } + } + } + + // InnerZ Energy + unsigned int sizeZ = m_EventData->GetInnerZMultEnergy(); + for (UShort_t i = 0; i < sizeZ ; ++i) { + if (m_EventData->GetInnerZ_E_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetInnerZ_E_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetInnerZE(m_EventData->GetInnerZ_E_DetectorNbr(i), m_EventData->GetInnerZ_E_StripNbr(i), Energy); + } + } + } + + ////// + // OuterX Energy + sizeX = m_EventData->GetOuterXMultEnergy(); + for (UShort_t i = 0; i < sizeX ; ++i) { + if (m_EventData->GetOuterX_E_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetOuterX_E_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetOuterXE(m_EventData->GetOuterX_E_DetectorNbr(i), m_EventData->GetOuterX_E_StripNbr(i), Energy); + } + } + } + + // OuterZ Energy + sizeZ = m_EventData->GetOuterZMultEnergy(); + for (UShort_t i = 0; i < sizeZ ; ++i) { + if (m_EventData->GetOuterZ_E_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetOuterZ_E_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetOuterZE(m_EventData->GetOuterZ_E_DetectorNbr(i), m_EventData->GetOuterZ_E_StripNbr(i), Energy); + } + } + } + + ////// + // Cluster Stage Energy +/* + sizeFront = m_EventData->GetClusterMultTEnergy(); + for (UShort_t i = 0; i < sizeFront ; ++i) { + if (m_EventData->GetCluster_TE_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetCluster_TE_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetClusterTE(m_EventData->GetCluster_TE_DetectorNbr(i), m_EventData->GetCluster_TE_StripNbr(i), Energy); + } + } + } + + sizeBack = m_EventData->GetClusterMultLEnergy(); + for (UShort_t i = 0; i < sizeBack ; ++i) { + if (m_EventData->GetCluster_LE_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetCluster_LE_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetClusterLE(m_EventData->GetCluster_LE_DetectorNbr(i), m_EventData->GetCluster_LE_StripNbr(i), Energy); + } + } + } +*/ + + + // ClusterX1 Energy + unsigned int sizeClusterX1 = m_EventData->GetClusterX1MultEnergy(); + for (UShort_t i = 0; i < sizeClusterX1 ; ++i) { + if (m_EventData->GetClusterX1_E_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetClusterX1_E_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetClusterX1E(m_EventData->GetClusterX1_E_DetectorNbr(i), m_EventData->GetClusterX1_E_StripNbr(i), Energy); + } + } + } + + // ClusterY1 Energy + unsigned int sizeClusterY1 = m_EventData->GetClusterY1MultEnergy(); + for (UShort_t i = 0; i < sizeClusterY1 ; ++i) { + if (m_EventData->GetClusterY1_E_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetClusterY1_E_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetClusterY1E(m_EventData->GetClusterY1_E_DetectorNbr(i), m_EventData->GetClusterY1_E_StripNbr(i), Energy); + } + } + } + + // ClusterX2 Energy + unsigned int sizeClusterX2 = m_EventData->GetClusterX2MultEnergy(); + for (UShort_t i = 0; i < sizeClusterX2 ; ++i) { + if (m_EventData->GetClusterX2_E_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetClusterX2_E_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetClusterX2E(m_EventData->GetClusterX2_E_DetectorNbr(i), m_EventData->GetClusterX2_E_StripNbr(i), Energy); + } + } + } + + // ClusterY2 Energy + unsigned int sizeClusterY2 = m_EventData->GetClusterY2MultEnergy(); + for (UShort_t i = 0; i < sizeClusterY2 ; ++i) { + if (m_EventData->GetClusterY2_E_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = m_EventData->GetClusterY2_E_Energy(i); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetClusterY2E(m_EventData->GetClusterY2_E_DetectorNbr(i), m_EventData->GetClusterY2_E_StripNbr(i), Energy); + } + } + } + + +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigTOGAXSI_SI.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigTOGAXSI_SI.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigTOGAXSI_SI.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigTOGAXSI_SI.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer,DataBuffer,whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + string name = "ConfigTOGAXSI_SI"; + if (LineBuffer.compare(0, name.length(), name) == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus ) { + whatToDo=""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + } + + else if (whatToDo=="E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_RAW_Threshold << endl; + } + + else if (whatToDo=="E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_E_Threshold << endl; + } + + else if (whatToDo=="E_FRONTBACK_MATCHING") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatching = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripEnergyMatching << endl; + } + + else { + ReadingStatus = false; + } + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::Clear() { + + EventMultiplicity = 0; + EventMultiplicity_cluster = 0; + + //DSSD + //DetectorNumber.clear(); + DetectorNumberInnerX.clear(); + DetectorNumberInnerZ.clear(); + DetectorNumberOuterX.clear(); + DetectorNumberOuterZ.clear(); + DetectorNumberClusterX1.clear(); + DetectorNumberClusterY1.clear(); + DetectorNumberClusterX2.clear(); + DetectorNumberClusterY2.clear(); + + InnerXStrip.clear(); + InnerZStrip.clear(); + OuterXStrip.clear(); + OuterZStrip.clear(); + ClusterX1Strip.clear(); + ClusterY1Strip.clear(); + ClusterX2Strip.clear(); + ClusterY2Strip.clear(); +// ClusterStripT.clear(); +// ClusterStripL.clear(); + InnerXE.clear(); + InnerZE.clear(); + OuterXE.clear(); + OuterZE.clear(); + ClusterX1E.clear(); + ClusterY1E.clear(); + ClusterX2E.clear(); + ClusterY2E.clear(); +// ClusterTE.clear(); +// ClusterLE.clear(); + + //Position Information + InnerXPosX.clear(); + InnerXPosY.clear(); + InnerXPosZ.clear(); + InnerZPosX.clear(); + InnerZPosY.clear(); + InnerZPosZ.clear(); + OuterXPosX.clear(); + OuterXPosY.clear(); + OuterXPosZ.clear(); + OuterZPosX.clear(); + OuterZPosY.clear(); + OuterZPosZ.clear(); +/* + ClusterPosX.clear(); + ClusterPosY.clear(); + ClusterPosZ.clear(); +*/ + ClusterX1PosX.clear(); + ClusterX1PosY.clear(); + ClusterX1PosZ.clear(); + ClusterY1PosX.clear(); + ClusterY1PosY.clear(); + ClusterY1PosZ.clear(); + ClusterX2PosX.clear(); + ClusterX2PosY.clear(); + ClusterX2PosZ.clear(); + ClusterY2PosX.clear(); + ClusterY2PosY.clear(); + ClusterY2PosZ.clear(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::ReadConfiguration(NPL::InputParser parser) { + + + //InnerX Tracker + vector<NPL::InputBlock*> blocks_innerX = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","InnerX"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_innerX.size() << "inner X detectors found " << endl; + + vector<string> coord = {"Radius","Z","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_innerX.size() ; i++){ + if(blocks_innerX[i]->HasTokenList(coord)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI inner X detector " << i+1 << endl; + + double R = blocks_innerX[i]->GetDouble("Radius","mm"); + double Z = blocks_innerX[i]->GetDouble("Z","mm"); + double Phi = blocks_innerX[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_innerX[i]->GetTVector3("Ref","mm"); + AddInnerXDetector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting on " << i+1 << " inner block " <<endl; + exit(1); + } + } + + //InnerZ Tracker + vector<NPL::InputBlock*> blocks_innerZ = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","InnerZ"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_innerZ.size() << "inner Z detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_innerZ.size() ; i++){ + if(blocks_innerZ[i]->HasTokenList(coord)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI inner Z detector " << i+1 << endl; + + double R = blocks_innerZ[i]->GetDouble("Radius","mm"); + double Z = blocks_innerZ[i]->GetDouble("Z","mm"); + double Phi = blocks_innerZ[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_innerZ[i]->GetTVector3("Ref","mm"); + AddInnerZDetector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting on " << i+1 << " inner block " <<endl; + exit(1); + } + } + + + //OuterX Tracker + vector<NPL::InputBlock*> blocks_outerX = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","OuterX"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_outerX.size() << "outer X detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_outerX.size() ; i++){ + if(blocks_outerX[i]->HasTokenList(coord)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI outer X detector " << i+1 << endl; + + double R = blocks_outerX[i]->GetDouble("Radius","mm"); + double Z = blocks_outerX[i]->GetDouble("Z","mm"); + double Phi = blocks_outerX[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_outerX[i]->GetTVector3("Ref","mm"); + AddOuterXDetector(R,Z,Phi,Ref); + } + else{ + + cout << "ERROR: check your input file formatting on " << i+1 << " outer block " <<endl; + exit(1); + } + } + + + //OuterZ Tracker + vector<NPL::InputBlock*> blocks_outerZ = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","OuterZ"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_outerZ.size() << "outer Z detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_outerZ.size() ; i++){ + if(blocks_outerZ[i]->HasTokenList(coord)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI outer Z detector " << i+1 << endl; + + double R = blocks_outerZ[i]->GetDouble("Radius","mm"); + double Z = blocks_outerZ[i]->GetDouble("Z","mm"); + double Phi = blocks_outerZ[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_outerZ[i]->GetTVector3("Ref","mm"); + AddOuterZDetector(R,Z,Phi,Ref); + } + else{ + + cout << "ERROR: check your input file formatting on " << i+1 << " outer block " <<endl; + exit(1); + } + } + + //Cluster Tracker +/* + vector<NPL::InputBlock*> blocks_cluster = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","Cluster"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_cluster.size() << "cluster detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_cluster.size() ; i++){ + if(blocks_cluster[i]->HasTokenList(coord)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI cluster detector " << i+1 << endl; + + double R = blocks_cluster[i]->GetDouble("Radius","mm"); + double Z = blocks_cluster[i]->GetDouble("Z","mm"); + double Phi = blocks_cluster[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_cluster[i]->GetTVector3("Ref","mm"); + AddClusterDetector(R,Z,Phi,Ref); + } + else{ + + cout << "ERROR: check your input file formatting on " << i+1 << " cluster block " <<endl; + exit(1); + } + } +*/ + + + //ClusterX Tracker + vector<NPL::InputBlock*> blocks_clusterX1 = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterX1"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterX1.size() << "cluster X1 detectors found " << endl; + + vector<string> coord_cluster = {"Radius","Z","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_clusterX1.size() ; i++){ + if(blocks_clusterX1[i]->HasTokenList(coord_cluster)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI cluster X1 detector " << i+1 << endl; + + double R = blocks_clusterX1[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterX1[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterX1[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_clusterX1[i]->GetTVector3("Ref","mm"); + AddClusterX1Detector(R,Z,Phi,Ref); + } + else{ + + cout << "ERROR: check your input file formatting on " << i+1 << " cluster X1 block " <<endl; + exit(1); + } + } + + //ClusterY Tracker + vector<NPL::InputBlock*> blocks_clusterY1 = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterY1"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterY1.size() << "cluster Y1 detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_clusterY1.size() ; i++){ + if(blocks_clusterY1[i]->HasTokenList(coord_cluster)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI cluster Y1 detector " << i+1 << endl; + + double R = blocks_clusterY1[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterY1[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterY1[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_clusterY1[i]->GetTVector3("Ref","mm"); + AddClusterY1Detector(R,Z,Phi,Ref); + } + else{ + + cout << "ERROR: check your input file formatting on " << i+1 << " cluster Y1 block " <<endl; + exit(1); + } + } + + + //ClusterX2 Tracker + vector<NPL::InputBlock*> blocks_clusterX2 = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterX2"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterX2.size() << "cluster X2 detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_clusterX2.size() ; i++){ + if(blocks_clusterX2[i]->HasTokenList(coord_cluster)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI cluster X2 detector " << i+1 << endl; + + double R = blocks_clusterX2[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterX2[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterX2[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_clusterX2[i]->GetTVector3("Ref","mm"); + AddClusterX2Detector(R,Z,Phi,Ref); + } + else{ + + cout << "ERROR: check your input file formatting on " << i+1 << " cluster X2 block " <<endl; + exit(1); + } + } + + //ClusterY Tracker + vector<NPL::InputBlock*> blocks_clusterY2 = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterY2"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterY2.size() << "cluster Y2 detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_clusterY2.size() ; i++){ + if(blocks_clusterY2[i]->HasTokenList(coord_cluster)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI cluster Y2 detector " << i+1 << endl; + + double R = blocks_clusterY2[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterY2[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterY2[i]->GetDouble("Phi","deg"); + TVector3 Ref = blocks_clusterY2[i]->GetTVector3("Ref","mm"); + AddClusterY2Detector(R,Z,Phi,Ref); + } + else{ + + cout << "ERROR: check your input file formatting on " << i+1 << " cluster Y2 block " <<endl; + exit(1); + } + } + + + + ReadAnalysisConfig(); + +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::InitSpectra() { +// m_Spectra = new TTOGAXSI_SISpectra(m_NumberOfDetectors); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TTOGAXSI_SIPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); +/* for (int i = 0; i < m_NumberOfDetectors; ++i) { + Cal->AddParameter("TOGAXSI_SI", "D"+ NPL::itoa(i+1)+"_ENERGY","TOGAXSI_SI_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("TOGAXSI_SI", "D"+ NPL::itoa(i+1)+"_TIME","TOGAXSI_SI_D"+ NPL::itoa(i+1)+"_TIME"); + } +*/ +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("TOGAXSI_SI", true ); + inputChain->SetBranchAddress("TOGAXSI_SI", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("TOGAXSI_SI", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SIPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("TOGAXSI_SI", "TTOGAXSI_SIPhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TTOGAXSI_SIPhysics::Construct() { + return (NPL::VDetector*) new TTOGAXSI_SIPhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ + class proxy_TOGAXSI_SI{ + public: + proxy_TOGAXSI_SI(){ + NPL::DetectorFactory::getInstance()->AddToken("TOGAXSI_SI","TOGAXSI_SI"); + NPL::DetectorFactory::getInstance()->AddDetector("TOGAXSI_SI",TTOGAXSI_SIPhysics::Construct); + } + }; + + proxy_TOGAXSI_SI p_TOGAXSI_SI; +} + diff --git a/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.h b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.h new file mode 100644 index 000000000..5d99a73ea --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SIPhysics.h @@ -0,0 +1,531 @@ +#ifndef TTOGAXSI_SIPHYSICS_H +#define TTOGAXSI_SIPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_SI Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <vector> +#include <map> +#include <string> +using namespace std; + +// ROOT headers +#include "TObject.h" +#include "TH1.h" +#include "TVector3.h" +// NPTool headers +#include "TTOGAXSI_SIData.h" +#include "TTOGAXSI_SISpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +// forward declaration +class TTOGAXSI_SISpectra; + + + +class TTOGAXSI_SIPhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TTOGAXSI_SIPhysics(); + ~TTOGAXSI_SIPhysics() {}; + + + ////////////////////////////////////////////////////////////// + // Inherited from TObject and overriden to avoid warnings + public: + void Clear(); + void Clear(const Option_t*) {}; + + public: + vector<TVector2> MatchInner(); + vector<TVector2> MatchOuter(); + vector<TVector2> MatchCluster1(); + vector<TVector2> MatchCluster2(); + int CheckEvent(); + + ////////////////////////////////////////////////////////////// + // data obtained after BuildPhysicalEvent() and stored in + // output ROOT file + public: + Int_t EventMultiplicity; + Int_t EventMultiplicity_cluster; + vector<int> DetectorNumber; + vector<int> DetectorNumberInnerX; + vector<int> DetectorNumberInnerZ; + vector<int> DetectorNumberOuterX; + vector<int> DetectorNumberOuterZ; + vector<int> DetectorNumberClusterX1; + vector<int> DetectorNumberClusterY1; + vector<int> DetectorNumberClusterX2; + vector<int> DetectorNumberClusterY2; + + vector<int> InnerXStrip; + vector<double> InnerXE; + vector<int> InnerZStrip; + vector<double> InnerZE; + vector<int> OuterXStrip; + vector<double> OuterXE; + vector<int> OuterZStrip; + vector<double> OuterZE; + vector<int> ClusterInnerStrip; + vector<double> ClusterInnerE; + vector<int> ClusterX1Strip; + vector<double> ClusterX1E; + vector<int> ClusterY1Strip; + vector<double> ClusterY1E; + vector<int> ClusterX2Strip; + vector<double> ClusterX2E; + vector<int> ClusterY2Strip; + vector<double> ClusterY2E; + + vector<double> InnerXPosX; + vector<double> InnerXPosY; + vector<double> InnerXPosZ; + vector<double> InnerZPosX; + vector<double> InnerZPosY; + vector<double> InnerZPosZ; + vector<double> OuterXPosX; + vector<double> OuterXPosY; + vector<double> OuterXPosZ; + vector<double> OuterZPosX; + vector<double> OuterZPosY; + vector<double> OuterZPosZ; + + vector<double> ClusterInnerPosX; + vector<double> ClusterInnerPosY; + vector<double> ClusterInnerPosZ; + vector<double> ClusterX1PosX; + vector<double> ClusterX1PosY; + vector<double> ClusterX1PosZ; + vector<double> ClusterY1PosX; + vector<double> ClusterY1PosY; + vector<double> ClusterY1PosZ; + vector<double> ClusterX2PosX; + vector<double> ClusterX2PosY; + vector<double> ClusterX2PosZ; + vector<double> ClusterY2PosX; + vector<double> ClusterY2PosY; + vector<double> ClusterY2PosZ; + + + ////////////////////////////////////////////////////////////// + // methods inherited from the VDetector ABC class + public: + // read stream from ConfigFile to pick-up detector parameters + void ReadConfiguration(NPL::InputParser); + + //A usefull method to bundle all operation to add a detector + void AddInnerXDetector(double R, double Z, double Phi, TVector3 Ref); + void AddInnerZDetector(double R, double Z, double Phi, TVector3 Ref); + void AddOuterXDetector(double R, double Z, double Phi, TVector3 Ref); + void AddOuterZDetector(double R, double Z, double Phi, TVector3 Ref); + void AddClusterInnerDetector(double R, double Z, double Phi, TVector3 Ref); + void AddClusterX1Detector(double R, double Z, double Phi, TVector3 Ref); + void AddClusterY1Detector(double R, double Z, double Phi, TVector3 Ref); + void AddClusterX2Detector(double R, double Z, double Phi, TVector3 Ref); + void AddClusterY2Detector(double R, double Z, double Phi, TVector3 Ref); + + // add parameters to the CalibrationManger + void AddParameterToCalibrationManager(); + + // method called event by event, aiming at extracting the + // physical information from detector + void BuildPhysicalEvent(); + + // same as BuildPhysicalEvent() method but with a simpler + // treatment + void BuildSimplePhysicalEvent(); + + // same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; + + // activate raw data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputRaw(); + + // activate physics data object and branches from input TChain + // in this method mother branches (Detector) AND daughter leaves + // (fDetector_parameter) have to be activated + void InitializeRootInputPhysics(); + + // create branches of output ROOT file + void InitializeRootOutput(); + + // clear the raw and physical data objects event by event + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // methods related to the TTOGAXSI_SISpectra class + // instantiate the TTOGAXSI_SISpectra class and + // declare list of histograms + void InitSpectra(); + + // fill the spectra + void FillSpectra(); + + // used for Online mainly, sanity check for histograms and + // change their color if issues are found, for example + void CheckSpectra(); + + // used for Online only, clear all the spectra + void ClearSpectra(); + + // write spectra to ROOT output file + void WriteSpectra(); + + + ////////////////////////////////////////////////////////////// + // specific methods to TOGAXSI_SI array + public: + // remove bad channels, calibrate the data and apply thresholds + void PreTreat(); + + // clear the pre-treated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // read the user configuration file. If no file is found, load standard one + void ReadAnalysisConfig(); + + // give and external TTOGAXSI_SIData object to TTOGAXSI_SIPhysics. + // needed for online analysis for example + void SetRawDataPointer(TTOGAXSI_SIData* rawDataPointer) {m_EventData = rawDataPointer;} + + double GetNumberOfInnerXDetector() const {return m_NumberOfInnerXDetectors;} + double GetNumberOfInnerZDetector() const {return m_NumberOfInnerZDetectors;} + double GetNumberOfOuterXDetector() const {return m_NumberOfOuterXDetectors;} + double GetNumberOfOuterZDetector() const {return m_NumberOfOuterZDetectors;} + double GetNumberOfClusterInnerDetector() const {return m_NumberOfClusterInnerDetectors;} + double GetNumberOfClusterX1Detector() const {return m_NumberOfClusterX1Detectors;} + double GetNumberOfClusterY1Detector() const {return m_NumberOfClusterY1Detectors;} + double GetNumberOfClusterX2Detector() const {return m_NumberOfClusterX2Detectors;} + double GetNumberOfClusterY2Detector() const {return m_NumberOfClusterY2Detectors;} + + + int GetEventMultiplicity() const {return EventMultiplicity;} + int GetEventMultiplicity_cluster() const {return EventMultiplicity_cluster;} + int GetDetNbrSize() const {return DetectorNumber.size();} + TVector3 GetInnerXPos(const int i) const {return TVector3(InnerXPosX[i],InnerXPosY[i],InnerXPosZ[i]);} + TVector3 GetInnerZPos(const int i) const {return TVector3(InnerZPosX[i],InnerZPosY[i],InnerZPosZ[i]);} + TVector3 GetOuterXPos(const int i) const {return TVector3(OuterXPosX[i],OuterXPosY[i],OuterXPosZ[i]);} + TVector3 GetOuterZPos(const int i) const {return TVector3(OuterZPosX[i],OuterZPosY[i],OuterZPosZ[i]);} + TVector3 GetClusterInnerPos(const int i) const {return TVector3(ClusterInnerPosX[i],ClusterInnerPosY[i],ClusterInnerPosZ[i]);} + TVector3 GetClusterX1Pos(const int i) const {return TVector3(ClusterX1PosX[i],ClusterX1PosY[i],ClusterX1PosZ[i]);} + TVector3 GetClusterY1Pos(const int i) const {return TVector3(ClusterY1PosX[i],ClusterY1PosY[i],ClusterY1PosZ[i]);} + TVector3 GetClusterX2Pos(const int i) const {return TVector3(ClusterX2PosX[i],ClusterX2PosY[i],ClusterX2PosZ[i]);} + TVector3 GetClusterY2Pos(const int i) const {return TVector3(ClusterY2PosX[i],ClusterY2PosY[i],ClusterY2PosZ[i]);} + + double GetInnerXStripPositionX(const int N, const int X, const int Y) { + return m_InnerXStripPositionX[N-1][X-1][Y-1]; + }; + double GetInnerXStripPositionY(const int N, const int X, const int Y) { + return m_InnerXStripPositionY[N-1][X-1][Y-1]; + }; + double GetInnerXStripPositionZ(const int N, const int X, const int Y) { + return m_InnerXStripPositionZ[N-1][X-1][Y-1]; + }; + + double GetInnerZStripPositionX(const int N, const int X, const int Y) { + return m_InnerZStripPositionX[N-1][X-1][Y-1]; + }; + double GetInnerZStripPositionY(const int N, const int X, const int Y) { + return m_InnerZStripPositionY[N-1][X-1][Y-1]; + }; + double GetInnerZStripPositionZ(const int N, const int X, const int Y) { + return m_InnerZStripPositionZ[N-1][X-1][Y-1]; + }; + + + double GetOuterXStripPositionX(const int N, const int X, const int Y) { + return m_OuterXStripPositionX[N-1][X-1][Y-1]; + }; + double GetOuterXStripPositionY(const int N, const int X, const int Y) { + return m_OuterXStripPositionY[N-1][X-1][Y-1]; + }; + double GetOuterXStripPositionZ(const int N, const int X, const int Y) { + return m_OuterXStripPositionZ[N-1][X-1][Y-1]; + }; + + double GetOuterZStripPositionX(const int N, const int X, const int Y) { + return m_OuterZStripPositionX[N-1][X-1][Y-1]; + }; + double GetOuterZStripPositionY(const int N, const int X, const int Y) { + return m_OuterZStripPositionY[N-1][X-1][Y-1]; + }; + double GetOuterZStripPositionZ(const int N, const int X, const int Y) { + return m_OuterZStripPositionZ[N-1][X-1][Y-1]; + }; + + + double GetClusterInnerStripPositionX(const int N, const int X, const int Y) { + return m_ClusterInnerStripPositionX[N-1][X-1][Y-1]; + }; + double GetClusterInnerStripPositionY(const int N, const int X, const int Y) { + return m_ClusterInnerStripPositionY[N-1][X-1][Y-1]; + }; + double GetClusterInnerStripPositionZ(const int N, const int X, const int Y) { + return m_ClusterInnerStripPositionZ[N-1][X-1][Y-1]; + }; + + double GetClusterX1StripPositionX(const int N, const int X, const int Y) { + return m_ClusterX1StripPositionX[N-1][X-1][Y-1]; + }; + double GetClusterX1StripPositionY(const int N, const int X, const int Y) { + return m_ClusterX1StripPositionY[N-1][X-1][Y-1]; + }; + double GetClusterX1StripPositionZ(const int N, const int X, const int Y) { + return m_ClusterX1StripPositionZ[N-1][X-1][Y-1]; + }; + + double GetClusterY1StripPositionX(const int N, const int X, const int Y) { + return m_ClusterY1StripPositionX[N-1][X-1][Y-1]; + }; + double GetClusterY1StripPositionY(const int N, const int X, const int Y) { + return m_ClusterY1StripPositionY[N-1][X-1][Y-1]; + }; + double GetClusterY1StripPositionZ(const int N, const int X, const int Y) { + return m_ClusterY1StripPositionZ[N-1][X-1][Y-1]; + }; + + double GetClusterX2StripPositionX(const int N, const int X, const int Y) { + return m_ClusterX2StripPositionX[N-1][X-1][Y-1]; + }; + double GetClusterX2StripPositionY(const int N, const int X, const int Y) { + return m_ClusterX2StripPositionY[N-1][X-1][Y-1]; + }; + double GetClusterX2StripPositionZ(const int N, const int X, const int Y) { + return m_ClusterX2StripPositionZ[N-1][X-1][Y-1]; + }; + + double GetClusterY2StripPositionX(const int N, const int X, const int Y) { + return m_ClusterY2StripPositionX[N-1][X-1][Y-1]; + }; + double GetClusterY2StripPositionY(const int N, const int X, const int Y) { + return m_ClusterY2StripPositionY[N-1][X-1][Y-1]; + }; + double GetClusterY2StripPositionZ(const int N, const int X, const int Y) { + return m_ClusterY2StripPositionZ[N-1][X-1][Y-1]; + }; + + + TVector3 GetInnerXPositionOfInteraction(const int i); + TVector3 GetInnerZPositionOfInteraction(const int i); + TVector3 GetOuterXPositionOfInteraction(const int i); + TVector3 GetOuterZPositionOfInteraction(const int i); + TVector3 GetClusterInnerPositionOfInteraction(const int i); + TVector3 GetClusterX1PositionOfInteraction(const int i); + TVector3 GetClusterY1PositionOfInteraction(const int i); + TVector3 GetClusterX2PositionOfInteraction(const int i); + TVector3 GetClusterY2PositionOfInteraction(const int i); + + TVector3 GetDetectorNormal(const int i); + + // objects are not written in the TTree + private: + TTOGAXSI_SIData* m_EventData; //! + TTOGAXSI_SIData* m_PreTreatedData; //! + TTOGAXSI_SIPhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TTOGAXSI_SIData* GetRawData() const {return m_EventData;} + TTOGAXSI_SIData* GetPreTreatedData() const {return m_PreTreatedData;} + + // parameters used in the analysis + private: + int m_NumberOfInnerXDetectors; //! + int m_NumberOfInnerZDetectors; //! + int m_NumberOfOuterXDetectors; //! + int m_NumberOfOuterZDetectors; //! + int m_NumberOfClusterInnerDetectors; //! + int m_NumberOfClusterX1Detectors; //! + int m_NumberOfClusterY1Detectors; //! + int m_NumberOfClusterX2Detectors; //! + int m_NumberOfClusterY2Detectors; //! + + vector<vector<vector<double>>> m_InnerXStripPositionX; //! + vector<vector<vector<double>>> m_InnerXStripPositionY; //! + vector<vector<vector<double>>> m_InnerXStripPositionZ; //! + + vector<vector<vector<double>>> m_InnerZStripPositionX; //! + vector<vector<vector<double>>> m_InnerZStripPositionY; //! + vector<vector<vector<double>>> m_InnerZStripPositionZ; //! + + vector<vector<vector<double>>> m_OuterXStripPositionX; //! + vector<vector<vector<double>>> m_OuterXStripPositionY; //! + vector<vector<vector<double>>> m_OuterXStripPositionZ; //! + + vector<vector<vector<double>>> m_OuterZStripPositionX; //! + vector<vector<vector<double>>> m_OuterZStripPositionY; //! + vector<vector<vector<double>>> m_OuterZStripPositionZ; //! + + vector<vector<vector<double>>> m_ClusterInnerStripPositionX; //! + vector<vector<vector<double>>> m_ClusterInnerStripPositionY; //! + vector<vector<vector<double>>> m_ClusterInnerStripPositionZ; //! + + vector<vector<vector<double>>> m_ClusterX1StripPositionX; //! + vector<vector<vector<double>>> m_ClusterX1StripPositionY; //! + vector<vector<vector<double>>> m_ClusterX1StripPositionZ; //! + + vector<vector<vector<double>>> m_ClusterY1StripPositionX; //! + vector<vector<vector<double>>> m_ClusterY1StripPositionY; //! + vector<vector<vector<double>>> m_ClusterY1StripPositionZ; //! + + vector<vector<vector<double>>> m_ClusterX2StripPositionX; //! + vector<vector<vector<double>>> m_ClusterX2StripPositionY; //! + vector<vector<vector<double>>> m_ClusterX2StripPositionZ; //! + + vector<vector<vector<double>>> m_ClusterY2StripPositionX; //! + vector<vector<vector<double>>> m_ClusterY2StripPositionY; //! + vector<vector<vector<double>>> m_ClusterY2StripPositionZ; //! + + // thresholds + double m_E_RAW_Threshold; //! + double m_E_Threshold; //! + + private: + unsigned int m_MaximumStripMultiplicityAllowed; //! + double m_StripEnergyMatching; //! + + // spectra class + private: + TTOGAXSI_SISpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TTOGAXSI_SIPhysics,1) // TOGAXSI_SIPhysics structure + + private: //geometry + //InnerX Detector + //Wafer parameter + double InnerX_Wafer_Length; + double InnerX_Wafer_Width; + double InnerX_Wafer_Thickness; + double InnerX_Wafer_LongitudinalStrips; + double InnerX_Wafer_TransverseStrips; + + // PCB parameter + double InnerX_PCB_Thickness; + + double InnerX_PCB_Width; + double InnerX_PCB_Length; + + //InnerZ Detector + //Wafer parameter + double InnerZ_Wafer_Length; + double InnerZ_Wafer_Width; + double InnerZ_Wafer_Thickness; + double InnerZ_Wafer_LongitudinalStrips; + double InnerZ_Wafer_TransverseStrips; + + // PCB parameter + double InnerZ_PCB_Thickness; + + double InnerZ_PCB_Width; + double InnerZ_PCB_Length; + + + //OuterX Detector + //Wafer parameter + double OuterX_Wafer_Length; + double OuterX_Wafer_Width; + double OuterX_Wafer_Thickness; + double OuterX_Wafer_LongitudinalStrips; + double OuterX_Wafer_TransverseStrips; + + // PCB parameter + double OuterX_PCB_Thickness; + + double OuterX_PCB_Width; + double OuterX_PCB_Length; + double OuterX_PCB_gap; + + //OuterZ Detector + //Wafer parameter + double OuterZ_Wafer_Length; + double OuterZ_Wafer_Width; + double OuterZ_Wafer_Thickness; + double OuterZ_Wafer_LongitudinalStrips; + double OuterZ_Wafer_TransverseStrips; + + // PCB parameter + double OuterZ_PCB_Thickness; + + double OuterZ_PCB_Width; + double OuterZ_PCB_Length; + double OuterZ_PCB_gap; + + + //ClusterInner Detector + //Wafer parameter + double ClusterInner_Wafer_Height; + double ClusterInner_Wafer_Base; + double ClusterInner_Wafer_Top; + double ClusterInner_Wafer_Thickness; + + double ClusterInner_ActiveWafer_Height; + double ClusterInner_ActiveWafer_Base; + double ClusterInner_ActiveWafer_Top; + double ClusterInner_ActiveWafer_Thickness; + + double ClusterInner_Wafer_LongitudinalStrips; + double ClusterInner_Wafer_TransverseStrips; + + + //ClusterX Detector + //Wafer parameter + double ClusterX_Wafer_Length; + double ClusterX_Wafer_Width; + double ClusterX_Wafer_Thickness; + double ClusterX_Wafer_LongitudinalStrips; + double ClusterX_Wafer_TransverseStrips; + + // PCB parameter + double ClusterX_PCB_Thickness; + double ClusterX_PCB_Width; + double ClusterX_PCB_Length; + double ClusterX_PCB_gap; + + //ClusterY Detector + //Wafer parameter + double ClusterY_Wafer_Length; + double ClusterY_Wafer_Width; + double ClusterY_Wafer_Thickness; + double ClusterY_Wafer_LongitudinalStrips; + double ClusterY_Wafer_TransverseStrips; + + // PCB parameter + double ClusterY_PCB_Thickness; + double ClusterY_PCB_Width; + double ClusterY_PCB_Length; + double ClusterY_PCB_gap; + +}; +#endif diff --git a/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.cxx b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.cxx new file mode 100644 index 000000000..363159b1f --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.cxx @@ -0,0 +1,150 @@ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_SI Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TTOGAXSI_SISpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TTOGAXSI_SISpectra::TTOGAXSI_SISpectra() + : fNumberOfDetectors(0) { + SetName("TOGAXSI_SI"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TTOGAXSI_SISpectra::TTOGAXSI_SISpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TTOGAXSI_SISpectra : Initalizing control spectra for " + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("TOGAXSI_SI"); + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TTOGAXSI_SISpectra::~TTOGAXSI_SISpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SISpectra::InitRawSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "TOGAXSI_SI"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "TOGAXSI_SI/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SISpectra::InitPreTreatedSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "TOGAXSI_SI"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "TOGAXSI_SI/CAL"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SISpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "TOGAXSI_SI_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "TOGAXSI_SI/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SISpectra::FillRawSpectra(TTOGAXSI_SIData* RawData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetInnerXMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "TOGAXSI_SI"+NPL::itoa(RawData->GetInnerX_E_DetectorNbr(i))+"_ENERGY_RAW"; + family = "TOGAXSI_SI/RAW"; + + FillSpectra(family,name,RawData->GetInnerX_E_Energy(i)); + } + +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SISpectra::FillPreTreatedSpectra(TTOGAXSI_SIData* PreTreatedData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetInnerXMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "TOGAXSI_SI"+NPL::itoa(PreTreatedData->GetInnerX_E_DetectorNbr(i))+"_ENERGY_CAL"; + family = "TOGAXSI_SI/CAL"; + + FillSpectra(family,name,PreTreatedData->GetInnerX_E_Energy(i)); + } + +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TTOGAXSI_SISpectra::FillPhysicsSpectra(TTOGAXSI_SIPhysics* Physics) { + static string name; + static string family; + family= "TOGAXSI_SI/PHY"; + + // Energy vs time + unsigned int sizeXE = Physics->InnerXE.size(); + for(unsigned int i = 0 ; i < sizeXE ; i++){ + //name = "TOGAXSI_SI_ENERGY_TIME"; + //FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]); + } +} + diff --git a/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.h b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.h new file mode 100644 index 000000000..14352a8d7 --- /dev/null +++ b/NPLib/Detectors/TOGAXSI_SI/TTOGAXSI_SISpectra.h @@ -0,0 +1,62 @@ +#ifndef TTOGAXSI_SISPECTRA_H +#define TTOGAXSI_SISPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold TOGAXSI_SI Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TTOGAXSI_SIData.h" +#include "TTOGAXSI_SIPhysics.h" + +// Forward Declaration +class TTOGAXSI_SIPhysics; + + +class TTOGAXSI_SISpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TTOGAXSI_SISpectra(); + TTOGAXSI_SISpectra(unsigned int NumberOfDetectors); + ~TTOGAXSI_SISpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TTOGAXSI_SIData*); + void FillPreTreatedSpectra(TTOGAXSI_SIData*); + void FillPhysicsSpectra(TTOGAXSI_SIPhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: + unsigned int fNumberOfDetectors; +}; + +#endif diff --git a/NPSimulation/Detectors/TOGAXSI_GAGG/CMakeLists.txt b/NPSimulation/Detectors/TOGAXSI_GAGG/CMakeLists.txt new file mode 100644 index 000000000..6d85bca98 --- /dev/null +++ b/NPSimulation/Detectors/TOGAXSI_GAGG/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSTOGAXSI_GAGG SHARED TOGAXSI_GAGG.cc) +target_link_libraries(NPSTOGAXSI_GAGG NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPTOGAXSI_GAGG) diff --git a/NPSimulation/Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.cc b/NPSimulation/Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.cc new file mode 100644 index 000000000..41d652e3e --- /dev/null +++ b/NPSimulation/Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.cc @@ -0,0 +1,488 @@ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TOGAXSI_GAGG simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <cmath> +#include <limits> +//G4 Geometry object +#include "G4Tubs.hh" +#include "G4Box.hh" + +//G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +//G4 various object +#include "G4Material.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" + +// NPTool header +#include "TOGAXSI_GAGG.hh" +#include "CalorimeterScorers.hh" +#include "InteractionScorers.hh" +#include "RootOutput.h" +#include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" +#include "NPOptionManager.h" +#include "NPSHitsMap.hh" +// CLHEP header +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace TOGAXSI_GAGG_NS{ + // Energy and time Resolution + const double EnergyThreshold = 0.1*MeV; + const double ResoTime = 4.5*ns ; + const double ResoEnergy = 1.0*MeV ; + + //Size of GAGG crystal + const double Crystal_Length = 3.5*cm ; + const double Crystal_Width = 3.5*cm ; + const double Crystal_Height = 12*cm ; +} + +using namespace TOGAXSI_GAGG_NS; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// TOGAXSI_GAGG Specific Method +TOGAXSI_GAGG::TOGAXSI_GAGG(){ + InitializeMaterial(); + m_ReactionRegion = NULL; + m_Event = new TTOGAXSI_GAGGData() ; + + m_RecoilArray = 0; + m_ClusterArray = 0; + + m_RecoilArrayScorer = 0; + m_ClusterArrayScorer = 0; + + // RGB Color + Transparency + // Yellow + m_VisGAGG = new G4VisAttributes(G4Colour(1, 1, 0, 0.5)); + + m_VisFrame = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + + //Transparent blue + m_VisTarget = new G4VisAttributes(G4Colour(0.15,0.85,0.85,0.1)); +} + +TOGAXSI_GAGG::~TOGAXSI_GAGG(){ +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_GAGG::AddGAGGRecoilArray(G4ThreeVector Pos, double Phi, G4ThreeVector Ref){ + // Convert the POS value to R theta Phi as Spherical coordinate is easier in G4 + m_Pos_RecoilArray.push_back(Pos); + m_Phi_RecoilArray.push_back(Phi); + m_Ref_RecoilArray.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_GAGG::AddGAGGClusterArray(G4ThreeVector Pos, double Phi, G4ThreeVector Ref){ + m_Pos_ClusterArray.push_back(Pos); + m_Phi_ClusterArray.push_back(Phi); + m_Ref_ClusterArray.push_back(Ref); +} + +void TOGAXSI_GAGG::AddTarget(double R, double L, string MaterialName, string CellMaterialName, double CellThickness, G4ThreeVector Pos) { + + m_Target_R.push_back(R); + m_Target_L.push_back(L); + m_Target_MaterialName.push_back(MaterialName); + m_Target_CellMaterialName.push_back(CellMaterialName); + m_Target_CellThickness.push_back(CellThickness); + m_Target_Pos.push_back(Pos); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_GAGG::BuildGAGGRecoilArray(){ + if(!m_RecoilArray) { + + G4Box* RecoilArrayFull = new G4Box("RecoilArrayFull", Crystal_Length*0.5, Crystal_Width*0.5, Crystal_Height*0.5); + + //Master volume Recoil Array + m_RecoilArray = new G4LogicalVolume(RecoilArrayFull, m_MaterialVacuum,"logicRecoilArray",0,0,0); + m_RecoilArray->SetVisAttributes(G4VisAttributes::GetInvisible()); + + //Crystals + G4Box* Crystal = new G4Box("GAGG_Crystal", Crystal_Length*0.5, Crystal_Width*0.5, Crystal_Height*0.5); + + G4LogicalVolume* logicCrystal = new G4LogicalVolume(Crystal,m_MaterialGAGG,"logic_Crystal",0,0,0); + logicCrystal->SetVisAttributes(m_VisGAGG); + logicCrystal->SetSensitiveDetector(m_RecoilArrayScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), logicCrystal, "GAGG_RecoilArray_Crystal", m_RecoilArray, false, 1); + + //Active area needed? +/* + G4Box* ActiveCrystal = new G4Box("RecoilArrayActiveCrystal", 0.5 * Crystal_Length, 0.5 * Crystal_Width, 0.5 * Crystal_Height); + G4LogicalVolume* logicActiveCrystal = new G4LogicalVolume(ActiveCrystal, m_MaterialGAGG, "logicActiveCrystal", 0, 0, 0); + logicActiveCrystal->SetVisAttributes(m_VisCrystal); + ActiveCrystal->SetSensitiveDetector(m_RecoilArrayScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), logicActiveCrystal, "RecoilArray_Active_Crystal", logicCrystal, false, 1); +*/ + } + + return m_RecoilArray; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_GAGG::BuildGAGGClusterArray(){ + if(!m_ClusterArray) { + + G4Box* ClusterArrayFull = new G4Box("ClusterArrayFull", Crystal_Length*0.5, Crystal_Width*0.5, Crystal_Height*0.5); + + //Master volume Recoil Array + m_ClusterArray = new G4LogicalVolume(ClusterArrayFull, m_MaterialVacuum,"logicClusterArray",0,0,0); + m_ClusterArray->SetVisAttributes(G4VisAttributes::GetInvisible()); + + //Crystals + G4Box* Crystal = new G4Box("GAGG_Crystal", Crystal_Length*0.5, Crystal_Width*0.5, Crystal_Height*0.5); + + G4LogicalVolume* logicCrystal = new G4LogicalVolume(Crystal,m_MaterialGAGG,"logic_Crystal",0,0,0); + logicCrystal->SetVisAttributes(m_VisGAGG); + logicCrystal->SetSensitiveDetector(m_ClusterArrayScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), logicCrystal, "GAGG_ClusterArray_Crystal", m_ClusterArray, false, 1); + + //Active area needed? +/* + G4Box* ActiveCrystal = new G4Box("RecoilArrayActiveCrystal", 0.5 * Crystal_Length, 0.5 * Crystal_Width, 0.5 * Crystal_Height); + G4LogicalVolume* logicActiveCrystal = new G4LogicalVolume(ActiveCrystal, m_MaterialGAGG, "logicActiveCrystal", 0, 0, 0); + logicActiveCrystal->SetVisAttributes(m_VisCrystal); + logicActiveCrystal->SetSensitiveDetector(m_RecoilArrayScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), logicActiveCrystal, "RecoilArray_Active_Crystal", logicCrystal, false, 1); +*/ + } + + return m_ClusterArray; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_GAGG::BuildTarget(int i) { + + if(i>0) { + cout << "ERROR: Multiple TOGAXSI target block defined in detector file" << endl; + } + + G4Material* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(m_Target_MaterialName[i]); + G4Tubs* solidTarget = new G4Tubs("Target",0.,m_Target_R[i], m_Target_L[i] / 2., 0, 360.); + m_Target = new G4LogicalVolume(solidTarget, TargetMaterial, "Target"); + m_Target->SetVisAttributes(m_VisTarget); + + return m_Target; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void TOGAXSI_GAGG::ReadConfiguration(NPL::InputParser parser){ + + //GAGG Recoil + vector<NPL::InputBlock*> blocks_recoil = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_GAGG", "RecoilArray"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_recoil.size() << " detectors found " << endl; + + vector<string> gagg_recoilarray = {"Pos","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_recoil.size() ; i++){ + if(blocks_recoil[i]->HasTokenList(gagg_recoilarray)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_GAGG " << i+1 << endl; + + G4ThreeVector Pos = NPS::ConvertVector(blocks_recoil[i]->GetTVector3("Pos","mm")); + double Phi = blocks_recoil[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_recoil[i]->GetTVector3("Ref","mm")); + AddGAGGRecoilArray(Pos,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + //GAGG Cluster + vector<NPL::InputBlock*> blocks_cluster = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_GAGG", "ClusterArray"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_cluster.size() << " detectors found " << endl; + + vector<string> gagg_clusterarray = {"Pos","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_cluster.size() ; i++){ + if(blocks_cluster[i]->HasTokenList(gagg_clusterarray)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_GAGG " << i+1 << endl; + + G4ThreeVector Pos = NPS::ConvertVector(blocks_cluster[i]->GetTVector3("Pos","mm")); + double Phi = blocks_cluster[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_cluster[i]->GetTVector3("Ref","mm")); + AddGAGGClusterArray(Pos,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + + + //Target + vector<NPL::InputBlock*> blocks_target = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_GAGG","Target"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_target.size() << " target found " << endl; + + vector<string> targettoken = {"Radius","Length","TargetMaterial","CellMaterial","CellThickness","Pos"}; + + for(unsigned int i = 0 ; i < blocks_target.size() ; i++){ + if(blocks_target[i]->HasTokenList(targettoken)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_GAGG " << i+1 << endl; + + double R = blocks_target[i]->GetDouble("Radius","mm"); + double L = blocks_target[i]->GetDouble("Length","mm"); + string TargetMaterialName = blocks_target[i]->GetString("TargetMaterial"); + string CellMaterialName = blocks_target[i]->GetString("CellMaterial"); + double CellThickness = blocks_target[i]->GetDouble("CellThickness","mm"); + G4ThreeVector Pos = NPS::ConvertVector(blocks_target[i]->GetTVector3("Pos","mm")); + AddTarget(R,L,TargetMaterialName,CellMaterialName,CellThickness,Pos); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void TOGAXSI_GAGG::ConstructDetector(G4LogicalVolume* world){ + //RecoilArray + for (unsigned short i = 0; i < m_Phi_RecoilArray.size(); i++) { + + G4ThreeVector Det_pos = m_Pos_RecoilArray[i]; + + Det_pos.rotate(-m_Phi_RecoilArray[i], G4ThreeVector(0,0,1)); + // Det_pos.rotate( 0, G4ThreeVector(0,0,1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_Phi_RecoilArray[i]); + // G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, 60*deg); + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_Ref_RecoilArray[i]), BuildGAGGRecoilArray(),"TOGAXSI_GAGG",world, false, i + 1); + + } + + cout << "________Test______" << endl; + //ClusterArray + for (unsigned short i = 0; i < m_Phi_ClusterArray.size(); i++) { + + G4ThreeVector Det_pos = m_Pos_ClusterArray[i]; + + Det_pos.rotate(-m_Phi_ClusterArray[i], G4ThreeVector(0,0,1)); + // Det_pos.rotate( 0, G4ThreeVector(0,0,1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_Phi_ClusterArray[i]); + // G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, 60*deg); + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_Ref_ClusterArray[i]), BuildGAGGClusterArray(),"TOGAXSI_GAGG",world, false, i + 1); + + } + + cout << "________Test______" << endl; + // Target + G4LogicalVolume* logicTarget[m_Target_R.size()]; + // G4LogicalVolume* logicTargetCell[m_Target_R.size()]; + + for (unsigned short i = 0; i < m_Target_R.size(); i++) { + G4ThreeVector Tar_pos = m_Target_Pos[i]; + cout << "TargetPos" << m_Target_Pos[i].z() << endl; + G4RotationMatrix* Rot = new G4RotationMatrix(); + logicTarget[i] = BuildTarget(i); + new G4PVPlacement(Rot, Tar_pos, logicTarget[i], "TOGAXSI_SI_Target", world, false, i + 1); + // logicTargetCell[i] = BuildTargetCell(i); + // new G4PVPlacement(Rot, Tar_pos, logicTargetCell[i], "Strasse_TargetCell", world, false, i + 1); + if (!m_ReactionRegion) { + m_ReactionRegion = new G4Region("NPSimulationProcess"); + } + + m_ReactionRegion->AddRootLogicalVolume(m_Target); + m_ReactionRegion->SetUserLimits(new G4UserLimits(1. * mm)); + + G4FastSimulationManager* mng = m_ReactionRegion->GetFastSimulationManager(); + unsigned int size = m_ReactionModel.size(); + for (unsigned int o = 0; o < size; o++) { + mng->RemoveFastSimulationModel(m_ReactionModel[o]); + } + m_ReactionModel.clear(); + + G4VFastSimulationModel* fsm; + fsm = new NPS::BeamReaction("BeamReaction", m_ReactionRegion); + ((NPS::BeamReaction*)fsm)->SetStepSize(1. * mm); + m_ReactionModel.push_back(fsm); + + fsm = new NPS::Decay("Decay", m_ReactionRegion); + m_ReactionModel.push_back(fsm); + + } + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method +void TOGAXSI_GAGG::InitializeRootOutput(){ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + if(!pTree->FindBranch("TOGAXSI_GAGG")){ + pTree->Branch("TOGAXSI_GAGG", "TTOGAXSI_GAGGData", &m_Event) ; + } + pTree->SetBranchAddress("TOGAXSI_GAGG", &m_Event) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void TOGAXSI_GAGG::ReadSensitive(const G4Event* ){ + m_Event->Clear(); + + /////////// + // Calorimeter scorer for RecoilArray + CalorimeterScorers::PS_Calorimeter* RecoilArrayScorer= (CalorimeterScorers::PS_Calorimeter*) m_RecoilArrayScorer->GetPrimitive(0); + + unsigned int size = RecoilArrayScorer->GetMult(); + for(unsigned int i = 0 ; i < size ; i++){ + vector<unsigned int> level = RecoilArrayScorer->GetLevel(i); + double Energy = RandGauss::shoot(RecoilArrayScorer->GetEnergy(i),ResoEnergy); + if(Energy>EnergyThreshold){ + double Time = RandGauss::shoot(RecoilArrayScorer->GetTime(i),ResoTime); + int DetectorNbr = level[0]; + m_Event->SetRecoilEnergy(DetectorNbr,Energy); + m_Event->SetRecoilTime(DetectorNbr,Time); + } + } + RecoilArrayScorer->clear(); + + // Calorimeter scorer for RecoilArray + CalorimeterScorers::PS_Calorimeter* ClusterArrayScorer= (CalorimeterScorers::PS_Calorimeter*) m_ClusterArrayScorer->GetPrimitive(0); + + size = ClusterArrayScorer->GetMult(); + for(unsigned int i = 0 ; i < size ; i++){ + vector<unsigned int> level = ClusterArrayScorer->GetLevel(i); + double Energy = RandGauss::shoot(ClusterArrayScorer->GetEnergy(i),ResoEnergy); + if(Energy>EnergyThreshold){ + double Time = RandGauss::shoot(ClusterArrayScorer->GetTime(i),ResoTime); + int DetectorNbr = level[0]; + m_Event->SetClusterEnergy(DetectorNbr,Energy); + m_Event->SetClusterTime(DetectorNbr,Time); + } + } + ClusterArrayScorer->clear(); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////// +void TOGAXSI_GAGG::InitializeScorers() { + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + m_RecoilArrayScorer = CheckScorer("RecoilArrayScorer",already_exist) ; + m_ClusterArrayScorer = CheckScorer("ClusterArrayScorer",already_exist) ; + + if(already_exist) + return ; + + // Otherwise the scorer is initialised + // RecoilArray + vector<int> level; level.push_back(1); + G4VPrimitiveScorer* Calorimeter_RecoilArray= new CalorimeterScorers::PS_Calorimeter("Calorimeter_RecoilArray",level, 0); + G4VPrimitiveScorer* Interaction_RecoilArray= new InteractionScorers::PS_Interactions("Interaction_RecoilArray",ms_InterCoord, 0); + G4VPrimitiveScorer* Calorimeter_ClusterArray= new CalorimeterScorers::PS_Calorimeter("Calorimeter_ClusterArray",level, 0); + G4VPrimitiveScorer* Interaction_ClusterArray= new InteractionScorers::PS_Interactions("Interaction_ClusterArray",ms_InterCoord, 0); + + //and register it to the multifunctionnal detector + m_RecoilArrayScorer->RegisterPrimitive(Calorimeter_RecoilArray); + m_RecoilArrayScorer->RegisterPrimitive(Interaction_RecoilArray); + m_ClusterArrayScorer->RegisterPrimitive(Calorimeter_ClusterArray); + m_ClusterArrayScorer->RegisterPrimitive(Interaction_ClusterArray); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_RecoilArrayScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_RecoilArrayScorer); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* TOGAXSI_GAGG::Construct(){ + return (NPS::VDetector*) new TOGAXSI_GAGG(); +} + +void TOGAXSI_GAGG::InitializeMaterial() { + + G4Element* elementGd = new G4Element("Gadolinium", "Gd", 64., 157.25*g/mole); + G4Element* elementAl = new G4Element("Aluminum", "Gd", 13., 26.982*g/mole); + G4Element* elementGa = new G4Element("Gallium", "Ga", 31., 69.723*g/mole); + G4Element* elementO = new G4Element("Oxygen", "O", 8., 15.999*g/mole); + m_MaterialGAGG = new G4Material("Material GAGG", 6.63*g/cm3, 4); + m_MaterialGAGG->AddElement(elementGd,3); + m_MaterialGAGG->AddElement(elementAl,2); + m_MaterialGAGG->AddElement(elementGa,3); + m_MaterialGAGG->AddElement(elementO,12); + + + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +// m_MaterialFrame = MaterialManager::getInstance()->GetMaterialFromLibrary(""); +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy_nps_TOGAXSI_GAGG{ + public: + proxy_nps_TOGAXSI_GAGG(){ + NPS::DetectorFactory::getInstance()->AddToken("TOGAXSI_GAGG","TOGAXSI_GAGG"); + NPS::DetectorFactory::getInstance()->AddDetector("TOGAXSI_GAGG",TOGAXSI_GAGG::Construct); + } + }; + + proxy_nps_TOGAXSI_GAGG p_nps_TOGAXSI_GAGG; +} diff --git a/NPSimulation/Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.hh b/NPSimulation/Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.hh new file mode 100644 index 000000000..f4b015c4d --- /dev/null +++ b/NPSimulation/Detectors/TOGAXSI_GAGG/TOGAXSI_GAGG.hh @@ -0,0 +1,149 @@ +#ifndef TOGAXSI_GAGG_h +#define TOGAXSI_GAGG_h 1 +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TOGAXSI_GAGG simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ header +#include <string> +#include <vector> +using namespace std; + +// G4 headers +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4LogicalVolume.hh" +#include "G4MultiFunctionalDetector.hh" + +#include "G4FastSimulationManager.hh" +#include "G4UserLimits.hh" +#include "G4VFastSimulationModel.hh" + +// NPTool header +#include "NPSVDetector.hh" +#include "TTOGAXSI_GAGGData.h" +#include "NPInputParser.h" + +#include "BeamReaction.hh" +#include "Decay.hh" + +class TOGAXSI_GAGG : public NPS::VDetector{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + public: + TOGAXSI_GAGG() ; + virtual ~TOGAXSI_GAGG() ; + + //////////////////////////////////////////////////// + /////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// + public: + void AddGAGGRecoilArray(G4ThreeVector Pos, double Phi, G4ThreeVector Ref); + void AddGAGGClusterArray(G4ThreeVector Pos, double Phi, G4ThreeVector Ref); + void AddTarget(double R, double L, string Materialname, string CellMaterialname, double CellThickness, G4ThreeVector Pos); + + G4LogicalVolume* BuildGAGGRecoilArray(); + G4LogicalVolume* BuildGAGGClusterArray(); + G4LogicalVolume* BuildTarget(int i); + + private: + G4LogicalVolume* m_RecoilArray; + G4LogicalVolume* m_ClusterArray; + G4LogicalVolume* m_Target; + + private: + // Initialize material used in detector definition + void InitializeMaterial(); + + //List of material + G4Material* m_MaterialGAGG; + G4Material* m_MaterialVacuum; + + + //////////////////////////////////////////////////// + ////// Inherite from NPS::VDetector class ///////// + //////////////////////////////////////////////////// + public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(NPL::InputParser) ; + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world) ; + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput() ; + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event) ; + + public: // Scorer + // Initialize all Scorer used by the MUST2Array + void InitializeScorers(); + + // Associated Scorer + G4MultiFunctionalDetector* m_RecoilArrayScorer ; + G4MultiFunctionalDetector* m_ClusterArrayScorer ; + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// + private: + TTOGAXSI_GAGGData* m_Event ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// + private: // Geometry + // Detector Coordinate + vector<G4ThreeVector> m_Pos_RecoilArray; + vector<double> m_Phi_RecoilArray; + vector<G4ThreeVector> m_Ref_RecoilArray; + + vector<G4ThreeVector> m_Pos_ClusterArray; + vector<double> m_Phi_ClusterArray; + vector<G4ThreeVector> m_Ref_ClusterArray; + + // Target Coordinate + vector<double> m_Target_R; + vector<double> m_Target_L; + vector<string> m_Target_MaterialName; + vector<string> m_Target_CellMaterialName; + vector<double> m_Target_CellThickness; + vector<G4ThreeVector> m_Target_Pos; + + //Region were reaction cann occure: + G4Region *m_ReactionRegion; + vector<G4VFastSimulationModel*> m_ReactionModel; + + // Visualisation Attribute + G4VisAttributes* m_VisGAGG; + G4VisAttributes* m_VisFrame; + G4VisAttributes* m_VisTarget; + + + // Needed for dynamic loading of the library + public: + static NPS::VDetector* Construct(); +}; +#endif diff --git a/NPSimulation/Detectors/TOGAXSI_SI/CMakeLists.txt b/NPSimulation/Detectors/TOGAXSI_SI/CMakeLists.txt new file mode 100644 index 000000000..9015f1997 --- /dev/null +++ b/NPSimulation/Detectors/TOGAXSI_SI/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSTOGAXSI_SI SHARED TOGAXSI_SI.cc) +target_link_libraries(NPSTOGAXSI_SI NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPTOGAXSI_SI) diff --git a/NPSimulation/Detectors/TOGAXSI_SI/TOGAXSI_SI.cc b/NPSimulation/Detectors/TOGAXSI_SI/TOGAXSI_SI.cc new file mode 100644 index 000000000..7bae3d1b9 --- /dev/null +++ b/NPSimulation/Detectors/TOGAXSI_SI/TOGAXSI_SI.cc @@ -0,0 +1,1790 @@ +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TOGAXSI_SI simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ headers +#include <sstream> +#include <cmath> +#include <limits> +//G4 Geometry object +#include "G4Tubs.hh" +#include "G4Box.hh" +#include "G4Trap.hh" + +#include "G4ExtrudedSolid.hh" +#include "G4SubtractionSolid.hh" +#include "G4TwoVector.hh" + +//G4 sensitive +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" + +//G4 various object +#include "G4Material.hh" +#include "G4Transform3D.hh" +#include "G4PVPlacement.hh" +#include "G4VisAttributes.hh" +#include "G4Colour.hh" + +// NPTool header +#include "TOGAXSI_SI.hh" +//#include "CalorimeterScorers.hh" +#include "InteractionScorers.hh" +#include "RootOutput.h" +#include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" +#include "NPOptionManager.h" +#include "NPSHitsMap.hh" + +#include "DSSDScorers.hh" + +// CLHEP header +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace TOGAXSI_SI_NS{ + // Energy and time Resolution + const double EnergyThreshold = 1*keV; + const double ResoEnergy = 0.015*MeV ; + + //////////////////// + // Inner Detector // + //////////////////// + // WaferX Parameter + double InnerX_Wafer_Length = 78.4*mm ; + double InnerX_Wafer_Width = 51*mm ; + double InnerX_Wafer_Thickness = 0.1*mm ; + double InnerX_Wafer_LongitudinalStrips = 255; +// double InnerX_Wafer_LongitudinalStrips = 64; + double InnerX_Wafer_TransverseStrips = 1; +// double InnerX_Wafer_LongitudinalStrips = 128; +// double InnerX_Wafer_TransverseStrips = 128; + + // PCB parameter + double InnerX_PCB_Thickness=3*mm; + + double InnerX_PCB_Length = 84.9*mm; + double InnerX_PCB_Width = 55.83*mm; + + // WaferZ Parameter + double InnerZ_Wafer_Length = 78.4*mm ; + double InnerZ_Wafer_Width = 51*mm ; + double InnerZ_Wafer_Thickness = 0.1*mm ; + double InnerZ_Wafer_LongitudinalStrips = 1; + double InnerZ_Wafer_TransverseStrips = 392; +// double InnerZ_Wafer_TransverseStrips = 98; +// double InnerZ_Wafer_LongitudinalStrips = 128; +// double InnerZ_Wafer_TransverseStrips = 128; + + // PCB parameter + double InnerZ_PCB_Thickness=3*mm; + + double InnerZ_PCB_Length = 84.9*mm; + double InnerZ_PCB_Width = 55.83*mm; + + //////////////////// + // Outer Detector // + //////////////////// + // WaferX Parameter + double OuterX_Wafer_Length = 78.4*mm ; + double OuterX_Wafer_Width = 51*mm ; +// double OuterX_Wafer_Length = 51*mm ; +// double OuterX_Wafer_Width = 78.4*mm ; + double OuterX_Wafer_Thickness = 0.1*mm ; + double OuterX_Wafer_LongitudinalStrips = 392; +// double OuterX_Wafer_LongitudinalStrips = 98; + double OuterX_Wafer_TransverseStrips = 1; +// double OuterX_Wafer_LongitudinalStrips = 1; +// double OuterX_Wafer_TransverseStrips = 392; + + // PCB parameter + double OuterX_PCB_Thickness=3*mm; + + double OuterX_PCB_Length = 107.16*mm; + double OuterX_PCB_Width = 84.9*mm; + double OuterX_PCB_gap = 3.5*mm; + + + // WaferZ Parameter + double OuterZ_Wafer_Length = 78.4*mm ; + double OuterZ_Wafer_Width = 51*mm ; +// double OuterZ_Wafer_Length = 51*mm ; +// double OuterZ_Wafer_Width = 78.4*mm ; + double OuterZ_Wafer_Thickness = 0.1*mm ; + double OuterZ_Wafer_LongitudinalStrips = 1; + double OuterZ_Wafer_TransverseStrips = 255; +// double OuterZ_Wafer_TransverseStrips = 64; +// double OuterZ_Wafer_LongitudinalStrips = 255; +// double OuterZ_Wafer_TransverseStrips = 1; + + // PCB parameter + double OuterZ_PCB_Thickness=3*mm; + + double OuterZ_PCB_Length = 108.6*mm; + double OuterZ_PCB_Width = 83.3*mm; + double OuterZ_PCB_gap = 3.5*mm; + + + ///////////////////// + // ClusterDetector // + ///////////////////// + double ClusterInner_Wafer_Base = 56.*mm; + double ClusterInner_Wafer_Top = 7.*mm; + double ClusterInner_Wafer_Height = 80.*mm; + double ClusterInner_Wafer_Thickness = 0.1*mm; + + double ClusterInner_ActiveWafer_Base = 88.*mm; + double ClusterInner_ActiveWafer_Top = 12.*mm; + double ClusterInner_ActiveWafer_Height = 66.*mm; + double ClusterInner_ActiveWafer_Thickness = 0.1*mm; + + double ClusterInner_Wafer_LongitudinalStrips = 128; + double ClusterInner_Wafer_TransverseStrips = 128; + + //Cluster Demonstrator X + double ClusterX_Wafer_Length = 78.4*mm ; + double ClusterX_Wafer_Width = 51*mm ; + double ClusterX_Wafer_Thickness = 0.1*mm ; + double ClusterX_Wafer_LongitudinalStrips = 392; + double ClusterX_Wafer_TransverseStrips = 1; + + double ClusterX_PCB_Thickness=3*mm; + double ClusterX_PCB_Length = 107.16*mm; + double ClusterX_PCB_Width = 84.9*mm; + double ClusterX_PCB_gap = 3.5*mm; + + //Cluster Demonstrator Y + double ClusterY_Wafer_Length = 78.4*mm ; + double ClusterY_Wafer_Width = 51*mm ; + double ClusterY_Wafer_Thickness = 0.1*mm ; + double ClusterY_Wafer_LongitudinalStrips = 1; + double ClusterY_Wafer_TransverseStrips = 255; + + double ClusterY_PCB_Thickness=3*mm; + double ClusterY_PCB_Length = 108.6*mm; + double ClusterY_PCB_Width = 83.3*mm; + double ClusterY_PCB_gap = 3.5*mm; + +} + +using namespace TOGAXSI_SI_NS; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// TOGAXSI_SI Specific Method +TOGAXSI_SI::TOGAXSI_SI(){ + InitializeMaterial(); + m_ReactionRegion = NULL; + m_Event = new TTOGAXSI_SIData() ; +// m_ReactionRegion = NULL; + m_InnerXScorer = 0; + m_InnerXDetector = 0; + m_InnerZScorer = 0; + m_InnerZDetector = 0; + + m_OuterXScorer1 = 0; + m_OuterXScorer2 = 0; + m_OuterZScorer1 = 0; + m_OuterZScorer2 = 0; + m_OuterXDetector = 0; + m_OuterZDetector = 0; + + m_ClusterInnerScorer = 0; + m_ClusterInnerDetector = 0; + + m_ClusterX1Scorer1 = 0; + m_ClusterX1Scorer2 = 0; + m_ClusterX1Detector = 0; + m_ClusterY1Scorer1 = 0; + m_ClusterY1Scorer2 = 0; + m_ClusterY1Detector = 0; + m_ClusterX2Scorer1 = 0; + m_ClusterX2Scorer2 = 0; + m_ClusterX2Detector = 0; + m_ClusterY2Scorer1 = 0; + m_ClusterY2Scorer2 = 0; + m_ClusterY2Detector = 0; + + m_Target = 0; + m_TargetCell = 0; + m_TargetCellScorer = 0; + + // Dark Grey + m_VisSi = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + // Green + m_VisPCB = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); + + //Transparent blue + m_VisTarget = new G4VisAttributes(G4Colour(0.15,0.85,0.85,0.1)); + m_VisTargetCell = new G4VisAttributes(G4Colour(0.8, 0.8, 0.8, 0.5)); + +} + +TOGAXSI_SI::~TOGAXSI_SI(){ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddInnerXDetector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_InnerX_R.push_back(R); + m_InnerX_Z.push_back(Z); + m_InnerX_Phi.push_back(Phi); + m_InnerX_Ref.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddInnerZDetector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_InnerZ_R.push_back(R); + m_InnerZ_Z.push_back(Z); + m_InnerZ_Phi.push_back(Phi); + m_InnerZ_Ref.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddOuterXDetector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_OuterX_R.push_back(R); + m_OuterX_Z.push_back(Z); + m_OuterX_Phi.push_back(Phi); + m_OuterX_Ref.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddOuterZDetector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_OuterZ_R.push_back(R); + m_OuterZ_Z.push_back(Z); + m_OuterZ_Phi.push_back(Phi); + m_OuterZ_Ref.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddClusterInnerDetector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_ClusterInner_R.push_back(R); + m_ClusterInner_Z.push_back(Z); + m_ClusterInner_Phi.push_back(Phi); + m_ClusterInner_Ref.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddClusterX1Detector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_ClusterX1_R.push_back(R); + m_ClusterX1_Z.push_back(Z); + m_ClusterX1_Phi.push_back(Phi); + m_ClusterX1_Ref.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddClusterY1Detector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_ClusterY1_R.push_back(R); + m_ClusterY1_Z.push_back(Z); + m_ClusterY1_Phi.push_back(Phi); + m_ClusterY1_Ref.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddClusterX2Detector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_ClusterX2_R.push_back(R); + m_ClusterX2_Z.push_back(Z); + m_ClusterX2_Phi.push_back(Phi); + m_ClusterX2_Ref.push_back(Ref); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddClusterY2Detector(double R, double Z, double Phi, G4ThreeVector Ref) { + m_ClusterY2_R.push_back(R); + m_ClusterY2_Z.push_back(Z); + m_ClusterY2_Phi.push_back(Phi); + m_ClusterY2_Ref.push_back(Ref); +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void TOGAXSI_SI::AddTarget(double R, double L, string MaterialName, string CellMaterialName, double CellThickness, G4ThreeVector Pos) { + + m_Target_R.push_back(R); + m_Target_L.push_back(L); + m_Target_MaterialName.push_back(MaterialName); + m_Target_CellMaterialName.push_back(CellMaterialName); + m_Target_CellThickness.push_back(CellThickness); + m_Target_Pos.push_back(Pos); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildInnerXDetector(){ + if(!m_InnerXDetector){ + + G4Box* PCBFull = new G4Box("TOGAXSI_SI_PCBFull", 0.5 * InnerX_PCB_Width, 0.5 * InnerX_PCB_Thickness, 0.5 * InnerX_PCB_Length); + + + // Master volume inner Detector + m_InnerXDetector = new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector",0,0,0); + m_InnerXDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + + // PCB frame + G4Box* HoleShape = new G4Box("HoleShape", InnerX_Wafer_Width * 0.5, InnerX_PCB_Thickness * 0.5 + 0.1 * mm, InnerX_Wafer_Length * 0.5); + + + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCBFull, HoleShape); + + //Sub Volume PCB + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(m_VisPCB); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "TOGAXSI_InnerX_PCB", m_InnerXDetector, false, 0); + + + ///////////////////////////////////////////////// + // Si Wafer + // Subvolume Wafer + G4Box* WaferShape = new G4Box("WaferShape",0.5 * InnerX_Wafer_Width, 0.5 * InnerX_Wafer_Thickness, 0.5 * InnerX_Wafer_Length); + + G4LogicalVolume* logicWafer = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer->SetVisAttributes(m_VisSi); +// logicWafer->SetSensitiveDetector(m_InnerScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicWafer, "TOGAXSI_SI_InnerX_Wafer", m_InnerXDetector, false, 1); + + + + // Active Wafer + G4Box* ActiveWaferShape = new G4Box("InnerActiveXWaferShape",0.5 * InnerX_Wafer_Width, 0.5 * InnerX_Wafer_Thickness, 0.5 * InnerX_Wafer_Length); + + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer", 0, 0, 0); + logicActiveWafer->SetVisAttributes(m_VisSi); + logicActiveWafer->SetSensitiveDetector(m_InnerXScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer, "TOGAXSI_SI_Active_InnerX_Wafer", logicWafer, false, 1); + + + } + return m_InnerXDetector; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildInnerZDetector(){ + if(!m_InnerZDetector){ + + G4Box* PCBFull = new G4Box("TOGAXSI_SI_PCBFull", 0.5 * InnerZ_PCB_Width, 0.5 * InnerZ_PCB_Thickness, 0.5 * InnerZ_PCB_Length); + + + // Master volume inner Detector + m_InnerZDetector = new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector",0,0,0); + m_InnerZDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + + // PCB frame + G4Box* HoleShape = new G4Box("HoleShape", InnerZ_Wafer_Width * 0.5, InnerZ_PCB_Thickness * 0.5 + 0.1 * mm, InnerZ_Wafer_Length * 0.5); + + + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCBFull, HoleShape); + + //Sub Volume PCB + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(m_VisPCB); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "TOGAXSI_InnerZ_PCB", m_InnerZDetector, false, 0); + + + ///////////////////////////////////////////////// + // Si Wafer + // Subvolume Wafer + G4Box* WaferShape = new G4Box("WaferShape",0.5 * InnerZ_Wafer_Width, 0.5 * InnerZ_Wafer_Thickness, 0.5 * InnerZ_Wafer_Length); + + G4LogicalVolume* logicWafer = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer->SetVisAttributes(m_VisSi); +// logicWafer->SetSensitiveDetector(m_InnerScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicWafer, "TOGAXSI_SI_InnerZ_Wafer", m_InnerZDetector, false, 1); + + + + // Active Wafer + G4Box* ActiveWaferShape = new G4Box("InnerActiveXWaferShape",0.5 * InnerZ_Wafer_Width, 0.5 * InnerZ_Wafer_Thickness, 0.5 * InnerZ_Wafer_Length); + + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer", 0, 0, 0); + logicActiveWafer->SetVisAttributes(m_VisSi); + logicActiveWafer->SetSensitiveDetector(m_InnerZScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer, "TOGAXSI_SI_Active_InnerZ_Wafer", logicWafer, false, 1); + + + } + return m_InnerZDetector; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildOuterXDetector(){ + if(!m_OuterXDetector){ + + + G4Box* PCBFull = new G4Box("TOGAXSI_SI_PCBFull", 0.5 * OuterX_PCB_Width, 0.5 * OuterX_PCB_Thickness, 0.5 * OuterX_PCB_Length); + + + // Master volume inner Detector + m_OuterXDetector = new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector",0,0,0); + m_OuterXDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + + // PCB frame + G4Box* HoleShape = new G4Box("HoleShape", OuterX_Wafer_Length * 0.5, OuterX_PCB_Thickness*0.5 + 0.1 * mm, OuterX_Wafer_Width * 0.5); + + G4ThreeVector HoleShift = G4ThreeVector(0,0,0.5 * OuterX_Wafer_Width + 0.5 * OuterX_PCB_gap); + + G4SubtractionSolid* PCB_temp = new G4SubtractionSolid("PCB", PCBFull, HoleShape, new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_temp, HoleShape,new G4RotationMatrix,-HoleShift); + + + //Sub Volume PCB + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(m_VisPCB); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "TOGAXSI_OuterX_PCB", m_OuterXDetector, false, 0); + + + ///////////////////////////////////////////////// + // Si Wafer + // Subvolume Wafer + G4Box* WaferShape = new G4Box("WaferShape",0.5 * OuterX_Wafer_Length, 0.5 * OuterX_Wafer_Thickness, 0.5 * OuterX_Wafer_Width); + + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer1->SetVisAttributes(m_VisSi); +// logicWafer1->SetSensitiveDetector(m_OuterScorer1); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer2->SetVisAttributes(m_VisSi); +// logicWafer2->SetSensitiveDetector(m_OuterScorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),-HoleShift, logicWafer1, "TOGAXSI_SI_OuterX_Wafer 1", m_OuterXDetector, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),HoleShift, logicWafer2, "TOGAXSI_SI_OuterX_Wafer 2", m_OuterXDetector, false, 1); + + + // Active Wafer + G4Box* ActiveWaferShape = new G4Box("OuterXActiveWaferShape",0.5 * OuterX_Wafer_Length, 0.5 * OuterX_Wafer_Thickness, 0.5 * OuterX_Wafer_Width); + + G4LogicalVolume* logicActiveWafer1 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer1", 0, 0, 0); + logicActiveWafer1->SetVisAttributes(m_VisSi); + logicActiveWafer1->SetSensitiveDetector(m_OuterXScorer1); + G4LogicalVolume* logicActiveWafer2 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer2", 0, 0, 0); + logicActiveWafer2->SetVisAttributes(m_VisSi); + logicActiveWafer2->SetSensitiveDetector(m_OuterXScorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer1, "TOGAXSI_SI_Inner_Wafer", logicWafer1, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer2, "TOGAXSI_SI_Inner_Wafer", logicWafer2, false, 1); + + + } + return m_OuterXDetector; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildOuterZDetector(){ + if(!m_OuterZDetector){ + + + G4Box* PCBFull = new G4Box("TOGAXSI_SI_PCBFull", 0.5 * OuterZ_PCB_Width, 0.5 * OuterZ_PCB_Thickness, 0.5 * OuterZ_PCB_Length); + + + // Master volume inner Detector + m_OuterZDetector = new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector",0,0,0); + m_OuterZDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + + // PCB frame + G4Box* HoleShape = new G4Box("HoleShape", OuterZ_Wafer_Length * 0.5, OuterZ_PCB_Thickness * 0.5 + 0.1 * mm, OuterZ_Wafer_Width * 0.5); + + G4ThreeVector HoleShift = G4ThreeVector(0,0,0.5 * OuterZ_Wafer_Width + 0.5 * OuterZ_PCB_gap); + + G4SubtractionSolid* PCB_temp = new G4SubtractionSolid("PCB", PCBFull, HoleShape, new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_temp, HoleShape,new G4RotationMatrix,-HoleShift); + + + //Sub Volume PCB + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(m_VisPCB); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "TOGAXSI_OuterZ_PCB", m_OuterZDetector, false, 0); + + + ///////////////////////////////////////////////// + // Si Wafer + // Subvolume Wafer + G4Box* WaferShape = new G4Box("WaferShape",0.5 * OuterZ_Wafer_Length, 0.5 * OuterZ_Wafer_Thickness, 0.5 * OuterZ_Wafer_Width); + + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer1->SetVisAttributes(m_VisSi); +// logicWafer1->SetSensitiveDetector(m_OuterScorer1); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer2->SetVisAttributes(m_VisSi); +// logicWafer2->SetSensitiveDetector(m_OuterScorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),-HoleShift, logicWafer1, "TOGAXSI_SI_OuterZ_Wafer 1", m_OuterZDetector, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),HoleShift, logicWafer2, "TOGAXSI_SI_OuterZ_Wafer 2", m_OuterZDetector, false, 1); + + + // Active Wafer + G4Box* ActiveWaferShape = new G4Box("OuterZActiveWaferShape",0.5 * OuterZ_Wafer_Length, 0.5 * OuterZ_Wafer_Thickness, 0.5 * OuterZ_Wafer_Width); + + G4LogicalVolume* logicActiveWafer1 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer1", 0, 0, 0); + logicActiveWafer1->SetVisAttributes(m_VisSi); + logicActiveWafer1->SetSensitiveDetector(m_OuterZScorer1); + G4LogicalVolume* logicActiveWafer2 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer2", 0, 0, 0); + logicActiveWafer2->SetVisAttributes(m_VisSi); + logicActiveWafer2->SetSensitiveDetector(m_OuterZScorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer1, "TOGAXSI_SI_Inner_Wafer", logicWafer1, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer2, "TOGAXSI_SI_Inner_Wafer", logicWafer2, false, 1); + + + } + return m_OuterZDetector; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildClusterInnerDetector(){ + if(!m_ClusterInnerDetector){ + + vector<G4TwoVector> coord; + + coord.push_back(G4TwoVector(0.5 * ClusterInner_Wafer_Base,0.5 * ClusterInner_Wafer_Height)); + coord.push_back(G4TwoVector(-0.5 * ClusterInner_Wafer_Base, 0.5 * ClusterInner_Wafer_Height)); + coord.push_back(G4TwoVector(-0.5 * ClusterInner_Wafer_Top, -0.5 * ClusterInner_Wafer_Height)); + coord.push_back(G4TwoVector(0.5 * ClusterInner_Wafer_Top, -0.5 * ClusterInner_Wafer_Height)); + + cout << "_____________Coordinates______________________" << endl; + cout << coord[0][0] << endl; + cout << coord[1][0] << endl; + cout << coord[2][0] << endl; + cout << coord[3][0] << endl; + cout << coord[0][1] << endl; + cout << coord[1][1] << endl; + cout << coord[2][1] << endl; + cout << coord[3][1] << endl; + + // for (int i = 0; i++; i<4) cout << coord[i][0] << endl; + //for (int i = 0; i++; i<4) cout << coord[i][1] << endl; + + G4ExtrudedSolid* WaferShape = new G4ExtrudedSolid("TOGAXSI_SI_ClusterInnerWaferShape", coord, 0.5 * ClusterInner_Wafer_Thickness, G4TwoVector(0,0), 1., G4TwoVector(0,0), 1.); + + // Master volume ClusterInner Detector + m_ClusterInnerDetector = new G4LogicalVolume(WaferShape,m_MaterialVacuum,"logicClusterInnerDetector",0,0,0); + m_ClusterInnerDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // Sub Volume Wafer + G4LogicalVolume* logicWaferShape = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafershape", 0, 0, 0); + logicWaferShape->SetVisAttributes(m_VisSi); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicWaferShape, "TOGAXSI_ClusterInner", m_ClusterInnerDetector, false, 0); + + // Active Wafer + + vector<G4TwoVector> coord_active; + + coord_active.push_back(G4TwoVector(0.5 * ClusterInner_Wafer_Base,0.5 * ClusterInner_Wafer_Height)); + coord_active.push_back(G4TwoVector(-0.5 * ClusterInner_Wafer_Base, 0.5 * ClusterInner_Wafer_Height)); + coord_active.push_back(G4TwoVector(-0.5 * ClusterInner_Wafer_Top, -0.5 * ClusterInner_Wafer_Height)); + coord_active.push_back(G4TwoVector(0.5 * ClusterInner_Wafer_Top, -0.5 * ClusterInner_Wafer_Height)); + + G4ExtrudedSolid* ActiveWaferShape = new G4ExtrudedSolid("ClusterInnerActiveWaferShape", coord_active, 0.5 * ClusterInner_ActiveWafer_Thickness, G4TwoVector(0,0), 1., G4TwoVector(0,0), 1.); + + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer1", 0, 0, 0); + logicActiveWafer->SetVisAttributes(m_VisSi); +// logicActiveWafer->SetSensitiveDetector(m_ClusterScorer); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer, "TOGAXSI_SI_Inner_Wafer", logicWaferShape, false, 1); + + + } + return m_ClusterInnerDetector; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildClusterX1Detector(){ + if(!m_ClusterX1Detector){ + + + G4Box* PCBFull = new G4Box("TOGAXSI_SI_PCBFull", 0.5 * ClusterX_PCB_Width, 0.5 * ClusterX_PCB_Length, 0.5 * ClusterX_PCB_Thickness); + + + // Master volume inner Detector + m_ClusterX1Detector = new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector",0,0,0); + m_ClusterX1Detector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + + // PCB frame + G4Box* HoleShape = new G4Box("HoleShape", ClusterX_Wafer_Length * 0.5, ClusterX_Wafer_Width * 0.5, ClusterX_PCB_Thickness * 0.5 + 0.1 * mm); + + G4ThreeVector HoleShift = G4ThreeVector(0,0.5 * ClusterX_Wafer_Width + 0.5 * ClusterX_PCB_gap,0); + + G4SubtractionSolid* PCB_temp = new G4SubtractionSolid("PCB", PCBFull, HoleShape, new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_temp, HoleShape,new G4RotationMatrix,-HoleShift); + + + //Sub Volume PCB + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(m_VisPCB); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "TOGAXSI_ClusterX_PCB", m_ClusterX1Detector, false, 0); + + + ///////////////////////////////////////////////// + // Si Wafer + // Subvolume Wafer + G4Box* WaferShape = new G4Box("WaferShape",0.5 * ClusterX_Wafer_Length, 0.5 * ClusterX_Wafer_Width, 0.5 * ClusterX_Wafer_Thickness); + + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer1->SetVisAttributes(m_VisSi); +// logicWafer1->SetSensitiveDetector(m_OuterScorer1); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer2->SetVisAttributes(m_VisSi); +// logicWafer2->SetSensitiveDetector(m_OuterScorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),-HoleShift, logicWafer1, "TOGAXSI_SI_ClusterX_Wafer 1", m_ClusterX1Detector, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),HoleShift, logicWafer2, "TOGAXSI_SI_ClusterX_Wafer 2", m_ClusterX1Detector, false, 1); + + + // Active Wafer + G4Box* ActiveWaferShape = new G4Box("ClusterXActiveWaferShape",0.5 * ClusterX_Wafer_Length, 0.5 * ClusterX_Wafer_Width, 0.5 * ClusterX_Wafer_Thickness); + + G4LogicalVolume* logicActiveWafer1 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer1", 0, 0, 0); + logicActiveWafer1->SetVisAttributes(m_VisSi); + logicActiveWafer1->SetSensitiveDetector(m_ClusterX1Scorer1); + G4LogicalVolume* logicActiveWafer2 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer2", 0, 0, 0); + logicActiveWafer2->SetVisAttributes(m_VisSi); + logicActiveWafer2->SetSensitiveDetector(m_ClusterX1Scorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer1, "TOGAXSI_SI_ClusterX_Wafer", logicWafer1, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer2, "TOGAXSI_SI_ClusterX_Wafer", logicWafer2, false, 1); + + + } + return m_ClusterX1Detector; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildClusterY1Detector(){ + if(!m_ClusterY1Detector){ + + + G4Box* PCBFull = new G4Box("TOGAXSI_SI_PCBFull", 0.5 * ClusterY_PCB_Width, 0.5 * ClusterY_PCB_Length, 0.5 * ClusterY_PCB_Thickness); + + + // Master volume inner Detector + m_ClusterY1Detector = new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector",0,0,0); + m_ClusterY1Detector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + + // PCB frame + G4Box* HoleShape = new G4Box("HoleShape", ClusterY_Wafer_Length * 0.5, ClusterY_Wafer_Width * 0.5, ClusterY_PCB_Thickness * 0.5 + 0.1 * mm); + + G4ThreeVector HoleShift = G4ThreeVector(0,0.5 * ClusterY_Wafer_Width + 0.5 * ClusterY_PCB_gap,0); + + G4SubtractionSolid* PCB_temp = new G4SubtractionSolid("PCB", PCBFull, HoleShape, new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_temp, HoleShape,new G4RotationMatrix,-HoleShift); + + + //Sub Volume PCB + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(m_VisPCB); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "TOGAXSI_ClusterY_PCB", m_ClusterY1Detector, false, 0); + + + ///////////////////////////////////////////////// + // Si Wafer + // Subvolume Wafer + G4Box* WaferShape = new G4Box("WaferShape",0.5 * ClusterY_Wafer_Length, 0.5 * ClusterY_Wafer_Width, 0.5 * ClusterY_Wafer_Thickness); + + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer1->SetVisAttributes(m_VisSi); +// logicWafer1->SetSensitiveDetector(m_OuterScorer1); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer2->SetVisAttributes(m_VisSi); +// logicWafer2->SetSensitiveDetector(m_OuterScorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),-HoleShift, logicWafer1, "TOGAXSI_SI_ClusterY_Wafer 1", m_ClusterY1Detector, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),HoleShift, logicWafer2, "TOGAXSI_SI_ClusterY_Wafer 2", m_ClusterY1Detector, false, 1); + + + // Active Wafer + G4Box* ActiveWaferShape = new G4Box("ClusterYActiveWaferShape",0.5 * ClusterY_Wafer_Length, 0.5 * ClusterY_Wafer_Width, 0.5 * ClusterY_Wafer_Thickness); + + G4LogicalVolume* logicActiveWafer1 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer1", 0, 0, 0); + logicActiveWafer1->SetVisAttributes(m_VisSi); + logicActiveWafer1->SetSensitiveDetector(m_ClusterY1Scorer1); + G4LogicalVolume* logicActiveWafer2 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer2", 0, 0, 0); + logicActiveWafer2->SetVisAttributes(m_VisSi); + logicActiveWafer2->SetSensitiveDetector(m_ClusterY1Scorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer1, "TOGAXSI_SI_ClusterY_Wafer", logicWafer1, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer2, "TOGAXSI_SI_ClusterY_Wafer", logicWafer2, false, 1); + + + } + return m_ClusterY1Detector; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildClusterX2Detector(){ + if(!m_ClusterX2Detector){ + + + G4Box* PCBFull = new G4Box("TOGAXSI_SI_PCBFull", 0.5 * ClusterX_PCB_Width, 0.5 * ClusterX_PCB_Length, 0.5 * ClusterX_PCB_Thickness); + + + // Master volume inner Detector + m_ClusterX2Detector = new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector",0,0,0); + m_ClusterX2Detector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + + // PCB frame + G4Box* HoleShape = new G4Box("HoleShape", ClusterX_Wafer_Length * 0.5, ClusterX_Wafer_Width * 0.5, ClusterX_PCB_Thickness * 0.5 + 0.1 * mm); + + G4ThreeVector HoleShift = G4ThreeVector(0,0.5 * ClusterX_Wafer_Width + 0.5 * ClusterX_PCB_gap,0); + + G4SubtractionSolid* PCB_temp = new G4SubtractionSolid("PCB", PCBFull, HoleShape, new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_temp, HoleShape,new G4RotationMatrix,-HoleShift); + + + //Sub Volume PCB + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(m_VisPCB); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "TOGAXSI_ClusterX_PCB", m_ClusterX2Detector, false, 0); + + + ///////////////////////////////////////////////// + // Si Wafer + // Subvolume Wafer + G4Box* WaferShape = new G4Box("WaferShape",0.5 * ClusterX_Wafer_Length, 0.5 * ClusterX_Wafer_Width, 0.5 * ClusterX_Wafer_Thickness); + + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer1->SetVisAttributes(m_VisSi); +// logicWafer1->SetSensitiveDetector(m_OuterScorer1); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer2->SetVisAttributes(m_VisSi); +// logicWafer2->SetSensitiveDetector(m_OuterScorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),-HoleShift, logicWafer1, "TOGAXSI_SI_ClusterX_Wafer 1", m_ClusterX2Detector, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),HoleShift, logicWafer2, "TOGAXSI_SI_ClusterX_Wafer 2", m_ClusterX2Detector, false, 1); + + + // Active Wafer + G4Box* ActiveWaferShape = new G4Box("ClusterXActiveWaferShape",0.5 * ClusterX_Wafer_Length, 0.5 * ClusterX_Wafer_Width, 0.5 * ClusterX_Wafer_Thickness); + + G4LogicalVolume* logicActiveWafer1 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer1", 0, 0, 0); + logicActiveWafer1->SetVisAttributes(m_VisSi); + logicActiveWafer1->SetSensitiveDetector(m_ClusterX2Scorer1); + G4LogicalVolume* logicActiveWafer2 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer2", 0, 0, 0); + logicActiveWafer2->SetVisAttributes(m_VisSi); + logicActiveWafer2->SetSensitiveDetector(m_ClusterX2Scorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer1, "TOGAXSI_SI_ClusterX_Wafer", logicWafer1, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer2, "TOGAXSI_SI_ClusterX_Wafer", logicWafer2, false, 1); + + + } + return m_ClusterX2Detector; +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildClusterY2Detector(){ + if(!m_ClusterY2Detector){ + + + G4Box* PCBFull = new G4Box("TOGAXSI_SI_PCBFull", 0.5 * ClusterY_PCB_Width, 0.5 * ClusterY_PCB_Length, 0.5 * ClusterY_PCB_Thickness); + + + // Master volume inner Detector + m_ClusterY2Detector = new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector",0,0,0); + m_ClusterY2Detector->SetVisAttributes(G4VisAttributes::GetInvisible()); + + + // PCB frame + G4Box* HoleShape = new G4Box("HoleShape", ClusterY_Wafer_Length * 0.5, ClusterY_Wafer_Width * 0.5, ClusterY_PCB_Thickness * 0.5 + 0.1 * mm); + + G4ThreeVector HoleShift = G4ThreeVector(0,0.5 * ClusterY_Wafer_Width + 0.5 * ClusterY_PCB_gap,0); + + G4SubtractionSolid* PCB_temp = new G4SubtractionSolid("PCB", PCBFull, HoleShape, new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_temp, HoleShape,new G4RotationMatrix,-HoleShift); + + + //Sub Volume PCB + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); + logicPCB->SetVisAttributes(m_VisPCB); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "TOGAXSI_ClusterY_PCB", m_ClusterY2Detector, false, 0); + + + ///////////////////////////////////////////////// + // Si Wafer + // Subvolume Wafer + G4Box* WaferShape = new G4Box("WaferShape",0.5 * ClusterY_Wafer_Length, 0.5 * ClusterY_Wafer_Width, 0.5 * ClusterY_Wafer_Thickness); + + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer1->SetVisAttributes(m_VisSi); +// logicWafer1->SetSensitiveDetector(m_OuterScorer1); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSi, "logicWafer", 0, 0, 0); + logicWafer2->SetVisAttributes(m_VisSi); +// logicWafer2->SetSensitiveDetector(m_OuterScorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),-HoleShift, logicWafer1, "TOGAXSI_SI_ClusterY_Wafer 1", m_ClusterY2Detector, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),HoleShift, logicWafer2, "TOGAXSI_SI_ClusterY_Wafer 2", m_ClusterY2Detector, false, 1); + + + // Active Wafer + G4Box* ActiveWaferShape = new G4Box("ClusterYActiveWaferShape",0.5 * ClusterY_Wafer_Length, 0.5 * ClusterY_Wafer_Width, 0.5 * ClusterY_Wafer_Thickness); + + G4LogicalVolume* logicActiveWafer1 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer1", 0, 0, 0); + logicActiveWafer1->SetVisAttributes(m_VisSi); + logicActiveWafer1->SetSensitiveDetector(m_ClusterY2Scorer1); + G4LogicalVolume* logicActiveWafer2 = new G4LogicalVolume(ActiveWaferShape, m_MaterialSi, "logicActiveWafer2", 0, 0, 0); + logicActiveWafer2->SetVisAttributes(m_VisSi); + logicActiveWafer2->SetSensitiveDetector(m_ClusterY2Scorer2); + + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer1, "TOGAXSI_SI_ClusterY_Wafer", logicWafer1, false, 1); + new G4PVPlacement(new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0), logicActiveWafer2, "TOGAXSI_SI_ClusterY_Wafer", logicWafer2, false, 1); + + + } + return m_ClusterY2Detector; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildTarget(int i) { + + if( i > 0) { + cout << "ERROR: Multiple TOGAXSI target block defined in detector file" << endl; + } + + G4Material* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(m_Target_MaterialName[i]); + G4Tubs* solidTarget = new G4Tubs("Target", 0., m_Target_R[i], m_Target_L[i] / 2., 0, 360.); + m_Target = new G4LogicalVolume(solidTarget, TargetMaterial, "Target"); + m_Target->SetVisAttributes(m_VisTarget); + + return m_Target; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* TOGAXSI_SI::BuildTargetCell(int i) { + if (i>0) { + cout << "ERROR: Multiple TOGAXSI target blocks defined in detector file" << endl; + } + + G4Material* CellMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(m_Target_CellMaterialName[i]); + G4Tubs* CellFull = new G4Tubs("CellFull", 0., m_Target_R[i] + m_Target_CellThickness[i], m_Target_L[i] / 2 + m_Target_CellThickness[i], 0, 360.); + + G4Tubs* CellInterior = new G4Tubs("CellInterior", 0., m_Target_R[i], m_Target_L[i] / 2., 0, 360.); + + G4SubtractionSolid* solidCell = new G4SubtractionSolid("solidCell", CellFull, CellInterior, new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0)); + + m_TargetCell = new G4LogicalVolume(solidCell, CellMaterial, "TargetCell"); + m_TargetCell->SetVisAttributes(m_VisTargetCell); + m_TargetCell->SetSensitiveDetector(m_TargetCellScorer); + + + return m_TargetCell; +} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void TOGAXSI_SI::ReadConfiguration(NPL::InputParser parser){ + + //InnerX Si Tracker + vector<NPL::InputBlock*> blocks_innerX = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","InnerX"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_innerX.size() << " innerX detectors found " << endl; + + vector<string> wafer_innerX = {"Radius","Z","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_innerX.size() ; i++){ + if(blocks_innerX[i]->HasTokenList(wafer_innerX)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_innerX[i]->GetDouble("Radius","mm"); + double Z = blocks_innerX[i]->GetDouble("Z","mm"); + double Phi = blocks_innerX[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_innerX[i]->GetTVector3("Ref","mm")); + AddInnerXDetector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + //InnerZ Si Tracker + vector<NPL::InputBlock*> blocks_innerZ = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","InnerZ"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_innerZ.size() << " innerZ detectors found " << endl; + + vector<string> wafer_innerZ = {"Radius","Z","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_innerZ.size() ; i++){ + if(blocks_innerZ[i]->HasTokenList(wafer_innerZ)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_innerZ[i]->GetDouble("Radius","mm"); + double Z = blocks_innerZ[i]->GetDouble("Z","mm"); + double Phi = blocks_innerZ[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_innerZ[i]->GetTVector3("Ref","mm")); + AddInnerZDetector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + //OuterX Si Tracker + vector<NPL::InputBlock*> blocks_outerX = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","OuterX"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_outerX.size() << " outerX detectors found " << endl; + + vector<string> wafer_outerX = {"Radius","Z","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_outerX.size() ; i++){ + if(blocks_outerX[i]->HasTokenList(wafer_outerX)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_outerX[i]->GetDouble("Radius","mm"); + double Z = blocks_outerX[i]->GetDouble("Z","mm"); + double Phi = blocks_outerX[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_outerX[i]->GetTVector3("Ref","mm")); + AddOuterXDetector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + //OuterZ Si Tracker + vector<NPL::InputBlock*> blocks_outerZ = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","OuterZ"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_outerZ.size() << " outerZ detectors found " << endl; + + vector<string> wafer_outerZ = {"Radius","Z","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_outerZ.size() ; i++){ + if(blocks_outerZ[i]->HasTokenList(wafer_outerZ)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_outerZ[i]->GetDouble("Radius","mm"); + double Z = blocks_outerZ[i]->GetDouble("Z","mm"); + double Phi = blocks_outerZ[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_outerZ[i]->GetTVector3("Ref","mm")); + AddOuterZDetector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + + //ClusterInner Si Tracker + vector<NPL::InputBlock*> blocks_clusterInner = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterInner"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterInner.size() << " cluster detectors found " << endl; + + vector<string> wafer_clusterInner = {"Radius","Z","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_clusterInner.size() ; i++){ + if(blocks_clusterInner[i]->HasTokenList(wafer_clusterInner)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_clusterInner[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterInner[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterInner[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_clusterInner[i]->GetTVector3("Ref","mm")); + AddClusterInnerDetector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + + //ClusterX Si Tracker + vector<NPL::InputBlock*> blocks_clusterX1 = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterX1"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterX1.size() << " ClusterX1 detectors found " << endl; + + vector<string> wafer_cluster = {"Radius","Z","Phi","Ref"}; + + for(unsigned int i = 0 ; i < blocks_clusterX1.size() ; i++){ + if(blocks_clusterX1[i]->HasTokenList(wafer_cluster)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_clusterX1[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterX1[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterX1[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_clusterX1[i]->GetTVector3("Ref","mm")); + AddClusterX1Detector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + //ClusterY Si Tracker + vector<NPL::InputBlock*> blocks_clusterY1 = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterY1"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterY1.size() << " ClusterY1 detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_clusterY1.size() ; i++){ + if(blocks_clusterY1[i]->HasTokenList(wafer_cluster)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_clusterY1[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterY1[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterY1[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_clusterY1[i]->GetTVector3("Ref","mm")); + AddClusterY1Detector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + + //ClusterX2 Si Tracker + vector<NPL::InputBlock*> blocks_clusterX2 = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterX2"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterX2.size() << " ClusterX2 detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_clusterX2.size() ; i++){ + if(blocks_clusterX2[i]->HasTokenList(wafer_cluster)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_clusterX2[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterX2[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterX2[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_clusterX2[i]->GetTVector3("Ref","mm")); + AddClusterX2Detector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + //ClusterY2 Si Tracker + vector<NPL::InputBlock*> blocks_clusterY2 = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","ClusterY2"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_clusterY2.size() << " ClusterY2 detectors found " << endl; + + for(unsigned int i = 0 ; i < blocks_clusterY2.size() ; i++){ + if(blocks_clusterY2[i]->HasTokenList(wafer_cluster)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_clusterY2[i]->GetDouble("Radius","mm"); + double Z = blocks_clusterY2[i]->GetDouble("Z","mm"); + double Phi = blocks_clusterY2[i]->GetDouble("Phi","deg"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_clusterY2[i]->GetTVector3("Ref","mm")); + AddClusterY2Detector(R,Z,Phi,Ref); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + + + //Target + vector<NPL::InputBlock*> blocks_target = parser.GetAllBlocksWithTokenAndValue("TOGAXSI_SI","Target"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_target.size() << " target found " << endl; + + vector<string> targettoken = {"Radius","Length","TargetMaterial","CellMaterial","CellThickness","Pos"}; + + for(unsigned int i = 0 ; i < blocks_target.size() ; i++){ + if(blocks_target[i]->HasTokenList(targettoken)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// TOGAXSI_SI " << i+1 << endl; + double R = blocks_target[i]->GetDouble("Radius","mm"); + double L = blocks_target[i]->GetDouble("Length","mm"); + string TargetMaterialName = blocks_target[i]->GetString("TargetMaterial"); + string CellMaterialName = blocks_target[i]->GetString("CellMaterial"); + double CellThickness = blocks_target[i]->GetDouble("CellThickness","mm"); + G4ThreeVector Pos = NPS::ConvertVector(blocks_target[i]->GetTVector3("Pos","mm")); + AddTarget(R,L,TargetMaterialName,CellMaterialName,CellThickness,Pos); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void TOGAXSI_SI::ConstructDetector(G4LogicalVolume* world){ + + //InnerX Si tracker + cout << "______________Size: " << m_InnerX_R.size() << endl; + for (unsigned short i = 0; i < m_InnerX_R.size(); i++) { + + G4ThreeVector Det_pos = G4ThreeVector(0,m_InnerX_R[i], m_InnerX_Z[i]); + + Det_pos.rotate(-m_InnerX_Phi[i], G4ThreeVector(0,0,1)); +// Det_pos.rotate( 0, G4ThreeVector(0,0,1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_InnerX_Phi[i]); +// G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, 60*deg); + cout << m_InnerX_Phi[i] << endl; + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_InnerX_Ref[i]), BuildInnerXDetector(),"TOGAXSI_SI_InnerX",world, false, i + 1); + + } + + //InnerZ Si tracker + cout << "______________Size: " << m_InnerZ_R.size() << endl; + for (unsigned short i = 0; i < m_InnerZ_R.size(); i++) { + + G4ThreeVector Det_pos = G4ThreeVector(0,m_InnerZ_R[i], m_InnerZ_Z[i]); + + Det_pos.rotate(-m_InnerZ_Phi[i], G4ThreeVector(0,0,1)); +// Det_pos.rotate( 0, G4ThreeVector(0,0,1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_InnerZ_Phi[i]); +// G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, 60*deg); + cout << m_InnerZ_Phi[i] << endl; + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_InnerZ_Ref[i]), BuildInnerZDetector(),"TOGAXSI_SI_InnerZ",world, false, i + 1); + + } + + //OuterX Si tracker + for (unsigned short i = 0; i < m_OuterX_R.size(); i++) { + + G4ThreeVector Det_pos = G4ThreeVector(0,m_OuterX_R[i], m_OuterX_Z[i]); + + Det_pos.rotate(-m_OuterX_Phi[i], G4ThreeVector(0,0,1)); +// Det_pos.rotate( 0, G4ThreeVector(0,0,1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_OuterX_Phi[i]); +// G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, 60*deg); + cout << m_OuterX_Phi[i] << endl; + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_OuterX_Ref[i]), BuildOuterXDetector(),"TOGAXSI_SI_OuterX",world, false, i + 1); + + } + + //OuterZ Si tracker + for (unsigned short i = 0; i < m_OuterZ_R.size(); i++) { + + G4ThreeVector Det_pos = G4ThreeVector(0,m_OuterZ_R[i], m_OuterZ_Z[i]); + + Det_pos.rotate(-m_OuterZ_Phi[i], G4ThreeVector(0,0,1)); +// Det_pos.rotate( 0, G4ThreeVector(0,0,1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_OuterZ_Phi[i]); +// G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, 60*deg); + cout << m_OuterZ_Phi[i] << endl; + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_OuterZ_Ref[i]), BuildOuterZDetector(),"TOGAXSI_SI_OuterZ",world, false, i + 1); + + } + + + //Cluster Si tracker + for (unsigned short i = 0; i < m_ClusterInner_R.size(); i++) { + + G4ThreeVector Det_pos = G4ThreeVector(0,m_ClusterInner_R[i], m_ClusterInner_Z[i]); + + Det_pos.rotate(-m_ClusterInner_Phi[i], G4ThreeVector(0,0,1)); +// Det_pos.rotate( 0, G4ThreeVector(0,0,1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_ClusterInner_Phi[i]); +// G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, 60*deg); + cout << m_ClusterInner_Phi[i] << endl; + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_ClusterInner_Ref[i]), BuildClusterInnerDetector(),"TOGAXSI_SI_ClusterInner",world, false, i + 1); + + } + + //ClusterX1 Si tracker + for (unsigned short i = 0; i < m_ClusterX1_R.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(m_ClusterX1_R[i],0, m_ClusterX1_Z[i]); + + Det_pos.rotate(-m_ClusterX1_Phi[i], G4ThreeVector(0,0,1)); + + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_ClusterX1_Phi[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_ClusterX1_Ref[i]), BuildClusterX1Detector(),"TOGAXSI_SI_ClusterX1",world, false, i + 1); + } + + //ClusterY1 Si tracker + for (unsigned short i = 0; i < m_ClusterY1_R.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(m_ClusterY1_R[i],0, m_ClusterY1_Z[i]); + + Det_pos.rotate(-m_ClusterY1_Phi[i], G4ThreeVector(0,0,1)); + + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_ClusterY1_Phi[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_ClusterY1_Ref[i]), BuildClusterY1Detector(),"TOGAXSI_SI_ClusterY1",world, false, i + 1); + + } + + + //ClusterX1 Si tracker + for (unsigned short i = 0; i < m_ClusterX2_R.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(m_ClusterX2_R[i],0, m_ClusterX2_Z[i]); + + Det_pos.rotate(-m_ClusterX2_Phi[i], G4ThreeVector(0,0,1)); + + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_ClusterX2_Phi[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_ClusterX2_Ref[i]), BuildClusterX2Detector(),"TOGAXSI_SI_ClusterX2",world, false, i + 1); + + } + + //ClusterY2 Si tracker + for (unsigned short i = 0; i < m_ClusterY2_R.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(m_ClusterY2_R[i],0, m_ClusterY2_Z[i]); + + Det_pos.rotate(-m_ClusterY2_Phi[i], G4ThreeVector(0,0,1)); + + G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg, m_ClusterY2_Phi[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_ClusterY2_Ref[i]), BuildClusterY2Detector(),"TOGAXSI_SI_ClusterY2",world, false, i + 1); + + } + + + // Target + G4LogicalVolume* logicTarget[m_Target_R.size()]; + G4LogicalVolume* logicTargetCell[m_Target_R.size()]; + + for (unsigned short i = 0; i < m_Target_R.size(); i++) { + G4ThreeVector Tar_pos = m_Target_Pos[i]; + cout << "TargetPos" << m_Target_Pos[i].z() << endl; + G4RotationMatrix* Rot = new G4RotationMatrix(); + logicTarget[i] = BuildTarget(i); + new G4PVPlacement(Rot, Tar_pos, logicTarget[i], "TOGAXSI_SI_Target", world, false, i + 1); + logicTargetCell[i] = BuildTargetCell(i); + new G4PVPlacement(Rot, Tar_pos, logicTargetCell[i], "TOGAXSI_SI_TargetCell", world, false, i + 1); + + if (!m_ReactionRegion) { + m_ReactionRegion = new G4Region("NPSimulationProcess"); + } + + m_ReactionRegion->AddRootLogicalVolume(m_Target); + m_ReactionRegion->SetUserLimits(new G4UserLimits(1. * mm)); + + G4FastSimulationManager* mng = m_ReactionRegion->GetFastSimulationManager(); + unsigned int size = m_ReactionModel.size(); + for (unsigned int o = 0; o < size; o++) { + mng->RemoveFastSimulationModel(m_ReactionModel[o]); + } + m_ReactionModel.clear(); + + G4VFastSimulationModel* fsm; + fsm = new NPS::BeamReaction("BeamReaction", m_ReactionRegion); + ((NPS::BeamReaction*)fsm)->SetStepSize(1. * mm); + m_ReactionModel.push_back(fsm); + + fsm = new NPS::Decay("Decay", m_ReactionRegion); + m_ReactionModel.push_back(fsm); + + } + +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method +void TOGAXSI_SI::InitializeRootOutput(){ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + if(!pTree->FindBranch("TOGAXSI_SI")){ + pTree->Branch("TOGAXSI_SI", "TTOGAXSI_SIData", &m_Event) ; + } + pTree->SetBranchAddress("TOGAXSI_SI", &m_Event) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void TOGAXSI_SI::ReadSensitive(const G4Event* ){ + m_Event->Clear(); + + /////////// + //InnerX Si tracker scorer + DSSDScorers::PS_Rectangle* InnerXScorer = (DSSDScorers::PS_Rectangle*)m_InnerXScorer->GetPrimitive(0); + + unsigned int size = InnerXScorer->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerXScorer->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerXScorer->GetDetectorLength(i); + int StripLongitudinal = InnerXScorer->GetStripLength(i); + m_Event->SetInnerXE(DetNbr, StripLongitudinal, Energy); + } + } + InnerXScorer->clear(); + + /////////// + //InnerZ Si tracker scorer + DSSDScorers::PS_Rectangle* InnerZScorer = (DSSDScorers::PS_Rectangle*)m_InnerZScorer->GetPrimitive(0); + + size = InnerZScorer->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerZScorer->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerZScorer->GetDetectorWidth(i); + int StripTransverse = InnerZScorer->GetStripWidth(i); + m_Event->SetInnerZE(DetNbr, StripTransverse, Energy); + } + } + + InnerZScorer->clear(); + + + /////////// + //OuterX first Si tracker scorer + DSSDScorers::PS_Rectangle* OuterXScorer1 = (DSSDScorers::PS_Rectangle*)m_OuterXScorer1->GetPrimitive(0); + + size = OuterXScorer1->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterXScorer1->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterXScorer1->GetDetectorLength(i); + int StripLongitudinal = OuterXScorer1->GetStripLength(i); + m_Event->SetOuterXE(DetNbr, StripLongitudinal, Energy); + } + } + + OuterXScorer1->clear(); + + /////////// + //OuterX second Si tracker scorer + DSSDScorers::PS_Rectangle* OuterXScorer2 = (DSSDScorers::PS_Rectangle*)m_OuterXScorer2->GetPrimitive(0); + + size = OuterXScorer2->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterXScorer2->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterXScorer2->GetDetectorLength(i); + int StripLongitudinal = OuterXScorer2->GetStripLength(i); + m_Event->SetOuterXE(DetNbr, StripLongitudinal, Energy); + } + } + + OuterXScorer2->clear(); + + + /////////// + //OuterZ first Si tracker scorer + DSSDScorers::PS_Rectangle* OuterZScorer1 = (DSSDScorers::PS_Rectangle*)m_OuterZScorer1->GetPrimitive(0); + + size = OuterZScorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterZScorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterZScorer1->GetDetectorWidth(i); + int StripTransverse = OuterZScorer1->GetStripWidth(i); + m_Event->SetOuterZE(DetNbr, StripTransverse, Energy); + } + } + + OuterZScorer1->clear(); + + /////////// + //OuterZ second Si tracker scorer + DSSDScorers::PS_Rectangle* OuterZScorer2 = (DSSDScorers::PS_Rectangle*)m_OuterZScorer2->GetPrimitive(0); + + size = OuterZScorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterZScorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterZScorer2->GetDetectorWidth(i); + int StripTransverse = OuterZScorer2->GetStripWidth(i) + OuterZ_Wafer_TransverseStrips; + m_Event->SetOuterZE(DetNbr, StripTransverse, Energy); + } + } + + OuterZScorer2->clear(); + + + /////////// + //ClusterX1 first Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterX1Scorer1 = (DSSDScorers::PS_Rectangle*)m_ClusterX1Scorer1->GetPrimitive(0); + + size = ClusterX1Scorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterX1Scorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterX1Scorer1->GetDetectorWidth(i); + int StripLongitudinal = ClusterX1Scorer1->GetStripLength(i); + m_Event->SetClusterX1E(DetNbr, StripLongitudinal, Energy); + } + } + + ClusterX1Scorer1->clear(); + + /////////// + //ClusterX1 second Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterX1Scorer2 = (DSSDScorers::PS_Rectangle*)m_ClusterX1Scorer2->GetPrimitive(0); + + size = ClusterX1Scorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterX1Scorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterX1Scorer2->GetDetectorWidth(i); + int StripLongitudinal = ClusterX1Scorer2->GetStripLength(i); + m_Event->SetClusterX1E(DetNbr, StripLongitudinal, Energy); + } + } + + ClusterX1Scorer2->clear(); + + + /////////// + //ClusterY1 first Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterY1Scorer1 = (DSSDScorers::PS_Rectangle*)m_ClusterY1Scorer1->GetPrimitive(0); + + size = ClusterY1Scorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterY1Scorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterY1Scorer1->GetDetectorWidth(i); + int StripTransverse = ClusterY1Scorer1->GetStripWidth(i); + m_Event->SetClusterY1E(DetNbr, StripTransverse, Energy); + } + } + + ClusterY1Scorer1->clear(); + + /////////// + //ClusterY1 second Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterY1Scorer2 = (DSSDScorers::PS_Rectangle*)m_ClusterY1Scorer2->GetPrimitive(0); + + size = ClusterY1Scorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterY1Scorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterY1Scorer2->GetDetectorWidth(i); + int StripTransverse = ClusterY1Scorer2->GetStripWidth(i) + ClusterY_Wafer_TransverseStrips; + m_Event->SetClusterY1E(DetNbr, StripTransverse, Energy); + } + } + + ClusterY1Scorer2->clear(); + + + + /////////// + //ClusterX2 first Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterX2Scorer1 = (DSSDScorers::PS_Rectangle*)m_ClusterX2Scorer1->GetPrimitive(0); + + size = ClusterX2Scorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterX2Scorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterX2Scorer1->GetDetectorWidth(i); + int StripLongitudinal = ClusterX2Scorer1->GetStripLength(i); + m_Event->SetClusterX2E(DetNbr, StripLongitudinal, Energy); + } + } + + ClusterX2Scorer1->clear(); + + /////////// + //ClusterX1 second Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterX2Scorer2 = (DSSDScorers::PS_Rectangle*)m_ClusterX2Scorer2->GetPrimitive(0); + + size = ClusterX2Scorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterX2Scorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterX2Scorer2->GetDetectorWidth(i); + int StripLongitudinal = ClusterX2Scorer2->GetStripLength(i); + m_Event->SetClusterX2E(DetNbr, StripLongitudinal, Energy); + } + } + + ClusterX2Scorer2->clear(); + + + /////////// + //ClusterY1 first Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterY2Scorer1 = (DSSDScorers::PS_Rectangle*)m_ClusterY2Scorer1->GetPrimitive(0); + + size = ClusterY2Scorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterY2Scorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterY2Scorer1->GetDetectorWidth(i); + int StripTransverse = ClusterY2Scorer1->GetStripWidth(i); + m_Event->SetClusterY2E(DetNbr, StripTransverse, Energy); + } + } + + ClusterY2Scorer1->clear(); + + /////////// + //ClusterY2 second Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterY2Scorer2 = (DSSDScorers::PS_Rectangle*)m_ClusterY2Scorer2->GetPrimitive(0); + + size = ClusterY2Scorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterY2Scorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterY2Scorer2->GetDetectorWidth(i); + int StripTransverse = ClusterY2Scorer2->GetStripWidth(i) + ClusterY_Wafer_TransverseStrips; + m_Event->SetClusterY2E(DetNbr, StripTransverse, Energy); + } + } + + ClusterY2Scorer2->clear(); + + + /////////// + //ClusterInner Si tracker scorer + DSSDScorers::PS_Rectangle* ClusterInnerScorer = (DSSDScorers::PS_Rectangle*)m_ClusterInnerScorer->GetPrimitive(0); + + size = ClusterInnerScorer->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(ClusterInnerScorer->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = ClusterInnerScorer->GetDetectorWidth(i); + int StripTransverse = ClusterInnerScorer->GetStripWidth(i); + m_Event->SetClusterInnerE(DetNbr, StripTransverse, Energy); + } + } + ClusterInnerScorer->clear(); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////// +void TOGAXSI_SI::InitializeScorers() { + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + m_InnerXScorer = CheckScorer("InnerXScorer", already_exist); + m_InnerZScorer = CheckScorer("InnerZScorer", already_exist); + + m_OuterXScorer1 = CheckScorer("OuterXScorer1", already_exist); + m_OuterXScorer2 = CheckScorer("OuterXScorer2", already_exist); + + m_OuterZScorer1 = CheckScorer("OuterZScorer1", already_exist); + m_OuterZScorer2 = CheckScorer("OuterZScorer2", already_exist); + + m_ClusterInnerScorer = CheckScorer("ClusterInnerScorer", already_exist); + + m_ClusterX1Scorer1 = CheckScorer("ClusterX1Scorer1", already_exist); + m_ClusterX1Scorer2 = CheckScorer("ClusterX1Scorer2", already_exist); + m_ClusterY1Scorer1 = CheckScorer("ClusterY1Scorer1", already_exist); + m_ClusterY1Scorer2 = CheckScorer("ClusterY1Scorer2", already_exist); + m_ClusterX2Scorer1 = CheckScorer("ClusterX2Scorer1", already_exist); + m_ClusterX2Scorer2 = CheckScorer("ClusterX2Scorer2", already_exist); + m_ClusterY2Scorer1 = CheckScorer("ClusterY2Scorer1", already_exist); + m_ClusterY2Scorer2 = CheckScorer("ClusterY2Scorer2", already_exist); + + m_TargetCellScorer = CheckScorer("TargetCellScorer", already_exist); + + if(already_exist) + return ; + + // Otherwise the scorer is initialised + //Si tracker InnerX + G4VPrimitiveScorer* InnerXScorer = new DSSDScorers::PS_Rectangle("InnerXScorer", 2, InnerX_Wafer_Width, InnerX_Wafer_Length, InnerX_Wafer_LongitudinalStrips, InnerX_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InteractionInnerX = new InteractionScorers::PS_Interactions("InteractionInnerX", ms_InterCoord, 0); + + //Si tracker InnerZ + G4VPrimitiveScorer* InnerZScorer = new DSSDScorers::PS_Rectangle("InnerZScorer", 2, InnerZ_Wafer_Width, InnerZ_Wafer_Length, InnerZ_Wafer_LongitudinalStrips, InnerZ_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InteractionInnerZ = new InteractionScorers::PS_Interactions("InteractionInnerZ", ms_InterCoord, 0); + + + //Si tracker OuterX + G4VPrimitiveScorer* OuterXScorer1 = new DSSDScorers::PS_Rectangle("OuterXScorer1", 2, OuterX_Wafer_Length, OuterX_Wafer_Width, OuterX_Wafer_LongitudinalStrips, OuterX_Wafer_TransverseStrips, 0, "xz"); + G4VPrimitiveScorer* OuterXScorer2 = new DSSDScorers::PS_Rectangle("OuterXScorer2", 2, OuterX_Wafer_Length, OuterX_Wafer_Width, OuterX_Wafer_LongitudinalStrips, OuterX_Wafer_TransverseStrips, 0, "xz"); + +// G4VPrimitiveScorer* OuterXScorer1 = new DSSDScorers::PS_Rectangle("OuterXScorer1", 2, OuterX_Wafer_Width, OuterX_Wafer_Length, OuterX_Wafer_LongitudinalStrips, OuterX_Wafer_TransverseStrips, 0, "xz"); +// G4VPrimitiveScorer* OuterXScorer2 = new DSSDScorers::PS_Rectangle("OuterXScorer2", 2, OuterX_Wafer_Width, OuterX_Wafer_Length, OuterX_Wafer_LongitudinalStrips, OuterX_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InteractionOuterX1 = new InteractionScorers::PS_Interactions("InteractionOuterX1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionOuterX2 = new InteractionScorers::PS_Interactions("InteractionOuterX2", ms_InterCoord, 0); + + //Si tracker OuterZ + G4VPrimitiveScorer* OuterZScorer1 = new DSSDScorers::PS_Rectangle("OuterZScorer1", 2, OuterZ_Wafer_Length, OuterZ_Wafer_Width, OuterZ_Wafer_LongitudinalStrips, OuterZ_Wafer_TransverseStrips, 0, "xz"); + G4VPrimitiveScorer* OuterZScorer2 = new DSSDScorers::PS_Rectangle("OuterZScorer2", 2, OuterZ_Wafer_Length, OuterZ_Wafer_Width, OuterZ_Wafer_LongitudinalStrips, OuterZ_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InteractionOuterZ1 = new InteractionScorers::PS_Interactions("InteractionOuterZ1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionOuterZ2 = new InteractionScorers::PS_Interactions("InteractionOuterZ2", ms_InterCoord, 0); + + + //Si tracker Cluster + G4VPrimitiveScorer* ClusterInnerScorer = new DSSDScorers::PS_Rectangle("ClusterInnerScorer", 2, ClusterInner_Wafer_Height, ClusterInner_Wafer_Base, ClusterInner_Wafer_LongitudinalStrips, ClusterInner_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InteractionClusterInner = new InteractionScorers::PS_Interactions("InteractionClusterInner", ms_InterCoord, 0); + + + //Si tracker Cluster1 demonstrator + G4VPrimitiveScorer* ClusterX1Scorer1 = new DSSDScorers::PS_Rectangle("ClusterX1Scorer1", 2, ClusterX_Wafer_Length, ClusterX_Wafer_Width, ClusterX_Wafer_LongitudinalStrips, ClusterX_Wafer_TransverseStrips, 0, "xy"); + G4VPrimitiveScorer* ClusterX1Scorer2 = new DSSDScorers::PS_Rectangle("ClusterX1Scorer2", 2, ClusterX_Wafer_Length, ClusterX_Wafer_Width, ClusterX_Wafer_LongitudinalStrips, ClusterX_Wafer_TransverseStrips, 0, "xy"); + + G4VPrimitiveScorer* InteractionClusterX1_1 = new InteractionScorers::PS_Interactions("InteractionClusterX1_1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionClusterX1_2 = new InteractionScorers::PS_Interactions("InteractionClusterX1_2", ms_InterCoord, 0); + + G4VPrimitiveScorer* ClusterY1Scorer1 = new DSSDScorers::PS_Rectangle("ClusterY1Scorer1", 2, ClusterY_Wafer_Length, ClusterY_Wafer_Width, ClusterY_Wafer_LongitudinalStrips, ClusterY_Wafer_TransverseStrips, 0, "xy"); + G4VPrimitiveScorer* ClusterY1Scorer2 = new DSSDScorers::PS_Rectangle("ClusterY1Scorer2", 2, ClusterY_Wafer_Length, ClusterY_Wafer_Width, ClusterY_Wafer_LongitudinalStrips, ClusterY_Wafer_TransverseStrips, 0, "xy"); + + G4VPrimitiveScorer* InteractionClusterY1_1 = new InteractionScorers::PS_Interactions("InteractionClusterY1_1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionClusterY1_2 = new InteractionScorers::PS_Interactions("InteractionClusterY1_2", ms_InterCoord, 0); + + //Si tracker Cluster2 demonstrator + G4VPrimitiveScorer* ClusterX2Scorer1 = new DSSDScorers::PS_Rectangle("ClusterX2Scorer1", 2, ClusterX_Wafer_Length, ClusterX_Wafer_Width, ClusterX_Wafer_LongitudinalStrips, ClusterX_Wafer_TransverseStrips, 0, "xy"); + G4VPrimitiveScorer* ClusterX2Scorer2 = new DSSDScorers::PS_Rectangle("ClusterX2Scorer2", 2, ClusterX_Wafer_Length, ClusterX_Wafer_Width, ClusterX_Wafer_LongitudinalStrips, ClusterX_Wafer_TransverseStrips, 0, "xy"); + + G4VPrimitiveScorer* InteractionClusterX2_1 = new InteractionScorers::PS_Interactions("InteractionClusterX2_1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionClusterX2_2 = new InteractionScorers::PS_Interactions("InteractionClusterX2_2", ms_InterCoord, 0); + + G4VPrimitiveScorer* ClusterY2Scorer1 = new DSSDScorers::PS_Rectangle("ClusterY2Scorer1", 2, ClusterY_Wafer_Length, ClusterY_Wafer_Width, ClusterY_Wafer_LongitudinalStrips, ClusterY_Wafer_TransverseStrips, 0, "xy"); + G4VPrimitiveScorer* ClusterY2Scorer2 = new DSSDScorers::PS_Rectangle("ClusterY2Scorer2", 2, ClusterY_Wafer_Length, ClusterY_Wafer_Width, ClusterY_Wafer_LongitudinalStrips, ClusterY_Wafer_TransverseStrips, 0, "xy"); + + G4VPrimitiveScorer* InteractionClusterY2_1 = new InteractionScorers::PS_Interactions("InteractionClusterY2_1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionClusterY2_2 = new InteractionScorers::PS_Interactions("InteractionClusterY2_2", ms_InterCoord, 0); + + //TargetCell +// G4VPrimitiveScorer* TargetCellScorer = new PS_CalorimeterScorers::PS_Calorimeter("ClusterY2Scorer1", 2, ClusterY_Wafer_Length, ClusterY_Wafer_Width, ClusterY_Wafer_LongitudinalStrips, ClusterY_Wafer_TransverseStrips, 0, "xy"); + + G4VPrimitiveScorer* InteractionTargetCell = new InteractionScorers::PS_Interactions("InteractionTargetCell", ms_InterCoord, 0); + + + + //and register it to the multifunctionnal detector + m_InnerXScorer->RegisterPrimitive(InnerXScorer); + m_InnerXScorer->RegisterPrimitive(InteractionInnerX); + m_InnerZScorer->RegisterPrimitive(InnerZScorer); + m_InnerZScorer->RegisterPrimitive(InteractionInnerZ); + + m_OuterXScorer1->RegisterPrimitive(OuterXScorer1); + m_OuterXScorer1->RegisterPrimitive(InteractionOuterX1); + m_OuterXScorer2->RegisterPrimitive(OuterXScorer2); + m_OuterXScorer2->RegisterPrimitive(InteractionOuterX2); + + m_OuterZScorer1->RegisterPrimitive(OuterZScorer1); + m_OuterZScorer1->RegisterPrimitive(InteractionOuterZ1); + m_OuterZScorer2->RegisterPrimitive(OuterZScorer2); + m_OuterZScorer2->RegisterPrimitive(InteractionOuterZ2); + + m_ClusterInnerScorer->RegisterPrimitive(ClusterInnerScorer); + m_ClusterInnerScorer->RegisterPrimitive(InteractionClusterInner); + + m_ClusterX1Scorer1->RegisterPrimitive(ClusterX1Scorer1); + m_ClusterX1Scorer1->RegisterPrimitive(InteractionClusterX1_1); + m_ClusterX1Scorer2->RegisterPrimitive(ClusterX1Scorer2); + m_ClusterX1Scorer2->RegisterPrimitive(InteractionClusterX1_2); + m_ClusterY1Scorer1->RegisterPrimitive(ClusterY1Scorer1); + m_ClusterY1Scorer1->RegisterPrimitive(InteractionClusterY1_1); + m_ClusterY1Scorer2->RegisterPrimitive(ClusterY1Scorer2); + m_ClusterY1Scorer2->RegisterPrimitive(InteractionClusterY1_2); + + m_ClusterX2Scorer1->RegisterPrimitive(ClusterX2Scorer1); + m_ClusterX2Scorer1->RegisterPrimitive(InteractionClusterX2_1); + m_ClusterX2Scorer2->RegisterPrimitive(ClusterX2Scorer2); + m_ClusterX2Scorer2->RegisterPrimitive(InteractionClusterX2_2); + m_ClusterY2Scorer1->RegisterPrimitive(ClusterY2Scorer1); + m_ClusterY2Scorer1->RegisterPrimitive(InteractionClusterY2_1); + m_ClusterY2Scorer2->RegisterPrimitive(ClusterY2Scorer2); + m_ClusterY2Scorer2->RegisterPrimitive(InteractionClusterY2_2); + +// m_TargetCellScorer->RegisterPrimitive(TargetCellScorer); + m_TargetCellScorer->RegisterPrimitive(InteractionTargetCell); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerXScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerZScorer); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterXScorer1); + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterXScorer2); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterZScorer1); + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterZScorer2); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterInnerScorer); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterX1Scorer1); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterX1Scorer2); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterY1Scorer1); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterY1Scorer2); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterX2Scorer1); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterX2Scorer2); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterY2Scorer1); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ClusterY2Scorer2); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_TargetCellScorer); + +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* TOGAXSI_SI::Construct(){ + return (NPS::VDetector*) new TOGAXSI_SI(); +} + +void TOGAXSI_SI::InitializeMaterial() { + m_MaterialSi = MaterialManager::getInstance()->GetMaterialFromLibrary("Si");//SI + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB");//PCB +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy_nps_TOGAXSI_SI{ + public: + proxy_nps_TOGAXSI_SI(){ + NPS::DetectorFactory::getInstance()->AddToken("TOGAXSI_SI","TOGAXSI_SI"); + NPS::DetectorFactory::getInstance()->AddDetector("TOGAXSI_SI",TOGAXSI_SI::Construct); + } + }; + + proxy_nps_TOGAXSI_SI p_nps_TOGAXSI_SI; +} diff --git a/NPSimulation/Detectors/TOGAXSI_SI/TOGAXSI_SI.hh b/NPSimulation/Detectors/TOGAXSI_SI/TOGAXSI_SI.hh new file mode 100644 index 000000000..054d5c250 --- /dev/null +++ b/NPSimulation/Detectors/TOGAXSI_SI/TOGAXSI_SI.hh @@ -0,0 +1,236 @@ +#ifndef TOGAXSI_SI_h +#define TOGAXSI_SI_h 1 +/***************************************************************************** + * Copyright (C) 2009-2024 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Thomas Pohl contact address: thomas.pohl@riken.jp * + * * + * Creation Date : February 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TOGAXSI_SI simulation * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// C++ header +#include <string> +#include <vector> +using namespace std; + +// G4 headers +#include "G4ThreeVector.hh" +#include "G4RotationMatrix.hh" +#include "G4LogicalVolume.hh" +#include "G4MultiFunctionalDetector.hh" + +#include "G4FastSimulationManager.hh" +#include "G4UserLimits.hh" +#include "G4VFastSimulationModel.hh" + +// NPTool header +#include "NPSVDetector.hh" +#include "TTOGAXSI_SIData.h" +#include "NPInputParser.h" + +#include "BeamReaction.hh" +#include "Decay.hh" + +class TOGAXSI_SI : public NPS::VDetector{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + public: + TOGAXSI_SI() ; + virtual ~TOGAXSI_SI() ; + + //////////////////////////////////////////////////// + /////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// + public: + // Cylindrical Coordinates + void AddInnerXDetector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddInnerZDetector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddOuterXDetector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddOuterZDetector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddClusterInnerDetector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddClusterX1Detector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddClusterY1Detector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddClusterX2Detector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddClusterY2Detector(double R, double Z, double Phi, G4ThreeVector Ref); + void AddTarget(double R, double L, string Materialname, string CellMaterialname, double CellThickness, G4ThreeVector Pos); + + + G4LogicalVolume* BuildInnerXDetector(); + G4LogicalVolume* BuildInnerZDetector(); + G4LogicalVolume* BuildOuterXDetector(); + G4LogicalVolume* BuildOuterZDetector(); + G4LogicalVolume* BuildClusterInnerDetector(); + G4LogicalVolume* BuildClusterX1Detector(); + G4LogicalVolume* BuildClusterY1Detector(); + G4LogicalVolume* BuildClusterX2Detector(); + G4LogicalVolume* BuildClusterY2Detector(); + G4LogicalVolume* BuildTarget(int i); + G4LogicalVolume* BuildTargetCell(int i); + + + private: + G4LogicalVolume* m_InnerXDetector; + G4LogicalVolume* m_InnerZDetector; + G4LogicalVolume* m_OuterXDetector; + G4LogicalVolume* m_OuterZDetector; + G4LogicalVolume* m_ClusterInnerDetector; + G4LogicalVolume* m_ClusterX1Detector; + G4LogicalVolume* m_ClusterY1Detector; + G4LogicalVolume* m_ClusterX2Detector; + G4LogicalVolume* m_ClusterY2Detector; + G4LogicalVolume* m_Target; + G4LogicalVolume* m_TargetCell; + + private: + // Initialize material used in detector definition + void InitializeMaterial(); + + // List of material + G4Material* m_MaterialSi; + G4Material* m_MaterialVacuum; + G4Material* m_MaterialPCB; + + // Calculated dimensions + double m_Active_InnerXWafer_Width; + double m_Active_InnerXWafer_Length; + double m_Active_InnerZWafer_Width; + double m_Active_InnerZWafer_Length; + double m_Active_OuterXWafer_Width; + double m_Active_OuterXWafer_Length; + double m_Active_OuterZWafer_Width; + double m_Active_OuterZWafer_Length; + + //////////////////////////////////////////////////// + ////// Inherite from NPS::VDetector class ///////// + //////////////////////////////////////////////////// + public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(NPL::InputParser) ; + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world) ; + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput() ; + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event) ; + + public: // Scorer + // Initialize all Scorer used by the MUST2Array + void InitializeScorers() ; + + // Associated Scorer + G4MultiFunctionalDetector* m_InnerXScorer; + G4MultiFunctionalDetector* m_InnerZScorer; + G4MultiFunctionalDetector* m_OuterXScorer1; + G4MultiFunctionalDetector* m_OuterXScorer2; + G4MultiFunctionalDetector* m_OuterZScorer1; + G4MultiFunctionalDetector* m_OuterZScorer2; + G4MultiFunctionalDetector* m_ClusterInnerScorer; + G4MultiFunctionalDetector* m_ClusterX1Scorer1; + G4MultiFunctionalDetector* m_ClusterX1Scorer2; + G4MultiFunctionalDetector* m_ClusterY1Scorer1; + G4MultiFunctionalDetector* m_ClusterY1Scorer2; + G4MultiFunctionalDetector* m_ClusterX2Scorer1; + G4MultiFunctionalDetector* m_ClusterX2Scorer2; + G4MultiFunctionalDetector* m_ClusterY2Scorer1; + G4MultiFunctionalDetector* m_ClusterY2Scorer2; + G4MultiFunctionalDetector* m_TargetCellScorer; + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// + private: + TTOGAXSI_SIData* m_Event ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// + private: // Geometry + // Detector Coordinate + vector<double> m_InnerX_R; + vector<double> m_InnerX_Z; + vector<double> m_InnerX_Phi; + vector<G4ThreeVector> m_InnerX_Ref; + vector<double> m_InnerZ_R; + vector<double> m_InnerZ_Z; + vector<double> m_InnerZ_Phi; + vector<G4ThreeVector> m_InnerZ_Ref; + + vector<double> m_OuterX_R; + vector<double> m_OuterX_Z; + vector<double> m_OuterX_Phi; + vector<G4ThreeVector> m_OuterX_Ref; + vector<double> m_OuterZ_R; + vector<double> m_OuterZ_Z; + vector<double> m_OuterZ_Phi; + vector<G4ThreeVector> m_OuterZ_Ref; + + vector<double> m_ClusterInner_R; + vector<double> m_ClusterInner_Z; + vector<double> m_ClusterInner_Phi; + vector<G4ThreeVector> m_ClusterInner_Ref; + + vector<double> m_ClusterX1_R; + vector<double> m_ClusterX1_Z; + vector<double> m_ClusterX1_Phi; + vector<G4ThreeVector> m_ClusterX1_Ref; + + vector<double> m_ClusterY1_R; + vector<double> m_ClusterY1_Z; + vector<double> m_ClusterY1_Phi; + vector<G4ThreeVector> m_ClusterY1_Ref; + + vector<double> m_ClusterX2_R; + vector<double> m_ClusterX2_Z; + vector<double> m_ClusterX2_Phi; + vector<G4ThreeVector> m_ClusterX2_Ref; + + vector<double> m_ClusterY2_R; + vector<double> m_ClusterY2_Z; + vector<double> m_ClusterY2_Phi; + vector<G4ThreeVector> m_ClusterY2_Ref; + + // Target Coordinate + vector<double> m_Target_R; + vector<double> m_Target_L; + vector<string> m_Target_MaterialName; + vector<string> m_Target_CellMaterialName; + vector<double> m_Target_CellThickness; + vector<G4ThreeVector> m_Target_Pos; + + //Region were reaction can occure: + G4Region *m_ReactionRegion; + vector<G4VFastSimulationModel*> m_ReactionModel; + + + // Visualisation Attribute + G4VisAttributes* m_VisSi; + G4VisAttributes* m_VisPCB; + G4VisAttributes* m_VisTarget; + G4VisAttributes* m_VisTargetCell; + + + // Needed for dynamic loading of the library + public: + static NPS::VDetector* Construct(); +}; +#endif diff --git a/Projects/TOGAXSI_GAGG/Analysis.cxx b/Projects/TOGAXSI_GAGG/Analysis.cxx new file mode 100644 index 000000000..61bce7434 --- /dev/null +++ b/Projects/TOGAXSI_GAGG/Analysis.cxx @@ -0,0 +1,136 @@ +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TOGAXSI_GAGG analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + IC = new TInitialConditions; + DC = new TInteractionCoordinates; + RC = new TReactionConditions; + + InitOutputBranch(); + InitInputBranch(); + + TOGAXSI_GAGG= (TTOGAXSI_GAGGPhysicsPhysics*) m_DetectorManager->GetDetector("TOGAXSI_GAGG"); + + m_QFS = new NPL::QFS(); + m_QFS->ReadConfiguration(NOptionManager::getInstance()->GetReactionFile()); + + myBeam = new NPL::QFS(); + myBeam->ReadConfigurationFile(NPOptionManager::getInstance()->GetReactionFile()); + InitialBeamEnergy = myBeam->GetEnergy(); + + TargetThickness = 150*mm; + string TargetMaterial = "LH2"; + string BeamName = NPL::ChangeNameToG4Standard(myBeam->GetName()); + + rand = new TRandom3(); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ + ReInitValue(); + unsigned int size = TOGAXSI_GAGG->GetEventMultiplicity(); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ +} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitOutputBranch() { +// RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex, "Ex/D"); +// RootOutput::getInstance()->GetTree()->Branch("E1",&E1, "E1/D"); +// RootOutput::getInstance()->GetTree()->Branch("E2",&E2, "E2/D"); +// RootOutput::getInstance()->GetTree()->Branch("Theta12",&Theta12, "Theta12/D"); +// RootOutput::getInstance()->GetTree()->Branch("ThetaCM",&ThetaCM, "ThetaCM/D"); +// RootOutput::getInstance()->GetTree()->Branch("VertexX",&VertexX, "VertexX/D"); +// RootOutput::getInstance()->GetTree()->Branch("VertexY",&VertexY, "VertexY/D"); +// RootOutput::getInstance()->GetTree()->Branch("VertexZ",&VertexZ, "VertexZ/D"); +// RootOutput::getInstance()->GetTree()->Branch("deltaX",&deltaX, "deltaX/D"); +// RootOutput::getInstance()->GetTree()->Branch("deltaY",&deltaY, "deltaY/D"); +// RootOutput::getInstance()->GetTree()->Branch("deltaZ",&deltaZ, "deltaZ/D"); +} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitInputBranch() { + RootInput::getInstance()->GetChain()->SetBranchAddress("InteractionCoordinates",&DC); + RootInput::getInstance()->GetChain()->SetBranchAddress("ReactionConditions",&RC); +} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::ReInitValue() { + Ex = -1000; + E1 = -1000; + E2 = -1000; + Theta12 = -1000; + ThetaCM = -1000; + VertexX = -1000; + VertexY = -1000; + VertexZ = -1000; + deltaX = -1000; + deltaY = -1000; + deltaZ = -1000; + Distance = -1000; + sumTheta = -1000; + deltaPhi = -1000; + alpha = -1000; + Theta1 = -1000; + Phi1 = -1000; + Theta2 = -1000; + Phi2 = -1000; + Theta1s = -1000; + Phi1s = -1000; + Theta2s = -1000; + Phi2s = -1000; + TA = -1000; + TAcalc = -1000; +} + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VAnalysis* Analysis::Construct(){ + return (NPL::VAnalysis*) new Analysis(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy{ + public: + proxy(){ + NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } +}; + +proxy p; +} + diff --git a/Projects/TOGAXSI_GAGG/Analysis.h b/Projects/TOGAXSI_GAGG/Analysis.h new file mode 100644 index 000000000..c15a785c4 --- /dev/null +++ b/Projects/TOGAXSI_GAGG/Analysis.h @@ -0,0 +1,112 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TOGAXSI_GAGG analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include"NPVAnalysis.h" +#include"TTOGAXSI_GAGGPhysics.h" + +#include "NPQFS.h" +#include "RootOutput.h" +#include "RootInput.h" +#include "TInititalConditions.h" +#include "TInteractionCoordinates.h" +#include "TReactionConditions.h" + +#include <TVector3.h> +#include <TLorentzVector.h> +#include <TMath.h> + +class Analysis: public NPL::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + + void InitOutputBranch(); + void InitInputBranch(); + void ReInitValue(); + + static NPL::VAnalysis* Construct(); + + private: + double Ex; + double E1; + double E2; + double E1s; + double E2s; + double Theta12; + double ThetaCM; + double VertexX; + double VertexY; + double VertexZ; + double deltaX; + double deltaY; + double deltaZ; + double Distance; + double deltaPhi; + double sumTheta; + double alpha; + double Theta1=-1000; + double Phi1=-1000; + double Theta2=-1000; + double Phi2=-1000; + double Theta1s=-1000; + double Phi1s=-1000; + double Theta2s=-1000; + double Phi2s=-1000; + double TA; + double TAcalc; + + TRandom3 *rand; + + TLorentzVector LV_A; + TLorentzVector LV_T; + TLorentzVector LV_B; + TLorentzVector LV_p1; + TLorentzVector LV_p2; + + NPL::BEAM* myBeam; + NPL::QFS* m_QFS; + + EnergyLoss BeamTarget; + EnergyLoss protonTarget; + EnergyLoss protonAl; + EnergyLoss protonSi; + double ReconstructProtonEnergy(const TVector3& x0, const TVector3& dir, const double& Ecatana); + + TVector3 BeamImpact; + double TargetThickness; + double InitialBeamEnergy; + + TRandom3 Rand; + TInitialConditions* IC; + TInteractionCoordinates* DC; + TReactionConditions* RC; + + TTOGAXSI_GAGGPhysics* TOGAXSI_GAGG; + +}; +#endif diff --git a/Projects/TOGAXSI_GAGG/CMakeLists.txt b/Projects/TOGAXSI_GAGG/CMakeLists.txt new file mode 100644 index 000000000..22c74affd --- /dev/null +++ b/Projects/TOGAXSI_GAGG/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.8) +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +# include the default NPAnalysis cmake file +include("../../NPLib/ressources/CMake/NPAnalysis.cmake") diff --git a/Projects/TOGAXSI_GAGG/TOGAXSI_GAGG.detector b/Projects/TOGAXSI_GAGG/TOGAXSI_GAGG.detector new file mode 100644 index 000000000..86527ec08 --- /dev/null +++ b/Projects/TOGAXSI_GAGG/TOGAXSI_GAGG.detector @@ -0,0 +1,37 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TOGAXSI_GAGG Target + Radius= 15 mm + Length= 150 mm + TargetMaterial= LH2 + CellMaterial= Mylar + CellThickness= 0.15 mm + Pos = 0 0 0 mm + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias RecoilArrayPhi + Action= Copy + Value= 0. 60.0 120.0 180.0 240.0 300.0 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias RecoilArrayPos + Action= Copy + Value= (-37 150 50) (0 150 50) (37. 150 50) (-55.5 187 50) (-18.5 187. 50) (18.5 187. 50) (55 187 50) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TOGAXSI_GAGG RecoilArray + POS = @RecoilArrayPos mm + Phi = @RecoilArrayPhi deg + Ref = 0 0 0 mm + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias ClusterArrayPhi + Action= Copy + Value= 0. 180.0 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias ClusterArrayPos + Action= Copy + Value= (-92.5 167.5 350) (-55.5 167.5 350) (-18.5 167.5 350) (18.5 167.5 350) (55.5 167.5 350) (92.5 167.5 350) (-111 130.5 350) (-74 130.5 350) (-37 130.5 350) (0 130.5 350) (37 130.5 350) (74 130.5 350) (111 130.5 350) (-129.5 93.5 350) (-92.5 93.5 350) (-55.5 93.5 350) (-18.5 93.5 350) (18.5 93.5 350) (55.5 93.5 350) (92.5 93.5 350) (129.5 93.5 350) (-148 56.5 350) (-111 56.5 350) (-74 56.5 350) (-37 56.5 350) (0 56.5 350) (37 56.5 350) (74 56.5 350) (111 56.5 350) (148 56.5 350) (-166.5 19.5 350) (-129.5 19.5 350) (-92.5 19.5 350) (-55.5 19.5 350) (55.5 19.5 350) (92.5 19.5 350) (129.5 19.5 350) (166.5 19.5 350) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TOGAXSI_GAGG ClusterArray + POS = @ClusterArrayPos mm + Phi = @ClusterArrayPhi deg + Ref = 0 0 0 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Projects/TOGAXSI_SI/Analysis.cxx b/Projects/TOGAXSI_SI/Analysis.cxx new file mode 100644 index 000000000..e9aa6fd33 --- /dev/null +++ b/Projects/TOGAXSI_SI/Analysis.cxx @@ -0,0 +1,900 @@ +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TOGAXSI_SI analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +#include "NPFunction.h" +#include "NPOptionManager.h" +#include "NPPhysicalConstants.h" +#include "NPTrackingUtility.h" +#include "TRandom3.h" + +#include "Math/Plane3D.h" + +using namespace ROOT::Math; + +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + IC = new TInitialConditions; + DC = new TInteractionCoordinates; + RC = new TReactionConditions; + + InitOutputBranch(); + InitInputBranch(); + + TOGAXSI_SI= (TTOGAXSI_SIPhysics*) m_DetectorManager->GetDetector("TOGAXSI_SI"); + + m_QFS = new NPL::QFS(); + m_QFS->ReadConfigurationFile(NPOptionManager::getInstance()->GetReactionFile()); + + myBeam = new NPL::Beam(); + myBeam->ReadConfigurationFile(NPOptionManager::getInstance()->GetReactionFile()); + InitialBeamEnergy = myBeam->GetEnergy(); + + TargetThickness = 150*mm; + string TargetMaterial = "LH2"; + //Energyloss Tables + string BeamName = NPL::ChangeNameToG4Standard(myBeam->GetName()); + + rand = new TRandom3(); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ + + ReInitValue(); + + bool perfectBeamEnergy = false; + bool perfectBeamTracking = false; + bool perfectProtonTracking = true; + bool perfectProtonEnergy = true; + + unsigned int size = TOGAXSI_SI->GetEventMultiplicity(); + unsigned int size_cluster = TOGAXSI_SI->GetEventMultiplicity_cluster(); + + double r_1 = 60; // Inner Z radius + double r_2 = 66; // Inner X radius + double r_3 = 90; // Outer Z radius + double r_4 = 96; // Outer X radius + + bool threeplanes_p2p = false; + bool fourplanes_p2p = true; + + bool cluster_fourplanes = false; + bool cluster_threeplanes = false; + + // Calculate z position on x-tracker for particle 1 and 2 + + if (threeplanes_p2p == true) { + /////////Protons (E,P) Reconstruction ///////// + + //Particle 1 +// TVector3 InnerPosX1 = TOGAXSI_SI->GetInnerXPositionOfInteraction(0); +// TVector3 InnerPosZ1 = TOGAXSI_SI->GetInnerZPositionOfInteraction(0); +// TVector3 OuterPosX1 = TOGAXSI_SI->GetOuterXPositionOfInteraction(0); +// TVector3 OuterPosZ1 = TOGAXSI_SI->GetOuterZPositionOfInteraction(0); + + //Particle 2 +// TVector3 InnerPosX2 = TOGAXSI_SI->GetInnerXPositionOfInteraction(1); +// TVector3 InnerPosZ2 = TOGAXSI_SI->GetInnerZPositionOfInteraction(1); +// TVector3 OuterPosX2 = TOGAXSI_SI->GetOuterXPositionOfInteraction(1); +// TVector3 OuterPosZ2 = TOGAXSI_SI->GetOuterZPositionOfInteraction(1); + + //Test + //Particle 1 + TVector3 InnerPosX1(0,66,0); + TVector3 InnerPosZ1(0,60,40); +// TVector3 OuterPosX1(10,96,0); + TVector3 OuterPosX1(27,96,0); + TVector3 OuterPosZ1(0,90,70); + + //Particle 2 + TVector3 InnerPosX2(0,-66,0); + TVector3 InnerPosZ2(0,-60,50); +// TVector3 OuterPosX2(20,-96,0); + TVector3 OuterPosX2(-14,-96,0); + TVector3 OuterPosZ2(0,-90,70); + + + //Particle 1 + double z_4 = (r_4 - r_1) / (r_3 - r_1) * (OuterPosZ1.Z() - InnerPosZ1.Z()) + InnerPosZ1.Z(); + cout << OuterPosX1.Z() << endl; + OuterPosX1.SetZ(z_4); + cout << OuterPosX1.Z() << endl; + + //Particle 2 + z_4 = (r_4 - r_1) / (r_3 - r_1) * (OuterPosZ2.Z() - InnerPosZ2.Z()) + InnerPosZ2.Z(); + cout << OuterPosX2.Z() << endl; + OuterPosX2.SetZ(z_4); + cout << OuterPosX2.Z() << endl; + + // Determine the plane for Particle 1 and 2 + // Particle 1 + double phi1 = TMath::ACos( InnerPosZ1.Y() / r_1 ); + TVector3 PlanePoint1(5,r_1,InnerPosZ1.Z()); + TVector3 PlanePoint2(-5,r_3,OuterPosZ1.Z()); + + cout << PlanePoint1.Y() << endl; + cout << PlanePoint1.Z() << endl; + cout << "Phi1: " << phi1 << endl; + + PlanePoint1.RotateZ(phi1); + PlanePoint2.RotateZ(phi1); + + TVector3 normalVector1; + TVector3 directionVector1 = OuterPosX1 - PlanePoint1; + TVector3 directionVector2 = OuterPosX1 - PlanePoint2; + normalVector1 = directionVector1.Cross(directionVector2); + + cout << normalVector1.x() << endl; + cout << normalVector1.y() << endl; + cout << normalVector1.z() << endl; + +// double a_1 = normalVector1.x(); +// double b_1 = normalVector1.y(); +// double c_1 = normalVector1.z(); +// double d_1 = -1 * normalVector1 * OuterPosX1; +// ROOT::Math::Plane3D Plane1(normalVector1, OuterPosX1); +// ROOT::Math::Plane3D Plane1(a_1,b_1,c_1,d_1); + + // Particle 2 + double phi2 = TMath::ACos( InnerPosZ2.Y() / r_1 ); + TVector3 PlanePoint3(10,r_1,InnerPosZ2.Z()); + TVector3 PlanePoint4(-9,r_1,InnerPosZ2.Z()); + + cout << "Phi2: " << phi2 << endl; + cout << PlanePoint3.x() << endl; + cout << PlanePoint3.y() << endl; + cout << PlanePoint3.z() << endl; + + + PlanePoint3.RotateZ(phi2); + PlanePoint4.RotateZ(phi2); + + TVector3 normalVector2; + directionVector1 = OuterPosX2 - PlanePoint3; + directionVector2 = OuterPosX2 - PlanePoint4; + normalVector2 = directionVector1.Cross(directionVector2); + + cout << normalVector2.x() << endl; + cout << normalVector2.y() << endl; + cout << normalVector2.z() << endl; + +// double a_2 = normalVector2.x(); +// double b_2 = normalVector2.y(); +// double c_2 = normalVector2.z(); +// double d_2 = -1 * normalVector2 * OuterPosX2; +// Plane3D Plane2(normalVector2, OuterPosX2); +// ROOT::Math::Plane3D Plane2(a_2,b_2,c_2,d_2); + + TVector3 line_position; + TVector3 line_direction; + + CalcLine(normalVector1, OuterPosX1, normalVector2, OuterPosX2, line_position, line_direction); + + cout << "line Point X" << line_position.X() << endl; + cout << line_position.Y() << endl; + cout << line_position.Z() << endl; + cout << "line direction Z" << line_direction.X() << endl; + cout << line_direction.Y() << endl; + cout << line_direction.Z() << endl; + + //Calculate points from line and target cylinder + //Cylinder + double r_c = 7.5; + + // Solve quadratic equation a_1* x^2 + a_2 *x + a_3 = 0 + double a_1 = pow(line_direction.x(),2.) + pow(line_direction.y(),2.); + double a_2 = 2 * line_direction.x() * line_position.x() + 2 * line_direction.y() * line_position.y(); + double a_3 = pow(line_position.x(),2.) + pow(line_position.y(),2.) - r_c * r_c; + + //solutions + double t_1 = (-a_2 + sqrt(a_2*a_2 - 4 * a_1 * a_3) ) / (2 * a_1); + double t_2 = (-a_2 - sqrt(a_2*a_2 - 4 * a_1 * a_3) ) / (2 * a_1); + + //Calculate coordinates of the two solutions + double z_1 = line_position.z() + t_1 * line_direction.z(); + double z_2 = line_position.z() + t_2 * line_direction.z(); + + double x_1 = line_position.x() + t_1 * line_direction.x(); + double x_2 = line_position.x() + t_2 * line_direction.x(); + double y_1 = line_position.y() + t_1 * line_direction.y(); + double y_2 = line_position.y() + t_2 * line_direction.y(); + + + //Check if one of the point is in the target and reconstruct vertex + double z_min = 50; + double z_max = 100; + + if ( (z_1 > z_min && z_1 < z_max) || (z_2 > z_min && z_2 < z_max) ) { + VertexZ = z_2 - z_1; + VertexX = x_2 - x_1; + VertexY = y_2 - y_1; + } else { + VertexZ = -9999.; + VertexX = -9999.; + VertexY = -9999.; + } + + + } else if ( fourplanes_p2p == true ) { + if (size==2) { +// cout << "test" << endl; + + + //Particle 1 + TVector3 InnerPosX1 = TOGAXSI_SI->GetInnerXPositionOfInteraction(0); + TVector3 InnerPosZ1 = TOGAXSI_SI->GetInnerZPositionOfInteraction(0); + TVector3 OuterPosX1 = TOGAXSI_SI->GetOuterXPositionOfInteraction(0); + TVector3 OuterPosZ1 = TOGAXSI_SI->GetOuterZPositionOfInteraction(0); + + //Particle 2 + TVector3 InnerPosX2 = TOGAXSI_SI->GetInnerXPositionOfInteraction(1); + TVector3 InnerPosZ2 = TOGAXSI_SI->GetInnerZPositionOfInteraction(1); + TVector3 OuterPosX2 = TOGAXSI_SI->GetOuterXPositionOfInteraction(1); + TVector3 OuterPosZ2 = TOGAXSI_SI->GetOuterZPositionOfInteraction(1); + +// cout <<"______Event Multiplicty 2______" << endl; + + //Particle 1 + + double z_2 = (r_2 - r_1) / (r_3 - r_1) * (OuterPosZ1.Z() - InnerPosZ1.Z()) + InnerPosZ1.Z(); + InnerPosX1.SetZ(z_2); + + double z_4 = (r_4 - r_1) / (r_3 - r_1) * (OuterPosZ1.Z() - InnerPosZ1.Z()) + InnerPosZ1.Z(); + OuterPosX1.SetZ(z_4); + + + double x_1 = (r_1 - r_2) / (r_4 - r_2) * (OuterPosX1.X() - InnerPosX1.X()) + InnerPosX1.X(); + InnerPosZ1.SetX(x_1); + + double x_3 = (r_3 - r_2) / (r_4 - r_2) * (OuterPosX1.X() - InnerPosX1.X()) + InnerPosX1.X(); + OuterPosZ1.SetX(x_3); +/* + cout << "InnerPos Z Particle 1: " << InnerPosZ1.Z() << endl; + cout << "InnerPos X Particle 1: " << InnerPosX1.Z() << endl; + cout << "OuterPos Z Particle 1: " << OuterPosZ1.Z() << endl; + cout << "OuterPos X Particle 1: " << OuterPosX1.Z() << endl; + cout << "InnerPos Z Particle 1 X: " << InnerPosZ1.X() << endl; + cout << "InnerPos X Particle 1 X: " << InnerPosX1.X() << endl; + cout << "OuterPos Z Particle 1 X: " << OuterPosZ1.X() << endl; + cout << "OuterPos X Particle 1 X: " << OuterPosX1.X() << endl; +*/ + + //Particle 2 + z_2 = (r_2 - r_1) / (r_3 - r_1) * (OuterPosZ2.Z() - InnerPosZ2.Z()) + InnerPosZ2.Z(); + InnerPosX2.SetZ(z_2); + z_4 = (r_4 - r_1) / (r_3 - r_1) * (OuterPosZ2.Z() - InnerPosZ2.Z()) + InnerPosZ2.Z(); + OuterPosX2.SetZ(z_4); + + x_1 = (r_1 - r_2) / (r_4 - r_2) * (OuterPosX2.X() - InnerPosX2.X()) + InnerPosX2.X(); + InnerPosZ2.SetX(x_1); + x_3 = (r_3 - r_2) / (r_4 - r_2) * (OuterPosX2.X() - InnerPosX2.X()) + InnerPosX2.X(); + OuterPosZ2.SetX(x_3); + + + // cout << OuterPosX2.Z() << endl; + + + + TVector3 Vertex; + TVector3 delta; + Distance = NPL::MinimumDistanceTwoLines(InnerPosX1, OuterPosX1, InnerPosX2, OuterPosX2, Vertex, delta); + + VertexX = Vertex.X(); + VertexY = Vertex.Y(); + VertexZ = Vertex.Z(); + deltaX = delta.X(); + deltaY = delta.Y(); + deltaZ = delta.Z(); + + SiInnerZ1_X = InnerPosZ1.X(); + SiInnerZ1_Y = InnerPosZ1.Y(); + SiInnerZ1_Z = InnerPosZ1.Z(); + SiOuterZ1_X = OuterPosZ1.X(); + SiOuterZ1_Y = OuterPosZ1.Y(); + SiOuterZ1_Z = OuterPosZ1.Z(); + + SiInnerX1_X = InnerPosX1.X(); + SiInnerX1_Y = InnerPosX1.Y(); + SiInnerX1_Z = InnerPosX1.Z(); + + + SiInnerZ2_X = InnerPosZ2.X(); + SiInnerZ2_Y = InnerPosZ2.Y(); + SiInnerZ2_Z = InnerPosZ2.Z(); + SiOuterZ2_X = OuterPosZ2.X(); + SiOuterZ2_Y = OuterPosZ2.Y(); + SiOuterZ2_Z = OuterPosZ2.Z(); + + SiInnerX2_X = InnerPosX2.X(); + SiInnerX2_Y = InnerPosX2.Y(); + SiInnerX2_Z = InnerPosX2.Z(); + + cout <<"InnerZ X1: " << SiInnerZ1_X << endl; + cout <<"InnerZ Z1: " << SiInnerZ1_Z << endl; + cout <<"OuterZ X1: " << SiOuterZ1_X << endl; + cout <<"OuterZ Z1: " << SiOuterZ1_Z << endl; + + cout <<"InnerX X1: " << SiInnerX1_X << endl; + cout <<"InnerX Z1: " << SiInnerX1_Z << endl; + + cout <<"InnerZ X2: " << SiInnerZ2_X << endl; + cout <<"InnerZ Z2: " << SiInnerZ2_Z << endl; + cout <<"OuterZ X2: " << SiOuterZ2_X << endl; + cout <<"OuterZ Z2: " << SiOuterZ2_Z << endl; + + cout <<"InnerX X2: " << SiInnerX2_X << endl; + cout <<"InnerX Z2: " << SiInnerX2_Z << endl; + + cout << DC->GetDetectedPositionX(0) << endl; + cout << DC->GetDetectedPositionX(1) << endl; + cout << DC->GetDetectedPositionX(2) << endl; + cout << DC->GetDetectedPositionX(3) << endl; + cout << DC->GetDetectedPositionX(4) << endl; + cout << DC->GetDetectedPositionX(5) << endl; + cout << DC->GetDetectedPositionX(6) << endl; + cout << DC->GetDetectedPositionX(7) << endl; + + cout << DC->GetDetectedPositionZ(0) << endl; + cout << DC->GetDetectedPositionZ(1) << endl; + cout << DC->GetDetectedPositionZ(2) << endl; + cout << DC->GetDetectedPositionZ(3) << endl; + cout << DC->GetDetectedPositionZ(4) << endl; + cout << DC->GetDetectedPositionZ(5) << endl; + cout << DC->GetDetectedPositionZ(6) << endl; + cout << DC->GetDetectedPositionZ(7) << endl; + + + cout <<"Targetcell: " << DC->GetDetectedPositionZ(8) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(9) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(10) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(11) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(12) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(13) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(14) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(15) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(16) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(17) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(18) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(19) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(20) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(21) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(22) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(23) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(24) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(25) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(26) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(27) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(28) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(29) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(30) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(31) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(32) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(33) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(34) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(35) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(36) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(37) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(38) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(39) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(40) << endl; + cout <<"Targetcell: " << DC->GetDetectedPositionZ(41) << endl; + + + cout <<"Targetcell X: " << DC->GetDetectedPositionX(10) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(11) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(12) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(13) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(14) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(15) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(16) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(17) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(10) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(11) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(12) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(13) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(14) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(15) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(16) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(17) << endl; + + cout <<"Targetcell X: " << DC->GetDetectedPositionX(20) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(21) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(22) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(23) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(24) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(25) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(26) << endl; + cout <<"Targetcell X: " << DC->GetDetectedPositionX(27) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(20) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(21) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(22) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(23) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(24) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(25) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(26) << endl; + cout <<"Targetcell Y: " << DC->GetDetectedPositionY(27) << endl; + + cout << DC->GetDetectedPositionY(0) << endl; + cout << DC->GetDetectedPositionY(1) << endl; + cout << DC->GetDetectedPositionY(2) << endl; + cout << DC->GetDetectedPositionY(3) << endl; + cout << DC->GetDetectedPositionY(4) << endl; + cout << DC->GetDetectedPositionY(5) << endl; + cout << DC->GetDetectedPositionY(6) << endl; + cout << DC->GetDetectedPositionY(7) << endl; + + + SiInnerZ1_X_sim = DC->GetDetectedPositionX(3); + SiInnerZ1_Y_sim = DC->GetDetectedPositionY(3); + SiInnerZ1_Z_sim = DC->GetDetectedPositionZ(3); + SiOuterZ1_X_sim = DC->GetDetectedPositionX(7); + SiOuterZ1_Y_sim = DC->GetDetectedPositionY(7); + SiOuterZ1_Z_sim = DC->GetDetectedPositionZ(7); + + SiInnerX1_X_sim = DC->GetDetectedPositionX(1); + SiInnerX1_Y_sim = DC->GetDetectedPositionY(1); + SiInnerX1_Z_sim = DC->GetDetectedPositionZ(1); + + InnerZ1_theta_sim = DC->GetDetectedAngleTheta(3); + OuterZ1_theta_sim = DC->GetDetectedAngleTheta(7); + InnerX1_theta_sim = DC->GetDetectedAngleTheta(1); + + +/* + cout <<"InnerZ X1 sim: " << SiInnerZ1_X_sim << endl; + cout <<"InnerZ Z1 sim: " << SiInnerZ1_Z_sim << endl; + cout <<"OuterZ X1 sim: " << SiOuterZ1_X_sim << endl; + cout <<"OuterZ Z1 sim: " << SiOuterZ1_Z_sim << endl; + + cout <<"InnerX X1 sim: " << SiInnerX1_X_sim << endl; + cout <<"InnerX Z1 sim: " << SiInnerX1_Z_sim << endl; + + cout <<"_______ Event Multiplicity 2 end_________" << endl; +*/ + theta_vertex_1_sim = RC->GetTheta(0); + theta_vertex_2_sim = RC->GetTheta(1); + + if(perfectProtonTracking) { + // From Reaction Conditions + VertexX_sim = RC->GetVertexPositionX(); + VertexY_sim = RC->GetVertexPositionY(); + VertexZ_sim = RC->GetVertexPositionZ(); + //Proton2sim = RC->GetParticleDirection(0).Unit(); + //Proton1 = RC->GetParticleDirection(1).Unit(); + } + + TVector3 direction_cal(SiInnerZ1_X_sim - VertexX_sim, SiInnerZ1_Y_sim - VertexY_sim, SiInnerZ1_Z_sim - VertexZ_sim); + direction_cal = direction_cal.Unit(); + + if (RC->GetTheta(0) < 45.01 && RC->GetTheta(0) > 44.99) { + cout << "________________Test_______________" << endl; + cout << RC->GetTheta(0) << endl; + cout << RC->GetTheta(1) << endl; + + cout << RC->GetParticleDirection(0).Theta() * 180/TMath::Pi() << endl; + cout << RC->GetParticleDirection(1).Theta() * 180/TMath::Pi() << endl; + + cout << "Particle direction X: " << RC->GetParticleDirection(0).X() << endl; + cout << "Particle direction Y: " << RC->GetParticleDirection(0).Y() << endl; + cout << "Particle direction Z: " << RC->GetParticleDirection(0).Z() << endl; + + cout << "Particle direction X: " << RC->GetParticleDirection(1).X() << endl; + cout << "Particle direction Y: " << RC->GetParticleDirection(1).Y() << endl; + cout << "Particle direction Z: " << RC->GetParticleDirection(1).Z() << endl; + + cout << "Particle direction X calculated: " << direction_cal.X() << endl; + cout << "Particle direction Y calculated: " << direction_cal.Y() << endl; + cout << "Particle direction Z calculated: " << direction_cal.Z() << endl; + + cout << "Calculated Theta: " << direction_cal.Theta() * 180/TMath::Pi() << endl; + + cout << DC->GetDetectedAngleTheta(0) << endl; + cout << DC->GetDetectedAngleTheta(1) << endl; + cout << DC->GetDetectedAngleTheta(2) << endl; + cout << DC->GetDetectedAngleTheta(3) << endl; + cout << DC->GetDetectedAngleTheta(4) << endl; + cout << DC->GetDetectedAngleTheta(5) << endl; + cout << DC->GetDetectedAngleTheta(6) << endl; + cout << DC->GetDetectedAngleTheta(7) << endl; + } + + } + + + + +// VertexX_sim = RC->GetVertexPositionX(); +// VertexY_sim = RC->GetVertexPositionY(); +// VertexZ_sim = RC->GetVertexPositionZ(); + + } else if (cluster_fourplanes == true) { + if (size == 1 && size_cluster == 1) { + + //Particle 1 + TVector3 InnerPosX = TOGAXSI_SI->GetInnerXPositionOfInteraction(0); + TVector3 InnerPosZ = TOGAXSI_SI->GetInnerZPositionOfInteraction(0); + TVector3 OuterPosX = TOGAXSI_SI->GetOuterXPositionOfInteraction(0); + TVector3 OuterPosZ = TOGAXSI_SI->GetOuterZPositionOfInteraction(0); + + //Particle 2 + TVector3 Cluster1PosX = TOGAXSI_SI->GetClusterX1PositionOfInteraction(0); + TVector3 Cluster1PosY = TOGAXSI_SI->GetClusterY1PositionOfInteraction(0); + TVector3 Cluster2PosX = TOGAXSI_SI->GetClusterX2PositionOfInteraction(0); + TVector3 Cluster2PosY = TOGAXSI_SI->GetClusterY2PositionOfInteraction(0); + + //Particle 1 + double z_2 = (r_2 - r_1) / (r_3 - r_1) * (OuterPosZ.Z() - InnerPosZ.Z()) + InnerPosZ.Z(); + InnerPosX.SetZ(z_2); + + double z_4 = (r_4 - r_1) / (r_3 - r_1) * (OuterPosZ.Z() - InnerPosZ.Z()) + InnerPosZ.Z(); + OuterPosX.SetZ(z_4); + + //Particle 2 + double x_2 = (Cluster1PosY.Z() - Cluster1PosX.Z()) / (Cluster2PosX.Z() - Cluster1PosX.Z()) * (Cluster2PosX.X() - Cluster1PosX.X()) + Cluster1PosX.X(); + Cluster1PosY.SetX(x_2); + + double x_4 = (Cluster2PosY.Z() - Cluster1PosX.Z()) / (Cluster2PosX.Z() - Cluster1PosX.Z()) * (Cluster2PosX.X() - Cluster1PosX.X()) + Cluster1PosX.X(); + Cluster2PosY.SetX(x_4); + +/* + cout << Cluster1PosY.Z() << endl; + cout << Cluster1PosX.Z() << endl; + cout << Cluster2PosX.Z() << endl; + cout << Cluster2PosY.Z() << endl; + + cout << "Z1: " << InnerPosZ.Z() << endl; + cout << "Z2: " << InnerPosX.Z() << endl; + cout << "Z3: " << OuterPosZ.Z() << endl; + cout << "Z4: " << OuterPosX.Z() << endl; +*/ + + cout << "X1: " << InnerPosZ.X() << endl; + cout << "X2: " << InnerPosX.X() << endl; + cout << "X3: " << OuterPosZ.X() << endl; + cout << "X4: " << OuterPosX.X() << endl; + +/* + cout << "X1: " << Cluster1PosX.X() << endl; + cout << "X2: " << Cluster1PosY.X() << endl; + cout << "X3: " << Cluster2PosX.X() << endl; + cout << "X4: " << Cluster2PosY.X() << endl; +*/ + + TVector3 Vertex; + TVector3 delta; + Distance = NPL::MinimumDistanceTwoLines(InnerPosX, OuterPosX, Cluster1PosY, Cluster2PosY, Vertex, delta); + + VertexX = Vertex.X(); + VertexY = Vertex.Y(); + VertexZ = Vertex.Z(); + deltaX = delta.X(); + deltaY = delta.Y(); + deltaZ = delta.Z(); + + + VertexX_sim = RC->GetVertexPositionX(); + VertexY_sim = RC->GetVertexPositionY(); + VertexZ_sim = RC->GetVertexPositionZ(); + + } + } else if (cluster_threeplanes == true) { + if (size == 1 && size_cluster == 1) { + + //Particle 1 + TVector3 InnerPosZ = TOGAXSI_SI->GetInnerZPositionOfInteraction(0); + TVector3 OuterPosX = TOGAXSI_SI->GetOuterXPositionOfInteraction(0); + TVector3 OuterPosZ = TOGAXSI_SI->GetOuterZPositionOfInteraction(0); + + //Particle 2 + TVector3 Cluster1PosX = TOGAXSI_SI->GetClusterX1PositionOfInteraction(0); + TVector3 Cluster2PosX = TOGAXSI_SI->GetClusterX2PositionOfInteraction(0); + TVector3 Cluster2PosY = TOGAXSI_SI->GetClusterY2PositionOfInteraction(0); + } + } + + +} + +//////////////////////////////////////////////////////////////////////////////// +/*void Analysis::CalcLine(const TVector3& n1, const TVector3& p1, TVector3& n2, TVector3& p2, TVector3& point) { + + direction = n1.Cross(n2); + + double d_1 = -1 * n1 * p1; + double d_2 = -1 * n2 * p2; + + TVector3 v1 = n1 * d_2 - n2 * d_1; + double c1 = n1.Dot(n1.cross(n2)); + point = v1.Cross(direction) * (1.0/ c1); + + return 0; + +} +*/ +void Analysis::CalcLine(const TVector3& n1, const TVector3& p1, const TVector3& n2, const TVector3& p2, TVector3& point, TVector3& direction) { + + point.Clear(); + direction.Clear(); + + + direction = n1.Cross(n2); + + double a_1 = n1.x(); + double b_1 = n1.y(); + double c_1 = n1.z(); + double a_2 = n2.x(); + double b_2 = n2.y(); + double c_2 = n2.z(); + + double d_1 = n1 * p1; + double d_2 = n2 * p2; + + + cout << "n1: " << n1.x() << endl; + cout << "n1: " << n1.y() << endl; + cout << "n1: " << n1.z() << endl; + + cout << "n2: " << n2.x() << endl; + cout << "n2: " << n2.y() << endl; + cout << "n2: " << n2.z() << endl; + cout << "x: " << p2.x() << endl; + cout << "y: " << p2.y() << endl; + cout << "z: " << p2.z() << endl; + + cout << "d1: " << d_1 << endl; + cout << "d2: " << d_2 << endl; + + + //Calculate Point + + if (c_1 != 0 || c_2 != 0) { + point.SetZ(0); + + point.SetX( (b_2 * d_1 - b_1 * d_2) / (b_2 * a_1 - b_1 * a_2) ); + point.SetY( (a_2 * d_1 - a_1 * d_2) / (a_2 * b_1 - a_1 * b_2) ); + } else if (b_1 != 0 || b_2 != 0 ) { + point.SetY(0); + + point.SetX( (c_2 * d_1 - c_1 * d_2) / (c_2 * a_1 - c_1 * a_2) ); + point.SetZ( (a_2 * d_1 - a_1 * d_2) / (a_2 * c_1 - a_1 * c_2) ); + } else if (a_1 != 0 || a_2 != 0 ) { + point.SetX(0); + + point.SetY( (c_2 * d_1 - c_1 * d_2) / (c_2 * b_1 - c_1 * b_2) ); + point.SetZ( (b_2 * d_1 - b_1 * d_2) / (b_2 * c_1 - b_1 * c_2) ); + } + + +} + +//////////////////////////////////////////////////////////////////////////////// +double Analysis::ReconstructProtonEnergy(const TVector3& x0, const TVector3& dir, const double& Ecatana) { + TVector3 Normal = TVector3(0, 1, 0); + Normal.SetPhi(dir.Phi()); + double Theta = dir.Angle(Normal); + // Catana Al housing + double E = protonAl.EvaluateInitialEnergy(Ecatana, 0.5 * mm, Theta); + //cout << "Ecatana=" << Ecatana << endl; + //cout << "Erec0=" << E << endl; + + //Outer Barrel + E = protonSi.EvaluateInitialEnergy(E, 300 * micrometer, Theta); + //Innter Barrel + E = protonSi.EvaluateInitialEnergy(E, 200 * micrometer, Theta); + //LH2 target + static TVector3 x1; + x1 = x0 + dir; + TVector3 T1(0,15,0); + TVector3 T2(0,15,1); + T1.SetPhi(dir.Phi()); + T2.SetPhi(dir.Phi()); + + double d = 0; + + cout << "d=" << d << endl; + cout << "Theta=" << Theta << endl; + E = protonTarget.EvaluateInitialEnergy(E, d, Theta); + cout << "Erec=" << E << endl; + return E; +} + +//////////////////////////////////////////////////////////////////////////////// +TVector3 Analysis::InterpolateInPlaneZ(TVector3 V0, TVector3 V1, double Zproj) { + TVector3 Vproj(-999, -999, -999); + double t = (Zproj - V1.Z()) / (V1.Z() - V0.Z()); + double Xproj = V1.X() + (V1.X() - V0.X()) * t; + double Yproj = V1.Y() + (V1.Y() - V0.Y()) * t; + Vproj.SetXYZ(Xproj, Yproj, Zproj); + return Vproj; +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ +} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitOutputBranch(){ + RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex, "Ex/D"); + RootOutput::getInstance()->GetTree()->Branch("E1",&E1, "E1/D"); + RootOutput::getInstance()->GetTree()->Branch("E2",&E2, "E2/D"); + RootOutput::getInstance()->GetTree()->Branch("Theta12",&Theta12, "Theta12/D"); + RootOutput::getInstance()->GetTree()->Branch("ThetaCM",&ThetaCM, "ThetaCM/D"); + RootOutput::getInstance()->GetTree()->Branch("VertexX",&VertexX, "VertexX/D"); + RootOutput::getInstance()->GetTree()->Branch("VertexY",&VertexY, "VertexY/D"); + RootOutput::getInstance()->GetTree()->Branch("VertexZ",&VertexZ, "VertexZ/D"); + RootOutput::getInstance()->GetTree()->Branch("VertexX_sim",&VertexX_sim, "VertexX_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("VertexY_sim",&VertexY_sim, "VertexY_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("VertexZ_sim",&VertexZ_sim, "VertexZ_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("deltaX",&deltaX, "deltaX/D"); + RootOutput::getInstance()->GetTree()->Branch("deltaY",&deltaY, "deltaY/D"); + RootOutput::getInstance()->GetTree()->Branch("deltaZ",&deltaZ, "deltaZ/D"); + RootOutput::getInstance()->GetTree()->Branch("deltaPhi",&deltaPhi, "deltaPhi/D"); + RootOutput::getInstance()->GetTree()->Branch("sumTheta",&sumTheta, "sumTheta/D"); + + RootOutput::getInstance()->GetTree()->Branch("alpha",&alpha, "alpha/D"); + + RootOutput::getInstance()->GetTree()->Branch("Theta1",&Theta1, "Theta1/D"); + RootOutput::getInstance()->GetTree()->Branch("Phi1",&Phi1, "Phi1/D"); + RootOutput::getInstance()->GetTree()->Branch("Theta2",&Theta2, "Theta2/D"); + RootOutput::getInstance()->GetTree()->Branch("Phi2",&Phi2, "Phi2/D"); + RootOutput::getInstance()->GetTree()->Branch("Theta1s",&Theta1s, "Theta1s/D"); + RootOutput::getInstance()->GetTree()->Branch("Phi1s",&Phi1s, "Phi1s/D"); + RootOutput::getInstance()->GetTree()->Branch("Theta2s",&Theta2s, "Theta2s/D"); + RootOutput::getInstance()->GetTree()->Branch("Phi2s",&Phi2s, "Phi2s/D"); + RootOutput::getInstance()->GetTree()->Branch("TA",&TA, "TA/D"); + RootOutput::getInstance()->GetTree()->Branch("TAcalc",&TAcalc, "TAcalc/D"); + + RootOutput::getInstance()->GetTree()->Branch("SiInnerZ1_X",&SiInnerZ1_X, "SiInnerZ1_X/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerZ1_Y",&SiInnerZ1_Y, "SiInnerZ1_Y/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerZ1_Z",&SiInnerZ1_Z, "SiInnerZ1_Z/D"); + RootOutput::getInstance()->GetTree()->Branch("SiOuterZ1_X",&SiOuterZ1_X, "SiOuterZ1_X/D"); + RootOutput::getInstance()->GetTree()->Branch("SiOuterZ1_Y",&SiOuterZ1_Y, "SiOuterZ1_Y/D"); + RootOutput::getInstance()->GetTree()->Branch("SiOuterZ1_Z",&SiOuterZ1_Z, "SiOuterZ1_Z/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerZ1_X_sim",&SiInnerZ1_X_sim, "SiInnerZ1_X_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerZ1_Y_sim",&SiInnerZ1_Y_sim, "SiInnerZ1_Y_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerZ1_Z_sim",&SiInnerZ1_Z_sim, "SiInnerZ1_Z_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("SiOuterZ1_X_sim",&SiOuterZ1_X_sim, "SiOuterZ1_X_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("SiOuterZ1_Y_sim",&SiOuterZ1_Y_sim, "SiOuterZ1_Y_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("SiOuterZ1_Z_sim",&SiOuterZ1_Z_sim, "SiOuterZ1_Z_sim/D"); + + + RootOutput::getInstance()->GetTree()->Branch("SiInnerX1_X",&SiInnerX1_X, "SiInnerX1_X/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerX1_Y",&SiInnerX1_Y, "SiInnerX1_Y/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerX1_Z",&SiInnerX1_Z, "SiInnerX1_Z/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerX1_X_sim",&SiInnerX1_X_sim, "SiInnerX1_X_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerX1_Y_sim",&SiInnerX1_Y_sim, "SiInnerX1_Y_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("SiInnerX1_Z_sim",&SiInnerX1_Z_sim, "SiInnerX1_Z_sim/D"); + + RootOutput::getInstance()->GetTree()->Branch("theta_vertex_1_sim",&theta_vertex_1_sim, "theta_vertex_1_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("theta_vertex_2_sim",&theta_vertex_2_sim, "theta_vertex_2_sim/D"); + + RootOutput::getInstance()->GetTree()->Branch("InnerZ1_theta_sim",&InnerZ1_theta_sim, "&InnerZ1_theta_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("InnerX1_theta_sim",&InnerX1_theta_sim, "&InnerX1_theta_sim/D"); + RootOutput::getInstance()->GetTree()->Branch("OuterZ1_theta_sim",&OuterZ1_theta_sim, "&OuterZ1_theta_sim/D"); + + + + RootOutput::getInstance()->GetTree()->Branch("Distance",&Distance, "Distance/D"); + RootOutput::getInstance()->GetTree()->Branch("InteractionCoordinates","TInteractioncoordinates", &DC); + RootOutput::getInstance()->GetTree()->Branch("ReactionConditions","ReactionConditions", &RC); +} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitInputBranch() { + RootInput::getInstance()->GetChain()->SetBranchAddress("InteractionCoordinates",&DC); + RootInput::getInstance()->GetChain()->SetBranchAddress("ReactionConditions",&RC); +} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::ReInitValue() { + Ex = -1000; + E1 = -1000; + E2 = -1000; + Theta12 = -1000; + ThetaCM = -1000; + VertexX = -1000; + VertexY = -1000; + VertexZ = -1000; + VertexX_sim = -1000; + VertexY_sim = -1000; + VertexZ_sim = -1000; + deltaX = -1000; + deltaY = -1000; + deltaZ = -1000; + Distance = -1000; + sumTheta = -1000; + deltaPhi = -1000; + alpha = -1000; + Theta1 = -1000; + Phi1 = -1000; + Theta2 = -1000; + Phi2 = -1000; + Theta1s = -1000; + Phi1s = -1000; + Theta2s = -1000; + Phi2s = -1000; + TA = -1000; + TAcalc = -1000; + + z_1_sim = -1000; + z_2_sim = -1000; + z_3_sim = -1000; + z_4_sim = -1000; + + theta_vertex_1_sim = -1000; + theta_vertex_2_sim = -1000; + + SiInnerZ1_X = -1000; + SiInnerZ1_Y = -1000; + SiInnerZ1_Z = -1000; + SiInnerZ1_X_sim = -1000; + SiInnerZ1_Y_sim = -1000; + SiInnerZ1_Z_sim = -1000; + SiOuterZ1_X = -1000; + SiOuterZ1_Y = -1000; + SiOuterZ1_Z = -1000; + SiOuterZ1_X_sim = -1000; + SiOuterZ1_Y_sim = -1000; + SiOuterZ1_Z_sim = -1000; + + SiInnerX1_X = -1000; + SiInnerX1_Y = -1000; + SiInnerX1_Z = -1000; + SiInnerX1_X_sim = -1000; + SiInnerX1_Y_sim = -1000; + SiInnerX1_Z_sim = -1000; + + InnerZ1_theta_sim = -1000; + InnerX1_theta_sim = -1000; + OuterZ1_theta_sim = -1000; + +} + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VAnalysis* Analysis::Construct(){ + return (NPL::VAnalysis*) new Analysis(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy{ + public: + proxy(){ + NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } +}; + +proxy p; +} + diff --git a/Projects/TOGAXSI_SI/Analysis.h b/Projects/TOGAXSI_SI/Analysis.h new file mode 100644 index 000000000..0af01b29e --- /dev/null +++ b/Projects/TOGAXSI_SI/Analysis.h @@ -0,0 +1,175 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: XAUTHORX contact address: XMAILX * + * * + * Creation Date : XMONTHX XYEARX * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe TOGAXSI_SI analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + + +#include "NPVAnalysis.h" +#include "NPEnergyLoss.h" +#include "NPQFS.h" +#include "RootOutput.h" +#include "RootInput.h" +#include "TTOGAXSI_SIPhysics.h" +#include "TInitialConditions.h" +#include "TInteractionCoordinates.h" +#include "TReactionConditions.h" +#include <TRandom3.h> +#include <TVector3.h> +#include <TLorentzVector.h> +#include <TMath.h> + + +class Analysis: public NPL::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + + void InitOutputBranch(); + void InitInputBranch(); + void ReInitValue(); + static NPL::VAnalysis* Construct(); + TVector3 InterpolateInPlaneZ(TVector3, TVector3, double); + double ApplyCATANAResoGamma(double); + double ApplyCATANAResoProton(double); + + + private: + double Ex; + double E1; + double E2; + double E1s; + double E2s; + double Theta12; + double ThetaCM; + double VertexX; + double VertexY; + double VertexZ; + double VertexX_sim; + double VertexY_sim; + double VertexZ_sim; + double deltaX; + double deltaY; + double deltaZ; + double Distance; + double deltaPhi; + double sumTheta; + double alpha; + double Theta1=-1000; + double Phi1=-1000; + double Theta2=-1000; + double Phi2=-1000; + double Theta1s=-1000; + double Phi1s=-1000; + double Theta2s=-1000; + double Phi2s=-1000; + double TA; + double TAcalc; + + double SiInnerZ1_X; + double SiInnerZ1_Y; + double SiInnerZ1_Z; + double SiOuterZ1_X; + double SiOuterZ1_Y; + double SiOuterZ1_Z; + double SiInnerZ1_X_sim; + double SiInnerZ1_Y_sim; + double SiInnerZ1_Z_sim; + double SiOuterZ1_X_sim; + double SiOuterZ1_Y_sim; + double SiOuterZ1_Z_sim; + + double SiInnerX1_X; + double SiInnerX1_Y; + double SiInnerX1_Z; + double SiInnerX1_X_sim; + double SiInnerX1_Y_sim; + double SiInnerX1_Z_sim; + + double SiInnerZ2_X; + double SiInnerZ2_Y; + double SiInnerZ2_Z; + double SiOuterZ2_X; + double SiOuterZ2_Y; + double SiOuterZ2_Z; + double SiInnerZ2_X_sim; + double SiInnerZ2_Y_sim; + double SiInnerZ2_Z_sim; + double SiOuterZ2_X_sim; + double SiOuterZ2_Y_sim; + double SiOuterZ2_Z_sim; + + double SiInnerX2_X; + double SiInnerX2_Y; + double SiInnerX2_Z; + double SiInnerX2_X_sim; + double SiInnerX2_Y_sim; + double SiInnerX2_Z_sim; + + + double theta_vertex_1_sim; + double theta_vertex_2_sim; + + double InnerZ1_theta_sim; + double InnerX1_theta_sim; + double OuterZ1_theta_sim; + + + double z_1_sim; + double z_2_sim; + double z_3_sim; + double z_4_sim; + + TRandom3 *rand; + + TLorentzVector LV_A; + TLorentzVector LV_T; + TLorentzVector LV_B; + TLorentzVector LV_p1; + TLorentzVector LV_p2; + + NPL::Beam* myBeam; + NPL::QFS* m_QFS; + + EnergyLoss BeamTarget; + EnergyLoss protonTarget; + EnergyLoss protonAl; + EnergyLoss protonSi; + double ReconstructProtonEnergy(const TVector3& x0, const TVector3& dir, const double& Ecatana); + void CalcLine(const TVector3& n1, const TVector3& p1, const TVector3& n2, const TVector3& p2, TVector3& point, TVector3& direction); + + TVector3 BeamImpact; + double TargetThickness; + double InitialBeamEnergy; + + TRandom3 Rand; + TInitialConditions* IC; + TInteractionCoordinates* DC; + TReactionConditions* RC; + + TTOGAXSI_SIPhysics* TOGAXSI_SI; + +}; +#endif diff --git a/Projects/TOGAXSI_SI/CMakeLists.txt b/Projects/TOGAXSI_SI/CMakeLists.txt new file mode 100644 index 000000000..22c74affd --- /dev/null +++ b/Projects/TOGAXSI_SI/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.8) +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +# include the default NPAnalysis cmake file +include("../../NPLib/ressources/CMake/NPAnalysis.cmake") diff --git a/Projects/TOGAXSI_SI/TOGAXSI_SI.detector b/Projects/TOGAXSI_SI/TOGAXSI_SI.detector new file mode 100644 index 000000000..9b71194d1 --- /dev/null +++ b/Projects/TOGAXSI_SI/TOGAXSI_SI.detector @@ -0,0 +1,87 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%Target +% THICKNESS = 150 mm +% RADIUS = 15 mm +% MATERIAL = LH2 +% ANGLE = 0 deg +% X = 0 mm +% Y = 0 mm +% Z = -50 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TOGAXSI_SI Target + Radius= 15 mm + Length= 150 mm + TargetMaterial= LH2 +% CellMaterial= Mylar + CellMaterial= Vacuum + CellThickness= 0.15 mm + Pos = 0 0 0 mm + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias InnerXPhi + Action= Copy +% Value= 0. 60.0 120.0 180.0 240.0 300.0 + Value= 0. 180. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TOGAXSI_SI InnerX + Radius= 66 mm + Z= 100 mm +% Z= 50 mm + Phi= @InnerZPhi deg + Ref= 0 0 0 mm + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias InnerZPhi + Action= Copy +% Value= 0. 60.0 120.0 180.0 240.0 300.0 + Value= 0. 180. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TOGAXSI_SI InnerZ + Radius= 60 mm + Z= 100 mm +% Z= 50 mm + Phi= @InnerZPhi deg + Ref= 0 0 0 mm + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias OuterXPhi + Action= Copy +% Value= 0. 60.0 120.0 180.0 240.0 300.0 + Value= 0. 180. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TOGAXSI_SI OuterX + Radius= 96 mm + Z= 100 mm +% Z= 50 mm + Phi= @OuterXPhi deg + Ref= 0 0 0 mm + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias OuterZPhi + Action= Copy +% Value= 0. 60.0 120.0 180.0 240.0 300.0 + Value= 0. 180. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TOGAXSI_SI OuterZ + Radius= 90 mm + Z= 100 mm +% Z= 50 mm + Phi= @OuterZPhi deg + Ref= 0 0 0 mm + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%Alias ClusterPhi +% Action= Copy +% Value= 0. 60. 120. 180. 240. 300. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%TOGAXSI_SI Cluster +% Radius= 50 mm +% Z= 200 mm +% Phi= @ClusterPhi deg +% Ref= 0 0 0 mm + -- GitLab