Belle II Software  release-05-01-25
PedeApplication.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Tadeas Bilka *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <alignment/PedeApplication.h>
12 
13 #include <fstream>
14 #include <sstream>
15 
16 using namespace std;
17 namespace Belle2 {
22  namespace alignment {
23 
24  // -----------
25  // PedeApplication
26  // -----------
27  int PedeApplication::revision()
28  {
29  int ver(-1);
30  string tmpfile("pede_test.tmp.txt");
31 
32  string cmd("pede > " + tmpfile);
33  system(cmd.c_str());
34 
35  ifstream file(tmpfile);
36  string line; string verText;
37 
38  getline(file, line);
39  stringstream ss(line);
40  ss >> verText >> ver;
41 
42  remove(tmpfile.c_str());
43  return ver;
44  }
45  void PedeApplication::readEndFile(string filename)
46  {
47  stringstream ss;
48  ifstream result(filename);
49  result >> exitCode;
50  ss << result.rdbuf();
51  exitMessage = ss.str();
52  }
53  PedeResult PedeApplication::calibrate(PedeSteering& steering)
54  {
55  PedeResult result;
56  if (run(steering)) {
57  result.read("millepede.res");
58  result.readEigenFile("millepede.eve");
59  }
60  return result;
61  }
62  bool PedeApplication::run(PedeSteering& steering)
63  {
64  string cmd("pede " + steering.make());
65  int retval = system(cmd.c_str());
66  if (retval != 0)
67  return false;
68  readEndFile();
69  return !aborted();
70  }
71 
72  int PedeApplication::warnings() const
73  {
74  switch (exitCode) {
75  // No warnings
76  case 0:
77  return 0;
78  // Mild warnings (result can be used)
79  case 1:
80  return 1;
81  // Severe warnings (result should not be used - add more data)
82  case 2:
83  return 2;
84  // Extreme warnings (result must not be used - problem not well defined)
85  case 3:
86  return 3;
87  // crashed or aborted:
88  default:
89  return 101;
90  }
91  }
92  }
94 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PedeSteering
Class representing Millepede steering.
Definition: PedeSteering.h:16
Belle2::alignment::PedeResult
Class to process Pede result file(s)
Definition: PedeResult.h:32