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

Contents of /yoda/techmodel/CalibTrgReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Tue Jul 6 12:30:58 2004 UTC (20 years, 5 months ago) by kusanagi
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +4 -4 lines
Error occurred while calculating annotation data.
FILE REMOVED
*** empty log message ***

1 /** @file
2 * $Source: /home/cvsmanager/yoda/techmodel/CalibTrgReader.cpp,v $
3 * $Id: CalibTrgReader.cpp,v 1.1 2004/07/06 12:20:23 kusanagi Exp $
4 * $Author: kusanagi $
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 extern "C" {
16 //Passo il path verso la il file temporaneo
17 extern void trkcalibpkt_(int*, char*);
18
19 //Struct per il passaggio di dati da e verso la chiamata fortran
20 extern struct {
21 int DAQmode[6];
22 int DSPnumber[6];
23 int calibnumber[6];
24 int ncalib_event[6];
25 int ped_l1[6];
26 int ped_l2[6];
27 int ped_l3[6];
28 int sig_l1[6];
29 int sig_l2[6];
30 int sig_l3[6];
31 int nbad_l1[6];
32 int nbad_l2[6];
33 int nbad_l3[6];
34 int cal_flag[6];
35 int checksum[6];
36 int DSPbad_par[6][3072];
37 float DSPped_par[6][3072];
38 float DSPsig_par[6][3072];
39 } trkcalib_;
40
41 #include <dirent.h>
42 }
43
44 #include <fstream>
45 #include "stdio.h"
46 #include "ReaderAlgorithms.h"
47
48 #include "event/CalibTrgEvent.h"
49
50 using namespace pamela;
51 using namespace pamela::techmodel;
52
53 static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibTrgReader");
54
55 /**
56 * Constructor.
57 */
58 CalibTrgReader::CalibTrgReader(void):
59 TechmodelAlgorithm(PacketType::CalibTrg, "TechmodelCalibTrgReader") {
60 cat << log4cpp::Priority::DEBUG
61 << "Constructor "
62 << "\n " << log4cpp::CategoryStream::ENDLINE;
63 calibTrg = new CalibTrgEvent();
64 }
65
66 /**
67 * Get a string with the version info of the algorithm.
68 */
69 std::string CalibTrgReader::GetVersionInfo(void) const {
70 return
71 "$Header: /home/cvsmanager/yoda/techmodel/CalibTrgReader.cpp,v 1.1 2004/07/06 12:20:23 kusanagi Exp $\n";
72 }
73
74 /**
75 * Initialize the algorithm with a special run. This will initialize the
76 * event reader routines for all packet types.
77 */
78 void CalibTrgReader::Init(PamelaRun *run) {
79 SetInputStream(run);
80 run->WriteSubPacket(this, &calibTrg, calibTrg->Class());
81 }
82
83 /**
84 * Unpack the CalibTrg event from an input file.
85 */
86 void CalibTrgReader::RunEvent(int EventNumber, long int length) {
87 int ERROR;
88
89 //the 2 bytes subtracted belong to the final event CRC bytes
90 long int dataLength = length;// - (long int)2;
91
92 char *subData = new char[dataLength];
93 InputFile->read(subData, sizeof(unsigned char)*dataLength);
94
95 //Skip the last two crc bytes already checked in UnpackPscu
96 //This part have to be refactored!!!! too bad......
97 InputFile->seekg((long int)2, std::ios::cur);
98
99 //Scrivo un file temporaneo per passarlo alla routine
100 //Speriamo di cambiare la routine per passargli un buffer.....
101 DIR *dirp;
102 std::string pathDir((char*)getenv("YODA_DATA"));
103 pathDir = pathDir + "/";
104 pathDir = pathDir + PamelaRun::GetRunName(EventNumber) + "/todatemp.dat";
105 FILE *pfile;
106 pfile = fopen((char*)pathDir.c_str(), "wb");
107 fwrite(subData, 1, dataLength, pfile);
108 fclose(pfile);
109
110 //Call to the FORTRAN routin that unpack tracker events
111 trkcalibpkt_(&ERROR, (char*)pathDir.c_str());
112
113 remove((char*)pathDir.c_str());
114
115 //Store the unpacked data
116 memcpy(calibTrg->DAQmode, trkcalib_.DAQmode, sizeof(calibTrg->DAQmode));
117 memcpy(calibTrg->DSPnumber, trkcalib_.DSPnumber, sizeof(calibTrg->DSPnumber));
118 memcpy(calibTrg->calibnumber, trkcalib_.calibnumber, sizeof(calibTrg->calibnumber));
119 memcpy(calibTrg->DSPnumber, trkcalib_.ncalib_event, sizeof(calibTrg->ncalib_event));
120 memcpy(calibTrg->ped_l1, trkcalib_.ped_l1, sizeof(calibTrg->ped_l1));
121 memcpy(calibTrg->ped_l2, trkcalib_.ped_l2, sizeof(calibTrg->ped_l2));
122 memcpy(calibTrg->ped_l3, trkcalib_.ped_l3, sizeof(calibTrg->ped_l3));
123 memcpy(calibTrg->sig_l1, trkcalib_.sig_l1, sizeof(calibTrg->sig_l1));
124 memcpy(calibTrg->sig_l2, trkcalib_.sig_l2, sizeof(calibTrg->sig_l2));
125 memcpy(calibTrg->sig_l3, trkcalib_.sig_l3, sizeof(calibTrg->sig_l3));
126 memcpy(calibTrg->nbad_l1, trkcalib_.nbad_l1, sizeof(calibTrg->nbad_l1));
127 memcpy(calibTrg->nbad_l2, trkcalib_.nbad_l2, sizeof(calibTrg->nbad_l2));
128 memcpy(calibTrg->nbad_l3, trkcalib_.nbad_l3, sizeof(calibTrg->nbad_l3));
129 memcpy(calibTrg->cal_flag, trkcalib_.cal_flag, sizeof(calibTrg->cal_flag));
130 memcpy(calibTrg->checksum, trkcalib_.checksum, sizeof(calibTrg->checksum));
131 memcpy(calibTrg->DSPbad_par,trkcalib_.DSPbad_par, sizeof(calibTrg->DSPbad_par));
132 memcpy(calibTrg->DSPped_par,trkcalib_.DSPped_par, sizeof(calibTrg->DSPped_par));
133 memcpy(calibTrg->DSPsig_par,trkcalib_.DSPsig_par, sizeof(calibTrg->DSPsig_par));
134
135 cat << log4cpp::Priority::ERROR
136 << "Fortran77 function trkcalibpkt error code = " << ERROR
137 << "\n " << log4cpp::CategoryStream::ENDLINE;
138 free(subData);
139
140 }
141

  ViewVC Help
Powered by ViewVC 1.1.23