1 |
kusanagi |
1.9 |
/** @file |
2 |
kusanagi |
1.2 |
* $Source: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v $ |
3 |
kusanagi |
3.0 |
* $Id: PhysicsReader.cpp,v 2.4 2005/01/29 00:26:55 kusanagi Exp $ |
4 |
kusanagi |
1.2 |
* $Author: kusanagi $ |
5 |
kusanagi |
1.1 |
* |
6 |
|
|
* Implementation of the LogReader class. |
7 |
|
|
* ToBeDone: |
8 |
|
|
* Control the CRC for the entire data Packet not just for single records |
9 |
|
|
*/ |
10 |
|
|
|
11 |
|
|
#define UINT unsigned int |
12 |
|
|
#define BYTE unsigned char |
13 |
|
|
#include <string> |
14 |
kusanagi |
1.9 |
#include <log4cxx/logger.h> |
15 |
kusanagi |
1.1 |
extern "C" { |
16 |
|
|
#include <sys/time.h> |
17 |
|
|
#include "CRC.h" |
18 |
|
|
} |
19 |
|
|
|
20 |
|
|
#include <fstream> |
21 |
|
|
#include "stdio.h" |
22 |
|
|
#include "ReaderAlgorithms.h" |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
using namespace pamela; |
26 |
|
|
using namespace pamela::techmodel; |
27 |
|
|
using namespace pamela::tracker; |
28 |
kusanagi |
1.3 |
using namespace pamela::anticounter; |
29 |
|
|
using namespace pamela::calorimeter; |
30 |
kusanagi |
1.4 |
using namespace pamela::neutron; |
31 |
kusanagi |
2.2 |
using namespace pamela::S4; |
32 |
kusanagi |
2.4 |
using namespace pamela::tof; |
33 |
|
|
using namespace pamela::trigger; |
34 |
kusanagi |
1.1 |
|
35 |
kusanagi |
1.9 |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.PhysicsReader")); |
36 |
kusanagi |
1.1 |
|
37 |
|
|
/** |
38 |
|
|
* Constructor. |
39 |
|
|
*/ |
40 |
|
|
PhysicsReader::PhysicsReader(void): |
41 |
kusanagi |
2.4 |
TechmodelAlgorithm(PacketType::Physics, "TechmodelPhysicsReader") { |
42 |
|
|
logger->debug(_T("Constructor")); |
43 |
|
|
trackerReader = new TrackerReader; |
44 |
|
|
anticounterReader = new AnticounterReader; |
45 |
|
|
calorimeterReader = new CalorimeterReader; |
46 |
|
|
neutronReader = new NeutronDetectorReader; |
47 |
|
|
s4Reader = new S4Reader; |
48 |
|
|
tofReader = new TofReader; |
49 |
|
|
triggerReader = new TriggerReader; |
50 |
kusanagi |
1.1 |
} |
51 |
|
|
|
52 |
|
|
/** |
53 |
|
|
* Get a string with the version info of the algorithm. |
54 |
|
|
*/ |
55 |
|
|
std::string PhysicsReader::GetVersionInfo(void) const { |
56 |
|
|
return |
57 |
kusanagi |
3.0 |
"$Header: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v 2.4 2005/01/29 00:26:55 kusanagi Exp $\n"; |
58 |
kusanagi |
1.1 |
} |
59 |
|
|
|
60 |
|
|
/** |
61 |
|
|
* Initialize the algorithm with a special run. This will initialize the |
62 |
|
|
* event reader routines for all packet types. |
63 |
|
|
*/ |
64 |
|
|
void PhysicsReader::Init(PamelaRun *run) { |
65 |
kusanagi |
2.4 |
SetInputStream(run); |
66 |
|
|
trackerReader->Init(run); |
67 |
|
|
anticounterReader->Init(run); |
68 |
|
|
calorimeterReader->Init(run); |
69 |
|
|
neutronReader->Init(run); |
70 |
|
|
s4Reader->Init(run); |
71 |
|
|
tofReader->Init(run); |
72 |
|
|
triggerReader->Init(run); |
73 |
kusanagi |
1.1 |
//run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class()); |
74 |
kusanagi |
1.9 |
logger->debug(_T("Initialize")); |
75 |
kusanagi |
1.1 |
} |
76 |
|
|
|
77 |
|
|
/** |
78 |
|
|
* Unpack the Physics event from an input file. |
79 |
|
|
*/ |
80 |
kusanagi |
2.1 |
void PhysicsReader::RunEvent(int EventNumber, long int dataLenght) throw (Exception){ |
81 |
kusanagi |
1.4 |
char *subData = new char[dataLenght]; |
82 |
|
|
InputFile->read(subData, sizeof(unsigned char)*dataLenght); |
83 |
kusanagi |
1.1 |
|
84 |
kusanagi |
2.4 |
/*-----------------*/ |
85 |
|
|
//passo packetData a tutti i reader dei vari rivelatori |
86 |
|
|
trackerReader->RunEvent(EventNumber, subData, dataLenght); |
87 |
|
|
anticounterReader->RunEvent(EventNumber, subData, dataLenght); |
88 |
|
|
calorimeterReader->RunEvent(EventNumber, subData, dataLenght); |
89 |
|
|
neutronReader->RunEvent(EventNumber, subData, dataLenght); |
90 |
|
|
s4Reader->RunEvent(EventNumber, subData, dataLenght); |
91 |
|
|
tofReader->RunEvent(EventNumber, subData, dataLenght); |
92 |
|
|
triggerReader->RunEvent(EventNumber, subData, dataLenght); |
93 |
|
|
/*-----------------*/ |
94 |
kusanagi |
1.9 |
delete[] subData; |
95 |
kusanagi |
1.1 |
} |
96 |
|
|
|