diff --git a/NPLib/Detectors/NebulaPlus/CMakeLists.txt b/NPLib/Detectors/NebulaPlus/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22de86f67630a680efb1d371ff261617a10f1099 --- /dev/null +++ b/NPLib/Detectors/NebulaPlus/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TNebulaPlusPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TNebulaPlusPhysics.h TNebulaPlusPhysicsDict.cxx TNebulaPlusPhysics.rootmap libNPNebulaPlus.dylib DEPENDS TNebulaPlusPhysics.h) +add_custom_command(OUTPUT TNebulaPlusDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TNebulaPlusData.h TNebulaPlusDataDict.cxx TNebulaPlusData.rootmap libNPNebulaPlus.dylib DEPENDS TNebulaPlusData.h) +add_library(NPNebulaPlus SHARED TNebulaPlusSpectra.cxx TNebulaPlusData.cxx TNebulaPlusPhysics.cxx TNebulaPlusDataDict.cxx TNebulaPlusPhysicsDict.cxx ) +target_link_libraries(NPNebulaPlus ${ROOT_LIBRARIES} NPCore) +install(FILES TNebulaPlusData.h TNebulaPlusPhysics.h TNebulaPlusSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/NebulaPlus/TNebulaPlusData.cxx b/NPLib/Detectors/NebulaPlus/TNebulaPlusData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..acbe099f6d22b531f7d48259318b48319bb68b84 --- /dev/null +++ b/NPLib/Detectors/NebulaPlus/TNebulaPlusData.cxx @@ -0,0 +1,86 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 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: freddy flavigny contact: flavigny@lpccaen.in2p3.fr * + * * + * Creation Date : OCtober 2022 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold NebulaPlus Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TNebulaPlusData.h" + +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(TNebulaPlusData) + + +////////////////////////////////////////////////////////////////////// +TNebulaPlusData::TNebulaPlusData() { +} + + + +////////////////////////////////////////////////////////////////////// +TNebulaPlusData::~TNebulaPlusData() { +} + + + +////////////////////////////////////////////////////////////////////// +void TNebulaPlusData::Clear() { + // UP // + fNebulaPlus_u_ID.clear(); + fNebulaPlus_u_Q.clear(); + fNebulaPlus_u_Q4.clear(); + fNebulaPlus_u_T.clear(); + + // DOWN // + fNebulaPlus_d_ID.clear(); + fNebulaPlus_d_Q.clear(); + fNebulaPlus_d_Q4.clear(); + fNebulaPlus_d_T.clear(); +} + + + +////////////////////////////////////////////////////////////////////// +void TNebulaPlusData::Dump() const { +/* // This method is very useful for debuging and worth the dev. + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TNebulaPlusData::Dump()] XXXXXXXXXXXXXXXXX" << endl; + + // Energy + size_t mysize = fNebulaPlus_E_DetectorNbr.size(); + cout << "NebulaPlus_E_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fNebulaPlus_E_DetectorNbr[i] + << " Energy: " << fNebulaPlus_Energy[i]; + } + + // Time + mysize = fNebulaPlus_T_DetectorNbr.size(); + cout << "NebulaPlus_T_Mult: " << mysize << endl; + + for (size_t i = 0 ; i < mysize ; i++){ + cout << "DetNbr: " << fNebulaPlus_T_DetectorNbr[i] + << " Time: " << fNebulaPlus_Time[i]; + } + */ +} diff --git a/NPLib/Detectors/NebulaPlus/TNebulaPlusData.h b/NPLib/Detectors/NebulaPlus/TNebulaPlusData.h new file mode 100644 index 0000000000000000000000000000000000000000..f11345e2a2531945ec79af0f040bb643c26fe7e3 --- /dev/null +++ b/NPLib/Detectors/NebulaPlus/TNebulaPlusData.h @@ -0,0 +1,123 @@ +#ifndef __NebulaPlusDATA__ +#define __NebulaPlusDATA__ +/***************************************************************************** + * Copyright (C) 2009-2019 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: freddy flavigny contact: flavigny@lpccaen.in2p3.fr * + * * + * Creation Date : OCotber 2022 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold NebulaPlus Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" + +class TNebulaPlusData : public TObject { + ////////////////////////////////////////////////////////////// + // data members are hold into vectors in order + // to allow multiplicity treatment + private: + // UP // + // Charges and Time + vector<UShort_t> fNebulaPlus_u_ID; + vector<Double_t> fNebulaPlus_u_Q; + vector<Double_t> fNebulaPlus_u_Q4; + vector<Double_t> fNebulaPlus_u_T; + + // DOWN // + // Charges and Time + vector<UShort_t> fNebulaPlus_d_ID; + vector<Double_t> fNebulaPlus_d_Q; + vector<Double_t> fNebulaPlus_d_Q4; + vector<Double_t> fNebulaPlus_d_T; + + + ////////////////////////////////////////////////////////////// + // Constructor and destructor + public: + TNebulaPlusData(); + ~TNebulaPlusData(); + + + ////////////////////////////////////////////////////////////// + // 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 //////////////////////// + // UP // + inline void SetUp(const Double_t& ID, const Double_t& Q, const Double_t& Q4, const Double_t& T){ + fNebulaPlus_u_ID.push_back(ID); + fNebulaPlus_u_Q.push_back(Q); + fNebulaPlus_u_Q4.push_back(Q4); + fNebulaPlus_u_T.push_back(T); + };//! + + // DOWN // + inline void SetDown(const Double_t& ID, const Double_t& Q, const Double_t& Q4, const Double_t& T){ + fNebulaPlus_d_ID.push_back(ID); + fNebulaPlus_d_Q.push_back(Q); + fNebulaPlus_d_Q4.push_back(Q4); + fNebulaPlus_d_T.push_back(T); + };//! + + ////////////////////// GETTERS //////////////////////// + // MULT // + inline unsigned int GetUpMult() const + {return fNebulaPlus_u_ID.size();}; + inline unsigned int GetDownMult() const + {return fNebulaPlus_d_ID.size();}; + + // Value // + // Up + inline UShort_t GetUpID(unsigned int& i) const + {return fNebulaPlus_u_ID[i];}; + inline double GetUpQ(unsigned int& i) const + {return fNebulaPlus_u_Q[i];}; + inline double GetUpQ4(unsigned int& i) const + {return fNebulaPlus_u_Q4[i];}; + inline double GetUpT(unsigned int& i) const + {return fNebulaPlus_u_T[i];}; + + // Down + inline UShort_t GetDownID(unsigned int& i) const + {return fNebulaPlus_d_ID[i];}; + inline double GetDownQ(unsigned int& i) const + {return fNebulaPlus_d_Q[i];}; + inline double GetDownQ4(unsigned int& i) const + {return fNebulaPlus_d_Q4[i];}; + inline double GetDownT(unsigned int& i) const + {return fNebulaPlus_d_T[i];}; + + ////////////////////////////////////////////////////////////// + // Required for ROOT dictionnary + ClassDef(TNebulaPlusData,1) // NebulaPlusData structure +}; + +#endif diff --git a/NPLib/Detectors/NebulaPlus/TNebulaPlusPhysics.cxx b/NPLib/Detectors/NebulaPlus/TNebulaPlusPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4c7dcaacf44635d4104c34260caf8c8e8a9164df --- /dev/null +++ b/NPLib/Detectors/NebulaPlus/TNebulaPlusPhysics.cxx @@ -0,0 +1,362 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 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 : December 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold NebulaPlus Treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include "TNebulaPlusPhysics.h" + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> +using namespace std; + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "NPDetectorFactory.h" +#include "NPOptionManager.h" +#include "NPSystemOfUnits.h" +// ROOT +#include "TChain.h" + +ClassImp(TNebulaPlusPhysics) + + + /////////////////////////////////////////////////////////////////////////// +TNebulaPlusPhysics::TNebulaPlusPhysics() + : m_EventData(new TNebulaPlusData), + m_EventPhysics(this), + m_Spectra(0), + m_Q_RAW_Threshold(0), // adc channels + m_Q_Threshold(7), // normal bars in MeV + m_V_Threshold(1), // veto bars in MeV + m_NumberOfBars(0) { + } + +/////////////////////////////////////////////////////////////////////////// +/// A usefull method to bundle all operation to add a detector +void TNebulaPlusPhysics::ReadXML(NPL::XmlParser xml){ + std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName("NEBULA"); + + for(unsigned int i = 0 ; i < b.size() ; i++){ + m_NumberOfBars++; + unsigned int id = b[i]->AsInt("ID"); + + // position + PositionX[id] = b[i]->AsDouble("PosX"); + PositionY[id] = b[i]->AsDouble("PosY"); + PositionZ[id] = b[i]->AsDouble("PosZ"); + // linear cal + aQu[id] = b[i]->AsDouble("QUCal"); + bQu[id] = b[i]->AsDouble("QUPed"); + aQd[id] = b[i]->AsDouble("QDCal"); + bQd[id] = b[i]->AsDouble("QDPed"); + aTu[id] = b[i]->AsDouble("TUCal"); + bTu[id] = b[i]->AsDouble("TUOff"); + aTd[id] = b[i]->AsDouble("TDCal"); + bTd[id] = b[i]->AsDouble("TDOff"); + + // T average offset + avgT0[id] = b[i]->AsDouble("TAveOff"); + + // slew correction T= tcal +slwT/sqrt(Qcal) + slwTu[id] = b[i]->AsDouble("TUSlw"); + slwTd[id] = b[i]->AsDouble("TDSlw"); + + // DT position cal + DTa[id] = b[i]->AsDouble("DTCal");//! + DTb[id] = b[i]->AsDouble("DTOff");//! + + + } + cout << " -> " << m_NumberOfBars << " bars found" << endl;; +} + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::BuildSimplePhysicalEvent() { + BuildPhysicalEvent(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::BuildPhysicalEvent() { + // apply thresholds and calibration +/* + // instantiate CalibrationManager + static CalibrationManager* Cal = CalibrationManager::getInstance(); + static double rawQup,calQup,rawQdown,calQdown,rawTup,calTup,rawTdown,calTdown,calQ,calT,Y; + static unsigned int ID; + // All vector size + static unsigned int QUsize, QDsize, TUsize, TDsize ; + QUsize = m_EventData->GetChargeUpMult(); + QDsize = m_EventData->GetChargeDownMult(); + TUsize = m_EventData->GetTimeUpMult(); + TDsize = m_EventData->GetTimeDownMult(); + static double threshold; + // loop on Qup + for (unsigned int qup = 0; qup < QUsize ; qup++) { + + rawQup = m_EventData->GetChargeUp(qup); + rawTup=-1; + rawQdown=-1; + rawTdown=-1; + if (rawQup > m_Q_RAW_Threshold) { + ID = m_EventData->GetChargeUpID(qup); + if(ID<121) + threshold=m_Q_Threshold; + else + threshold=m_V_Threshold; + + // look for associated Charge down + for(unsigned int qdown = 0 ; qdown < QDsize ; qdown++){ + if(m_EventData->GetChargeDownID(qdown)==ID){ + rawQdown=m_EventData->GetChargeDown(qdown); + if(rawQdown > m_Q_RAW_Threshold){ + // Look for the associate time + for(unsigned int tdown = 0 ; tdown < TDsize; tdown++){ + if(m_EventData->GetTimeDownID(qdown)==ID) { + rawTdown=m_EventData->GetTimeDown(qdown); + break; + } + }// TDown + }//if raw threshold down + + break; + } //if match ID + + }// Qdwown + + if(rawTdown>0){ // Tdown is found, means Qdown as well + // look for Tup + for(unsigned int tup = 0 ; tup < TUsize ; tup++){ + if(m_EventData->GetTimeUpID(tup)==ID){ + rawTup = m_EventData->GetTimeUp(tup); + break; + } + } + } + // Got everything, do the math + if(rawTup>0){ + // cal Q Up and Down + calQup=aQu[ID]*(rawQup-bQu[ID]); + calQdown=aQd[ID]*(rawQdown-bQd[ID]); + + // average value of Up and Down + calQ=sqrt(calQup*calQdown); + + // cal T Up + calTup=aTu[ID]*rawTup+bTu[ID]; + // slew correction + calTup -= slwTu[ID]/sqrt(rawQup-bQu[ID]); + + // cal T Down + calTdown=aTd[ID]*rawTdown+bTd[ID]; + // slew correction + calTdown -= slwTd[ID]/sqrt(rawQdown-bQd[ID]); + + + if(calQ>threshold){ + calT= (calTdown+calTup)*0.5+avgT0[ID]+Cal->GetPedestal("NEBULA_T_ID"+NPL::itoa(ID)); + Y=(calTdown-calTup)*DTa[ID]+DTb[ID]+Cal->GetPedestal("NEBULA_Y_ID"+NPL::itoa(ID)); + + DetectorNumber.push_back(ID); + Charge.push_back(calQ); + TOF.push_back(calT); + PosY.push_back(Y+PositionY[ID]); + PosX.push_back(PositionX[ID]); + PosZ.push_back(PositionZ[ID]); + + if(ID<121) + IsVeto.push_back(0); + else + IsVeto.push_back(1); + + } + } + + }// if raw threshold up + } // Qup +*/ +} + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::PreTreat() { + +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::ReadAnalysisConfig() { +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::Clear() { + DetectorNumber.clear(); + Charge.clear(); + TOF.clear(); + PosY.clear(); + PosX.clear(); + PosZ.clear(); + IsVeto.clear(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("NEBULA"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detector(s) found " << endl; + + vector<string> token= {"XML","Offset","InvertX","InvertY"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if(blocks[i]->HasTokenList(token)){ + cout << endl << "//// NebulaPlus (" << i+1 << ")" << endl; + unsigned int det = std::atoi(blocks[i]->GetMainValue().c_str()); + string xmlpath = blocks[i]->GetString("XML"); + NPL::XmlParser xml; + xml.LoadFile(xmlpath); + ReadXML(xml); + TVector3 offset = blocks[i]->GetTVector3("Offset","mm"); + bool invertX = blocks[i]->GetInt("InvertX"); + bool invertY = blocks[i]->GetInt("InvertY"); + m_offset[det] = offset; + m_invertX[det] = invertX; + m_invertY[det] = invertY; + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::InitSpectra() { + m_Spectra = new TNebulaPlusSpectra(m_NumberOfBars); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::FillSpectra() { + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::CheckSpectra() { + m_Spectra->CheckSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::ClearSpectra() { + // To be done +} + + + +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TNebulaPlusPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::WriteSpectra() { + m_Spectra->WriteSpectra(); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + + vector<double> standardO={0}; + for (int i = 0; i < m_NumberOfBars; ++i) { + Cal->AddParameter("NEBULA_T_ID"+ NPL::itoa(i+1),standardO); + Cal->AddParameter("NEBULA_Y_ID"+ NPL::itoa(i+1),standardO); + } +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("NebulaPlus", true ); + inputChain->SetBranchAddress("NebulaPlus", &m_EventData ); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchAddress("NebulaPlus", &m_EventPhysics); +} + + + +/////////////////////////////////////////////////////////////////////////// +void TNebulaPlusPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree("NebulaPlus"); + outputTree->Branch("NebulaPlus", "TNebulaPlusPhysics", &m_EventPhysics); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TNebulaPlusPhysics::Construct() { + return (NPL::VDetector*) new TNebulaPlusPhysics(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ + class proxy_NebulaPlus{ + public: + proxy_NebulaPlus(){ + NPL::DetectorFactory::getInstance()->AddToken("NEBULAPLUS","NebulaPlus"); + NPL::DetectorFactory::getInstance()->AddDetector("NEBULAPLUS",TNebulaPlusPhysics::Construct); + } + }; + + proxy_NebulaPlus p_NebulaPlus; +} + diff --git a/NPLib/Detectors/NebulaPlus/TNebulaPlusPhysics.h b/NPLib/Detectors/NebulaPlus/TNebulaPlusPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..32b1a9547f03740eca22cbcd4898283be3e732d4 --- /dev/null +++ b/NPLib/Detectors/NebulaPlus/TNebulaPlusPhysics.h @@ -0,0 +1,250 @@ +#ifndef TNebulaPlusPHYSICS_H +#define TNebulaPlusPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2019 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 : December 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold NebulaPlus 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 "TNebulaPlusData.h" +#include "TNebulaPlusSpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +#include "NPXmlParser.h" +// forward declaration +class TNebulaPlusSpectra; + + + +class TNebulaPlusPhysics : public TObject, public NPL::VDetector { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TNebulaPlusPhysics(); + ~TNebulaPlusPhysics() {}; + + + ////////////////////////////////////////////////////////////// + // 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> Charge; + vector<double> TOF; + vector<double> PosY; + vector<double> PosX; + vector<double> PosZ; + vector<bool> IsVeto; + + public: + TVector3 GetPos(const unsigned int& i) const{ + return TVector3(PosX[i],PosY[i],PosZ[i]); + } + + // Return true if one veto fired + bool HasVeto(){ + unsigned int size = IsVeto.size(); + for(unsigned int i = 0 ; i < size ; i++){ + if(IsVeto[i]) + return true; + } + return false; + }; + + /////////// Get index of fastest neutron + int GetFirstHit(){ + unsigned int size = TOF.size(); + unsigned int index=0; + + if(!size) + return -1; + + double tof = TOF[0]; + for(unsigned int i = 1 ; i < size ; i++){ + if(tof<TOF[i]){ + tof=TOF[i]; + index=i; + } + } + return index; + }; + + public: + /// A usefull method to bundle all operation to add a detector + void ReadXML(NPL::XmlParser); + + ////////////////////////////////////////////////////////////// + // 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 TNebulaPlusSpectra class + // instantiate the TNebulaPlusSpectra 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 NebulaPlus array + public: + // remove bad channels, calibrate the data and apply thresholds + void PreTreat(); + + // read the user configuration file. If no file is found, load standard one + void ReadAnalysisConfig(); + + // give and external TNebulaPlusData object to TNebulaPlusPhysics. + // needed for online analysis for example + void SetRawDataPointer(TNebulaPlusData* rawDataPointer) {m_EventData = rawDataPointer;} + + // objects are not written in the TTree + private: + TNebulaPlusData* m_EventData; //! + TNebulaPlusPhysics* m_EventPhysics; //! + + // getters for raw and pre-treated data object + public: + TNebulaPlusData* GetRawData() const {return m_EventData;} + + // parameters used in the analysis + private: + // thresholds + double m_Q_RAW_Threshold; //! + double m_Q_Threshold; //! + double m_V_Threshold; //! + + public: + void SetQThreshold(double t) {m_Q_Threshold=t;}; + void SetVThreshold(double t) {m_V_Threshold=t;}; + // number of detectors + private: + int m_NumberOfBars; //! + + private: // offset and inversion + std::map<unsigned int, TVector3> m_offset;//! + std::map<unsigned int, bool> m_invertX;//! + std::map<unsigned int, bool> m_invertY;//! + + private: // xml calibration + // position + std::map<unsigned int , double > PositionX;//! + std::map<unsigned int , double > PositionY;//! + std::map<unsigned int , double > PositionZ;//! + + // linear cal + std::map<unsigned int , double > aQu;//! + std::map<unsigned int , double > bQu;//! + std::map<unsigned int , double > aQd;//! + std::map<unsigned int , double > bQd;//! + std::map<unsigned int , double > aTu;//! + std::map<unsigned int , double > bTu;//! + std::map<unsigned int , double > aTd;//! + std::map<unsigned int , double > bTd;//! + + // T average offset + std::map<unsigned int , double > avgT0;//! + + // slew correction T= tcal +slwT/sqrt(Qcal) + std::map<unsigned int , double > slwTu;//! + std::map<unsigned int , double > slwTd;//! + + // DT position cal + std::map<unsigned int , double > DTa;//! + std::map<unsigned int , double > DTb;//! + + + // spectra class + private: + TNebulaPlusSpectra* m_Spectra; // ! + + // spectra getter + public: + map<string, TH1*> GetSpectra(); + + // Static constructor to be passed to the Detector Factory + public: + static NPL::VDetector* Construct(); + + ClassDef(TNebulaPlusPhysics,1) // NebulaPlusPhysics structure +}; +#endif diff --git a/NPLib/Detectors/NebulaPlus/TNebulaPlusSpectra.cxx b/NPLib/Detectors/NebulaPlus/TNebulaPlusSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5e1c5fe27cf67de936f89a91d2065e22d14c31f9 --- /dev/null +++ b/NPLib/Detectors/NebulaPlus/TNebulaPlusSpectra.cxx @@ -0,0 +1,174 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 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 : December 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold NebulaPlus Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// class header +#include "TNebulaPlusSpectra.h" + +// STL +#include <iostream> +#include <string> +using namespace std; + +// NPTool header +#include "NPOptionManager.h" + + + +//////////////////////////////////////////////////////////////////////////////// +TNebulaPlusSpectra::TNebulaPlusSpectra() + : fNumberOfDetectors(0) { + SetName("NebulaPlus"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TNebulaPlusSpectra::TNebulaPlusSpectra(unsigned int NumberOfDetectors) { + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TNebulaPlusSpectra : Initalizing control spectra for " + << NumberOfDetectors << " Detectors" << endl + << "************************************************" << endl ; + SetName("NebulaPlus"); + fNumberOfDetectors = NumberOfDetectors; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + + + +//////////////////////////////////////////////////////////////////////////////// +TNebulaPlusSpectra::~TNebulaPlusSpectra() { +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TNebulaPlusSpectra::InitRawSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "NebulaPlus"+NPL::itoa(i+1)+"_ENERGY_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "NebulaPlus/RAW"); + // Time + name = "NebulaPlus"+NPL::itoa(i+1)+"_TIME_RAW"; + AddHisto1D(name, name, 4096, 0, 16384, "NebulaPlus/RAW"); + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TNebulaPlusSpectra::InitPreTreatedSpectra() { + static string name; + for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors + // Energy + name = "NebulaPlus"+NPL::itoa(i+1)+"_ENERGY_CAL"; + AddHisto1D(name, name, 500, 0, 25, "NebulaPlus/CAL"); + // Time + name = "NebulaPlus"+NPL::itoa(i+1)+"_TIME_CAL"; + AddHisto1D(name, name, 500, 0, 25, "NebulaPlus/CAL"); + + + } // end loop on number of detectors +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TNebulaPlusSpectra::InitPhysicsSpectra() { + static string name; + // Kinematic Plot + name = "NebulaPlus_ENERGY_TIME"; + AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "NebulaPlus/PHY"); +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TNebulaPlusSpectra::FillRawSpectra(TNebulaPlusData* RawData) { +/* static string name; + static string family; + + // Energy + unsigned int sizeE = RawData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "NebulaPlus"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW"; + family = "NebulaPlus/RAW"; + + FillSpectra(family,name,RawData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = RawData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "NebulaPlus"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW"; + family = "NebulaPlus/RAW"; + + FillSpectra(family,name,RawData->Get_Time(i)); + }*/ +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TNebulaPlusSpectra::FillPreTreatedSpectra(TNebulaPlusData* PreTreatedData) { +/* static string name; + static string family; + + // Energy + unsigned int sizeE = PreTreatedData->GetMultEnergy(); + for (unsigned int i = 0; i < sizeE; i++) { + name = "NebulaPlus"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL"; + family = "NebulaPlus/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Energy(i)); + } + + // Time + unsigned int sizeT = PreTreatedData->GetMultTime(); + for (unsigned int i = 0; i < sizeT; i++) { + name = "NebulaPlus"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL"; + family = "NebulaPlus/CAL"; + + FillSpectra(family,name,PreTreatedData->Get_Time(i)); + }*/ +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TNebulaPlusSpectra::FillPhysicsSpectra(TNebulaPlusPhysics* Physics) { +/* static string name; + static string family; + family= "NebulaPlus/PHY"; + + // Energy vs time + unsigned int sizeE = Physics->Energy.size(); + for(unsigned int i = 0 ; i < sizeE ; i++){ + name = "NebulaPlus_ENERGY_TIME"; + FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]); + }*/ +} + diff --git a/NPLib/Detectors/NebulaPlus/TNebulaPlusSpectra.h b/NPLib/Detectors/NebulaPlus/TNebulaPlusSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..4d2e800927a7924610bb951c4bf467723e8971b9 --- /dev/null +++ b/NPLib/Detectors/NebulaPlus/TNebulaPlusSpectra.h @@ -0,0 +1,62 @@ +#ifndef TNebulaPlusSPECTRA_H +#define TNebulaPlusSPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2019 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 : December 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold NebulaPlus Spectra * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TNebulaPlusData.h" +#include "TNebulaPlusPhysics.h" + +// Forward Declaration +class TNebulaPlusPhysics; + + +class TNebulaPlusSpectra : public VSpectra { + ////////////////////////////////////////////////////////////// + // constructor and destructor + public: + TNebulaPlusSpectra(); + TNebulaPlusSpectra(unsigned int NumberOfDetectors); + ~TNebulaPlusSpectra(); + + ////////////////////////////////////////////////////////////// + // Initialization methods + private: + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + ////////////////////////////////////////////////////////////// + // Filling methods + public: + void FillRawSpectra(TNebulaPlusData*); + void FillPreTreatedSpectra(TNebulaPlusData*); + void FillPhysicsSpectra(TNebulaPlusPhysics*); + + ////////////////////////////////////////////////////////////// + // Detector parameters + private: + unsigned int fNumberOfDetectors; +}; + +#endif