Belle II Software development
PedeApplication.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <alignment/PedeApplication.h>
10
11#include <fstream>
12#include <sstream>
13
14using namespace std;
15namespace Belle2 {
20 namespace alignment {
21
22 // -----------
23 // PedeApplication
24 // -----------
26 {
27 int ver(-1);
28 string tmpfile("pede_test.tmp.txt");
29
30 string cmd("pede > " + tmpfile);
31 system(cmd.c_str());
32
33 ifstream file(tmpfile);
34 string line; string verText;
35
36 getline(file, line);
37 stringstream ss(line);
38 ss >> verText >> ver;
39
40 remove(tmpfile.c_str());
41 return ver;
42 }
43 void PedeApplication::readEndFile(string filename)
44 {
45 stringstream ss;
46 ifstream result(filename);
47 result >> exitCode;
48 ss << result.rdbuf();
49 exitMessage = ss.str();
50 }
52 {
53 PedeResult result;
54 if (run(steering)) {
55 result.read("millepede.res");
56 result.readEigenFile("millepede.eve");
57 }
58 return result;
59 }
61 {
62 string cmd("export OMP_THREAD_LIMIT=1000 && pede " + steering.make());
63 int retval = system(cmd.c_str());
64 if (retval != 0)
65 return false;
67 return !aborted();
68 }
69
71 {
72 switch (exitCode) {
73 // No warnings
74 case 0:
75 return 0;
76 // Mild warnings (result can be used)
77 case 1:
78 return 1;
79 // Severe warnings (result should not be used - add more data)
80 case 2:
81 return 2;
82 // Extreme warnings (result must not be used - problem not well defined)
83 case 3:
84 return 3;
85 // crashed or aborted:
86 default:
87 return 101;
88 }
89 }
90 }
92}
Class representing Millepede steering.
Definition: PedeSteering.h:23
bool run(PedeSteering &steering)
Run Pede with given steering.
PedeResult calibrate(PedeSteering &steering)
Run Pede and return full result with parameter corrections.
int warnings() const
Level of warnings converted to int.
std::string exitMessage
Pede exit message.
void readEndFile(std::string filename="millepede.end")
Reads the millepede.end file and sets this object retrieved state.
bool aborted() const
True if Pede was aborted (parameters not calculated)
int revision()
Return Pede revision number.
Class to process Pede result file(s)
Definition: PedeResult.h:22
Abstract base class for different kinds of events.
STL namespace.