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

Last change on this file since 13132 was 12477, checked in by tbretz, 13 years ago
Moved RunDescription to HeadersFAD, added it as a second argument to Open and write the run-type to the header.
File size: 2.5 KB
Line 
1#include "DataProcessorImp.h"
2
3#include "FAD.h"
4
5#include "DimWriteStatistics.h" // weird dependency
6
7using 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//
17string 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
30 const Time night = time - boost::posix_time::hours(12);
31
32 name << night.GetAsStr("%Y/%m/%d/");
33
34 try
35 {
36 DimWriteStatistics::CreateDirectory(name.str());
37 }
38 catch (const runtime_error &)
39 {
40 // File creation will fail anyway
41 //Error(e.what());
42 }
43
44 name << time.NightAsInt() << '_' << setfill('0') << setw(3) << runid << '.' << extension;
45 return name.str();
46}
47
48// =======================================================================
49
50bool DataDump::Open(const RUN_HEAD* h, const FAD::RunDescription &)
51{
52 fFileName = "/dev/null";
53
54 ostringstream str;
55 str << this << " - "
56 << "OPEN_FILE #" << GetRunId() << ":"
57 << " Ver=" << h->Version
58 << " Typ=" << h->RunType
59 << " Nb=" << h->NBoard
60 << " Np=" << h->NPix
61 << " NTm=" << h->NTm
62 << " roi=" << h->Nroi;
63
64 Debug(str);
65
66 fTime = Time();
67
68 return true;
69}
70
71bool DataDump::WriteEvt(EVENT *e)
72{
73 const Time now;
74 if (now-fTime<boost::posix_time::seconds(5))
75 return true;
76
77 fTime = now;
78
79 ostringstream str;
80 str << this << " - EVENT #" << e->EventNum << " / " << e->TriggerNum;
81 Debug(str);
82
83 return true;
84}
85
86bool DataDump::Close(RUN_TAIL *)
87{
88 ostringstream str;
89 str << this << " - CLOSE FILE #" << GetRunId();
90
91 Debug(str);
92
93 return true;
94}
95
96// =======================================================================
97
98bool DataDebug::WriteEvt(EVENT *e)
99{
100 cout << "WRITE_EVENT #" << GetRunId() << " (" << e->EventNum << ")" << endl;
101 cout << " Typ=" << e->TriggerType << endl;
102 cout << " roi=" << e->Roi << endl;
103 cout << " trg=" << e->SoftTrig << endl;
104 cout << " tim=" << e->PCTime << endl;
105
106 return true;
107}
108
Note: See TracBrowser for help on using the repository browser.