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