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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.0 - (show annotations) (download)
Tue Feb 7 17:11:11 2006 UTC (18 years, 9 months ago) by kusanagi
Branch: MAIN
CVS Tags: yodaPreTermistors2_1/00, YODA6_2/01, YODA6_2/00, YODA6_1/00, YODA6_0/00, YODA6_3/00, YODA6_3/01, YODA6_3/02, yodaPreTermistores2_0/00
Branch point for: PreThermistores2
Changes since 5.1: +3 -3 lines
Several new features in this revision:
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/TrackerReader.cpp,v $
3 * $Id: TrackerReader.cpp,v 5.1 2006/02/04 12:37:46 kusanagi Exp $
4 * $Author: kusanagi $
5 *
6 * Implementation of the TrackerPhysicsReader class.
7 */
8
9
10 #include <string>
11 #include <log4cxx/logger.h>
12 #include "TrackerReader.h"
13 #include "event/physics/tracker/TrackerEvent.h"
14
15 extern "C" {
16
17 extern void trkeventpkt_(int*, unsigned char[], long int*, int*);
18
19 //Struct per il passaggio di dati da e verso la chiamata fortran
20 extern struct {
21 int DAQmode[12];
22 int DSPnumber[12];
23 int DATAlength[12];
24 int eventn[12];
25 int nclust[12];
26 int cutc[12];
27 int cutcl[12];
28 int addrcluster[3][12];
29 int signcluster[3][12];
30 int fc[12];
31 int compressiontime[12];
32 int fl5[12];
33 int fl4[12];
34 int fl3[12];
35 int fl2[12];
36 int fl1[12];
37 int fl6[12];
38 int checksum[12];
39 int TOTDATAlength;
40 int datatracker[49152];
41 int pnum[12];
42 int cmdnum[12];
43 int bid[12];
44 int alarm[12];
45 int aswr[12];
46 int good0;
47 int crc[12];
48 } level0_;
49 #include <dirent.h>
50 }
51
52 using namespace pamela;
53 using namespace pamela::tracker;
54
55 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.tracker.TrackerReader"));
56
57 /**
58 * Constructor.
59 */
60 TrackerReader::TrackerReader(void):
61 TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") {
62 logger->debug(_T("Constructor"));
63 tracker = new TrackerEvent();
64 }
65
66 /**
67 * Get a string with the version info of the algorithm.
68 */
69 std::string TrackerReader::GetVersionInfo(void) const {
70 return
71 "$Header: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v 5.1 2006/02/04 12:37:46 kusanagi Exp $";
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 TrackerReader::Init(PamelaRun *run) {
79 logger->debug(_T("Initialize"));
80 SetInputStream(run);
81 run->WriteSubPacket(this, &tracker, tracker->Class());
82 }
83
84 /**
85 * Unpack the orbital event from an input file.
86 */
87 void TrackerReader::RunEvent(int EventNumber) {
88
89 }
90
91 /**
92 * Unpack the Tracker data event from the physical packet.
93 */
94 void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) {
95 std::stringstream oss;
96 int ERROR=0;
97 char *data = new char[length];
98 memcpy(data, subData, length);
99 int curpos=1;
100
101 //Call to the FORTRAN routin that unpack tracker events
102 trkeventpkt_( &ERROR,(unsigned char*)data, &length, &curpos);
103
104 if (ERROR != 0) {
105 char *errmsg;
106 switch (ERROR){
107 case 1: errmsg = "GENERIC TRACKER ERROR";
108 break;
109 default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED";
110 }
111 oss.str("");
112 oss << "Fortran77 function trkeventpkt: " << errmsg;
113 logger->warn(oss.str().c_str());
114 }
115 //Store the unpacked data
116 tracker->unpackError = ERROR;
117 tracker->good0 = level0_.good0;
118 memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode));
119 memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber));
120 memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength));
121 memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn));
122 memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust));
123 memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc));
124 memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl));
125 //--------have to invert array because of FORTRAN <-> C different management of the indexes
126 int tempAddr[3][12];
127 int tempSign[3][12];
128 memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr));
129 memcpy(tempSign, (level0_.signcluster), sizeof(tempSign));
130 for (int j = 0; j < 12; j++){
131 for (int i = 0; i < 3; i++){
132 tracker->addrcluster[j][i] = tempAddr[i][j];
133 tracker->signcluster[j][i] = tempSign[i][j];
134 }
135 }
136 //-----------------------------------------------------------------------------------------
137
138 memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc));
139 memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime));
140 memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1));
141 memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2));
142 memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3));
143 memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4));
144 memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5));
145 memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6));
146 memcpy(tracker->checksum, level0_.checksum, sizeof(tracker->checksum));
147 memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum));
148 memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum));
149 memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid));
150 memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm));
151 memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr));
152 memcpy(tracker->crc, level0_.crc, sizeof(tracker->crc));
153
154 tracker->TOTDATAlength = level0_.TOTDATAlength;
155 tracker->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
156 }

  ViewVC Help
Powered by ViewVC 1.1.23