5#include <nlohmann/json.hpp>
11 , XStationPositions(NULL)
12 , YStationPositions(NULL)
13 , ZStationPositions(NULL)
20 , XStationPositions(NULL)
21 , YStationPositions(NULL)
22 , ZStationPositions(NULL)
26 Bool_t create_status = CreateConfigurationFromXMLFile(xml_config_file);
28 std::cerr <<
"Error: There are problems with creation of the configuration from XML (in BmnVSPStationSet)\n";
99 for (Int_t istation = 0; istation <
NStations; ++istation) {
117 if (
VSPStations[station]->AddPointToStation(xcoord, ycoord, zcoord, px, py, pz, dEloss, refID) != -1)
127 Int_t points_sum = 0;
128 for (Int_t iStation = 0; iStation <
NStations; iStation++) {
136 for (Int_t iStation = 0; iStation <
NStations; iStation++) {
143 Int_t points_sum = 0;
144 for (Int_t iStation = 0; iStation <
NStations; iStation++) {
153 for (Int_t iStation = 0; iStation <
NStations; iStation++) {
155 for (Int_t iModule = 0; iModule < NModules; ++iModule) {
156 if (
VSPStations[iStation]->GetModule(iModule)->IsPointInsideZThickness(zcoord)) {
167 for (Int_t iStation = 0; iStation <
NStations; iStation++) {
169 for (Int_t iModule = 0; iModule < NModules; ++iModule) {
171 if (
VSPStations[iStation]->GetModule(iModule)->IsPointInsideModule(xcoord, ycoord, zcoord)) {
179Bool_t BmnVSPStationSet::CreateConfigurationFromXMLFile(TString xml_config_file)
181 TDOMParser* parser =
new TDOMParser();
182 parser->SetValidate(
false);
184 Int_t parse_status = parser->ParseFile(xml_config_file);
185 if (parse_status != 0) {
186 std::cerr <<
"Error: An error occured when parsing the file! (in BmnVSPStationSet)\n";
190 TXMLNode* node =
parser->GetXMLDocument()->GetRootNode();
192 if (strcmp(node->GetNodeName(),
"StationSet") != 0) {
193 std::cerr <<
"Error: Incorrect name of the root element! (in BmnVSPStationSet)\n";
212 node = node->GetChildren();
213 Int_t currentStationNum = 0;
215 if (strcmp(node->GetNodeName(),
"Station") == 0) {
216 parse_status = ParseStation(node, currentStationNum);
221 node = node->GetNextNode();
229Int_t BmnVSPStationSet::CountNumberOfStations(TXMLNode* node)
231 Int_t station_cnt = 0;
232 node = node->GetChildren();
234 if (strcmp(node->GetNodeName(),
"Station") == 0) {
237 node = node->GetNextNode();
242Bool_t BmnVSPStationSet::ParseStation(TXMLNode* node, Int_t iStation)
245 if (node->HasAttributes()) {
246 TList* attrList = node->GetAttributes();
248 TIter next(attrList);
250 while ((attr = (TXMLAttr*)next()) !=
nullptr) {
251 if (strcmp(attr->GetName(),
"xPosition") == 0) {
254 if (strcmp(attr->GetName(),
"yPosition") == 0) {
257 if (strcmp(attr->GetName(),
"zPosition") == 0) {
269 Int_t stat = it.first;
270 if (iStation == stat) {
285 TString gPathConfig = getenv(
"VMCWORKDIR");
286 std::ifstream
f(gPathConfig +
"/config/bmnconf.json");
288 json jss = data[
"Detectors"][
"vsp"][
"StationSet"];
289 TString conf_subdir = jss.
value(
"Dir",
"");
290 json xmlConfFileNameJ = jss[to_string(stp).c_str()];
291 TString xmlConfFileName = jss[
"Setup"][to_string(stp).c_str()][
"Period"].
value(to_string(period).c_str(),
"");
292 TString gPathCscConfig = gPathConfig +
"/" + conf_subdir +
"/";
293 return std::make_unique<BmnVSPStationSet>(gPathCscConfig + xmlConfFileName);
Double_t * ZStationPositions
map< Int_t, TVector3 > * fStatShifts
Int_t CountNProcessedPointsInDetector()
Double_t GetZStationPosition(Int_t station_num)
Double_t * XStationPositions
Bool_t AddPointToDetector(Double_t xcoord, Double_t ycoord, Double_t zcoord, Double_t px, Double_t py, Double_t pz, Double_t dEloss, Int_t refID)
Int_t GetPointStationOwnership(Double_t zcoord)
virtual ~BmnVSPStationSet()
Double_t GetXStationPosition(Int_t station_num)
BmnVSPStation ** VSPStations
static unique_ptr< BmnVSPStationSet > Create(Int_t period, Int_t stp=0)
Int_t CountNAddedToDetectorPoints()
Double_t * YStationPositions
void ProcessPointsInDetector()
BmnVSPStation * GetVSPStation(Int_t station_num)
Double_t GetYStationPosition(Int_t station_num)
Int_t CountNAddedToStationPoints()
Int_t CountNProcessedPointInStation()
void ProcessPointsInStation()
a class to store JSON values
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
basic_json<> json
default specialization