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

Contents of /yoda/techmodel/physics/NeutronDetectorReader.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/04, YODA6_3/05, YODA6_3/00, YODA6_3/01, YODA6_3/02, YODA6_3/03, yodaPreTermistores2_0/00
Branch point for: PreThermistores2
Changes since 5.1: +1 -1 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
2 #include <string>
3 #include <log4cxx/logger.h>
4 #include "NeutronDetectorReader.h"
5
6 using namespace pamela;
7 using namespace pamela::neutron;
8
9 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.neutron.NeutronDetectorReader"));
10
11 /**
12 * Constructor.
13 */
14 NeutronDetectorReader::NeutronDetectorReader(void):
15 TechmodelAlgorithm(PacketType::Physics, "TechmodelNeutronDetectorReader") {
16 logger->debug(_T("Constructor"));
17 neutronEvent = new NeutronEvent();
18 }
19
20 /**
21 * Get a string with the version info of the algorithm.
22 */
23 std::string NeutronDetectorReader::GetVersionInfo(void) const {
24 return
25 "$Header: /home/cvsmanager/yoda/techmodel/physics/NeutronDetectorReader.cpp,v 5.1 2006/02/04 12:37:46 kusanagi Exp $";
26 }
27
28 /**
29 * Initialize the algorithm with a special run. This will initialize the
30 * event reader routines for all packet types.
31 * For definition the definition for Neutron detector data is located in the
32 * end of the physics packet.
33 * More explicitely the neutronData is composed by 4 bytes;
34 * a pattern 00 0F TR BK
35 * where:
36 * 00 0f is a fixed pattern
37 * TR is the NeutronCounter for a trigger event
38 * BK is the NeutronCounter beetween two trigger events
39 */
40 void NeutronDetectorReader::Init(PamelaRun *run) {
41 logger->debug(_T("Initialize"));
42 SetInputStream(run);
43 run->WriteSubPacket(this, &neutronEvent, neutronEvent->Class());
44 }
45
46 /**
47 * Unpack the anticounter event from an input file.
48 */
49 void NeutronDetectorReader::RunEvent(int EventNumber) {
50
51 }
52
53 /**
54 * Unpack the NeutronDetector data event from the physical packet.
55 */
56 void NeutronDetectorReader::RunEvent(int EventNumber, const char subData[], long int length) {
57 NeutronRecord *rec;
58 const int lenNeutronData = 12;
59 //char *data = new char[lenght];
60 //memcpy(data, subData, lenght);
61 neutronEvent->Records->Clear();
62 TClonesArray &recs = *(neutronEvent->Records);
63 int offset;
64 if (haveData(&*subData, length)){
65 for (int i = 0; i < 3; i++){
66 offset = lenNeutronData - 4*i;
67 rec = new(recs[i]) NeutronRecord(); //aggiungo un nuovo NeutronRecord all'evento
68 rec->trigPhysics = (UINT8)subData[length-offset];
69 rec->upperBack = (((UINT8)subData[length-offset+1])>>4);
70 rec->bottomBack = (((UINT8)subData[length-offset+1])&0x0F);
71 }
72 neutronEvent->unpackError = 0;
73 } else {
74 neutronEvent->unpackError = 1;
75 }
76 }
77
78
79 bool NeutronDetectorReader::haveData(const char data[], long int length){
80 bool ret = false;
81 if (((UINT8)data[length - 1] == 0x0F)&&((UINT8)data[length - 5] == 0x0F)&&((UINT8)data[length - 9] == 0x0F) &&
82 ((UINT8)data[length - 2] == 0x00)&&((UINT8)data[length - 6] == 0x00)&&((UINT8)data[length - 10] == 0x00)) ret = true;
83 return ret;
84 }

  ViewVC Help
Powered by ViewVC 1.1.23