00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "FiltMBSpillModule.h"
00011 #include "MessageService/MsgService.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "JobControl/JobCModuleRegistry.h"
00014 #include "JobControl/JobCommand.h"
00015 #include "Conventions/Munits.h"
00016
00017 #include "RawData/RawRecord.h"
00018 #include "RawData/RawDaqSnarlHeader.h"
00019
00020 #include "OnlineUtil/mdTriggerCodes.h"
00021
00022
00023 #include "MiniBooNEAna/MBSpillAccessor.h"
00024 #include "MiniBooNEAna/MBSpill.h"
00025
00026
00027 #include "TSystem.h"
00028 #include "TFile.h"
00029 #include "TTree.h"
00030 #include "TMath.h"
00031
00032 JOBMODULE(FiltMBSpillModule, "FiltMBSpillModule",
00033 "MBSpill");
00034 CVSID("$Id: FiltMBSpillModule.cxx,v 1.5 2008/03/14 16:44:51 tjyang Exp $");
00035
00036
00037 FiltMBSpillModule::FiltMBSpillModule() :
00038 fTWin(0.0),
00039 fTrigMask(0)
00040 {
00044
00045
00046 }
00047
00048
00049 FiltMBSpillModule::~FiltMBSpillModule()
00050 {
00054 }
00055
00056
00057
00058 void FiltMBSpillModule::BeginJob()
00059 {
00060
00061
00062 }
00063
00064
00065
00066 void FiltMBSpillModule::EndJob()
00067 {
00071 }
00072
00073
00074
00075 void FiltMBSpillModule::BeginFile()
00076 {
00080 }
00081
00082
00083
00084 void FiltMBSpillModule::EndFile()
00085 {
00089 }
00090
00091
00092
00093 void FiltMBSpillModule::BeginRun()
00094 {
00098 }
00099
00100
00101
00102 void FiltMBSpillModule::EndRun()
00103 {
00107 }
00108
00109
00110
00111 JobCResult FiltMBSpillModule::Ana(const MomNavigator* mom)
00112 {
00118
00119 JobCResult result = JobCResult::kFailed;
00120 TObject* recObj = 0;
00121 int nrawrec=0;
00122 int nrawblk=0;
00123 int nsnarlblk=0;
00124 int trgsrc=0;
00125 VldTimeStamp vldts;
00126 time_t trgsec;
00127 int trgnsec;
00128
00129 int snarl;
00130 int run;
00131
00132 double dt = -9e9;
00133 int mbsec;
00134 int mbnsec;
00135
00136
00137 TIter recItr = mom->FragmentIter();
00138 while ( ( recObj = recItr.Next() ) ) {
00139 RawRecord* rawrec = dynamic_cast<RawRecord*>(recObj);
00140 if (!rawrec) continue;
00141 nrawrec++;
00142
00143
00144 const RawDaqSnarlHeader* snarlHdr =
00145 dynamic_cast<const RawDaqSnarlHeader*>(rawrec->GetHeader());
00146 if ( snarlHdr ) {
00147 trgsrc = snarlHdr->GetTrigSrc();
00148 run = snarlHdr->GetRun();
00149 snarl = snarlHdr->GetSnarl();
00150 }
00151
00152
00153 TObject* blkObj = 0;
00154 TIter blkItr = rawrec->GetRawBlockIter();
00155 while ( ( blkObj = blkItr.Next() ) ) {
00156 const RawDataBlock* rawBlk = dynamic_cast<const RawDataBlock*>(blkObj);
00157 if (!rawBlk) continue;
00158 nrawblk++;
00159
00160
00161 const RawSnarlHeaderBlock* snarlblk =
00162 dynamic_cast<const RawSnarlHeaderBlock*>(rawBlk);
00163 if (!snarlblk) continue;
00164 nsnarlblk++;
00165 vldts = snarlblk->GetTriggerTime();
00166 trgsec = vldts.GetSec();
00167 trgnsec = vldts.GetNanoSec();
00168
00169
00170 VldTimeStamp tmpnd=vldts;
00171
00172
00173 MBSpillAccessor& spillAccess = MBSpillAccessor::Get();
00174
00175 const MBSpill *spillInfo = spillAccess.LoadSpill(vldts);
00176 if (spillInfo) {
00177 dt = double(spillInfo->GetTimeStamp()-vldts);
00178 mbsec = spillInfo->GetSec();
00179 mbnsec = spillInfo->GetNanoSec();
00180 }
00181
00182
00183
00184
00185 if (trgsrc & fTrigMask) {
00186
00187 if (TMath::Abs(dt)<fTWin) {
00188 MSG("Filt",Msg::kDebug) << "-------------------------------------------------" << endl;
00189 MSG("Filt",Msg::kDebug) << "ND snarl within +-" << fTWin << " seconds of MiniBooNE spill. The trigger source is: " << trgsrc << endl;
00190 MSG("Filt",Msg::kDebug) << "Run, Snarl: " << run << ", " << snarl << endl;
00191 MSG("Filt",Msg::kDebug) << "dt(MB-MINOS snarl)= " << TMath::Abs(dt) <<" seconds"<< endl;
00192 MSG("Filt",Msg::kDebug) << "ND vldtimestamp in sec, nsec, double: " << vldts.GetSec() << ", " << vldts.GetNanoSec() << ", " << vldts.AsString() << endl;
00193 MSG("Filt",Msg::kDebug) << "MB vldtimestamp in sec, nsec, double: " << mbsec << ", " << mbnsec << ", " << (spillInfo->GetTimeStamp()).AsString() << endl;
00194 result = JobCResult::kPassed;
00195 }
00196 }
00197
00198 }
00199 }
00200
00201
00202
00203
00204
00205
00206 return result;
00207
00208
00209
00210 }
00211
00212
00213
00214 JobCResult FiltMBSpillModule::Reco(MomNavigator* )
00215 {
00219 return JobCResult::kPassed;
00220 }
00221
00222
00223
00224 const Registry& FiltMBSpillModule::DefaultConfig() const
00225 {
00229 static Registry r;
00230
00231
00232 std::string name = this->GetName();
00233 name += ".config.default";
00234 r.SetName(name.c_str());
00235
00236
00237 r.UnLockValues();
00238 r.Set("TWin", 1.0e-3);
00239
00240 Int_t thisTrigMask = 0;
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 thisTrigMask |= TRIGGER_BIT_PLANE;
00253 thisTrigMask |= TRIGGER_BIT_ACTIVITY;
00254 thisTrigMask |= TRIGGER_BIT_SPILL;
00255
00256
00257 r.Set("TrigMask", thisTrigMask);
00258 r.LockValues();
00259
00260 return r;
00261 }
00262
00263
00264
00265 void FiltMBSpillModule::Config(const Registry& r)
00266 {
00270 fTWin = r.GetDouble("TWin");
00271 fTrigMask = r.GetInt("TrigMask");
00272 }
00273
00274
00275
00276 void FiltMBSpillModule::Report()
00277 {
00281 }
00282
00283
00284
00285 void FiltMBSpillModule::Reset()
00286 {
00290 }
00291
00292
00293
00294 void FiltMBSpillModule::HandleCommand(JobCommand* )
00295 {
00299 }
00300