1 |
|
|
2 |
#include <string> |
#include <string> |
3 |
#include <log4cpp/Category.hh> |
#include <log4cxx/logger.h> |
4 |
#include "NeutronDetectorReader.h" |
#include "NeutronDetectorReader.h" |
5 |
|
|
6 |
using namespace pamela; |
using namespace pamela; |
7 |
using namespace pamela::neutron; |
using namespace pamela::neutron; |
8 |
|
|
9 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.neutron.NeutronDetectorReader"); |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.neutron.NeutronDetectorReader")); |
10 |
|
|
11 |
/** |
/** |
12 |
* Constructor. |
* Constructor. |
13 |
*/ |
*/ |
14 |
NeutronDetectorReader::NeutronDetectorReader(void): |
NeutronDetectorReader::NeutronDetectorReader(void): |
15 |
TechmodelAlgorithm(PacketType::Physics, "TechmodelNeutronDetectorReader") { |
TechmodelAlgorithm(PacketType::Physics, "TechmodelNeutronDetectorReader") { |
16 |
cat.debug("Constructor"); |
logger->debug(_T("Constructor")); |
17 |
neutronEvent = new NeutronEvent(); |
neutronEvent = new NeutronEvent(); |
18 |
} |
} |
19 |
|
|
22 |
*/ |
*/ |
23 |
std::string NeutronDetectorReader::GetVersionInfo(void) const { |
std::string NeutronDetectorReader::GetVersionInfo(void) const { |
24 |
return |
return |
25 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/NeutronDetectorReader.cpp,v 1.1 2004/07/20 13:27:07 kusanagi Exp $"; |
"$Header: /home/cvsmanager/yoda/techmodel/physics/NeutronDetectorReader.cpp,v 1.1 2004/08/19 15:24:58 kusanagi Exp $"; |
26 |
} |
} |
27 |
|
|
28 |
/** |
/** |
30 |
* event reader routines for all packet types. |
* event reader routines for all packet types. |
31 |
*/ |
*/ |
32 |
void NeutronDetectorReader::Init(PamelaRun *run) { |
void NeutronDetectorReader::Init(PamelaRun *run) { |
33 |
|
logger->debug(_T("Initialize")); |
34 |
SetInputStream(run); |
SetInputStream(run); |
35 |
run->WriteSubPacket(this, &neutronEvent, neutronEvent->Class()); |
run->WriteSubPacket(this, &neutronEvent, neutronEvent->Class()); |
36 |
} |
} |
48 |
void NeutronDetectorReader::RunEvent(int EventNumber, const char subData[], long int lenght) { |
void NeutronDetectorReader::RunEvent(int EventNumber, const char subData[], long int lenght) { |
49 |
NeutronRecord *rec; |
NeutronRecord *rec; |
50 |
int offset = 0; |
int offset = 0; |
51 |
char data[lenght]; |
char *data = new char[lenght]; |
52 |
//the 2 bytes subtracted belong to the final event CRC bytes |
//the 2 bytes subtracted belong to the final event CRC bytes |
53 |
memcpy(data, subData, lenght); |
memcpy(data, subData, lenght); |
54 |
neutronEvent->Records->Clear(); |
neutronEvent->Records->Clear(); |
64 |
offset = offset - 4*(i+1); |
offset = offset - 4*(i+1); |
65 |
} |
} |
66 |
} |
} |
67 |
|
delete[] data; |
68 |
} |
} |
69 |
|
|
70 |
bool NeutronDetectorReader::haveData(const char data[], long int lenght){ |
bool NeutronDetectorReader::haveData(const char data[], long int lenght){ |