musrfit  1.9.2
PStartupHandler.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  PStartupHandler.cpp
4 
5  Author: Andreas Suter
6  e-mail: andreas.suter@psi.ch
7 
8 ***************************************************************************/
9 
10 /***************************************************************************
11  * Copyright (C) 2007-2023 by Andreas Suter *
12  * andreas.suter@psi.ch *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the *
26  * Free Software Foundation, Inc., *
27  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28  ***************************************************************************/
29 
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 
33 #include <cstdlib>
34 #include <iostream>
35 #include <fstream>
36 
37 #include <TObjArray.h>
38 #include <TObjString.h>
39 #include <TColor.h>
40 #include <TList.h>
41 #include <TXMLAttr.h>
42 
43 #include "PStartupHandler.h"
44 
46 
47 //--------------------------------------------------------------------------
48 // This function is a replacement for the ParseFile method of TSAXParser.
49 // It is needed because in certain environments ParseFile does not work but ParseBuffer does.
50 //--------------------------------------------------------------------------
62 int parseXmlFile(TSAXParser *saxParser, const char *startup_path_name)
63 {
64  int status;
65  std::fstream xmlFile;
66  unsigned int xmlSize = 0;
67  char *xmlBuffer = nullptr;
68 
69  xmlFile.open(startup_path_name, std::ios::in | std::ios::ate); // open file for reading and go to the end of the file
70  if (xmlFile.is_open()) { // check if file has been opened successfully
71  xmlSize = xmlFile.tellg(); // get the position within the stream == size of the file (since we are at the end)
72  xmlFile.seekg(0, std::ios::beg); // go back to the beginning of the stream
73  xmlBuffer = new char[xmlSize]; // allocate buffer memory for the whole XML file
74  xmlFile.read(xmlBuffer, xmlSize); // read in the whole XML file into the buffer
75  xmlFile.close(); // close the XML file
76  }
77  if (!xmlBuffer) { // file has not been read into the buffer
78  status = 1;
79  } else {
80  status = saxParser->ParseBuffer(xmlBuffer, xmlSize); // parse buffer
81  delete[] xmlBuffer; // free the buffer memory
82  xmlBuffer = nullptr;
83  }
84 
85  return status;
86 }
87 
88 //--------------------------------------------------------------------------
89 // Constructor
90 //--------------------------------------------------------------------------
95 {
96  fStartupFileFound = false;
97  fStartupFilePath = "";
98 
99  // get default path (for the moment only linux like)
100  Char_t *pmusrpath=nullptr;
101  Char_t *home=nullptr;
102  Char_t musrpath[128];
103  Char_t startup_path_name[128];
104 
105  strncpy(musrpath, "", sizeof(musrpath));
106 
107  // check if the startup file is found in the current directory
108  strcpy(startup_path_name, "./musrfit_startup.xml");
110  fStartupFileFound = true;
112  }
113  if (!fStartupFileFound) { // startup file not found in the current directory
114  // check if the startup file is found under $HOME/.musrfit
115  home = getenv("HOME");
116  if (home != nullptr) {
117  snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/musrfit_startup.xml", home);
120  fStartupFileFound = true;
121  }
122  }
123  }
124  if (!fStartupFileFound) { // startup file not found in $HOME/.musrfit
125  // check if the MUSRFITPATH system variable is set
126  pmusrpath = getenv("MUSRFITPATH");
127  if (pmusrpath != nullptr) {
128  snprintf(startup_path_name, sizeof(startup_path_name), "%s/musrfit_startup.xml", pmusrpath);
131  fStartupFileFound = true;
132  }
133  }
134  }
135  if (!fStartupFileFound) { // MUSRFITPATH not set or empty, will try $ROOTSYS/bin
136  home = getenv("ROOTSYS");
137  if (home != nullptr) {
138  snprintf(musrpath, sizeof(musrpath), "%s/bin", home);
139  std::cerr << std::endl << "**WARNING** MUSRFITPATH environment variable not set will try " << musrpath << std::endl;
140  snprintf(startup_path_name, sizeof(startup_path_name), "%s/musrfit_startup.xml", musrpath);
143  fStartupFileFound = true;
144  }
145  }
146  }
147 
148  // if musrfit_startup.xml is still not found, will create a default one
149  if (!fStartupFileFound) {
150  std::cout << std::endl << "**INFO** no musrfit_startup.xml file found, will write a default one." << std::endl;
151  if (!WriteDefaultStartupFile()) {
152  std::cerr << std::endl << "**ERROR** couldn't write default musrfit_startup.xml." << std::endl;
153  } else {
154  home = getenv("HOME");
155  if (home != nullptr) {
156  snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/musrfit_startup.xml", home);
159  fStartupFileFound = true;
160  }
161  }
162  }
163  }
164 }
165 
166 //--------------------------------------------------------------------------
167 // Destructor
168 //--------------------------------------------------------------------------
173 {
174  // clean up
175  fDataPathList.clear();
176  fMarkerList.clear();
177  fColorList.clear();
178  fRunNameTemplate.clear();
179 }
180 
181 //--------------------------------------------------------------------------
182 // OnStartDocument
183 //--------------------------------------------------------------------------
188 {
189  fKey = eEmpty;
190 
191  // init fourier default variables
199  fFourierDefaults.fPlotRange[0] = -1.0;
200  fFourierDefaults.fPlotRange[1] = -1.0;
202 }
203 
204 //--------------------------------------------------------------------------
205 // OnEndDocument
206 //--------------------------------------------------------------------------
211 {
212  // check if anything was set, and if not set some default stuff
213  CheckLists();
214 }
215 
216 //--------------------------------------------------------------------------
217 // OnStartElement
218 //--------------------------------------------------------------------------
226 void PStartupHandler::OnStartElement(const Char_t *str, const TList *attributes)
227 {
228  if (!strcmp(str, "data_path")) {
229  fKey = eDataPath;
230  } else if (!strcmp(str, "run_name_template")) {
232  TXMLAttr *attr;
233  TIter next(attributes);
234  while ((attr = (TXMLAttr*) next())) {
235  if (!strcmp(attr->GetName(), "inst")) {
236  fCurrentInstrumentName = attr->GetValue();
237  }
238  }
239  } else if (!strcmp(str, "marker")) {
240  fKey = eMarker;
241  } else if (!strcmp(str, "color")) {
242  fKey = eColor;
243  } else if (!strcmp(str, "units")) {
244  fKey = eUnits;
245  } else if (!strcmp(str, "fourier_power")) {
247  } else if (!strcmp(str, "apodization")) {
248  fKey = eApodization;
249  } else if (!strcmp(str, "plot")) {
250  fKey = ePlot;
251  } else if (!strcmp(str, "phase")) {
252  fKey = ePhase;
253  } else if (!strcmp(str, "phase_increment")) {
255  }
256 }
257 
258 //--------------------------------------------------------------------------
259 // OnEndElement
260 //--------------------------------------------------------------------------
266 void PStartupHandler::OnEndElement(const Char_t *str)
267 {
268  fKey = eEmpty;
269 }
270 
271 //--------------------------------------------------------------------------
272 // OnCharacters
273 //--------------------------------------------------------------------------
280 void PStartupHandler::OnCharacters(const Char_t *str)
281 {
282  TObjArray *tokens;
283  TObjString *ostr;
284  TString tstr;
285  Int_t color, r, g, b, ival;
286 
287  PRunNameTemplate tmpl;
288  switch (fKey) {
289  case eDataPath:
290  // check that str is a valid path
291  // add str to the path list
292  fDataPathList.push_back(str);
293  break;
294  case eRunNameTemplate:
296  tmpl.runNameTemplate = str;
297  fRunNameTemplate.push_back(tmpl);
299  break;
300  case eMarker:
301  // check that str is a number
302  tstr = TString(str);
303  if (tstr.IsDigit()) {
304  // add converted str to the marker list
305  fMarkerList.push_back(tstr.Atoi());
306  } else {
307  std::cerr << std::endl << "PStartupHandler **WARNING** '" << str << "' is not a number, will ignore it";
308  std::cerr << std::endl;
309  }
310  break;
311  case eColor:
312  // check that str is a rbg code
313  tstr = TString(str);
314  tokens = tstr.Tokenize(",");
315  // check that there any tokens
316  if (!tokens) {
317  std::cerr << std::endl << "PStartupHandler **WARNING** '" << str << "' is not a rbg code, will ignore it";
318  std::cerr << std::endl;
319  return;
320  }
321  // check there is the right number of tokens
322  if (tokens->GetEntries() != 3) {
323  std::cerr << std::endl << "PStartupHandler **WARNING** '" << str << "' is not a rbg code, will ignore it";
324  std::cerr << std::endl;
325  return;
326  }
327  // get r
328  ostr = dynamic_cast<TObjString*>(tokens->At(0));
329  tstr = ostr->GetString();
330  if (tstr.IsDigit()) {
331  r = tstr.Atoi();
332  } else {
333  std::cerr << std::endl << "PStartupHandler **WARNING** r within the rgb code is not a number, will ignore it";
334  std::cerr << std::endl;
335  return;
336  }
337  // get g
338  ostr = dynamic_cast<TObjString*>(tokens->At(1));
339  tstr = ostr->GetString();
340  if (tstr.IsDigit()) {
341  g = tstr.Atoi();
342  } else {
343  std::cerr << std::endl << "PStartupHandler **WARNING** g within the rgb code is not a number, will ignore it";
344  std::cerr << std::endl;
345  return;
346  }
347  // get b
348  ostr = dynamic_cast<TObjString*>(tokens->At(2));
349  tstr = ostr->GetString();
350  if (tstr.IsDigit()) {
351  b = tstr.Atoi();
352  } else {
353  std::cerr << std::endl << "PStartupHandler **WARNING** b within the rgb code is not a number, will ignore it";
354  std::cerr << std::endl;
355  return;
356  }
357  // clean up tokens
358  if (tokens) {
359  delete tokens;
360  tokens = nullptr;
361  }
362  // generate the ROOT color code based on str
363  color = TColor::GetColor(r,g,b);
364  // add the color code to the color list
365  fColorList.push_back(color);
366  break;
367  case eUnits:
368  tstr = TString(str);
369  if (!tstr.CompareTo("gauss", TString::kIgnoreCase)) {
371  } else if (!tstr.CompareTo("tesla", TString::kIgnoreCase)) {
373  } else if (!tstr.CompareTo("mhz", TString::kIgnoreCase)) {
375  } else if (!tstr.CompareTo("mc/s", TString::kIgnoreCase)) {
377  } else {
378  std::cerr << std::endl << "PStartupHandler **WARNING** '" << str << "' is not a valid unit, will ignore it.";
379  std::cerr << std::endl;
380  }
381  break;
382  case eFourierPower:
383  tstr = TString(str);
384  if (tstr.IsDigit()) {
385  ival = tstr.Atoi();
386  if ((ival >= 0) && (ival <= 20)) {
388  } else {
389  std::cerr << std::endl << "PStartupHandler **WARNING** fourier power '" << str << "' is not a valid number (0..20), will ignore it.";
390  std::cerr << std::endl;
391  }
392  } else {
393  std::cerr << std::endl << "PStartupHandler **WARNING** fourier power '" << str << "' is not a valid number (0..20), will ignore it.";
394  std::cerr << std::endl;
395  }
396  break;
397  case eApodization:
398  tstr = TString(str);
399  if (!tstr.CompareTo("none", TString::kIgnoreCase)) {
401  } else if (!tstr.CompareTo("weak", TString::kIgnoreCase)) {
403  } else if (!tstr.CompareTo("medium", TString::kIgnoreCase)) {
405  } else if (!tstr.CompareTo("strong", TString::kIgnoreCase)) {
407  } else {
408  std::cerr << std::endl << "PStartupHandler **WARNING** '" << str << "' is not a valid apodization, will ignore it.";
409  std::cerr << std::endl;
410  }
411  break;
412  case ePlot:
413  tstr = TString(str);
414  if (!tstr.CompareTo("real", TString::kIgnoreCase)) {
416  } else if (!tstr.CompareTo("imag", TString::kIgnoreCase)) {
418  } else if (!tstr.CompareTo("real_and_imag", TString::kIgnoreCase)) {
420  } else if (!tstr.CompareTo("power", TString::kIgnoreCase)) {
422  } else if (!tstr.CompareTo("phase", TString::kIgnoreCase)) {
424  } else {
425  std::cerr << std::endl << "PStartupHandler **WARNING** '" << str << "' is not a valid plot option, will ignore it.";
426  std::cerr << std::endl;
427  }
428  break;
429  case ePhase:
430  tstr = TString(str);
431  if (tstr.IsFloat()) {
432  fFourierDefaults.fPhase.push_back(tstr.Atof());
433  } else {
434  std::cerr << std::endl << "PStartupHandler **WARNING** '" << str << "' is not a valid phase, will ignore it.";
435  std::cerr << std::endl;
436  }
437  break;
438  case ePhaseIncrement:
439  tstr = TString(str);
440  if (tstr.IsFloat()) {
441  fFourierDefaults.fPhaseIncrement = tstr.Atof();
442  } else {
443  std::cerr << std::endl << "PStartupHandler **WARNING** '" << str << "' is not a valid phase increment, will ignore it.";
444  std::cerr << std::endl;
445  }
446  break;
447  default:
448  break;
449  }
450 }
451 
452 //--------------------------------------------------------------------------
453 // OnComment
454 //--------------------------------------------------------------------------
460 void PStartupHandler::OnComment(const Char_t *str)
461 {
462  // nothing to be done for now
463 }
464 
465 //--------------------------------------------------------------------------
466 // OnWarning
467 //--------------------------------------------------------------------------
473 void PStartupHandler::OnWarning(const Char_t *str)
474 {
475  std::cerr << std::endl << "PStartupHandler **WARNING** " << str;
476  std::cerr << std::endl;
477 }
478 
479 //--------------------------------------------------------------------------
480 // OnError
481 //--------------------------------------------------------------------------
487 void PStartupHandler::OnError(const Char_t *str)
488 {
489  std::cerr << std::endl << "PStartupHandler **ERROR** " << str;
490  std::cerr << std::endl;
491 }
492 
493 //--------------------------------------------------------------------------
494 // OnFatalError
495 //--------------------------------------------------------------------------
501 void PStartupHandler::OnFatalError(const Char_t *str)
502 {
503  std::cerr << std::endl << "PStartupHandler **FATAL ERROR** " << str;
504  std::cerr << std::endl;
505 }
506 
507 //--------------------------------------------------------------------------
508 // OnCdataBlock
509 //--------------------------------------------------------------------------
516 void PStartupHandler::OnCdataBlock(const Char_t *str, Int_t len)
517 {
518  // nothing to be done for now
519 }
520 
521 //--------------------------------------------------------------------------
522 // CheckLists
523 //--------------------------------------------------------------------------
529 {
530  // check if anything was set, and if not set some default stuff
531 
532  // check if any data path is given
533  if (fDataPathList.size() == 0) {
534  fDataPathList.push_back(TString("/mnt/data/nemu/his"));
535  fDataPathList.push_back(TString("/mnt/data/nemu/wkm"));
536  fDataPathList.push_back(TString("/afs/psi.ch/project/nemu/data/his"));
537  fDataPathList.push_back(TString("/afs/psi.ch/project/nemu/data/wkm"));
538  fDataPathList.push_back(TString("/afs/psi.ch/project/bulkmusr/data/gps"));
539  fDataPathList.push_back(TString("/afs/psi.ch/project/bulkmusr/data/dolly"));
540  fDataPathList.push_back(TString("/afs/psi.ch/project/bulkmusr/data/gpd"));
541  fDataPathList.push_back(TString("/afs/psi.ch/project/bulkmusr/data/ltf"));
542  fDataPathList.push_back(TString("/afs/psi.ch/project/bulkmusr/data/alc"));
543  }
544 
545  // check if any markers are given
546  if (fMarkerList.size() == 0) {
547  fMarkerList.push_back(24); // open circle
548  fMarkerList.push_back(25); // open square
549  fMarkerList.push_back(26); // open triangle
550  fMarkerList.push_back(27); // open diamond
551  fMarkerList.push_back(28); // open cross
552  fMarkerList.push_back(29); // full star
553  fMarkerList.push_back(30); // open star
554  fMarkerList.push_back(20); // full circle
555  fMarkerList.push_back(21); // full square
556  fMarkerList.push_back(22); // full triangle
557  fMarkerList.push_back(23); // full down triangle
558  fMarkerList.push_back(2); // thin cross
559  fMarkerList.push_back(3); // thin star
560  fMarkerList.push_back(5); // thin cross 45° rotated
561  }
562 
563  // check if any colors are given
564  if (fColorList.size() == 0) {
565  fColorList.push_back(TColor::GetColor(0, 0, 0)); // kBlack
566  fColorList.push_back(TColor::GetColor(255, 0, 0)); // kRed
567  fColorList.push_back(TColor::GetColor(0, 255, 0)); // kGreen
568  fColorList.push_back(TColor::GetColor(0, 0, 255)); // kBlue
569  fColorList.push_back(TColor::GetColor(255, 0, 255)); // kMagneta
570  fColorList.push_back(TColor::GetColor(0, 255, 255)); // kCyan
571  fColorList.push_back(TColor::GetColor(156, 0, 255)); // kViolette-3
572  fColorList.push_back(TColor::GetColor(99, 101, 49)); // kYellow-1
573  fColorList.push_back(TColor::GetColor(49, 101, 49)); // kGreen-1
574  fColorList.push_back(TColor::GetColor(156, 48, 0)); // kOrange-4
575  }
576 }
577 
578 //--------------------------------------------------------------------------
579 // StartupFileExists
580 //--------------------------------------------------------------------------
591 {
592  Bool_t result = false;
593 
594  std::ifstream ifile(fln);
595 
596  if (ifile.fail()) {
597  result = false;
598  } else {
599  result = true;
600  ifile.close();
601  }
602 
603  return result;
604 }
605 
606 //--------------------------------------------------------------------------
607 // WriteDefaultStartupFile
608 //--------------------------------------------------------------------------
610 {
611  // get home
612  Char_t startup_path_name[256];
613  Char_t *home = nullptr;
614  home = getenv("HOME");
615  if (home == nullptr) {
616  std::cerr << std::endl << "**ERROR** couldn't obtain $HOME." << std::endl;
617  return false;
618  }
619 
620  // first check that $HOME/.musrfit exists and if NOT create it
621  struct stat info;
622 
623  snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit", home);
624  if (!stat(startup_path_name, &info)) {
625  if (!(info.st_mode & S_IFDIR))
626  return false;
627  } else {
628  if (mkdir(startup_path_name, 0777)) {
629  std::cerr << std::endl << "**ERROR** couldn't create '" << startup_path_name << "'" << std::endl;
630  return false;
631  }
632  }
633 
634  // set path-name for musrfit_startup.xml
635  snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/musrfit_startup.xml", home);
636 
637  std::ofstream fout(startup_path_name, std::ofstream::out);
638  if (!fout.is_open()) {
639  std::cerr << std::endl << "**ERROR** couldn't open '" << startup_path_name << "' for writing." << std::endl;
640  return false;
641  }
642 
643  // write default musrfit_startup.xml
644  fout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
645  fout << "<musrfit xmlns=\"http://lmu.web.psi.ch/musrfit/user/MUSR/WebHome.html\">" << std::endl;
646  fout << " <comment>" << std::endl;
647  fout << " Defines default settings for the musrfit package" << std::endl;
648  fout << " </comment>" << std::endl;
649  fout << " <data_path>/afs/psi.ch/project/nemu/data/his</data_path>" << std::endl;
650  fout << " <data_path>/afs/psi.ch/project/nemu/data/wkm</data_path>" << std::endl;
651  fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/gps</data_path>" << std::endl;
652  fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/dolly</data_path>" << std::endl;
653  fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/gpd</data_path>" << std::endl;
654  fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/ltf</data_path>" << std::endl;
655  fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/alc</data_path>" << std::endl;
656  fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/hifi</data_path>" << std::endl;
657  fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/lem</data_path>" << std::endl;
658  fout << " <data_path>/afs/psi.ch/project/bulkmusr/data/flame</data_path>" << std::endl;
659  fout << " <!-- Dolly/PSI -->" << std::endl;
660  fout << " <run_name_template inst=\"dolly\">d%yyyy%/pie1/deltat_flc_%rrrr%.bin</run_name_template>" << std::endl;
661  fout << " <run_name_template inst=\"dolly\">d%yyyy%/pie3/deltat_flc_%rrrr%.bin</run_name_template>" << std::endl;
662  fout << " <run_name_template inst=\"dolly\">d%yyyy%/deltat_flc_%rrrr%.bin</run_name_template>" << std::endl;
663  fout << " <run_name_template inst=\"dolly\">d%yyyy%/deltat_pta_dolly_%rrrr%.bin</run_name_template>" << std::endl;
664  fout << " <run_name_template inst=\"dolly\">d%yyyy%/pta/deltat_pta_dolly_%rrrr%.bin</run_name_template>" << std::endl;
665  fout << " <run_name_template inst=\"dolly\">d%yyyy%/pta/deltat_pta_dolly_%rrrr%.bin</run_name_template>" << std::endl;
666  fout << " <run_name_template inst=\"dolly\">d%yyyy%/tdc/deltat_tdc_dolly_%rrrr%.bin</run_name_template>" << std::endl;
667  fout << " <run_name_template inst=\"dolly\">d%yyyy%/tdc/root/deltat_tdc_dolly_%rrrr%.root</run_name_template>" << std::endl;
668  fout << " <run_name_template inst=\"dolly\">d%yyyy%/tdc/mdu/deltat_tdc_dolly_%rrrr%.mdu</run_name_template>" << std::endl;
669  fout << " <!-- Flame/PSI -->" << std::endl;
670  fout << " <run_name_template inst=\"flame\">d%yyyy%/tdc/root/deltat_tdc_flame_%yyyy%_%rrrr%.root</run_name_template>" << std::endl;
671  fout << " <run_name_template inst=\"flame\">d%yyyy%/tdc/deltat_tdc_flame_%rrrr%.bin</run_name_template>" << std::endl;
672  fout << " <run_name_template inst=\"flame\">d%yyyy%/tdc/mdu/deltat_tdc_flame_%yyyy%_%rrrr%.mdu</run_name_template>" << std::endl;
673  fout << " <!-- GPD/PSI -->" << std::endl;
674  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_mue1_%rrrr%.bin</run_name_template>" << std::endl;
675  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_fq_si_%rrrr%.bin</run_name_template>" << std::endl;
676  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_strobo_%rrrr%.bin</run_name_template>" << std::endl;
677  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_hp_ni_ht_%rrrr%.bin</run_name_template>" << std::endl;
678  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_hp_ni_%rrrr%.bin</run_name_template>" << std::endl;
679  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_ccr2_%rrrr%.bin</run_name_template>" << std::endl;
680  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_gpd_%rrrr%.bin</run_name_template>" << std::endl;
681  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_janis_%rrrr%.bin</run_name_template>" << std::endl;
682  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_janis_gpd_%rrrr%.bin</run_name_template>" << std::endl;
683  fout << " <run_name_template inst=\"gpd\">d%yyyy%/deltat_pta_gpd_%rrrr%.bin</run_name_template>" << std::endl;
684  fout << " <run_name_template inst=\"gpd\">d%yyyy%/tdc/deltat_tdc_gpd_%rrrr%.bin</run_name_template>" << std::endl;
685  fout << " <run_name_template inst=\"gpd\">d%yyyy%/tdc/root/deltat_tdc_gpd_%rrrr%.root</run_name_template>" << std::endl;
686  fout << " <run_name_template inst=\"gpd\">d%yyyy%/tdc/mdu/deltat_tdc_gpd_%rrrr%.mdu</run_name_template>" << std::endl;
687  fout << " <!-- GPS/PSI -->" << std::endl;
688  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_ccr_%rrrr%.bin</run_name_template>" << std::endl;
689  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_he3_%rrrr%.bin</run_name_template>" << std::endl;
690  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_stutt_%rrrr%.bin</run_name_template>" << std::endl;
691  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_ltf_%rrrr%.bin</run_name_template>" << std::endl;
692  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_flc_%rrrr%.bin</run_name_template>" << std::endl;
693  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_flc2_%rrrr%.bin</run_name_template>" << std::endl;
694  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_oven_%rrrr%.bin</run_name_template>" << std::endl;
695  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_oven2_%rrrr%.bin</run_name_template>" << std::endl;
696  fout << " <run_name_template inst=\"gps\">d%yyyy%/deltat_pta_gps_%rrrr%.bin</run_name_template>" << std::endl;
697  fout << " <run_name_template inst=\"gps\">d%yyyy%/tdc/deltat_tdc_gps_%rrrr%.bin</run_name_template>" << std::endl;
698  fout << " <run_name_template inst=\"gps\">d%yyyy%/tdc/root/deltat_tdc_gps_%yyyy%_%rrrr%.root</run_name_template>" << std::endl;
699  fout << " <run_name_template inst=\"gps\">d%yyyy%/tdc/mdu/deltat_tdc_gps_%yyyy%_%rrrr%.mdu</run_name_template>" << std::endl;
700  fout << " <!-- HAL-9500/PSI == HIFI/PSI -->" << std::endl;
701  fout << " <run_name_template inst=\"hifi\">d%yyyy%/tdc/deltat_hifi_%rrrr%.bin</run_name_template>" << std::endl;
702  fout << " <run_name_template inst=\"hifi\">d%yyyy%/tdc/tdc_hifi_%yyyy%_%rrrrr%.mdu</run_name_template>" << std::endl;
703  fout << " <run_name_template inst=\"hifi\">d%yyyy%/tdc/root/deltat_tdc_hifi_%yyyy%_%rrrr%.mdu</run_name_template>" << std::endl;
704  fout << " <!-- LTF/PSI -->" << std::endl;
705  fout << " <run_name_template inst=\"ltf\">d%yyyy%/deltat_ltf_%rrrr%.bin</run_name_template>" << std::endl;
706  fout << " <run_name_template inst=\"ltf\">d%yyyy%/deltat_pta_ltf_%rrrr%.bin</run_name_template>" << std::endl;
707  fout << " <run_name_template inst=\"ltf\">d%yyyy%/pta/deltat_pta_ltf_%rrrr%.bin</run_name_template>" << std::endl;
708  fout << " <run_name_template inst=\"ltf\">d%yyyy%/tdc/deltat_tdc_ltf_%rrrr%.bin</run_name_template>" << std::endl;
709  fout << " <!-- LEM/PSI -->" << std::endl;
710  fout << " <run_name_template inst=\"lem\">%yyyy%/lem%yy%_his_%rrrr%.root</run_name_template>" << std::endl;
711  fout << " <run_name_template inst=\"lem\">d%yyyy%/tdc/lem%yy%_his_%rrrr%.root</run_name_template>" << std::endl;
712  fout << " <run_name_template inst=\"lem\">%yyyy%/lem%yy%_his_%rrrrr%.root</run_name_template>" << std::endl;
713  fout << " <run_name_template inst=\"lem\">d%yyyy%/tdc/lem%yy%_his_%rrrrr%.root</run_name_template>" << std::endl;
714  fout << " <fourier_settings>" << std::endl;
715  fout << " <units>Gauss</units>" << std::endl;
716  fout << " <fourier_power>0</fourier_power>" << std::endl;
717  fout << " <apodization>none</apodization>" << std::endl;
718  fout << " <plot>real_and_imag</plot>" << std::endl;
719  fout << " <phase>0.0</phase>" << std::endl;
720  fout << " <phase_increment>1.0</phase_increment>" << std::endl;
721  fout << " </fourier_settings>" << std::endl;
722  fout << " <root_settings>" << std::endl;
723  fout << " <marker_list>" << std::endl;
724  fout << " <!-- Root marker numbers -->" << std::endl;
725  fout << " <marker>24</marker> <!-- open circle -->" << std::endl;
726  fout << " <marker>25</marker> <!-- open square -->" << std::endl;
727  fout << " <marker>26</marker> <!-- open triangle -->" << std::endl;
728  fout << " <marker>27</marker> <!-- open diamond -->" << std::endl;
729  fout << " <marker>28</marker> <!-- open cross -->" << std::endl;
730  fout << " <marker>29</marker> <!-- full star -->" << std::endl;
731  fout << " <marker>30</marker> <!-- open star -->" << std::endl;
732  fout << " <marker>20</marker> <!-- full circle -->" << std::endl;
733  fout << " <marker>21</marker> <!-- full square -->" << std::endl;
734  fout << " <marker>22</marker> <!-- full triangle -->" << std::endl;
735  fout << " <marker>23</marker> <!-- full triangle down -->" << std::endl;
736  fout << " <marker>2</marker> <!-- thin cross -->" << std::endl;
737  fout << " <marker>3</marker> <!-- thin star -->" << std::endl;
738  fout << " <marker>5</marker> <!-- thin x -->" << std::endl;
739  fout << " </marker_list>" << std::endl;
740  fout << " <color_list>" << std::endl;
741  fout << " <!-- Color as RGB coded string -->" << std::endl;
742  fout << " <color>0,0,0</color> <!-- kBlack -->" << std::endl;
743  fout << " <color>255,0,0</color> <!-- kRed -->" << std::endl;
744  fout << " <color>0,255,0</color> <!-- kGreen -->" << std::endl;
745  fout << " <color>0,0,255</color> <!-- kBlue -->" << std::endl;
746  fout << " <color>255,0,255</color> <!-- kMagenta -->" << std::endl;
747  fout << " <color>0,255,255</color> <!-- kCyan -->" << std::endl;
748  fout << " <color>153,0,255</color> <!-- kViolet-3 -->" << std::endl;
749  fout << " <color>102,102,51</color> <!-- kYellow-1 -->" << std::endl;
750  fout << " <color>51,102,51</color> <!-- kGreen-1 -->" << std::endl;
751  fout << " <color>153,0,0</color> <!-- kRed+2 -->" << std::endl;
752  fout << " </color_list>" << std::endl;
753  fout << " </root_settings>" << std::endl;
754  fout << "</musrfit>" << std::endl;
755 
756  fout.close();
757 
758  return true;
759 }
760 
761 // -------------------------------------------------------------------------
762 // end
763 // -------------------------------------------------------------------------
764 
Double_t fPhaseIncrement
phase increment for manual phase optimization
Definition: PMusr.h:772
virtual void OnEndElement(const Char_t *)
TString fStartupFilePath
full musrfit_startup.xml startup file paths
PRunNameTemplateList fRunNameTemplate
run name template vector
virtual void OnFatalError(const Char_t *)
#define FOURIER_APOD_WEAK
Definition: PMusr.h:139
Bool_t WriteDefaultStartupFile()
Bool_t fFourierBlockPresent
flag indicating if a Fourier block is present in the msr-file
Definition: PMusr.h:761
Bool_t StartupFileExists(Char_t *fln)
ClassImpQ(PStartupHandler) int parseXmlFile(TSAXParser *saxParser
Int_t fPlotTag
tag used for initial plot. 0=real, 1=imaginary, 2=real & imaginary (default), 3=power, 4=phase
Definition: PMusr.h:766
virtual void OnComment(const Char_t *)
TString instrument
Definition: PMusr.h:883
#define FOURIER_PLOT_POWER
Definition: PMusr.h:147
int parseXmlFile(TSAXParser *, const char *)
#define FOURIER_PLOT_IMAG
Definition: PMusr.h:145
virtual void OnCharacters(const Char_t *)
#define FOURIER_PLOT_REAL
Definition: PMusr.h:144
char * xmlBuffer
#define FOURIER_UNIT_CYCLES
Definition: PMusr.h:135
#define FOURIER_PLOT_REAL_AND_IMAG
Definition: PMusr.h:146
PIntVector fMarkerList
marker list
#define FOURIER_UNIT_FREQ
Definition: PMusr.h:134
Int_t fApodization
tag indicating the kind of apodization wished, 0=no appodization (default), 1=weak, 2=medium, 3=strong (for details see the docu)
Definition: PMusr.h:765
virtual void OnEndDocument()
PIntVector fColorList
color list
const char * startup_path_name
PMsrFourierStructure fFourierDefaults
Fourier defaults.
PStringVector fDataPathList
search data path list
Double_t fRangeForPhaseCorrection[2]
field/frequency range for automatic phase correction
Definition: PMusr.h:770
PDoubleVector fPhase
phase(s)
Definition: PMusr.h:769
virtual void OnError(const Char_t *)
TString fCurrentInstrumentName
current instrument name
Bool_t fStartupFileFound
startup file found flag
virtual void OnStartDocument()
Int_t fUnits
flag used to indicate the units. 1=field units (G); 2=field units (T); 3=frequency units (MHz); 4=Mc/...
Definition: PMusr.h:762
std::fstream xmlFile
#define FOURIER_APOD_NONE
Definition: PMusr.h:138
virtual void CheckLists()
#define FOURIER_PLOT_PHASE
Definition: PMusr.h:148
#define FOURIER_UNIT_GAUSS
Definition: PMusr.h:132
#define FOURIER_UNIT_TESLA
Definition: PMusr.h:133
virtual void OnStartElement(const Char_t *, const TList *)
Int_t fFourierPower
i.e. zero padding up to 2^fFourierPower, default = 0 which means NO zero padding
Definition: PMusr.h:764
#define FOURIER_APOD_STRONG
Definition: PMusr.h:141
EKeyWords fKey
xml filter key
return status
Double_t fPlotRange[2]
field/frequency plot range
Definition: PMusr.h:771
virtual ~PStartupHandler()
#define FOURIER_APOD_MEDIUM
Definition: PMusr.h:140
virtual void OnWarning(const Char_t *)
TString runNameTemplate
Definition: PMusr.h:884
unsigned int xmlSize
virtual void OnCdataBlock(const Char_t *, Int_t)