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

Annotation of /yoda/techmodel/CalibCalReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue Jul 6 12:20:23 2004 UTC (20 years, 5 months ago) by kusanagi
Branch: MAIN
Initial revision

1 kusanagi 1.1 /** @file
2     * $Source: /home/cvspamela/yoda/techmodel/CalibCalReader.cpp,v $
3     * $Id: CalibCalReader.cpp,v 1.1 2004/05/11 10:12:35 nagni Exp $
4     * $Author: nagni $
5     *
6     * Implementation of the LogReader class.
7     * ToBeDone:
8     * Control the CRC for the entire data Packet not just for single records
9     */
10    
11     //#define UINT unsigned int
12     #define BYTE unsigned char
13     #include <string>
14     #include <log4cpp/Category.hh>
15     #include <fstream>
16     #include "stdio.h"
17     extern "C" {
18     #include "CRC.h"
19     /* external declaration of the Fortran function */
20     void calpedestal_(short[], int*, float[96][11][4], float[][11][4],
21     float[][11][4], float[][11][4], float[][11][4]);
22     }
23    
24     #include "ReaderAlgorithms.h"
25     #include "event/CalibCalEvent.h"
26    
27     using namespace pamela;
28     using namespace pamela::techmodel;
29    
30     static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibCalReader");
31    
32     /**
33     * Constructor.
34     */
35     CalibCalReader::CalibCalReader(void):
36     TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalReader") {
37     cat << log4cpp::Priority::DEBUG
38     << "Constructor "
39     << "\n " << log4cpp::CategoryStream::ENDLINE;
40     CalibCal = new CalibCalEvent();
41     }
42    
43     /**
44     * Get a string with the version info of the algorithm.
45     */
46     std::string CalibCalReader::GetVersionInfo(void) const {
47     return
48     "$Header: /home/cvspamela/yoda/techmodel/CalibCalReader.cpp,v 1.1 2004/05/11 10:12:35 nagni Exp $\n";
49     }
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 CalibCalReader::Init(PamelaRun *run) {
56     SetInputStream(run);
57     run->WriteSubPacket(this, &CalibCal, CalibCal->Class());
58     }
59    
60     /**
61     * Unpack the CalibCal event from an input file.
62     */
63     void CalibCalReader::RunEvent(int EventNumber, long int length) {
64    
65     char *subData;
66     long int dataLength;
67     int ERROR;
68    
69     //the 2 bytes subtracted belong to the final event CRC bytes
70     dataLength = length - (long int)2;
71    
72     subData = new char[dataLength];
73     InputFile->read(subData, sizeof(unsigned char)*dataLength);
74    
75     //Skip the last two crc bytes already checked in UnpackPscu
76     //This part have to be refactored!!!! too bad......
77     InputFile->seekg((long int)2, std::ios::cur);
78    
79     //Chiamata alla funzione fortran per la lettura dei piedistalli
80     calpedestal_((short*)subData, &ERROR, CalibCal->cal_ped, CalibCal->cal_good, CalibCal->cal_thr, CalibCal->cal_base, CalibCal->cal_var);
81     cat << log4cpp::Priority::ERROR
82     << "Fortran77 function calpedestal error code = " << ERROR
83     << "\n " << log4cpp::CategoryStream::ENDLINE;
84     free(subData);
85     }
86    
87    

  ViewVC Help
Powered by ViewVC 1.1.23