52 for (const_iterator subsys = source.begin(); subsys != source.end(); ++subsys) {
53 this->push_back(subsys->get()->Clone());
55 if (this->back()->PublishInternalValues() == kFALSE) {
56 QwError <<
"Not all variables for " << this->back()->GetName()
57 <<
" could be published!" << QwLog::endl;
78 for (
size_t i = 0; i < this->size(); ++i) {
79 if (this->at(i) !=
nullptr) {
88 const Bool_t cache_valid =
92 if (cache_valid)
return;
97 if (this->size() != source.size())
return;
99 for (
size_t i = 0; i < source.size(); ++i) {
103 if (ptr1 ==
nullptr || ptr2 ==
nullptr)
continue;
105 if (
typeid(*ptr1) ==
typeid(*ptr2)) {
109 QwError <<
" typeid(*ptr1)=" <<
typeid(*ptr1).name()
110 <<
" but typeid(*ptr2)=" <<
typeid(*ptr2).name()
126 if (!source.empty()){
127 if (this->size() == source.size()){
129 for(
size_t i=0;i<source.size();i++){
149 std::unique_ptr<QwParameterFile> preamble;
154 if (preamble) preamble.reset();
156 std::unique_ptr<QwParameterFile> section;
157 std::string section_name;
165 std::string subsys_type = section_name;
166 std::string subsys_name;
167 if (! section->FileHasVariablePair(
"=",
"name",subsys_name)) {
168 QwError <<
"No name defined in section for subsystem " << subsys_type <<
"." <<
QwLog::endl;
173 bool disabled_by_type =
false;
176 disabled_by_type =
true;
177 if (disabled_by_type) {
183 bool disabled_by_name =
false;
186 disabled_by_name =
true;
187 if (disabled_by_name) {
193 QwMessage <<
"Creating subsystem of type " << subsys_type <<
" "
194 <<
"with name " << subsys_name <<
"." <<
QwLog::endl;
198 VQwSubsystemFactory::Create(subsys_type, subsys_name);
210 QwMessage <<
"Subsystem " << subsys_name <<
" cannot be stored in this "
213 delete subsys; subsys = 0;
239 if (subsys == NULL) {
240 QwError <<
"QwSubsystemArray::push_back(): NULL subsys"
247 QwError <<
"QwSubsystemArray::push_back(): subsys " << subsys->
GetName()
252 QwError <<
"QwSubsystemArray::push_back(): subsys " << subsys->
GetName()
253 <<
" is not supported by this subsystem array" <<
QwLog::endl;
256 std::shared_ptr<VQwSubsystem> subsys_tmp(subsys);
257 SubsysPtrs::push_back(subsys_tmp);
261 subsys_tmp->SetParent(
this);
278 po::value<std::string>()->default_value(
"detectors.map"),
279 "map file with detectors to include");
282 po::value<std::string>()->default_value(
""),
283 "map file with bad event ranges");
287 po::value<std::vector <std::string> >()->multitoken(),
288 "subsystem types to disable");
290 po::value<std::vector <std::string> >()->multitoken(),
291 "subsystem names to disable");
318 for (iterator subsys_iter = begin(); subsys_iter != end(); ++subsys_iter) {
326 std::string fBadEventListFileName = options.
GetValue<std::string>(
"bad-event-list");
327 if (fBadEventListFileName.size() > 0) {
330 std::string bad_event_range;
331 while (fBadEventListFile.
ReadNextLine(bad_event_range)){
353 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
356 if ((*subsys)->GetName() == name) {
357 tmp = (*subsys).get();
376 std::vector<VQwSubsystem*> subsys_list;
382 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
385 if (VQwSubsystemFactory::InheritsFrom((*subsys).get(),type)) {
386 subsys_list.push_back((*subsys).get());
403 std::for_each(begin(), end(),
415 for (iterator subsys = begin(); subsys != end(); ++subsys){
416 (*subsys)->ProcessConfigurationBuffer(roc_id, bank_id, buffer, num_words);
427 std::vector<UInt_t>& marker)
const
430 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
431 (*subsys)->GetMarkerWordList(roc_id, bank_id, marker);
438 const UInt_t event_type,
446 for (iterator subsys = begin(); subsys != end(); ++subsys) {
447 (*subsys)->ProcessEvBuffer(event_type, roc_id, bank_id, buffer, num_words);
475 for (iterator subsys = begin(); subsys != end(); ++subsys) {
476 (*subsys)->RandomizeEventData(helicity, time);
484 for (iterator subsys = begin(); subsys != end(); ++subsys) {
485 (*subsys)->EncodeEventData(buffer);
492 std::vector<ROCID_t> tmp;
493 for (iterator subsys = begin(); subsys != end(); ++subsys) {
494 tmp = (*subsys)->GetROCIds();
495 for(
auto it = tmp.begin(); it!=tmp.end();it++){
496 if(std::find(list.begin(), list.end(), *it) == list.end() )
507 for (iterator subsys = begin(); subsys != end(); ++subsys){
508 (*subsys)->ConstructObjects(folder,prefix);
517 for (iterator subsys = begin(); subsys != end(); ++subsys){
518 (*subsys)->ConstructHistograms(folder,prefix);
531 if (!empty() && !source.empty()) {
532 if (this->size() == source.size()) {
533 for (
size_t i = 0; i < source.size(); ++i) {
534 this->at(i)->ShareHistograms(source.at(i).get());
549 for (iterator subsys = begin(); subsys != end(); ++subsys){
550 (*subsys)->ConstructTree(folder, prefix);
578 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
579 (*subsys)->PrintInfo();
602 values.
push_back(
"CodaEventNumber",
'i');
604 if (prefix ==
"" || prefix.Index(
"yield_") == 0) {
605 tree->Branch(
"CodaEventNumber",&(values[
fTreeArrayIndex]),
"CodaEventNumber/i");
606 tree->Branch(
"CodaEventType",&(values[
fTreeArrayIndex+1]),
"CodaEventType/i");
608 for (iterator subsys = begin(); subsys != end(); ++subsys) {
624 if (prefix ==
"" || prefix ==
"yield_") {
629 for (iterator subsys = begin(); subsys != end(); ++subsys) {
649 std::unique_ptr<QwParameterFile> preamble;
650 std::unique_ptr<QwParameterFile> nextsection;
657 if (prefix ==
"" || prefix ==
"yield_") {
662 for (iterator subsys = begin(); subsys != end(); ++subsys) {
665 TString subsysname = subsys_ptr->
GetName();
691 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
697#ifdef HAS_RNTUPLE_SUPPORT
704void QwSubsystemArray::ConstructNTupleAndVector(
705 std::unique_ptr<ROOT::RNTupleModel>& model,
707 std::vector<Double_t>& values,
708 std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
714 values.push_back(0.0);
715 values.push_back(0.0);
716 values.push_back(0.0);
717 values.push_back(0.0);
718 values.push_back(0.0);
721 if (prefix ==
"" || prefix.Index(
"yield_") == 0) {
722 auto eventNumField = model->MakeField<Double_t>(
"CodaEventNumber");
723 auto eventTypeField = model->MakeField<Double_t>(
"CodaEventType");
725 fieldPtrs.push_back(eventNumField);
726 fieldPtrs.push_back(eventTypeField);
729 fieldPtrs.push_back(
nullptr);
730 fieldPtrs.push_back(
nullptr);
734 for (iterator subsys = begin(); subsys != end(); ++subsys) {
735 VQwSubsystem* subsys_ptr =
dynamic_cast<VQwSubsystem*
>(subsys->get());
736 subsys_ptr->ConstructNTupleAndVector(model, prefix, values, fieldPtrs);
741#ifdef HAS_RNTUPLE_SUPPORT
746void QwSubsystemArray::FillNTupleVector(std::vector<Double_t>& values)
const
754 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
755 VQwSubsystem* subsys_ptr =
dynamic_cast<VQwSubsystem*
>(subsys->get());
756 subsys_ptr->FillNTupleVector(values);
800 for (const_iterator subsys = begin(); subsys != end(); ++subsys)
802 (*subsys)->PrintDetectorMaps(
true);
811 TList* return_maps_TList =
new TList;
812 return_maps_TList->SetName(name);
814 std::map<TString, TString> mapfiles_subsystem;
816 for (const_iterator subsys = begin(); subsys != end(); ++subsys)
818 mapfiles_subsystem = (*subsys)->GetDetectorMaps();
819 for( std::map<TString, TString>::iterator ii= mapfiles_subsystem.begin(); ii!= mapfiles_subsystem.end(); ++ii)
821 TList *test =
new TList;
822 test->SetName((*ii).first);
823 test->AddLast(
new TObjString((*ii).second));
824 return_maps_TList -> AddLast(test);
828 return return_maps_TList;
845 if (subsys.get() == NULL) {
846 QwError <<
"QwSubsystemArray::push_back(): NULL subsys"
853 QwError <<
"QwSubsystemArray::push_back(): subsys " << subsys->GetName()
858 QwError <<
"QwSubsystemArray::push_back(): subsys " << subsys->GetName()
859 <<
" is not supported by this subsystem array" <<
QwLog::endl;
862 std::shared_ptr<VQwSubsystem> subsys_tmp(subsys);
863 SubsysPtrs::push_back(subsys_tmp);
867 subsys_tmp->SetParent(
this);
874 if (subsys_tmp->PublishInternalValues() == kFALSE) {
875 QwError <<
"Not all variables for " << subsys_tmp->GetName()
A logfile class, based on an identical class in the Hermes analyzer.
#define QwVerbose
Predefined log drain for verbose messages.
#define QwError
Predefined log drain for errors.
#define QwWarning
Predefined log drain for warnings.
#define QwMessage
Predefined log drain for regular messages.
#define QwDebug
Predefined log drain for debugging output.
ROOT file and tree management wrapper classes.
Array container for managing multiple subsystems.
Parameter file parsing and management.
static std::ostream & endl(std::ostream &)
End of the line.
Command-line and configuration file options processor.
std::vector< T > GetValueVector(const std::string &key)
Get a list of templated values.
T GetValue(const std::string &key)
Get a templated value.
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Configuration file parser with flexible tokenization and search capabilities.
Bool_t FileHasSectionHeader(const std::string &secname)
void TrimWhitespace(TString::EStripType head_tail=TString::kBoth)
static std::pair< int, int > ParseIntRange(const std::string &separatorchars, const std::string &range)
Parse a range of integers as #:# where either can be missing.
void TrimComment(const char commentchar)
std::unique_ptr< QwParameterFile > ReadUntilNextSection(const bool add_current_line=false)
std::unique_ptr< QwParameterFile > ReadSectionPreamble()
Rewinds to the start and read until it finds next section header.
std::unique_ptr< QwParameterFile > ReadNextSection(std::string &secname, const bool keep_header=false)
A helper class to manage a vector of branch entries for ROOT trees.
size_type size() const noexcept
void push_back(const std::string &name, const char type='D')
void SetValue(size_type index, Double_t val)
std::vector< Bool_t > fResolvedPairCompatible
void BuildResolvedSelf() const
void SetDataLoaded(const Bool_t flag)
Set data loaded flag.
QwSubsystemArray & operator=(const QwSubsystemArray &value)
Assignment operator.
virtual std::vector< VQwSubsystem * > GetSubsystemByType(const std::string &type)
Get the list of subsystems of the specified type.
void ConstructHistograms()
Construct the histograms for this subsystem.
void GetMarkerWordList(const ROCID_t roc_id, const BankID_t bank_id, std::vector< UInt_t > &marker) const
void push_back(VQwSubsystem *subsys)
Add the subsystem to this array.
void EncodeEventData(std::vector< UInt_t > &buffer)
Encode the data in this event.
UInt_t fCodaEventType
CODA event type as provided by QwEventBuffer.
void ConstructObjects()
Construct the objects for this subsystem.
void ProcessEvent()
Process the decoded data in this event.
UInt_t GetCodaEventNumber() const
Get the internal record of the CODA event number.
std::vector< std::string > fSubsystemsDisabledByName
List of disabled types.
const QwSubsystemArray * fResolvedPeer
virtual VQwSubsystem * GetSubsystemByName(const TString &name)
Get the subsystem with the specified name.
QwSubsystemArray()
Private default constructor.
void LoadAllEventRanges(QwOptions &options)
void PrintParamFileList() const
Print list of parameter files.
void ConstructBranchAndVector(TTree *tree, QwRootTreeBranchVector &values)
Construct the tree and vector for this subsystem.
TList * GetParamFileNameList(TString name) const
Get list of parameter files.
CanContainFn fnCanContain
Function to determine which subsystems we can accept.
void PrintInfo() const
Print some information about the subsystem.
Bool_t(* CanContainFn)(VQwSubsystem *)
UInt_t GetCodaEventType() const
Get the internal record of the CODA event type.
static void DefineOptions(QwOptions &options)
Define configuration options for global array.
void ConstructTree()
Construct the tree for this subsystem.
UInt_t fCodaRunNumber
Index of this data element in root tree.
Int_t ProcessEvBuffer(const UInt_t event_type, const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words)
Process the event buffer for events.
void ShareHistograms(const QwSubsystemArray &source)
Share the histograms with another subsystem.
std::vector< VQwSubsystem * > fResolvedSelf
std::string fSubsystemsMapFile
Filename of the global detector map.
std::vector< VQwSubsystem * > fResolvedPeerSlots
void SetCodaEventNumber(UInt_t evtnum)
Set the internal record of the CODA event number.
void FillTree()
Fill the tree for this subsystem.
void RandomizeEventData(int helicity=0, double time=0.0)
Randomize the data in this event.
UInt_t fCodaSegmentNumber
CODA segment number as provided by QwEventBuffer.
std::vector< std::string > fSubsystemsDisabledByType
List of disabled names.
void ConstructBranch(TTree *tree, TString &prefix)
Construct a branch for this subsystem with a prefix.
std::vector< std::pair< UInt_t, UInt_t > > fBadEventRange
void ProcessOptionsToplevel(QwOptions &options)
Process configuration options for the subsystem array itself.
void ResolvePairing(const QwSubsystemArray &source, const char *context) const
UInt_t fEventTypeMask
Mask of event types.
Bool_t fHasDataLoaded
Has this array gotten data to be processed?
void LoadSubsystemsFromParameterFile(QwParameterFile &detectors)
void SetCodaEventType(UInt_t evttype)
Set the internal record of the CODA event type.
void AtEndOfEventLoop()
Perform actions at the end of the event loop.
void ProcessOptionsSubsystems(QwOptions &options)
Process configuration options for all subsystems in the array.
void FillTreeVector(QwRootTreeBranchVector &values) const
Fill the vector for this subsystem.
Bool_t HasDataLoaded() const
Get data loaded flag.
UInt_t fCodaEventNumber
CODA event number as provided by QwEventBuffer.
Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words)
Process the event buffer for configuration events.
void GetROCIDList(std::vector< ROCID_t > &list)
Get the ROCID list.
void FillHistograms()
Fill the histograms for this subsystem.
void DeleteTree()
Delete the tree for this subsystem.
void InvalidateResolvedDispatchCache()
Base class for subsystems implementing container-delegation pattern.
virtual void AtEndOfEventLoop()
Perform actions at the end of the event loop.
virtual void DeleteTree()
Delete the tree for this subsystem.
Bool_t PublishInternalValues() const override
Publish all variables of the subsystem.
virtual void ProcessOptions(QwOptions &)
Process the command line options.
virtual void FillTree()
Fill the tree for this subsystem.
virtual void FillHistograms()=0
Fill the histograms for this subsystem.
virtual void ExchangeProcessedData()
Request processed data from other subsystems for internal use in the second event processing stage....
virtual void FillTreeVector(QwRootTreeBranchVector &values) const =0
Fill the tree vector.
virtual void ClearEventData()=0
virtual Int_t LoadDetectorMaps(QwParameterFile &file)
Parse parameter file to find the map files.
virtual void ProcessEvent_2()
Process the event data again, including data from other subsystems. Not all derived classes will requ...
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)=0
Construct the branch and tree vector.
virtual void ConstructBranch(TTree *tree, TString &prefix)=0
Construct the branch and tree vector.
virtual void ProcessEvent()=0