00001
00002
00003
00004
00005
00006
00008 #include <map>
00009 #include <iostream>
00010 using std::endl;
00011 #include "TNamed.h"
00012 #include "Record/test/DemoRecordModule.h"
00013 #include "MessageService/MsgService.h"
00014 #include "JobControl/JobCModuleRegistry.h"
00015 #include "JobControl/JobCommand.h"
00016 #include "MinosObjectMap/MomNavigator.h"
00017 #include "RawData/RawRecord.h"
00018 #include "RawData/RawHeader.h"
00019 #include "RawData/RawDaqSnarlHeader.h"
00020 #include "Record/RecPhysicsHeader.h"
00021 #include "Record/RecDataRecord.h"
00022
00023 #include <cassert>
00024
00025 ClassImp(DemoRecordModule)
00026
00027
00028
00029
00030 CVSID("$Id: DemoRecordModule.cxx,v 1.4 2005/05/18 03:02:57 schubert Exp $");
00031 JOBMODULE(DemoRecordModule, "DemoRecordModule",
00032 "A module for demonstrating record construction.");
00033
00034
00035
00036
00037
00038 JobCResult DemoRecordModule::Ana(const MomNavigator *mom) {
00039
00040 JobCResult result(JobCResult::kPassed);
00041 MSG("DemoRecord",Msg::kVerbose) << "DemoRecordModule::Ana" << endl;
00042
00043
00044 assert(mom);
00045
00046
00047 RecDataRecord<RecPhysicsHeader> *record
00048 = dynamic_cast<RecDataRecord<RecPhysicsHeader>*>
00049 (mom->GetFragment("RecDataRecord<RecPhysicsHeader>"));
00050 if ( !record ) {
00051 MSG("DemoRecord",Msg::kWarning) << "No RecDataRecord in Mom " <<endl;
00052 result.SetWarning().SetFailed();
00053 return result;
00054 }
00055 MSG("DemoRecord",Msg::kInfo)
00056 << "DemoRecordModule::Ana retrieved selected record:\n" << *record << endl;
00057 return result;
00058
00059 }
00060
00061 JobCResult DemoRecordModule::Reco(MomNavigator *mom) {
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 JobCResult result(JobCResult::kPassed);
00074 MSG("DemoRecord",Msg::kVerbose) << "DemoRecordModule::Reco" << endl;
00075
00076
00077 assert(mom);
00078
00079
00080
00081 RawRecord *rawRec = dynamic_cast<RawRecord*>(mom->GetFragment("RawRecord"));
00082 if ( !rawRec ) {
00083 MSG("RawRecord",Msg::kWarning) << "No RawRecord in Mom " <<endl;
00084 result.SetWarning().SetFailed();
00085 return result;
00086 }
00087
00088 const RawDaqSnarlHeader* rawHdr = dynamic_cast<const RawDaqSnarlHeader*>
00089 (rawRec -> GetHeader());
00090 RecPhysicsHeader* newHdr = new RecPhysicsHeader(rawHdr->GetVldContext(),
00091 rawHdr->GetRun(),rawHdr->GetSubRun(),rawHdr->GetRunType(),
00092 rawHdr->GetErrorCode(),rawHdr->GetSnarl(),rawHdr->GetTrigSrc(),
00093 rawHdr->GetTimeFrameNum(),rawHdr->GetRemoteSpillType());
00094
00095
00096 RecDataRecord<RecPhysicsHeader>* newRec
00097 = new RecDataRecord<RecPhysicsHeader>(*newHdr);
00098
00099
00100
00101
00102
00103
00104
00105 if ( rawHdr->GetSnarl() % 3 == 1 || rawHdr->GetSnarl() % 3 == 2 ) {
00106 TNamed* named = new TNamed("MyObject1","");
00107 newRec->AdoptComponent(named);
00108 }
00109 if ( rawHdr->GetSnarl() % 3 == 2 ) {
00110 TNamed* named = new TNamed("MyObject2","");
00111 newRec->AdoptComponent(named);
00112 }
00113
00114
00115 MSG("DemoRecord",Msg::kInfo)
00116 << "DemoRecordModule::Reco created record:\n" << *newRec << endl;
00117 mom->AdoptFragment(newRec);
00118
00119 return result;
00120
00121 }
00122
00123 void DemoRecordModule::BeginJob() {
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 MSG("DemoRecord", Msg::kVerbose) << "DemoRecordModule::BeginJob" << endl;
00135
00136
00137
00138 }
00139
00140 void DemoRecordModule::Config(const Registry& r) {
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 MSG("DemoRecord",Msg::kDebug) << "Config DemoRecordModule with r=" << r << endl;
00152
00153 }
00154
00155 const Registry& DemoRecordModule::DefaultConfig() const {
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 static Registry r;
00167 r.SetName("DemoRecord.config");
00168
00169 r.UnLockValues();
00170
00171 MSG("DemoRecord",Msg::kDebug) << "Loading default config.\n" << endl;
00172
00173
00174
00175 r.LockValues();
00176 return r;
00177
00178 }
00179
00180 DemoRecordModule::DemoRecordModule() {
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 MSG("DemoRecord", Msg::kVerbose) << "DemoRecordModule::Constructor" << endl;
00194
00195 }
00196
00197 DemoRecordModule::~DemoRecordModule() {
00198
00199
00200
00201
00202
00203
00204 MSG("DemoRecord", Msg::kVerbose) << "DemoRecordModule::Destructor" << endl;
00205
00206 }
00207
00208
00209
00210
00211