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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2.1 - (hide annotations) (download)
Sat Jan 29 00:31:36 2005 UTC (19 years, 10 months ago) by kusanagi
Branch: MAIN
*** empty log message ***

1 kusanagi 2.1 /** @file
2     * $Source: /home/cvsmanager/yoda/techmodel/physics/CalorimeterReader.cpp,v $
3     * $Id: CalorimeterReader.cpp,v 2.3 2004/10/18 14:28: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: /home/cvsmanager/yoda/techmodel/physics/TofReader.cpp,v 2.3 2004/10/18 14:28: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 = "GENERIC TOF ERROR";
96     }
97     oss.flush();
98     oss << "Fortran77 function tofunpack: " << errmsg;
99     logger->warn(oss.str().c_str());
100     }
101     // In case of "ERROR != 0" the calunpack will take care to set all
102     // parameters to zero
103     //} else {
104     // only for a variable tof->tof1int = evento_.IEV2;
105     // memcpy(tof->tof1int, tofvar_.tof1int, sizeof(tofvar_.tof1int));
106     // printf("tof->tof1int[1] %i \n",tof->tof1int[0]);
107    
108    
109     // for (int i = 0; i < 6; i++){
110     // tof->tof1int[i] = tofvar_.tof1int[i];
111     //};
112     // printf("tof->tof1int[2] %i \n",tof->tof1int[1]);
113    
114     memcpy(tof->tdcid, tofvar_.tdcid, sizeof(tof->tdcid));
115     memcpy(tof->evcount, tofvar_.evcount, sizeof(tof->evcount));
116     memcpy(tof->tdcmask, tofvar_.tdcmask, sizeof(tof->tdcmask));
117     memcpy(tof->temp1, tofvar_.temp1, sizeof(tof->temp1));
118     memcpy(tof->temp2, tofvar_.temp2, sizeof(tof->temp2));
119    
120    
121     //--------have to invert array because of FORTRAN <-> C different management of the indexes
122    
123     // int temptofmat[6][12];
124    
125     // memcpy(temptofmat, toftest_.tofmat, sizeof(temptofmat));
126    
127     // for (int i = 0; i < 6; i++){
128     // for (int j = 0; j < 12; j++){
129     // tof->tofmat[j][i] = temptofmat[i][j];
130     // }
131     // }
132    
133    
134     int tmpadc[12][4];
135     int tmptdc[12][4];
136    
137     memcpy(tmpadc, tofvar_.adc, sizeof(tmpadc));
138     memcpy(tmptdc, tofvar_.tdc, sizeof(tmptdc));
139    
140     for (int i = 0; i < 12; i++){
141     for (int j = 0; j < 4; j++){
142     tof->adc[j][i] = tmpadc[i][j];
143     tof->tdc[j][i] = tmptdc[i][j];
144     }
145     }
146    
147     delete[] data;
148     }

  ViewVC Help
Powered by ViewVC 1.1.23