/[PAMELA software]/yoda/techmodel/physics/TofReader.cpp
ViewVC logotype

Contents of /yoda/techmodel/physics/TofReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.3 - (show annotations) (download)
Tue Sep 12 08:56:30 2006 UTC (18 years, 2 months ago) by mocchiut
Branch: MAIN
CVS Tags: YODA6_3/13, YODA6_3/12, YODA6_3/11, YODA6_3/10, YODA6_3/08, YODA6_3/09
Changes since 6.2: +4 -4 lines
Added unpackError flag to trigger and tof, small change in the calo unpackError flag

1 /** @file
2 * $Source: /afs/ba.infn.it/user/pamela/src/CVS/yoda/techmodel/physics/TofReader.cpp,v $
3 * $Id: TofReader.cpp,v 6.2 2006/05/30 19:10:03 kusanagi Exp $
4 * $Author: kusanagi $
5 *
6 * Implementation of the CalorimeterReader class.
7 */
8
9
10 #include <iostream>
11 #include <string>
12 #include <log4cxx/logger.h>
13 #include "TofReader.h"
14
15 extern "C" {
16
17
18 extern struct {
19 int tdcid[12];
20 int evcount[12];
21 int tdcmask[12];
22 int adc[4][12];
23 int tdc[4][12];
24 int temp1[12];
25 int temp2[12];
26
27 } tofvar_;
28
29 void tofunpack_(unsigned char[], long int*, int*);
30
31 //Struct per il passaggio di dati da e verso la chiamata fortran
32 }
33
34 using namespace pamela;
35 using namespace pamela::tof;
36
37 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.tof.TofReader"));
38
39 /**
40 * Constructor.
41 */
42 TofReader::TofReader(void):
43 TechmodelAlgorithm(PacketType::Physics, "TechmodelTofReader") {
44 logger->debug(_T("Construnctor"));
45 tof = new TofEvent();
46 }
47
48 /**
49 * Get a string with the version info of the algorithm.
50 */
51 std::string TofReader::GetVersionInfo(void) const {
52 return
53 "$Header: /afs/ba.infn.it/user/pamela/src/CVS/yoda/techmodel/physics/TofReader.cpp,v 6.2 2006/05/30 19:10:03 kusanagi Exp $";
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 TofReader::Init(PamelaRun *run) {
61 logger->debug(_T("Initialize"));
62 SetInputStream(run);
63 run->WriteSubPacket(this, &tof, tof->Class());
64 }
65
66 /**
67 * Unpack the tof event from an input file.
68 */
69 void TofReader::RunEvent(int EventNumber) {
70
71 }
72
73 /**
74 * Unpack the Tof data event from the physical packet.
75 */
76 void TofReader::RunEvent(int EventNumber, const char subData[], long int length) {
77 std::stringstream oss;
78 char *data = new char[length];
79 memcpy(data, subData, length);
80 int ERROR = 0;
81
82 /*unsigned short convdata[length];
83 for (int i = 0; i<length; i++){
84 convdata[i] = (unsigned short)((unsigned char)subData[i]&0xFF);
85 }*/
86
87
88 //Call to the routine that unpack tof events
89 tofunpack_((unsigned char*)data, &length, &ERROR);
90
91
92 if (ERROR != 0) {
93 char *errmsg;
94 switch (ERROR){
95 case 1: errmsg = "CRC TOF ERROR";
96 break;
97 default: errmsg = "TOF ERROR CODE UNIDENTIFIED";
98 }
99 oss.str("");
100 oss << "Fortran77 function tofunpack: " << errmsg;
101 logger->debug(oss.str().c_str());
102 }
103 // In case of "ERROR != 0" the calunpack will take care to set all
104 // parameters to zero
105 //} else {
106 // only for a variable tof->tof1int = evento_.IEV2;
107 // memcpy(tof->tof1int, tofvar_.tof1int, sizeof(tofvar_.tof1int));
108 // printf("tof->tof1int[1] %i \n",tof->tof1int[0]);
109 tof->unpackError = (unsigned short)ERROR;
110
111 // for (int i = 0; i < 6; i++){
112 // tof->tof1int[i] = tofvar_.tof1int[i];
113 //};
114 // printf("tof->tof1int[2] %i \n",tof->tof1int[1]);
115
116 memcpy(tof->tdcid, tofvar_.tdcid, sizeof(tof->tdcid));
117 memcpy(tof->evcount, tofvar_.evcount, sizeof(tof->evcount));
118 memcpy(tof->tdcmask, tofvar_.tdcmask, sizeof(tof->tdcmask));
119 memcpy(tof->temp1, tofvar_.temp1, sizeof(tof->temp1));
120 memcpy(tof->temp2, tofvar_.temp2, sizeof(tof->temp2));
121
122
123 //--------have to invert array because of FORTRAN <-> C different management of the indexes
124
125 // int temptofmat[6][12];
126
127 // memcpy(temptofmat, toftest_.tofmat, sizeof(temptofmat));
128
129 // for (int i = 0; i < 6; i++){
130 // for (int j = 0; j < 12; j++){
131 // tof->tofmat[j][i] = temptofmat[i][j];
132 // }
133 // }
134
135 int tmpadc[12][4];
136 int tmptdc[12][4];
137
138 memcpy(tmpadc, tofvar_.adc, sizeof(tmpadc));
139 memcpy(tmptdc, tofvar_.tdc, sizeof(tmptdc));
140
141 for (int i = 0; i < 12; i++){
142 for (int j = 0; j < 4; j++){
143 tof->adc[j][i] = tmpadc[i][j];
144 tof->tdc[j][i] = tmptdc[i][j];
145 }
146 }
147
148 delete [] data;
149 }

  ViewVC Help
Powered by ViewVC 1.1.23