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

Contents of /yoda/event/EventCounter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3.0 - (show annotations) (download)
Fri Mar 4 15:54:11 2005 UTC (20 years, 1 month ago) by kusanagi
Branch: MAIN
Changes since 2.8: +1 -1 lines
Error proof version.
Implemented all detectors packets plus all the main telemetries packets.
Missing all the Init and Alarm packets.
Disabled CRC control on VarDump, ArrDump, TabDump for CPU debugging needs
(the data formats seems correct even if CRC get wrong)

1 /** @file
2 * $Source: /home/cvsmanager/yoda/event/EventCounter.cpp,v $
3 * $Id: EventCounter.cpp,v 2.8 2005/03/03 10:23:30 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 CalibTrkBoth(0),
31 CalibTrk1(0),
32 CalibTrk2(0),
33 CalibTrd(0),
34 CalibTof(0),
35 CalibS4(0),
36 CalibCalPed(0),
37 Calib1_Ac1(0),
38 Calib1_Ac2(0),
39 Calib2_Ac1(0),
40 Calib2_Ac2(0),
41 RunHeader(0),
42 RunTrailer(0),
43 CalibHeader(0),
44 CalibTrailer(0),
45 InitHeader(0),
46 InitTrailer(0),
47 EventTrk(0),
48 TestTrk(0),
49 TestTof(0),
50 Log(0),
51 VarDump(0),
52 ArrDump(0),
53 TabDump(0),
54 Tmtc(0),
55 Mcmd(0),
56 ForcedFECmd(0),
57 Ac1Init(0),
58 CalInit(0),
59 TrkInit(0),
60 TofInit(0),
61 TrgInit(0),
62 NdInit(0),
63 S4Init(0),
64 Ac2Init(0),
65 CalAlarm(0),
66 AcAlarm(0),
67 TrkAlarm(0),
68 TrgAlarm(0),
69 TofAlarm(0),
70 S4Alarm(0),
71 TsbT(0),
72 TsbB(0),
73 RunNumber(run) {
74 CMap.insert(CounterMap::value_type(PacketType::Pscu, &Pscu));
75 CMap.insert(CounterMap::value_type(PacketType::PhysEndRun, &PhysEndRun));
76 CMap.insert(CounterMap::value_type(PacketType::CalibCalPulse1, &CalibCalPulse1));
77 CMap.insert(CounterMap::value_type(PacketType::CalibCalPulse2, &CalibCalPulse2));
78 CMap.insert(CounterMap::value_type(PacketType::Physics, &Physics));
79 CMap.insert(CounterMap::value_type(PacketType::CalibTrkBoth, &CalibTrkBoth));
80 CMap.insert(CounterMap::value_type(PacketType::CalibTrk1, &CalibTrk1));
81 CMap.insert(CounterMap::value_type(PacketType::CalibTrk2, &CalibTrk2));
82 CMap.insert(CounterMap::value_type(PacketType::CalibTrd, &CalibTrd));
83 CMap.insert(CounterMap::value_type(PacketType::CalibTof, &CalibTof));
84 CMap.insert(CounterMap::value_type(PacketType::CalibS4, &CalibS4));
85 CMap.insert(CounterMap::value_type(PacketType::CalibCalPed, &CalibCalPed));
86 CMap.insert(CounterMap::value_type(PacketType::Calib1_Ac1, &Calib1_Ac1));
87 CMap.insert(CounterMap::value_type(PacketType::Calib1_Ac2, &Calib1_Ac2));
88 CMap.insert(CounterMap::value_type(PacketType::Calib2_Ac1, &Calib2_Ac1));
89 CMap.insert(CounterMap::value_type(PacketType::Calib2_Ac2, &Calib2_Ac2));
90 CMap.insert(CounterMap::value_type(PacketType::RunHeader, &RunHeader));
91 CMap.insert(CounterMap::value_type(PacketType::RunTrailer, &RunTrailer));
92 CMap.insert(CounterMap::value_type(PacketType::CalibHeader, &CalibHeader));
93 CMap.insert(CounterMap::value_type(PacketType::CalibTrailer, &CalibTrailer));
94 CMap.insert(CounterMap::value_type(PacketType::InitHeader, &InitHeader));
95 CMap.insert(CounterMap::value_type(PacketType::InitTrailer, &InitTrailer));
96 CMap.insert(CounterMap::value_type(PacketType::EventTrk, &EventTrk));
97 CMap.insert(CounterMap::value_type(PacketType::TestTrk, &TestTrk));
98 CMap.insert(CounterMap::value_type(PacketType::TestTof, &TestTof));
99 CMap.insert(CounterMap::value_type(PacketType::Log, &Log));
100 CMap.insert(CounterMap::value_type(PacketType::VarDump, &VarDump));
101 CMap.insert(CounterMap::value_type(PacketType::ArrDump, &ArrDump));
102 CMap.insert(CounterMap::value_type(PacketType::TabDump, &TabDump));
103 CMap.insert(CounterMap::value_type(PacketType::Tmtc, &Tmtc));
104 CMap.insert(CounterMap::value_type(PacketType::Mcmd, &Mcmd));
105 CMap.insert(CounterMap::value_type(PacketType::ForcedFECmd, &ForcedFECmd));
106 CMap.insert(CounterMap::value_type(PacketType::Ac1Init, &Ac1Init));
107 CMap.insert(CounterMap::value_type(PacketType::CalInit, &CalInit));
108 CMap.insert(CounterMap::value_type(PacketType::TrkInit, &TrkInit));
109 CMap.insert(CounterMap::value_type(PacketType::TofInit, &TofInit));
110 CMap.insert(CounterMap::value_type(PacketType::NdInit, &NdInit));
111 CMap.insert(CounterMap::value_type(PacketType::S4Init, &S4Init));
112 CMap.insert(CounterMap::value_type(PacketType::Ac2Init, &Ac2Init));
113 CMap.insert(CounterMap::value_type(PacketType::CalAlarm, &CalAlarm));
114 CMap.insert(CounterMap::value_type(PacketType::AcAlarm, &AcAlarm));
115 CMap.insert(CounterMap::value_type(PacketType::TrkAlarm, &TrkAlarm));
116 CMap.insert(CounterMap::value_type(PacketType::TrgAlarm, &TrgAlarm));
117 CMap.insert(CounterMap::value_type(PacketType::TofAlarm, &TofAlarm));
118 CMap.insert(CounterMap::value_type(PacketType::S4Alarm, &S4Alarm));
119 CMap.insert(CounterMap::value_type(PacketType::TsbT, &TsbT));
120 CMap.insert(CounterMap::value_type(PacketType::TsbB, &TsbB));
121 }
122
123 /**
124 * Increment the event counter for a certain packet.
125 * @param type Event type to be incremented.
126 */
127 void EventCounter::Increment(PacketType const * type) throw (NotExistingCounterException){
128 CounterMap::iterator p = CMap.find(type);
129 if (p != CMap.end()) {
130 int *counter = p->second;
131 (*counter)++;
132 oss.str("");
133 oss << " Counter." << type->GetName() << " = " << (*counter);
134 logger->info(oss.str().c_str());
135 } else {
136 oss.str("");
137 oss << "\n No counter of type " << type->GetName().c_str();
138 throw NotExistingCounterException(oss.str().c_str());
139 }
140 }
141
142 /**
143 * Get the counter corresponding to a certain packet type.
144 * @param type Event type to be incremented.
145 * @return The counter of that packet type. For the current event type,
146 * this is the actual event number. For all other types, this is the event
147 * number of the last read event of that type.
148 * @retval -1 if there was no event of this type.
149 */
150 int EventCounter::Get(PacketType const * type) const throw (NotExistingCounterException){
151 const CounterMap::const_iterator p = CMap.find(type);
152 if (p != CMap.end()) {
153 const int *counter = p->second;
154 return *counter;
155 } else {
156 throw NotExistingCounterException(type->GetName().c_str());
157 return -1;
158 }
159 }
160
161 /**
162 * Get the counter of the next event corresponding to a certain packet type.
163 * @param type Event type to be incremented.
164 * @return The next counter of that packet type.
165 * @retval -1 if there was no event of this type.
166 */
167 int EventCounter::Next(PacketType const * type) const throw (NotExistingCounterException){
168 const CounterMap::const_iterator p = CMap.find(type);
169 if (p != CMap.end()) {
170 const int *counter = p->second;
171 return *counter + 1;
172 } else {
173 throw NotExistingCounterException(type->GetName().c_str());
174 return -1;
175 }
176 }
177
178 /**
179 * Get the all the counters
180 * @retval 0 if there was no event of this type.
181 */
182 void EventCounter::PrintCounters() const {
183 for(CounterMap::const_iterator p = CMap.begin(); p != CMap.end(); p++) {
184 oss.str("");
185 oss << " Counter." << (p->first)->GetName() << " \t \t " << (*p->second);
186 logger->info(oss.str().c_str());
187 }
188 }

  ViewVC Help
Powered by ViewVC 1.1.23