/[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 5.1 - (show annotations) (download)
Sat Feb 4 12:37:46 2006 UTC (18 years, 10 months ago) by kusanagi
Branch: MAIN
Changes since 5.0: +4 -4 lines
Several new features in this release:
a) all the packets are conform to the Mass Memory Format specifications (http://people.roma2.infn.it/~cpu/Mass_Memory_Format.html)
b) unpacking either using the old files structure OR the new one file unpacking.
c) parametrized root files compression factor
d) deleting of the following packet: TofTest, TrkTest, TrkEvent.
e) the Tracker routines now work without the use of temp files.

The point a) allow Yoda to unpack in the root file all the packets generated by the CPU. According to the MassMemoryFormat; that is three possible data are available:

1) almost explicit structure of the packet (like for Log, Tracker, Mcmd, etc....);
2) dummy data collection structure (InitHeader, InitTrailer, CalibHeader, CalibTrailer);
3) just the data of the packet (almost all Alarm and Init procedures). The class regarding this packets have only one parameters, a TArrayC class, which contain the data-block included in the packet (tat is the data below the packet Header).

The point b) has been implemented as a consequence of an agreement about a more compact structure of the unpacked data. Up to now the structure of each unpacked data consisted of a folder, named after the packet type, and three files: xxx.Header.root, xxx.NamePacket.root, xxx.Registry.root.
Starting from this release YODA, by default will unpack the data in a unique root file. The structure of this file will consist of:
- several TTree(s) named after the packet type;
- into each TTree are foreseen three TBranche(s):
    - 'Header'  (the old xxx.Header.root file)
    - 'NameOfThePacket' (the old xxx.Event.root file or the xxx.Event.DETECTOR.root)
    - 'Registry' (the old xxx.Registry.root file)

Anyway is still possible, but deprecated, to unpack using the old structure, passing to the "yoda" command the optional parameter "-multifile"

The point c) has been implemented because is well know that writing time in a TTree is as much fast as much lower is the compression factor for the root file; anyway for a PAMELA dat file, a compression equal to 0 will generate a root file which will be more than two times the original size. To modify the compression parameter just add the optional parameter "-c [0-9]" to the yoda command line.

1 /** @file
2 * $Source: /home/cvsmanager/yoda/techmodel/physics/TofReader.cpp,v $
3 * $Id: TofReader.cpp,v 5.0 2005/08/29 09:46:13 Maurizio Nagni Exp $
4 * $Author: Maurizio Nagni $
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 5.0 2005/08/29 09:46:13 Maurizio Nagni 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 break;
97 default: errmsg = "TOF ERRROR 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
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