00001 #include "art/Framework/Core/FileBlock.h"
00002 #include "art/Framework/Core/InputSourceMacros.h"
00003 #include "art/Framework/Core/ProductRegistryHelper.h"
00004 #include "art/Framework/IO/Sources/Source.h"
00005 #include "art/Framework/IO/Sources/SourceHelper.h"
00006 #include "art/Framework/IO/Sources/SourceTraits.h"
00007 #include "art/Framework/Services/Registry/ServiceHandle.h"
00008
00009 #if ART_HEX_VERSION < 0x20900
00010 #include "art/Persistency/Provenance/BranchIDListRegistry.h"
00011 #include "canvas/Persistency/Provenance/BranchIDList.h"
00012 #endif
00013 #include "art/Persistency/Provenance/MasterProductRegistry.h"
00014 #include "art/Persistency/Provenance/ProcessHistoryRegistry.h"
00015 #include "art/Persistency/Provenance/ProductMetaData.h"
00016
00017 #include "canvas/Persistency/Common/EDProduct.h"
00018 #include "canvas/Persistency/Common/Wrapper.h"
00019 #include "canvas/Persistency/Provenance/BranchDescription.h"
00020 #include "canvas/Persistency/Provenance/BranchKey.h"
00021 #include "canvas/Persistency/Provenance/History.h"
00022 #include "canvas/Persistency/Provenance/ParentageRegistry.h"
00023 #include "canvas/Persistency/Provenance/ProcessConfiguration.h"
00024 #include "canvas/Persistency/Provenance/ProcessHistory.h"
00025 #include "canvas/Persistency/Provenance/ProcessHistoryID.h"
00026 #include "canvas/Persistency/Provenance/ProductList.h"
00027 #include "canvas/Persistency/Provenance/ProductProvenance.h"
00028 #include "canvas/Utilities/DebugMacros.h"
00029
00030 #include "fhiclcpp/make_ParameterSet.h"
00031 #include "fhiclcpp/ParameterSet.h"
00032 #include "fhiclcpp/ParameterSetID.h"
00033 #include "fhiclcpp/ParameterSetRegistry.h"
00034
00035 #include <TClass.h>
00036 #include <TMessage.h>
00037 #include <TBufferFile.h>
00038
00039 #include "artdaq/DAQdata/Globals.hh"
00040 #include "artdaq/ArtModules/InputUtilities.hh"
00041 #include "artdaq-core/Data/detail/ParentageMap.hh"
00042 #include "artdaq-core/Utilities/ExceptionHandler.hh"
00043
00044 #include <cstdio>
00045 #include <iomanip>
00046 #include <memory>
00047 #include <sstream>
00048 #include <string>
00049 #include <vector>
00050 #include <sys/time.h>
00051 #include <iostream>
00052
00053 namespace art
00054 {
00055 template <typename U>
00056 class ArtdaqInput;
00057 }
00058
00073 template <typename U>
00074 class art::ArtdaqInput
00075 {
00076 public:
00080 ArtdaqInput(const ArtdaqInput&) = delete;
00081
00086 ArtdaqInput& operator=(const ArtdaqInput&) = delete;
00087
00091 ~ArtdaqInput();
00092
00099 ArtdaqInput(const fhicl::ParameterSet& ps, art::ProductRegistryHelper& helper,
00100 art::SourceHelper const& pm);
00101
00105 void closeCurrentFile();
00106
00111 void readFile(const std::string&, art::FileBlock*& fb);
00112
00117 bool hasMoreData() const;
00118
00128 bool readNext(art::RunPrincipal* const inR,
00129 art::SubRunPrincipal* const inSR, art::RunPrincipal*& outR,
00130 art::SubRunPrincipal*& outSR, art::EventPrincipal*& outE);
00131
00132 private:
00133 void
00134 readAndConstructPrincipal(std::unique_ptr<TBufferFile>&,
00135 unsigned long,
00136 art::RunPrincipal* const,
00137 art::SubRunPrincipal* const,
00138 art::RunPrincipal*&,
00139 art::SubRunPrincipal*&,
00140 art::EventPrincipal*&);
00141
00142 template <class T>
00143 void readDataProducts(std::unique_ptr<TBufferFile>&, T*&);
00144
00145 void putInPrincipal(RunPrincipal*&, std::unique_ptr<EDProduct>&&, const BranchDescription&, std::unique_ptr<const ProductProvenance>&&);
00146
00147 void putInPrincipal(SubRunPrincipal*&, std::unique_ptr<EDProduct>&&, const BranchDescription&, std::unique_ptr<const ProductProvenance>&&);
00148
00149 void putInPrincipal(EventPrincipal*&, std::unique_ptr<EDProduct>&&, const BranchDescription&, std::unique_ptr<const ProductProvenance>&&);
00150
00151
00152 private:
00153 bool shutdownMsgReceived_;
00154 bool outputFileCloseNeeded_;
00155 art::SourceHelper const& pm_;
00156 U communicationWrapper_;
00157 };
00158
00159 template <typename U>
00160 art::ArtdaqInput<U>::
00161 ArtdaqInput(const fhicl::ParameterSet& ps,
00162 art::ProductRegistryHelper& helper,
00163 art::SourceHelper const& pm)
00164 : shutdownMsgReceived_(false)
00165 , outputFileCloseNeeded_(false)
00166 , pm_(pm)
00167 , communicationWrapper_(ps)
00168 {
00169 artdaq::configureMessageFacility("artdaqart");
00170
00171
00172
00173
00174
00175
00176
00177 TLOG_ARB(5, "ArtdaqInput") << "Begin: ArtdaqInput::ArtdaqInput(" <<
00178 "const fhicl::ParameterSet& ps, " <<
00179 "art::ProductRegistryHelper& helper, " <<
00180 "const art::SourceHelper& pm)";
00181 (void)helper;
00182
00183 TLOG_ARB(5, "ArtdaqInput") << "Going to receive init message";
00184 std::unique_ptr<TBufferFile> msg(nullptr);
00185 communicationWrapper_.receiveInitMessage(msg);
00186 TLOG_ARB(5, "ArtdaqInput") << "Init message received";
00187
00188 if (!msg)
00189 {
00190 throw art::Exception(art::errors::DataCorruption) <<
00191 "ArtdaqInput: Could not receive init message!";
00192 }
00193
00194
00195 unsigned long dummy = 0;
00196 msg->ReadULong(dummy);
00197
00198
00199
00200
00201 unsigned long ps_cnt = 0;
00202 msg->ReadULong(ps_cnt);
00203 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: parameter set count: " << ps_cnt;
00204 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: reading parameter sets ...";
00205 for (unsigned long I = 0; I < ps_cnt; ++I)
00206 {
00207 std::string pset_str = "";
00208 msg->ReadStdString(pset_str);
00209
00210 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: parameter set: " << pset_str;
00211
00212 fhicl::ParameterSet pset;
00213 fhicl::make_ParameterSet(pset_str, pset);
00214
00215 pset.id();
00216 fhicl::ParameterSetRegistry::put(pset);
00217 }
00218 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: finished reading parameter sets.";
00219
00220
00221
00222
00223 art::ProductList* productlist = ReadObjectAny<art::ProductList>(msg, "std::map<art::BranchKey,art::BranchDescription>", "ArtdaqInput::ArtdaqInput");
00224 helper.productList(productlist);
00225 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: got product list";
00226
00227 #if ART_HEX_VERSION < 0x20900
00228 if (art::debugit() >= 1)
00229 {
00230 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: before BranchIDLists";
00231
00232 BranchIDLists const * bil = &BranchIDListRegistry::instance().data();
00233 int max_bli = bil->size();
00234 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: max_bli: " << max_bli;
00235 for (int i = 0; i < max_bli; ++i)
00236 {
00237 int max_prdidx = (*bil)[i].size();
00238 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: max_prdidx: " << max_prdidx;
00239 for (int j = 0; j < max_prdidx; ++j)
00240 {
00241 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput:"
00242 << " bli: "
00243 << i
00244 << " prdidx: "
00245 << j
00246 << " bid: 0x"
00247 << std::hex
00248 << static_cast<unsigned long>((*bil)[i][j])
00249 << std::dec;
00250 }
00251 }
00252 }
00253 #endif
00254
00255
00256
00257 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: Reading ProcessHistory";
00258 art::ProcessHistoryMap* phm = ReadObjectAny<art::ProcessHistoryMap>(msg, "std::map<const art::Hash<2>,art::ProcessHistory>", "ArtdaqInput::ArtdaqInput");
00259 printProcessMap(*phm, "ArtdaqInput's ProcessHistoryMap");
00260
00261 ProcessHistoryRegistry::put(*phm);
00262 printProcessMap(ProcessHistoryRegistry::get(), "ArtdaqInput's ProcessHistoryRegistry");
00263
00264
00265
00266
00267 TLOG_ARB(5, "ArtdaqInput") << "ArtdaqInput: Reading ParentageMap";
00268 ParentageMap* parentageMap = ReadObjectAny<ParentageMap>(msg, "art::ParentageMap", "ArtdaqInput::ArtdaqInput");
00269 ParentageRegistry::put(*parentageMap);
00270
00271
00272
00273
00274 TLOG_ARB(5, "ArtdaqInput") << "End: ArtdaqInput::ArtdaqInput(" << "const fhicl::ParameterSet& ps, " << "art::ProductRegistryHelper& helper, " << "const art::SourceHelper& pm)";
00275 }
00276
00277 template <typename U>
00278 art::ArtdaqInput<U>::
00279 ~ArtdaqInput() {}
00280
00281 template <typename U>
00282 void
00283 art::ArtdaqInput<U>::
00284 closeCurrentFile()
00285 {
00286 TLOG_ARB(6, "ArtdaqInput") << "Begin/End: ArtdaqInput::closeCurrentFile()";
00287 }
00288
00289 template <typename U>
00290 void
00291 art::ArtdaqInput<U>::
00292 readFile(const std::string&, art::FileBlock*& fb)
00293 {
00294 TLOG_ARB(7, "ArtdaqInput") << "Begin: ArtdaqInput::"
00295 "readFile(const std::string& name, art::FileBlock*& fb)";
00296 fb = new art::FileBlock(art::FileFormatVersion(1, "ArtdaqInput2013"),
00297 "nothing");
00298 TLOG_ARB(7, "ArtdaqInput") << "End: ArtdaqInput::"
00299 "readFile(const std::string& name, art::FileBlock*& fb)";
00300 }
00301
00302 template <typename U>
00303 bool
00304 art::ArtdaqInput<U>::
00305 hasMoreData() const
00306 {
00307 TLOG_ARB(8, "ArtdaqInput") << "Begin: ArtdaqInput::hasMoreData()";
00308 if (shutdownMsgReceived_)
00309 {
00310 TLOG_ARB(8, "ArtdaqInput") << "ArtdaqInput::hasMoreData(): "
00311 "returning false on shutdownMsgReceived_.";
00312 TLOG_ARB(8, "ArtdaqInput") << "End: ArtdaqInput::hasMoreData()";
00313 return false;
00314 }
00315 TLOG_ARB(8, "ArtdaqInput") << "ArtdaqInput::hasMoreData(): "
00316 "returning true on not shutdownMsgReceived_.";
00317 TLOG_ARB(8, "ArtdaqInput") << "End: ArtdaqInput::hasMoreData()";
00318 return true;
00319 }
00320
00321 template <typename U>
00322 void
00323 art::ArtdaqInput<U>::
00324 readAndConstructPrincipal(std::unique_ptr<TBufferFile>& msg,
00325 unsigned long msg_type_code,
00326 art::RunPrincipal* const inR,
00327 art::SubRunPrincipal* const inSR,
00328 art::RunPrincipal*& outR,
00329 art::SubRunPrincipal*& outSR,
00330 art::EventPrincipal*& outE)
00331 {
00332
00333
00334
00335 std::unique_ptr<art::RunAuxiliary> run_aux;
00336 std::unique_ptr<art::SubRunAuxiliary> subrun_aux;
00337 std::unique_ptr<art::EventAuxiliary> event_aux;
00338 std::shared_ptr<History> history;
00339
00340 if (msg_type_code == 2)
00341 {
00342
00343 TLOG_ARB(9, "ArtdaqInput") << "readAndConstructPrincipal: " << "processing EndRun message ...";
00344
00345 run_aux.reset(ReadObjectAny<art::RunAuxiliary>(msg, "art::RunAuxiliary", "ArtdaqInput::readAndConstructPrincipal"));
00346 printProcessHistoryID("readAndConstructPrincipal", run_aux.get());
00347
00348 TLOG_ARB(9, "ArtdaqInput") << "readAndConstructPrincipal: " << "making flush RunPrincipal ...";
00349 outR = pm_.makeRunPrincipal(RunID::flushRun(), run_aux->beginTime());
00350
00351 TLOG_ARB(9, "ArtdaqInput") << "readAndConstructPrincipal: " << "making flush SubRunPrincipal ...";
00352 outSR = pm_.makeSubRunPrincipal(SubRunID::flushSubRun(), run_aux->beginTime());
00353
00354 TLOG_ARB(9, "ArtdaqInput") << "readAndConstructPrincipal: " << "making flush EventPrincipal ...";
00355 outE = pm_.makeEventPrincipal(EventID::flushEvent(), run_aux->endTime(), true, EventAuxiliary::Any);
00356
00357 TLOG_ARB(9, "ArtdaqInput") << "readAndConstructPrincipal: " <<
00358 "finished processing EndRun message.";
00359 }
00360 else if (msg_type_code == 3)
00361 {
00362
00363 TLOG_ARB(10, "ArtdaqInput") << "readAndConstructPrincipal: " << "processing EndSubRun message ...";
00364
00365 subrun_aux.reset(ReadObjectAny<art::SubRunAuxiliary>(msg, "art::SubRunAuxiliary", "ArtdaqInput::readAndConstructPrincipal"));
00366 printProcessHistoryID("readAndConstructPrincipal", subrun_aux.get());
00367
00368 TLOG_ARB(10, "ArtdaqInput") << "readAndConstructPrincipal: " << "making flush RunPrincipal ...";
00369 outR = pm_.makeRunPrincipal(RunID::flushRun(), subrun_aux->beginTime());
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386 art::Timestamp currentTime = time(0);
00387 if (inR != nullptr) { inR->setEndTime(currentTime); }
00388 if (inSR != nullptr) { inSR->setEndTime(currentTime); }
00389
00390 TLOG_ARB(10, "ArtdaqInput") << "readAndConstructPrincipal: " << "making flush SubRunPrincipal ...";
00391 outSR = pm_.makeSubRunPrincipal(SubRunID::flushSubRun(), subrun_aux->beginTime());
00392
00393 TLOG_ARB(10, "ArtdaqInput") << "readAndConstructPrincipal: " << "making flush EventPrincipal ...";
00394 outE = pm_.makeEventPrincipal(EventID::flushEvent(), subrun_aux->endTime(), true, EventAuxiliary::Any);
00395
00396 TLOG_ARB(10, "ArtdaqInput") << "readAndConstructPrincipal: " << "finished processing EndSubRun message.";
00397 }
00398 else if (msg_type_code == 4)
00399 {
00400
00401 TLOG_ARB(11, "ArtdaqInput") << "readAndConstructPrincipal: " << "processing Event message ...";
00402
00403 run_aux.reset(ReadObjectAny<art::RunAuxiliary>(msg, "art::RunAuxiliary", "ArtdaqInput::readAndConstructPrincipal"));
00404 printProcessHistoryID("readAndConstructPrincipal", run_aux.get());
00405
00406 subrun_aux.reset(ReadObjectAny<art::SubRunAuxiliary>(msg, "art::SubRunAuxiliary", "ArtdaqInput::readAndConstructPrincipal"));
00407 printProcessHistoryID("readAndConstructPrincipal", subrun_aux.get());
00408
00409 event_aux.reset(ReadObjectAny<art::EventAuxiliary>(msg, "art::EventAuxiliary", "ArtdaqInput::readAndConstructPrincipal"));
00410
00411 history.reset(ReadObjectAny<art::History>(msg, "art::History", "ArtdaqInput::readAndConstructPrincipal"));
00412 printProcessHistoryID("readAndConstructPrincipal", history.get());
00413
00414
00415 if (!history->processHistoryID().isValid())
00416 {
00417 throw art::Exception(art::errors::Unknown) << "readAndConstructPrincipal: processHistoryID of history in Event message is invalid!";
00418 }
00419
00420 if ((inR == nullptr) || !inR->id().isValid() || (inR->run() != event_aux->run()))
00421 {
00422
00423
00424 TLOG_ARB(11, "ArtdaqInput") << "readAndConstructPrincipal: making RunPrincipal ...";
00425 outR = pm_.makeRunPrincipal(*run_aux.get());
00426 }
00427 if ((inSR == nullptr) || !inSR->id().isValid() || (inSR->subRun() != event_aux->subRun()))
00428 {
00429
00430
00431 TLOG_ARB(11, "ArtdaqInput") << "readAndConstructPrincipal: " << "making SubRunPrincipal ...";
00432 outSR = pm_.makeSubRunPrincipal(*subrun_aux.get());
00433 }
00434 TLOG_ARB(11, "ArtdaqInput") << "readAndConstructPrincipal: making EventPrincipal ...";
00435 outE = pm_.makeEventPrincipal(*event_aux.get(), std::move(history));
00436
00437 TLOG_ARB(11, "ArtdaqInput") << "readAndConstructPrincipal: " << "finished processing Event message.";
00438 }
00439 }
00440
00441 template <typename U>
00442 template <class T>
00443 void
00444 art::ArtdaqInput<U>::
00445 readDataProducts(std::unique_ptr<TBufferFile>& msg, T*& outPrincipal)
00446 {
00447 unsigned long prd_cnt = 0;
00448 {
00449 TLOG_ARB(12, "ArtdaqInput") << "readDataProducts: reading data product count ...";
00450 msg->ReadULong(prd_cnt);
00451 TLOG_ARB(12, "ArtdaqInput") << "readDataProducts: product count: " << prd_cnt;
00452 }
00453
00454
00455
00456 const ProductList& productList = ProductMetaData::instance().productList();
00457
00458 for (unsigned long I = 0; I < prd_cnt; ++I)
00459 {
00460 std::unique_ptr<BranchKey> bk;
00461
00462 {
00463 TLOG_ARB(12, "ArtdaqInput") << "readDataProducts: Reading branch key.";
00464 bk.reset(ReadObjectAny<BranchKey>(msg, "art::BranchKey", "ArtdaqInput::readDataProducts"));
00465 }
00466
00467 if (art::debugit() >= 1)
00468 {
00469 TLOG_ARB(13, "ArtdaqInput") << "readDataProducts: got product class: '"
00470 << bk->friendlyClassName_
00471 << "' modlbl: '"
00472 << bk->moduleLabel_
00473 << "' instnm: '"
00474 << bk->productInstanceName_
00475 << "' procnm: '"
00476 << bk->processName_;
00477 }
00478 ProductList::const_iterator iter;
00479 {
00480 TLOG_ARB(12, "ArtdaqInput") << "readDataProducts: looking up product ...";
00481 iter = productList.find(*bk);
00482 if (iter == productList.end())
00483 {
00484 throw art::Exception(art::errors::ProductNotFound)
00485 << "No product is registered for\n"
00486 << " process name: '"
00487 << bk->processName_ << "'\n"
00488 << " module label: '"
00489 << bk->moduleLabel_ << "'\n"
00490 << " product friendly class name: '"
00491 << bk->friendlyClassName_ << "'\n"
00492 << " product instance name: '"
00493 << bk->productInstanceName_ << "'\n";
00494 }
00495 }
00496
00497
00498 const BranchDescription& bd = iter->second;
00499 std::unique_ptr<EDProduct> prd;
00500 {
00501 TLOG_ARB(12, "ArtdaqInput") << "readDataProducts: Reading product with wrapped name: " << bd.wrappedName()
00502 << ", TClass = " << (void*)TClass::GetClass(bd.wrappedName().c_str());
00503
00504
00505
00506
00507
00508
00509 void* p = msg->ReadObjectAny(TClass::GetClass(bd.wrappedName().c_str()));
00510 auto pp = reinterpret_cast<EDProduct*>(p);
00511
00512 TLOG_ARB(12, "ArtdaqInput") << "readDataProducts: After ReadObjectAny(prd): p=" << p
00513 << ", EDProduct::isPresent: " << pp->isPresent();
00514 prd.reset(pp);
00515 p = nullptr;
00516 }
00517 std::unique_ptr<const ProductProvenance> prdprov;
00518 {
00519 TLOG_ARB(12, "ArtdaqInput") << "readDataProducts: Reading product provenance.";
00520 prdprov.reset(ReadObjectAny<ProductProvenance>(msg, "art::ProductProvenance", "ArtdaqInput::readDataProducts"));
00521 }
00522 {
00523 TLOG_ARB(12, "ArtdaqInput") << "readDataProducts: inserting product: class: '"
00524 << bd.friendlyClassName()
00525 << "' modlbl: '"
00526 << bd.moduleLabel()
00527 << "' instnm: '"
00528 << bd.productInstanceName()
00529 << "' procnm: '"
00530 << bd.processName();
00531 putInPrincipal(outPrincipal, std::move(prd), bd, std::move(prdprov));
00532
00533 }
00534 }
00535 }
00536
00537 template <typename U>
00538 void
00539 art::ArtdaqInput<U>::
00540 putInPrincipal(RunPrincipal*& rp, std::unique_ptr<EDProduct>&& prd, const BranchDescription& bd, std::unique_ptr<const ProductProvenance>&& prdprov)
00541 {
00542 rp->put(std::move(prd), bd, std::move(prdprov), RangeSet::forRun(rp->id()));
00543 }
00544
00545 template <typename U>
00546 void
00547 art::ArtdaqInput<U>::
00548 putInPrincipal(SubRunPrincipal*& srp, std::unique_ptr<EDProduct>&& prd, const BranchDescription& bd, std::unique_ptr<const ProductProvenance>&& prdprov)
00549 {
00550 srp->put(std::move(prd), bd, std::move(prdprov), RangeSet::forSubRun(srp->id()));
00551 }
00552
00553 template <typename U>
00554 void
00555 art::ArtdaqInput<U>::
00556 putInPrincipal(EventPrincipal*& ep, std::unique_ptr<EDProduct>&& prd, const BranchDescription& bd, std::unique_ptr<const ProductProvenance>&& prdprov)
00557 {
00558 TLOG_ARB(14, "ArtdaqInput") << "EventPrincipal size before put: " << ep->size();
00559 ep->put(std::move(prd), bd, std::move(prdprov));
00560 TLOG_ARB(14, "ArtdaqInput") << "EventPrincipal size after put: " << ep->size();
00561 }
00562
00563
00564 template <typename U>
00565 bool
00566 art::ArtdaqInput<U>::
00567 readNext(art::RunPrincipal* const inR, art::SubRunPrincipal* const inSR,
00568 art::RunPrincipal*& outR, art::SubRunPrincipal*& outSR,
00569 art::EventPrincipal*& outE)
00570 {
00571 TLOG_ARB(15, "ArtdaqInput") << "Begin: ArtdaqInput::readNext";
00572 if (outputFileCloseNeeded_)
00573 {
00574 outputFileCloseNeeded_ = false;
00575
00576
00577 TLOG_ARB(15, "ArtdaqInput") << "ArtdaqInput::readNext: " << "returning false on outputFileCloseNeeded_";
00578 TLOG_ARB(15, "ArtdaqInput") << "End: ArtdaqInput::readNext";
00579 return false;
00580 }
00581
00582 std::unique_ptr<TBufferFile> msg;
00583 communicationWrapper_.receiveMessage(msg);
00584
00585 if (!msg)
00586 {
00587 shutdownMsgReceived_ = true;
00588 return false;
00589 }
00590
00591
00592
00593
00594 unsigned long msg_type_code = 0;
00595 {
00596 TLOG_ARB(15, "ArtdaqInput") << "ArtdaqInput::readNext: " << "getting message type code ...";
00597 msg->ReadULong(msg_type_code);
00598 TLOG_ARB(15, "ArtdaqInput") << "ArtdaqInput::readNext: " << "message type: " << msg_type_code;
00599 }
00600 if (msg_type_code == 5)
00601 {
00602
00603 shutdownMsgReceived_ = true;
00604 TLOG_ARB(16, "ArtdaqInput") << "ArtdaqInput::readNext: " << "returning false on Shutdown message.";
00605 TLOG_ARB(16, "ArtdaqInput") << "End: ArtdaqInput::readNext";
00606 return false;
00607 }
00608
00609 readAndConstructPrincipal(msg, msg_type_code, inR, inSR, outR,
00610 outSR, outE);
00611
00612
00613
00614 if (msg_type_code == 2)
00615 {
00616
00617
00618 readDataProducts(msg, outR);
00619
00620 TLOG_ARB(17, "ArtdaqInput") << "ArtdaqInput::readNext: " << "returning false on EndRun message.";
00621 TLOG_ARB(17, "ArtdaqInput") << "End: ArtdaqInput::readNext";
00622 return false;
00623 }
00624 else if (msg_type_code == 3)
00625 {
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635 if (inR != 0 && inSR != 0 && outR != 0 && outSR != 0)
00636 {
00637 if (inR->id().isFlush() && inSR->id().isFlush() &&
00638 outR->id().isFlush() && outSR->id().isFlush())
00639 {
00640 outR = 0;
00641 outSR = 0;
00642 outputFileCloseNeeded_ = true;
00643 return true;
00644 }
00645 }
00646
00647 readDataProducts(msg, outSR);
00648
00649
00650 outputFileCloseNeeded_ = true;
00651 TLOG_ARB(18, "ArtdaqInput") << "readNext: returning true on EndSubRun message.";
00652 TLOG_ARB(18, "ArtdaqInput") << "End: ArtdaqInput::readNext";
00653 return true;
00654 }
00655 else if (msg_type_code == 4)
00656 {
00657
00658 readDataProducts(msg, outE);
00659 TLOG_ARB(19, "ArtdaqInput") << "readNext: returning true on Event message.";
00660 TLOG_ARB(19, "ArtdaqInput") << "End: ArtdaqInput::readNext";
00661 return true;
00662 }
00663
00664
00665 TLOG_ARB(20, "ArtdaqInput") << "readNext: returning false on unknown msg_type_code!";
00666 TLOG_ARB(20, "ArtdaqInput") << "End: ArtdaqInput::readNext";
00667 return false;
00668 }