/[PAMELA software]/yoda/event/EventCounter.cpp
ViewVC logotype

Contents of /yoda/event/EventCounter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.0 - (show annotations) (download)
Tue Feb 7 17:11:07 2006 UTC (18 years, 10 months ago) by kusanagi
Branch: MAIN
CVS Tags: YODA6_0/00
Changes since 5.1: +2 -2 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/event/EventCounter.cpp,v $
3 * $Id: EventCounter.cpp,v 5.1 2006/02/04 12:37:43 kusanagi Exp $
4 * $Author: kusanagi $
5 *
6 * Implementation of the EventCounter class.
7 */
8 #include <log4cxx/logger.h>
9 #include <sstream>
10
11 #include "EventCounter.h"
12 #include "PscuHeader.h"
13
14
15 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.EventCounter"));
16 static std::stringstream oss;
17 using namespace pamela;
18
19 /**
20 * Create a new event counter for a certain run.
21 * @param run Run number.
22 */
23 EventCounter::EventCounter(int run):
24 // New Packets.
25 Pscu(0),
26 PhysEndRun(0),
27 CalibCalPulse1(0),
28 CalibCalPulse2(0),
29 Physics(0),
30 CalibTrk1(0),
31 CalibTrk2(0),
32 CalibTof(0),
33 CalibS4(0),
34 CalibCalPed(0),
35 Calib1_Ac1(0),
36 Calib1_Ac2(0),
37 Calib2_Ac1(0),
38 Calib2_Ac2(0),
39 RunHeader(0),
40 RunTrailer(0),
41 CalibHeader(0),
42 CalibTrailer(0),
43 InitHeader(0),
44 InitTrailer(0),
45 Log(0),
46 VarDump(0),
47 ArrDump(0),
48 TabDump(0),
49 Tmtc(0),
50 Mcmd(0),
51 ForcedFECmd(0),
52 Ac1Init(0),
53 CalInit(0),
54 TrkInit(0),
55 TofInit(0),
56 TrgInit(0),
57 NdInit(0),
58 S4Init(0),
59 Ac2Init(0),
60 CalAlarm(0),
61 AcAlarm(0),
62 TrkAlarm(0),
63 TrgAlarm(0),
64 TofAlarm(0),
65 S4Alarm(0),
66 TsbT(0),
67 TsbB(0),
68 RunNumber(run) {
69 CMap.insert(CounterMap::value_type(PacketType::Pscu, &Pscu));
70 CMap.insert(CounterMap::value_type(PacketType::PhysEndRun, &PhysEndRun));
71 CMap.insert(CounterMap::value_type(PacketType::CalibCalPulse1, &CalibCalPulse1));
72 CMap.insert(CounterMap::value_type(PacketType::CalibCalPulse2, &CalibCalPulse2));
73 CMap.insert(CounterMap::value_type(PacketType::Physics, &Physics));
74 CMap.insert(CounterMap::value_type(PacketType::CalibTrk1, &CalibTrk1));
75 CMap.insert(CounterMap::value_type(PacketType::CalibTrk2, &CalibTrk2));
76 CMap.insert(CounterMap::value_type(PacketType::CalibTof, &CalibTof));
77 CMap.insert(CounterMap::value_type(PacketType::CalibS4, &CalibS4));
78 CMap.insert(CounterMap::value_type(PacketType::CalibCalPed, &CalibCalPed));
79 CMap.insert(CounterMap::value_type(PacketType::Calib1_Ac1, &Calib1_Ac1));
80 CMap.insert(CounterMap::value_type(PacketType::Calib1_Ac2, &Calib1_Ac2));
81 CMap.insert(CounterMap::value_type(PacketType::Calib2_Ac1, &Calib2_Ac1));
82 CMap.insert(CounterMap::value_type(PacketType::Calib2_Ac2, &Calib2_Ac2));
83 CMap.insert(CounterMap::value_type(PacketType::RunHeader, &RunHeader));
84 CMap.insert(CounterMap::value_type(PacketType::RunTrailer, &RunTrailer));
85 CMap.insert(CounterMap::value_type(PacketType::CalibHeader, &CalibHeader));
86 CMap.insert(CounterMap::value_type(PacketType::CalibTrailer, &CalibTrailer));
87 CMap.insert(CounterMap::value_type(PacketType::InitHeader, &InitHeader));
88 CMap.insert(CounterMap::value_type(PacketType::InitTrailer, &InitTrailer));
89 CMap.insert(CounterMap::value_type(PacketType::Log, &Log));
90 CMap.insert(CounterMap::value_type(PacketType::VarDump, &VarDump));
91 CMap.insert(CounterMap::value_type(PacketType::ArrDump, &ArrDump));
92 CMap.insert(CounterMap::value_type(PacketType::TabDump, &TabDump));
93 CMap.insert(CounterMap::value_type(PacketType::Tmtc, &Tmtc));
94 CMap.insert(CounterMap::value_type(PacketType::Mcmd, &Mcmd));
95 CMap.insert(CounterMap::value_type(PacketType::ForcedFECmd, &ForcedFECmd));
96 CMap.insert(CounterMap::value_type(PacketType::Ac1Init, &Ac1Init));
97 CMap.insert(CounterMap::value_type(PacketType::CalInit, &CalInit));
98 CMap.insert(CounterMap::value_type(PacketType::TrkInit, &TrkInit));
99 CMap.insert(CounterMap::value_type(PacketType::TofInit, &TofInit));
100 CMap.insert(CounterMap::value_type(PacketType::NdInit, &NdInit));
101 CMap.insert(CounterMap::value_type(PacketType::S4Init, &S4Init));
102 CMap.insert(CounterMap::value_type(PacketType::Ac2Init, &Ac2Init));
103 CMap.insert(CounterMap::value_type(PacketType::CalAlarm, &CalAlarm));
104 CMap.insert(CounterMap::value_type(PacketType::AcAlarm, &AcAlarm));
105 CMap.insert(CounterMap::value_type(PacketType::TrkAlarm, &TrkAlarm));
106 CMap.insert(CounterMap::value_type(PacketType::TrgAlarm, &TrgAlarm));
107 CMap.insert(CounterMap::value_type(PacketType::TofAlarm, &TofAlarm));
108 CMap.insert(CounterMap::value_type(PacketType::S4Alarm, &S4Alarm));
109 CMap.insert(CounterMap::value_type(PacketType::TsbT, &TsbT));
110 CMap.insert(CounterMap::value_type(PacketType::TsbB, &TsbB));
111 }
112
113 /**
114 * Increment the event counter for a certain packet.
115 * @param type Event type to be incremented.
116 */
117 void EventCounter::Increment(PacketType const * type) throw (NotExistingCounterException){
118 CounterMap::iterator p = CMap.find(type);
119 if (p != CMap.end()) {
120 int *counter = p->second;
121 (*counter)++;
122 oss.str("");
123 oss << " Counter." << type->GetName() << " = " << (*counter);
124 logger->info(oss.str().c_str());
125 } else {
126 oss.str("");
127 oss << "\n No counter of type " << type->GetName().c_str();
128 throw NotExistingCounterException(oss.str().c_str());
129 }
130 }
131
132 /**
133 * Get the counter corresponding to a certain packet type.
134 * @param type Event type to be incremented.
135 * @return The counter of that packet type. For the current event type,
136 * this is the actual event number. For all other types, this is the event
137 * number of the last read event of that type.
138 * @retval -1 if there was no event of this type.
139 */
140 int EventCounter::Get(PacketType const * type) const throw (NotExistingCounterException){
141 const CounterMap::const_iterator p = CMap.find(type);
142 if (p != CMap.end()) {
143 const int *counter = p->second;
144 return *counter;
145 } else {
146 throw NotExistingCounterException(type->GetName().c_str());
147 return -1;
148 }
149 }
150
151 /**
152 * Get the counter of the next event corresponding to a certain packet type.
153 * @param type Event type to be incremented.
154 * @return The next counter of that packet type.
155 * @retval -1 if there was no event of this type.
156 */
157 int EventCounter::Next(PacketType const * type) const throw (NotExistingCounterException){
158 const CounterMap::const_iterator p = CMap.find(type);
159 if (p != CMap.end()) {
160 const int *counter = p->second;
161 return *counter + 1;
162 } else {
163 throw NotExistingCounterException(type->GetName().c_str());
164 return -1;
165 }
166 }
167
168 /**
169 * Get the all the counters
170 * @retval 0 if there was no event of this type.
171 */
172 void EventCounter::PrintCounters() const {
173 for(CounterMap::const_iterator p = CMap.begin(); p != CMap.end(); p++) {
174 oss.str("");
175 oss << " Counter." << (p->first)->GetName() << " \t \t " << (*p->second);
176 logger->info(oss.str().c_str());
177 }
178 }
179

  ViewVC Help
Powered by ViewVC 1.1.23