1 | #include "DataProcessorImp.h"
|
---|
2 |
|
---|
3 | #include "HeadersFAD.h"
|
---|
4 | #include "FAD.h"
|
---|
5 | #include "tools.h"
|
---|
6 |
|
---|
7 | #include "DimWriteStatistics.h" // weird dependency
|
---|
8 |
|
---|
9 | using 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 | //
|
---|
19 | string 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 | DimWriteStatistics::CreateDirectory(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 |
|
---|
48 | bool 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 |
|
---|
69 | bool DataDump::WriteEvt(const EVENT &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.EventNum << " / " << e.TriggerNum;
|
---|
79 | Debug(str);
|
---|
80 |
|
---|
81 | return true;
|
---|
82 | }
|
---|
83 |
|
---|
84 | bool DataDump::Close(const RUN_TAIL *)
|
---|
85 | {
|
---|
86 | ostringstream str;
|
---|
87 | str << this << " - CLOSE FILE #" << GetRunId();
|
---|
88 |
|
---|
89 | Debug(str);
|
---|
90 |
|
---|
91 | return true;
|
---|
92 | }
|
---|
93 |
|
---|
94 | // =======================================================================
|
---|
95 |
|
---|
96 | bool DataDebug::WriteEvt(const EVENT &e)
|
---|
97 | {
|
---|
98 | cout << "WRITE_EVENT #" << GetRunId() << " (" << e.EventNum << ")" << endl;
|
---|
99 | cout << " Typ=" << e.TriggerType << endl;
|
---|
100 | cout << " roi=" << e.Roi << endl;
|
---|
101 | cout << " tim=" << e.PCTime << endl;
|
---|
102 |
|
---|
103 | return true;
|
---|
104 | }
|
---|
105 |
|
---|