1 |
kusanagi |
1.9 |
/** @file |
2 |
kusanagi |
1.2 |
* $Source: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v $ |
3 |
kusanagi |
2.3 |
* $Id: PhysicsReader.cpp,v 2.2 2004/12/09 08:48:41 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 |
1.1 |
|
33 |
kusanagi |
1.9 |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.PhysicsReader")); |
34 |
kusanagi |
1.1 |
|
35 |
|
|
/** |
36 |
|
|
* Constructor. |
37 |
|
|
*/ |
38 |
|
|
PhysicsReader::PhysicsReader(void): |
39 |
kusanagi |
1.4 |
TechmodelAlgorithm(PacketType::Physics, "TechmodelPhysicsReader") { |
40 |
kusanagi |
1.9 |
logger->debug(_T("Constructor")); |
41 |
kusanagi |
2.2 |
trackerReader = new TrackerReader; |
42 |
|
|
anticounterReader = new AnticounterReader; |
43 |
|
|
calorimeterReader = new CalorimeterReader; |
44 |
|
|
neutronReader = new NeutronDetectorReader; |
45 |
|
|
s4Reader = new S4Reader; |
46 |
kusanagi |
1.1 |
} |
47 |
|
|
|
48 |
|
|
/** |
49 |
|
|
* Get a string with the version info of the algorithm. |
50 |
|
|
*/ |
51 |
|
|
std::string PhysicsReader::GetVersionInfo(void) const { |
52 |
|
|
return |
53 |
kusanagi |
2.3 |
"$Header: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v 2.2 2004/12/09 08:48:41 kusanagi Exp $\n"; |
54 |
kusanagi |
1.1 |
} |
55 |
|
|
|
56 |
|
|
/** |
57 |
|
|
* Initialize the algorithm with a special run. This will initialize the |
58 |
|
|
* event reader routines for all packet types. |
59 |
|
|
*/ |
60 |
|
|
void PhysicsReader::Init(PamelaRun *run) { |
61 |
|
|
SetInputStream(run); |
62 |
|
|
trackerReader->Init(run); |
63 |
kusanagi |
1.3 |
anticounterReader->Init(run); |
64 |
|
|
calorimeterReader->Init(run); |
65 |
kusanagi |
1.4 |
neutronReader->Init(run); |
66 |
kusanagi |
2.3 |
s4Reader->Init(run); |
67 |
kusanagi |
1.1 |
//run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class()); |
68 |
kusanagi |
1.9 |
logger->debug(_T("Initialize")); |
69 |
kusanagi |
1.1 |
} |
70 |
|
|
|
71 |
|
|
/** |
72 |
|
|
* Unpack the Physics event from an input file. |
73 |
|
|
*/ |
74 |
kusanagi |
2.1 |
void PhysicsReader::RunEvent(int EventNumber, long int dataLenght) throw (Exception){ |
75 |
kusanagi |
1.4 |
char *subData = new char[dataLenght]; |
76 |
|
|
InputFile->read(subData, sizeof(unsigned char)*dataLenght); |
77 |
kusanagi |
1.1 |
|
78 |
kusanagi |
1.3 |
/*-----------------*/ |
79 |
kusanagi |
1.1 |
//passo packetData a tutti i reader dei vari rivelatori |
80 |
kusanagi |
1.4 |
trackerReader->RunEvent(EventNumber, subData, dataLenght); |
81 |
kusanagi |
1.8 |
anticounterReader->RunEvent(EventNumber, subData, dataLenght); |
82 |
kusanagi |
1.4 |
calorimeterReader->RunEvent(EventNumber, subData, dataLenght); |
83 |
|
|
neutronReader->RunEvent(EventNumber, subData, dataLenght); |
84 |
kusanagi |
2.2 |
s4Reader->RunEvent(EventNumber, subData, dataLenght); |
85 |
kusanagi |
1.3 |
/*-----------------*/ |
86 |
kusanagi |
1.9 |
delete[] subData; |
87 |
kusanagi |
1.1 |
} |
88 |
|
|
|