| 1 | #include "DataProcessorImp.h"
|
|---|
| 2 |
|
|---|
| 3 | #include "FAD.h"
|
|---|
| 4 | #include "tools.h"
|
|---|
| 5 |
|
|---|
| 6 | #include "DimWriteStatistics.h" // weird dependency
|
|---|
| 7 |
|
|---|
| 8 | using namespace std;
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | // --------------------------------------------------------------------------
|
|---|
| 12 | //
|
|---|
| 13 | //! This creates an appropriate file name for a particular run number and type
|
|---|
| 14 | //! @param runNumberq the run number for which a filename is to be created
|
|---|
| 15 | //! @param runType an int describing the kind of run. 0=Data, 1=Pedestal, 2=Calibration, 3=Calibrated data
|
|---|
| 16 | //! @param extension a string containing the extension to be appened to the file name
|
|---|
| 17 | //
|
|---|
| 18 | string DataProcessorImp::FormFileName(const string &path, uint64_t night, uint32_t runid, const string &extension)
|
|---|
| 19 | {
|
|---|
| 20 | ostringstream name;
|
|---|
| 21 |
|
|---|
| 22 | if (!path.empty())
|
|---|
| 23 | {
|
|---|
| 24 | name << path;
|
|---|
| 25 | if (path[path.length()-1] != '/')
|
|---|
| 26 | name << '/';
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | name << Tools::Form("%04d/%02d/%02d/", night/10000, (night/100)%100, night%100);
|
|---|
| 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 << night << '_' << setfill('0') << setw(3) << runid << '.' << extension;
|
|---|
| 42 | return name.str();
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | // =======================================================================
|
|---|
| 46 |
|
|---|
| 47 | bool DataDump::Open(const RUN_HEAD* h, const FAD::RunDescription &)
|
|---|
| 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 |
|
|---|