diff --git a/NPLib/Detectors/LEPS/CMakeLists.txt b/NPLib/Detectors/LEPS/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9b35d7a28c5eeeb79fa6b3dff12e4415acf5ea36 --- /dev/null +++ b/NPLib/Detectors/LEPS/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TLEPSPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TLEPSPhysics.h TLEPSPhysicsDict.cxx TLEPSPhysics.rootmap libNPLEPS.dylib DEPENDS TLEPSPhysics.h) +add_custom_command(OUTPUT TLEPSDataDict.cxx COMMAND ../../scripts/build_dict.sh TLEPSData.h TLEPSDataDict.cxx TLEPSData.rootmap libNPLEPS.dylib DEPENDS TLEPSData.h) +add_library(NPLEPS SHARED TLEPSSpectra.cxx TLEPSData.cxx TLEPSPhysics.cxx TLEPSDataDict.cxx TLEPSPhysicsDict.cxx ) +target_link_libraries(NPLEPS ${ROOT_LIBRARIES} NPCore) +install(FILES TLEPSData.h TLEPSPhysics.h TLEPSSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/LEPS/TLEPSData.cxx b/NPLib/Detectors/LEPS/TLEPSData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..011f7a9402acaf9e50667a2b99a1e13dbd95b109 --- /dev/null +++ b/NPLib/Detectors/LEPS/TLEPSData.cxx @@ -0,0 +1,79 @@ +/***************************************************************************** + * 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: Leo Plagnol contact address: plagnol@ijclab.in2p3.fr * + * * + * Creation Date : March 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold LEPS Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TLEPSData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TLEPSData) + + +////////////////////////////////////////////////////////////////////// +TLEPSData::TLEPSData() { +} + + + +////////////////////////////////////////////////////////////////////// +TLEPSData::~TLEPSData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TLEPSData::Clear() { + // Energy + fLEPS_E_DetectorNbr.clear(); + fLEPS_Energy.clear(); + // Time + fLEPS_T_DetectorNbr.clear(); + fLEPS_Time.clear(); +} + + + +////////////////////////////////////////////////////////////////////// +void TLEPSData::Dump() const { + // This method is very useful for debuging and worth the dev. + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TLEPSData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = fLEPS_E_DetectorNbr.size(); + cout << "LEPS_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fLEPS_E_DetectorNbr[i] + << " Energy: " << fLEPS_Energy[i]; + } + + // Time + mysize = fLEPS_T_DetectorNbr.size(); + cout << "LEPS_T_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fLEPS_T_DetectorNbr[i] + << " Time: " << fLEPS_Time[i]; + } +} diff --git a/NPLib/Detectors/LEPS/TLEPSData.h b/NPLib/Detectors/LEPS/TLEPSData.h new file mode 100644 index 0000000000000000000000000000000000000000..b3a71af8e735ee55ccac348af55f36a2d5074c7d --- /dev/null +++ b/NPLib/Detectors/LEPS/TLEPSData.h @@ -0,0 +1,104 @@ +#ifndef __LEPSDATA__ +#define __LEPSDATA__ +/***************************************************************************** + * 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: Leo Plagnol contact address: plagnol@ijclab.in2p3.fr * + * * + * Creation Date : March 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold LEPS Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TLEPSData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + private: + // Energy + vector<UShort_t> fLEPS_E_DetectorNbr; + vector<Double_t> fLEPS_Energy; + + // Time + vector<UShort_t> fLEPS_T_DetectorNbr; + vector<Double_t> fLEPS_Time; + + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TLEPSData(); + ~TLEPSData(); + + + ////////////////////////////////////////////////////////////// + // 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){ + fLEPS_E_DetectorNbr.push_back(DetNbr); + fLEPS_Energy.push_back(Energy); + };//! + + // Time + inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) { + fLEPS_T_DetectorNbr.push_back(DetNbr); + fLEPS_Time.push_back(Time); + };//! + + + ////////////////////// GETTERS //////////////////////// + // Energy + inline UShort_t GetMultEnergy() const + {return fLEPS_E_DetectorNbr.size();} + inline UShort_t GetE_DetectorNbr(const unsigned int &i) const + {return fLEPS_E_DetectorNbr[i];}//! + inline Double_t Get_Energy(const unsigned int &i) const + {return fLEPS_Energy[i];}//! + + // Time + inline UShort_t GetMultTime() const + {return fLEPS_T_DetectorNbr.size();} + inline UShort_t GetT_DetectorNbr(const unsigned int &i) const + {return fLEPS_T_DetectorNbr[i];}//! + inline Double_t Get_Time(const unsigned int &i) const + {return fLEPS_Time[i];}//! + + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TLEPSData,1) // LEPSData structure +}; + +#endif diff --git a/NPLib/Detectors/LEPS/TLEPSPhysics.cxx b/NPLib/Detectors/LEPS/TLEPSPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..121b805009e24918b09885a0955e9f00d196e2b6 --- /dev/null +++ b/NPLib/Detectors/LEPS/TLEPSPhysics.cxx @@ -0,0 +1,344 @@ +/***************************************************************************** + * 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: Leo Plagnol contact address: plagnol@ijclab.in2p3.fr * + * * + * Creation Date : March 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold LEPS Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TLEPSPhysics.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(TLEPSPhysics) + + +/////////////////////////////////////////////////////////////////////////// +TLEPSPhysics::TLEPSPhysics() + : m_EventData(new TLEPSData), + m_PreTreatedData(new TLEPSData), + 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 TLEPSPhysics::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 TLEPSPhysics::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 TLEPSPhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::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 TLEPSPhysics::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("LEPS/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("LEPS/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i)); + m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigLEPS.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigLEPS.dat found: Default parameter loaded for Analayis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigLEPS.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigLEPS.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 = "ConfigLEPS"; + 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 TLEPSPhysics::Clear() { + DetectorNumber.clear(); + Energy.clear(); + Time.clear(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("LEPS"); + 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 << "//// LEPS " << 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 << "//// LEPS " << 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 TLEPSPhysics::InitSpectra() { + m_Spectra = new TLEPSSpectra(m_NumberOfDetectors); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TLEPSPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + for (int i = 0; i < m_NumberOfDetectors; ++i) { + Cal->AddParameter("LEPS", "D"+ NPL::itoa(i+1)+"_ENERGY","LEPS_D"+ NPL::itoa(i+1)+"_ENERGY"); + Cal->AddParameter("LEPS", "D"+ NPL::itoa(i+1)+"_TIME","LEPS_D"+ NPL::itoa(i+1)+"_TIME"); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("LEPS", true ); + inputChain->SetBranchAddress("LEPS", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("LEPS", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TLEPSPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("LEPS", "TLEPSPhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TLEPSPhysics::Construct() { + return (NPL::VDetector*) new TLEPSPhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy_LEPS{ + public: + proxy_LEPS(){ + NPL::DetectorFactory::getInstance()->AddToken("LEPS","LEPS"); + NPL::DetectorFactory::getInstance()->AddDetector("LEPS",TLEPSPhysics::Construct); + } +}; + +proxy_LEPS p_LEPS; +} + diff --git a/NPLib/Detectors/LEPS/TLEPSPhysics.h b/NPLib/Detectors/LEPS/TLEPSPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..c89d69e1dfb6623098d4356d6eca31e39d0deef9 --- /dev/null +++ b/NPLib/Detectors/LEPS/TLEPSPhysics.h @@ -0,0 +1,180 @@ +#ifndef TLEPSPHYSICS_H +#define TLEPSPHYSICS_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: Leo Plagnol contact address: plagnol@ijclab.in2p3.fr * + * * + * Creation Date : March 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold LEPS 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 "TLEPSData.h" +#include "TLEPSSpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +// forward declaration +class TLEPSSpectra; + + + +class TLEPSPhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TLEPSPhysics(); + ~TLEPSPhysics() {}; + + + ////////////////////////////////////////////////////////////// + // 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 TLEPSSpectra class + // instantiate the TLEPSSpectra 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 LEPS 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 TLEPSData object to TLEPSPhysics. + // needed for online analysis for example + void SetRawDataPointer(TLEPSData* rawDataPointer) {m_EventData = rawDataPointer;} + + // objects are not written in the TTree + private: + TLEPSData* m_EventData; //! + TLEPSData* m_PreTreatedData; //! + TLEPSPhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TLEPSData* GetRawData() const {return m_EventData;} + TLEPSData* 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: + TLEPSSpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TLEPSPhysics,1) // LEPSPhysics structure +}; +#endif diff --git a/NPLib/Detectors/LEPS/TLEPSSpectra.cxx b/NPLib/Detectors/LEPS/TLEPSSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..41f96a17227db580ce22b44fb1e949a41d481170 --- /dev/null +++ b/NPLib/Detectors/LEPS/TLEPSSpectra.cxx @@ -0,0 +1,174 @@ +/***************************************************************************** + * 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: Leo Plagnol contact address: plagnol@ijclab.in2p3.fr * + * * + * Creation Date : March 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold LEPS Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TLEPSSpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TLEPSSpectra::TLEPSSpectra() + : fNumberOfDetectors(0) { + SetName("LEPS"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TLEPSSpectra::TLEPSSpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TLEPSSpectra : Initalizing control spectra for " + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("LEPS"); + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TLEPSSpectra::~TLEPSSpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TLEPSSpectra::InitRawSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "LEPS"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "LEPS/RAW"); + // Time + name = "LEPS"+NPL::itoa(i+1)+"_TIME_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "LEPS/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TLEPSSpectra::InitPreTreatedSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "LEPS"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "LEPS/CAL"); + // Time + name = "LEPS"+NPL::itoa(i+1)+"_TIME_CAL"; + AddHisto1D(name, name, 500, 0, 25, "LEPS/CAL"); + + + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TLEPSSpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "LEPS_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "LEPS/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TLEPSSpectra::FillRawSpectra(TLEPSData* RawData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "LEPS"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW"; + family = "LEPS/RAW"; + + FillSpectra(family,name,RawData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = RawData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "LEPS"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW"; + family = "LEPS/RAW"; + + FillSpectra(family,name,RawData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TLEPSSpectra::FillPreTreatedSpectra(TLEPSData* PreTreatedData) { + static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "LEPS"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL"; + family = "LEPS/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = PreTreatedData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "LEPS"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL"; + family = "LEPS/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Time(i)); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TLEPSSpectra::FillPhysicsSpectra(TLEPSPhysics* Physics) { + static string name; + static string family; + family= "LEPS/PHY"; + + // Energy vs time + unsigned int sizeE = Physics->Energy.size(); + for(unsigned int i = 0 ; i < sizeE ; i++){ + name = "LEPS_ENERGY_TIME"; + FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]); + } +} + diff --git a/NPLib/Detectors/LEPS/TLEPSSpectra.h b/NPLib/Detectors/LEPS/TLEPSSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..363940c6cb94dbd75f583cc3e1aab344cfdf5c56 --- /dev/null +++ b/NPLib/Detectors/LEPS/TLEPSSpectra.h @@ -0,0 +1,62 @@ +#ifndef TLEPSSPECTRA_H +#define TLEPSSPECTRA_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: Leo Plagnol contact address: plagnol@ijclab.in2p3.fr * + * * + * Creation Date : March 2024 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold LEPS Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TLEPSData.h" +#include "TLEPSPhysics.h" + +// Forward Declaration +class TLEPSPhysics; + + +class TLEPSSpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TLEPSSpectra(); + TLEPSSpectra(unsigned int NumberOfDetectors); + ~TLEPSSpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TLEPSData*); + void FillPreTreatedSpectra(TLEPSData*); + void FillPhysicsSpectra(TLEPSPhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: + unsigned int fNumberOfDetectors; +}; + +#endif