diff --git a/NPLib/Detectors/eAGanil/CMakeLists.txt b/NPLib/Detectors/eAGanil/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..65ae957d69ce32421159fef162f223dbb6a37e42 --- /dev/null +++ b/NPLib/Detectors/eAGanil/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TeAGanilPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TeAGanilPhysics.h TeAGanilPhysicsDict.cxx TeAGanilPhysics.rootmap libNPeAGanil.dylib DEPENDS TeAGanilPhysics.h) +add_custom_command(OUTPUT TeAGanilDataDict.cxx COMMAND ../../scripts/build_dict.sh TeAGanilData.h TeAGanilDataDict.cxx TeAGanilData.rootmap libNPeAGanil.dylib DEPENDS TeAGanilData.h) +add_library(NPeAGanil SHARED TeAGanilSpectra.cxx TeAGanilData.cxx TeAGanilPhysics.cxx TeAGanilDataDict.cxx TeAGanilPhysicsDict.cxx ) +target_link_libraries(NPeAGanil ${ROOT_LIBRARIES} NPCore) +install(FILES TeAGanilData.h TeAGanilPhysics.h TeAGanilSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/eAGanil/TeAGanilData.cxx b/NPLib/Detectors/eAGanil/TeAGanilData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d2cffe5a82187bd1a6777968c2b66f372dbba47d --- /dev/null +++ b/NPLib/Detectors/eAGanil/TeAGanilData.cxx @@ -0,0 +1,79 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 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: Adrien Matta contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold eAGanil Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TeAGanilData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TeAGanilData) + + +////////////////////////////////////////////////////////////////////// +TeAGanilData::TeAGanilData() { +} + + + +////////////////////////////////////////////////////////////////////// +TeAGanilData::~TeAGanilData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TeAGanilData::Clear() { + // Energy + feAGanil_E_DetectorNbr.clear(); + feAGanil_Energy.clear(); + // Time + feAGanil_T_DetectorNbr.clear(); + feAGanil_Time.clear(); +} + + + +////////////////////////////////////////////////////////////////////// +void TeAGanilData::Dump() const { + // This method is very useful for debuging and worth the dev. + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TeAGanilData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = feAGanil_E_DetectorNbr.size(); + cout << "eAGanil_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << feAGanil_E_DetectorNbr[i] + << " Energy: " << feAGanil_Energy[i]; + } + + // Time + mysize = feAGanil_T_DetectorNbr.size(); + cout << "eAGanil_T_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << feAGanil_T_DetectorNbr[i] + << " Time: " << feAGanil_Time[i]; + } +} diff --git a/NPLib/Detectors/eAGanil/TeAGanilData.h b/NPLib/Detectors/eAGanil/TeAGanilData.h new file mode 100644 index 0000000000000000000000000000000000000000..f114e96e4a2a5e436d29e2732df7e5e01d8a762b --- /dev/null +++ b/NPLib/Detectors/eAGanil/TeAGanilData.h @@ -0,0 +1,104 @@ +#ifndef __eAGanilDATA__ +#define __eAGanilDATA__ +/***************************************************************************** + * Copyright (C) 2009-2020 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: Adrien Matta contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold eAGanil Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TeAGanilData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + private: + // Energy + vector<UShort_t> feAGanil_E_DetectorNbr; + vector<Double_t> feAGanil_Energy; + + // Time + vector<UShort_t> feAGanil_T_DetectorNbr; + vector<Double_t> feAGanil_Time; + + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TeAGanilData(); + ~TeAGanilData(); + + + ////////////////////////////////////////////////////////////// + // 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 //////////////////////// + // Energy + inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){ + feAGanil_E_DetectorNbr.push_back(DetNbr); + feAGanil_Energy.push_back(Energy); + };//! + + // Time + inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) { + feAGanil_T_DetectorNbr.push_back(DetNbr); + feAGanil_Time.push_back(Time); + };//! + + + ////////////////////// GETTERS //////////////////////// + // Energy + inline UShort_t GetMultEnergy() const + {return feAGanil_E_DetectorNbr.size();} + inline UShort_t GetE_DetectorNbr(const unsigned int &i) const + {return feAGanil_E_DetectorNbr[i];}//! + inline Double_t Get_Energy(const unsigned int &i) const + {return feAGanil_Energy[i];}//! + + // Time + inline UShort_t GetMultTime() const + {return feAGanil_T_DetectorNbr.size();} + inline UShort_t GetT_DetectorNbr(const unsigned int &i) const + {return feAGanil_T_DetectorNbr[i];}//! + inline Double_t Get_Time(const unsigned int &i) const + {return feAGanil_Time[i];}//! + + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TeAGanilData,1) // eAGanilData structure +}; + +#endif diff --git a/NPLib/Detectors/eAGanil/TeAGanilPhysics.cxx b/NPLib/Detectors/eAGanil/TeAGanilPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..bb696e5bea270d8b3a427ee4bc85a178b2c4adde --- /dev/null +++ b/NPLib/Detectors/eAGanil/TeAGanilPhysics.cxx @@ -0,0 +1,344 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 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: Adrien Matta contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold eAGanil Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TeAGanilPhysics.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" + +// ROOT +#include "TChain.h" + +ClassImp(TeAGanilPhysics) + + +/////////////////////////////////////////////////////////////////////////// +TeAGanilPhysics::TeAGanilPhysics() + : m_EventData(new TeAGanilData), + m_PreTreatedData(new TeAGanilData), + m_EventPhysics(this), + m_Spectra(0), + m_E_RAW_Threshold(0), // adc channels + m_E_Threshold(0), // MeV + m_NumberOfDetectors(0) { +} + +/////////////////////////////////////////////////////////////////////////// +/// A usefull method to bundle all operation to add a detector +void TeAGanilPhysics::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 TeAGanilPhysics::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 TeAGanilPhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::BuildPhysicalEvent() { + // apply thresholds and calibration + PreTreat(); + + // match energy and time together + unsigned int mysizeE = m_PreTreatedData->GetMultEnergy(); + unsigned int mysizeT = m_PreTreatedData->GetMultTime(); + for (UShort_t e = 0; e < mysizeE ; e++) { + for (UShort_t t = 0; t < mysizeT ; t++) { + if (m_PreTreatedData->GetE_DetectorNbr(e) == m_PreTreatedData->GetT_DetectorNbr(t)) { + DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e)); + Energy.push_back(m_PreTreatedData->Get_Energy(e)); + Time.push_back(m_PreTreatedData->Get_Time(t)); + } + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::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(); + + // Energy + unsigned int mysize = m_EventData->GetMultEnergy(); + for (UShort_t i = 0; i < mysize ; ++i) { + if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) { + Double_t Energy = Cal->ApplyCalibration("eAGanil/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i)); + if (Energy > m_E_Threshold) { + m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), Energy); + } + } + } + + // Time + mysize = m_EventData->GetMultTime(); + for (UShort_t i = 0; i < mysize; ++i) { + Double_t Time= Cal->ApplyCalibration("eAGanil/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); + m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigeAGanil.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigeAGanil.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigeAGanil.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigeAGanil.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 = "ConfigeAGanil"; + 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 TeAGanilPhysics::Clear() { + DetectorNumber.clear(); + Energy.clear(); + Time.clear(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("eAGanil"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"POS","Shape"}; + vector<string> sphe = {"R","Theta","Phi","Shape"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(cart)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// eAGanil " << i+1 << endl; + + TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); + string Shape = blocks[i]->GetString("Shape"); + AddDetector(Pos,Shape); + } + else if(blocks[i]->HasTokenList(sphe)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// eAGanil " << i+1 << endl; + double R = blocks[i]->GetDouble("R","mm"); + double Theta = blocks[i]->GetDouble("Theta","deg"); + double Phi = blocks[i]->GetDouble("Phi","deg"); + string Shape = blocks[i]->GetString("Shape"); + AddDetector(R,Theta,Phi,Shape); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::InitSpectra() { + m_Spectra = new TeAGanilSpectra(m_NumberOfDetectors); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TeAGanilPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + for (int i = 0; i < m_NumberOfDetectors; ++i) { + Cal->AddParameter("eAGanil", "D"+ NPL::itoa(i+1)+"_ENERGY","eAGanil_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("eAGanil", "D"+ NPL::itoa(i+1)+"_TIME","eAGanil_D"+ NPL::itoa(i+1)+"_TIME"); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("eAGanil", true ); + inputChain->SetBranchAddress("eAGanil", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("eAGanil", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TeAGanilPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("eAGanil", "TeAGanilPhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TeAGanilPhysics::Construct() { + return (NPL::VDetector*) new TeAGanilPhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy_eAGanil{ + public: + proxy_eAGanil(){ + NPL::DetectorFactory::getInstance()->AddToken("eAGanil","eAGanil"); + NPL::DetectorFactory::getInstance()->AddDetector("eAGanil",TeAGanilPhysics::Construct); + } +}; + +proxy_eAGanil p_eAGanil; +} + diff --git a/NPLib/Detectors/eAGanil/TeAGanilPhysics.h b/NPLib/Detectors/eAGanil/TeAGanilPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..e6d1abe84f412a59da21844367aa7fd21cf7c8c7 --- /dev/null +++ b/NPLib/Detectors/eAGanil/TeAGanilPhysics.h @@ -0,0 +1,180 @@ +#ifndef TeAGanilPHYSICS_H +#define TeAGanilPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2020 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: Adrien Matta contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold eAGanil 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 "TeAGanilData.h" +#include "TeAGanilSpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +// forward declaration +class TeAGanilSpectra; + + + +class TeAGanilPhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TeAGanilPhysics(); + ~TeAGanilPhysics() {}; + + + ////////////////////////////////////////////////////////////// + // 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: + vector<int> DetectorNumber; + vector<double> Energy; + vector<double> Time; + + /// 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); + + // 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 TeAGanilSpectra class + // instantiate the TeAGanilSpectra 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 eAGanil 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 TeAGanilData object to TeAGanilPhysics. + // needed for online analysis for example + void SetRawDataPointer(TeAGanilData* rawDataPointer) {m_EventData = rawDataPointer;} + + // objects are not written in the TTree + private: + TeAGanilData* m_EventData; //! + TeAGanilData* m_PreTreatedData; //! + TeAGanilPhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TeAGanilData* GetRawData() const {return m_EventData;} + TeAGanilData* GetPreTreatedData() const {return m_PreTreatedData;} + + // parameters used in the analysis + private: + // thresholds + double m_E_RAW_Threshold; //! + double m_E_Threshold; //! + + // number of detectors + private: + int m_NumberOfDetectors; //! + + // spectra class + private: + TeAGanilSpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TeAGanilPhysics,1) // eAGanilPhysics structure +}; +#endif diff --git a/NPLib/Detectors/eAGanil/TeAGanilSpectra.cxx b/NPLib/Detectors/eAGanil/TeAGanilSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c419eac20de97c1d175724233635a77391ce2317 --- /dev/null +++ b/NPLib/Detectors/eAGanil/TeAGanilSpectra.cxx @@ -0,0 +1,174 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 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: Adrien Matta contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold eAGanil Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TeAGanilSpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TeAGanilSpectra::TeAGanilSpectra() + : fNumberOfDetectors(0) { + SetName("eAGanil"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TeAGanilSpectra::TeAGanilSpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TeAGanilSpectra : Initalizing control spectra for " + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("eAGanil"); + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TeAGanilSpectra::~TeAGanilSpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TeAGanilSpectra::InitRawSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "eAGanil"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "eAGanil/RAW"); + // Time + name = "eAGanil"+NPL::itoa(i+1)+"_TIME_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "eAGanil/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TeAGanilSpectra::InitPreTreatedSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "eAGanil"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "eAGanil/CAL"); + // Time + name = "eAGanil"+NPL::itoa(i+1)+"_TIME_CAL"; + AddHisto1D(name, name, 500, 0, 25, "eAGanil/CAL"); + + + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TeAGanilSpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "eAGanil_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "eAGanil/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TeAGanilSpectra::FillRawSpectra(TeAGanilData* RawData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "eAGanil"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW"; + family = "eAGanil/RAW"; + + FillSpectra(family,name,RawData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = RawData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "eAGanil"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW"; + family = "eAGanil/RAW"; + + FillSpectra(family,name,RawData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TeAGanilSpectra::FillPreTreatedSpectra(TeAGanilData* PreTreatedData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "eAGanil"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL"; + family = "eAGanil/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = PreTreatedData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "eAGanil"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL"; + family = "eAGanil/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TeAGanilSpectra::FillPhysicsSpectra(TeAGanilPhysics* Physics) { + static string name; + static string family; + family= "eAGanil/PHY"; + + // Energy vs time + unsigned int sizeE = Physics->Energy.size(); + for(unsigned int i = 0 ; i < sizeE ; i++){ + name = "eAGanil_ENERGY_TIME"; + FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]); + } +} + diff --git a/NPLib/Detectors/eAGanil/TeAGanilSpectra.h b/NPLib/Detectors/eAGanil/TeAGanilSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..6f32c3064bda490afd1d76b5c803610d4edb8657 --- /dev/null +++ b/NPLib/Detectors/eAGanil/TeAGanilSpectra.h @@ -0,0 +1,62 @@ +#ifndef TeAGanilSPECTRA_H +#define TeAGanilSPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2020 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: Adrien Matta contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold eAGanil Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TeAGanilData.h" +#include "TeAGanilPhysics.h" + +// Forward Declaration +class TeAGanilPhysics; + + +class TeAGanilSpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TeAGanilSpectra(); + TeAGanilSpectra(unsigned int NumberOfDetectors); + ~TeAGanilSpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TeAGanilData*); + void FillPreTreatedSpectra(TeAGanilData*); + void FillPhysicsSpectra(TeAGanilPhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: + unsigned int fNumberOfDetectors; +}; + +#endif diff --git a/NPSimulation/Detectors/eAGanil/CMakeLists.txt b/NPSimulation/Detectors/eAGanil/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7b2238bb192325faa1916de38665a539f7446e71 --- /dev/null +++ b/NPSimulation/Detectors/eAGanil/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSeAGanil SHARED eAGanil.cc) +target_link_libraries(NPSeAGanil NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPeAGanil) diff --git a/NPSimulation/Detectors/eAGanil/eAGanil.cc b/NPSimulation/Detectors/eAGanil/eAGanil.cc new file mode 100644 index 0000000000000000000000000000000000000000..114a2e29f39d6448694d44c4d2042672ec2f9155 --- /dev/null +++ b/NPSimulation/Detectors/eAGanil/eAGanil.cc @@ -0,0 +1,327 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 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: Adrien Matta contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe eAGanil 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 "eAGanil.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 eAGanil_NS{ + // Energy and time Resolution + const double EnergyThreshold = 0.1*MeV; + const double ResoTime = 4.5*ns ; + const double ResoEnergy = 1.0*MeV ; + const double Thickness = 500*mm ; + const string Material = "Pb"; +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// eAGanil Specific Method +eAGanil::eAGanil(){ + m_Event = new TeAGanilData() ; + m_eAGanilScorer = 0; + + m_Length=0; + + // RGB Color + Transparency + m_VisDetector = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_VisTrap = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.5)); +} + +eAGanil::~eAGanil(){ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void eAGanil::AddDetector(double R, double Theta, double Phi, double EntranceWidth,double EntranceHeigh,double MR){ + m_SpecR.push_back(R); + m_SpecTheta.push_back(Theta); + m_SpecPhi.push_back(Phi); + m_SpecEntranceWidth.push_back(EntranceWidth); + m_SpecEntranceHeigh.push_back(EntranceHeigh); + m_SpecMomentumResolution.push_back(MR); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void eAGanil::SetTrap(double Length, double InnerRadius, double OuterRadius, double BladesThickness, int NumberOfBlades,double Phi, double WindowsThickness){ + m_Length=Length; + m_InnerRadius=InnerRadius; + m_OuterRadius=OuterRadius; + m_BladesThickness=BladesThickness; + m_NumberOfBlades=NumberOfBlades; + m_Phi=Phi; + m_WindowsThickness=WindowsThickness; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* eAGanil::BuildDetector(unsigned int i){ + G4Box* box = new G4Box("eAGanil_Box",m_SpecEntranceHeigh[i]*0.5, + m_SpecEntranceWidth[i]*0.5,eAGanil_NS::Thickness*0.5); + + G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(eAGanil_NS::Material); + G4LogicalVolume* Detector = new G4LogicalVolume(box,DetectorMaterial,"logic_eAGanil_spec",0,0,0); + Detector->SetVisAttributes(m_VisDetector); + Detector->SetSensitiveDetector(m_eAGanilScorer); + return Detector; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4LogicalVolume* eAGanil::BuildTrap(){ + G4Tubs* tubs = new G4Tubs("eAGanil_Trap",m_InnerRadius*0.9,m_OuterRadius*1.1,m_Length*0.5,0,360*deg ); + + G4Material* VacuumMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4LogicalVolume* Trap = new G4LogicalVolume(tubs,VacuumMaterial,"logic_eAGanil_trap",0,0,0); + Trap->SetVisAttributes(G4VisAttributes::Invisible); + + + G4Box* box = new G4Box("eAGanil_Blades", + m_BladesThickness*0.5, + (m_OuterRadius-m_InnerRadius)*0.5, + m_Length*0.5 + ); + + G4Material* TrapMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4LogicalVolume* Blades = new G4LogicalVolume(box,TrapMaterial,"logic_eAGanil_trap",0,0,0); + Blades->SetVisAttributes(m_VisTrap); + G4RotationMatrix* Rot = new G4RotationMatrix(); + G4ThreeVector Pos(0,(m_OuterRadius-m_InnerRadius)*0.5+m_InnerRadius,0); + for(unsigned int i = 0 ; i < m_NumberOfBlades ; i++){ + Rot->rotateZ(360.*deg/m_NumberOfBlades); + Pos.rotateZ(360.*deg/m_NumberOfBlades); + new G4PVPlacement(G4Transform3D(*Rot,Pos), + Blades, + "eAGanil",Trap,false,1); + } + + return Trap; +} + + +//....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 eAGanil::ReadConfiguration(NPL::InputParser parser){ + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil","Spectrometer"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> sphe = {"R","Theta","Phi","EntranceWidth","EntranceHeigh","MomentumResolution"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(sphe)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// eAGanil " << i+1 << endl; + double R = blocks[i]->GetDouble("R","mm"); + double Theta = blocks[i]->GetDouble("Theta","deg"); + double Phi = blocks[i]->GetDouble("Phi","deg"); + double EW = blocks[i]->GetDouble("EntranceWidth","cm"); + double EH = blocks[i]->GetDouble("EntranceHeigh","cm"); + double MR = blocks[i]->GetDouble("MomentumResolution","void"); + AddDetector(R,Theta,Phi,EW,EH,MR); + } + else{ + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } + + blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil","Trap"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> trap= {"Length","InnerRadius", "OuterRadius","BladesThickness","NumberOfBlades","Phi","WindowsThickness"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(trap)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// eAGanil " << i+1 << endl; + + double L = blocks[i]->GetDouble("Length","mm"); + double iR = blocks[i]->GetDouble("InnerRadius","mm"); + double oR = blocks[i]->GetDouble("OuterRadius","mm"); + double fT = blocks[i]->GetDouble("BladesThickness","mm"); + int nF = blocks[i]->GetInt("NumberOfBlades"); + double Phi = blocks[i]->GetDouble("Phi","deg"); + double wT = blocks[i]->GetDouble("WindowsThickness","mm"); + SetTrap(L,iR,oR,fT,nF,Phi,wT); + } + 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 eAGanil::ConstructDetector(G4LogicalVolume* world){ + for (unsigned short i = 0 ; i < m_SpecR.size() ; i++) { + G4double wX = m_SpecR[i] * sin(m_SpecTheta[i] ) * cos(m_SpecPhi[i] ) ; + G4double wY = m_SpecR[i] * sin(m_SpecTheta[i] ) * sin(m_SpecPhi[i] ) ; + G4double wZ = m_SpecR[i] * cos(m_SpecTheta[i] ) ; + G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; + // So the face of the detector is at R instead of the middle + Det_pos+=Det_pos.unit()*eAGanil_NS::Thickness*0.5; + // Building Detector reference frame + G4double ii = cos(m_SpecTheta[i]) * cos(m_SpecPhi[i]); + G4double jj = cos(m_SpecTheta[i]) * sin(m_SpecPhi[i]); + G4double kk = -sin(m_SpecTheta[i]); + G4ThreeVector Y(ii,jj,kk); + G4ThreeVector w = Det_pos.unit(); + G4ThreeVector u = w.cross(Y); + G4ThreeVector v = w.cross(u); + v = v.unit(); + u = u.unit(); + + G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w); + + new G4PVPlacement(G4Transform3D(*Rot,Det_pos), + BuildDetector(i), + "eAGanil",world,false,i+1); + } + if(m_Length){ + G4RotationMatrix* Rot = new G4RotationMatrix(); + Rot->rotateZ(m_Phi); + + new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,0)), + BuildTrap(), + "eAGanil",world,false,1); + } +} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method +void eAGanil::InitializeRootOutput(){ + RootOutput *pAnalysis = RootOutput::getInstance(); + TTree *pTree = pAnalysis->GetTree(); + if(!pTree->FindBranch("eAGanil")){ + pTree->Branch("eAGanil", "TeAGanilData", &m_Event) ; + } + pTree->SetBranchAddress("eAGanil", &m_Event) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void eAGanil::ReadSensitive(const G4Event* ){ + m_Event->Clear(); + + /////////// + // Calorimeter scorer + CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_eAGanilScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for(unsigned int i = 0 ; i < size ; i++){ + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i),eAGanil_NS::ResoEnergy); + if(Energy>eAGanil_NS::EnergyThreshold){ + double Time = RandGauss::shoot(Scorer->GetTime(i),eAGanil_NS::ResoTime); + int DetectorNbr = level[0]; + m_Event->SetEnergy(DetectorNbr,Energy); + m_Event->SetTime(DetectorNbr,Time); + } + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////// +void eAGanil::InitializeScorers() { + // This check is necessary in case the geometry is reloaded + bool already_exist = false; + m_eAGanilScorer = CheckScorer("eAGanilScorer",already_exist) ; + + if(already_exist) + return ; + + // Otherwise the scorer is initialised + vector<int> level; level.push_back(0); + G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ; + G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; + //and register it to the multifunctionnal detector + m_eAGanilScorer->RegisterPrimitive(Calorimeter); + m_eAGanilScorer->RegisterPrimitive(Interaction); + G4SDManager::GetSDMpointer()->AddNewDetector(m_eAGanilScorer) ; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* eAGanil::Construct(){ + return (NPS::VDetector*) new eAGanil(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy_nps_eAGanil{ + public: + proxy_nps_eAGanil(){ + NPS::DetectorFactory::getInstance()->AddToken("eAGanil","eAGanil"); + NPS::DetectorFactory::getInstance()->AddDetector("eAGanil",eAGanil::Construct); + } + }; + + proxy_nps_eAGanil p_nps_eAGanil; +} diff --git a/NPSimulation/Detectors/eAGanil/eAGanil.hh b/NPSimulation/Detectors/eAGanil/eAGanil.hh new file mode 100644 index 0000000000000000000000000000000000000000..03da51795537f5264baa39318598d5c6e07576d9 --- /dev/null +++ b/NPSimulation/Detectors/eAGanil/eAGanil.hh @@ -0,0 +1,120 @@ +#ifndef eAGanil_h +#define eAGanil_h 1 +/***************************************************************************** + * Copyright (C) 2009-2020 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: Adrien Matta contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class describe eAGanil 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" + +// NPTool header +#include "NPSVDetector.hh" +#include "TeAGanilData.h" +#include "NPInputParser.h" + +class eAGanil : public NPS::VDetector{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + public: + eAGanil() ; + virtual ~eAGanil() ; + + //////////////////////////////////////////////////// + /////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// + public: + + void AddDetector(double R, double Theta, double Phi, double EntranceWidth,double EntranceHeigh,double MR); + void SetTrap(double Length,double InnerRadius, double OuterRadius, double BladesThickness, int NumberOfBlades,double Phi, double WindowsThickness); + + G4LogicalVolume* BuildDetector(unsigned int i); + G4LogicalVolume* BuildTrap(); + + private: + //////////////////////////////////////////////////// + ////// 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_eAGanilScorer ; + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// + private: + TeAGanilData* m_Event ; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// + private: // Geometry + // Detector Coordinate + vector<double> m_SpecR; + vector<double> m_SpecTheta; + vector<double> m_SpecPhi; + vector<double> m_SpecEntranceWidth; + vector<double> m_SpecEntranceHeigh; + vector<double> m_SpecMomentumResolution; + + // Trap + double m_Length; + double m_InnerRadius; + double m_OuterRadius; + double m_BladesThickness; + double m_NumberOfBlades; + double m_Phi; + double m_WindowsThickness; + + // Visualisation Attribute + G4VisAttributes* m_VisDetector; + G4VisAttributes* m_VisTrap; + // Needed for dynamic loading of the library + public: + static NPS::VDetector* Construct(); +}; +#endif diff --git a/Projects/eAGanil/Analysis.cxx b/Projects/eAGanil/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..39077081a4c81cf8acbb44a1f358eb26898dae4a --- /dev/null +++ b/Projects/eAGanil/Analysis.cxx @@ -0,0 +1,68 @@ +/***************************************************************************** + * 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 eAGanil analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + eAGanil= (TeAGanilPhysicsPhysics*) m_DetectorManager->GetDetector("eAGanil"); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ +} + + +//////////////////////////////////////////////////////////////////////////////// +// 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/eAGanil/Analysis.h b/Projects/eAGanil/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..744bf0cdf7418bfa39c81b2110f1cac2477613f8 --- /dev/null +++ b/Projects/eAGanil/Analysis.h @@ -0,0 +1,42 @@ +#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 eAGanil analysis project * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +#include"NPVAnalysis.h" +#include"TeAGanilPhysics.h" +class Analysis: public NPL::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + + static NPL::VAnalysis* Construct(); + + private: + TeAGanilPhysics* eAGanil; + +}; +#endif diff --git a/Projects/eAGanil/CMakeLists.txt b/Projects/eAGanil/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22c74affdfc45019bdda2594f8439c52d4ab97ec --- /dev/null +++ b/Projects/eAGanil/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/eAGanil/Mott.cxx b/Projects/eAGanil/Mott.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f74d2b5c4dd9367f9f8c025edf77b5d08d0055c7 --- /dev/null +++ b/Projects/eAGanil/Mott.cxx @@ -0,0 +1,37 @@ +#include"NPPhysicalConstants.h" +double CS(double Z2, double Ei, double Ef, double Mt, double theta){ + static double a2 = NPUNITS::fine_structure_const*NPUNITS::fine_structure_const; + double sin4 = pow(sin(theta*0.5),4); + double sin2 = sin(theta*0.5)*sin(theta*0.5); + double cos2 = cos(theta*0.5)*cos(theta*0.5); + return (M_PI*a2)/(Ei*Ei*sin4)*cos2/(1+(2*Ef/Mt)*sin2); + } + +void Mott(){ + NPL::Reaction r; + r.ReadConfigurationFile("Sn132.reac"); + + double Ei=r.GetBeamEnergy(); + double Ef,Thetaf;// electron + double HE,ThetaE;// heavy ion + unsigned int size = 180; + double step = 180./size; + double Z2 = r.GetParticle2()->GetZ()*r.GetParticle2()->GetZ(); + double Mt = r.GetParticle2()->Mass(); + vector<double> x,y; + ofstream out("mott.txt"); + for(unsigned int i = 0 ; i < size ; i++){ + r.SetThetaCM(i*step); + r.KineRelativistic(Thetaf,Ef,ThetaE,HE); + if(Thetaf){ + double val = CS(Z2,Ei,Ef,Mt,Thetaf); + y.push_back(val); + x.push_back(Thetaf/NPUNITS::deg); + out << i*step << " " << val << endl; + } + } + + auto g = new TGraph(x.size(),&x[0],&y[0]); + g->Draw("ap"); + out.close(); + } diff --git a/Projects/eAGanil/PhysicsListOption.txt b/Projects/eAGanil/PhysicsListOption.txt new file mode 100644 index 0000000000000000000000000000000000000000..ee6f9bf671915b7d77776726cc66b465126c4a3d --- /dev/null +++ b/Projects/eAGanil/PhysicsListOption.txt @@ -0,0 +1,11 @@ +EmPhysicsList Option4 +DefaultCutOff 10000 +IonBinaryCascadePhysics 0 +NPIonInelasticPhysics 0 +EmExtraPhysics 0 +HadronElasticPhysics 0 +StoppingPhysics 0 +OpticalPhysics 0 +HadronPhysicsINCLXX 0 +HadronPhysicsQGSP_BIC_HP 0 +Decay 0 diff --git a/Projects/eAGanil/Sn132.reac b/Projects/eAGanil/Sn132.reac new file mode 100755 index 0000000000000000000000000000000000000000..c6a3c3d915975298636e5646db84b10c5506f8dd --- /dev/null +++ b/Projects/eAGanil/Sn132.reac @@ -0,0 +1,27 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= electron + Energy= 500 MeV + SigmaEnergy= 0 MeV + SigmaThetaX= 0.1 deg + SigmaPhiY= 0.1 deg + SigmaX= 0.1 mm + SigmaY= 0.1 mm + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= 0 mm + MeanY= 0 mm + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam= electron + Target= 132Sn + Light= electron + Heavy= 132Sn + ExcitationEnergy3= 0.0 MeV + ExcitationEnergy4= 0.0 MeV + CrossSectionPath= mott.txt Mott + ShootLight= 1 + ShootHeavy= 1 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Projects/eAGanil/eAGanil.detector b/Projects/eAGanil/eAGanil.detector new file mode 100644 index 0000000000000000000000000000000000000000..0633fb6eac0960f5cc09f1552d317a5f2c25086f --- /dev/null +++ b/Projects/eAGanil/eAGanil.detector @@ -0,0 +1,63 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Target + THICKNESS= 120 mm + RADIUS= @SpecRadius mm + MATERIAL= Vacuum + ANGLE= 0 deg + X= 0 mm + Y= 0 mm + Z= 0 mm + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +eAGanil Trap + Length= 120 mm + InnerRadius= 30 mm + OuterRadius= 60 mm + BladesThickness= 5 mm + NumberOfBlades= 4 + Phi= 45 deg + WindowsThickness= @SpecRadius mm + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Alias SpecRadius + Action= Replace + Value= 0.7 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +eAGanil Spectrometer + R= @SpecRadius m + Theta= 90 deg + Phi= 0 deg + EntranceWidth= 900 mm + EntranceHeigh= 200 mm + MomentumResolution= 0.0001 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +eAGanil Spectrometer + R= @SpecRadius m + Theta= 20 deg + Phi= 0 deg + EntranceWidth= 50 cm + EntranceHeigh= 30 cm + MomentumResolution= 0.0001 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +eAGanil Spectrometer + R= @SpecRadius m + Theta= -90 deg + Phi= 0 deg + EntranceWidth= 900 mm + EntranceHeigh= 200 mm + MomentumResolution= 0.0001 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +eAGanil Spectrometer + R= @SpecRadius m + Theta= 200 deg + Phi= 0 deg + EntranceWidth= 50 cm + EntranceHeigh= 30 cm + MomentumResolution= 0.0001 + + diff --git a/Projects/eAGanil/mott.txt b/Projects/eAGanil/mott.txt new file mode 100644 index 0000000000000000000000000000000000000000..45e07768d72767a241aa68ec434e77cf72bfeb83 --- /dev/null +++ b/Projects/eAGanil/mott.txt @@ -0,0 +1,179 @@ +1 9.87797e-09 +2 3.91506e-10 +3 3.38268e-12 +4 1.70003e-10 +5 3.38315e-09 +6 1.68019e-06 +7 3.93139e-08 +8 8.77652e-10 +9 3.25902e-11 +10 6.3768e-11 +11 1.3674e-09 +12 1.02739e-07 +13 3.02666e-07 +14 2.06046e-09 +15 1.04076e-10 +16 1.47922e-11 +17 6.00142e-10 +18 1.95196e-08 +19 2.12006e-05 +20 5.44061e-09 +21 2.53628e-10 +22 1.31085e-14 +23 2.67131e-10 +24 5.81552e-09 +25 3.49958e-05 +26 1.79186e-08 +27 5.7071e-10 +28 1.29978e-11 +29 1.1058e-10 +30 2.18007e-09 +31 3.58067e-07 +32 9.06657e-08 +33 1.29659e-09 +34 5.93845e-11 +35 3.55966e-11 +36 9.2386e-10 +37 4.35551e-08 +38 1.31711e-06 +39 3.18471e-09 +40 1.60863e-10 +41 4.29103e-12 +42 4.11739e-10 +43 1.06493e-08 +44 0.110796 +45 9.17312e-09 +46 3.72231e-10 +47 2.58458e-12 +48 1.79568e-10 +49 3.59622e-09 +50 2.17707e-06 +51 3.55698e-08 +52 8.33905e-10 +53 2.97425e-11 +54 6.83652e-11 +55 1.44254e-09 +56 1.16869e-07 +57 2.57534e-07 +58 1.9483e-09 +59 9.78616e-11 +60 1.67153e-11 +61 6.31129e-10 +62 2.12987e-08 +63 1.35793e-05 +64 5.09412e-09 +65 2.40739e-10 +66 1.18008e-13 +67 2.81279e-10 +68 6.22166e-09 +69 6.20634e-05 +70 1.64751e-08 +71 5.42745e-10 +72 1.13293e-11 +73 1.17387e-10 +74 2.3077e-09 +75 4.26665e-07 +76 8.03004e-08 +77 1.22982e-09 +78 5.52067e-11 +79 3.87667e-11 +80 9.72693e-10 +81 4.83743e-08 +82 1.04685e-06 +83 2.99973e-09 +84 1.52129e-10 +85 5.31109e-12 +86 4.32987e-10 +87 1.14947e-08 +88 0.00692419 +89 8.52806e-09 +90 3.53866e-10 +91 1.89547e-12 +92 1.89579e-10 +93 3.82521e-09 +94 2.87146e-06 +95 3.22547e-08 +96 7.9247e-10 +97 2.70485e-11 +98 7.31846e-11 +99 1.52232e-09 +100 1.33488e-07 +101 2.20472e-07 +102 1.84303e-09 +103 9.19253e-11 +104 1.87703e-11 +105 6.63767e-10 +106 2.32804e-08 +107 9.09381e-06 +108 4.77354e-09 +109 2.28434e-10 +110 3.27972e-13 +111 2.96106e-10 +112 6.66217e-09 +113 0.000121133 +114 1.51708e-08 +115 5.16164e-10 +116 9.78376e-12 +117 1.2451e-10 +118 2.444e-09 +119 5.12414e-07 +120 7.13621e-08 +121 1.16681e-09 +122 5.12273e-11 +123 4.2106e-11 +124 1.02432e-09 +125 5.38681e-08 +126 8.42351e-07 +127 2.82714e-09 +128 1.43782e-10 +129 6.44449e-12 +130 4.55307e-10 +131 1.24229e-08 +132 0.00136755 +133 7.93686e-09 +134 3.36362e-10 +135 1.31424e-12 +136 2.00057e-10 +137 4.07155e-09 +138 3.86544e-06 +139 2.93113e-08 +140 7.53206e-10 +141 2.45037e-11 +142 7.82351e-11 +143 1.60707e-09 +144 1.5314e-07 +145 1.89812e-07 +146 1.74417e-09 +147 8.62553e-11 +148 2.09607e-11 +149 6.98158e-10 +150 2.54925e-08 +151 6.31573e-06 +152 4.4766e-09 +153 2.16683e-10 +154 6.43334e-13 +155 3.11649e-10 +156 7.14054e-09 +157 0.00027046 +158 1.39901e-08 +159 4.90889e-10 +160 8.35882e-12 +161 1.31963e-10 +162 2.58966e-09 +163 6.20716e-07 +164 6.36219e-08 +165 1.10734e-09 +166 4.74389e-11 +167 4.56205e-11 +168 1.07894e-09 +169 6.01527e-08 +170 6.85326e-07 +171 2.66598e-09 +172 1.35805e-10 +173 7.69305e-12 +174 4.78759e-10 +175 1.34435e-08 +176 0.000432619 +177 7.39425e-09 +178 3.19674e-10 +179 8.39972e-13 diff --git a/Projects/eAGanil/run.mac b/Projects/eAGanil/run.mac new file mode 100644 index 0000000000000000000000000000000000000000..8eec34f7c0cc1911bbafaa6e92961e0836d874ba --- /dev/null +++ b/Projects/eAGanil/run.mac @@ -0,0 +1 @@ +/run/beamOn 1000