musrfit 1.10.0
PFindRun Class Reference

PFindRun - Locates muSR data files using template-based path resolution. More...

#include <PFindRun.h>

Public Member Functions

 PFindRun (const PStringVector path, const PRunNameTemplateList runNameTemplateList)
 Default constructor - Creates instance without search parameters.
 
 PFindRun (const PStringVector path, const PRunNameTemplateList runNameTemplateList, const TString &instrument, const UInt_t year, const UInt_t run, const TString file_format="")
 Full constructor - Creates instance and prepares for file search.
 
Bool_t FoundPathName ()
 Searches for the run file using configured templates and paths.
 
TString GetPathName ()
 Returns the full path to the found run file.
 
void DumpTemplateList ()
 Debug utility - Prints current search configuration to stdout.
 

Private Member Functions

TString CreatePathName (const TString path, const TString runNameTemplate)
 Generates full file path by substituting template placeholders.
 

Private Attributes

const PStringVector fPath
 Search paths for data files.
 
const PRunNameTemplateList fRunNameTemplateList
 Template patterns per instrument.
 
TString fInstrument {""}
 Target instrument name (e.g., "GPS", "LEM")
 
Int_t fYear {-1}
 Run year (-1 if not specified)
 
Int_t fRun {-1}
 Run number (-1 if not specified)
 
TString fFileFormat {""}
 Optional file format filter (empty = any)
 
TString fPathName {""}
 Resolved full path (empty until found)
 

Detailed Description

PFindRun - Locates muSR data files using template-based path resolution.

This class searches for muSR run data files across multiple paths using configurable templates that encode instrument naming conventions. It supports various file formats (ROOT, NeXus, PSI-BIN, PSI-MDU, MUD, WKM) and handles year/run number substitution in file paths.

The template system uses placeholders:

  • yyyy% : 4-digit year (e.g., 2023)
  • yy% : 2-digit year (e.g., 23)
  • rr...r% : Run number with varying digits (rr%, rrr%, up to rrrrrrrrr%)
Example Usage:
PStringVector paths = {"/data/gps", "/data/lem"};
PRunNameTemplate gpsTemplate;
gpsTemplate.instrument = "GPS";
gpsTemplate.runNameTemplate = "%yyyy%/%rrrrr%.root";
templates.push_back(gpsTemplate);
PFindRun finder(paths, templates, "GPS", 2023, 2425, "MusrRoot");
if (finder.FoundPathName()) {
TString fullPath = finder.GetPathName();
// fullPath = "/data/gps/2023/02425.root"
}
std::vector< PRunNameTemplate > PRunNameTemplateList
Definition PMusr.h:1454
std::vector< TString > PStringVector
Definition PMusr.h:403
PFindRun - Locates muSR data files using template-based path resolution.
Definition PFindRun.h:68
TString runNameTemplate
File path template with placeholders (r=run, y=year)
Definition PMusr.h:1447
TString instrument
Instrument identifier (e.g., "GPS", "LEM", "DOLLY")
Definition PMusr.h:1446
See also
PRunNameTemplate
PRunNameTemplateList

Definition at line 68 of file PFindRun.h.

Constructor & Destructor Documentation

◆ PFindRun() [1/2]

PFindRun::PFindRun ( const PStringVector path,
const PRunNameTemplateList runNameTemplateList )

Default constructor - Creates instance without search parameters.

PFindRun::PFindRun.

Initializes the finder with paths and templates but no specific run to search. Use the full constructor to perform automatic searches.

Parameters
pathVector of directory paths to search
runNameTemplateListList of template patterns for different instruments
runNameTemplateList

Definition at line 40 of file PFindRun.cpp.

References fPath, and fRunNameTemplateList.

◆ PFindRun() [2/2]

PFindRun::PFindRun ( const PStringVector path,
const PRunNameTemplateList runNameTemplateList,
const TString & instrument,
const UInt_t year,
const UInt_t run,
const TString file_format = "" )

Full constructor - Creates instance and prepares for file search.

PFindRun::PFindRun.

Initializes the finder with all parameters needed to locate a specific run file. Call FoundPathName() after construction to perform the actual search.

Parameters
pathVector of directory paths to search
runNameTemplateListList of template patterns for different instruments
instrumentInstrument name (must match a template entry, e.g., "GPS", "LEM")
yearRun year (e.g., 2023)
runRun number (e.g., 2425)
file_formatOptional file format filter: "MusrRoot"/"ROOT", "NeXus", "PSI-BIN", "PSI-MDU", "MUD", "WKM". Empty string matches any format.
path
runNameTemplateList
instrument
year
run

Definition at line 56 of file PFindRun.cpp.

References fFileFormat, fInstrument, fPath, fRun, fRunNameTemplateList, and fYear.

Member Function Documentation

◆ CreatePathName()

TString PFindRun::CreatePathName ( const TString path,
const TString runNameTemplate )
private

Generates full file path by substituting template placeholders.

PFindRun::CreatePathName.

Internal helper that replaces year and run number placeholders in a template with actual values. Supports variable-length run number formatting (2-9 digits).

Parameters
pathBase directory path
runNameTemplateTemplate string with placeholders (yyyy%, yy%, rr...r%)
Returns
Full path with placeholders substituted (e.g., "/data/gps/2023/02425.root")
Template Examples:
  • "%yyyy%/%rrrrr%.root" with year=2023, run=42 → "2023/00042.root"
  • "run_%yy%_%rrr%.nxs" with year=2023, run=425 → "run_23_425.nxs"
Parameters
path
runNameTemplate
Returns

Definition at line 89 of file PFindRun.cpp.

References fRun, and fYear.

Referenced by FoundPathName().

◆ DumpTemplateList()

void PFindRun::DumpTemplateList ( )

Debug utility - Prints current search configuration to stdout.

PFindRun::DumpTemplateList.

Outputs instrument name, year, run number, and all available templates with their patterns. Useful for troubleshooting path resolution issues.

Definition at line 69 of file PFindRun.cpp.

References fInstrument, fRun, fRunNameTemplateList, and fYear.

◆ FoundPathName()

Bool_t PFindRun::FoundPathName ( )

Searches for the run file using configured templates and paths.

PFindRun::FoundPathName.

Iterates through all paths containing the instrument name, applies matching templates, and checks filesystem for file existence. If a file format is specified, only files with matching extensions are considered.

Returns
true if file was found, false otherwise
Search Algorithm:
  1. Filter paths containing instrument name
  2. For each matching path, try all templates for that instrument
  3. Substitute year/run placeholders to create full path
  4. Check if file exists on filesystem
  5. If file_format specified, verify extension matches
Note
After successful search, use GetPathName() to retrieve the full path.
Returns

Definition at line 133 of file PFindRun.cpp.

References CreatePathName(), fFileFormat, fInstrument, fPath, fPathName, and fRunNameTemplateList.

Referenced by main().

◆ GetPathName()

TString PFindRun::GetPathName ( )
inline

Returns the full path to the found run file.

Returns
Full filesystem path including filename and extension, or empty string if no file was found (call FoundPathName() first).

Definition at line 128 of file PFindRun.h.

References fPathName.

Referenced by main().

Member Data Documentation

◆ fFileFormat

TString PFindRun::fFileFormat {""}
private

Optional file format filter (empty = any)

Definition at line 145 of file PFindRun.h.

Referenced by FoundPathName(), and PFindRun().

◆ fInstrument

TString PFindRun::fInstrument {""}
private

Target instrument name (e.g., "GPS", "LEM")

Definition at line 142 of file PFindRun.h.

Referenced by DumpTemplateList(), FoundPathName(), and PFindRun().

◆ fPath

const PStringVector PFindRun::fPath
private

Search paths for data files.

Definition at line 140 of file PFindRun.h.

Referenced by FoundPathName(), PFindRun(), and PFindRun().

◆ fPathName

TString PFindRun::fPathName {""}
private

Resolved full path (empty until found)

Definition at line 146 of file PFindRun.h.

Referenced by FoundPathName(), and GetPathName().

◆ fRun

Int_t PFindRun::fRun {-1}
private

Run number (-1 if not specified)

Definition at line 144 of file PFindRun.h.

Referenced by CreatePathName(), DumpTemplateList(), and PFindRun().

◆ fRunNameTemplateList

const PRunNameTemplateList PFindRun::fRunNameTemplateList
private

Template patterns per instrument.

Definition at line 141 of file PFindRun.h.

Referenced by DumpTemplateList(), FoundPathName(), PFindRun(), and PFindRun().

◆ fYear

Int_t PFindRun::fYear {-1}
private

Run year (-1 if not specified)

Definition at line 143 of file PFindRun.h.

Referenced by CreatePathName(), DumpTemplateList(), and PFindRun().


The documentation for this class was generated from the following files: