30 #include <sys/types.h> 37 #include <TObjArray.h> 38 #include <TObjString.h> 72 xmlFile.seekg(0, std::ios::beg);
100 Char_t *pmusrpath=
nullptr;
101 Char_t *home=
nullptr;
102 Char_t musrpath[128];
105 strncpy(musrpath,
"",
sizeof(musrpath));
115 home = getenv(
"HOME");
116 if (home !=
nullptr) {
126 pmusrpath = getenv(
"MUSRFITPATH");
127 if (pmusrpath !=
nullptr) {
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;
150 std::cout << std::endl <<
"**INFO** no musrfit_startup.xml file found, will write a default one." << std::endl;
152 std::cerr << std::endl <<
"**ERROR** couldn't write default musrfit_startup.xml." << std::endl;
154 home = getenv(
"HOME");
155 if (home !=
nullptr) {
228 if (!strcmp(str,
"data_path")) {
230 }
else if (!strcmp(str,
"run_name_template")) {
233 TIter next(attributes);
234 while ((attr = (TXMLAttr*) next())) {
235 if (!strcmp(attr->GetName(),
"inst")) {
239 }
else if (!strcmp(str,
"marker")) {
241 }
else if (!strcmp(str,
"color")) {
243 }
else if (!strcmp(str,
"units")) {
245 }
else if (!strcmp(str,
"fourier_power")) {
247 }
else if (!strcmp(str,
"apodization")) {
249 }
else if (!strcmp(str,
"plot")) {
251 }
else if (!strcmp(str,
"phase")) {
253 }
else if (!strcmp(str,
"phase_increment")) {
285 Int_t color, r, g, b, ival;
303 if (tstr.IsDigit()) {
307 std::cerr << std::endl <<
"PStartupHandler **WARNING** '" << str <<
"' is not a number, will ignore it";
308 std::cerr << std::endl;
314 tokens = tstr.Tokenize(
",");
317 std::cerr << std::endl <<
"PStartupHandler **WARNING** '" << str <<
"' is not a rbg code, will ignore it";
318 std::cerr << std::endl;
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;
328 ostr =
dynamic_cast<TObjString*
>(tokens->At(0));
329 tstr = ostr->GetString();
330 if (tstr.IsDigit()) {
333 std::cerr << std::endl <<
"PStartupHandler **WARNING** r within the rgb code is not a number, will ignore it";
334 std::cerr << std::endl;
338 ostr =
dynamic_cast<TObjString*
>(tokens->At(1));
339 tstr = ostr->GetString();
340 if (tstr.IsDigit()) {
343 std::cerr << std::endl <<
"PStartupHandler **WARNING** g within the rgb code is not a number, will ignore it";
344 std::cerr << std::endl;
348 ostr =
dynamic_cast<TObjString*
>(tokens->At(2));
349 tstr = ostr->GetString();
350 if (tstr.IsDigit()) {
353 std::cerr << std::endl <<
"PStartupHandler **WARNING** b within the rgb code is not a number, will ignore it";
354 std::cerr << std::endl;
363 color = TColor::GetColor(r,g,b);
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)) {
378 std::cerr << std::endl <<
"PStartupHandler **WARNING** '" << str <<
"' is not a valid unit, will ignore it.";
379 std::cerr << std::endl;
384 if (tstr.IsDigit()) {
386 if ((ival >= 0) && (ival <= 20)) {
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;
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;
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)) {
408 std::cerr << std::endl <<
"PStartupHandler **WARNING** '" << str <<
"' is not a valid apodization, will ignore it.";
409 std::cerr << std::endl;
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)) {
425 std::cerr << std::endl <<
"PStartupHandler **WARNING** '" << str <<
"' is not a valid plot option, will ignore it.";
426 std::cerr << std::endl;
431 if (tstr.IsFloat()) {
434 std::cerr << std::endl <<
"PStartupHandler **WARNING** '" << str <<
"' is not a valid phase, will ignore it.";
435 std::cerr << std::endl;
440 if (tstr.IsFloat()) {
443 std::cerr << std::endl <<
"PStartupHandler **WARNING** '" << str <<
"' is not a valid phase increment, will ignore it.";
444 std::cerr << std::endl;
475 std::cerr << std::endl <<
"PStartupHandler **WARNING** " << str;
476 std::cerr << std::endl;
489 std::cerr << std::endl <<
"PStartupHandler **ERROR** " << str;
490 std::cerr << std::endl;
503 std::cerr << std::endl <<
"PStartupHandler **FATAL ERROR** " << str;
504 std::cerr << std::endl;
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"));
565 fColorList.push_back(TColor::GetColor(0, 0, 0));
566 fColorList.push_back(TColor::GetColor(255, 0, 0));
567 fColorList.push_back(TColor::GetColor(0, 255, 0));
568 fColorList.push_back(TColor::GetColor(0, 0, 255));
569 fColorList.push_back(TColor::GetColor(255, 0, 255));
570 fColorList.push_back(TColor::GetColor(0, 255, 255));
571 fColorList.push_back(TColor::GetColor(156, 0, 255));
572 fColorList.push_back(TColor::GetColor(99, 101, 49));
573 fColorList.push_back(TColor::GetColor(49, 101, 49));
574 fColorList.push_back(TColor::GetColor(156, 48, 0));
592 Bool_t result =
false;
594 std::ifstream ifile(fln);
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;
625 if (!(info.st_mode & S_IFDIR))
629 std::cerr << std::endl <<
"**ERROR** couldn't create '" <<
startup_path_name <<
"'" << std::endl;
638 if (!fout.is_open()) {
639 std::cerr << std::endl <<
"**ERROR** couldn't open '" <<
startup_path_name <<
"' for writing." << std::endl;
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;
Double_t fPhaseIncrement
phase increment for manual phase optimization
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
Bool_t WriteDefaultStartupFile()
Bool_t fFourierBlockPresent
flag indicating if a Fourier block is present in the msr-file
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
virtual void OnComment(const Char_t *)
#define FOURIER_PLOT_POWER
int parseXmlFile(TSAXParser *, const char *)
#define FOURIER_PLOT_IMAG
virtual void OnCharacters(const Char_t *)
#define FOURIER_PLOT_REAL
#define FOURIER_UNIT_CYCLES
#define FOURIER_PLOT_REAL_AND_IMAG
PIntVector fMarkerList
marker list
#define FOURIER_UNIT_FREQ
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)
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
PDoubleVector fPhase
phase(s)
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/...
#define FOURIER_APOD_NONE
virtual void CheckLists()
#define FOURIER_PLOT_PHASE
#define FOURIER_UNIT_GAUSS
#define FOURIER_UNIT_TESLA
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
#define FOURIER_APOD_STRONG
EKeyWords fKey
xml filter key
Double_t fPlotRange[2]
field/frequency plot range
virtual ~PStartupHandler()
#define FOURIER_APOD_MEDIUM
virtual void OnWarning(const Char_t *)
virtual void OnCdataBlock(const Char_t *, Int_t)