Commit ec8435af authored by Adrien Matta's avatar Adrien Matta
Browse files

* changing a few things around in NPXml

parent debdf1e6
Pipeline #87092 passed with stages
in 12 minutes and 36 seconds
...@@ -4,4 +4,4 @@ add_custom_command(OUTPUT NPDeltaSpectraDict.cxx COMMAND ${CMAKE_BINARY_DIR}/sc ...@@ -4,4 +4,4 @@ add_custom_command(OUTPUT NPDeltaSpectraDict.cxx COMMAND ${CMAKE_BINARY_DIR}/sc
add_custom_command(OUTPUT NPVDetectorDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPVDetector.h NPVDetectorDict.cxx NPVDetector.rootmap libNPCore.so NPCoreLinkdef.h) add_custom_command(OUTPUT NPVDetectorDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh NPVDetector.h NPVDetectorDict.cxx NPVDetector.rootmap libNPCore.so NPCoreLinkdef.h)
add_library(NPCore SHARED NPCore.cxx NPRandom.cxx NPVAnalysis.cxx NPAnalysisFactory.cxx NPCalibrationManager.cxx NPOptionManager.cxx RootOutput.cxx RootInput.cxx TAsciiFile.cxx TAsciiFileDict.cxx NPDeltaSpectraDict.cxx NPDetectorManager.cxx NPVDetector.cxx NPVDetectorDict.cxx NPVSpectra.cxx NPDetectorFactory.cxx NPSpectraServer.cxx NPInputParser.cxx NPImage.cxx NPElog.cxx NPDeltaSpectra.cxx NPXmlParser.cxx) add_library(NPCore SHARED NPCore.cxx NPRandom.cxx NPVAnalysis.cxx NPAnalysisFactory.cxx NPCalibrationManager.cxx NPOptionManager.cxx RootOutput.cxx RootInput.cxx TAsciiFile.cxx TAsciiFileDict.cxx NPDeltaSpectraDict.cxx NPDetectorManager.cxx NPVDetector.cxx NPVDetectorDict.cxx NPVSpectra.cxx NPDetectorFactory.cxx NPSpectraServer.cxx NPInputParser.cxx NPImage.cxx NPElog.cxx NPDeltaSpectra.cxx NPXmlParser.cxx)
target_link_libraries(NPCore ${ROOT_LIBRARIES} -lXMLIO) target_link_libraries(NPCore ${ROOT_LIBRARIES} -lXMLIO)
install(FILES NPCore.h NPVAnalysis.h NPAnalysisFactory.h NPRandom.h NPCalibrationManager.h NPOptionManager.h RootInput.h RootOutput.h TAsciiFile.h NPDetectorManager.h NPVDetector.h NPGlobalSystemOfUnits.h NPPhysicalConstants.h NPSystemOfUnits.h NPVSpectra.h NPDetectorFactory.h NPSpectraServer.h NPInputParser.h NPImage.h NPElog.h NPDeltaSpectra.h NPXmlParser.cxx DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) install(FILES NPCore.h NPVAnalysis.h NPAnalysisFactory.h NPRandom.h NPCalibrationManager.h NPOptionManager.h RootInput.h RootOutput.h TAsciiFile.h NPDetectorManager.h NPVDetector.h NPGlobalSystemOfUnits.h NPPhysicalConstants.h NPSystemOfUnits.h NPVSpectra.h NPDetectorFactory.h NPSpectraServer.h NPInputParser.h NPImage.h NPElog.h NPDeltaSpectra.h NPXmlParser.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <iostream> #include <iostream>
using namespace NPL; using namespace NPL;
using namespace NPL::XML;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
block::block(){}; block::block(){};
block::~block(){}; block::~block(){};
...@@ -121,8 +121,8 @@ void XmlParser::LoadNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level){ ...@@ -121,8 +121,8 @@ void XmlParser::LoadNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level){
} }
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
std::vector<NPL::block*> XmlParser::GetAllBlocksWithName(std::string name){ std::vector<NPL::XML::block*> XmlParser::GetAllBlocksWithName(std::string name){
std::vector<NPL::block*> res; std::vector<NPL::XML::block*> res;
auto it=m_blocks.find(name); auto it=m_blocks.find(name);
if(it!=m_blocks.end()){ if(it!=m_blocks.end()){
......
...@@ -7,85 +7,87 @@ ...@@ -7,85 +7,87 @@
#include "TXMLEngine.h" #include "TXMLEngine.h"
namespace NPL{ namespace NPL{
///////////////////// /////////////////////
class parameter{ namespace XML{
public: class parameter{
parameter(); public:
parameter(std::string name, std::string value){ parameter();
m_name=name; parameter(std::string name, std::string value){
m_value=value; m_name=name;
m_value=value;
}; };
~parameter(); ~parameter();
private: private:
std::string m_name; std::string m_name;
std::string m_value; std::string m_value;
public:
std::string GetName() const {return m_name;};
std::string GetValue() const {return m_value;};
public: public:
bool operator<(const parameter p2){ std::string GetName() const {return m_name;};
return this->m_name<p2.m_name; std::string GetValue() const {return m_value;};
}
friend bool operator<(const parameter p1,const parameter p2){
return p1.m_name<p2.m_name;
}
friend bool operator==(const parameter p1,const parameter p2){
return p1.m_name==p2.m_name;
};
};
///////////////////// public:
class Channel{ bool operator<(const parameter p2){
public: return this->m_name<p2.m_name;
Channel(); }
~Channel(); friend bool operator<(const parameter p1,const parameter p2){
Channel(int device,int geo,int ch){ return p1.m_name<p2.m_name;
m_device=device; }
m_geo=geo; friend bool operator==(const parameter p1,const parameter p2){
m_ch=ch; return p1.m_name==p2.m_name;
}; };
};
private: /////////////////////
int m_device; // Use for Riken data conversion only
int m_geo; class Channel{
int m_ch; public:
Channel();
public: ~Channel();
int norme() const {return (m_device*1000000+m_geo*1000+m_ch);} ; Channel(int device,int geo,int ch){
m_device=device;
m_geo=geo;
m_ch=ch;
};
public: private:
bool operator<(const Channel p2){ int m_device;
return this->norme()<p2.norme(); int m_geo;
int m_ch;
public:
int norme() const {return (m_device*1000000+m_geo*1000+m_ch);} ;
public:
bool operator<(const Channel p2){
return this->norme()<p2.norme();
} }
friend bool operator<(const Channel p1,const Channel p2){ friend bool operator<(const Channel p1,const Channel p2){
return p1.norme()<p2.norme(); return p1.norme()<p2.norme();
} }
friend bool operator==(const Channel p1,const Channel p2){
return p1.norme()==p2.norme();
}
};
/////////////////////
class block{
public:
block();
~block();
public:
int AsInt(std::string name);
double AsDouble(std::string name);
std::string AsString(std::string name);
void AddParameter(parameter p){ m_parameters.insert(p);};
private: friend bool operator==(const Channel p1,const Channel p2){
std::string m_name; return p1.norme()==p2.norme();
std::set<parameter> m_parameters; }
}; };
/////////////////////
class block{
public:
block();
~block();
public:
int AsInt(std::string name);
double AsDouble(std::string name);
std::string AsString(std::string name);
void AddParameter(parameter p){ m_parameters.insert(p);};
private:
std::string m_name;
std::set<parameter> m_parameters;
};
}
///////////////////// /////////////////////
class XmlParser{ class XmlParser{
public: public:
...@@ -97,26 +99,27 @@ namespace NPL{ ...@@ -97,26 +99,27 @@ namespace NPL{
void LoadFile(std::string file); void LoadFile(std::string file);
void DisplayNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level); void DisplayNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level);
void LoadNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level); void LoadNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level);
public: // access by channel id public: // access by channel id
block* GetBlock(Channel c){ // this is used by mrdc to convert ridf file into nptool root file
XML::block* GetBlock(XML::Channel c){
auto it = m_Channels.find(c); auto it = m_Channels.find(c);
if(it!=m_Channels.end()) if(it!=m_Channels.end())
return it->second; return it->second;
else else
return NULL; return NULL;
}; };
void SetBlock(const Channel& c,block* b){ void SetBlock(const XML::Channel& c,XML::block* b){
m_Channels[c]=b; m_Channels[c]=b;
} }
public: public:
std::vector<block*> GetAllBlocksWithName(std::string name) ; std::vector<XML::block*> GetAllBlocksWithName(std::string name) ;
std::vector<std::string> GetAllBlocksName(); std::vector<std::string> GetAllBlocksName();
private: private:
std::map<std::string,std::vector<block>> m_blocks; std::map<std::string,std::vector<XML::block>> m_blocks;
std::map<Channel,block*> m_Channels; std::map<XML::Channel,XML::block*> m_Channels;
}; };
} }
......
...@@ -411,7 +411,7 @@ void TSamuraiFDC2Physics::ReadConfiguration(NPL::InputParser parser){ ...@@ -411,7 +411,7 @@ void TSamuraiFDC2Physics::ReadConfiguration(NPL::InputParser parser){
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void TSamuraiFDC2Physics::AddDC(string name, NPL::XmlParser& xml){ void TSamuraiFDC2Physics::AddDC(string name, NPL::XmlParser& xml){
std::vector<NPL::block*> b = xml.GetAllBlocksWithName(name); std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName(name);
// FDC2 case // FDC2 case
if(name=="SAMURAIFDC2"){ if(name=="SAMURAIFDC2"){
unsigned int det=2; unsigned int det=2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment