1 | #include "DataProcessorImp.h"
|
---|
2 |
|
---|
3 | #include "FAD.h"
|
---|
4 |
|
---|
5 | #include "DimWriteStatistics.h" // weird dependency
|
---|
6 |
|
---|
7 | using namespace std;
|
---|
8 |
|
---|
9 |
|
---|
10 | // --------------------------------------------------------------------------
|
---|
11 | //
|
---|
12 | //! This creates an appropriate file name for a particular run number and type
|
---|
13 | //! @param runNumberq the run number for which a filename is to be created
|
---|
14 | //! @param runType an int describing the kind of run. 0=Data, 1=Pedestal, 2=Calibration, 3=Calibrated data
|
---|
15 | //! @param extension a string containing the extension to be appened to the file name
|
---|
16 | //
|
---|
17 | string DataProcessorImp::FormFileName(const string &path, uint32_t runid, const string &extension)
|
---|
18 | {
|
---|
19 | ostringstream name;
|
---|
20 |
|
---|
21 | if (!path.empty())
|
---|
22 | {
|
---|
23 | name << path;
|
---|
24 | if (path[path.length()-1] != '/')
|
---|
25 | name << '/';
|
---|
26 | }
|
---|
27 |
|
---|
28 | const Time time;
|
---|
29 | name << time.GetAsStr("%Y/%m/%d/");
|
---|
30 |
|
---|
31 | try
|
---|
32 | {
|
---|
33 | DimWriteStatistics::CreateDirectory(name.str());
|
---|
34 | }
|
---|
35 | catch (const runtime_error &)
|
---|
36 | {
|
---|
37 | // File creation will fail anyway
|
---|
38 | //Error(e.what());
|
---|
39 | }
|
---|
40 |
|
---|
41 | name << time.NightAsInt() << '_' << setfill('0') << setw(3) << runid << '.' << extension;
|
---|
42 | return name.str();
|
---|
43 | }
|
---|
44 |
|
---|
45 | // =======================================================================
|
---|
46 |
|
---|
47 | bool DataDump::Open(RUN_HEAD* h)
|
---|
48 | {
|
---|
49 | fFileName = "/dev/null";
|
---|
50 |
|
---|
51 | ostringstream str;
|
---|
52 | str << this << " - "
|
---|
53 | << "OPEN_FILE #" << GetRunId() << ":"
|
---|
54 | << " Ver=" << h->Version
|
---|
55 | << " Typ=" << h->RunType
|
---|
56 | << " Nb=" << h->NBoard
|
---|
57 | << " Np=" << h->NPix
|
---|
58 | << " NTm=" << h->NTm
|
---|
59 | << " roi=" << h->Nroi;
|
---|
60 |
|
---|
61 | Debug(str);
|
---|
62 |
|
---|
63 | fTime = Time();
|
---|
64 |
|
---|
65 | return true;
|
---|
66 | }
|
---|
67 |
|
---|
68 | bool DataDump::WriteEvt(EVENT *e)
|
---|
69 | {
|
---|
70 | const Time now;
|
---|
71 | if (now-fTime<boost::posix_time::seconds(5))
|
---|
72 | return true;
|
---|
73 |
|
---|
74 | fTime = now;
|
---|
75 |
|
---|
76 | ostringstream str;
|
---|
77 | str << this << " - EVENT #" << e->EventNum << " / " << e->TriggerNum;
|
---|
78 | Debug(str);
|
---|
79 |
|
---|
80 | return true;
|
---|
81 | }
|
---|
82 |
|
---|
83 | bool DataDump::Close(RUN_TAIL *)
|
---|
84 | {
|
---|
85 | ostringstream str;
|
---|
86 | str << this << " - CLOSE FILE #" << GetRunId();
|
---|
87 |
|
---|
88 | Debug(str);
|
---|
89 |
|
---|
90 | return true;
|
---|
91 | }
|
---|
92 |
|
---|
93 | // =======================================================================
|
---|
94 |
|
---|
95 | bool DataDebug::WriteEvt(EVENT *e)
|
---|
96 | {
|
---|
97 | cout << "WRITE_EVENT #" << GetRunId() << " (" << e->EventNum << ")" << endl;
|
---|
98 | cout << " Typ=" << e->TriggerType << endl;
|
---|
99 | cout << " roi=" << e->Roi << endl;
|
---|
100 | cout << " trg=" << e->SoftTrig << endl;
|
---|
101 | cout << " tim=" << e->PCTime << endl;
|
---|
102 |
|
---|
103 | return true;
|
---|
104 | }
|
---|
105 |
|
---|