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

Annotation of /yoda/techmodel/CalibCalPulse1Reader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.1 - (hide annotations) (download)
Tue May 30 19:10:01 2006 UTC (18 years, 6 months ago) by kusanagi
Branch: MAIN
Changes since 6.0: +1 -10 lines
Major update.
All the packet officially produced by PAMELA are implemented and unpacked.
The RegistryEvent Packet has been removed and put into another library.
New version, releasd by D.Campana, of tofunpack.

1 kusanagi 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 kusanagi 2.1 int iev;
10     int pstwerr[4];
11     float pperror[4];
12     float calpuls[4][11][96];
13     } calpul_;
14 kusanagi 1.1
15     //external declaration of the Fortran function
16 kusanagi 2.1 void calpulse_(char*, long int*, int*);
17 kusanagi 1.1 }
18    
19     #include "ReaderAlgorithms.h"
20    
21     using namespace pamela::techmodel;
22    
23 kusanagi 1.4 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibCalPulse1Reader"));
24 kusanagi 1.1
25     /**
26     * Constructor.
27     */
28     CalibCalPulse1Reader::CalibCalPulse1Reader(void):
29     TechmodelAlgorithm(PacketType::CalibCalPulse1, "TechmodelCalibCalPulse1Reader") {
30 kusanagi 1.4 logger->debug(_T("Constructor"));
31 kusanagi 1.1 calibCalPulse1 = new CalibCalPulse1Event();
32     }
33    
34     /**
35     * Get a string with the version info of the algorithm.
36     */
37     std::string CalibCalPulse1Reader::GetVersionInfo(void) const {
38     return
39 kusanagi 6.1 "$Header: /home/cvsmanager/yoda/techmodel/CalibCalPulse1Reader.cpp,v 6.0 2006/02/07 17:11:09 kusanagi Exp $\n";
40 kusanagi 1.1 }
41    
42     /**
43     * Initialize the algorithm with a special run. This will initialize the
44     * event reader routines for all packet types.
45     */
46     void CalibCalPulse1Reader::Init(PamelaRun *run) {
47 kusanagi 1.4 logger->debug(_T("Initialize"));
48 kusanagi 1.1 SetInputStream(run);
49     run->WriteSubPacket(this, &calibCalPulse1, calibCalPulse1->Class());
50     }
51    
52     /**
53     * Unpack the CalibCalPulse1 event from an input file.
54     */
55 kusanagi 2.1 void CalibCalPulse1Reader::RunEvent(int EventNumber, long int dataLength) throw (Exception){
56 kusanagi 1.4 std::stringstream oss;
57 kusanagi 2.1 char packetData[dataLength];
58 kusanagi 1.1 int ERROR;
59     InputFile->read(packetData, sizeof(packetData));
60    
61 kusanagi 2.1 calpulse_(packetData, &dataLength, &ERROR);
62 kusanagi 1.1
63 kusanagi 2.2 calibCalPulse1->unpackError = ERROR;
64 kusanagi 2.1 oss.str("");
65     if (ERROR != 0) {
66     char *errmsg;
67     switch (ERROR){
68     case 1: errmsg = "CALORIMETER NOT FOUND";
69     }
70     oss << "Fortran77 function calpulse error code = " << ERROR
71 kusanagi 2.3 << " " << errmsg;
72 kusanagi 2.1 logger->warn(oss.str().c_str());
73 kusanagi 4.1 } //else {
74 kusanagi 2.1 //Store the unpacked data
75     calibCalPulse1->iev = calpul_.iev;
76     memcpy(calibCalPulse1->pstwerr, calpul_.pstwerr, sizeof(calibCalPulse1->pstwerr));
77     memcpy(calibCalPulse1->pperror, calpul_.pperror, sizeof(calibCalPulse1->pperror));
78     //--------have to invert array because of FORTRAN <-> C different management of the indexes
79     float tempCalpuls[96][11][4];
80     memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));
81     for (int i = 0; i < 4; i++){
82     for (int j = 0; j <11; j++){
83     for (int z = 0; z < 96; z++){
84     calibCalPulse1->calpuls[i][j][z] = tempCalpuls[z][j][i];
85 kusanagi 1.2 }
86 kusanagi 1.1 }
87     }
88 kusanagi 2.1 //-----------------------------------------------------------------------------------------
89 kusanagi 4.1 //}
90 kusanagi 1.1 }
91    

  ViewVC Help
Powered by ViewVC 1.1.23