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

Contents of /yoda/techmodel/physics/TriggerReader.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_3/06, YODA6_1/00, YODA6_0/00, YODA6_3/04, YODA6_3/05, YODA6_3/07, YODA6_3/00, YODA6_3/01, YODA6_3/02, YODA6_3/03, 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/TriggerReader.cpp,v $
3 * $Id: TriggerReader.cpp,v 5.1 2006/02/04 12:37:46 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 "TriggerReader.h"
14
15 extern "C" {
16
17
18 extern struct {
19 int evcount;
20 int pmtpl[3];
21 int trigrate[6];
22 int dltime[2];
23 int s4calcount[2];
24 int pmtcount1[24];
25 int pmtcount2[24];
26 int patternbusy[3];
27 int patterntrig[6];
28 int trigconf;
29 } trig_;
30
31 void triggerunpack_(unsigned char[], long int*, int*);
32
33 //Struct per il passaggio di dati da e verso la chiamata fortran
34 }
35
36 using namespace pamela;
37 using namespace pamela::trigger;
38
39 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.trigger.TriggerReader"));
40
41 /**
42 * Constructor.
43 */
44 TriggerReader::TriggerReader(void):
45 TechmodelAlgorithm(PacketType::Physics, "TechmodelTriggerReader") {
46 logger->debug(_T("Construnctor"));
47 trigger = new TriggerEvent();
48 }
49
50 /**
51 * Get a string with the version info of the algorithm.
52 */
53 std::string TriggerReader::GetVersionInfo(void) const {
54 return
55 "$Header: /home/cvsmanager/yoda/techmodel/physics/TriggerReader.cpp,v 5.1 2006/02/04 12:37:46 kusanagi Exp $";
56 }
57
58 /**
59 * Initialize the algorithm with a special run. This will initialize the
60 * event reader routines for all packet types.
61 */
62 void TriggerReader::Init(PamelaRun *run) {
63 logger->debug(_T("Initialize"));
64 SetInputStream(run);
65 run->WriteSubPacket(this, &trigger, trigger->Class());
66 }
67
68 /**
69 * Unpack the trigger event from an input file.
70 */
71 void TriggerReader::RunEvent(int EventNumber) {
72
73 }
74
75 /**
76 * Unpack the Trigger data event from the physical packet.
77 */
78 void TriggerReader::RunEvent(int EventNumber, const char subData[], long int length) {
79 std::stringstream oss;
80 char *data = new char[length];
81 memcpy(data, subData, length);
82 int ERROR = 0;
83
84 /*unsigned short convdata[length];
85 for (int i = 0; i<length; i++){
86 convdata[i] = (unsigned short)((unsigned char)subData[i]&0xFF);
87 }*/
88
89
90 //Call to the routine that unpack trigger events
91 triggerunpack_((unsigned char*)data, &length, &ERROR);
92
93
94 if (ERROR != 0) {
95 char *errmsg;
96 switch (ERROR){
97 case 1: errmsg = "GENERIC TRIGGER ERROR";
98 break;
99 default: errmsg = "TRIGGER ERRROR CODE UNIDENTIFIED";
100 }
101 oss.str("");
102 oss << "Fortran77 function triggerunpack: " << errmsg;
103 logger->warn(oss.str().c_str());
104 }
105 // In case of "ERROR != 0" the calunpack will take care to set all
106 // parameters to zero
107 //} else {
108
109 trigger->evcount = trig_.evcount;
110 memcpy(trigger->pmtpl, trig_.pmtpl, sizeof(trigger->pmtpl));
111 memcpy(trigger->trigrate, trig_.trigrate, sizeof(trigger->trigrate));
112 memcpy(trigger->dltime, trig_.dltime, sizeof(trigger->dltime));
113 memcpy(trigger->s4calcount, trig_.s4calcount, sizeof(trigger->s4calcount));
114 memcpy(trigger->pmtcount1, trig_.pmtcount1, sizeof(trigger->pmtcount1));
115 memcpy(trigger->pmtcount2, trig_.pmtcount2, sizeof(trigger->pmtcount2));
116 memcpy(trigger->patternbusy, trig_.patternbusy, sizeof(trigger->patternbusy));
117 memcpy(trigger->patterntrig, trig_.patterntrig, sizeof(trigger->patterntrig));
118 trigger->trigconf = trig_.trigconf;
119
120 delete [] data;
121 }

  ViewVC Help
Powered by ViewVC 1.1.23