00001
00002
00003
00004
00005
00006
00008 #include <iostream>
00009 using namespace std;
00010
00011 #include "StandardNtuple/NtpStRecord.h"
00012 #include "StandardNtuple/Module/NtpStModule.h"
00013 #include "MessageService/MsgService.h"
00014 #include "JobControl/JobCModuleRegistry.h"
00015 #include "JobControl/JobCommand.h"
00016 #include "MinosObjectMap/MomNavigator.h"
00017 #include "Record/RecCandHeader.h"
00018 #include "Record/SimSnarlRecord.h"
00019 #include "Record/SimSnarlHeader.h"
00020 #include "CandData/CandRecord.h"
00021 #include "CandData/CandHeader.h"
00022 #include "RawData/RawRecord.h"
00023 #include "RawData/RawDaqSnarlHeader.h"
00024 #include <cassert>
00025
00026 ClassImp(NtpStModule)
00027
00028
00029
00030
00031 CVSID("$Id: NtpStModule.cxx,v 1.6 2007/11/10 16:42:44 schubert Exp $");
00032 JOBMODULE(NtpStModule, "NtpStModule",
00033 "A module for filling Standard ntuple records.");
00034
00035
00036
00037
00038
00039
00040
00041
00042 const Registry& NtpStModule::DefaultConfig() const {
00043
00044
00045
00046
00047
00048
00049
00050
00051 MSG("NtpSt",Msg::kDebug) << "NtpStModule::DefaultConfig" << endl;
00052
00053 static Registry r;
00054 std::string name = this->JobCModule::GetName();
00055 name += ".config.default";
00056 r.SetName(name.c_str());
00057
00058 r.UnLockValues();
00059
00060 r.Set("RecordName","Primary");
00061 r.Set("RecordTitle","Created by NtpStModule");
00062 r.Set("CandRecordName","PrimaryCandidateRecord");
00063
00064 r.LockValues();
00065
00066 return r;
00067 }
00068
00069
00070
00071 void NtpStModule::Config(const Registry& r) {
00072
00073
00074
00075
00076
00077
00078
00079
00080 MSG("NtpSt",Msg::kDebug) << "NtpStModule::Config" << endl;
00081
00082
00083
00084 const Char_t* tmps;
00085 if ( r.Get("RecordName", tmps) ) fRecordName = tmps;
00086 if ( r.Get("RecordTitle", tmps) ) fRecordTitle = tmps;
00087 if ( r.Get("CandRecordName",tmps) ) fCandRecordName = tmps;
00088
00089 }
00090
00091
00092
00093 JobCResult NtpStModule::Get(MomNavigator *mom) {
00094
00095
00096
00097
00098
00099
00100
00101
00102 JobCResult result(JobCResult::kPassed);
00103 MSG("NtpSt",Msg::kDebug) << "NtpStModule::Get" << endl;
00104
00105
00106 assert(mom);
00107
00108 const CandRecord* cndrec = dynamic_cast<const CandRecord*>
00109 (mom->GetFragment("CandRecord",fCandRecordName.c_str()));
00110 const SimSnarlRecord* simrec = dynamic_cast<const SimSnarlRecord*>
00111 (mom->GetFragment("SimSnarlRecord"));
00112 if (!cndrec && !simrec ) {
00113 MSG("NtpSt",Msg::kWarning)
00114 << "No PrimaryCandidateRecord or SimSnarlRecord in Mom" << endl;
00115 result.SetWarning().SetFailed();
00116 return result;
00117 }
00118
00119 NtpStRecord* ntprec = 0;
00120 if ( !cndrec ) {
00121
00122 const SimSnarlHeader* simhdr = simrec->GetSimSnarlHeader();
00123
00124 RecCandHeader ntphdr(simhdr->GetVldContext(),simhdr->GetRun(),
00125 simhdr->GetSubRun(),simhdr->GetRunType(),simhdr->GetErrorCode(),
00126 simhdr->GetSnarl(),simhdr->GetTrigSrc(),simhdr->GetTimeFrame(),
00127 simhdr->GetRemoteSpillType(),-1);
00128 ntprec = new NtpStRecord(ntphdr);
00129 ntprec -> SetName(fRecordName.c_str());
00130 ntprec -> SetTitle(fRecordTitle.c_str());
00131
00132 RecJobHistory& jobhist
00133 = const_cast<RecJobHistory&>(ntprec->GetJobHistory());
00134 jobhist.Append(simrec->GetJobHistory());
00135 jobhist.CreateJobRecord(RecJobHistory::kNtpSt);
00136
00137 mom -> AdoptFragment(ntprec);
00138 return result;
00139 }
00140
00141
00142
00143
00144 const CandHeader* cndhdr = cndrec -> GetCandHeader();
00145 const RawRecord* rawrec =
00146 dynamic_cast<const RawRecord*>(mom->GetFragment("RawRecord","","DaqSnarl"));
00147 if (!rawrec) {
00148 MSG("NtpSt",Msg::kWarning) << "No DaqSnarl RawRecord in Mom"
00149 <<"\nShield data will not be filled and header will be incomplete."
00150 << endl;
00151 result.SetWarning();
00152 }
00153 if (rawrec) {
00154 const RawDaqSnarlHeader* rawhdr = dynamic_cast<const RawDaqSnarlHeader*>
00155 (rawrec -> GetRawHeader());
00156 RecCandHeader ntphdr(rawhdr->GetVldContext(),rawhdr->GetRun(),
00157 rawhdr->GetSubRun(),rawhdr->GetRunType(),rawhdr->GetErrorCode(),
00158 rawhdr->GetSnarl(),rawhdr->GetTrigSrc(),rawhdr->GetTimeFrameNum(),
00159 rawhdr->GetRemoteSpillType(),cndhdr->GetEvent());
00160 ntprec = new NtpStRecord(ntphdr);
00161 }
00162 else {
00163
00164
00165 RecCandHeader ntphdr(cndhdr->GetVldContext(),cndhdr->GetRun(),
00166 -1,-1,0,cndhdr->GetSnarl(),0,-1,-1,cndhdr->GetEvent());
00167 ntprec = new NtpStRecord(ntphdr);
00168 }
00169
00170 ntprec -> SetName(fRecordName.c_str());
00171 ntprec -> SetTitle(fRecordTitle.c_str());
00172
00173 RecJobHistory& jobhist
00174 = const_cast<RecJobHistory&>(ntprec->GetJobHistory());
00175 if ( simrec ) jobhist.Append(simrec->GetJobHistory());
00176 jobhist.Append(cndrec->GetJobHistory());
00177 jobhist.CreateJobRecord(RecJobHistory::kNtpSt);
00178
00179 mom -> AdoptFragment(ntprec);
00180
00181 return result;
00182
00183 }
00184
00185
00186
00187
00188