/[PAMELA software]/yoda/techmodel/CalibCalPulse2Reader.cpp
ViewVC logotype

Annotation of /yoda/techmodel/CalibCalPulse2Reader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2.2 - (hide annotations) (download)
Thu Jan 13 14:48:04 2005 UTC (19 years, 11 months ago) by kusanagi
Branch: MAIN
Changes since 2.1: +5 -1 lines
Added unpackError initialization.

1 kusanagi 1.1
2     // Implementation of the CalibCalPulse2Reader class.
3    
4    
5     #define UINT unsigned int
6     #define BYTE unsigned char
7     #include <string>
8 kusanagi 1.4 #include <log4cxx/logger.h>
9 kusanagi 1.1
10     extern "C" {
11     #include "CRC.h"
12     //Struct per il passaggio di dati da e verso la chiamata fortran
13 kusanagi 2.1 extern struct {
14     int iev;
15     int pstwerr[4];
16     float pperror[4];
17     float calpuls[4][11][96];
18     } calpul_;
19 kusanagi 1.1
20     //external declaration of the Fortran function
21 kusanagi 2.1 void calpulse_(char*, long int*, int*);
22 kusanagi 1.1 }
23     #include <fstream>
24     #include "stdio.h"
25     #include "ReaderAlgorithms.h"
26    
27     #include "event/CalibCalPulse2Event.h"
28    
29     using namespace pamela;
30     using namespace pamela::techmodel;
31    
32 kusanagi 1.4 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibCalPulse2Reader"));
33 kusanagi 1.1
34     /**
35     * Constructor.
36     */
37     CalibCalPulse2Reader::CalibCalPulse2Reader(void):
38     TechmodelAlgorithm(PacketType::CalibCalPulse2, "TechmodelCalibCalPulse2Reader") {
39 kusanagi 1.4 logger->debug(_T("Constructor"));
40 kusanagi 1.1 calibCalPulse2 = new CalibCalPulse2Event();
41     }
42    
43     /**
44     * Get a string with the version info of the algorithm.
45     */
46     std::string CalibCalPulse2Reader::GetVersionInfo(void) const {
47     return
48 kusanagi 2.2 "$Header: /home/cvsmanager/yoda/techmodel/CalibCalPulse2Reader.cpp,v 2.1 2004/12/03 22:08:00 kusanagi Exp $\n";
49 kusanagi 1.1 }
50    
51     /**
52     * Initialize the algorithm with a special run. This will initialize the
53     * event reader routines for all packet types.
54     */
55     void CalibCalPulse2Reader::Init(PamelaRun *run) {
56 kusanagi 1.4 logger->debug(_T("Initialize"));
57 kusanagi 1.1 SetInputStream(run);
58     run->WriteSubPacket(this, &calibCalPulse2, calibCalPulse2->Class());
59     }
60    
61     /**
62     * Unpack the CalibCalPulse2 event from an input file.
63     */
64 kusanagi 2.1 void CalibCalPulse2Reader::RunEvent(int EventNumber, long int dataLength) throw (Exception){
65 kusanagi 1.4 std::stringstream oss;
66 kusanagi 2.1 char packetData[dataLength];
67 kusanagi 1.1 int ERROR;
68     InputFile->read(packetData, sizeof(packetData));
69 kusanagi 2.2
70 kusanagi 2.1 calpulse_(packetData, &dataLength, &ERROR);
71 kusanagi 2.2
72     calibCalPulse2->unpackError = ERROR;
73    
74 kusanagi 2.1 if (ERROR != 0) {
75     char *errmsg;
76     switch (ERROR){
77     case 1: errmsg = "CALORIMETER NOT FOUND";
78     }
79     oss.str("");
80     oss << "Fortran77 function calpulse error code = " << ERROR
81     << "\n" <<errmsg;
82     logger->warn(oss.str().c_str());
83     } else {
84     //Store the unpacked data
85     calibCalPulse2->iev = calpul_.iev;
86     memcpy(calibCalPulse2->pstwerr, calpul_.pstwerr, sizeof(calibCalPulse2->pstwerr));
87     memcpy(calibCalPulse2->pperror, calpul_.pperror, sizeof(calibCalPulse2->pperror));
88     //--------have to invert array because of FORTRAN <-> C different management of the indexes
89     float tempCalpuls[96][11][4];
90     memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));
91     for (int i = 0; i < 4; i++){
92     for (int j = 0; j <11; j++){
93     for (int z = 0; z < 96; z++){
94     calibCalPulse2->calpuls[i][j][z] = tempCalpuls[z][j][i];
95 kusanagi 1.2 }
96 kusanagi 1.1 }
97     }
98 kusanagi 2.1 //-----------------------------------------------------------------------------------------
99 kusanagi 1.1 }
100     }
101    

  ViewVC Help
Powered by ViewVC 1.1.23