GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RunAgent.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010 by Olivier Stezowski *
3  * stezow(AT)ipnl.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef ADF_RunAgent
24 #include "RunAgent.h"
25 #endif
26 
27 using namespace ADF;
28 using namespace std;
29 
30 RunAgent::RunAgent(const Char_t *rid, const Char_t *srid, Bool_t is_record) :
31  DotConf(rid,srid,is_record),
32  fExperiment(""),
33  fDate(""),
34  fRunNumber(-1),
35  fSubRunNumber(-1),
36  fGlobalVertex(7)
37 {
38  fLog.GetProcessName() = "ADF::RunAgent";
39  Reset();
40 }
41 
43 {
44 }
45 
46 void RunAgent::Reset(const Char_t *opt)
47 {
48  if(!opt) fExperiment = "An experiment"; fRunNumber = fSubRunNumber = 0;
49  // x,y,z
50  fGlobalVertex[0] = 0;
51  fGlobalVertex[1] = 0;
52  fGlobalVertex[2] = 0;
53  // dx,dy,dz
54  fGlobalVertex[3] = 0;
55  fGlobalVertex[4] = 0;
56  fGlobalVertex[5] = 0;
57  // beta
58  fGlobalVertex[6] = 0;
59 }
60 
61 Bool_t RunAgent::ProcessLine(const string &aline)
62 {
63  string tmp1, tmp2; Bool_t ok_decode = true;
64 
65  if ( aline.find("Experiment:") == 0 ) {
66  fExperiment = aline.substr(11);
67  }
68  // get run number
69  if ( aline.find("RunNumber:") == 0 ) {
70  Int_t run, subrun;
71 
72  istringstream decode(aline);
73  // just to be sure ...
74  decode.clear();
75  decode >> tmp1 >> run >> subrun ;
76  if ( decode.good() ) { // expected format
77  fRunNumber = run; fSubRunNumber = subrun;
78  }
79  else ok_decode = false;
80  }
81  // get run number
82  if ( aline.find("GlobalVertex:") == 0 ) {
83  Double_t d0, d1, d2, d3, d4, d5, d6;
84 
85  istringstream decode(aline);
86  // just to be sure ...
87  decode.clear();
88  decode >> tmp1 >> d0 >> d1 >> d2 >> d3 >> d4 >> d5 >> d6 ;
89  if ( decode.good() ) { // expected format
90  // x,y,z
91  fGlobalVertex[0] = d0;
92  fGlobalVertex[1] = d1;
93  fGlobalVertex[2] = d2;
94  // dx,dy,dz
95  fGlobalVertex[3] = d3;
96  fGlobalVertex[4] = d4;
97  fGlobalVertex[5] = d5;
98  // beta
99  fGlobalVertex[6] = d6;
100  }
101  else ok_decode = false;
102  }
103  return ok_decode;
104 }
105 
106 Bool_t RunAgent::DoConfigure (ostream &out)
107 {
108  // add a start record
109  AddRecord(out,'b');
110 
111  out << "# Experiment Name \n";
112  out << "Experiment: " << fExperiment << "\n";
113  out << "# Run, Subrun \n";
114  out << "RunNumber: " << fRunNumber << " " << fSubRunNumber << "\n";
115  out << "# Global vertex x,y,z,dx,dy,dz,beta \n";
116  out << "GlobalVertex: "
117  << fGlobalVertex[0]
118  << " "
119  << fGlobalVertex[1]
120  << " "
121  << fGlobalVertex[2]
122  << " "
123  << fGlobalVertex[3]
124  << " "
125  << fGlobalVertex[4]
126  << " "
127  << fGlobalVertex[5]
128  << " "
129  << fGlobalVertex[6]
130  << "\n";
131 
132  // add an end of record
133  AddRecord(out,'e');
134 
135  return out.good();
136 }
137 
138 
139 
DotConf : Utility for class configuration from ascii file or Configuration frames.
Definition: DotConf.h:96
virtual ~RunAgent()
Definition: RunAgent.cpp:42
virtual Bool_t ProcessLine(const std::string &)
a helper template to do clones : it requires a default constructor. then it uses the Configure facili...
Definition: RunAgent.cpp:61
RunAgent(const Char_t *rid, const Char_t *srid, Bool_t is_record=true)
Definition: RunAgent.cpp:30
LogMessage fLog
the log messenger ... to know the object hae been properly intitialised/modified
Definition: DotConf.h:100
virtual void Reset(const Char_t *opt="")
Reset this object.
Definition: RunAgent.cpp:46
virtual Bool_t DoConfigure(std::istream &in, Bool_t allow_init)
configure this from an input stream
Definition: RunAgent.h:97
header file for RunAgent.cpp
virtual std::string & GetProcessName()
To get the Process name.
Bool_t AddRecord(std::ostream &, char t= 'b')
Add a begin or end of record, return true if done.
Definition: DotConf.cpp:198