Belle II Software development
PedeSteering Class Reference

Class representing Millepede steering. More...

#include <PedeSteering.h>

Inheritance diagram for PedeSteering:

Public Member Functions

 PedeSteering ()
 Default constructor.
 
 PedeSteering (const std::string &filename)
 Constructor to directly import command from file.
 
virtual ~PedeSteering ()
 Destructor.
 
void import (std::string filename)
 Load commands from existing text file.
 
void command (std::string line)
 Add command to the steering.
 
std::string make (std::string filename="")
 Compose and write out steering file.
 
void fixParameters (std::vector< int > labels, std::vector< double > values={}, std::vector< double > presigmas={})
 Fix parameter values and set presigmas.
 
void addFile (std::string filename, double weight=1.)
 Add a file (optionally with weight) to list of binary files.
 
void clearFiles ()
 Clear list of files.
 

Private Attributes

std::vector< std::string > commands
 list command lines
 
std::vector< std::string > files
 list of binary files
 
std::string name
 Name of steering (used as default filename)
 

Detailed Description

Class representing Millepede steering.

Definition at line 23 of file PedeSteering.h.

Constructor & Destructor Documentation

◆ PedeSteering() [1/2]

PedeSteering ( )
inline

Default constructor.

Definition at line 26 of file PedeSteering.h.

26: commands(), files(), name("PedeSteering.txt") {}
std::vector< std::string > files
list of binary files
Definition: PedeSteering.h:59
std::string name
Name of steering (used as default filename)
Definition: PedeSteering.h:61
std::vector< std::string > commands
list command lines
Definition: PedeSteering.h:57

◆ PedeSteering() [2/2]

PedeSteering ( const std::string &  filename)
inlineexplicit

Constructor to directly import command from file.

Parameters
filenametext file with Pede commands

Definition at line 29 of file PedeSteering.h.

29: commands(), files(), name(filename) {}

◆ ~PedeSteering()

virtual ~PedeSteering ( )
inlinevirtual

Destructor.

Definition at line 31 of file PedeSteering.h.

31{}

Member Function Documentation

◆ addFile()

void addFile ( std::string  filename,
double  weight = 1. 
)

Add a file (optionally with weight) to list of binary files.

Definition at line 69 of file PedeSteering.cc.

70{
71 if (weight != 1.)
72 filename = filename + " -- " + std::to_string(weight);
73 bool exists = false;
74 for (auto file : files)
75 if (file == filename)
76 exists = true;
77 if (!exists)
78 files.push_back(filename);
79}

◆ clearFiles()

void clearFiles ( )
inline

Clear list of files.

Definition at line 53 of file PedeSteering.h.

53{files.clear();}

◆ command()

void command ( std::string  line)

Add command to the steering.

Parameters
lineLine with command to be added

Definition at line 35 of file PedeSteering.cc.

36{
37 commands.push_back(line);
38}

◆ fixParameters()

void fixParameters ( std::vector< int >  labels,
std::vector< double >  values = {},
std::vector< double >  presigmas = {} 
)

Fix parameter values and set presigmas.

Parameters
labelsVector of Pede labels (see GlobalLabel.h)
valuesVector (of size labels) with values to be set to parameters in labels
presigmasVector (of size labels) with presigmas for parameters (<0 means fixed parameter)

Definition at line 51 of file PedeSteering.cc.

52{
53 command("Parameters");
54 bool useValues = (labels.size() == values.size());
55 bool usePresigmas = (labels.size() == presigmas.size());
56
57 for (unsigned int i = 0; i < labels.size(); i++) {
58 double value = 0.;
59 double presigma = -1.;
60 if (useValues)
61 value = values[i];
62 if (usePresigmas)
63 presigma = presigmas[i];
64
65 command(to_string(labels[i]) + " " + to_string(value) + " " + to_string(presigma));
66 }
67}
void command(std::string line)
Add command to the steering.
Definition: PedeSteering.cc:35

◆ import()

void import ( std::string  filename)

Load commands from existing text file.

Parameters
filenamePath to txt file to be loaded

Definition at line 39 of file PedeSteering.cc.

40{
41 commands.clear();
42 ifstream file(filename);
43 if (!file.is_open())
44 return;
45
46 string commandLine;
47 while (getline(file, commandLine))
48 command(commandLine);
49}

◆ make()

string make ( std::string  filename = "")

Compose and write out steering file.

Parameters
filenameOutput steering file name

Definition at line 16 of file PedeSteering.cc.

17{
18 command("end");
19 if (filename == "")
20 filename = name;
21 ofstream file(filename.c_str());
22 file << "! Steerig file for Pede generated by PedeSteering class !" << endl;
23 file << "Cfiles" << endl;
24 for (string& cfile : files)
25 file << cfile << endl;
26
27 file << endl;
28
29 for (string& command : commands)
30 file << command << endl;
31
32 file.close();
33 return filename;
34}

Member Data Documentation

◆ commands

std::vector<std::string> commands
private

list command lines

Definition at line 57 of file PedeSteering.h.

◆ files

std::vector<std::string> files
private

list of binary files

Definition at line 59 of file PedeSteering.h.

◆ name

std::string name
private

Name of steering (used as default filename)

Definition at line 61 of file PedeSteering.h.


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