/[PAMELA software]/chewbacca/PamOffLineSW/techmodel/CalibCalPedReader.cpp
ViewVC logotype

Contents of /chewbacca/PamOffLineSW/techmodel/CalibCalPedReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Tue Sep 23 07:20:28 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Branch point for: v0r00
Initial revision

1
2 extern "C" {
3
4 //Struct per il passaggio di dati da e verso la chiamata fortran
5 extern struct {
6 int iev;
7 int cstwerr[4];
8 float cperror[4];
9 float calped[4][11][96];
10 float calgood[4][11][96];
11 float calthr[4][11][6];
12 float calrms[4][11][96];
13 float calbase[4][11][6];
14 float calvar[4][11][6];
15 //float calpuls[4][11][96];
16 } calib_;
17 //external declaration of the Fortran function
18 void calpedestal_(char*, long int*, int*);
19 }
20
21 #include "ReaderAlgorithms.h"
22 using namespace pamela::techmodel;
23
24
25 /**
26 * Constructor.
27 */
28 CalibCalPedReader::CalibCalPedReader(void):
29 TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalPedReader") {
30 calibCalPed = new CalibCalPedEvent();
31 }
32
33
34
35 /**
36 * Initialize the algorithm with a special run. This will initialize the
37 * event reader routines for all packet types.
38 */
39 void CalibCalPedReader::Init(PamelaRun *run) {
40 run->WriteSubPacket(this, &calibCalPed, calibCalPed->Class());
41 }
42
43 /**
44 * Unpack the CalibCalPed event from an input file.
45 */
46 void CalibCalPedReader::PKT_RunEvent(char* packetData, long int dataLength) throw (CalibException){
47 stringstream oss;
48 string msg;
49 int ERROR;
50 calpedestal_((char*)packetData, &dataLength, &ERROR);
51 calibCalPed->unpackError = ERROR;
52 if (ERROR != 0) {
53 char *errmsg;
54 switch (ERROR){
55 case 1: errmsg = "CALORIMETER NOT FOUND";
56 }
57 oss.str("");
58 oss << "CalibCalPed: Fortran77 function calpedestal error code = " << ERROR
59 << " " << errmsg;
60 msg=oss.str();
61 PamOffLineSW::mainLogUtil->logWarning(msg);
62 } //else {
63 //Store the unpacked data
64 calibCalPed->iev = calib_.iev;
65 memcpy(calibCalPed->cstwerr, calib_.cstwerr, sizeof(calibCalPed->cstwerr));
66 memcpy(calibCalPed->cperror, calib_.cperror, sizeof(calibCalPed->cperror));
67 //--------have to invert array because of FORTRAN <-> C different management of the indexes
68 float tempCalped[96][11][4];
69 float tempCalgood[96][11][4];
70 float tempCalthr[6][11][4];
71 float tempCalrms[96][11][4];
72 float tempCalbase[6][11][4];
73 float tempCalvar[6][11][4];
74 //float tempCalpuls[96][11][4];
75
76 memcpy(tempCalped, calib_.calped, sizeof(tempCalped));
77 memcpy(tempCalgood, calib_.calgood, sizeof(tempCalgood));
78 memcpy(tempCalthr, calib_.calthr, sizeof(tempCalthr));
79 memcpy(tempCalrms, calib_.calrms, sizeof(tempCalrms));
80 memcpy(tempCalbase, calib_.calbase, sizeof(tempCalbase));
81 memcpy(tempCalvar, calib_.calvar, sizeof(tempCalvar));
82 //memcpy(tempCalpuls, calib_.calpuls, sizeof(tempCalpuls));
83
84 for (int i = 0; i < 4; i++){
85 for (int j = 0; j <11; j++){
86 for (int z = 0; z < 96; z++){
87 calibCalPed->calped[i][j][z] = tempCalped[z][j][i];
88 calibCalPed->calgood[i][j][z] = tempCalgood[z][j][i];
89 calibCalPed->calrms[i][j][z] = tempCalrms[z][j][i];
90 //calibCalPed->calpuls[i][j][z] = tempCalpuls[z][j][i];
91 }
92 }
93 }
94
95 for (int i = 0; i < 4; i++){
96 for (int j = 0; j <11; j++){
97 for (int z = 0; z < 6; z++){
98 calibCalPed->calthr[i][j][z] = tempCalthr[z][j][i];
99 calibCalPed->calbase[i][j][z] = tempCalbase[z][j][i];
100 calibCalPed->calvar[i][j][z] = tempCalvar[z][j][i];
101 }
102 }
103 }
104 //-----------------------------------------------------------------------------------------
105 //}
106
107 //TODO: check here ....
108 if((calibCalPed->cperror[0])||(calibCalPed->cperror[1])||(calibCalPed->cperror[2])||(calibCalPed->cperror[3]))
109 {
110 oss.str("");
111 oss << "CalibCalPed Problem: cperror[0] = " <<calibCalPed->cperror[0]<<" cperror[1] = " <<calibCalPed->cperror[1]<<" cperror[2] = " <<calibCalPed->cperror[2]<<" cperror[3] = " <<calibCalPed->cperror[3];
112 msg=oss.str();
113 PamOffLineSW::mainLogUtil->logError(msg);
114 throw CalibException("Wrong Global CRC for CalibCalPed Packet ");
115 }
116
117 }
118
119 /**
120 * Get a string with the version info of the algorithm.
121 */
122 std::string CalibCalPedReader::GetVersionInfo(void) const {
123 return
124 "$Header: /repository/PamOffLineSW/techmodel/CalibCalPedReader.cpp,v 1.7 2008-03-21 16:18:46 messineo Exp $\n";
125 }

  ViewVC Help
Powered by ViewVC 1.1.23