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

Annotation of /chewbacca/PamOffLineSW/techmodel/CalibCalPulse1Reader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

1 mocchiut 1.1
2     // Implementation of the CalibCalPulse1Reader class.
3    
4    
5     extern "C" {
6     #include "CRC.h"
7     //Struct per il passaggio di dati da e verso la chiamata fortran
8     extern struct {
9     int iev;
10     int pstwerr[4];
11     float pperror[4];
12     float calpuls[4][11][96];
13     } calpul_;
14    
15     //external declaration of the Fortran function
16     void calpulse_(char*, long int*, int*);
17     }
18    
19     #include "ReaderAlgorithms.h"
20    
21     using namespace pamela::techmodel;
22    
23    
24     /**
25     * Constructor.
26     */
27     CalibCalPulse1Reader::CalibCalPulse1Reader(void):
28     TechmodelAlgorithm(PacketType::CalibCalPulse1, "TechmodelCalibCalPulse1Reader") {
29     calibCalPulse1 = new CalibCalPulse1Event();
30     }
31    
32     /**
33     * Get a string with the version info of the algorithm.
34     */
35     std::string CalibCalPulse1Reader::GetVersionInfo(void) const {
36     return
37     "$Header: /repository/PamOffLineSW/techmodel/CalibCalPulse1Reader.cpp,v 1.6 2008-03-04 18:09:30 messineo Exp $\n";
38     }
39    
40     /**
41     * Initialize the algorithm with a special run. This will initialize the
42     * event reader routines for all packet types.
43     */
44     void CalibCalPulse1Reader::Init(PamelaRun *run) {
45     run->WriteSubPacket(this, &calibCalPulse1, calibCalPulse1->Class());
46     }
47    
48     /**
49     * Unpack the CalibCalPulse1 event
50     */
51     void CalibCalPulse1Reader::PKT_RunEvent(char* packetData, long int dataLength) throw (Exception){
52    
53     string msg;
54     std::stringstream oss;
55     int ERROR;
56     calpulse_(packetData, &dataLength, &ERROR);
57    
58     calibCalPulse1->unpackError = ERROR;
59     oss.str("");
60     if (ERROR != 0) {
61     char *errmsg;
62     switch (ERROR){
63     case 1: errmsg = "CALORIMETER NOT FOUND";
64     }
65     oss << "CalibCalPulse1: Fortran77 function calpulse error code = " << ERROR
66     << " " << errmsg;
67     msg=oss.str();
68     PamOffLineSW::mainLogUtil->logWarning(msg);
69     } //else {
70     //Store the unpacked data
71     calibCalPulse1->iev = calpul_.iev;
72     memcpy(calibCalPulse1->pstwerr, calpul_.pstwerr, sizeof(calibCalPulse1->pstwerr));
73     memcpy(calibCalPulse1->pperror, calpul_.pperror, sizeof(calibCalPulse1->pperror));
74     //--------have to invert array because of FORTRAN <-> C different management of the indexes
75     float tempCalpuls[96][11][4];
76     memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));
77     for (int i = 0; i < 4; i++){
78     for (int j = 0; j <11; j++){
79     for (int z = 0; z < 96; z++){
80     calibCalPulse1->calpuls[i][j][z] = tempCalpuls[z][j][i];
81     }
82     }
83     }
84     //-----------------------------------------------------------------------------------------
85     //}
86     }

  ViewVC Help
Powered by ViewVC 1.1.23