/[PAMELA software]/yoda/techmodel/physics/NeutronDetectorReader.cpp
ViewVC logotype

Contents of /yoda/techmodel/physics/NeutronDetectorReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Tue Sep 21 20:24:53 2004 UTC (20 years, 2 months ago) by kusanagi
Branch: MAIN
Changes since 1.1: +7 -5 lines
Commit toward log4cxx plus new packets types

1
2 #include <string>
3 #include <log4cxx/logger.h>
4 #include "NeutronDetectorReader.h"
5
6 using namespace pamela;
7 using namespace pamela::neutron;
8
9 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.neutron.NeutronDetectorReader"));
10
11 /**
12 * Constructor.
13 */
14 NeutronDetectorReader::NeutronDetectorReader(void):
15 TechmodelAlgorithm(PacketType::Physics, "TechmodelNeutronDetectorReader") {
16 logger->debug(_T("Constructor"));
17 neutronEvent = new NeutronEvent();
18 }
19
20 /**
21 * Get a string with the version info of the algorithm.
22 */
23 std::string NeutronDetectorReader::GetVersionInfo(void) const {
24 return
25 "$Header: /home/cvsmanager/yoda/techmodel/physics/NeutronDetectorReader.cpp,v 1.1 2004/08/19 15:24:58 kusanagi Exp $";
26 }
27
28 /**
29 * Initialize the algorithm with a special run. This will initialize the
30 * event reader routines for all packet types.
31 */
32 void NeutronDetectorReader::Init(PamelaRun *run) {
33 logger->debug(_T("Initialize"));
34 SetInputStream(run);
35 run->WriteSubPacket(this, &neutronEvent, neutronEvent->Class());
36 }
37
38 /**
39 * Unpack the anticounter event from an input file.
40 */
41 void NeutronDetectorReader::RunEvent(int EventNumber) {
42
43 }
44
45 /**
46 * Unpack the NeutronDetector data event from the physical packet.
47 */
48 void NeutronDetectorReader::RunEvent(int EventNumber, const char subData[], long int lenght) {
49 NeutronRecord *rec;
50 int offset = 0;
51 char *data = new char[lenght];
52 //the 2 bytes subtracted belong to the final event CRC bytes
53 memcpy(data, subData, lenght);
54 neutronEvent->Records->Clear();
55 TClonesArray &recs = *(neutronEvent->Records);
56 offset = 12;
57 if (haveData(data, lenght)){
58 for (int i = 0; i < 3; i++){
59 rec = new(recs[i]) NeutronRecord(); //aggiungo un nuovo NeutronRecord all'evento
60 rec->upperTrig = (((BYTE)data[lenght-offset])>>4);
61 rec->bottomTrig = (((BYTE)data[lenght-offset])&0x0F);
62 rec->upperBack = (((BYTE)data[lenght-offset+1])>>4);
63 rec->bottomBack = (((BYTE)data[lenght-offset+1])&0x0F);
64 offset = offset - 4*(i+1);
65 }
66 }
67 delete[] data;
68 }
69
70 bool NeutronDetectorReader::haveData(const char data[], long int lenght){
71 bool ret = false;
72 if (((data[lenght-1] && data[lenght - 5] && data[lenght - 9]) && 0x0F) &&
73 ((data[lenght-2] | data[lenght - 6] | data[lenght - 10]) == 0x00)) ret = true;
74 return ret;
75 }

  ViewVC Help
Powered by ViewVC 1.1.23