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
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)
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 @@
#include <stdio.h>
#include <iostream>
using namespace NPL;
using namespace NPL::XML;
////////////////////////////////////////////////////////////////////////////////
block::block(){};
block::~block(){};
......@@ -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::block*> res;
std::vector<NPL::XML::block*> XmlParser::GetAllBlocksWithName(std::string name){
std::vector<NPL::XML::block*> res;
auto it=m_blocks.find(name);
if(it!=m_blocks.end()){
......
......@@ -7,85 +7,87 @@
#include "TXMLEngine.h"
namespace NPL{
/////////////////////
class parameter{
public:
parameter();
parameter(std::string name, std::string value){
m_name=name;
m_value=value;
namespace XML{
class parameter{
public:
parameter();
parameter(std::string name, std::string value){
m_name=name;
m_value=value;
};
~parameter();
~parameter();
private:
std::string m_name;
std::string m_value;
public:
std::string GetName() const {return m_name;};
std::string GetValue() const {return m_value;};
private:
std::string m_name;
std::string m_value;
public:
bool operator<(const parameter p2){
return this->m_name<p2.m_name;
}
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:
std::string GetName() const {return m_name;};
std::string GetValue() const {return m_value;};
/////////////////////
class Channel{
public:
Channel();
~Channel();
Channel(int device,int geo,int ch){
m_device=device;
m_geo=geo;
m_ch=ch;
};
public:
bool operator<(const parameter p2){
return this->m_name<p2.m_name;
}
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;
};
};
private:
int m_device;
int m_geo;
int m_ch;
public:
int norme() const {return (m_device*1000000+m_geo*1000+m_ch);} ;
/////////////////////
// Use for Riken data conversion only
class Channel{
public:
Channel();
~Channel();
Channel(int device,int geo,int ch){
m_device=device;
m_geo=geo;
m_ch=ch;
};
public:
bool operator<(const Channel p2){
return this->norme()<p2.norme();
private:
int m_device;
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){
return p1.norme()<p2.norme();
friend bool operator<(const Channel p1,const Channel p2){
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:
std::string m_name;
std::set<parameter> m_parameters;
};
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:
std::string m_name;
std::set<parameter> m_parameters;
};
}
/////////////////////
class XmlParser{
public:
......@@ -97,26 +99,27 @@ namespace NPL{
void LoadFile(std::string file);
void DisplayNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level);
void LoadNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level);
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);
if(it!=m_Channels.end())
return it->second;
else
return NULL;
};
void SetBlock(const Channel& c,block* b){
};
void SetBlock(const XML::Channel& c,XML::block* b){
m_Channels[c]=b;
}
}
public:
std::vector<block*> GetAllBlocksWithName(std::string name) ;
std::vector<XML::block*> GetAllBlocksWithName(std::string name) ;
std::vector<std::string> GetAllBlocksName();
private:
std::map<std::string,std::vector<block>> m_blocks;
std::map<Channel,block*> m_Channels;
std::map<std::string,std::vector<XML::block>> m_blocks;
std::map<XML::Channel,XML::block*> m_Channels;
};
}
......
......@@ -411,7 +411,7 @@ void TSamuraiFDC2Physics::ReadConfiguration(NPL::InputParser parser){
///////////////////////////////////////////////////////////////////////////
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
if(name=="SAMURAIFDC2"){
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