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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5.1 - (hide annotations) (download)
Sat Feb 4 12:37:46 2006 UTC (18 years, 10 months ago) by kusanagi
Branch: MAIN
Changes since 5.0: +3 -3 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 kusanagi 2.1 /** @file
2     * $Source: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v $
3 kusanagi 5.1 * $Id: S4Reader.cpp,v 5.0 2005/08/29 09:46:13 Maurizio Nagni Exp $
4     * $Author: Maurizio Nagni $
5 kusanagi 2.1 *
6     * Implementation of the S4Reader class.
7     */
8    
9     #include <string>
10     #include <log4cxx/logger.h>
11     #include "S4Reader.h"
12    
13     using namespace pamela;
14     using namespace pamela::S4;
15    
16     static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.S4.S4Reader"));
17    
18     /**
19     * Constructor.
20     */
21     S4Reader::S4Reader(void):
22     TechmodelAlgorithm(PacketType::Physics, "TechmodelS4Reader") {
23     logger->debug(_T("Constructor"));
24     s4 = new S4Event();
25     }
26    
27     /**
28     * Get a string with the version info of the algorithm.
29     */
30     std::string S4Reader::GetVersionInfo(void) const {
31     return
32 kusanagi 5.1 "$Header: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v 5.0 2005/08/29 09:46:13 Maurizio Nagni Exp $";
33 kusanagi 2.1 }
34    
35     /**
36     * Initialize the algorithm with a special run. This will initialize the
37     * event reader routines for all packet types.
38     */
39     void S4Reader::Init(PamelaRun *run) {
40     logger->debug(_T("Initialize"));
41     SetInputStream(run);
42     run->WriteSubPacket(this, &s4, s4->Class());
43     }
44    
45     /**
46     * Unpack the S4 event from an input file.
47     */
48     void S4Reader::RunEvent(int EventNumber) {
49    
50     }
51    
52     /**
53     * Unpack the S4 data event from the physical packet.
54 kusanagi 2.2 * Unfortunately the only definition available for S4 is "Rigth before the Neutron detector data"
55     * consequently supposing the Neutron data (12 Bytes) always present S4 start 18 Bytes before the end of the packet
56 kusanagi 2.1 */
57     void S4Reader::RunEvent(int EventNumber, const char subData[], long int length) {
58 kusanagi 2.5 int offset;
59 kusanagi 4.2 int index = haveData(&*subData, length);
60 kusanagi 2.5
61 kusanagi 4.1 if (index > 0){
62 kusanagi 2.5 int offset = length - index;
63     s4->S4_REG_STATUS = (((UINT8)subData[offset])&0xF0);
64     s4->S4_DATA = ((((UINT16)subData[offset]<<8)&0x0FFF) + (((UINT16)subData[offset+1])&0x00FF));
65     s4->S4_CMD_NUM = (((UINT8)subData[offset+2])&0xFF);
66     s4->S4_RESP_LENGHT = ((((UINT16)subData[offset+3]<<8)&0xFF00) + (((UINT16)subData[offset+4])&0x00FF));
67     s4->S4_OVERALL_CHKCODE = (((UINT8)subData[offset+5])&0xFF);
68     s4->unpackError = 0;
69     } else {
70     s4->unpackError = 1;
71     }
72 kusanagi 2.2 }
73 kusanagi 2.1
74 kusanagi 2.5 /*
75     *
76     * @return int
77     * It return the index, starting from the end of data[] parameter, which
78     * is the starting byte of the S4 data.
79     *
80     */
81     /**
82     * Check if S4Data are present.
83     * @param const char data[] - Physics data
84     * @param long int lenght - Lenght of data[]
85 kusanagi 4.1 * @return int represent the index from the end of data[]
86     * from which S4 data starts
87 kusanagi 2.5 */
88     int S4Reader::haveData(const char data[], long int length){
89 kusanagi 4.2 int ret = 0;
90 kusanagi 2.5 /* I start 20 bytes from the end because we have three cases:
91     *
92     * 1) S4 (4bytes) + NeutronDetector (12bytes) //END PACKET
93     * 2) S4 (4bytes) //END PACKET
94     * 3) //END PACKET
95     *
96     * so in anycase I expect to find the data into the last 20 bytes
97     * Anyway, it will be a MUST to implements also the check of the CRC
98     * on the S4 data to have a better confidence on the data; the crc algorithm
99     * sholud be the same of the Tracker
100     *
101     */
102 kusanagi 4.1
103     //Check the existence of NeutronDetector data
104 kusanagi 4.2 if (((UINT8)data[length - 1] == 0x0F)&&((UINT8)data[length - 5] == 0x0F)&&((UINT8)data[length - 9] == 0x0F) &&
105     ((UINT8)data[length - 2] == 0x00)&&((UINT8)data[length - 6] == 0x00)&&((UINT8)data[length - 10] == 0x00)) {
106 kusanagi 4.1 //Chech the existance of S4 data before NeutronDetector
107 kusanagi 4.2 if (((UINT8)data[length - 14] == 0x03) &&
108     ((UINT8)data[length - 15] == 0x00) &&
109     ((UINT8)data[length - 16] == 0xD8)) ret = 18;
110 kusanagi 4.1 //NeutronDetector data does not exists
111     } else {
112     //Chech the existance of S4 data at the end of the Physics packet
113 kusanagi 4.2 if ( ((UINT8)data[length - 2] == 0x03) &&
114     ((UINT8)data[length - 3] == 0x00) &&
115     ((UINT8)data[length - 4] == 0xD8)) ret = 6;
116 kusanagi 4.1 }
117 kusanagi 4.2 return ret;
118 kusanagi 2.5 }

  ViewVC Help
Powered by ViewVC 1.1.23