source: trunk/FACT++/src/DataProcessorImp.cc@ 18530

Last change on this file since 18530 was 17357, checked in by tbretz, 11 years ago
Fixed a compilation error.
File size: 2.5 KB
Line 
1#include "DataProcessorImp.h"
2
3#include <boost/filesystem.hpp>
4
5#include "HeadersFAD.h"
6#include "EventBuilder.h"
7#include "tools.h"
8
9using namespace std;
10
11
12// --------------------------------------------------------------------------
13//
14//! This creates an appropriate file name for a particular run number and type
15//! @param runNumberq the run number for which a filename is to be created
16//! @param runType an int describing the kind of run. 0=Data, 1=Pedestal, 2=Calibration, 3=Calibrated data
17//! @param extension a string containing the extension to be appened to the file name
18//
19string DataProcessorImp::FormFileName(const string &path, uint64_t night, uint32_t runid, const string &extension)
20{
21 ostringstream name;
22
23 if (!path.empty())
24 {
25 name << path;
26 if (path[path.length()-1] != '/')
27 name << '/';
28 }
29
30 name << Tools::Form("%04d/%02d/%02d/", night/10000, (night/100)%100, night%100);
31
32 try
33 {
34 boost::filesystem::create_directories(name.str());
35 }
36 catch (const runtime_error &)
37 {
38 // File creation will fail anyway
39 //Error(e.what());
40 }
41
42 name << night << '_' << setfill('0') << setw(3) << runid << '.' << extension;
43 return name.str();
44}
45
46// =======================================================================
47
48bool DataDump::Open(const RUN_HEAD &h, const FAD::RunDescription &d)
49{
50 fFileName = "/dev/null";
51
52 ostringstream str;
53 str << this << " - "
54 << "OPEN_FILE #" << GetRunId() << ":"
55 << " Ver=" << h.Version
56 << " Nb=" << h.NBoard
57 << " Np=" << h.NPix
58 << " NTm=" << h.NTm
59 << " roi=" << h.Nroi
60 << " Typ=" << d.name;
61
62 Debug(str);
63
64 fTime = Time();
65
66 return true;
67}
68
69bool DataDump::WriteEvt(const EVT_CTRL2 &e)
70{
71 const Time now;
72 if (now-fTime<boost::posix_time::seconds(5))
73 return true;
74
75 fTime = now;
76
77 ostringstream str;
78 str << this << " - EVENT #" << e.evNum << " / " << e.trgNum;
79 Debug(str);
80
81 return true;
82}
83
84bool DataDump::Close(const EVT_CTRL2 &)
85{
86 ostringstream str;
87 str << this << " - CLOSE FILE #" << GetRunId();
88
89 Debug(str);
90
91 return true;
92}
93
94// =======================================================================
95
96bool DataDebug::WriteEvt(const EVT_CTRL2 &e)
97{
98 cout << "WRITE_EVENT #" << GetRunId() << " (" << e.evNum << ")" << endl;
99 cout << " Typ=" << e.trgTyp << endl;
100 cout << " roi=" << e.nRoi << endl;
101 cout << " tim=" << e.time.tv_sec << endl;
102
103 return true;
104}
105
Note: See TracBrowser for help on using the repository browser.