musrfit 1.10.0
musrFT.cpp
Go to the documentation of this file.
1/***************************************************************************
2
3 musrFT.cpp
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-2026 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#ifdef HAVE_CONFIG_H
31#include "config.h"
32#endif
33
34#include <sys/time.h>
35
36#include <iostream>
37#include <fstream>
38#include <vector>
39#include <memory>
40
41#include <TApplication.h>
42#include <TROOT.h>
43#include <TString.h>
44#include <TObjArray.h>
45#include <TObjString.h>
46#include <TSAXParser.h>
47
48#ifdef HAVE_GIT_REV_H
49#include "git-revision.h"
50#endif
51
52#include "PMusr.h"
53#include "PStartupHandler.h"
54#include "PMsrHandler.h"
55#include "PRunDataHandler.h"
56#include "PPrepFourier.h"
57#include "PFourier.h"
58#include "PFourierCanvas.h"
59
60//----------------------------------------------------------------------------
89
90//-------------------------------------------------------------------------
95{
96 std::cout << std::endl << "usage: musrFT [Options] [<msr-files> | -df, --data-file <data-file>]";
97 std::cout << std::endl << " <msr-files> : msr-file name(s). These msr-files are used for the Fourier transform.";
98 std::cout << std::endl << " It can be a list of msr-files, e.g. musrFT 3110.msr 3111.msr";
99 std::cout << std::endl << " For the syntax of the msr-file check the user manual of musrfit.";
100 std::cout << std::endl << " -df, --data-file <data-file> : This allows to feed only muSR data file(s) to";
101 std::cout << std::endl << " perform the Fourier transform. Since the extended <msr-file> information";
102 std::cout << std::endl << " are missing, they will need to be provided by to options, or musrFT";
103 std::cout << std::endl << " tries to guess, based on musrfit_startup.xml settings.";
104 std::cout << std::endl << " Options: ";
105 std::cout << std::endl << " --help : display this help and exit";
106 std::cout << std::endl << " --version : output version information and exit";
107 std::cout << std::endl << " -g, --graphic-format <graphic-format-extension> : ";
108 std::cout << std::endl << " will produce a graphic-output-file without starting a root session.";
109 std::cout << std::endl << " the name is based either on the <msr-file> or the <data-file>,";
110 std::cout << std::endl << " e.g. 3310.msr -> 3310_0.png.";
111 std::cout << std::endl << " Supported graphic-format-extension: eps, pdf, gif, jpg, png, svg, xpm, root";
112 std::cout << std::endl << " --dump <fln> : rather than starting a root session and showing Fourier graphs of the data,";
113 std::cout << std::endl << " it will output the Fourier data in an ascii file <fln>.";
114 std::cout << std::endl << " -br, --background-range <start> <end>: background interval used to estimate the background to be";
115 std::cout << std::endl << " subtracted before the Fourier transform. <start>, <end> to be given in bins.";
116 std::cout << std::endl << " -bg, --background <list> : gives the background explicit for each histogram.";
117 std::cout << std::endl << " -fo, --fourier-option <fopt>: <fopt> can be 'real', 'imag', 'real+imag', 'power', 'phase', or 'phaseOptReal'.";
118 std::cout << std::endl << " If this is not defined (neither on the command line nor in the musrfit_startup.xml),";
119 std::cout << std::endl << " default will be 'power'.";
120 std::cout << std::endl << " -ap, --apodization <val> : <val> can be either 'none', 'weak', 'medium', 'strong'.";
121 std::cout << std::endl << " Default will be 'none'.";
122 std::cout << std::endl << " -fp, --fourier-power <N> : <N> being the Fourier power, i.e. 2^<N> used for zero padding.";
123 std::cout << std::endl << " Default is -1, i.e. no zero padding will be performed.";
124 std::cout << std::endl << " -u, --units <units> : <units> is used to define the x-axis of the Fourier transform.";
125 std::cout << std::endl << " One may choose between the fields (Gauss) or (Tesla), the frequency (MHz),";
126 std::cout << std::endl << " and the angular-frequency domain (Mc/s).";
127 std::cout << std::endl << " Default will be 'MHz'.";
128 std::cout << std::endl << " -ph, --phase <val> : defines the initial phase <val>. This only is of concern for 'real',";
129 std::cout << std::endl << " '<imag>', and 'real+imag'.";
130 std::cout << std::endl << " Default will be 0.0.";
131 std::cout << std::endl << " -fr, --fourier-range <start> <end> : Fourier range. <start>, <end> are interpreted in the units given.";
132 std::cout << std::endl << " Default will be -1.0 for both which means, take the full Fourier range.";
133 std::cout << std::endl << " -tr, --time-range <start> <end> : time domain range to be used for Fourier transform.";
134 std::cout << std::endl << " <start>, <end> are to be given in (us). If nothing is given, the full time range";
135 std::cout << std::endl << " found in the data file(s) will be used.";
136 std::cout << std::endl << " --histo <list> : give the <list> of histograms to be used for the Fourier transform.";
137 std::cout << std::endl << " E.g. musrFT -df lem15_his_01234.root --histo 1 3, will only be needed together with";
138 std::cout << std::endl << " the option --data-file. If multiple data file are given, <list> will apply";
139 std::cout << std::endl << " to all data-files given. If --histo is not given, all histos of a data file will be used.";
140 std::cout << std::endl << " <list> can be anything like: 2 3 6, or 2-17, or 1-6 9, etc.";
141 std::cout << std::endl << " -a, --average : show the average of ALL Fourier transformed data.";
142 std::cout << std::endl << " -ad, --average-per-data-set : show the average of the Fourier transformed data per data set.";
143 std::cout << std::endl << " --t0 <list> : A list of t0's can be provided. This in conjunction with --data-file and";
144 std::cout << std::endl << " --fourier-option real allows to get the proper initial phase if t0's are known.";
145 std::cout << std::endl << " If a single t0 for multiple histos is given, it is assume, that this t0 is common";
146 std::cout << std::endl << " to all histos.";
147 std::cout << std::endl << " Example: musrFT -df lem15_his_01234.root -fo real --t0 2750 --histo 1 3";
148 std::cout << std::endl << " -pa, --packing <N> : if <N> (an integer), the time domain data will first be packed/rebinned by <N>.";
149 std::cout << std::endl << " --title <title> : give a global title for the plot.";
150 std::cout << std::endl << " --create-msr-file <fln> : creates a msr-file based on the command line options";
151 std::cout << std::endl << " provided. This will help on the way to a full fitting model.";
152 std::cout << std::endl << " -lc, --lifetimecorrection <fudge>: try to eliminate muon life time decay. Only makes sense for low";
153 std::cout << std::endl << " transverse fields. <fudge> is a tweaking factor and should be kept around 1.0.";
154 std::cout << std::endl << " --timeout <timeout> : <timeout> given in seconds after which musrFT terminates.";
155 std::cout << std::endl << " If <timeout> <= 0, no timeout will take place. Default <timeout> is 3600.";
156 std::cout << std::endl << std::endl;
157}
158
159//-------------------------------------------------------------------------
166{
167 startupParam.graphicFormat = TString("");
168 startupParam.dumpFln = TString("");
169 startupParam.msrFlnOut = TString("");
170 startupParam.bkg_range[0] = -1;
171 startupParam.bkg_range[1] = -1;
172 startupParam.fourierOpt = TString("??");
173 startupParam.apodization = TString("none");
174 startupParam.fourierPower = -1;
175 startupParam.fourierUnits = TString("??");
176 startupParam.initialPhase = 0.0;
177 startupParam.fourierRange[0] = -1.0;
178 startupParam.fourierRange[1] = -1.0;
179 startupParam.timeRange[0] = -1.0;
180 startupParam.timeRange[1] = -1.0;
181 startupParam.showAverage = false;
182 startupParam.showAveragePerDataSet = false;
183 startupParam.packing = 1;
184 startupParam.title = TString("");
185 startupParam.lifetimecorrection = 0.0;
186 startupParam.timeout = 3600;
187}
188
189//-------------------------------------------------------------------------
205Bool_t musrFT_filter_histo(Int_t &i, Int_t argc, Char_t *argv[], musrFT_startup_param &startupParam)
206{
207 Int_t start = i+1, end = 0;
208
209 // find last element of histo option
210 while (++i < argc) {
211 if (argv[i][0] == '-') {
212 if (!isdigit(argv[i][1]) || (argv[i][1] == '-'))
213 break;
214 }
215 }
216 end = i;
217 --i;
218 if (end < start) {
219 std::cerr << std::endl << ">> musrFT **ERROR** something is wrong with the --histo arguments." << std::endl;
220 startupParam.histo.clear();
221 return false;
222 }
223
224 // handle histo arguments
225 TString tstr("");
226 for (Int_t j=start; j<end; j++) {
227 tstr = argv[j];
228 if (!tstr.Contains("-")) { // likely to be a single number
229 if (tstr.IsDigit()) {
230 startupParam.histo.push_back(tstr.Atoi());
231 } else { // not a number -> error
232 std::cerr << std::endl << ">> musrFT **ERROR** found --histo argument '" << tstr << "' which is not a number." << std::endl;
233 startupParam.histo.clear();
234 return false;
235 }
236 } else { // should be something like h0-hN with h0, hN numbers
237 TObjArray *tok = tstr.Tokenize("-");
238 if (tok->GetEntries() != 2) {
239 std::cerr << std::endl << ">> musrFT **ERROR** found --histo argument '" << tstr << "' which is not of the form <h0>-<hN>." << std::endl;
240 startupParam.histo.clear();
241 return false;
242 }
243 TObjString *ostr;
244 TString sstr("");
245 Int_t first=0, last=0;
246 ostr = dynamic_cast<TObjString*>(tok->At(0));
247 sstr = ostr->GetString();
248 if (sstr.IsDigit()) {
249 first = sstr.Atoi();
250 } else {
251 std::cerr << std::endl << ">> musrFT **ERROR** found --histo argument '" << tstr << "' which is of the form <h0>-<hN>,";
252 std::cerr << std::endl << " but <h0>='" << sstr << "' is not a number." << std::endl;
253 startupParam.histo.clear();
254 return false;
255 }
256 ostr = dynamic_cast<TObjString*>(tok->At(1));
257 sstr = ostr->GetString();
258 if (sstr.IsDigit()) {
259 last = sstr.Atoi();
260 } else {
261 std::cerr << std::endl << ">> musrFT **ERROR** found --histo argument '" << tstr << "' which is of the form <h0>-<hN>,";
262 std::cerr << std::endl << " but <hN>='" << sstr << "' is not a number." << std::endl;
263 startupParam.histo.clear();
264 return false;
265 }
266
267 if (first > last) {
268 std::cerr << std::endl << ">> musrFT **ERROR** found --histo argument of the form <h0>-<hN> with h0=" << first << " > hN=" << last << "." << std::endl;
269 startupParam.histo.clear();
270 return false;
271 }
272
273 for (Int_t k=first; k<=last; k++) {
274 startupParam.histo.push_back(k);
275 }
276
277 // clean up
278 if (tok)
279 delete tok;
280 }
281 }
282
283 return true;
284}
285
286//-------------------------------------------------------------------------
296Int_t musrFT_parse_options(Int_t argc, Char_t *argv[], musrFT_startup_param &startupParam)
297{
298 TString tstr("");
299
300 for (Int_t i=1; i<argc; i++) {
301 tstr = argv[i];
302 if (tstr.BeginsWith("--version")) {
303#ifdef HAVE_CONFIG_H
304#ifdef HAVE_GIT_REV_H
305 std::cout << std::endl << "musrFT version: " << PACKAGE_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
306#else
307 std::cout << std::endl << "musrFT version: " << PACKAGE_VERSION << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
308#endif
309#else
310#ifdef HAVE_GIT_REV_H
311 std::cout << std::endl << "musrFT git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
312#else
313 std::cout << std::endl << "musrFT version: unknown." << std::endl << std::endl;
314#endif
315#endif
316 return 1;
317 } else if (tstr.BeginsWith("--help")) {
319 return 1;
320 } else if (tstr.BeginsWith("-g") || tstr.BeginsWith("--graphic-format")) {
321 if (i+1 >= argc) { // something is wrong since there needs to be an argument here
322 std::cerr << std::endl << ">> musrFT **ERROR** found option --graphic-format without argument!" << std::endl;
323 return 2;
324 }
325 TString topt(argv[i+1]);
326 if (!topt.BeginsWith("eps") && !topt.BeginsWith("pdf") && !topt.BeginsWith("gif") && !topt.BeginsWith("jpg") &&
327 !topt.BeginsWith("png") && !topt.BeginsWith("svg") && !topt.BeginsWith("xpm") && !topt.BeginsWith("root")) {
328 std::cerr << std::endl << ">> musrFT **ERROR** found unrecogniced graphic format '" << topt << "'!" << std::endl;
329 return 2;
330 }
331 startupParam.graphicFormat = topt;
332 i++;
333 } else if (tstr.BeginsWith("--dump")) {
334 if (i+1 >= argc) { // something is wrong since there needs to be an argument here
335 std::cerr << std::endl << ">> musrFT **ERROR** found option --dump without argument!" << std::endl;
336 return 2;
337 }
338 startupParam.dumpFln = argv[i+1];
339 i++;
340 } else if (tstr.Contains("-br") || tstr.Contains("--background-range")) {
341 if (i+2 >= argc) { // something is wrong since there needs to be two arguments here
342 std::cerr << std::endl << ">> musrFT **ERROR** found option --background-range with wrong number of arguments." << std::endl;
343 return 2;
344 }
345 TString bkgRange[2];
346 bkgRange[0] = argv[i+1];
347 bkgRange[1] = argv[i+2];
348 if (!bkgRange[0].IsDigit()) {
349 std::cerr << std::endl << ">> musrFT **ERROR** <start> bin of option --background-range is NOT an int-number! ('" << bkgRange[0] << "')." << std::endl;
350 return 2;
351 }
352 if (!bkgRange[1].IsDigit()) {
353 std::cerr << std::endl << ">> musrFT **ERROR** <end> bin of option --background-range is NOT an int-number! ('" << bkgRange[1] << "')." << std::endl;
354 return 2;
355 }
356 startupParam.bkg_range[0] = bkgRange[0].Atoi();
357 startupParam.bkg_range[1] = bkgRange[1].Atoi();
358 i += 2;
359 } else if (tstr.BeginsWith("-bg") || !tstr.CompareTo("--background")) {
360 TString topt("");
361 while (++i < argc) {
362 if (argv[i][0] == '-') {
363 --i;
364 break;
365 } else {
366 topt = argv[i];
367 if (!topt.IsFloat()) {
368 std::cerr << std::endl << ">> musrFT **ERROR** found option --background='" << topt << "' which is not a float" << std::endl;
369 return 2;
370 }
371 startupParam.bkg.push_back(topt.Atoi());
372 }
373 }
374 if (startupParam.bkg.size() == 0) { // something is wrong since there needs to be an argument here
375 std::cerr << std::endl << ">> musrFT **ERROR** found option --background without argument!" << std::endl;
376 return 2;
377 }
378 } else if (tstr.BeginsWith("-fo") || tstr.BeginsWith("--fourier-option")) {
379 if (i+1 >= argc) { // something is wrong since there needs to be two arguments here
380 std::cerr << std::endl << ">> musrFT **ERROR** found option --fourier-option without arguments." << std::endl;
381 return 2;
382 }
383 TString topt(argv[i+1]);
384 if (!topt.BeginsWith("real") && !topt.BeginsWith("imag") && !topt.BeginsWith("power") &&
385 !topt.BeginsWith("phase") && !topt.BeginsWith("phaseOptReal")) {
386 std::cerr << std::endl << ">> musrFT **ERROR** found option --fourier-option with unrecognized argument '" << topt << "'." << std::endl;
387 return 2;
388 }
389 startupParam.fourierOpt = topt;
390 i++;
391 } else if (tstr.BeginsWith("-ap") || tstr.BeginsWith("--apodization")) {
392 if (i+1 >= argc) { // something is wrong since there needs to be two arguments here
393 std::cerr << std::endl << ">> musrFT **ERROR** found option --apodization without arguments." << std::endl;
394 return 2;
395 }
396 TString topt(argv[i+1]);
397 if (!topt.BeginsWith("none") && !topt.BeginsWith("weak") && !topt.BeginsWith("medium") && !topt.BeginsWith("strong")) {
398 std::cerr << std::endl << ">> musrFT **ERROR** found option --apodization with unrecognized argument '" << topt << "'." << std::endl;
399 return 2;
400 }
401 startupParam.apodization = topt;
402 i++;
403 } else if (tstr.BeginsWith("-fp") || tstr.BeginsWith("--fourier-power")) {
404 if (i+1 >= argc) { // something is wrong since there needs to be two arguments here
405 std::cerr << std::endl << ">> musrFT **ERROR** found option --fourier-power without arguments." << std::endl;
406 return 2;
407 }
408 TString fourierPower(argv[i+1]);
409 if (!fourierPower.IsDigit()) {
410 std::cerr << std::endl << ">> musrFT **ERROR** found option --fourier-power with a power which is not an integer '" << fourierPower << "'." << std::endl;
411 return 2;
412 }
413 startupParam.fourierPower = fourierPower.Atoi();
414 if ((startupParam.fourierPower < 1) || (startupParam.fourierPower > 20)) {
415 std::cerr << std::endl << ">> musrFT **ERROR** found Fourier power '" << fourierPower << "', which is out of range [1..20]" << std::endl;
416 return 2;
417 }
418 i++;
419 } else if (tstr.BeginsWith("-u") || tstr.BeginsWith("--units")) {
420 if (i+1 >= argc) { // something is wrong since there needs to be two arguments here
421 std::cerr << std::endl << ">> musrFT **ERROR** found option --units without arguments." << std::endl;
422 return 2;
423 }
424 TString topt(argv[i+1]);
425 if (!topt.BeginsWith("MHz", TString::kIgnoreCase) && !topt.BeginsWith("Gauss", TString::kIgnoreCase) &&
426 !topt.BeginsWith("Tesla", TString::kIgnoreCase) && !topt.BeginsWith("Mc/s", TString::kIgnoreCase)) {
427 std::cerr << std::endl << ">> musrFT **ERROR** found option --fourier-option with unrecognized argument '" << topt << "'." << std::endl;
428 return 2;
429 }
430 startupParam.fourierUnits = topt;
431 i++;
432 } else if (tstr.BeginsWith("-ph") || tstr.BeginsWith("--phase")) {
433 if (i+1 >= argc) { // something is wrong since there needs to be an argument here
434 std::cerr << std::endl << ">> musrFT **ERROR** found option --phase without argument!" << std::endl;
435 return 2;
436 }
437 TString phase(argv[i+1]);
438 if (!phase.IsFloat()) {
439 std::cerr << std::endl << ">> musrFT **ERROR** found --phase argument '" << phase << "' which is not a number." << std::endl;
440 return 2;
441 }
442 startupParam.initialPhase = phase.Atof();
443 i++;
444 } else if (tstr.BeginsWith("-fr") || tstr.BeginsWith("--fourier-range")) {
445 if (i+2 >= argc) { // something is wrong since there needs to be an argument here
446 std::cerr << std::endl << ">> musrFT **ERROR** found option --fourier-range with wrong number of arguments!" << std::endl;
447 return 2;
448 }
449 TString fourierRange[2] = {argv[i+1], argv[i+2]};
450 if (!fourierRange[0].IsFloat() || !fourierRange[1].IsFloat()) {
451 std::cerr << std::endl << ">> musrFT **ERROR** found invalid --fourier-range arguments '" << fourierRange[0] << "' and/or '" << fourierRange[1] << "'." << std::endl;
452 return 2;
453 }
454 startupParam.fourierRange[0] = fourierRange[0].Atof();
455 startupParam.fourierRange[1] = fourierRange[1].Atof();
456 i += 2;
457 } else if (tstr.BeginsWith("-tr") || tstr.BeginsWith("--time-range")) {
458 if (i+2 >= argc) { // something is wrong since there needs to be an argument here
459 std::cerr << std::endl << ">> musrFT **ERROR** found option --time-range with wrong number of arguments!" << std::endl;
460 return 2;
461 }
462 TString timeRange[2] = {argv[i+1], argv[i+2]};
463 if (!timeRange[0].IsFloat() || !timeRange[1].IsFloat()) {
464 std::cerr << std::endl << ">> musrFT **ERROR** found invalid --time-range arguments '" << timeRange[0] << "' and/or '" << timeRange[1] << "'." << std::endl;
465 return 2;
466 }
467 startupParam.timeRange[0] = timeRange[0].Atof();
468 startupParam.timeRange[1] = timeRange[1].Atof();
469 i += 2;
470 } else if (!tstr.CompareTo("-a") || !tstr.CompareTo("--average")) {
471 startupParam.showAverage = true;
472 } else if (!tstr.CompareTo("-ad") || !tstr.CompareTo("--average-per-data-set")) {
473 startupParam.showAveragePerDataSet = true;
474 } else if (tstr.BeginsWith("--histo")) {
475 if (!musrFT_filter_histo(i, argc, argv, startupParam))
476 return 2;
477 } else if (tstr.BeginsWith("--t0")) {
478 TString topt("");
479 while (++i < argc) {
480 if (argv[i][0] == '-') {
481 --i;
482 break;
483 } else {
484 topt = argv[i];
485 if (!topt.IsDigit()) {
486 std::cerr << std::endl << ">> musrFT **ERROR** found option t0='" << topt << "' which is not a number" << std::endl;
487 return 2;
488 }
489 startupParam.t0.push_back(topt.Atoi());
490 }
491 }
492 if (startupParam.t0.size() == 0) { // something is wrong since there needs to be an argument here
493 std::cerr << std::endl << ">> musrFT **ERROR** found option --t0 without argument!" << std::endl;
494 return 2;
495 }
496 } else if (tstr.BeginsWith("--title")) {
497 if (i+1 >= argc) { // something is wrong since there needs to be an argument here
498 std::cerr << std::endl << ">> musrFT **ERROR** found option --title without argument!" << std::endl;
499 return 2;
500 }
501 ++i;
502 startupParam.title = argv[i];
503 } else if (tstr.BeginsWith("-pa") || tstr.BeginsWith("--packing")) {
504 if (i+1 >= argc) { // something is wrong since there needs to be an argument here
505 std::cerr << std::endl << ">> musrFT **ERROR** found option --packing without argument!" << std::endl;
506 return 2;
507 }
508 ++i;
509 TString pack = TString(argv[i]);
510 if (!pack.IsDigit()) {
511 std::cerr << std::endl << ">> musrFT **ERROR** found option --packing with argument '" << pack << "' which is NOT an integer!" << std::endl;
512 return 2;
513 }
514 startupParam.packing = pack.Atoi();
515 } else if (tstr.BeginsWith("--create-msr-file")) {
516 if (i+1 >= argc) { // something is wrong since there needs to be an argument here
517 std::cerr << std::endl << ">> musrFT **ERROR** found option --create-msr-file without argument!" << std::endl;
518 return 2;
519 }
520 ++i;
521 startupParam.msrFlnOut = TString(argv[i]);
522 } else if (tstr.BeginsWith("-lc") || tstr.BeginsWith("--lifetimecorrection")) {
523 if (i+1 >= argc) { // something is wrong since there needs to be an argument here
524 std::cerr << std::endl << ">> musrFT **ERROR** found option --lifetimecorrection without argument!" << std::endl;
525 return 2;
526 }
527 ++i;
528 TString fudge(argv[i]);
529 if (!fudge.IsFloat()) {
530 std::cerr << std::endl << ">> musrFT **ERROR** found option --lifetimecorrection with a fudge which is not a double '" << fudge << "'." << std::endl;
531 return 2;
532 }
533 startupParam.lifetimecorrection = fudge.Atof();
534 } else if (tstr.BeginsWith("--timeout")) {
535 if (i+1 >= argc) { // something is wrong since there needs to be an argument here
536 std::cerr << std::endl << ">> musrFT **ERROR** found option --timeout without argument!" << std::endl;
537 return 2;
538 }
539 ++i;
540 TString tt(argv[i]);
541 if (!tt.IsDigit()) {
542 std::cerr << std::endl << ">> musrFT **ERROR** found option --timeout with a <timeout> which is not an integer '" << tt << "'." << std::endl;
543 return 2;
544 }
545 startupParam.timeout = tt.Atoi();
546 } else if (tstr.BeginsWith("-df") || tstr.BeginsWith("--data-file")) {
547 while (++i < argc) {
548 if (argv[i][0] == '-') {
549 --i;
550 break;
551 } else {
552 startupParam.dataFln.push_back(argv[i]);
553 TString fln(argv[i]);
554 TString fileFormat("??");
555 if (fln.Contains(".root", TString::kIgnoreCase))
556 fileFormat = "MusrRoot";
557 else if (fln.Contains(".bin", TString::kIgnoreCase))
558 fileFormat = "PsiBin";
559 else if (fln.Contains(".mdu", TString::kIgnoreCase))
560 fileFormat = "PsiMdu";
561 else if (fln.Contains(".nxs", TString::kIgnoreCase))
562 fileFormat = "NeXus";
563 else if (fln.Contains(".msr", TString::kIgnoreCase))
564 fileFormat = "Mud";
565
566 if (fileFormat == "??") {
567 std::cerr << std::endl << ">> musrFT **ERROR** found data file name with unrecognized data file format ('" << fln << "')." << std::endl;
568 return 2;
569 } else {
570 startupParam.dataFileFormat.push_back(fileFormat);
571 }
572 }
573 }
574 if (startupParam.dataFln.size() == 0) { // something is wrong since there needs to be an argument here
575 std::cerr << std::endl << ">> musrFT **ERROR** found option --data-file without argument!" << std::endl;
576 return 2;
577 }
578 } else if (tstr.Contains(".msr")) {
579 startupParam.msrFln.push_back(tstr);
580 } else {
581 std::cerr << std::endl << ">> musrFT **ERROR** unrecognized option '" << tstr << "' found." << std::endl;
582 return 2;
583 }
584 }
585
586 // consistency checks
587 if ((startupParam.msrFln.size() == 0) && (startupParam.dataFln.size() == 0)) {
588 std::cerr << std::endl << ">> musrFT **ERROR** neither <msr-file> nor <data-file> defined." << std::endl;
589 return 2;
590 }
591 if (startupParam.bkg_range[0] > startupParam.bkg_range[1]) {
592 std::cerr << std::endl << ">> musrFT **WARNING** in --background-range, start=" << startupParam.bkg_range[0] << " > end=" << startupParam.bkg_range[1] << ", will swap them." << std::endl;
593 Double_t swap = startupParam.bkg_range[0];
594 startupParam.bkg_range[0] = startupParam.bkg_range[1];
595 startupParam.bkg_range[1] = swap;
596 }
597 if (startupParam.fourierRange[0] > startupParam.fourierRange[1]) {
598 std::cerr << std::endl << ">> musrFT **WARNING** in --fourier-range, start=" << startupParam.fourierRange[0] << " > end=" << startupParam.fourierRange[1] << ", will swap them." << std::endl;
599 Double_t swap = startupParam.fourierRange[0];
600 startupParam.fourierRange[0] = startupParam.fourierRange[1];
601 startupParam.fourierRange[1] = swap;
602 }
603 if (startupParam.showAverage && startupParam.showAveragePerDataSet) {
604 std::cerr << std::endl << ">> musrFT **WARNING** Options: --average and --average-per-data-set exclude each other, will choose the latter." << std::endl;
605 startupParam.showAverage = false;
606 }
607
608 return 0;
609}
610
611//----------------------------------------------------------------------------------------
619void musrFT_getMetaInfo(const TString fln, PRawRunData *rawRunData, TString &metaInfo)
620{
621 Double_t dval;
622 TString str = fln;
623 // file name
624 // trunc it in case a path-name is given
625 size_t idx = str.Last('/');
626 if (idx > 0)
627 str.Remove(0, idx+1);
628 metaInfo = str;
629 metaInfo += ",";
630 // temperature
631 for (UInt_t i=0; i<rawRunData->GetNoOfTemperatures(); i++) {
632 metaInfo += TString::Format("T%d=%0.2fK,", i, rawRunData->GetTemperature(i));
633 }
634 // magnetic field
635 dval = rawRunData->GetField();
636 if (dval == PMUSR_UNDEFINED)
637 metaInfo += TString("B=??,");
638 else if (dval < 5000.0)
639 metaInfo += TString::Format("B=%0.1fG,", dval);
640 else
641 metaInfo += TString::Format("B=%0.1fT,", dval/1.0e4);
642 // implantation energy
643 dval = rawRunData->GetEnergy();
644 if (dval == PMUSR_UNDEFINED)
645 metaInfo += TString("E=??;");
646 else if (dval < 1000.0)
647 metaInfo += TString::Format("E=%0.1fkeV;", dval);
648 else
649 metaInfo += TString::Format("E=%0.1fMeV;", dval/1.0e3);
650
651 metaInfo += *rawRunData->GetCryoName();
652 metaInfo += ";";
653 metaInfo += *rawRunData->GetSample();
654}
655
656//-------------------------------------------------------------------------
665{
666 std::cout << std::endl << ">> musrFT **WARNING** try to estimate t0 from maximum in the data set";
667 std::cout << std::endl << " '" << rd.info << "'";
668 std::cout << std::endl << " NO warranty this is sensible!" << std::endl;
669
670 UInt_t idx = 0;
671 Double_t max = rd.rawData[0];
672 for (UInt_t i=1; i<rd.rawData.size(); i++) {
673 if (rd.rawData[i] > max) {
674 max = rd.rawData[i];
675 idx = (Int_t)i;
676 }
677 }
678 std::cout << std::endl << ">> musrFT_estimateT0: estimated t0=" << idx << std::endl;
679 rd.t0 = idx;
680}
681
682//-------------------------------------------------------------------------
688void musrFT_cleanup(TH1F *h)
689{
690 if (h) {
691 delete h;
692 h = 0;
693 }
694}
695
696//-------------------------------------------------------------------------
705Int_t musrFT_dumpData(TString fln, std::vector<PFourier*> &fourierData, Double_t start, Double_t end)
706{
707 std::vector<PDoubleVector> data;
708 PDoubleVector freq;
709 PDoubleVector re;
710 PDoubleVector im;
711 PDoubleVector pwr;
712 TH1F *hRe=nullptr, *hIm=nullptr;
713 Double_t dval;
714
715 // make sure start/end are given, otherwise take the minimum/maximum off all data
716 hRe = fourierData[0]->GetRealFourier();
717 if (start == -1.0) {
718 start = hRe->GetBinCenter(1);
719 if (end == -1.0)
720 end = hRe->GetBinCenter(hRe->GetNbinsX());
721 }
722
723 UInt_t minSize = hRe->GetNbinsX()-1;
724 musrFT_cleanup(hRe);
725 for (UInt_t i=1; i<fourierData.size(); i++) {
726 hRe = fourierData[i]->GetRealFourier();
727 if (hRe->GetNbinsX()-1 < (Int_t)minSize)
728 minSize = hRe->GetNbinsX()-1;
729 musrFT_cleanup(hRe);
730 }
731
732 for (UInt_t i=0; i<fourierData.size(); i++) {
733 hRe = fourierData[i]->GetRealFourier();
734 hIm = fourierData[i]->GetImaginaryFourier();
735 for (Int_t j=1; j<(Int_t)minSize; j++) {
736 dval = hRe->GetBinCenter(j);
737 if ((dval >= start) && (dval <= end)) {
738 freq.push_back(dval);
739 re.push_back(hRe->GetBinContent(j));
740 im.push_back(hIm->GetBinContent(j));
741 pwr.push_back(hRe->GetBinContent(j)*hRe->GetBinContent(j)+hIm->GetBinContent(j)*hIm->GetBinContent(j));
742 }
743 }
744 data.push_back(freq);
745 data.push_back(re);
746 data.push_back(im);
747 data.push_back(pwr);
748 // cleanup
749 freq.clear();
750 re.clear();
751 im.clear();
752 pwr.clear();
753 musrFT_cleanup(hRe);
754 musrFT_cleanup(hIm);
755 }
756
757 std::ofstream fout(fln, std::ofstream::out);
758
759 // write header
760 fout << "% ";
761 for (UInt_t i=0; i<fourierData.size()-1; i++)
762 fout << "freq" << i << ", Re[d" << i << "], Im[d" << i << "], Pwr[d" << i << "], ";
763 fout << "freq" << fourierData.size()-1 << ", Re[d" << fourierData.size()-1 << "], Im[d" << fourierData.size()-1 << "], Pwr[d" << fourierData.size()-1 << "]" << std::endl;
764
765 // write data
766 for (UInt_t j=0; j<data[0].size(); j++) {
767 for (UInt_t i=0; i<data.size()-1; i++) {
768 fout << data[i][j] << ", ";
769 }
770 fout << data[data.size()-1][j] << std::endl;
771 }
772 fout.close();
773
774 return 0;
775}
776
777//-------------------------------------------------------------------------
788{
789 // get proper raw run data set
790 TString runName = *(run.GetRunName());
791 PRawRunData *rawRunData = runDataHandler->GetRunData(runName);
792 if (rawRunData == nullptr) {
793 std::cerr << std::endl << ">> musrFT_groupHistos **ERROR** Couldn't get raw run data for run '" << runName << "'." << std::endl;
794 return 1;
795 }
796
797 // keep histo list
798 PIntVector histoList;
799 for (UInt_t i=0; i<run.GetForwardHistoNoSize(); i++) {
800 histoList.push_back(run.GetForwardHistoNo(i));
801 }
802
803 // check if t0's are found and that #t0 == #histos
804 PDoubleVector t0;
805 t0.resize(histoList.size());
806 // init t0 vector
807 for (UInt_t i=0; i<t0.size(); i++)
808 t0[i] = -1.0;
809 // 1st: check in the global block
810 for (UInt_t i=0; i<global->GetT0BinSize(); i++) {
811 if (i >= t0.size()) { // something is VERY strange
812 std::cerr << std::endl << ">> musrFT_groupHistos **WARNING** found #t0's in GLOBAL block > #histos!";
813 std::cerr << std::endl << ">> This should NEVER happen. Will ignore these entries.";
814 std::cerr << std::endl << ">> Please check your msr-file!!" << std::endl;
815 } else {
816 t0[i] = global->GetT0Bin(i);
817 }
818 }
819 // 2nd: check in the run block
820 for (UInt_t i=0; i<run.GetT0BinSize(); i++) {
821 if (i >= t0.size()) { // something is VERY strange
822 std::cerr << std::endl << ">> musrFT_groupHistos **WARNING** found #t0's in RUN block > #histos!";
823 std::cerr << std::endl << ">> This should NEVER happen. Will ignore these entries.";
824 std::cerr << std::endl << ">> Please check your msr-file!!" << std::endl;
825 } else {
826 t0[i] = run.GetT0Bin(i);
827 }
828 }
829 // if still some t0's are == -1, estimate t0
830 UInt_t idx;
831 Double_t max;
832 for (UInt_t i=0; i<t0.size(); i++) {
833 if (t0[i] == -1.0) {
834 std::cout << std::endl << ">> musrFT_groupHistos **WARNING** try to estimate t0 from maximum in the data set";
835 std::cout << std::endl << ">> '" << runName << "', histo " << histoList[i] << ". NO warranty this is sensible!";
836 idx = 0;
837 max = rawRunData->GetDataBin(histoList[i])->at(0);
838 for (UInt_t j=1; j<rawRunData->GetDataBin(histoList[i])->size(); j++) {
839 if (rawRunData->GetDataBin(histoList[i])->at(j) > max) {
840 max = rawRunData->GetDataBin(histoList[i])->at(j);
841 idx = j;
842 }
843 }
844 std::cout << std::endl << ">> estimated t0=" << idx << std::endl;
845 t0[i] = idx;
846 }
847 }
848
849 // group histos
850 PDoubleVector data = *(rawRunData->GetDataBin(histoList[0]));
851 for (UInt_t i=1; i<histoList.size(); i++) {
852 for (UInt_t j=0; j<data.size(); j++) {
853 if ((j+t0[i]-t0[0] >= 0) && (j+t0[i]-t0[0] < rawRunData->GetDataBin(histoList[i])->size())) {
854 data[j] += rawRunData->GetDataBin(histoList[i])->at(j);
855 }
856 }
857 }
858
859 rd.rawData.clear();
860 rd.rawData = data;
861 rd.t0 = static_cast<Int_t>(t0[0]);
862
863 return 0;
864}
865
866//-------------------------------------------------------------------------
877{
878 std::ofstream fout(param.msrFlnOut.Data(), std::ofstream::out);
879
880 // write title
881 if (param.title.Length() == 0) { // create title if not given
882 if (param.dataFln.size() != 0) {
883 param.title = param.dataFln[0];
884 } else {
885 param.title = param.msrFlnOut;
886 }
887 }
888 fout << param.title << std::endl;
889 fout << "###############################################################" << std::endl;
890
891 // write GLOBAL block
892 fout << "GLOBAL" << std::endl;
893 fout << "fittype 0 (single histogram fit)" << std::endl;
894 if (param.t0.size() == 1) { // only a single t0 value given, hence assume it is valid for ALL histos
895 fout << "t0 " << param.t0[0] << std::endl;
896 }
897 if ((param.timeRange[0] != -1.0) && (param.timeRange[1] != -1.0)) {
898 fout << "fit " << param.timeRange[0] << " " << param.timeRange[1] << std::endl;
899 }
900 fout << "packing " << param.packing << std::endl;
901 fout << std::endl;
902 fout << "###############################################################" << std::endl;
903
904 // write RUN block
905 // get extension of the data file
906 TString fileFormat("MUSR-ROOT");
907 for (UInt_t i=0; i<param.dataFln.size(); i++) {
908 if (param.dataFileFormat[i].BeginsWith("PsiBin"))
909 fileFormat = TString("PSI-BIN");
910 else if (param.dataFileFormat[i].BeginsWith("PsiMdu"))
911 fileFormat = TString("PSI-MDU");
912 else if (param.dataFileFormat[i].BeginsWith("NeXus"))
913 fileFormat = TString("NEXUS");
914 else if (param.dataFileFormat[i].BeginsWith("Mud"))
915 fileFormat = TString("MUD");
916 for (UInt_t j=0; j<param.histo.size(); j++) {
917 fout << "RUN " << param.dataFln[i] << " BXXX IXX " << fileFormat << " (name beamline institute data-file-format)" << std::endl;
918 fout << "forward " << param.histo[j] << std::endl;
919 if ((param.t0.size() > 1) && (j < param.t0.size())) {
920 fout << "t0 " << param.t0[j] << std::endl;
921 }
922 if ((param.bkg_range[0] > -1) && (param.bkg_range[1] > -1))
923 fout << "background " << param.bkg_range[0] << " " << param.bkg_range[1] << std::endl;
924 fout << "#--------------------------------------------------------------" << std::endl;
925 }
926 }
927 fout << std::endl;
928 fout << "###############################################################" << std::endl;
929
930 // write PLOT block
931 fout << "PLOT 0 (single histo plot)" << std::endl;
932 if (param.histo.size() == 0) {
933 fout << "runs 1" << std::endl;
934 } else {
935 fout << "runs ";
936 for (UInt_t i=0; i<param.histo.size(); i++)
937 fout << i+1 << " ";
938 fout << std::endl;
939 }
940 if ((param.timeRange[0] == -1.0) && (param.timeRange[1] == -1.0)) {
941 fout << "range 0 10" << std::endl;
942 } else {
943 fout << "range " << param.timeRange[0] << " " << param.timeRange[1] << std::endl;
944 }
945 fout << std::endl;
946 fout << "###############################################################" << std::endl;
947
948 // write FOURIER block
949 fout << "FOURIER" << std::endl;
950 if (param.fourierUnits.BeginsWith("??")) { // Fourier units not given, hence choose MHz
951 fout << "units MHz # units either 'Gauss', 'MHz', or 'Mc/s'" << std::endl;
952 } else {
953 fout << "units " << param.fourierUnits << " # units either 'Gauss', 'MHz', or 'Mc/s'" << std::endl;
954 }
955 if (param.fourierOpt.BeginsWith("??")) { // Fourier plot option not given, hence choose POWER
956 fout << "plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL" << std::endl;
957 } else {
958 fout << "plot " << param.fourierOpt << " # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL" << std::endl;
959 }
960 if (param.fourierPower > 1) {
961 fout << "fourier_power " << param.fourierPower << std::endl;
962 }
963 fout << "apodization " << param.apodization << " # NONE, WEAK, MEDIUM, STRONG" << std::endl;
964 if ((param.fourierRange[0] > -1.0) && (param.fourierRange[1] > -1.0)) {
965 fout << "range " << param.fourierRange[0] << " " << param.fourierRange[1] << std::endl;
966 }
967
968 fout.close();
969}
970
971//-------------------------------------------------------------------------
977Double_t millitime()
978{
979 struct timeval now;
980 gettimeofday(&now, 0);
981
982 return (static_cast<Double_t>(now.tv_sec) * 1.0e6 + static_cast<Double_t>(now.tv_usec))/1.0e3;
983}
984
985//-------------------------------------------------------------------------
996Int_t main(Int_t argc, Char_t *argv[])
997{
998 Int_t unitTag = FOURIER_UNIT_NOT_GIVEN;
999 Int_t apodTag = F_APODIZATION_NONE;
1000 Int_t fourierPlotTag = FOURIER_PLOT_NOT_GIVEN;
1001
1002 // only program name alone
1003 if (argc == 1) {
1004 musrFT_syntax();
1005 return PMUSR_SUCCESS;
1006 }
1007
1008 musrFT_startup_param startupParam;
1009 // init startupParam
1010 musrFT_init(startupParam);
1011
1012 // parse command line options
1013 Int_t status = musrFT_parse_options(argc, argv, startupParam);
1014 if (status != 0) {
1015 Int_t retVal = PMUSR_SUCCESS;
1016 if (status == 2) {
1017 musrFT_syntax();
1019 }
1020 return retVal;
1021 }
1022
1023 // dump msr-file
1024 if (startupParam.msrFlnOut.Length() > 0) {
1025 musrFT_dumpMsrFile(startupParam);
1026 return PMUSR_SUCCESS;
1027 }
1028
1029 // read startup file
1030 Char_t startup_path_name[128];
1031 PStartupOptions startup_options;
1032 startup_options.writeExpectedChisq = false;
1033 startup_options.estimateN0 = true;
1034 std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
1035 std::unique_ptr<PStartupHandler> startupHandler = std::make_unique<PStartupHandler>();
1036 if (!startupHandler->StartupFileFound()) {
1037 std::cerr << std::endl << ">> musrFT **WARNING** couldn't find " << startupHandler->GetStartupFilePath().Data();
1038 std::cerr << std::endl;
1039 } else {
1040 strcpy(startup_path_name, startupHandler->GetStartupFilePath().Data());
1041 saxParser->ConnectToHandler("PStartupHandler", startupHandler.get());
1042 //status = saxParser->ParseFile(startup_path_name);
1043 // parsing the file as above seems to lead to problems in certain environments;
1044 // use the parseXmlFile function instead (see PStartupHandler.cpp for the definition)
1045 status = parseXmlFile(saxParser.get(), startup_path_name);
1046 // check for parse errors
1047 if (status) { // error
1048 std::cerr << std::endl << ">> musrFT **WARNING** Reading/parsing musrfit_startup.xml failed.";
1049 std::cerr << std::endl;
1050 }
1051 }
1052
1053 // defines the raw time-domain data vector
1054 PPrepFourier data(startupParam.packing, startupParam.bkg_range, startupParam.bkg);
1055
1056 // load msr-file(s)
1057 std::vector< std::unique_ptr<PMsrHandler> > msrHandler;
1058 msrHandler.resize(startupParam.msrFln.size());
1059 for (UInt_t i=0; i<startupParam.msrFln.size(); i++) {
1060 msrHandler[i] = std::make_unique<PMsrHandler>(startupParam.msrFln[i].Data(), &startup_options, true);
1061 status = msrHandler[i]->ReadMsrFile();
1062 if (status != PMUSR_SUCCESS) {
1063 switch (status) {
1065 std::cout << std::endl << ">> musrFT **ERROR** couldn't find " << startupParam.msrFln[i] << std::endl << std::endl;
1066 break;
1068 std::cout << std::endl << ">> musrFT **SYNTAX ERROR** in file " << startupParam.msrFln[i] << ", full stop here." << std::endl << std::endl;
1069 break;
1070 default:
1071 std::cout << std::endl << ">> musrFT **UNKOWN ERROR** when trying to read the msr-file" << std::endl << std::endl;
1072 break;
1073 }
1074 return status;
1075 }
1076 }
1077
1078 // check for ascii-, db- or dat-files in msr-file RUN block
1079 TString ffstr("");
1080 for (UInt_t i=0; i<msrHandler.size(); i++) {
1081 PMsrRunList *runList = msrHandler[i]->GetMsrRunList();
1082 for (UInt_t j=0; j<runList->at(i).GetFileFormatSize(); j++) {
1083 ffstr = *(runList->at(i).GetFileFormat(j));
1084 if (!ffstr.CompareTo("ascii", TString::kIgnoreCase) || !ffstr.CompareTo("dat", TString::kIgnoreCase) || !ffstr.CompareTo("db", TString::kIgnoreCase)) {
1085 std::cout << std::endl;
1086 std::cout << "**ERROR** Currently file format's 'ASCII', 'DAT', nor 'DB' are NOT supported." << std::endl;
1087 std::cout << std::endl;
1089 }
1090 }
1091 }
1092
1093 std::vector< std::unique_ptr<PRunDataHandler> > runDataHandler;
1094 runDataHandler.resize(startupParam.msrFln.size()+startupParam.dataFln.size()); // resize to the total number of run data provided
1095 // load data-file(s) related to msr-file
1096 for (UInt_t i=0; i<msrHandler.size(); i++) {
1097 // create run data handler
1098 if (startupHandler)
1099 runDataHandler[i] = std::make_unique<PRunDataHandler>(msrHandler[i].get(), startupHandler->GetDataPathList());
1100 else
1101 runDataHandler[i] = std::make_unique<PRunDataHandler>(msrHandler[i].get());
1102 if (runDataHandler[i] == nullptr) {
1103 std::cerr << ">> musrFT: **ERROR** couldn't allocate PRunDataHandler object." << std::endl;
1105 }
1106 }
1107
1108 // load data-file(s) provided directly
1109 for (UInt_t i=msrHandler.size(); i<msrHandler.size()+startupParam.dataFln.size(); i++) {
1110 // create run data handler
1111 if (startupHandler)
1112 runDataHandler[i] = std::make_unique<PRunDataHandler>(startupParam.dataFln[i-msrHandler.size()], startupParam.dataFileFormat[i-msrHandler.size()], startupHandler->GetDataPathList());
1113 else
1114 runDataHandler[i] = std::make_unique<PRunDataHandler>(startupParam.dataFln[i-msrHandler.size()], startupParam.dataFileFormat[i-msrHandler.size()]);
1115 if (runDataHandler[i] == nullptr) {
1116 std::cerr << ">> musrFT: **ERROR** couldn't allocate PRunDataHandler object." << std::endl;
1118 }
1119 }
1120
1121 // read all the data files
1122 musrFT_data rd;
1123 rd.dataSetTag = -1;
1124 Int_t dataSetTagCounter = 0;
1125 TString prevDataSetPathName("");
1126 TString str(""), fln("");
1127 UInt_t idx=0;
1128
1129 for (UInt_t i=0; i<runDataHandler.size(); i++) {
1130 runDataHandler[i]->ReadData();
1131
1132 if (!runDataHandler[i]->IsAllDataAvailable()) {
1133 if (i < msrHandler.size()) {
1134 std::cerr << std::endl << ">> musrFT **ERROR** couldn't read data from msr-file '" << startupParam.msrFln[i] << "'." << std::endl;
1135 } else {
1136 std::cerr << std::endl << ">> musrFT **ERROR** couldn't read data-file '" << startupParam.dataFln[i] << "'." << std::endl;
1137 }
1139 }
1140
1141 // dig out all the necessary time domain data
1142 PRawRunData *rawRunData = runDataHandler[i]->GetRunData();
1143 if (rawRunData == nullptr) {
1144 if (i < msrHandler.size()) {
1145 std::cerr << std::endl << ">> musrFT **ERROR** couldn't obtain the raw run data set from msr-file " << startupParam.msrFln[i] << std::endl;
1146 } else {
1147 std::cerr << std::endl << ">> musrFT **ERROR** couldn't obtain the raw run data set for " << startupParam.dataFln[i-msrHandler.size()] << std::endl;
1148 }
1150 }
1151
1152 // first check of histo list makes sense
1153 if (i >= msrHandler.size()) { // only check if originating from data-files (not msr-files)
1154 for (UInt_t j=0; j<startupParam.histo.size(); j++) {
1155 if ((UInt_t)startupParam.histo[j] > rawRunData->GetNoOfHistos()) {
1156 std::cerr << std::endl << ">> musrFT **ERROR** found histo no " << startupParam.histo[j] << " > # of histo in the file (";
1157 std::cerr << startupParam.dataFln[i] << " // # histo: " << rawRunData->GetNoOfHistos() << ")." << std::endl;
1159 }
1160 }
1161 if (startupParam.histo.size() == 0) { // no histo list given
1162 // set histo list to ALL available histos for the data file
1163 for (UInt_t j=0; j<rawRunData->GetNoOfHistos(); j++)
1164 startupParam.histo.push_back(j+1);
1165 }
1166 }
1167
1168 // get meta info, time resolution, time range, raw data sets
1169 if (i < msrHandler.size()) { // obtain info from msr-files
1170 // keep title if not overwritten by the command line
1171 if (startupParam.title.Length() == 0)
1172 startupParam.title = *(msrHandler[0]->GetMsrTitle());
1173 // keep PLOT block info
1174 PMsrPlotList *plot = msrHandler[i]->GetMsrPlotList();
1175 if (plot == nullptr) {
1176 std::cerr << std::endl << ">> musrFT **ERROR** couldn't obtain PLOT block from msr-handler." << std::endl;
1178 }
1179 // keep RUN block(s) info
1180 PMsrRunList *runs = msrHandler[i]->GetMsrRunList();
1181 if (runs == nullptr) {
1182 std::cerr << std::endl << ">> musrFT **ERROR** couldn't obtain RUN block(s) from msr-handler." << std::endl;
1184 }
1185 // keep GLOBAL block info
1186 PMsrGlobalBlock *global = msrHandler[i]->GetMsrGlobal();
1187 if (global == nullptr) {
1188 std::cerr << std::endl << ">> musrFT **ERROR** couldn't obtain GLOBAL block from msr-handler." << std::endl;
1190 }
1191 // keep FOURIER block info
1192 PMsrFourierStructure *fourierBlock = msrHandler[i]->GetMsrFourierList();
1193 if (fourierBlock == nullptr) {
1194 std::cerr << std::endl << ">> msrFT **WARNING** couldn't obtain FOURIER block from msr-handler." << std::endl;
1196 } else { // filter out all necessary info
1197 if (fourierBlock->fFourierBlockPresent) {
1198 // get units
1199 unitTag = fourierBlock->fUnits;
1200 if (startupParam.fourierUnits.BeginsWith("??")) {
1201 switch (unitTag) {
1202 case FOURIER_UNIT_GAUSS:
1203 startupParam.fourierUnits = TString("Gauss");
1204 break;
1205 case FOURIER_UNIT_TESLA:
1206 startupParam.fourierUnits = TString("Tesla");
1207 break;
1208 case FOURIER_UNIT_FREQ:
1209 startupParam.fourierUnits = TString("MHz");
1210 break;
1212 startupParam.fourierUnits = TString("Mc/s");
1213 break;
1214 default:
1215 break;
1216 }
1217 }
1218 // get fourier power
1219 if (startupParam.fourierPower == -1) { // no Fourier power given from the command line, hence check FOURIER block
1220 if (fourierBlock->fFourierPower > 1)
1221 startupParam.fourierPower = fourierBlock->fFourierPower;
1222 }
1223 // get apodization tag
1224 switch (fourierBlock->fApodization) {
1225 case FOURIER_APOD_WEAK:
1226 startupParam.apodization = "weak";
1227 break;
1229 startupParam.apodization = "medium";
1230 break;
1232 startupParam.apodization = "strong";
1233 break;
1234 default:
1235 startupParam.apodization = "none";
1236 break;
1237 }
1238 // get range
1239 if ((startupParam.fourierRange[0] == -1) && (startupParam.fourierRange[1] == -1)) { // no Fourier range given from the command line
1240 startupParam.fourierRange[0] = fourierBlock->fPlotRange[0];
1241 startupParam.fourierRange[1] = fourierBlock->fPlotRange[1];
1242 }
1243 // get Fourier plot option, i.e. real, imag, power, phase
1244 if (startupParam.fourierOpt.BeginsWith("??")) { // only do something if not overwritten by the command line
1245 fourierPlotTag = fourierBlock->fPlotTag;
1246 }
1247 }
1248 }
1249
1250 // get the run information from the msr-file PLOT block 'runs'
1251 PIntVector runList = plot->at(0).fRuns;
1252
1253 // loop over all runs listed in the msr-file PLOT block
1254 for (UInt_t j=0; j<runList.size(); j++) {
1255
1256 // check if the data set name has changed
1257 str = *(runs->at(runList[j]-1).GetRunName()); // get the name from the msr-file RUN block
1258 if (prevDataSetPathName.CompareTo(str)) { // i.e. data set name changed
1259 rd.dataSetTag = dataSetTagCounter++;
1260 prevDataSetPathName = str;
1261 }
1262
1263 // keep forward histo list
1264 PIntVector histoList;
1265 for (UInt_t k=0; k<runs->at(runList[j]-1).GetForwardHistoNoSize(); k++) {
1266 histoList.push_back(runs->at(runList[j]-1).GetForwardHistoNo(k));
1267 }
1268
1269 // handle meta information
1270 fln = *(runs->at(runList[j]-1).GetRunName()); // get the name from the msr-file RUN block
1271 musrFT_getMetaInfo(fln, rawRunData, str);
1272 TString hh("");
1273 hh = TString::Format("h%d", histoList[0]);
1274 for (UInt_t k=1; k<histoList.size(); k++)
1275 hh += TString::Format("/%d", histoList[k]);
1276 hh += ":";
1277 rd.info = hh;
1278 rd.info += str;
1279
1280 // handle time resolution
1281 rd.timeResolution = rawRunData->GetTimeResolution() / 1.0e3; // time resolution in (us)
1282
1283 // handle time range
1284 // take it from msr-file PLOT block 'range' if not overwritten from the command line
1285 if ((startupParam.timeRange[0] != -1) && (startupParam.timeRange[1] != -1)) {
1286 rd.timeRange[0] = startupParam.timeRange[0];
1287 rd.timeRange[1] = startupParam.timeRange[1];
1288 } else {
1289 if (plot->at(0).fTmin.size() > 0) {
1290 rd.timeRange[0] = plot->at(0).fTmin[0];
1291 rd.timeRange[1] = plot->at(0).fTmax[0];
1292 }
1293 }
1294
1295 // handle data set(s)
1296 // group forward histos
1297 if (musrFT_groupHistos(runDataHandler[i].get(), global, runs->at(runList[j]-1), rd)) {
1299 }
1300 // keep data set
1301 data.AddData(rd);
1302
1303 // get packing
1304 Int_t pack = 1;
1305 if (global->GetPacking() != -1) {
1306 pack = global->GetPacking();
1307 }
1308 if (runs->at(runList[j]-1).GetPacking() != -1) {
1309 pack = runs->at(runList[j]-1).GetPacking();
1310 }
1311 if (startupParam.packing > 1)
1312 pack = startupParam.packing;
1313 data.SetPacking(pack);
1314
1315 // get background range
1316 Int_t bkgStart=-1, bkgEnd=-1;
1317 bkgStart = runs->at(runList[j]-1).GetBkgRange(0);
1318 bkgEnd = runs->at(runList[j]-1).GetBkgRange(1);
1319 if ((startupParam.bkg_range[0] == -1) && (bkgStart != -1))
1320 startupParam.bkg_range[0] = bkgStart;
1321 if ((startupParam.bkg_range[1] == -1) && (bkgEnd != -1))
1322 startupParam.bkg_range[1] = bkgEnd;
1323 data.SetBkgRange(startupParam.bkg_range);
1324 }
1325 } else { // obtain info from command line options for direct data-file read
1326 // check if the data set name has changed
1327 // since data-files are given, each PRunDataHandler object contains only a SINGLE data file.
1328 str = *(runDataHandler[i]->GetRunData()->GetFileName()); // get the data set name
1329 if (prevDataSetPathName.CompareTo(str)) { // i.e. data set name changed
1330 rd.dataSetTag = dataSetTagCounter++;
1331 prevDataSetPathName = str;
1332 }
1333
1334 musrFT_getMetaInfo(startupParam.dataFln[i-msrHandler.size()], rawRunData, str);
1335 for (UInt_t j=0; j<startupParam.histo.size(); j++) {
1336 idx = startupParam.histo[j];
1337
1338 // handle meta information
1339 rd.info = TString::Format("h%d:", idx);
1340 rd.info += str;
1341
1342 // handle time resolution
1343 rd.timeResolution = rawRunData->GetTimeResolution() / 1.0e3; // time resolution in (us)
1344
1345 // handle time range
1346 rd.timeRange[0] = startupParam.timeRange[0]; // in (us)
1347 rd.timeRange[1] = startupParam.timeRange[1]; // in (us)
1348
1349 // handle data set
1350 rd.rawData.clear();
1351 rd.rawData = *(rawRunData->GetDataBin(idx));
1352
1353 // handle t0's
1354 rd.t0 = -1;
1355 if (startupParam.t0.size() == 1)
1356 rd.t0 = startupParam.t0[0];
1357 else if (j < startupParam.t0.size())
1358 rd.t0 = startupParam.t0[j];
1359 if (rd.t0 == -1) { // no t0 given, try to estimate it
1361 }
1362
1363 data.AddData(rd);
1364 }
1365 }
1366 }
1367
1368 // generate data set label vector
1369 PIntVector dataSetTag;
1370 for (UInt_t i=0; i<data.GetNoOfData(); i++) {
1371 dataSetTag.push_back(data.GetDataSetTag(i));
1372 }
1373
1374 // make sure Fourier plot tag is set
1375 if (fourierPlotTag == FOURIER_PLOT_NOT_GIVEN) {
1376 if (!startupParam.fourierOpt.CompareTo("real", TString::kIgnoreCase))
1377 fourierPlotTag = FOURIER_PLOT_REAL;
1378 else if (!startupParam.fourierOpt.CompareTo("imag", TString::kIgnoreCase))
1379 fourierPlotTag = FOURIER_PLOT_IMAG;
1380 else if (!startupParam.fourierOpt.CompareTo("real+imag", TString::kIgnoreCase))
1381 fourierPlotTag = FOURIER_PLOT_REAL_AND_IMAG;
1382 else if (!startupParam.fourierOpt.CompareTo("power", TString::kIgnoreCase))
1383 fourierPlotTag = FOURIER_PLOT_POWER;
1384 else if (!startupParam.fourierOpt.CompareTo("phase", TString::kIgnoreCase))
1385 fourierPlotTag = FOURIER_PLOT_PHASE;
1386 else if (!startupParam.fourierOpt.CompareTo("phaseoptreal", TString::kIgnoreCase))
1387 fourierPlotTag = FOURIER_PLOT_PHASE_OPT_REAL;
1388 else
1389 fourierPlotTag = FOURIER_PLOT_POWER;
1390 }
1391
1392 // calculate background levels and subtract them from the data
1393 data.DoBkgCorrection();
1394
1395 // do lifetime correction
1396 if (startupParam.lifetimecorrection != 0.0)
1397 data.DoLifeTimeCorrection(startupParam.lifetimecorrection);
1398
1399 // do packing
1400 data.DoPacking();
1401
1402 // get all the corrected data
1403 std::vector<TH1F*> histo = data.GetData();
1404
1405 // prepare Fourier
1406 if (startupParam.fourierUnits.BeginsWith("gauss", TString::kIgnoreCase))
1407 unitTag = FOURIER_UNIT_GAUSS;
1408 else if (startupParam.fourierUnits.BeginsWith("tesla", TString::kIgnoreCase))
1409 unitTag = FOURIER_UNIT_TESLA;
1410 else if (startupParam.fourierUnits.BeginsWith("mhz", TString::kIgnoreCase))
1411 unitTag = FOURIER_UNIT_FREQ;
1412 else if (startupParam.fourierUnits.BeginsWith("mc/s", TString::kIgnoreCase))
1413 unitTag = FOURIER_UNIT_CYCLES;
1414 else if (startupParam.fourierUnits.BeginsWith("??", TString::kIgnoreCase) && (unitTag == FOURIER_UNIT_NOT_GIVEN))
1415 unitTag = FOURIER_UNIT_FREQ;
1416
1417 std::vector<PFourier*> fourier;
1418 fourier.resize(histo.size());
1419 for (UInt_t i=0; i<fourier.size(); i++) {
1420 fourier[i] = new PFourier(histo[i], unitTag, 0.0, 0.0, true, startupParam.fourierPower);
1421 if (fourier[i] == nullptr) {
1422 std::cerr << ">> musrFT: **ERROR** couldn't invoke PFourier object" << std::endl;
1424 }
1425 }
1426
1427 // Fourier transform data
1428 if (startupParam.apodization.BeginsWith("weak", TString::kIgnoreCase))
1429 apodTag = F_APODIZATION_WEAK;
1430 else if (startupParam.apodization.BeginsWith("medium", TString::kIgnoreCase))
1431 apodTag = F_APODIZATION_MEDIUM;
1432 else if (startupParam.apodization.BeginsWith("strong", TString::kIgnoreCase))
1433 apodTag = F_APODIZATION_STRONG;
1434
1435 Double_t start = millitime();
1436 for (UInt_t i=0; i<fourier.size(); i++) {
1437 fourier[i]->Transform(apodTag);
1438 }
1439 Double_t end = millitime();
1440 std::cout << std::endl << "info> after FFT. calculation time: " << (end-start)/1.0e3 << " (sec)." << std::endl;
1441
1442 // make sure that a Fourier range is provided, if not calculate one
1443 if ((startupParam.fourierRange[0] == -1.0) && (startupParam.fourierRange[1] == -1.0)) {
1444 startupParam.fourierRange[0] = 0.0;
1445 startupParam.fourierRange[1] = fourier[0]->GetMaxFreq();
1446 }
1447
1448 std::unique_ptr<PFourierCanvas> fourierCanvas;
1449
1450 // if Fourier dumped if whished do it now
1451 if (startupParam.dumpFln.Length() > 0) {
1452 musrFT_dumpData(startupParam.dumpFln, fourier, startupParam.fourierRange[0], startupParam.fourierRange[1]);
1453 } else { // do Canvas
1454
1455 // if Fourier graphical export is wished, switch to batch mode
1456 Bool_t batch = false;
1457 // create list of essential arguments to pass to the ROOT application
1458 std::vector<char*> args;
1459 args.push_back(argv[0]); // program name
1460 if (startupParam.graphicFormat.Length() != 0) {
1461 batch = true;
1462 args.push_back((char*)"-b"); // batch mode flag
1463 }
1464 int cc = args.size();
1465 // plot the Fourier transform
1466 TApplication app("App", &cc, args.data());
1467
1468 if (startupHandler) {
1469 fourierCanvas = std::unique_ptr<PFourierCanvas>(new PFourierCanvas(fourier, dataSetTag, startupParam.title.Data(),
1470 startupParam.showAverage, startupParam.showAveragePerDataSet,
1471 fourierPlotTag, startupParam.fourierRange, startupParam.initialPhase,
1472 10, 10, 800, 800,
1473 startupHandler->GetMarkerList(),
1474 startupHandler->GetColorList(),
1475 batch));
1476 } else {
1477 fourierCanvas = std::unique_ptr<PFourierCanvas>(new PFourierCanvas(fourier, dataSetTag, startupParam.title.Data(),
1478 startupParam.showAverage, startupParam.showAveragePerDataSet,
1479 fourierPlotTag, startupParam.fourierRange, startupParam.initialPhase,
1480 10, 10, 800, 800,
1481 batch));
1482 }
1483 if (fourierCanvas == nullptr) {
1484 std::cerr << ">> musrFT: **ERROR** couldn't invoke PFourierCanvas object." << std::endl;
1486 }
1487
1488 fourierCanvas->UpdateFourierPad();
1489 fourierCanvas->UpdateInfoPad();
1490
1491 Bool_t ok = true;
1492 if (!fourierCanvas->IsValid()) {
1493 std::cerr << std::endl << ">> musrFT **SEVERE ERROR** Couldn't invoke all necessary objects, will quit.";
1494 std::cerr << std::endl;
1495 ok = false;
1496 } else {
1497 // connect signal/slot
1498 TQObject::Connect("TCanvas", "Closed()", "PFourierCanvas", fourierCanvas.get(), "LastCanvasClosed()");
1499
1500 fourierCanvas->SetTimeout(startupParam.timeout);
1501
1502 fourierCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)");
1503
1504 if (startupParam.graphicFormat.Length() != 0) {
1505 TString fileName("");
1506 // create output filename based on the msr- or raw-data-filename
1507 if (startupParam.dataFln.size() > 0) {
1508 fileName = startupParam.dataFln[0];
1509 }
1510 if (startupParam.msrFln.size() > 0) {
1511 fileName = startupParam.msrFln[0];
1512 }
1513 Ssiz_t idx = fileName.Last('.');
1514 fileName.Remove(idx, fileName.Length());
1515 fileName += ".";
1516 fileName += startupParam.graphicFormat;
1517 fourierCanvas->SaveGraphicsAndQuit(fileName.Data());
1518 }
1519 }
1520 // check that everything is ok
1521 if (ok)
1522 app.Run();
1523 }
1524
1525 return PMUSR_SUCCESS;
1526}
#define F_APODIZATION_WEAK
Weak apodization (gentle roll-off at edges)
Definition PFourier.h:55
#define F_APODIZATION_STRONG
Strong apodization (heavy roll-off for best frequency resolution)
Definition PFourier.h:59
#define F_APODIZATION_NONE
No apodization (rectangular window)
Definition PFourier.h:53
#define F_APODIZATION_MEDIUM
Medium apodization (moderate roll-off)
Definition PFourier.h:57
#define PMUSR_DATA_FILE_READ_ERROR
Error reading data file (ROOT, NeXus, MUD, etc.)
Definition PMusr.h:71
#define FOURIER_UNIT_FREQ
Frequency in MHz.
Definition PMusr.h:276
#define FOURIER_PLOT_REAL_AND_IMAG
Plot both real and imaginary components (default)
Definition PMusr.h:314
#define PMUSR_SUCCESS
Successful operation completion.
Definition PMusr.h:53
std::vector< PMsrRunBlock > PMsrRunList
Definition PMusr.h:1245
#define FOURIER_UNIT_GAUSS
Magnetic field in Gauss (G)
Definition PMusr.h:272
#define PMUSR_UNSUPPORTED_FEATURE
Requested feature is not yet supported.
Definition PMusr.h:75
#define FOURIER_PLOT_NOT_GIVEN
Plot type not specified.
Definition PMusr.h:308
#define FOURIER_PLOT_POWER
Plot power spectrum |F(ω)|²
Definition PMusr.h:316
#define PMUSR_UNDEFINED
Definition PMusr.h:172
#define PMUSR_MSR_FILE_NOT_FOUND
MSR file could not be found at specified path.
Definition PMusr.h:59
#define FOURIER_PLOT_REAL
Plot real component only.
Definition PMusr.h:310
#define FOURIER_PLOT_PHASE_OPT_REAL
Plot phase-optimized real component.
Definition PMusr.h:320
#define FOURIER_APOD_WEAK
Weak apodization (gentle windowing)
Definition PMusr.h:294
std::vector< PMsrPlotStructure > PMsrPlotList
Definition PMusr.h:1312
#define PMUSR_MSR_SYNTAX_ERROR
Syntax error detected in MSR file content.
Definition PMusr.h:63
#define FOURIER_UNIT_CYCLES
Angular frequency in Mc/s (Mega-cycles per second)
Definition PMusr.h:278
#define FOURIER_APOD_STRONG
Strong apodization (heavy windowing for best frequency resolution)
Definition PMusr.h:298
std::vector< Int_t > PIntVector
Definition PMusr.h:367
#define FOURIER_PLOT_IMAG
Plot imaginary component only.
Definition PMusr.h:312
#define FOURIER_APOD_MEDIUM
Medium apodization (moderate windowing)
Definition PMusr.h:296
#define FOURIER_PLOT_PHASE
Plot phase spectrum arg(F(ω))
Definition PMusr.h:318
#define FOURIER_UNIT_NOT_GIVEN
Units not specified.
Definition PMusr.h:270
#define PMUSR_MSR_ALLOCATION_ERROR
Memory allocation error while processing MSR file.
Definition PMusr.h:61
#define FOURIER_UNIT_TESLA
Magnetic field in Tesla (T)
Definition PMusr.h:274
#define PMUSR_WRONG_STARTUP_SYNTAX
Incorrect startup command syntax provided.
Definition PMusr.h:57
std::vector< TString > PStringVector
Definition PMusr.h:403
std::vector< Double_t > PDoubleVector
Definition PMusr.h:385
const char * startup_path_name
return status
int parseXmlFile(TSAXParser *, const char *)
Replacement function for TSAXParser::ParseFile().
virtual UInt_t GetT0BinSize()
Definition PMusr.h:1050
virtual Int_t GetPacking()
Definition PMusr.h:1058
virtual Double_t GetT0Bin(UInt_t idx=0)
Definition PMusr.cpp:1004
virtual UInt_t GetForwardHistoNoSize()
Definition PMusr.h:1140
virtual TString * GetRunName(UInt_t idx=0)
Definition PMusr.cpp:1301
virtual UInt_t GetT0BinSize()
Definition PMusr.h:1148
virtual Int_t GetForwardHistoNo(UInt_t idx=0)
Definition PMusr.cpp:1469
virtual Double_t GetT0Bin(UInt_t idx=0)
Definition PMusr.cpp:1764
Prepares time-domain μSR data for Fourier transformation.
virtual void DoLifeTimeCorrection(Double_t fudge)
Applies muon lifetime correction for theory-free analysis.
virtual void SetPacking(const Int_t packing)
Sets rebinning/packing factor for data reduction.
UInt_t GetNoOfData()
Returns number of stored data sets.
Int_t GetDataSetTag(const UInt_t idx)
Returns data set tag identifier.
virtual void AddData(musrFT_data &data)
Adds a time-domain data set for processing.
std::vector< TH1F * > GetData()
Creates ROOT histograms for all processed data sets.
virtual void DoBkgCorrection()
Applies background correction to all data sets.
virtual void SetBkgRange(const Int_t *bkgRange)
Sets background range for automatic background calculation.
virtual void DoPacking()
Applies rebinning/packing to reduce data points.
virtual const PDoubleVector * GetDataBin(const UInt_t histoNo)
Definition PMusr.h:880
virtual const Double_t GetTimeResolution()
Definition PMusr.h:868
virtual const TString * GetSample()
Definition PMusr.h:856
virtual const UInt_t GetNoOfTemperatures()
Definition PMusr.h:860
virtual const Double_t GetField()
Definition PMusr.h:859
virtual const Double_t GetEnergy()
Definition PMusr.h:864
virtual const UInt_t GetNoOfHistos()
Definition PMusr.h:878
virtual const TString * GetCryoName()
Definition PMusr.h:855
virtual const PDoublePairVector * GetTemperature() const
Definition PMusr.h:861
Raw data file reader and format converter for μSR data.
virtual PRawRunData * GetRunData(const TString &runName)
Retrieves run data by run name.
Int_t musrFT_dumpData(TString fln, std::vector< PFourier * > &fourierData, Double_t start, Double_t end)
Definition musrFT.cpp:705
void musrFT_init(musrFT_startup_param &startupParam)
Definition musrFT.cpp:165
Int_t musrFT_groupHistos(PRunDataHandler *runDataHandler, PMsrGlobalBlock *global, PMsrRunBlock &run, musrFT_data &rd)
Definition musrFT.cpp:787
void musrFT_dumpMsrFile(musrFT_startup_param &param)
Definition musrFT.cpp:876
Bool_t musrFT_filter_histo(Int_t &i, Int_t argc, Char_t *argv[], musrFT_startup_param &startupParam)
Definition musrFT.cpp:205
void musrFT_syntax()
Definition musrFT.cpp:94
void musrFT_estimateT0(musrFT_data &rd)
Definition musrFT.cpp:664
Int_t main(Int_t argc, Char_t *argv[])
Definition musrFT.cpp:996
Int_t musrFT_parse_options(Int_t argc, Char_t *argv[], musrFT_startup_param &startupParam)
Definition musrFT.cpp:296
void musrFT_cleanup(TH1F *h)
Definition musrFT.cpp:688
Double_t millitime()
Definition musrFT.cpp:977
void musrFT_getMetaInfo(const TString fln, PRawRunData *rawRunData, TString &metaInfo)
Definition musrFT.cpp:619
Int_t fPlotTag
tag used for initial plot. 0=real, 1=imaginary, 2=real & imaginary (default), 3=power,...
Definition PMusr.h:1266
Bool_t fFourierBlockPresent
flag indicating if a Fourier block is present in the msr-file
Definition PMusr.h:1261
Double_t fPlotRange[2]
field/frequency plot range
Definition PMusr.h:1271
Int_t fFourierPower
i.e. zero padding up to 2^fFourierPower, default = 0 which means NO zero padding
Definition PMusr.h:1264
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:1262
Int_t fApodization
tag indicating the kind of apodization wished, 0=no appodization (default), 1=weak,...
Definition PMusr.h:1265
Bool_t writeExpectedChisq
if set to true, expected chisq and chisq per block will be written
Definition PMusr.h:1379
Bool_t estimateN0
if set to true, for single histogram fits N0 will be estimated
Definition PMusr.h:1380
Data structure holding raw time-domain μSR data with metadata.
PDoubleVector rawData
Raw time-domain data vector (bin counts)
Double_t timeResolution
Time resolution in microseconds (μs)
Double_t timeRange[2]
Time range to process: [0]=start, [1]=end in microseconds (μs)
Int_t dataSetTag
Data set identifier tag (needed for average-per-data-set operations)
TString info
Metadata string (run name, histogram info, etc.)
Int_t t0
Time zero bin number (start of valid data)
Bool_t showAveragePerDataSet
flag indicating if initially the Fourier average over the given histos shall be plotted,...
Definition musrFT.cpp:82
TString apodization
apodization setting: none, weak, medium, strong
Definition musrFT.cpp:74
TString fourierUnits
wished Fourier units: Gauss, Tesla, MHz, Mc/s
Definition musrFT.cpp:76
Double_t fourierRange[2]
Fourier range to be plotted. Given in the choosen units.
Definition musrFT.cpp:78
Double_t lifetimecorrection
is == 0.0 for NO life time correction, otherwise it holds the fudge factor
Definition musrFT.cpp:86
PDoubleVector bkg
background value
Definition musrFT.cpp:72
Int_t packing
packing for rebinning the time histograms before Fourier transform.
Definition musrFT.cpp:84
Int_t bkg_range[2]
background range
Definition musrFT.cpp:71
TString graphicFormat
format for the graphical output dump
Definition musrFT.cpp:68
TString msrFlnOut
dump file name for msr-file generation
Definition musrFT.cpp:70
Int_t fourierPower
Fourier power for zero padding, i.e. 2^fourierPower points.
Definition musrFT.cpp:75
Bool_t showAverage
flag indicating if initially the Fourier average over the given histos shall be plotted,...
Definition musrFT.cpp:81
PStringVector dataFileFormat
file format guess
Definition musrFT.cpp:67
Int_t timeout
timeout in (sec) after which musrFT will terminate. if <= 0, no automatic termination will take place...
Definition musrFT.cpp:87
TString title
title to be shown for the Fourier plot.
Definition musrFT.cpp:85
Double_t initialPhase
inital Fourier phase for Real/Imag
Definition musrFT.cpp:77
PStringVector dataFln
raw-data-file names to be used.
Definition musrFT.cpp:66
PIntVector histo
selection of the histos used from at data file for Fourier
Definition musrFT.cpp:80
Double_t timeRange[2]
time range used for the Fourier
Definition musrFT.cpp:79
PIntVector t0
t0 vector for the histos. If not given t0's will be estimated.
Definition musrFT.cpp:83
TString fourierOpt
Fourier options, i.e. real, imag, power, phase, phaseOptReal.
Definition musrFT.cpp:73
PStringVector msrFln
msr-file names to be used.
Definition musrFT.cpp:65
TString dumpFln
dump file name for Fourier data output
Definition musrFT.cpp:69