| 1 |
/** @file |
/** @file |
| 2 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
| 3 |
* $Date: 2004/10/17 12:28:38 $ |
* $Date: 2004/12/03 22:08:00 $ |
| 4 |
* $Revision: 2.3 $ |
* $Revision: 2.4 $ |
| 5 |
* |
* |
| 6 |
* Implementation of the functions of a sample Algorithm class. |
* Implementation of the functions of a sample Algorithm class. |
| 7 |
* This file can be used as a templace to develop your own algorithm. |
* This file can be used as a templace to develop your own algorithm. |
| 36 |
logger->debug(_T("Constructor")); |
logger->debug(_T("Constructor")); |
| 37 |
Header = new EventHeader(); |
Header = new EventHeader(); |
| 38 |
|
|
| 39 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::PhysEndRun, new PhysEndRunReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::PhysEndRun, new PhysEndRunReader)); |
| 40 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse1, new CalibCalPulse1Reader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse1, new CalibCalPulse1Reader)); |
| 41 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse2, new CalibCalPulse2Reader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse2, new CalibCalPulse2Reader)); |
| 42 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Physics, new PhysicsReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Physics, new PhysicsReader)); |
| 43 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrkBoth, new CalibTrkBothReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrkBoth, new CalibTrkBothReader)); |
| 44 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk1, new CalibTrk1Reader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk1, new CalibTrk1Reader)); |
| 45 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk2, new CalibTrk2Reader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk2, new CalibTrk2Reader)); |
| 46 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrd, new CalibTrdReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrd, new CalibTrdReader)); |
| 47 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTof, new CalibTofReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTof, new CalibTofReader)); |
| 48 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibS4, new CalibS4Reader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibS4, new CalibS4Reader)); |
| 49 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPed, new CalibCalPedReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPed, new CalibCalPedReader)); |
| 50 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibAc, new CalibAcReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibAc, new CalibAcReader)); |
| 51 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunHeader, new RunHeaderReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunHeader, new RunHeaderReader)); |
| 52 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunTrailer, new RunTrailerReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunTrailer, new RunTrailerReader)); |
| 53 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibHeader, new CalibHeaderReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibHeader, new CalibHeaderReader)); |
| 54 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrailer, new CalibTrailerReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrailer, new CalibTrailerReader)); |
| 55 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::InitHeader, new InitHeaderReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::InitHeader, new InitHeaderReader)); |
| 56 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::InitTrailer, new InitTrailerReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::InitTrailer, new InitTrailerReader)); |
| 57 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::EventTrk, new EventTrkReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::EventTrk, new EventTrkReader)); |
| 58 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TestTrk, new TestTrkReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TestTrk, new TestTrkReader)); |
| 59 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TestTof, new TestTofReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TestTof, new TestTofReader)); |
| 60 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Log, new LogReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Log, new LogReader)); |
| 61 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::VarDump, new VarDumpReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::VarDump, new VarDumpReader)); |
| 62 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ArrDump, new ArrDumpReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ArrDump, new ArrDumpReader)); |
| 63 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TabDump, new TabDumpReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TabDump, new TabDumpReader)); |
| 64 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Tmtc, new TmtcReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Tmtc, new TmtcReader)); |
| 65 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Mcmd, new McmdReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Mcmd, new McmdReader)); |
| 66 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ForcedFECmd, new ForcedFECmdReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ForcedFECmd, new ForcedFECmdReader)); |
| 67 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcInit, new AcInitReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcInit, new AcInitReader)); |
| 68 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalInit, new CalInitReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalInit, new CalInitReader)); |
| 69 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkInit, new TrkInitReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkInit, new TrkInitReader)); |
| 70 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofInit, new TofInitReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofInit, new TofInitReader)); |
| 71 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgInit, new TrgInitReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgInit, new TrgInitReader)); |
| 72 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgInit, new NdInitReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::NdInit, new NdInitReader)); |
| 73 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalAlarm, new CalAlarmReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::S4Init, new S4InitReader)); |
| 74 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcAlarm, new AcAlarmReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalAlarm, new CalAlarmReader)); |
| 75 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkAlarm, new TrkAlarmReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcAlarm, new AcAlarmReader)); |
| 76 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgAlarm, new TrgAlarmReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkAlarm, new TrkAlarmReader)); |
| 77 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofAlarm, new TofAlarmReader())); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgAlarm, new TrgAlarmReader)); |
| 78 |
|
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofAlarm, new TofAlarmReader)); |
| 79 |
|
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::S4Alarm, new S4AlarmReader)); |
| 80 |
} |
} |
| 81 |
|
|
| 82 |
/** |
/** |
| 84 |
*/ |
*/ |
| 85 |
std::string EventReader::GetVersionInfo(void) const { |
std::string EventReader::GetVersionInfo(void) const { |
| 86 |
return |
return |
| 87 |
"$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 2.3 2004/10/17 12:28:38 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 2.4 2004/12/03 22:08:00 kusanagi Exp $\n"; |
| 88 |
} |
} |
| 89 |
|
|
| 90 |
/** |
/** |
| 125 |
//to insert a GetPacketStart() |
//to insert a GetPacketStart() |
| 126 |
stringstream oss; |
stringstream oss; |
| 127 |
int step = 0; |
int step = 0; |
| 128 |
|
const PacketType* type; |
| 129 |
while (!InputFile->eof() && ((step++ < maxPackets) || (maxPackets == 0))){ |
while (!InputFile->eof() && ((step++ < maxPackets) || (maxPackets == 0))){ |
| 130 |
try { |
try { |
| 131 |
if (FindStart()) { |
if (FindStart()) { |
| 132 |
UnpackPscuHeader(); |
UnpackPscuHeader(); |
| 133 |
const PacketType* type = Header->GetPscuHeader()->GetPacketType(); |
type = Header->GetPscuHeader()->GetPacketType(); |
| 134 |
AlgorithmMap::iterator i = TechmodelAlgorithmMap.find(type); |
AlgorithmMap::iterator i = TechmodelAlgorithmMap.find(type); |
| 135 |
if (i != TechmodelAlgorithmMap.end()) { |
if (i != TechmodelAlgorithmMap.end()) { |
| 136 |
TechmodelAlgorithm *EventAlgorithm = i->second; |
TechmodelAlgorithm *EventAlgorithm(i->second); |
| 137 |
EventAlgorithm->RunEvent(EventNumber, Header->GetPscuHeader()->GetPacketLenght()); |
EventAlgorithm->RunEvent(EventNumber, Header->GetPscuHeader()->GetPacketLenght()); |
| 138 |
Run->FillTrees(type); |
Run->FillTrees(type); |
| 139 |
Header->GetCounter()->Increment(type); |
Header->GetCounter()->Increment(type); |
| 144 |
} |
} |
| 145 |
// In case of exception have to save the packet in a specific root file?? |
// In case of exception have to save the packet in a specific root file?? |
| 146 |
} catch (NotExistingAlgorithmException exc) { |
} catch (NotExistingAlgorithmException exc) { |
| 147 |
char *temp; |
oss.str(""); |
| 148 |
sprintf(temp, "%s %s \n", exc.print(), Header->GetPscuHeader()->Print()); |
oss << exc.print() << " " << Header->GetPscuHeader()->Print(); |
| 149 |
logger->warn(temp); |
logger->error(oss.str().c_str()); |
| 150 |
} catch (WrongCRCHeaderException exc) { |
} catch (WrongCRCHeaderException exc) { |
| 151 |
char *temp; |
oss.str(""); |
| 152 |
sprintf(temp, "%s %s \n", exc.print(), Header->GetPscuHeader()->Print()); |
oss << exc.print() << " " << Header->GetPscuHeader()->Print(); |
| 153 |
logger->warn(temp); |
logger->error(oss.str().c_str()); |
| 154 |
} catch (WrongCRCException exc) { |
} catch (WrongCRCException exc) { |
| 155 |
//char *temp; |
oss.str(""); |
| 156 |
//sprintf(temp, "%s %s \n", exc.print(), Header->GetPscuHeader()->Print()); |
oss << exc.print() << " " << Header->GetPscuHeader()->Print(); |
| 157 |
//logger->warn(temp); |
logger->error(oss.str().c_str()); |
|
logger->warn(Header->GetPscuHeader()->Print()); |
|
| 158 |
} catch (UnidentifiedPacketException exc) { |
} catch (UnidentifiedPacketException exc) { |
| 159 |
char *temp; |
oss.str(""); |
| 160 |
sprintf(temp, "%s %s \n", exc.print(), Header->GetPscuHeader()->Print()); |
oss << exc.print() << " " << Header->GetPscuHeader()->Print(); |
| 161 |
logger->warn(temp); |
logger->error(oss.str().c_str()); |
| 162 |
} catch (NotExistingCounterException exc) { |
} catch (NotExistingCounterException exc) { |
| 163 |
char *temp; |
oss.str(""); |
| 164 |
sprintf(temp, "%s %s \n", exc.print(), Header->GetPscuHeader()->Print()); |
oss << exc.print() << " " << Header->GetPscuHeader()->Print(); |
| 165 |
logger->warn(temp); |
logger->error(oss.str().c_str()); |
| 166 |
} catch (LengthException exc) { |
} catch (LengthException exc) { |
| 167 |
char *temp; |
oss.str(""); |
| 168 |
sprintf(temp, "%s %s \n", exc.print(), Header->GetPscuHeader()->Print()); |
oss << exc.print() << " " << Header->GetPscuHeader()->Print(); |
| 169 |
logger->warn(temp); |
logger->error(oss.str().c_str()); |
| 170 |
} catch (...) { |
} catch (...) { |
| 171 |
logger->error("Couldn't read the event. Skipping to the next header. \n"); |
logger->error("Couldn't read the event. Skipping to the next header. \n"); |
| 172 |
} |
} |
| 241 |
oss.str(""); |
oss.str(""); |
| 242 |
oss << "The begin of the next packet is far more than 64 byte from the end of the previous." |
oss << "The begin of the next packet is far more than 64 byte from the end of the previous." |
| 243 |
<< Header->GetPscuHeader()->Print(); |
<< Header->GetPscuHeader()->Print(); |
| 244 |
logger->warn(oss.str().c_str()); |
logger->error(oss.str().c_str()); |
| 245 |
//throw LengthException("The begin of the next packet is far more than 64 byte from the end of the previous."); |
//throw LengthException("The begin of the next packet is far more than 64 byte from the end of the previous."); |
| 246 |
} |
} |
| 247 |
InputFile->seekg(initPos, std::ios::beg); |
InputFile->seekg(initPos, std::ios::beg); |