19#ifdef HAS_RNTUPLE_SUPPORT
21#include <ROOT/RNTupleModel.hxx>
22#include <ROOT/RNTupleWriter.hxx>
30#ifdef __USE_DATABASE__
76 fRunningsum = source.fRunningsum->Clone();
86 for (
size_t i = 0; i <
fOutputVar.size(); ++i) {
116 vector< const VQwHardwareChannel* > &ivs,
117 vector< Double_t > &sens) {
136 for (
size_t iv = 0; iv < ivs.size(); iv++) {
137 output->
ScaledAdd(sens.at(iv), ivs.at(iv));
186 QwWarning <<
"QwCombiner::ConnectChannels(QwSubsystemArrayParity& asym, QwSubsystemArrayParity& diff): Dependent variable, "
188 <<
", for asym/diff processing does not have proper type, type=="
194 QwWarning <<
"VQwDataHandler::ConnectChannels(QwSubsystemArrayParity& asym, QwSubsystemArrayParity& diff): Dependent variable, "
196 <<
", was not found (fullname=="
215 else if(dv_ptr!=NULL) {
224 if(new_ptr != NULL) {
240 pair<EQwHandleType,string> type_name;
241 size_t len = variable.length();
244 if (pos1 == string::npos) {
246 type_name.second = variable;
248 string type = variable.substr(0,pos1);
249 string name = variable.substr(pos2,len-pos2);
252 else if (type ==
"diff")
254 else if (type ==
"yield")
256 else if (type ==
"mps")
260 type_name.second = name;
272 const std::string& treeprefix,
273 const std::string& branchprefix)
277 QwWarning <<
"No data handler output; not creating tree "
281 TString tmp_branchprefix(branchprefix.c_str());
303 for (
size_t i = 0; i <
fOutputVar.size(); ++i) {
304 fOutputVar.at(i)->ConstructBranchAndVector(tree, prefix, values);
322 const std::string& treeprefix,
323 const std::string& branchprefix)
327 QwWarning <<
"No data handler output; not creating RNTuple "
331 TString tmp_branchprefix(branchprefix.c_str());
339#ifdef HAS_RNTUPLE_SUPPORT
353#ifdef HAS_RNTUPLE_SUPPORT
357 treerootfile->FillNTupleFields(*
this);
370 for (
size_t i = 0; i <
fOutputVar.size(); ++i) {
376#ifdef HAS_RNTUPLE_SUPPORT
377void VQwDataHandler::ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
379 for (
size_t i = 0; i <
fOutputVar.size(); ++i) {
380 fOutputVar.at(i)->ConstructNTupleAndVector(model, prefix, values, fieldPtrs);
384void VQwDataHandler::FillNTupleVector(std::vector<Double_t>& values)
const
387 for (
size_t i = 0; i <
fOutputVar.size(); ++i) {
414 for (
size_t i = 0; i <
fOutputVar.size(); i++){
423 for(
size_t i = 0; i <
fRunningsum->fOutputVar.size(); i++) {
425 fRunningsum->fOutputVar[i]->CalculateRunningAverage();
433 for(
size_t i = 0; i <
fOutputVar.size(); i++) {
441 for(
size_t i = 0; i <
fOutputVar.size(); i++) {
454 Bool_t status = kTRUE;
463 device_type.ToLower();
464 device_prop.ToLower();
469 if(device_name.CompareTo(
fOutputVar.at(i)->GetElementName())==0){
474 if (tmp_channel == NULL) {
475 QwError <<
"VQwDataHandler::PublishInternalValues(): " << publish_name
479 QwDebug <<
"VQwDataHandler::PublishInternalValues(): " << publish_name
489 Bool_t status = kFALSE;
491 if(device_name.CompareTo(
fOutputVar.at(i)->GetElementName())==0){
498 QwDebug <<
"VQwDataHandler::PublishByRequest: Failed to publish channel name: " << device_name <<
QwLog::endl;
504 Bool_t local_print_flag =
false;
505 Bool_t local_add_element= type.Contains(
"asy");
508 if(local_print_flag){
509 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
511 QwMessage <<
" --------------------------------------------------------------- " <<
QwLog::endl;
515 TString element_name =
"";
516 Double_t element_value = 0.0;
517 Double_t element_value_err = 0.0;
518 Double_t element_value_width = 0.0;
521 Bool_t local_add_these_elements=
false;
523 for (
size_t i = 0; i <
fOutputVar.size(); i++)
525 element_name =
fOutputVar[i]->GetElementName();
528 element_value_err = 0.0;
529 element_value_width = 0.0;
532 local_add_these_elements=element_name.Contains(
"dd")||element_name.Contains(
"da");
534 if(local_add_these_elements && local_add_element){
540 if(local_ps_element) {
541 element_value = tmp_channel->
GetValue();
545 local_ps_element->
Set(type, element_value, element_value_err, element_value_width);
548 if( local_print_flag && local_ps_element) {
549 printf(
"Type %12s, Element %32s, value %12.4e error %8.4e width %12.4e\n", type.Data(), element_name.Data(), element_value, element_value_err, element_value_width);
556#ifdef __USE_DATABASE__
557void VQwDataHandler::FillDB(QwParityDB *db, TString datatype)
560 Bool_t local_print_flag = kTRUE;
562 UInt_t analysis_id = db->GetAnalysisID();
564 TString measurement_type;
567 std::vector<QwDBInterface> interface;
569 std::vector<QwParitySchema::beam_row> beamlist;
570 std::vector<QwParitySchema::md_data_row> mdlist;
571 std::vector<QwParitySchema::lumi_data_row> lumilist;
576 for(
size_t i = 0; i <
fOutputVar.size(); i++) {
579 for(
size_t j=0; j<interface.size(); j++) {
580 interface.at(j).SetAnalysisID( analysis_id ) ;
581 interface.at(j).SetMeasurementTypeID( measurement_type );
582 tabletype = interface.at(j).SetDetectorID( db );
584 TString tmp_name = interface.at(j).GetDeviceName();
585 tmp_name.Remove(0,5);
586 interface.at(j).SetDetectorName(tmp_name);
587 tabletype = interface.at(j).SetDetectorID( db );
590 interface.at(j).AddThisEntryToList( beamlist );
592 interface.at(j).AddThisEntryToList( mdlist );
594 interface.at(j).AddThisEntryToList( lumilist );
596 QwError <<
"QwCombiner::FillDB: Unrecognized detector name: "
599 interface.at(j).PrintStatus( local_print_flag);
605 auto c = db->GetScopedConnection();
608 if( beamlist.size() ) {
609 for (
const auto& entry: beamlist) {
610 c->QueryExecute(entry.insert_into());
613 QwMessage <<
"QwCombiner::FillDB :: This is the case when the beamlist contains nothing for type="<< measurement_type.Data()
616 if( mdlist.size() ) {
617 for (
const auto& entry: mdlist) {
618 c->QueryExecute(entry.insert_into());
621 QwMessage <<
"QwCombiner::FillDB :: This is the case when the mdlist contains nothing for type="<< measurement_type.Data()
624 if( lumilist.size() ) {
625 for (
const auto& entry: lumilist) {
626 c->QueryExecute(entry.insert_into());
629 QwMessage <<
"QwCombiner::FillDB :: This is the case when the lumilist contains nothing for type="<< measurement_type.Data()
#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.
Parameter file parsing and management.
Prompt summary data management.
Decoding and management for VQWK ADC channels (6x32-bit datawords)
Virtual base class for data handlers accessing multiple subsystems.
Bool_t PublishInternalValue(const TString name, const TString desc, const VQwHardwareChannel *element) const
const VQwHardwareChannel * RequestExternalPointer(const TString &name) const
const VQwHardwareChannel * RequestExternalPointer(const TString &name) const
Retrieve a direct pointer to an external variable Searches for the named variable in external subsyst...
static TString DetermineMeasurementTypeID(TString type, TString suffix="", Bool_t forcediffs=kFALSE)
static std::ostream & endl(std::ostream &)
End of the line.
Configuration file parser with flexible tokenization and search capabilities.
Bool_t PopValue(const std::string keyname, T &retvalue)
void Set(TString type, const Double_t a, const Double_t a_err, const Double_t a_width)
void AddElement(PromptSummaryElement *in)
PromptSummaryElement * GetElementByName(TString name)
A helper class to manage a vector of branch entries for ROOT trees.
A wrapper class for a ROOT file or memory mapped file.
Int_t FillTree(const std::string &name)
Fill the tree with name.
void ConstructTreeBranches(const std::string &name, const std::string &desc, T &object, const std::string &prefix="")
Construct the tree branches of a generic object.
void FillTreeBranches(const std::string &name, const T &object)
Fill the tree branches of a generic object by tree name.
Concrete hardware channel for VQWK ADC modules (6x32-bit words)
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
virtual const TString & GetElementName() const
Get the name of this element.
void SetElementName(const TString &name)
Set the name of this element.
Abstract base for concrete hardware channels implementing dual-operator pattern.
Double_t GetValueError() const
virtual void ScaledAdd(Double_t scale, const VQwHardwareChannel *value)=0
virtual VQwHardwareChannel * Clone() const
void ClearEventData() override
Clear the event data in this element.
Double_t GetValueWidth() const
Double_t GetValue() const
void AssignValueFrom(const VQwDataElement *valueptr) override=0
Subsystem array container specialized for parity analysis with asymmetry calculations.
const UInt_t * GetEventcutErrorFlagPointer() const
void CalcOneOutput(const VQwHardwareChannel *dv, VQwHardwareChannel *output, std::vector< const VQwHardwareChannel * > &ivs, std::vector< Double_t > &sens)
virtual void ProcessData()
QwSubsystemArrayParity * fSubsystemArray
Single event pointer.
void FillTreeVector(QwRootTreeBranchVector &values) const
std::vector< std::string > fDependentFull
void AccumulateRunningSum()
void SetEventcutErrorFlagPointer(const UInt_t *errorflagptr)
void WritePromptSummary(QwPromptSummary *ps, TString type)
std::vector< std::vector< TString > > fPublishList
Bool_t PublishInternalValues() const override
Publish all variables of the subsystem.
virtual void ConstructTreeBranches(QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="")
std::vector< Double_t > fDependentValues
virtual void ParseConfigFile(QwParameterFile &file)
virtual void ClearEventData()
std::vector< const VQwHardwareChannel * > fDependentVar
~VQwDataHandler() override
void CalculateRunningAverage()
virtual void FillTreeBranches(QwRootFile *treerootfile)
VQwDataHandler(const TString &name)
VQwDataHandler * fRunningsum
const UInt_t * fErrorFlagPtr
Error flag pointer.
virtual void FillNTupleFields(QwRootFile *treerootfile)
std::string ParseSeparator
virtual void ConstructNTupleFields(QwRootFile *treerootfile, const std::string &treeprefix="", const std::string &branchprefix="")
RNTuple methods.
Short_t fBurstCounter
When a datahandler array is processed, handlers with lower priority will be processed before handlers...
std::vector< VQwHardwareChannel * > fOutputVar
Bool_t PublishByRequest(TString device_name) override
Try to publish an internal variable matching the submitted name.
Bool_t fRunningsumFillsTree
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
std::pair< EQwHandleType, std::string > ParseHandledVariable(const std::string &variable)
std::vector< EQwHandleType > fDependentType
QwHelicityPattern * fHelicityPattern
Helicity pattern pointer.
std::vector< Double_t > fOutputValues
std::vector< std::string > fDependentName
virtual Int_t ConnectChannels(QwSubsystemArrayParity &, QwSubsystemArrayParity &asym, QwSubsystemArrayParity &diff)