diff --git a/NPLib/Detectors/BigRIPS/BigRIPSPlasticVariables.h b/NPLib/Detectors/BigRIPS/BigRIPSPlasticVariables.h new file mode 100644 index 0000000000000000000000000000000000000000..41341bb2bab8b7c7a5660542de4a725ec4b928d0 --- /dev/null +++ b/NPLib/Detectors/BigRIPS/BigRIPSPlasticVariables.h @@ -0,0 +1,89 @@ +#ifndef BIGRIPSPlasticVariables_H +#define BIGRIPSPlasticVariables_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: Freddy Flavigny contact: flavigny@lpccaen.in2p3.fr * + * * + * Creation Date : October 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class aims at holding Plastic data after pretreatment * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * Intermediate class necessary to hold all variables per detector per event* + * Different from TPlasticData whose variable (vectors) are independent * + * * + *****************************************************************************/ + +#include <iostream> +using namespace std; + +class BigRIPSPlasticVariables{ + public: + BigRIPSPlasticVariables(){Clear();}; + ~BigRIPSPlasticVariables(){}; + + public: + std::vector<double> FTL; + std::vector<double> FTR; + std::vector<double> FQL; + std::vector<double> FQR; + int FmultiHit[4]; + + void Clear(){ + FTL.clear(); + FTR.clear(); + FQL.clear(); + FQR.clear(); + for(int i=0; i<4; i++) FmultiHit[i]=0; + }; + + void Print(){ + //cout << "XXXXXXXXXXXXXXXXXXXXXXXX Plastic Event XXXXXXXXXXXXXXXXX" << endl; + cout << "FTL_Mult = " << FTL.size(); + for (UShort_t i = 0; i < FTL.size(); i++){cout << "\tFTL: " << FTL[i] << endl;} + cout << "FTR_Mult = " << FTR.size(); + for (UShort_t i = 0; i < FTR.size(); i++){cout << "\tFTR: " << FTR[i] << endl;} + cout << "FQL_Mult = " << FQL.size(); + for (UShort_t i = 0; i < FQL.size(); i++){cout << "\tFQL: " << FQL[i] << endl;} + cout << "FQR_Mult = " << FQR.size(); + for (UShort_t i = 0; i < FQR.size(); i++){cout << "\tFQR: " << FQR[i] << endl;} + cout << "MultHit = " <<endl; + for (UShort_t i = 0; i <4; i++){cout << FmultiHit[i] << endl;} + } + + bool HasTLandQL(){ + if(FTL.size()==1 && FQL.size()==1){return true;} + else{return false;} + } + bool HasTRandQR(){ + if(FTR.size()==1 && FQR.size()==1){return true;} + else{return false;} + } + bool HasTLandTR(){ + if(FTL.size()==1 && FTR.size()==1){return true;} + else{return false;} + } + bool HasQLandQR(){ + if(FQL.size()==1 && FQR.size()==1){return true;} + else{return false;} + } + bool HasEverything(){ + if(FTL.size()==1 && FTR.size()==1 && + FQL.size()==1 && FQR.size()==1){ + return true; + }else{return false;} + } + }; + +#endif diff --git a/NPLib/Detectors/BigRIPS/CMakeLists.txt b/NPLib/Detectors/BigRIPS/CMakeLists.txt index a40bdd27f056ba1f18ce09883fdbb0aa044c5175..0caea5c9864f1b742094c11687b6a51207ef368f 100644 --- a/NPLib/Detectors/BigRIPS/CMakeLists.txt +++ b/NPLib/Detectors/BigRIPS/CMakeLists.txt @@ -2,8 +2,12 @@ add_custom_command(OUTPUT TBigRIPSPPACDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/s add_custom_command(OUTPUT TBigRIPSPPACPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TBigRIPSPPACPhysics.h TBigRIPSPPACPhysicsDict.cxx TBigRIPSPPACPhysics.rootmap libNPBigRIPS.dylib DEPENDS TBigRIPSPPACPhysics.h) -add_library(NPBigRIPS SHARED TBigRIPSPPACData.cxx TBigRIPSPPACDataDict.cxx TBigRIPSPPACPhysics.cxx TBigRIPSPPACPhysicsDict.cxx) +add_custom_command(OUTPUT TBigRIPSPlasticDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TBigRIPSPlasticData.h TBigRIPSPlasticDataDict.cxx TBigRIPSPlasticData.rootmap libNPBigRIPS.dylib DEPENDS TBigRIPSPlasticData.h) + +add_custom_command(OUTPUT TBigRIPSPlasticPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TBigRIPSPlasticPhysics.h TBigRIPSPlasticPhysicsDict.cxx TBigRIPSPlasticPhysics.rootmap libNPBigRIPS.dylib DEPENDS TBigRIPSPlasticPhysics.h) + +add_library(NPBigRIPS SHARED TBigRIPSPPACData.cxx TBigRIPSPPACDataDict.cxx TBigRIPSPPACPhysics.cxx TBigRIPSPPACPhysicsDict.cxx TBigRIPSPlasticData.cxx TBigRIPSPlasticDataDict.cxx TBigRIPSPlasticPhysics.cxx TBigRIPSPlasticPhysicsDict.cxx ) target_link_libraries(NPBigRIPS ${ROOT_LIBRARIES} NPCore NPTrackReconstruction) -install(FILES TBigRIPSPPACData.h TBigRIPSPPACPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) +install(FILES TBigRIPSPPACData.h TBigRIPSPPACPhysics.h TBigRIPSPlasticData.h TBigRIPSPPACPhysics.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/BigRIPS/TBigRIPSPlasticData.cxx b/NPLib/Detectors/BigRIPS/TBigRIPSPlasticData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4d30def4d14de2aab58db478caecb3a0d8168599 --- /dev/null +++ b/NPLib/Detectors/BigRIPS/TBigRIPSPlasticData.cxx @@ -0,0 +1,29 @@ +#include "TBigRIPSPlasticData.h" +#include <iostream> + +TBigRIPSPlasticData::TBigRIPSPlasticData(){}; +TBigRIPSPlasticData::~TBigRIPSPlasticData(){}; + + +//////////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticData::Clear(){ + fPlastic_TL.clear(); + fPlastic_TR.clear(); + fPlastic_QL.clear(); + fPlastic_QR.clear(); + + fPlastic_TL_ID.clear(); + fPlastic_TR_ID.clear(); + fPlastic_QL_ID.clear(); + fPlastic_QR_ID.clear(); +} + +//////////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticData::Print(){ + using namespace std; + + cout << " -- Event:" << endl; + //cout << " - Multiplicity: " << Mult() << endl; + +} +ClassImp(TBigRIPSPlasticData); diff --git a/NPLib/Detectors/BigRIPS/TBigRIPSPlasticData.h b/NPLib/Detectors/BigRIPS/TBigRIPSPlasticData.h new file mode 100644 index 0000000000000000000000000000000000000000..d8f3555d1bd322a9460f54e1f4eb68718e83751c --- /dev/null +++ b/NPLib/Detectors/BigRIPS/TBigRIPSPlasticData.h @@ -0,0 +1,53 @@ +#ifndef TBigRIPSPlasticData_H +#define TBigRIPSPlasticData_H +#include "TObject.h" +#include <vector> +class TBigRIPSPlasticData: public TObject{ + public: + TBigRIPSPlasticData(); + ~TBigRIPSPlasticData(); + + private: + std::vector<int> fPlastic_TL; + std::vector<int> fPlastic_TR; + std::vector<int> fPlastic_QL; + std::vector<int> fPlastic_QR; + + std::vector<int> fPlastic_TL_ID; + std::vector<int> fPlastic_TR_ID; + std::vector<int> fPlastic_QL_ID; + std::vector<int> fPlastic_QR_ID; + + public: + void Clear(); + void Print(); + void Clear(const Option_t*) {}; + void Dump() const{}; + + public: + void SetTL(const int& T, const int& ID){fPlastic_TL.push_back(T);fPlastic_TL_ID.push_back(ID);} + void SetTR(const int& T, const int& ID){fPlastic_TR.push_back(T);fPlastic_TR_ID.push_back(ID);} + + void SetQL(const int& Q, const int& ID){fPlastic_QL.push_back(Q);fPlastic_QL_ID.push_back(ID);} + void SetQR(const int& Q, const int& ID){fPlastic_QR.push_back(Q);fPlastic_QR_ID.push_back(ID);} + + int GetTLMult() const {return fPlastic_TL_ID.size();} + int const GetTL(const unsigned int& i){return fPlastic_TL[i];}; + int const GetTLID(const unsigned int& i){return fPlastic_TL_ID[i];}; + + int GetTRMult() const {return fPlastic_TR_ID.size();} + int const GetTR(const unsigned int& i){return fPlastic_TR[i];}; + int const GetTRID(const unsigned int& i){return fPlastic_TR_ID[i];}; + + int GetQLMult() const {return fPlastic_QL_ID.size();} + int const GetQL(const unsigned int& i){return fPlastic_QL[i];}; + int const GetQLID(const unsigned int& i){return fPlastic_QL_ID[i];}; + + int GetQRMult() const {return fPlastic_QR_ID.size();} + int const GetQR(const unsigned int& i){return fPlastic_QR[i];}; + int const GetQRID(const unsigned int& i){return fPlastic_QR_ID[i];}; + + ClassDef(TBigRIPSPlasticData,1); +}; + +#endif diff --git a/NPLib/Detectors/BigRIPS/TBigRIPSPlasticPhysics.cxx b/NPLib/Detectors/BigRIPS/TBigRIPSPlasticPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8de76772a8c1aef583fd259d57c48fa9be6be65a --- /dev/null +++ b/NPLib/Detectors/BigRIPS/TBigRIPSPlasticPhysics.cxx @@ -0,0 +1,382 @@ +/***************************************************************************** + * 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: F, Flavigny contact address: flavigny@lpccaen.in2p3.fr * + * * + * Creation Date : April 2021 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold RIBF Plastic treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +#include "TBigRIPSPlasticPhysics.h" + +// STL +#include <sstream> +#include <iostream> +#include <cmath> +#include <stdlib.h> +#include <limits> + +// NPL +#include "RootInput.h" +#include "RootOutput.h" +#include "TAsciiFile.h" +#include "NPOptionManager.h" +#include "NPDetectorFactory.h" +#include "NPSystemOfUnits.h" +// ROOT +using namespace NPUNITS; +/////////////////////////////////////////////////////////////////////////// + +ClassImp(TBigRIPSPlasticPhysics) + /////////////////////////////////////////////////////////////////////////// + TBigRIPSPlasticPhysics::TBigRIPSPlasticPhysics(){ + m_EventData = new TBigRIPSPlasticData ; + m_PreTreatedData = new TBigRIPSPlasticData ; + m_EventPhysics = this ; + //m_Spectra = NULL; + } + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::BuildSimplePhysicalEvent(){ + BuildPhysicalEvent(); +} + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::BuildPhysicalEvent(){ + PreTreat(); + return; +} +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::PreTreat(){ + + ClearPreTreatedData(); + + //Intermediate map associating a Plastic ID with its variables stored in an object + // Condition for filling: Raw TDC value within [LowerLimit,UpperLimit] + // Only first TDC hit for each variable is stored + static map<int, BigRIPSPlasticVariables > Fdata ; + static map<int, BigRIPSPlasticVariables >::iterator found; + Fdata.clear() ; + + //pair of detector ID and variable type (TL,TR,QR,QL)=(0,1,2,3) + std::pair<unsigned int, double> pair_id_type; + int id, TimeRaw, QRaw; + + + //TL + unsigned int sizeTL = m_EventData->GetTLMult(); + for(unsigned int i = 0 ; i < sizeTL ; i++){ + id = m_EventData->GetTLID(i); + TimeRaw = m_EventData->GetTL(i); + if(TimeRaw>RawLowerLimit[id] && TimeRaw<RawUpperLimit[id]){ + if(Fdata[id].FTL.size()==0){ + Fdata[id].FTL.push_back(TimeRaw); + + }else { + Fdata[id].FmultiHit[0]=1; //multiple value for same TDC ch. + } + } + } + + //TR + unsigned int sizeTR = m_EventData->GetTRMult(); + for(unsigned int i = 0 ; i < sizeTR ; i++){ + id = m_EventData->GetTRID(i); + TimeRaw = m_EventData->GetTR(i); + if(TimeRaw>RawLowerLimit[id] && TimeRaw<RawUpperLimit[id]){ + if(Fdata[id].FTR.size()==0){ + Fdata[id].FTR.push_back(TimeRaw); + }else { + Fdata[id].FmultiHit[1]=1; //multiple value for same TDC ch. + } + } + } + + //QL + unsigned int sizeQL = m_EventData->GetQLMult(); + for(unsigned int i = 0 ; i < sizeQL ; i++){ + id = m_EventData->GetQLID(i); + QRaw = m_EventData->GetQL(i); + if(Fdata[id].FQL.size()==0){ + Fdata[id].FQL.push_back(QRaw); + }else { + Fdata[id].FmultiHit[2]=1; //multiple value for same Q ch. + } + } + + //QR + unsigned int sizeQR = m_EventData->GetQRMult(); + for(unsigned int i = 0 ; i < sizeQR ; i++){ + id = m_EventData->GetQRID(i); + QRaw = m_EventData->GetQR(i); + if(Fdata[id].FQR.size()==0){ + Fdata[id].FQR.push_back(QRaw); + }else { + Fdata[id].FmultiHit[3]=1; //multiple value for same Q ch. + } + } + + int Nmulti; + BigRIPSPlasticVariables tmp; + + for(auto it = Fdata.begin();it!=Fdata.end();++it){ + id = it->first; + ID.push_back(id); + FP.push_back(IDtoFP[id]); + tmp.Clear(); + tmp = it->second; + //tmp.Print(); + //TL=tmp.FTL * tcal_left[id]; + //TR=tmp.FTR * tcal_right[id]; + //QL=tmp.FQL; + //QR=tmp.FQR; + + //Calculate how many TDC variables got a multi hit + Nmulti=0; + for (int i=0; i<4; i++) if(tmp.FmultiHit[i]==1) Nmulti++; + multiHit.push_back(Nmulti); + + //Calculate TL, TLSlew + double TL_cal, TLSlew_cal; + if(tmp.FTL.size()==1){ + TL_cal = tmp.FTL[0] * tcal_left[id]; + TL.push_back(TL_cal); + if(tmp.HasTLandQL()){ + TLSlew_cal = tcal_left[id]* + (tmp.FTL[0] + + tslew_left_a[id]/sqrt(tmp.FQL[0]) + + tslew_left_b[id]); + TLSlew.push_back(TLSlew_cal); + }else{ + TLSlew.push_back(TL_cal); + } + }else{ + TL.push_back(-99999); + TLSlew.push_back(-99999); + } + + //Calculate TR, TRSlew + double TR_cal, TRSlew_cal; + if(tmp.FTR.size()==1){ + TR_cal = tmp.FTR[0] * tcal_right[id]; + TR.push_back(TR_cal); + if(tmp.HasTRandQR()){ + TRSlew_cal = tcal_right[id]* + (tmp.FTR[0] + + tslew_right_a[id]/sqrt(tmp.FQR[0]) + + tslew_right_b[id]); + TRSlew.push_back(TRSlew_cal); + }else{ + TRSlew.push_back(TR_cal); + } + }else{ + TR.push_back(-99999); + TRSlew.push_back(-99999); + } + + //Calculate T, TSlew + if(tmp.FTL.size()==1 && tmp.FTR.size()==1){ + T.push_back((TR_cal+TL_cal)/2.); + if(tmp.FQL.size()==1 && tmp.FQR.size()==1){ + TSlew.push_back((TRSlew_cal+TLSlew_cal)/2.); + } + } + + //Simply fill QL and QR + if(tmp.FQL.size()==1){ + QL.push_back(tmp.FQL[0]); + }else{ + QL.push_back(-99999); + } + if(tmp.FQR.size()==1){ + QR.push_back(tmp.FQR[0]); + }else{ + QR.push_back(-99999); + } + + if(tmp.HasEverything()==1){ + fired.push_back(true); + }else{ + fired.push_back(false); + } + + }//end of loop on FData (loop on all plastics) + + //Print(); + Fdata.clear(); + + return; +} +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::Clear(){ + ID.clear(); + FP.clear(); + T.clear(); + TL.clear(); + TR.clear(); + TSlew.clear(); + TLSlew.clear(); + TRSlew.clear(); + QL.clear(); + QR.clear(); + multiHit.clear(); + fired.clear(); +} +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::Print(){ + cout << "XXXXXXXXXXXXXXXXXXXXXXXX Plastic Physics Event XXXXXXXXXXXXXXXXX" << endl; + cout << "TL_Mult = " << TL.size(); + for (UShort_t i = 0; i < TL.size(); i++){cout << "\tTL: " << TL[i] << endl;} + cout << "TR_Mult = " << TR.size(); + for (UShort_t i = 0; i < TR.size(); i++){cout << "\tTR: " << TR[i] << endl;} + cout << "QL_Mult = " << QL.size(); + for (UShort_t i = 0; i < QL.size(); i++){cout << "\tQL: " << QL[i] << endl;} + cout << "QR_Mult = " << QR.size(); + for (UShort_t i = 0; i < QR.size(); i++){cout << "\tQR: " << QR[i] << endl;} +} +/////////////////////////////////////////////////////////////////////////// + +//// Innherited from VDetector Class //// + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::ReadConfiguration(NPL::InputParser parser){ + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("BigRIPSPlastic"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Plastic detector file found " << endl; + + vector<string> token= {"XML"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + cout << endl << "//// BigRIPSPlastic file (" << i+1 << ")" << endl; + string xmlpath = blocks[i]->GetString("XML"); + NPL::XmlParser xml; + xml.LoadFile(xmlpath); + AddPlastics("BigRIPSPlastic",xml); + } +} + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::AddPlastics(string name, NPL::XmlParser& xml){ + std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName(name); + + if(name=="BigRIPSPlastic"){ + unsigned int size = b.size(); + for(unsigned int i = 0 ; i < size ; i++){ + unsigned int ID = b[i]->AsInt("ID"); + //string sDir = b[i]->AsString("anodedir"); + RawLowerLimit[ID] = b[i]->AsInt("tdc_underflow"); + RawUpperLimit[ID] = b[i]->AsInt("tdc_overflow"); + IDtoFP[ID] = b[i]->AsInt("FPL"); + tcal_left[ID] = b[i]->AsDouble("tcal_left"); + tcal_right[ID] = b[i]->AsDouble("tcal_right"); + tslew_left_a[ID] = b[i]->AsDouble("tslew_left_a"); + tslew_left_b[ID] = b[i]->AsDouble("tslew_left_b"); + tslew_right_a[ID] = b[i]->AsDouble("tslew_right_a"); + tslew_right_b[ID] = b[i]->AsDouble("tslew_right_b"); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::InitSpectra(){ + //m_Spectra = new TBigRIPSPlasticSpectra(m_NumberOfDetector); +} + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::FillSpectra(){ + // m_Spectra -> FillRawSpectra(m_EventData); + // m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + // m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::CheckSpectra(){ + // m_Spectra->CheckSpectra(); +} +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::ClearSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TBigRIPSPlasticPhysics::GetSpectra() { + /* if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + }*/ + map< string , TH1*> empty; + return empty; + +} + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::WriteSpectra(){ + // m_Spectra->WriteSpectra(); +} +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::AddParameterToCalibrationManager(){ + //CalibrationManager* Cal = CalibrationManager::getInstance(); + + // each layer + //for( int l = 0 ; l < 14 ; ++l){ + // Cal->AddParameter("SamuraiFDC2", "L"+ NPL::itoa(l),"FDC2_L"+ NPL::itoa(l)); + //} + +} + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::InitializeRootInputRaw(){ + TChain* inputChain = RootInput::getInstance()->GetChain() ; + inputChain->SetBranchStatus( "BigRIPSPlastic" , true ); + // The following line is necessary only for system were the tree is splitted + // (older root version). The found argument silenced the Branches not found + // warning for non splitted tree. + if(inputChain->FindBranch("fPlastic_*")) + inputChain->SetBranchStatus( "fPlastic_*",true); + inputChain->SetBranchAddress( "BigRIPSPlastic" , &m_EventData ); + +} + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::InitializeRootInputPhysics(){ +} + +/////////////////////////////////////////////////////////////////////////// +void TBigRIPSPlasticPhysics::InitializeRootOutput(){ + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch( "Plastic" , "TBigRIPSPlasticPhysics" , &m_EventPhysics ); +} + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TBigRIPSPlasticPhysics::Construct(){ + return (NPL::VDetector*) new TBigRIPSPlasticPhysics(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ + class proxy_bigripsPlastic{ + public: + proxy_bigripsPlastic(){ + NPL::DetectorFactory::getInstance()->AddToken("BigRIPSPlastic","BigRIPS"); + NPL::DetectorFactory::getInstance()->AddDetector("BigRIPSPlastic",TBigRIPSPlasticPhysics::Construct); + } + }; + + proxy_bigripsPlastic p_bigripsPlastic; +} + diff --git a/NPLib/Detectors/BigRIPS/TBigRIPSPlasticPhysics.h b/NPLib/Detectors/BigRIPS/TBigRIPSPlasticPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..305fe6989a0ae7d1de18a0f9eb63152b047b6856 --- /dev/null +++ b/NPLib/Detectors/BigRIPS/TBigRIPSPlasticPhysics.h @@ -0,0 +1,162 @@ +#ifndef TBIGRIPSPLASTICPHYSICS_H +#define TBIGRIPSPLASTICPHYSICS_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: F. Flavigny contact address: flavigny@lpccaen.in2p3.fr * + * * + * Creation Date : April 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold RIBF Plastic treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + * * + *****************************************************************************/ +// STL +#include <vector> +#include <map> + +// NPL +#include "TBigRIPSPlasticData.h" +#include "BigRIPSPlasticVariables.h" +//#include "TBigRIPSPlasticSpectra.h" +#include "NPCalibrationManager.h" +#include "NPVDetector.h" +#include "NPInputParser.h" +#include "NPXmlParser.h" +#include "NPDCReconstruction.h" +// ROOT +#include "TVector3.h" +// Forward declaration +//class TBigRIPSPlasticSpectra; + + +using namespace std ; + +class TBigRIPSPlasticPhysics : public TObject, public NPL::VDetector{ + public: + TBigRIPSPlasticPhysics(); + ~TBigRIPSPlasticPhysics() {}; + + public: + void Clear(); + void Clear(const Option_t*) {}; + void Print(); + + public: + std::vector<int> ID; + std::vector<int> FP; + std::vector<double> T; + std::vector<double> TL; + std::vector<double> TR; + std::vector<double> TSlew; + std::vector<double> TLSlew; + std::vector<double> TRSlew; + std::vector<double> QL; + std::vector<double> QR; + std::vector<int> multiHit; + std::vector<bool> fired; + + public: + + // Projected position at given Z plan + TVector3 ProjectedPosition(double Z); + + private: // Xml file read to add Plastics and their parameters + void AddPlastics(string name, NPL::XmlParser&);//! take the XML file and fill in parameters of each Plastic + map<int,double> RawUpperLimit;//! Upper Value of TDC range considered for a Plastic + map<int,double> RawLowerLimit;//! Lower Value of TDC range considered for a Plastic + map<int,int> IDtoFP;//! Focal plane where the Plastic is located + map<int,double> tcal_left; + map<int,double> tcal_right; + map<int,double> tslew_left_a; + map<int,double> tslew_left_b; + map<int,double> tslew_right_a; + map<int,double> tslew_right_b; + + public: // Innherited from VDetector Class + + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + void ReadConfiguration(NPL::InputParser) ; + + // Add Parameter to the CalibrationManger + void AddParameterToCalibrationManager() ; + + // Activated associated Branches and link it to the private member DetectorData address + // In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated + void InitializeRootInputRaw() ; + + // Activated associated Branches and link it to the private member DetectorPhysics address + // In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated + void InitializeRootInputPhysics() ; + + // Create associated branches and associated private member DetectorPhysics address + void InitializeRootOutput() ; + + // This method is called at each event read from the Input Tree. Aime is to build treat Raw dat in order to extract physical parameter. + void BuildPhysicalEvent() ; + + // Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but less efficient ...). + // This method aimed to be used for analysis performed during experiment, when speed is requiered. + // NB: This method can eventually be the same as BuildPhysicalEvent. + void BuildSimplePhysicalEvent() ; + + // Same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();}; + + // Those two method all to clear the Event Physics or Data + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // Method related to the TSpectra classes, aimed at providing a framework for online applications + // Instantiate the Spectra class and the histogramm throught it + void InitSpectra(); + // Fill the spectra hold by the spectra class + void FillSpectra(); + // Used for Online mainly, perform check on the histo and for example change their color if issues are found + void CheckSpectra(); + // Used for Online only, clear all the spectra hold by the Spectra class + void ClearSpectra(); + // Write Spectra to file + void WriteSpectra(); + + public: + + // Clear The PreTeated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // Remove bad channel, calibrate the data and apply threshold + void PreTreat(); + + // Retrieve raw and pre-treated data + TBigRIPSPlasticData* GetRawData() const {return m_EventData;} + TBigRIPSPlasticData* GetPreTreatedData() const {return m_PreTreatedData;} + + private: // Root Input and Output tree classes + TBigRIPSPlasticData* m_EventData;//! + TBigRIPSPlasticData* m_PreTreatedData;//! + TBigRIPSPlasticPhysics* m_EventPhysics;//! + + + private: // Spectra Class + // TBigRIPSPlasticSpectra* m_Spectra; // ! + + public: // Spectra Getter + map< string , TH1*> GetSpectra(); + + public: // Static constructor to be passed to the Detector Factory + static NPL::VDetector* Construct(); + ClassDef(TBigRIPSPlasticPhysics,1) // BigRIPSPlasticPhysics structure +}; + +#endif