JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwDataHandlerArray Class Reference

Virtual base class for the parity handlers. More...

#include <QwDataHandlerArray.h>

+ Inheritance diagram for QwDataHandlerArray:
+ Collaboration diagram for QwDataHandlerArray:

Public Member Functions

 QwDataHandlerArray (QwOptions &options, QwHelicityPattern &helicitypattern, const TString &run)
 Constructor from helicity pattern with options.
 
 QwDataHandlerArray (QwOptions &options, QwSubsystemArrayParity &detectors, const TString &run)
 Constructor from subsystem array with options.
 
 QwDataHandlerArray (const QwDataHandlerArray &source)
 Copy constructor by reference.
 
 ~QwDataHandlerArray () override
 Default destructor.
 
void ProcessOptions (QwOptions &options)
 Process configuration options for the datahandler array itself.
 
template<class T>
void LoadDataHandlersFromParameterFile (QwParameterFile &mapfile, T &detectors, const TString &run)
 Load data handlers from a parameter file.
 
void push_back (VQwDataHandler *handler)
 Add the datahandler to this array.
 
void push_back (std::shared_ptr< VQwDataHandler > handler)
 
VQwDataHandlerGetDataHandlerByName (const TString &name)
 Get the handler with the specified name.
 
std::vector< VQwDataHandler * > GetDataHandlerByType (const std::string &type)
 
void ConstructTreeBranches (QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="")
 
void ConstructBranchAndVector (TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
 Construct a branch and vector for this handler with a prefix.
 
void FillTreeBranches (QwRootFile *treerootfile)
 
void FillTreeVector (QwRootTreeBranchVector &values) const
 Fill the vector for this handler.
 
void ConstructNTupleFields (QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="")
 RNTuple methods.
 
void FillNTupleFields (QwRootFile *treerootfile)
 
void ConstructHistograms ()
 Construct the histograms for this subsystem.
 
void ConstructHistograms (TDirectory *folder)
 Construct the histograms for this subsystem in a folder.
 
void ConstructHistograms (TDirectory *folder, TString &prefix)
 Construct the histograms in a folder with a prefix.
 
void FillHistograms ()
 Fill the histograms.
 
void FillDB (QwParityDB *db, TString type)
 Fill the database.
 
void ClearEventData ()
 
void ProcessEvent ()
 
void UpdateBurstCounter (Short_t burstcounter)
 
QwDataHandlerArrayoperator= (const QwDataHandlerArray &value)
 Assignment operator.
 
void AccumulateRunningSum ()
 Update the running sums for devices accumulated for the global error non-zero events/patterns.
 
void AccumulateRunningSum (const QwDataHandlerArray &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
 Update the running sums for devices accumulated for the global error non-zero events/patterns.
 
void AccumulateAllRunningSum (const QwDataHandlerArray &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
 Update the running sums for devices check only the error flags at the channel level. Only used for stability checks.
 
void CalculateRunningAverage ()
 Calculate the average for all good events.
 
void PrintErrorCounters () const
 Report the number of events failed due to HW and event cut failures.
 
void PrintValue () const
 Print value of all channels.
 
void WritePromptSummary (QwPromptSummary *ps, TString type)
 
void ProcessDataHandlerEntry ()
 
void FinishDataHandler ()
 
- Public Member Functions inherited from MQwPublishable< QwDataHandlerArray, VQwDataHandler >
 MQwPublishable ()
 Default constructor Initializes empty variable publishing maps.
 
 MQwPublishable (const MQwPublishable &source)
 Copy constructor Creates a new container with cleared publishing maps (variables are not copied).
 
virtual ~MQwPublishable ()
 Virtual destructor.
 
Bool_t RequestExternalValue (const TString &name, VQwHardwareChannel *value) const
 Retrieve a variable value from external sources by copying Searches for the named variable in external subsystem arrays and copies its value into the provided data element.
 
const VQwHardwareChannelRequestExternalPointer (const TString &name) const
 Retrieve a direct pointer to an external variable Searches for the named variable in external subsystem arrays and returns a direct pointer to the data element.
 
virtual const VQwHardwareChannelReturnInternalValue (const TString &name) const
 Retrieve an internal variable by name (pointer version) Searches for the named variable among published internal variables and returns a direct pointer to the data element.
 
Bool_t ReturnInternalValue (const TString &name, VQwHardwareChannel *value) const
 Retrieve an internal variable by name (copy version) Searches for the named variable among published internal variables and copies its value into the provided data element.
 
void ListPublishedValues () const
 List all published variables with descriptions Prints a summary of all currently published variables and their descriptions to the logging output for debugging and inspection purposes.
 
Bool_t PublishInternalValue (const TString name, const TString desc, const VQwDataHandler *subsys, const VQwHardwareChannel *element)
 Publish an internal variable from a subsystem Registers a variable from one of the contained subsystems in the publishing framework, making it available for external access by name.
 

Static Public Member Functions

static void DefineOptions (QwOptions &options)
 Define configuration options for global array.
 

Protected Types

enum  EDataHandlerArrayScope { kUnknownScope =-1 , kEventScope , kPatternScope }
 

Protected Member Functions

void SetPointer (QwHelicityPattern &helicitypattern)
 
void SetPointer (QwSubsystemArrayParity &detectors)
 
Bool_t ScopeMismatch (TString name)
 

Static Protected Member Functions

static Bool_t CanContain (VQwDataHandler *handler)
 Test whether this handler array can contain a particular handler.
 

Protected Attributes

QwHelicityPatternfHelicityPattern
 Pointer for the original data source.
 
QwSubsystemArrayParityfSubsystemArray
 
std::string fDataHandlersMapFile
 Filename of the global detector map.
 
EDataHandlerArrayScope fArrayScope
 
std::vector< std::string > fDataHandlersDisabledByName
 List of disabled types.
 
std::vector< std::string > fDataHandlersDisabledByType
 List of disabled names.
 
Bool_t fPrintRunningSum
 

Private Types

typedef std::vector< std::shared_ptr< VQwDataHandler > > HandlerPtrs
 

Private Member Functions

 QwDataHandlerArray ()
 Private default constructor.
 

Additional Inherited Members

- Data Fields inherited from MQwPublishable< QwDataHandlerArray, VQwDataHandler >
std::vector< std::vector< TString > > fPublishList
 

Detailed Description

Virtual base class for the parity handlers.

Virtual base class for the classes containing the event-based information from each parity handler. This will define the interfaces used in communicating with the CODA routines.

Definition at line 45 of file QwDataHandlerArray.h.

Member Typedef Documentation

◆ HandlerPtrs

typedef std::vector<std::shared_ptr<VQwDataHandler> > QwDataHandlerArray::HandlerPtrs
private

Definition at line 50 of file QwDataHandlerArray.h.

Member Enumeration Documentation

◆ EDataHandlerArrayScope

Enumerator
kUnknownScope 
kEventScope 
kPatternScope 

Definition at line 214 of file QwDataHandlerArray.h.

Constructor & Destructor Documentation

◆ QwDataHandlerArray() [1/4]

QwDataHandlerArray::QwDataHandlerArray ( )
private

Private default constructor.

References QwDataHandlerArray().

Referenced by AccumulateAllRunningSum(), AccumulateRunningSum(), AccumulateRunningSum(), operator=(), QwDataHandlerArray(), and QwDataHandlerArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ QwDataHandlerArray() [2/4]

QwDataHandlerArray::QwDataHandlerArray ( QwOptions & options,
QwHelicityPattern & helicitypattern,
const TString & run )

Constructor from helicity pattern with options.

Create a handler array based on the configuration option 'detectors'

Definition at line 20 of file QwDataHandlerArray.cc.

22{
23 ProcessOptions(options);
24 if (fDataHandlersMapFile != ""){
25 QwParameterFile mapfile(fDataHandlersMapFile.c_str());
26 QwMessage << "Loading handlers from " << fDataHandlersMapFile << "." << QwLog::endl;
27 LoadDataHandlersFromParameterFile(mapfile, helicitypattern, run);
28 }
29}
#define QwMessage
Predefined log drain for regular messages.
Definition QwLog.h:49
static std::ostream & endl(std::ostream &)
End of the line.
Definition QwLog.cc:297
QwSubsystemArrayParity * fSubsystemArray
QwHelicityPattern * fHelicityPattern
Pointer for the original data source.
std::string fDataHandlersMapFile
Filename of the global detector map.
void ProcessOptions(QwOptions &options)
Process configuration options for the datahandler array itself.
EDataHandlerArrayScope fArrayScope
void LoadDataHandlersFromParameterFile(QwParameterFile &mapfile, T &detectors, const TString &run)
Load data handlers from a parameter file.

References QwLog::endl(), fArrayScope, fDataHandlersMapFile, fHelicityPattern, fSubsystemArray, kPatternScope, LoadDataHandlersFromParameterFile(), ProcessOptions(), and QwMessage.

+ Here is the call graph for this function:

◆ QwDataHandlerArray() [3/4]

QwDataHandlerArray::QwDataHandlerArray ( QwOptions & options,
QwSubsystemArrayParity & detectors,
const TString & run )

Constructor from subsystem array with options.

Create a handler array based on the configuration option 'detectors'

Definition at line 34 of file QwDataHandlerArray.cc.

36{
37 ProcessOptions(options);
38 if (fDataHandlersMapFile != ""){
39 QwParameterFile mapfile(fDataHandlersMapFile.c_str());
40 QwMessage << "Loading handlers from " << fDataHandlersMapFile << "." << QwLog::endl;
41 LoadDataHandlersFromParameterFile(mapfile, detectors, run);
42 }
43}

References QwLog::endl(), fArrayScope, fDataHandlersMapFile, fHelicityPattern, fSubsystemArray, kEventScope, LoadDataHandlersFromParameterFile(), ProcessOptions(), and QwMessage.

+ Here is the call graph for this function:

◆ QwDataHandlerArray() [4/4]

QwDataHandlerArray::QwDataHandlerArray ( const QwDataHandlerArray & source)

Copy constructor by reference.

Copy constructor by reference

Parameters
sourceSource handler array

Definition at line 49 of file QwDataHandlerArray.cc.

50: std::vector<std::shared_ptr<VQwDataHandler>>(),
56{
57 // Make copies of all handlers rather than copying just the pointers
58 for (const_iterator handler = source.begin(); handler != source.end(); ++handler) {
59 this->push_back(handler->get()->Clone());
60 /*
61 // Instruct the handler to publish variables
62 if (this->back()->PublishInternalValues() == kFALSE) {
63 QwError << "Not all variables for " << this->back()->GetName()
64 << " could be published!" << QwLog::endl;
65 */
66 }
67}
void push_back(VQwDataHandler *handler)
Add the datahandler to this array.
std::vector< std::string > fDataHandlersDisabledByType
List of disabled names.
std::vector< std::string > fDataHandlersDisabledByName
List of disabled types.

References fDataHandlersDisabledByName, fDataHandlersDisabledByType, fDataHandlersMapFile, fHelicityPattern, fSubsystemArray, and QwDataHandlerArray().

+ Here is the call graph for this function:

◆ ~QwDataHandlerArray()

QwDataHandlerArray::~QwDataHandlerArray ( )
override

Default destructor.

Destructor.

Definition at line 74 of file QwDataHandlerArray.cc.

75{
76 // nothing
77}

Member Function Documentation

◆ AccumulateAllRunningSum()

void QwDataHandlerArray::AccumulateAllRunningSum ( const QwDataHandlerArray & value,
Int_t count = 0,
Int_t ErrorMask = 0xFFFFFFF )

Update the running sums for devices check only the error flags at the channel level. Only used for stability checks.

Definition at line 576 of file QwDataHandlerArray.cc.

577{
578 if (!value.empty()) {
579 if (this->size() == value.size()) {
580 for (size_t i = 0; i < value.size(); i++) {
581 if (value.at(i)==NULL || this->at(i)==NULL) {
582 // Either the value or the destination handler
583 // are null
584 } else {
585 VQwDataHandler *ptr1 =
586 dynamic_cast<VQwDataHandler*>(this->at(i).get());
587 VQwDataHandler *ptr2 = value.at(i).get();
588 if (typeid(*ptr1) == typeid(*ptr2)) {
589 ptr1->AccumulateRunningSum(*ptr2, count, ErrorMask);
590 } else {
591 QwError << "QwDataHandlerArray::AccumulateRunningSum here where types don't match" << QwLog::endl;
592 QwError << " typeid(ptr1)=" << typeid(ptr1).name()
593 << " but typeid(value.at(i)))=" << typeid(value.at(i)).name()
594 << QwLog::endl;
595 // DataHandlers don't match
596 }
597 }
598 }
599 } else {
600 // Array sizes don't match
601
602 }
603 } else {
604 // The value is empty
605 }
606}
#define QwError
Predefined log drain for errors.
Definition QwLog.h:39
void AccumulateRunningSum()

References VQwDataHandler::AccumulateRunningSum(), QwLog::endl(), QwDataHandlerArray(), and QwError.

+ Here is the call graph for this function:

◆ AccumulateRunningSum() [1/2]

void QwDataHandlerArray::AccumulateRunningSum ( )

Update the running sums for devices accumulated for the global error non-zero events/patterns.

References QwDataHandlerArray().

+ Here is the call graph for this function:

◆ AccumulateRunningSum() [2/2]

void QwDataHandlerArray::AccumulateRunningSum ( const QwDataHandlerArray & value,
Int_t count = 0,
Int_t ErrorMask = 0xFFFFFFF )

Update the running sums for devices accumulated for the global error non-zero events/patterns.

Definition at line 543 of file QwDataHandlerArray.cc.

544{
545 if (!value.empty()) {
546 if (this->size() == value.size()) {
547 for (size_t i = 0; i < value.size(); i++) {
548 if (value.at(i)==NULL || this->at(i)==NULL) {
549 // Either the value or the destination handler
550 // are null
551 } else {
552 VQwDataHandler *ptr1 =
553 dynamic_cast<VQwDataHandler*>(this->at(i).get());
554 VQwDataHandler *ptr2 = value.at(i).get();
555 if (typeid(*ptr1) == typeid(*ptr2)) {
556 ptr1->AccumulateRunningSum(*ptr2, count, ErrorMask);
557 } else {
558 QwError << "QwDataHandlerArray::AccumulateRunningSum here where types don't match" << QwLog::endl;
559 QwError << " typeid(ptr1)=" << typeid(ptr1).name()
560 << " but typeid(value.at(i)))=" << typeid(value.at(i)).name()
561 << QwLog::endl;
562 // DataHandlers don't match
563 }
564 }
565 }
566
567 } else {
568 // Array sizes don't match
569
570 }
571 } else {
572 // The value is empty
573 }
574}

References VQwDataHandler::AccumulateRunningSum(), QwLog::endl(), QwDataHandlerArray(), and QwError.

+ Here is the call graph for this function:

◆ CalculateRunningAverage()

void QwDataHandlerArray::CalculateRunningAverage ( )

Calculate the average for all good events.

Definition at line 532 of file QwDataHandlerArray.cc.

533{
534 if (!empty()) {
535 for (iterator handler = begin(); handler != end(); ++handler) {
536 VQwDataHandler* handler_parity = dynamic_cast<VQwDataHandler*>(handler->get());
537 handler_parity->CalculateRunningAverage();
538 }
539 }
540}
void CalculateRunningAverage()

References VQwDataHandler::CalculateRunningAverage().

+ Here is the call graph for this function:

◆ CanContain()

static Bool_t QwDataHandlerArray::CanContain ( VQwDataHandler * handler)
inlinestaticprotected

Test whether this handler array can contain a particular handler.

Definition at line 223 of file QwDataHandlerArray.h.

223 {
224 return (dynamic_cast<VQwDataHandler*>(handler) != 0);
225 };

Referenced by LoadDataHandlersFromParameterFile(), push_back(), and push_back().

+ Here is the caller graph for this function:

◆ ClearEventData()

void QwDataHandlerArray::ClearEventData ( )

Definition at line 328 of file QwDataHandlerArray.cc.

329{
330 if (!empty()) {
331 std::for_each(begin(), end(),
332 std::mem_fn(&VQwDataHandler::ClearEventData));
333 }
334}
virtual void ClearEventData()

References VQwDataHandler::ClearEventData().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConstructBranchAndVector()

void QwDataHandlerArray::ConstructBranchAndVector ( TTree * tree,
TString & prefix,
QwRootTreeBranchVector & values )

Construct a branch and vector for this handler with a prefix.

Definition at line 391 of file QwDataHandlerArray.cc.

392{
393 if (!empty()){
394 for (iterator handler = begin(); handler != end(); ++handler) {
395 VQwDataHandler* handler_parity = dynamic_cast<VQwDataHandler*>(handler->get());
396 handler_parity->ConstructBranchAndVector(tree,prefix,values);
397 }
398 }
399}
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)

References VQwDataHandler::ConstructBranchAndVector().

+ Here is the call graph for this function:

◆ ConstructHistograms() [1/3]

void QwDataHandlerArray::ConstructHistograms ( )
inline

Construct the histograms for this subsystem.

Definition at line 122 of file QwDataHandlerArray.h.

122 {
123 ConstructHistograms((TDirectory*) NULL);
124 };
void ConstructHistograms()
Construct the histograms for this subsystem.

References ConstructHistograms().

Referenced by ConstructHistograms(), and ConstructHistograms().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConstructHistograms() [2/3]

void QwDataHandlerArray::ConstructHistograms ( TDirectory * folder)
inline

Construct the histograms for this subsystem in a folder.

Definition at line 126 of file QwDataHandlerArray.h.

126 {
127 TString prefix = "";
128 ConstructHistograms(folder, prefix);
129 };

References ConstructHistograms().

+ Here is the call graph for this function:

◆ ConstructHistograms() [3/3]

void QwDataHandlerArray::ConstructHistograms ( TDirectory * folder,
TString & prefix )

Construct the histograms in a folder with a prefix.

Definition at line 413 of file QwDataHandlerArray.cc.

414{
415 if (!empty()) {
416 for (iterator subsys = begin(); subsys != end(); ++subsys){
417 (*subsys)->ConstructHistograms(folder,prefix);
418 }
419 }
420}

◆ ConstructNTupleFields()

void QwDataHandlerArray::ConstructNTupleFields ( QwRootFile * treerootfile,
const std::string & treeprefix = "",
const std::string & branchprefix = "" )

RNTuple methods.

Definition at line 366 of file QwDataHandlerArray.cc.

370{
371 if (!empty()){
372 for (iterator handler = begin(); handler != end(); ++handler) {
373 handler->get()->ConstructNTupleFields(treerootfile, treeprefix, branchprefix);
374 }
375 }
376}

Referenced by main().

+ Here is the caller graph for this function:

◆ ConstructTreeBranches()

void QwDataHandlerArray::ConstructTreeBranches ( QwRootFile * treerootfile,
const std::string & treeprefix = "",
const std::string & branchprefix = "" )

Definition at line 345 of file QwDataHandlerArray.cc.

349{
350 if (!empty()){
351 for (iterator handler = begin(); handler != end(); ++handler) {
352 handler->get()->ConstructTreeBranches(treerootfile, treeprefix, branchprefix);
353 }
354 }
355}

Referenced by main().

+ Here is the caller graph for this function:

◆ DefineOptions()

void QwDataHandlerArray::DefineOptions ( QwOptions & options)
static

Define configuration options for global array.

Define configuration options for global array

Parameters
optionsOptions

Definition at line 231 of file QwDataHandlerArray.cc.

232{
233 options.AddOptions()("datahandlers",
234 po::value<std::string>(),
235 "map file with datahandlers to include");
236
237 // Versions of boost::program_options below 1.39.0 have a bug in multitoken processing
238#if BOOST_VERSION < 103900
239 options.AddOptions()("DataHandler.disable-by-type",
240 po::value<std::vector <std::string> >(),
241 "handler types to disable");
242 options.AddOptions()("DataHandler.disable-by-name",
243 po::value<std::vector <std::string> >(),
244 "handler names to disable");
245#else // BOOST_VERSION >= 103900
246 options.AddOptions()("DataHandler.disable-by-type",
247 po::value<std::vector <std::string> >()->multitoken(),
248 "handler types to disable");
249 options.AddOptions()("DataHandler.disable-by-name",
250 po::value<std::vector <std::string> >()->multitoken(),
251 "handler names to disable");
252#endif // BOOST_VERSION
253}
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Definition QwOptions.h:170

References QwOptions::AddOptions().

Referenced by DefineOptionsParity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FillDB()

void QwDataHandlerArray::FillDB ( QwParityDB * db,
TString type )

Fill the database.

◆ FillHistograms()

void QwDataHandlerArray::FillHistograms ( )

Fill the histograms.

Definition at line 422 of file QwDataHandlerArray.cc.

423{
424 if (!empty())
425 std::for_each(begin(), end(), std::mem_fn(&VQwDataHandler::FillHistograms));
426}
virtual void FillHistograms()
Fill the histograms.

References VQwDataHandler::FillHistograms().

+ Here is the call graph for this function:

◆ FillNTupleFields()

void QwDataHandlerArray::FillNTupleFields ( QwRootFile * treerootfile)

Definition at line 378 of file QwDataHandlerArray.cc.

379{
380 if (!empty()){
381 for (iterator handler = begin(); handler != end(); ++handler) {
382 handler->get()->FillNTupleFields(treerootfile);
383 }
384 }
385}

Referenced by main().

+ Here is the caller graph for this function:

◆ FillTreeBranches()

void QwDataHandlerArray::FillTreeBranches ( QwRootFile * treerootfile)

Definition at line 357 of file QwDataHandlerArray.cc.

358{
359 if (!empty()){
360 for (iterator handler = begin(); handler != end(); ++handler) {
361 handler->get()->FillTreeBranches(treerootfile);
362 }
363 }
364}

Referenced by main().

+ Here is the caller graph for this function:

◆ FillTreeVector()

void QwDataHandlerArray::FillTreeVector ( QwRootTreeBranchVector & values) const

Fill the vector for this handler.

Definition at line 401 of file QwDataHandlerArray.cc.

402{
403 if (!empty()){
404 for (const_iterator handler = begin(); handler != end(); ++handler) {
405 VQwDataHandler* handler_parity = dynamic_cast<VQwDataHandler*>(handler->get());
406 handler_parity->FillTreeVector(values);
407 }
408 }
409}
void FillTreeVector(QwRootTreeBranchVector &values) const

References VQwDataHandler::FillTreeVector().

+ Here is the call graph for this function:

◆ FinishDataHandler()

void QwDataHandlerArray::FinishDataHandler ( )

Definition at line 715 of file QwDataHandlerArray.cc.

716{
717 if (!empty()) {
718 for(iterator handler = begin(); handler != end(); ++handler){
719 (*handler)->FinishDataHandler();
720 }
721 }
722}

Referenced by main().

+ Here is the caller graph for this function:

◆ GetDataHandlerByName()

VQwDataHandler * QwDataHandlerArray::GetDataHandlerByName ( const TString & name)

Get the handler with the specified name.

Get the handler in this array with the specified name

Parameters
nameName of the handler
Returns
Pointer to the handler

Definition at line 280 of file QwDataHandlerArray.cc.

281{
282 VQwDataHandler* tmp = NULL;
283 if (!empty()) {
284 // Loop over the handlers
285 for (const_iterator handler = begin(); handler != end(); ++handler) {
286 // Check the name of this handler
287 // std::cout<<"QwDataHandlerArray::GetDataHandlerByName available name=="<<(*handler)->GetName()<<"== to be compared to =="<<name<<"==\n";
288 if ((*handler)->GetName() == name) {
289 tmp = (*handler).get();
290 //std::cout<<"QwDataHandlerArray::GetDataHandlerByName found a matching name \n";
291 } else {
292 // nothing
293 }
294 }
295 }
296 return tmp;
297}

Referenced by push_back(), and push_back().

+ Here is the caller graph for this function:

◆ GetDataHandlerByType()

std::vector< VQwDataHandler * > QwDataHandlerArray::GetDataHandlerByType ( const std::string & type)

Get the list of handlers in this array of the specified type

Parameters
typeType of the handler
Returns
Vector of handlers

Definition at line 305 of file QwDataHandlerArray.cc.

306{
307 // Vector of handler pointers
308 std::vector<VQwDataHandler*> handler_list;
309
310 // If this array is not empty
311 if (!empty()) {
312
313 // Loop over the handlers
314 for (const_iterator handler = begin(); handler != end(); ++handler) {
315
316 // Test to see if the handler inherits from the required type
317 if (VQwDataHandlerFactory::InheritsFrom((*handler).get(),type)) {
318 handler_list.push_back((*handler).get());
319 }
320
321 } // end of loop over handlers
322
323 } // end of if !empty()
324
325 return handler_list;
326}

◆ LoadDataHandlersFromParameterFile()

template<class T>
void QwDataHandlerArray::LoadDataHandlersFromParameterFile ( QwParameterFile & mapfile,
T & detectors,
const TString & run )

Load data handlers from a parameter file.

Parses the map file and constructs/initializes handlers, connecting them to the provided source container.

Template Parameters
TSource type (QwHelicityPattern or QwSubsystemArrayParity).
Parameters
mapfileParameter file describing handlers and settings.
detectorsSource object to connect handlers to.
runRun label used for per-run configuration.

Definition at line 86 of file QwDataHandlerArray.cc.

90{
91 // Set pointer to this object
92 SetPointer(detectors);
93
94 // This is how this should work
95 std::unique_ptr<QwParameterFile> preamble;
96 preamble = mapfile.ReadSectionPreamble();
97 // Process preamble
98 QwVerbose << "Preamble:" << QwLog::endl;
99 QwVerbose << *preamble << QwLog::endl;
100 if (preamble) preamble.reset();
101
102 std::unique_ptr<QwParameterFile> section;
103 std::string section_name;
104 while ((section = mapfile.ReadNextSection(section_name))) {
105
106 // Debugging output of configuration section
107 QwVerbose << "[" << section_name << "]" << QwLog::endl;
108 QwVerbose << *section << QwLog::endl;
109
110 // Determine type and name of handler
111 std::string handler_type = section_name;
112 std::string handler_name;
113 std::string handler_scope;
114 if (! section->FileHasVariablePair("=","name",handler_name)) {
115 QwError << "No name defined in section for handler " << handler_type << "." << QwLog::endl;
116 continue;
117 }
118 if (section->FileHasVariablePair("=","scope",handler_scope)) {
119 if (ScopeMismatch(handler_scope)) continue;
120 } else {
121 // Assume the scope of a handler without a scope specifier is
122 // "pattern".
123 if (fArrayScope != kPatternScope) continue;
124 }
125
126 // If handler type is explicitly disabled
127 bool disabled_by_type = false;
128 for (size_t i = 0; i < fDataHandlersDisabledByType.size(); i++)
129 if (handler_type == fDataHandlersDisabledByType.at(i))
130 disabled_by_type = true;
131 if (disabled_by_type) {
132 QwWarning << "DataHandler of type " << handler_type << " disabled." << QwLog::endl;
133 continue;
134 }
135
136 // If handler name is explicitly disabled
137 bool disabled_by_name = false;
138 for (size_t i = 0; i < fDataHandlersDisabledByName.size(); i++)
139 if (handler_name == fDataHandlersDisabledByName.at(i))
140 disabled_by_name = true;
141 if (disabled_by_name) {
142 QwWarning << "DataHandler with name " << handler_name << " disabled." << QwLog::endl;
143 continue;
144 }
145
146 // Create handler
147 QwMessage << "Creating handler of type " << handler_type << " "
148 << "with name " << handler_name << "." << QwLog::endl;
149 VQwDataHandler* handler = 0;
150
151 try {
152 handler =
153 VQwDataHandlerFactory::Create(handler_type, handler_name);
154 } catch (QwException_TypeUnknown&) {
155 QwError << "No support for handlers of type " << handler_type << "." << QwLog::endl;
156 // Fall-through to next error for more the psychological effect of many warnings
157 }
158 if (! handler) {
159 QwError << "Could not create handler " << handler_type << "." << QwLog::endl;
160 continue;
161 }
162
163 // If this handler cannot be stored in this array
164 if (! CanContain(handler)) {
165 QwMessage << "DataHandler " << handler_name << " cannot be stored in this "
166 << "handler array." << QwLog::endl;
167 QwMessage << "Deleting handler " << handler_name << " again" << QwLog::endl;
168 delete handler; handler = 0;
169 continue;
170 }
171
172 // Pass detector maps
173 handler->SetParent(this);
174 handler->SetRunLabel(run);
175 handler->SetPointer(&detectors);
176 handler->ParseConfigFile(*section);
177 handler->LoadChannelMap();
178 handler->ConnectChannels(detectors);
179 handler->InitRunningSum();
180
181 // Add to array
182 this->push_back(handler);
183 /*
184 // Instruct the handler to publish variables
185 if (handler->PublishInternalValues() == kFALSE) {
186 QwError << "Not all variables for " << handler->GetName()
187 << " could be published!" << QwLog::endl;
188 }
189 */
190 }
191}
#define QwVerbose
Predefined log drain for verbose messages.
Definition QwLog.h:54
#define QwWarning
Predefined log drain for warnings.
Definition QwLog.h:44
void SetParent(U *parent)
Set the parent container for this child object.
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)
void SetPointer(QwHelicityPattern &helicitypattern)
Bool_t ScopeMismatch(TString name)
static Bool_t CanContain(VQwDataHandler *handler)
Test whether this handler array can contain a particular handler.
virtual void ParseConfigFile(QwParameterFile &file)
void SetRunLabel(TString x)
void SetPointer(QwHelicityPattern *ptr)
virtual Int_t ConnectChannels(QwSubsystemArrayParity &, QwSubsystemArrayParity &asym, QwSubsystemArrayParity &diff)

References CanContain(), VQwDataHandler::ConnectChannels(), QwLog::endl(), fArrayScope, fDataHandlersDisabledByName, fDataHandlersDisabledByType, VQwDataHandler::InitRunningSum(), kPatternScope, VQwDataHandler::LoadChannelMap(), VQwDataHandler::ParseConfigFile(), push_back(), QwError, QwMessage, QwVerbose, QwWarning, QwParameterFile::ReadNextSection(), QwParameterFile::ReadSectionPreamble(), ScopeMismatch(), MQwPublishable_child< U, T >::SetParent(), SetPointer(), VQwDataHandler::SetPointer(), and VQwDataHandler::SetRunLabel().

Referenced by QwDataHandlerArray(), and QwDataHandlerArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

QwDataHandlerArray & QwDataHandlerArray::operator= ( const QwDataHandlerArray & source)

Assignment operator.

Assignment operator

Parameters
sourceDataHandler array to assign to this array
Returns
This handler array after assignment

Definition at line 469 of file QwDataHandlerArray.cc.

470{
471 Bool_t localdebug=kFALSE;
472 if(localdebug) std::cout<<"QwDataHandlerArray::operator= \n";
473 if (!source.empty()){
474 if (this->size() == source.size()){
475 for(size_t i=0;i<source.size();i++){
476 if (source.at(i)==NULL || this->at(i)==NULL){
477 // Either the source or the destination handler
478 // are null
479 } else {
480 VQwDataHandler *ptr1 =
481 dynamic_cast<VQwDataHandler*>(this->at(i).get());
482 VQwDataHandler *ptr2 = source.at(i).get();
483 if (typeid(*ptr1)==typeid(*ptr2)){
484 if(localdebug) std::cout<<" here in QwDataHandlerArray::operator= types mach \n";
485 *(ptr1) = *(source.at(i).get());
486 } else {
487 // DataHandlers don't match
488 QwError << " QwDataHandlerArray::operator= types do not mach" << QwLog::endl;
489 QwError << " typeid(*ptr1)=" << typeid(*ptr1).name()
490 << " but typeid(*ptr2)=" << typeid(*ptr2).name()
491 << QwLog::endl;
492 }
493 }
494 }
495 } else {
496 // Array sizes don't match
497 }
498 } else {
499 // The source is empty
500 }
501 return *this;
502}

References QwLog::endl(), QwDataHandlerArray(), and QwError.

+ Here is the call graph for this function:

◆ PrintErrorCounters()

void QwDataHandlerArray::PrintErrorCounters ( ) const

Report the number of events failed due to HW and event cut failures.

◆ PrintValue()

void QwDataHandlerArray::PrintValue ( ) const

Print value of all channels.

Definition at line 517 of file QwDataHandlerArray.cc.

518{
519 if (!empty()) {
520 for (const_iterator handler = begin(); handler != end(); ++handler) {
521 VQwDataHandler* handler_parity = dynamic_cast<VQwDataHandler*>(handler->get());
522 handler_parity->PrintValue();
523 }
524 }
525}
void PrintValue() const

References VQwDataHandler::PrintValue().

+ Here is the call graph for this function:

◆ ProcessDataHandlerEntry()

void QwDataHandlerArray::ProcessDataHandlerEntry ( )

Definition at line 705 of file QwDataHandlerArray.cc.

706{
707 if (!empty()) {
708 for(iterator handler = begin(); handler != end(); ++handler){
709 (*handler)->ProcessData();
710 (*handler)->AccumulateRunningSum();
711 }
712 }
713}

Referenced by main().

+ Here is the caller graph for this function:

◆ ProcessEvent()

void QwDataHandlerArray::ProcessEvent ( )

Definition at line 338 of file QwDataHandlerArray.cc.

339{
340 if (!empty()){
341 std::for_each(begin(), end(), std::mem_fn(&VQwDataHandler::ProcessData));
342 }
343}
virtual void ProcessData()

References VQwDataHandler::ProcessData().

+ Here is the call graph for this function:

◆ ProcessOptions()

void QwDataHandlerArray::ProcessOptions ( QwOptions & options)

Process configuration options for the datahandler array itself.

Handle configuration options for the handler array itself

Parameters
optionsOptions

Definition at line 260 of file QwDataHandlerArray.cc.

261{
262 // Filename to use for handler creation (single filename could be expanded
263 // to a list)
264 if (options.HasValue("datahandlers")){
265 fDataHandlersMapFile = options.GetValue<std::string>("datahandlers");
266 }
267 // DataHandlers to disable
268 fDataHandlersDisabledByName = options.GetValueVector<std::string>("DataHandler.disable-by-name");
269 fDataHandlersDisabledByType = options.GetValueVector<std::string>("DataHandler.disable-by-type");
270
271 // Get the globally defined print running sum flag
272 fPrintRunningSum = options.GetValue<bool>("print-runningsum");
273}
std::vector< T > GetValueVector(const std::string &key)
Get a list of templated values.
Definition QwOptions.h:249
T GetValue(const std::string &key)
Get a templated value.
Definition QwOptions.h:236
bool HasValue(const std::string &key)
Has this key been defined.
Definition QwOptions.h:229

References fDataHandlersDisabledByName, fDataHandlersDisabledByType, fDataHandlersMapFile, fPrintRunningSum, QwOptions::GetValue(), QwOptions::GetValueVector(), and QwOptions::HasValue().

Referenced by QwDataHandlerArray(), and QwDataHandlerArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ push_back() [1/2]

void QwDataHandlerArray::push_back ( std::shared_ptr< VQwDataHandler > handler)

Add the handler to this array. Do nothing if the handler is null or if there is already a handler with that name in the array.

Parameters
handlerDataHandler to add to the array

Definition at line 627 of file QwDataHandlerArray.cc.

628{
629
630 if (handler.get() == NULL) {
631 QwError << "QwDataHandlerArray::push_back(): NULL handler"
632 << QwLog::endl;
633 // This is an empty handler...
634 // Do nothing for now.
635
636 } else if (!this->empty() && GetDataHandlerByName(handler->GetName())){
637 // There is already a handler with this name!
638 QwError << "QwDataHandlerArray::push_back(): handler " << handler->GetName()
639 << " already exists" << QwLog::endl;
640
641 } else if (!CanContain(handler.get())) {
642 // There is no support for this type of handler
643 QwError << "QwDataHandlerArray::push_back(): handler " << handler->GetName()
644 << " is not supported by this handler array" << QwLog::endl;
645
646 } else {
647 std::shared_ptr<VQwDataHandler> handler_tmp(handler);
648 HandlerPtrs::push_back(handler_tmp);
649
650/*
651 // Set the parent of the handler to this array
652 handler_tmp->SetParent(this);
653
654
655 // Instruct the handler to publish variables
656 if (handler_tmp->PublishInternalValues() == kFALSE) {
657 QwError << "Not all variables for " << handler_tmp->GetName()
658 << " could be published!" << QwLog::endl;
659 }
660*/
661 }
662}
VQwDataHandler * GetDataHandlerByName(const TString &name)
Get the handler with the specified name.

References CanContain(), QwLog::endl(), GetDataHandlerByName(), and QwError.

+ Here is the call graph for this function:

◆ push_back() [2/2]

void QwDataHandlerArray::push_back ( VQwDataHandler * handler)

Add the datahandler to this array.

Add the handler to this array. Do nothing if the handler is null or if there is already a handler with that name in the array.

Parameters
handlerDataHandler to add to the array

Definition at line 199 of file QwDataHandlerArray.cc.

200{
201 if (handler == NULL) {
202 QwError << "QwDataHandlerArray::push_back(): NULL handler"
203 << QwLog::endl;
204 // This is an empty handler...
205 // Do nothing for now.
206
207 } else if (!this->empty() && GetDataHandlerByName(handler->GetName())){
208 // There is already a handler with this name!
209 QwError << "QwDataHandlerArray::push_back(): handler " << handler->GetName()
210 << " already exists" << QwLog::endl;
211
212 } else if (!CanContain(handler)) {
213 // There is no support for this type of handler
214 QwError << "QwDataHandlerArray::push_back(): handler " << handler->GetName()
215 << " is not supported by this handler array" << QwLog::endl;
216
217 } else {
218 std::shared_ptr<VQwDataHandler> handler_tmp(handler);
219 HandlerPtrs::push_back(handler_tmp);
220
221 // Set the parent of the handler to this array
222 // handler_tmp->SetParent(this);
223
224 }
225}
TString GetName()

References CanContain(), QwLog::endl(), GetDataHandlerByName(), VQwDataHandler::GetName(), and QwError.

Referenced by LoadDataHandlersFromParameterFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ScopeMismatch()

Bool_t QwDataHandlerArray::ScopeMismatch ( TString name)
inlineprotected

Definition at line 207 of file QwDataHandlerArray.h.

207 {
208 name.ToLower();
210 if (name=="event") tmpscope = kEventScope;
211 if (name=="pattern") tmpscope = kPatternScope;
212 return (fArrayScope != tmpscope);
213 }

References fArrayScope, kEventScope, kPatternScope, and kUnknownScope.

Referenced by LoadDataHandlersFromParameterFile().

+ Here is the caller graph for this function:

◆ SetPointer() [1/2]

void QwDataHandlerArray::SetPointer ( QwHelicityPattern & helicitypattern)
inlineprotected

Definition at line 193 of file QwDataHandlerArray.h.

193 {
194 fHelicityPattern = &helicitypattern;
195 }

References fHelicityPattern.

Referenced by LoadDataHandlersFromParameterFile().

+ Here is the caller graph for this function:

◆ SetPointer() [2/2]

void QwDataHandlerArray::SetPointer ( QwSubsystemArrayParity & detectors)
inlineprotected

Definition at line 196 of file QwDataHandlerArray.h.

196 {
197 fSubsystemArray = &detectors;
198 }

References fSubsystemArray.

◆ UpdateBurstCounter()

void QwDataHandlerArray::UpdateBurstCounter ( Short_t burstcounter)
inline

Definition at line 142 of file QwDataHandlerArray.h.

143 {
144 if (!empty()) {
145 for(iterator handler = begin(); handler != end(); ++handler){
146 (*handler)->UpdateBurstCounter(burstcounter);
147 }
148 }
149 }

Referenced by main().

+ Here is the caller graph for this function:

◆ WritePromptSummary()

void QwDataHandlerArray::WritePromptSummary ( QwPromptSummary * ps,
TString type )

Definition at line 451 of file QwDataHandlerArray.cc.

452{
453 if (!empty()){
454 for (const_iterator handler = begin(); handler != end(); ++handler) {
455 VQwDataHandler* handler_parity = dynamic_cast<VQwDataHandler*>(handler->get());
456 handler_parity->WritePromptSummary(ps, type);
457 }
458 }
459}
void WritePromptSummary(QwPromptSummary *ps, TString type)

References VQwDataHandler::WritePromptSummary().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ fArrayScope

EDataHandlerArrayScope QwDataHandlerArray::fArrayScope
protected

◆ fDataHandlersDisabledByName

std::vector<std::string> QwDataHandlerArray::fDataHandlersDisabledByName
protected

List of disabled types.

Definition at line 217 of file QwDataHandlerArray.h.

Referenced by LoadDataHandlersFromParameterFile(), ProcessOptions(), and QwDataHandlerArray().

◆ fDataHandlersDisabledByType

std::vector<std::string> QwDataHandlerArray::fDataHandlersDisabledByType
protected

List of disabled names.

Definition at line 218 of file QwDataHandlerArray.h.

Referenced by LoadDataHandlersFromParameterFile(), ProcessOptions(), and QwDataHandlerArray().

◆ fDataHandlersMapFile

std::string QwDataHandlerArray::fDataHandlersMapFile
protected

Filename of the global detector map.

Definition at line 205 of file QwDataHandlerArray.h.

Referenced by ProcessOptions(), QwDataHandlerArray(), QwDataHandlerArray(), and QwDataHandlerArray().

◆ fHelicityPattern

QwHelicityPattern* QwDataHandlerArray::fHelicityPattern
protected

Pointer for the original data source.

Definition at line 201 of file QwDataHandlerArray.h.

Referenced by QwDataHandlerArray(), QwDataHandlerArray(), QwDataHandlerArray(), and SetPointer().

◆ fPrintRunningSum

Bool_t QwDataHandlerArray::fPrintRunningSum
protected

Definition at line 220 of file QwDataHandlerArray.h.

Referenced by ProcessOptions().

◆ fSubsystemArray

QwSubsystemArrayParity* QwDataHandlerArray::fSubsystemArray
protected

The documentation for this class was generated from the following files: