1 |
kusanagi |
1.1 |
/** @file |
2 |
kusanagi |
1.2 |
* $Source: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v $ |
3 |
kusanagi |
1.4 |
* $Id: CalorimeterReader.cpp,v 1.3 2004/08/20 15:01:50 kusanagi Exp $ |
4 |
kusanagi |
1.1 |
* $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 |
kusanagi |
1.2 |
int stwerr; |
18 |
|
|
int perror; |
19 |
|
|
int dexy[2][22][96]; |
20 |
|
|
int dexyc[2][22][96]; |
21 |
|
|
int base[2][22][96]; |
22 |
|
|
int calselftrig[4][7]; |
23 |
kusanagi |
1.1 |
int calIItrig[4]; |
24 |
|
|
int calstripshift[4]; |
25 |
|
|
int calDSPtaberr[4]; |
26 |
|
|
int calevnum[4]; |
27 |
|
|
} evento_; |
28 |
|
|
|
29 |
kusanagi |
1.2 |
void calunpack_(short[], long int*, int*); |
30 |
kusanagi |
1.1 |
//Struct per il passaggio di dati da e verso la chiamata fortran |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
using namespace pamela; |
34 |
|
|
using namespace pamela::calorimeter; |
35 |
|
|
|
36 |
|
|
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.calorimeter.CalorimeterReader"); |
37 |
|
|
|
38 |
|
|
/** |
39 |
|
|
* Constructor. |
40 |
|
|
*/ |
41 |
|
|
CalorimeterReader::CalorimeterReader(void): |
42 |
|
|
TechmodelAlgorithm(PacketType::Physics, "TechmodelCalorimeterReader") { |
43 |
|
|
cat.debug("Constructor"); |
44 |
|
|
calorimeter = new CalorimeterEvent(); |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* Get a string with the version info of the algorithm. |
49 |
|
|
*/ |
50 |
|
|
std::string CalorimeterReader::GetVersionInfo(void) const { |
51 |
|
|
return |
52 |
kusanagi |
1.4 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v 1.3 2004/08/20 15:01:50 kusanagi Exp $"; |
53 |
kusanagi |
1.1 |
} |
54 |
|
|
|
55 |
|
|
/** |
56 |
|
|
* Initialize the algorithm with a special run. This will initialize the |
57 |
|
|
* event reader routines for all packet types. |
58 |
|
|
*/ |
59 |
|
|
void CalorimeterReader::Init(PamelaRun *run) { |
60 |
|
|
SetInputStream(run); |
61 |
|
|
run->WriteSubPacket(this, &calorimeter, calorimeter->Class()); |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
/** |
65 |
|
|
* Unpack the calorimeter event from an input file. |
66 |
|
|
*/ |
67 |
|
|
void CalorimeterReader::RunEvent(int EventNumber) { |
68 |
|
|
|
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
/** |
72 |
|
|
* Unpack the Calorimeter data event from the physical packet. |
73 |
|
|
*/ |
74 |
|
|
void CalorimeterReader::RunEvent(int EventNumber, const char subData[], long int length) { |
75 |
|
|
char data[length]; |
76 |
|
|
memcpy(data, subData, length); |
77 |
|
|
int ERROR = 0; |
78 |
|
|
|
79 |
|
|
unsigned short convdata[length]; |
80 |
|
|
for (int i = 0; i<length; i++){ |
81 |
|
|
convdata[i] = (unsigned short)((unsigned char)subData[i]&0xFF); |
82 |
|
|
} |
83 |
kusanagi |
1.2 |
|
84 |
|
|
//Call to the routine that unpack calorimeter events |
85 |
|
|
calunpack_((short*)convdata, &length, &ERROR); |
86 |
kusanagi |
1.3 |
|
87 |
|
|
if (ERROR != 0) { |
88 |
|
|
char *errmsg; |
89 |
|
|
switch (ERROR){ |
90 |
|
|
case 1: errmsg = "CALORIMETER NOT FOUND"; |
91 |
|
|
} |
92 |
|
|
cat << log4cpp::Priority::ERROR |
93 |
kusanagi |
1.4 |
<< "Fortran77 function calunpack: " << errmsg |
94 |
kusanagi |
1.3 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
95 |
|
|
} else { |
96 |
|
|
calorimeter->IEV2 = evento_.IEV2; |
97 |
|
|
calorimeter->stwerr = evento_.stwerr; |
98 |
|
|
calorimeter->perror = evento_.perror; |
99 |
|
|
|
100 |
|
|
//--------have to invert array because of FORTRAN <-> C different management of the indexes |
101 |
|
|
int tempDexy[96][22][2]; |
102 |
|
|
int tempDexyc[96][22][2]; |
103 |
|
|
int tempBase[96][22][2]; |
104 |
|
|
int tempCalselftrig[7][4]; |
105 |
|
|
memcpy(tempDexy, evento_.dexy, sizeof(tempDexy)); |
106 |
|
|
memcpy(tempDexyc, evento_.dexyc, sizeof(tempDexyc)); |
107 |
|
|
memcpy(tempBase, evento_.base, sizeof(tempBase)); |
108 |
|
|
memcpy(tempCalselftrig, evento_.calselftrig, sizeof(tempCalselftrig)); |
109 |
|
|
|
110 |
|
|
for (int i = 0; i < 4; i++){ |
111 |
|
|
for (int j = 0; j < 7; j++){ |
112 |
|
|
calorimeter->calselftrig[i][j] = tempCalselftrig[j][i]; |
113 |
|
|
} |
114 |
kusanagi |
1.2 |
} |
115 |
|
|
|
116 |
kusanagi |
1.3 |
for (int i = 0; i < 2; i++){ |
117 |
|
|
for (int j = 0; j < 22; j++){ |
118 |
|
|
for (int z = 0; z < 96; z++){ |
119 |
|
|
calorimeter->dexy[i][j][z] = tempDexy[z][j][i]; |
120 |
|
|
calorimeter->dexyc[i][j][z] = tempDexyc[z][j][i]; |
121 |
|
|
calorimeter->base[i][j][z] = tempBase[z][j][i]; |
122 |
|
|
} |
123 |
kusanagi |
1.2 |
} |
124 |
|
|
} |
125 |
kusanagi |
1.3 |
//----------------------------------------------------------------------------------------- |
126 |
|
|
|
127 |
|
|
memcpy(calorimeter->calIItrig, evento_.calIItrig, sizeof(calorimeter->calIItrig)); |
128 |
|
|
memcpy(calorimeter->calstripshift, evento_.calstripshift, sizeof(calorimeter->calstripshift)); |
129 |
|
|
memcpy(calorimeter->calDSPtaberr, evento_.calDSPtaberr, sizeof(calorimeter->calDSPtaberr)); |
130 |
|
|
memcpy(calorimeter->calevnum, evento_.calevnum, sizeof(calorimeter->calevnum)); |
131 |
kusanagi |
1.2 |
} |
132 |
kusanagi |
1.1 |
} |