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

Contents of /chewbacca/PamOffLineSW/techmodel/CalibTrk2Reader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Fri Jul 24 13:53:44 2009 UTC (15 years, 4 months ago) by mocchiut
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, HEAD
Changes since 1.1: +5 -5 lines
Runtime error with ROOT 5.24 fixed, many small changes and warnings fixing

1 /** @file
2 * $Source: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/CalibTrk2Reader.cpp,v $
3 * $Id: CalibTrk2Reader.cpp,v 1.1.1.1 2008/09/23 07:20:25 mocchiut Exp $
4 * $Author: mocchiut $
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 #include "ReaderAlgorithms.h"
12
13 extern "C" {
14 #include "CRC.h"
15 extern void trkcalibpkt_(int*, unsigned char[], long int*, int*); //(*)
16
17 //Struct per il passaggio di dati da e verso la chiamata fortran
18 extern struct {
19 int good0;
20 int DAQmode[6];
21 int DSPnumber[6];
22 int calibnumber[6];
23 int ncalib_event[6];
24 int ped_l1[6];
25 int ped_l2[6];
26 int ped_l3[6];
27 int sig_l1[6];
28 int sig_l2[6];
29 int sig_l3[6];
30 int nbad_l1[6];
31 int nbad_l2[6];
32 int nbad_l3[6];
33 int cal_flag[6];
34 float DSPped_par[3072][6];
35 float DSPsig_par[3072][6];
36 int DSPbad_par[3072][6];
37 int crc_cal[3][6];
38 int crc_hcal[6];
39 } trkcalib_;
40 #include <dirent.h>
41 }
42
43 using namespace pamela::techmodel;
44
45
46 /**
47 * Constructor.
48 */
49 CalibTrk2Reader::CalibTrk2Reader(void):
50 TechmodelAlgorithm(PacketType::CalibTrk2, "TechmodelCalibTrk2Reader") {
51 calibTrk2 = new CalibTrk2Event();
52 }
53
54
55
56 /**
57 * Initialize the algorithm with a special run. This will initialize the
58 * event reader routines for all packet types.
59 */
60 void CalibTrk2Reader::Init(PamelaRun *run) {
61 run->WriteSubPacket(this, &calibTrk2, calibTrk2->Class());
62 }
63
64 /**
65 * Unpack the CalibTrk event
66 */
67 void CalibTrk2Reader::PKT_RunEvent(char* data, long int dataLength) throw (CalibException){
68 std::stringstream oss;
69 string msg;
70 int ERROR;
71 int curpos=1;
72
73 //Call to the FORTRAN routin that unpack tracker events
74 trkcalibpkt_( &ERROR,(unsigned char*)data, &dataLength, &curpos);
75
76 calibTrk2->unpackError = ERROR;
77 if (ERROR != 0) {
78 oss.str("");
79 oss << "CalibTrk2: Fortran77 function trkcalibpkt error code = " << ERROR;
80 msg=oss.str();
81 PamOffLineSW::mainLogUtil->logWarning(msg);
82 }
83
84 //Store the unpacked data
85 calibTrk2->good0 = trkcalib_.good0;
86 memcpy(calibTrk2->DAQmode, trkcalib_.DAQmode, sizeof(calibTrk2->DAQmode));
87 memcpy(calibTrk2->DSPnumber, trkcalib_.DSPnumber, sizeof(calibTrk2->DSPnumber));
88 memcpy(calibTrk2->calibnumber, trkcalib_.calibnumber, sizeof(calibTrk2->calibnumber));
89 memcpy(calibTrk2->ncalib_event, trkcalib_.ncalib_event, sizeof(calibTrk2->ncalib_event));
90 memcpy(calibTrk2->ped_l1, trkcalib_.ped_l1, sizeof(calibTrk2->ped_l1));
91 memcpy(calibTrk2->ped_l2, trkcalib_.ped_l2, sizeof(calibTrk2->ped_l2));
92 memcpy(calibTrk2->ped_l3, trkcalib_.ped_l3, sizeof(calibTrk2->ped_l3));
93 memcpy(calibTrk2->sig_l1, trkcalib_.sig_l1, sizeof(calibTrk2->sig_l1));
94 memcpy(calibTrk2->sig_l2, trkcalib_.sig_l2, sizeof(calibTrk2->sig_l2));
95 memcpy(calibTrk2->sig_l3, trkcalib_.sig_l3, sizeof(calibTrk2->sig_l3));
96 memcpy(calibTrk2->nbad_l1, trkcalib_.nbad_l1, sizeof(calibTrk2->nbad_l1));
97 memcpy(calibTrk2->nbad_l2, trkcalib_.nbad_l2, sizeof(calibTrk2->nbad_l2));
98 memcpy(calibTrk2->nbad_l3, trkcalib_.nbad_l3, sizeof(calibTrk2->nbad_l3));
99 memcpy(calibTrk2->cal_flag, trkcalib_.cal_flag, sizeof(calibTrk2->cal_flag));
100
101 int tempBad_par[3072][6];
102 float tempPed_par[3072][6];
103 float tempSig_par[3072][6];
104 int tempCrc_cal[3][6];
105 memcpy(tempBad_par,trkcalib_.DSPbad_par, sizeof(tempBad_par));
106 memcpy(tempPed_par,trkcalib_.DSPped_par, sizeof(tempPed_par));
107 memcpy(tempSig_par,trkcalib_.DSPsig_par, sizeof(tempSig_par));
108 memcpy(tempCrc_cal,trkcalib_.crc_cal, sizeof(tempCrc_cal));
109
110 for (int i = 0; i < 6; i++){
111 for (int j = 0; j < 3072; j++){
112 calibTrk2->DSPbad_par[i][j] = tempBad_par[j][i];
113 calibTrk2->DSPped_par[i][j] = tempPed_par[j][i];
114 calibTrk2->DSPsig_par[i][j] = tempSig_par[j][i];
115 }
116 for (int k = 0; k < 3; k++){
117 calibTrk2->crc_cal[i][k] = tempCrc_cal[k][i];
118 }
119 }
120
121 PamOffLineSW::mainLogUtil->logError("CANNOT CHECK IF CalibTrk2 IS GOOD OR NOT ...");
122
123 //TODO: put the correct check here ....
124 if(1>2){
125 oss.str("");
126 //oss << "CalibTrk1 Problem: ??[0] = " <<cperror[0]<<" cperror[1] = " <<cperror[1]<<" cperror[2] = " <<cperror[2]<<" cperror[3] = " <<cperror[3];
127 msg=oss.str();
128 PamOffLineSW::mainLogUtil->logError(msg);
129 throw CalibException("Wrong Global CRC for CalibTrk2 Packet ");
130 }
131 //-----------------------------------------------------------------------------------------
132 }
133
134 /**
135 * Get a string with the version info of the algorithm.
136 */
137 std::string CalibTrk2Reader::GetVersionInfo(void) const {
138 return
139 "$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/CalibTrk2Reader.cpp,v 1.1.1.1 2008/09/23 07:20:25 mocchiut Exp $\n";
140 }

  ViewVC Help
Powered by ViewVC 1.1.23