50 for (
size_t i = 0; i < 3; i++)
54 for (const_iterator subsys = source.begin(); subsys != source.end(); ++subsys) {
55 this->push_back(subsys->get()->Clone());
57 if (this->back()->PublishInternalValues() == kFALSE) {
58 QwError <<
"Not all variables for " << this->back()->GetName()
59 <<
" could be published!" << QwLog::endl;
75 if (this->size() == source.size()){
76 for(
size_t i=0;i<source.size();i++){
77 if (source.at(i)==NULL || this->at(i)==NULL){
84 if (
typeid(*ptr1)==
typeid(*(ptr2))){
85 *(ptr1) = source.at(i).get();
89 QwError <<
" typeid(*ptr1)=" <<
typeid(*ptr1).name()
90 <<
" but typeid(*ptr2)=" <<
typeid(*ptr2).name()
111 std::unique_ptr<QwParameterFile> preamble;
116 if (preamble) preamble.reset();
118 std::unique_ptr<QwParameterFile> section;
119 std::string section_name;
127 std::string subsys_type = section_name;
128 std::string subsys_name;
129 if (! section->FileHasVariablePair(
"=",
"name",subsys_name)) {
130 QwError <<
"No name defined in section for subsystem " << subsys_type <<
"." <<
QwLog::endl;
135 bool disabled_by_type =
false;
138 disabled_by_type =
true;
139 if (disabled_by_type) {
145 bool disabled_by_name =
false;
148 disabled_by_name =
true;
149 if (disabled_by_name) {
155 QwMessage <<
"Creating subsystem of type " << subsys_type <<
" "
156 <<
"with name " << subsys_name <<
"." <<
QwLog::endl;
160 VQwSubsystemFactory::Create(subsys_type, subsys_name);
172 QwMessage <<
"Subsystem " << subsys_name <<
" cannot be stored in this "
175 delete subsys; subsys = 0;
201 if (subsys == NULL) {
202 QwError <<
"QwSubsystemArray::push_back(): NULL subsys"
209 QwError <<
"QwSubsystemArray::push_back(): subsys " << subsys->
GetName()
214 QwError <<
"QwSubsystemArray::push_back(): subsys " << subsys->
GetName()
215 <<
" is not supported by this subsystem array" <<
QwLog::endl;
218 std::shared_ptr<VQwSubsystem> subsys_tmp(subsys);
219 SubsysPtrs::push_back(subsys_tmp);
222 subsys_tmp->SetParent(
this);
239 po::value<std::string>()->default_value(
"detectors.map"),
240 "map file with detectors to include");
243 po::value<std::string>()->default_value(
""),
244 "map file with bad event ranges");
248 po::value<std::vector <std::string> >()->multitoken(),
249 "subsystem types to disable");
251 po::value<std::vector <std::string> >()->multitoken(),
252 "subsystem names to disable");
279 for (iterator subsys_iter = begin(); subsys_iter != end(); ++subsys_iter) {
287 std::string fBadEventListFileName = options.
GetValue<std::string>(
"bad-event-list");
288 if (fBadEventListFileName.size() > 0) {
291 std::string bad_event_range;
292 while (fBadEventListFile.
ReadNextLine(bad_event_range)){
314 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
317 if ((*subsys)->GetName() == name) {
318 tmp = (*subsys).get();
337 std::vector<VQwSubsystem*> subsys_list;
343 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
346 if (VQwSubsystemFactory::InheritsFrom((*subsys).get(),type)) {
347 subsys_list.push_back((*subsys).get());
364 std::for_each(begin(), end(),
376 for (iterator subsys = begin(); subsys != end(); ++subsys){
377 (*subsys)->ProcessConfigurationBuffer(roc_id, bank_id, buffer, num_words);
388 std::vector<UInt_t>& marker)
const
391 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
392 (*subsys)->GetMarkerWordList(roc_id, bank_id, marker);
399 const UInt_t event_type,
407 for (iterator subsys = begin(); subsys != end(); ++subsys) {
408 (*subsys)->ProcessEvBuffer(event_type, roc_id, bank_id, buffer, num_words);
436 for (iterator subsys = begin(); subsys != end(); ++subsys) {
437 (*subsys)->RandomizeEventData(helicity, time);
445 for (iterator subsys = begin(); subsys != end(); ++subsys) {
446 (*subsys)->EncodeEventData(buffer);
453 std::vector<ROCID_t> tmp;
454 for (iterator subsys = begin(); subsys != end(); ++subsys) {
455 tmp = (*subsys)->GetROCIds();
456 for(
auto it = tmp.begin(); it!=tmp.end();it++){
457 if(std::find(list.begin(), list.end(), *it) == list.end() )
468 for (iterator subsys = begin(); subsys != end(); ++subsys){
469 (*subsys)->ConstructObjects(folder,prefix);
478 for (iterator subsys = begin(); subsys != end(); ++subsys){
479 (*subsys)->ConstructHistograms(folder,prefix);
492 if (!empty() && !source.empty()) {
493 if (this->size() == source.size()) {
494 for (
size_t i = 0; i < source.size(); ++i) {
495 this->at(i)->ShareHistograms(source.at(i).get());
510 for (iterator subsys = begin(); subsys != end(); ++subsys){
511 (*subsys)->ConstructTree(folder, prefix);
539 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
540 (*subsys)->PrintInfo();
563 values.
push_back(
"CodaEventNumber",
'i');
568 if (prefix ==
"" || prefix.Index(
"yield_") == 0) {
569 tree->Branch(
"CodaEventNumber",&(values[
fTreeArrayIndex]),
"CodaEventNumber/i");
570 tree->Branch(
"CodaEventType",&(values[
fTreeArrayIndex+1]),
"CodaEventType/i");
571 tree->Branch(
"Coda_CleanData",&(values[
fTreeArrayIndex+2]),
"Coda_CleanData/D");
572 tree->Branch(
"Coda_ScanData1",&(values[
fTreeArrayIndex+3]),
"Coda_ScanData1/D");
573 tree->Branch(
"Coda_ScanData2",&(values[
fTreeArrayIndex+4]),
"Coda_ScanData2/D");
575 for (iterator subsys = begin(); subsys != end(); ++subsys) {
591 if (prefix ==
"" || prefix ==
"yield_") {
596 for (iterator subsys = begin(); subsys != end(); ++subsys) {
616 std::unique_ptr<QwParameterFile> preamble;
617 std::unique_ptr<QwParameterFile> nextsection;
624 if (prefix ==
"" || prefix ==
"yield_") {
629 for (iterator subsys = begin(); subsys != end(); ++subsys) {
632 TString subsysname = subsys_ptr->
GetName();
661 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
667#ifdef HAS_RNTUPLE_SUPPORT
674void QwSubsystemArray::ConstructNTupleAndVector(
675 std::unique_ptr<ROOT::RNTupleModel>& model,
677 std::vector<Double_t>& values,
678 std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
684 values.push_back(0.0);
685 values.push_back(0.0);
686 values.push_back(0.0);
687 values.push_back(0.0);
688 values.push_back(0.0);
691 if (prefix ==
"" || prefix.Index(
"yield_") == 0) {
692 auto eventNumField = model->MakeField<Double_t>(
"CodaEventNumber");
693 auto eventTypeField = model->MakeField<Double_t>(
"CodaEventType");
694 auto cleanDataField = model->MakeField<Double_t>(
"Coda_CleanData");
695 auto scanData1Field = model->MakeField<Double_t>(
"Coda_ScanData1");
696 auto scanData2Field = model->MakeField<Double_t>(
"Coda_ScanData2");
698 fieldPtrs.push_back(eventNumField);
699 fieldPtrs.push_back(eventTypeField);
700 fieldPtrs.push_back(cleanDataField);
701 fieldPtrs.push_back(scanData1Field);
702 fieldPtrs.push_back(scanData2Field);
705 fieldPtrs.push_back(
nullptr);
706 fieldPtrs.push_back(
nullptr);
707 fieldPtrs.push_back(
nullptr);
708 fieldPtrs.push_back(
nullptr);
709 fieldPtrs.push_back(
nullptr);
713 for (iterator subsys = begin(); subsys != end(); ++subsys) {
714 VQwSubsystem* subsys_ptr =
dynamic_cast<VQwSubsystem*
>(subsys->get());
715 subsys_ptr->ConstructNTupleAndVector(model, prefix, values, fieldPtrs);
720#ifdef HAS_RNTUPLE_SUPPORT
725void QwSubsystemArray::FillNTupleVector(std::vector<Double_t>& values)
const
736 for (const_iterator subsys = begin(); subsys != end(); ++subsys) {
737 VQwSubsystem* subsys_ptr =
dynamic_cast<VQwSubsystem*
>(subsys->get());
738 subsys_ptr->FillNTupleVector(values);
782 for (const_iterator subsys = begin(); subsys != end(); ++subsys)
784 (*subsys)->PrintDetectorMaps(
true);
793 TList* return_maps_TList =
new TList;
794 return_maps_TList->SetName(name);
796 std::map<TString, TString> mapfiles_subsystem;
798 for (const_iterator subsys = begin(); subsys != end(); ++subsys)
800 mapfiles_subsystem = (*subsys)->GetDetectorMaps();
801 for( std::map<TString, TString>::iterator ii= mapfiles_subsystem.begin(); ii!= mapfiles_subsystem.end(); ++ii)
803 TList *test =
new TList;
804 test->SetName((*ii).first);
805 test->AddLast(
new TObjString((*ii).second));
806 return_maps_TList -> AddLast(test);
810 return return_maps_TList;
827 if (subsys.get() == NULL) {
828 QwError <<
"QwSubsystemArray::push_back(): NULL subsys"
835 QwError <<
"QwSubsystemArray::push_back(): subsys " << subsys->GetName()
840 QwError <<
"QwSubsystemArray::push_back(): subsys " << subsys->GetName()
841 <<
" is not supported by this subsystem array" <<
QwLog::endl;
844 std::shared_ptr<VQwSubsystem> subsys_tmp(subsys);
845 SubsysPtrs::push_back(subsys_tmp);
848 subsys_tmp->SetParent(
this);
855 if (subsys_tmp->PublishInternalValues() == kFALSE) {
856 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.
Array container for managing multiple subsystems.
ROOT file and tree management wrapper classes.
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)
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.
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.
Double_t fCleanParameter[3]
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::string fSubsystemsMapFile
Filename of the global detector map.
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.
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.
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