1 |
kusanagi |
1.1 |
/** @file |
2 |
|
|
* $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $ |
3 |
|
|
* $Id: TrackerReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $ |
4 |
|
|
* $Author: kusanagi $ |
5 |
|
|
* |
6 |
|
|
* Implementation of the CalorimeterReader class. |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
#include <string> |
10 |
|
|
#include <log4cpp/Category.hh> |
11 |
|
|
#include "CalorimeterReader.h" |
12 |
|
|
|
13 |
|
|
extern "C" { |
14 |
|
|
|
15 |
|
|
extern struct { |
16 |
|
|
int IEV2; |
17 |
|
|
int dexy[96][22][2]; |
18 |
|
|
int dexyc[96][22][2]; |
19 |
|
|
int base[96][22][2]; |
20 |
|
|
int calselftrig[7][4]; |
21 |
|
|
int calIItrig[4]; |
22 |
|
|
int calstripshift[4]; |
23 |
|
|
int calDSPtaberr[4]; |
24 |
|
|
int calevnum[4]; |
25 |
|
|
} evento_; |
26 |
|
|
|
27 |
|
|
int calunpack_(unsigned short[], long int*, int*); |
28 |
|
|
//Struct per il passaggio di dati da e verso la chiamata fortran |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
using namespace pamela; |
32 |
|
|
using namespace pamela::calorimeter; |
33 |
|
|
|
34 |
|
|
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.calorimeter.CalorimeterReader"); |
35 |
|
|
|
36 |
|
|
/** |
37 |
|
|
* Constructor. |
38 |
|
|
*/ |
39 |
|
|
CalorimeterReader::CalorimeterReader(void): |
40 |
|
|
TechmodelAlgorithm(PacketType::Physics, "TechmodelCalorimeterReader") { |
41 |
|
|
cat.debug("Constructor"); |
42 |
|
|
calorimeter = new CalorimeterEvent(); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
/** |
46 |
|
|
* Get a string with the version info of the algorithm. |
47 |
|
|
*/ |
48 |
|
|
std::string CalorimeterReader::GetVersionInfo(void) const { |
49 |
|
|
return |
50 |
|
|
"$Header: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $"; |
51 |
|
|
} |
52 |
|
|
|
53 |
|
|
/** |
54 |
|
|
* Initialize the algorithm with a special run. This will initialize the |
55 |
|
|
* event reader routines for all packet types. |
56 |
|
|
*/ |
57 |
|
|
void CalorimeterReader::Init(PamelaRun *run) { |
58 |
|
|
SetInputStream(run); |
59 |
|
|
run->WriteSubPacket(this, &calorimeter, calorimeter->Class()); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
/** |
63 |
|
|
* Unpack the calorimeter event from an input file. |
64 |
|
|
*/ |
65 |
|
|
void CalorimeterReader::RunEvent(int EventNumber) { |
66 |
|
|
|
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
/** |
70 |
|
|
* Unpack the Calorimeter data event from the physical packet. |
71 |
|
|
*/ |
72 |
|
|
void CalorimeterReader::RunEvent(int EventNumber, const char subData[], long int length) { |
73 |
|
|
char data[length]; |
74 |
|
|
memcpy(data, subData, length); |
75 |
|
|
int ERROR = 0; |
76 |
|
|
|
77 |
|
|
unsigned short convdata[length]; |
78 |
|
|
for (int i = 0; i<length; i++){ |
79 |
|
|
convdata[i] = (unsigned short)((unsigned char)subData[i]&0xFF); |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
|
83 |
|
|
//Call to the routine that unpack calorimeter events |
84 |
|
|
ERROR = calunpack_(convdata, &length, &ERROR); |
85 |
|
|
|
86 |
|
|
calorimeter->IEV2 = evento_.IEV2; |
87 |
|
|
memcpy(calorimeter->dexy, evento_.dexy, sizeof(calorimeter->dexy)); |
88 |
|
|
memcpy(calorimeter->dexyc, evento_.dexyc, sizeof(calorimeter->dexyc)); |
89 |
|
|
memcpy(calorimeter->base, evento_.base, sizeof(calorimeter->base)); |
90 |
|
|
memcpy(calorimeter->calselftrig, evento_.calselftrig, sizeof(calorimeter->calselftrig)); |
91 |
|
|
memcpy(calorimeter->calIItrig, evento_.calIItrig, sizeof(calorimeter->calIItrig)); |
92 |
|
|
memcpy(calorimeter->calstripshift, evento_.calstripshift, sizeof(calorimeter->calstripshift)); |
93 |
|
|
memcpy(calorimeter->calDSPtaberr, evento_.calDSPtaberr, sizeof(calorimeter->calDSPtaberr)); |
94 |
|
|
memcpy(calorimeter->calevnum, evento_.calevnum, sizeof(calorimeter->calevnum)); |
95 |
|
|
|
96 |
|
|
cat << log4cpp::Priority::ERROR |
97 |
|
|
<< "Fortran77 function calunpack error code = " << ERROR |
98 |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
99 |
|
|
} |