diff --git a/NPLib/Misc/Makefile b/NPLib/Misc/Makefile index 8274b74d56579633336754d6b0d4c735509fe595..70e09a2748849279337bb58abdd7cdae958b1a67 100644 --- a/NPLib/Misc/Makefile +++ b/NPLib/Misc/Makefile @@ -1,19 +1,24 @@ include ../Makefile.arch #------------------------------------------------------------------------------ -SHARELIB = libTacData.so libTriggerData.so +SHARELIB = libTacData.so libTacPhysics.so libTriggerData.so all: $(SHARELIB) #------------------------------------------------------------------------------ -############### Detector ############## -## MUST2 ## +############### Detector ############## libTacData.so: TTacData.o TTacDataDict.o $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ TTacDataDict.cxx: TTacData.h rootcint -f $@ -c $^ +libTacPhysics.so: TTacPhysics.o TTacPhysicsDict.o + $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ + +TTacPhysicsDict.cxx: TTacPhysics.h + rootcint -f $@ -c $^ + libTriggerData.so: TTriggerData.o TTriggerDataDict.o $(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ @@ -21,7 +26,8 @@ TTriggerDataDict.cxx: TTriggerData.h rootcint -f $@ -c $^ # dependances -TTacData.o: TTacData.cxx TTacData.h +TTacData.o: TTacData.cxx TTacData.h +TTacPhysics.o: TTacPhysics.cxx TTacPhysics.h TTriggerData.o: TTriggerData.cxx TTriggerData.h ####################################### diff --git a/NPLib/Misc/TTacData.cxx b/NPLib/Misc/TTacData.cxx index cedde7e862c546851b76ba2237d5fb62d287a32d..412662b6fc6c4445b9cb700f4ebb4397cb95f75e 100644 --- a/NPLib/Misc/TTacData.cxx +++ b/NPLib/Misc/TTacData.cxx @@ -26,7 +26,16 @@ void TTacData::Clear() fTAC_PL_GAL = -1; fTAC_CATS1_HF = -1; fTAC_CATS2_HF = -1; - fTAC_MM_HF = -1; + fTAC_MM_HF = -1; + fTAC_MM1_HF = -1; + fTAC_MM2_HF = -1; + fTAC_MM3_HF = -1; + fTAC_MM4_HF = -1; + fTAC_MM5_HF = -1; + fTAC_MM6_HF = -1; + fTAC_MM7_HF = -1; + fTAC_MM8_HF = -1; + fTAC_MM_HF_DetectorNbr.clear(); } void TTacData::Dump() const @@ -41,5 +50,17 @@ void TTacData::Dump() const cout << "fTAC_PL_GAL : " << fTAC_PL_GAL << endl; cout << "fTAC_CATS1_HF : " << fTAC_CATS1_HF << endl; cout << "fTAC_CATS2_HF : " << fTAC_CATS2_HF << endl; - cout << "fTAC_MM_HF : " << fTAC_MM_HF << endl; + cout << "fTAC_MM_HF : " << fTAC_MM_HF << endl; + cout << "fTAC_MM1_HF : " << fTAC_MM1_HF << endl; + cout << "fTAC_MM2_HF : " << fTAC_MM2_HF << endl; + cout << "fTAC_MM3_HF : " << fTAC_MM3_HF << endl; + cout << "fTAC_MM4_HF : " << fTAC_MM4_HF << endl; + cout << "fTAC_MM5_HF : " << fTAC_MM5_HF << endl; + cout << "fTAC_MM6_HF : " << fTAC_MM6_HF << endl; + cout << "fTAC_MM7_HF : " << fTAC_MM7_HF << endl; + cout << "fTAC_MM8_HF : " << fTAC_MM8_HF << endl; + + cout << "TAC_MM_HF_DetectorNbr = " << fTAC_MM_HF_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fTAC_MM_HF_DetectorNbr.size(); i++) + cout << "DetNbr: " << fTAC_MM_HF_DetectorNbr[i] << endl; } diff --git a/NPLib/Misc/TTacData.h b/NPLib/Misc/TTacData.h index f4737b71ae3dd573e0d49e645b84b4ded6f419ee..f2d849f6865a2f2129286b7ada27f3b4bc347366 100644 --- a/NPLib/Misc/TTacData.h +++ b/NPLib/Misc/TTacData.h @@ -19,26 +19,44 @@ class TTacData : public TObject { UShort_t fTAC_CATS1_HF; UShort_t fTAC_CATS2_HF; UShort_t fTAC_MM_HF; + UShort_t fTAC_MM1_HF; + UShort_t fTAC_MM2_HF; + UShort_t fTAC_MM3_HF; + UShort_t fTAC_MM4_HF; + UShort_t fTAC_MM5_HF; + UShort_t fTAC_MM6_HF; + UShort_t fTAC_MM7_HF; + UShort_t fTAC_MM8_HF; + vector<UShort_t> fTAC_MM_HF_DetectorNbr; public: TTacData(); virtual ~TTacData(); - void Clear(); + void Clear(); void Clear(const Option_t*) {}; void Dump() const; ///////////////////// GETTERS //////////////////////// // (TAC) - UShort_t GetTAC_MM_CATS1() {return fTAC_MM_CATS1;} - UShort_t GetTAC_MM_CATS2() {return fTAC_MM_CATS2;} - UShort_t GetTAC_PL_CATS1() {return fTAC_PL_CATS1;} - UShort_t GetTAC_PL_CATS2() {return fTAC_PL_CATS2;} - UShort_t GetTAC_CATS12() {return fTAC_CATS12;} - UShort_t GetTAC_PL_GAL() {return fTAC_PL_GAL;} - UShort_t GetTAC_CATS1_HF() {return fTAC_CATS1_HF;} - UShort_t GetTAC_CATS2_HF() {return fTAC_CATS2_HF;} - UShort_t GetTAC_MM_HF() {return fTAC_MM_HF;} + UShort_t GetTAC_MM_CATS1() {return fTAC_MM_CATS1;} + UShort_t GetTAC_MM_CATS2() {return fTAC_MM_CATS2;} + UShort_t GetTAC_PL_CATS1() {return fTAC_PL_CATS1;} + UShort_t GetTAC_PL_CATS2() {return fTAC_PL_CATS2;} + UShort_t GetTAC_CATS12() {return fTAC_CATS12;} + UShort_t GetTAC_PL_GAL() {return fTAC_PL_GAL;} + UShort_t GetTAC_CATS1_HF() {return fTAC_CATS1_HF;} + UShort_t GetTAC_CATS2_HF() {return fTAC_CATS2_HF;} + UShort_t GetTAC_MM_HF() {return fTAC_MM_HF;} + Double_t GetTAC_MM1_HF() {return fTAC_MM1_HF;} + Double_t GetTAC_MM2_HF() {return fTAC_MM2_HF;} + Double_t GetTAC_MM3_HF() {return fTAC_MM3_HF;} + Double_t GetTAC_MM4_HF() {return fTAC_MM4_HF;} + Double_t GetTAC_MM5_HF() {return fTAC_MM5_HF;} + Double_t GetTAC_MM6_HF() {return fTAC_MM6_HF;} + Double_t GetTAC_MM7_HF() {return fTAC_MM7_HF;} + Double_t GetTAC_MM8_HF() {return fTAC_MM8_HF;} + Double_t GetTAC_MM_HF_DetectorNbr(const Int_t i) const {return fTAC_MM_HF_DetectorNbr[i];} ///////////////////// SETTERS //////////////////////// // (TAC) @@ -46,13 +64,23 @@ class TTacData : public TObject { void SetTAC_MM_CATS2(UShort_t T) {fTAC_MM_CATS2 = T;} void SetTAC_PL_CATS1(UShort_t T) {fTAC_PL_CATS1 = T;} void SetTAC_PL_CATS2(UShort_t T) {fTAC_PL_CATS2 = T;} - void SetTAC_CATS12(UShort_t T) {fTAC_CATS12 = T;} - void SetTAC_PL_GAL(UShort_t T) {fTAC_PL_GAL = T;} + void SetTAC_CATS12(UShort_t T) {fTAC_CATS12 = T;} + void SetTAC_PL_GAL(UShort_t T) {fTAC_PL_GAL = T;} void SetTAC_CATS1_HF(UShort_t T) {fTAC_CATS1_HF = T;} void SetTAC_CATS2_HF(UShort_t T) {fTAC_CATS2_HF = T;} - void SetTAC_MM_HF(UShort_t T) {fTAC_MM_HF = T;} + void SetTAC_MM_HF(UShort_t T) {fTAC_MM_HF = T;} + void SetTAC_MM1_HF(UShort_t T) {fTAC_MM1_HF = T;} + void SetTAC_MM2_HF(UShort_t T) {fTAC_MM2_HF = T;} + void SetTAC_MM3_HF(UShort_t T) {fTAC_MM3_HF = T;} + void SetTAC_MM4_HF(UShort_t T) {fTAC_MM4_HF = T;} + void SetTAC_MM5_HF(UShort_t T) {fTAC_MM5_HF = T;} + void SetTAC_MM6_HF(UShort_t T) {fTAC_MM6_HF = T;} + void SetTAC_MM7_HF(UShort_t T) {fTAC_MM7_HF = T;} + void SetTAC_MM8_HF(UShort_t T) {fTAC_MM8_HF = T;} + void SetTAC_MM_HF_DetectorNbr(const UShort_t DetNbr) {fTAC_MM_HF_DetectorNbr.push_back(DetNbr);} - ClassDef(TTacData,1) // TacData structure + + ClassDef(TTacData,2) // TacData structure }; #endif diff --git a/NPLib/Misc/TTacPhysics.cxx b/NPLib/Misc/TTacPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..46f3d286e1bd9428aab90260e20160c955dfdd2b --- /dev/null +++ b/NPLib/Misc/TTacPhysics.cxx @@ -0,0 +1,142 @@ +/***************************************************************************** + * Copyright (C) 2009-2010 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: L. Lefebvre contact address: lefebvrl@ipno.in2p3.fr * + * * + * Creation Date : October 2011 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold the Tac Physics * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// NPL +#include "TTacPhysics.h" +#include "../include/RootOutput.h" +#include "../include/RootInput.h" + +// STL +#include <iostream> +#include <sstream> +#include <fstream> +#include <limits> +#include <stdlib.h> +using namespace std; + +// ROOT +#include "TChain.h" + +// tranform an integer to a string +string itoa(int value) +{ + char buffer [33]; + sprintf(buffer,"%d",value); + return buffer; +} + +ClassImp(TTacPhysics) +/////////////////////////////////////////////////////////////////////////// +TTacPhysics::TTacPhysics() + { + EventData = new TTacData ; + EventPhysics = this ; + } + +/////////////////////////////////////////////////////////////////////////// +TTacPhysics::~TTacPhysics() + {} + +/////////////////////////////////////////////////////////////////////////// +void TTacPhysics::Clear() + { + TacNumber.clear() ; + Time_TAC_1 =0; + Time_TAC_2 =0; + Time_TAC_3 =0; + Time_TAC_4 =0; + Time_TAC_5 =0; + Time_TAC_6 =0; + Time_TAC_7 =0; + Time_TAC_8 =0; + } + +/////////////////////////////////////////////////////////////////////////// +void TTacPhysics::ReadConfiguration(string Path) + { + } + +/////////////////////////////////////////////////////////////////////////// +void TTacPhysics::AddParameterToCalibrationManager() + { + CalibrationManager* Cal = CalibrationManager::getInstance(); + + for(int i = 0 ; i < 8 ; i++) + { + Cal->AddParameter("TAC", "_T"+itoa(i+1),"TAC_T"+itoa(i+1)) ; + } + } + +/////////////////////////////////////////////////////////////////////////// +void TTacPhysics::InitializeRootInputRaw() + { + TChain* inputChain = RootInput::getInstance()->GetChain() ; + inputChain->SetBranchStatus ( "TAC" , true ) ; + inputChain->SetBranchStatus ( "fTAC_MM*" , true ) ; + inputChain->SetBranchAddress( "TAC" , &EventData ) ; + } +/////////////////////////////////////////////////////////////////////////// +void TTacPhysics::InitializeRootInputPhysics() + { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus ( "Tac", true ); + inputChain->SetBranchStatus ( "TacNumber", true ); + inputChain->SetBranchStatus ( "Time_TAC_1", true ); + inputChain->SetBranchStatus ( "Time_TAC_2", true ); + inputChain->SetBranchStatus ( "Time_TAC_3", true ); + inputChain->SetBranchStatus ( "Time_TAC_4", true ); + inputChain->SetBranchStatus ( "Time_TAC_5", true ); + inputChain->SetBranchStatus ( "Time_TAC_6", true ); + inputChain->SetBranchStatus ( "Time_TAC_7", true ); + inputChain->SetBranchStatus ( "Time_TAC_8", true ); + inputChain->SetBranchAddress( "Tac", &EventPhysics ); + } +/////////////////////////////////////////////////////////////////////////// +void TTacPhysics::InitializeRootOutput() + { + TTree* outputTree = RootOutput::getInstance()->GetTree() ; + outputTree->Branch( "Tac" , "TTacPhysics" , &EventPhysics ) ; + } + +/////////////////////////////////////////////////////////////////////////// +void TTacPhysics::BuildPhysicalEvent() + { + BuildSimplePhysicalEvent() ; + } + +/////////////////////////////////////////////////////////////////////////// +void TTacPhysics::BuildSimplePhysicalEvent() + { + for(int i=0;i<8;i++) + { + TacNumber.push_back(EventData->GetTAC_MM_HF_DetectorNbr(i)); + } + Time_TAC_1=CalibrationManager::getInstance()->ApplyCalibration("TAC/_T" + itoa( EventData->GetTAC_MM_HF_DetectorNbr(0) ),EventData->GetTAC_MM1_HF() ); + Time_TAC_2=CalibrationManager::getInstance()->ApplyCalibration("TAC/_T" + itoa( EventData->GetTAC_MM_HF_DetectorNbr(1) ),EventData->GetTAC_MM2_HF() ); + Time_TAC_3=CalibrationManager::getInstance()->ApplyCalibration("TAC/_T" + itoa( EventData->GetTAC_MM_HF_DetectorNbr(2) ),EventData->GetTAC_MM3_HF() ); + Time_TAC_4=CalibrationManager::getInstance()->ApplyCalibration("TAC/_T" + itoa( EventData->GetTAC_MM_HF_DetectorNbr(3) ),EventData->GetTAC_MM4_HF() ); + Time_TAC_5=CalibrationManager::getInstance()->ApplyCalibration("TAC/_T" + itoa( EventData->GetTAC_MM_HF_DetectorNbr(4) ),EventData->GetTAC_MM5_HF() ); + Time_TAC_6=CalibrationManager::getInstance()->ApplyCalibration("TAC/_T" + itoa( EventData->GetTAC_MM_HF_DetectorNbr(5) ),EventData->GetTAC_MM6_HF() ); + Time_TAC_7=CalibrationManager::getInstance()->ApplyCalibration("TAC/_T" + itoa( EventData->GetTAC_MM_HF_DetectorNbr(6) ),EventData->GetTAC_MM7_HF() ); + Time_TAC_8=CalibrationManager::getInstance()->ApplyCalibration("TAC/_T" + itoa( EventData->GetTAC_MM_HF_DetectorNbr(7) ),EventData->GetTAC_MM8_HF() ); + } + diff --git a/NPLib/Misc/TTacPhysics.h b/NPLib/Misc/TTacPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..2f10a6f8327e606139eda446f6b7fd32b598e788 --- /dev/null +++ b/NPLib/Misc/TTacPhysics.h @@ -0,0 +1,102 @@ +#ifndef __TacPhysics__ +#define __TacPhysics__ +/***************************************************************************** + * Copyright (C) 2009-2010 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: L. Lefebvre contact address: lefebvrl@ipno.in2p3.fr * + * * + * Creation Date : October 2011 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold the Tac Physics * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std ; + +// ROOT +#include "TObject.h" + +// NPL +#include "TTacData.h" +#include "../include/VDetector.h" +#include "../include/CalibrationManager.h" + +class TTacPhysics : public TObject, public NPA::VDetector +{ + public: // Constructor and Destructor + TTacPhysics(); + ~TTacPhysics(); + + public: + void Clear(); + void Clear(const Option_t*) {}; + + public: // Calibrated Data + Double_t Time_TAC_1 ; + Double_t Time_TAC_2 ; + Double_t Time_TAC_3 ; + Double_t Time_TAC_4 ; + Double_t Time_TAC_5 ; + Double_t Time_TAC_6 ; + Double_t Time_TAC_7 ; + Double_t Time_TAC_8 ; + vector<UShort_t> TacNumber; + + public: // inherrited from VDetector + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + void ReadConfiguration(string); + + + // 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();}; + + // Give and external TTacData object to TTacPhysics. Needed for online analysis for example. + void SetRawDataPointer(TTacData* rawDataPointer) {EventData = rawDataPointer;} + + // Those two method all to clear the Event Physics or Data + void ClearEventPhysics() {Clear();} + void ClearEventData() {EventData->Clear();} + + private: // Data not writted in the tree + TTacData* EventData ;//! + TTacPhysics* EventPhysics ;//! + + ClassDef(TTacPhysics,1) // TacPhysics structure +}; + +#endif diff --git a/NPLib/Speg/TSpegPhysics.cxx b/NPLib/Speg/TSpegPhysics.cxx index dba1e83bca82bc8896044723d0b92e409232e921..5d9f0fae31117d664e6e320e0389f08c004c2b9e 100644 --- a/NPLib/Speg/TSpegPhysics.cxx +++ b/NPLib/Speg/TSpegPhysics.cxx @@ -118,7 +118,7 @@ void TSpegPhysics::ReadConfiguration(string Path) string LineBuffer ; string DataBuffer ; - bool check_nmesx = false ; +// bool check_nmesx = false ; bool check_nomx = false ; bool check_zxx = false ; bool check_ievx = false ; @@ -143,7 +143,7 @@ void TSpegPhysics::ReadConfiguration(string Path) bool check_zfx = false ; bool ReadingStatus1 = false ; - bool check_nmesy = false ; +// bool check_nmesy = false ; bool check_zyy = false ; bool check_ievy = false ; bool check_dy = false ; @@ -214,7 +214,7 @@ void TSpegPhysics::ReadConfiguration(string Path) ReadingStatus1 = false ; } else if (DataBuffer=="nmesx=") { - check_nmesx = true ; +// check_nmesx = true ; ConfigFile >> DataBuffer ; nmesx=atof(DataBuffer.c_str()); cout << "nmesx: " << atof(DataBuffer.c_str()) << endl; @@ -417,7 +417,7 @@ void TSpegPhysics::ReadConfiguration(string Path) } else if (DataBuffer=="nmesy=") { - check_nmesy = true ; +// check_nmesy = true ; ConfigFile >> DataBuffer ; nmesy=atof(DataBuffer.c_str()); cout << "nmesy: " << atof(DataBuffer.c_str()) << endl; @@ -1512,8 +1512,8 @@ else if(xfoc>0 && tfoc>0) { //Correction of xfoc by thetafoc and phifoc - cor_xfoc_thetafoc=(CalibrationManager::getInstance()->GetCalibration("SPEG/_xfoc_cor_theta")); - cor_xfoc_phifoc=(CalibrationManager::getInstance()->GetCalibration("SPEG/_xfoc_cor_phi")); + cor_xfoc_thetafoc=(CalibrationManager::getInstance()->GetCorrection("SPEG/_xfoc_cor_theta")); + cor_xfoc_phifoc=(CalibrationManager::getInstance()->GetCorrection("SPEG/_xfoc_cor_phi")); xfoc_cor_thetafoc=xfoc; for(unsigned int n = 0 ; n < cor_xfoc_thetafoc.size() ; n++) @@ -1538,7 +1538,7 @@ else for(int n = 0 ; n < degree_of_correction_angle_with_Brho+1 ; n++) { param_theta = 0; - cor_theta = (CalibrationManager::getInstance()->GetCalibration("SPEG/_tfoc_correction_with_Brho_"+itoa(n))); + cor_theta = (CalibrationManager::getInstance()->GetCorrection("SPEG/_tfoc_correction_with_Brho_"+itoa(n))); for(unsigned int l=0; l<cor_theta.size() ; l++) { param_theta += cor_theta[l]*pow(xfoc_cor_phifoc,l); @@ -1552,7 +1552,7 @@ else for(int n = 0 ; n < degree_of_correction_angle_with_Brho+1 ; n++) { param_phi = 0; - cor_phi = (CalibrationManager::getInstance()->GetCalibration("SPEG/_phifoc_correction_with_Brho_"+itoa(n))); + cor_phi = (CalibrationManager::getInstance()->GetCorrection("SPEG/_phifoc_correction_with_Brho_"+itoa(n))); for(unsigned int l=0; l<cor_phi.size() ; l++) { param_phi += cor_phi[l]*pow(xfoc_cor_phifoc,l); @@ -1566,7 +1566,7 @@ else for(int n = 0 ; n < degree_of_calibration_angle_with_Brho+1 ; n++) { param_theta = 0; - cal_theta = (CalibrationManager::getInstance()->GetCalibration("SPEG/_tfoc_calibration_with_Brho_"+itoa(n))); + cal_theta = (CalibrationManager::getInstance()->GetCorrection("SPEG/_tfoc_calibration_with_Brho_"+itoa(n))); for(unsigned int l=0; l<cal_theta.size() ; l++) { param_theta += cal_theta[l]*pow(xfoc_cor_phifoc,l); @@ -1588,7 +1588,7 @@ else for(int n = 0 ; n < degree_of_calibration_angle_with_Brho+1 ; n++) { param_phi = 0; - cal_phi = (CalibrationManager::getInstance()->GetCalibration("SPEG/_phifoc_calibration_with_Brho_"+itoa(n))); + cal_phi = (CalibrationManager::getInstance()->GetCorrection("SPEG/_phifoc_calibration_with_Brho_"+itoa(n))); for(unsigned int l=0; l<cal_phi.size() ; l++) { param_phi += cal_phi[l]*pow(xfoc_cor_phifoc,l); diff --git a/NPLib/Tools/CalibrationManager.cxx b/NPLib/Tools/CalibrationManager.cxx index b232fa85f1a4100fcd898c7eae1dc01cc0670ef2..68e399c9c2d13363acc06badecda23b61e2eb7d9 100644 --- a/NPLib/Tools/CalibrationManager.cxx +++ b/NPLib/Tools/CalibrationManager.cxx @@ -45,14 +45,14 @@ CalibrationManager* CalibrationManager::getInstance(string configFileName) ////////////////////////////////////////////////////////////////// CalibrationManager::CalibrationManager(string configFileName) - { +{ // Read configuration file Buffer string lineBuffer, dataBuffer; // Open file ifstream inputConfigFile; inputConfigFile.open(configFileName.c_str()); - + cout << endl; cout << "/////////// Calibration Information ///////////" << endl; cout << "Getting list of Calibration File" << endl; @@ -61,18 +61,18 @@ CalibrationManager::CalibrationManager(string configFileName) cout << "Calibration Path file :" << configFileName << " not found " << endl; return; } - + else - { - cout << "Reading list of file from :" << configFileName << endl; + { + cout << "Reading list of file from :" << configFileName << endl; while (!inputConfigFile.eof()) { getline(inputConfigFile, lineBuffer); - + // search for token giving the list of Root files to treat if ( lineBuffer.compare(0, 19, "CalibrationFilePath") == 0 ) { - while (!inputConfigFile.eof()) { + while (!inputConfigFile.eof()) { inputConfigFile >> dataBuffer; - + // ignore comment Line if (dataBuffer.compare(0, 1, "%") == 0) { inputConfigFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); @@ -82,37 +82,65 @@ CalibrationManager::CalibrationManager(string configFileName) AddFile(dataBuffer); cout << "Adding file " << dataBuffer << " to Calibration" << endl; } - } } } - } - cout << "/////////////////////////////////" << endl; + } } - + cout << "/////////////////////////////////" << endl; +} + ////////////////////////////////////////////////////////////////// CalibrationManager::~CalibrationManager() - {} - +{} + ////////////////////////////////////////////////////////////////// bool CalibrationManager::AddParameter(string DetectorName , string ParameterName , string Token ) +{ + string ParameterPath = DetectorName + "/" + ParameterName ; + fToken[Token] = ParameterPath ; + return true; +} + +///////////////////////////////////////////////////////////////// +void CalibrationManager::ClearCalibration() +{ + fCalibrationCoeff.clear(); +} + +///////////////////////////////////////////////////////////////// +vector<double> CalibrationManager::GetCorrection(const string& ParameterPath) +{ + vector<double> Coeff ; + map< string , vector<double> >::iterator it ; + it = fCalibrationCoeff.find(ParameterPath) ; + + if(it == fCalibrationCoeff.end() ) { - string ParameterPath = DetectorName + "/" + ParameterName ; - fToken[Token] = ParameterPath ; - return true; + /* cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ; + cout << " ERROR: PARAMETER " << ParameterPath << " IS NOT FOUND IN THE CALIBRATION DATA BASE " << endl ; + cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " << endl ;*/ + + return Coeff ; } + Coeff = it->second ; + + return(Coeff); +} + + ////////////////////////////////////////////////////////////////// void CalibrationManager::LoadParameterFromFile() - { - ifstream CalibFile ; - string DataBuffer ; - string LineBuffer ; - - // Get pointer to the TAsciifile CalibrationFile in RootOuput - TAsciiFile* AcsiiCalibration = RootOutput::getInstance()->GetAsciiFileCalibration(); - - - for(unsigned int i = 0 ; i < fFileList.size() ; i++) +{ + ifstream CalibFile ; + string DataBuffer ; + string LineBuffer ; + + // Get pointer to the TAsciifile CalibrationFile in RootOuput + TAsciiFile* AcsiiCalibration = RootOutput::getInstance()->GetAsciiFileCalibration(); + + + for(unsigned int i = 0 ; i < fFileList.size() ; i++) { CalibFile.open( fFileList[i].c_str() ); map<string,string>::iterator it ; diff --git a/NPLib/Tools/CalibrationManager.h b/NPLib/Tools/CalibrationManager.h index f319facec6ae8d6b08bf5f648259ef8eff4cd758..2de05b5fc77a25ad14cf998ed52570025ee86137 100644 --- a/NPLib/Tools/CalibrationManager.h +++ b/NPLib/Tools/CalibrationManager.h @@ -64,8 +64,15 @@ class CalibrationManager public: // To be called after initialisation // Loop over the file list and catch the file used for calibration void LoadParameterFromFile(); - - + + public: //Clear calibration if we have some calibration files to read + void ClearCalibration(); + + public: //Get calibration coefficient vector + vector<double> GetCorrection(const string& ParameterPath); + + + private: // This map hold a vector of the calibration coefficient. Index is the Parameter path, like "MUST2/Telescope5_Si_X38_E" map< string , vector<double> > fCalibrationCoeff ; diff --git a/NPLib/VDetector/DetectorManager.cxx b/NPLib/VDetector/DetectorManager.cxx index e4787452bac7dfa82ba87294828dbfc377b1bd5b..089dee5daee44eb07c2944e9b2d588abe0957413 100644 --- a/NPLib/VDetector/DetectorManager.cxx +++ b/NPLib/VDetector/DetectorManager.cxx @@ -16,6 +16,9 @@ #include "Paris.h" #include "TW1Physics.h" #include "Shield.h" +#include "TSpegPhysics.h" +#include "TExlPhysics.h" +#include "TTacPhysics.h" #include "NPOptionManager.h" #include "RootInput.h" ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -59,6 +62,9 @@ void DetectorManager::ReadConfigurationFile(string Path) bool ParisDet = false; bool ShieldDet = false; bool W1 = false; + bool SPEG = false; + bool EXL = false; + bool TAC = false; ////////////////////////////////////////////////////////////////////////////////////////// string GlobalPath = getenv("NPTOOL"); @@ -256,22 +262,79 @@ void DetectorManager::ReadConfigurationFile(string Path) AddDetector("Plastic", myDetector); } - //////////////////////////////////////////// - ///////////// Search for Trifoil /////////// - //////////////////////////////////////////// + //////////////////////////////////////////// + ///////////// Search for SPEG ////////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 4, "SPEG") == 0 && SPEG == false) { + SPEG = true ; + cout << "//////// SPEG Spectrometer ////////" << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TSpegPhysics(); + + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("SPEG", myDetector); + } + + /////////////////////////////////////////////////////////// + //////////// Search for EXL Csi gamma detector //////////// + /////////////////////////////////////////////////////////// + else if (LineBuffer.compare(0, 3, "EXL") == 0 && EXL == false) { + EXL = true ; + cout << "//////// EXL Csi gamma detector ////////" << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TExlPhysics(); + + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("EXL", myDetector); + } + + //////////////////////////////////////////// + ////////////// Search for TAC ////////////// + //////////////////////////////////////////// + else if (LineBuffer.compare(0, 3, "TAC") == 0 && TAC == false) { + TAC = true ; + cout << "//////// TAC ////////" << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TTacPhysics(); + + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("TAC", myDetector); + } + + //////////////////////////////////////////// + ///////////// Search for Trifoil /////////// + //////////////////////////////////////////// else if (LineBuffer.compare(0, 7, "Trifoil") == 0 && Trifoil == false) { - Trifoil = true; - cout << "//////// Trifoil ////////" << endl << endl; - - // Instantiate the new array as a VDetector Object - VDetector* myDetector = new TTrifoilPhysics(); - // Read Position of Telescope - ConfigFile.close(); - myDetector->ReadConfiguration(Path); - ConfigFile.open(Path.c_str()); - - // Add array to the VDetector Vector - AddDetector("Trifoil", myDetector); + Trifoil = true; + cout << "//////// Trifoil ////////" << endl << endl; + + // Instantiate the new array as a VDetector Object + VDetector* myDetector = new TTrifoilPhysics(); + // Read Position of Telescope + ConfigFile.close(); + myDetector->ReadConfiguration(Path); + ConfigFile.open(Path.c_str()); + + // Add array to the VDetector Vector + AddDetector("Trifoil", myDetector); } //////////////////////////////////////////// @@ -286,7 +349,7 @@ void DetectorManager::ReadConfigurationFile(string Path) getline(ConfigFile, LineBuffer); bool check_Thickness = false; - bool check_Angle = false; +// bool check_Angle = false; bool check_Radius = false; bool check_Material = false; bool check_X = false; @@ -309,7 +372,7 @@ void DetectorManager::ReadConfigurationFile(string Path) } else if (DataBuffer.compare(0, 6, "ANGLE=") == 0) { - check_Angle = true ; +// check_Angle = true ; ConfigFile >> DataBuffer; // m_TargetAngle = atof(DataBuffer.c_str()) * deg; m_TargetAngle = atof(DataBuffer.c_str());