19#ifdef HAS_RNTUPLE_SUPPORT
20#include <ROOT/RNTupleModel.hxx>
21#include <ROOT/RNTupleWriter.hxx>
25#ifdef __USE_DATABASE__
55 if(channel.EndsWith(
subelement[i],TString::kIgnoreCase)){
58 size_t detnamesize = channel.Sizeof() - subname.Sizeof();
59 detname = channel(0,detnamesize);
70 QwWarning <<
"QwBPMCavity::GetSubElementIndex is unable to associate the string -"
87 Bool_t localdebug = kFALSE;
94 std::cout<<
" Wire ["<<i<<
"]="<<
fElement[i].GetElementName()<<
"\n";
118 Bool_t localdebug = kFALSE;
125 std::cout<<
" Wire ["<<i<<
"]="<<
fElement[i].GetElementName()<<
"\n";
129 fRelPos[i].InitializeChannel(subsystem,
"QwBPMCavity", name+
"Rel"+
subelement[i],
"derived");
130 fAbsPos[i].InitializeChannel(subsystem,
"QwBPMCavity", name+
kAxisLabel[i],
"derived");
160 Bool_t eventokay=kTRUE;
162 UInt_t deviceerror=0;
165 deviceerror|=
fElement[i].ApplyHWChecks();
166 eventokay &= (deviceerror & 0x0);
168 if (
bDEBUG) std::cout<<
" Inconsistent within BPM terminals wire[ "<<i<<
" ] "<<std::endl;
169 if (
bDEBUG) std::cout<<
" wire[ "<<i<<
" ] sequence num "<<
fElement[i].GetSequenceNumber()<<
" sample size "<<
fElement[i].GetNumberOfSamples()<<std::endl;
180 fElement[i].IncrementErrorCounters();
183 fRelPos[i].IncrementErrorCounters();
184 fAbsPos[i].IncrementErrorCounters();
197 fAbsPos[i].PrintErrorCounters();
210 error|=
fElement[i].GetEventcutErrorFlag();
213 error|=
fRelPos[i].GetEventcutErrorFlag();
214 error|=
fAbsPos[i].GetEventcutErrorFlag();
230 error2|=
fElement[i].GetEventcutErrorFlag();
233 fRelPos[i].UpdateErrorFlag(error1);
234 fAbsPos[i].UpdateErrorFlag(error1);
235 error2|=
fRelPos[i].GetEventcutErrorFlag();
236 error2|=
fAbsPos[i].GetEventcutErrorFlag();
250 UInt_t error_code = 0;
259 <<
" event cut failed ";
261 error_code |=
fElement[i].GetErrorCode();
264 fRelPos[i].UpdateErrorFlag(error_code);
270 if (
bDEBUG) std::cout<<
" Rel X event cut failed ";
275 fAbsPos[i].UpdateErrorFlag(error_code);
281 if (
bDEBUG) std::cout<<
" Abs X event cut failed ";
298 if (ch_name==
"relx"){
300 }
else if (ch_name==
"rely"){
302 }
else if (ch_name==
"absx" || ch_name==
"x" ){
304 }
else if (ch_name==
"absy" || ch_name==
"y"){
306 }
else if (ch_name==
"effectivecharge" || ch_name==
"charge" || ch_name==
"q"){
309 TString loc=
"QwLinearDiodeArray::GetSubelementByName for"
311 + ch_name +
", which is an unrecognized subelement name.";
312 throw std::invalid_argument(loc.Data());
358 if (ch_name==
"relx"){
360 fRelPos[0].SetSingleEventCuts(errorflag,minX,maxX,stability,burplevel);
362 }
else if (ch_name==
"rely"){
364 fRelPos[1].SetSingleEventCuts(errorflag,minX,maxX,stability,burplevel);
366 }
else if (ch_name==
"absx"){
368 fAbsPos[0].SetSingleEventCuts(errorflag,minX,maxX,stability,burplevel);
370 }
else if (ch_name==
"absy"){
372 fAbsPos[1].SetSingleEventCuts(errorflag,minX,maxX,stability,burplevel);
374 }
else if (ch_name==
"effectivecharge"){
376 fElement[
kQElem].SetSingleEventCuts(errorflag,minX,maxX,stability,burplevel);
378 }
else if (ch_name==
"xi"){
380 fElement[0].SetSingleEventCuts(errorflag,minX,maxX,stability,burplevel);
382 }
else if (ch_name==
"yi"){
384 fElement[1].SetSingleEventCuts(errorflag,minX,maxX,stability,burplevel);
401 Bool_t burpstatus = kFALSE;
403 if(
typeid(*ev_error)==
typeid(*
this)) {
409 burpstatus |=
fRelPos[i].CheckForBurpFail(&(value_bpm->
fRelPos[i]));
410 burpstatus |=
fAbsPos[i].CheckForBurpFail(&(value_bpm->
fAbsPos[i]));
415 TString loc=
"Standard exception from QwBPMCavity::CheckForBurpFail :"+
418 throw std::invalid_argument(loc.Data());
420 }
catch (std::exception& e) {
421 std::cerr<< e.what()<<std::endl;
436 if(
typeid(*ev_error)==
typeid(*
this)) {
449 TString loc=
"Standard exception from QwBPMCavity::UpdateErrorFlag :"+
452 throw std::invalid_argument(loc.Data());
454 }
catch (std::exception& e) {
455 std::cerr<< e.what()<<std::endl;
500 fElement[index].ProcessEvBuffer(buffer,word_position_in_buffer);
504 "QwBPMCavity::ProcessEvBuffer(): attempt to fill in raw date for a wire that doesn't exist \n";
506 return word_position_in_buffer;
546 if(subindex<kNumElements&&subindex>-1)
547 thisname=
fElement[subindex].GetElementName();
549 std::cerr<<
"QwBPMCavity::GetSubElementName for "<<
563 std::cerr <<
"QwBPMCavity::GetSubElementIndex is unable to associate the string -"
564 <<subname<<
"- to any index"<<std::endl;
705 fRelPos[i].CalculateRunningAverage();
706 fAbsPos[i].CalculateRunningAverage();
723 for (i = 0; i < 2; i++){
724 fRelPos[i].AccumulateRunningSum(value.
fRelPos[i], count, ErrorMask);
725 fAbsPos[i].AccumulateRunningSum(value.
fAbsPos[i], count, ErrorMask);
762 TString thisprefix=prefix;
764 if(prefix.Contains(
"asym_"))
765 thisprefix.ReplaceAll(
"asym_",
"diff_");
771 fAbsPos[i].ConstructHistograms(folder, thisprefix);
806 TString thisprefix=prefix;
807 if(prefix.Contains(
"asym_"))
808 thisprefix.ReplaceAll(
"asym_",
"diff_");
816 fAbsPos[i].ConstructBranchAndVector(tree,thisprefix,values);
833 TString thisprefix=prefix;
834 if(prefix.Contains(
"asym_"))
835 thisprefix.ReplaceAll(
"asym_",
"diff_");
843 fAbsPos[i].ConstructBranch(tree,thisprefix);
868 devicename.ToLower();
873 if (modulelist.
HasValue(devicename)){
874 TString thisprefix=prefix;
875 if(prefix.Contains(
"asym_"))
876 thisprefix.ReplaceAll(
"asym_",
"diff_");
884 fAbsPos[i].ConstructBranch(tree,thisprefix);
912 fAbsPos[i].FillTreeVector(values);
918#ifdef HAS_RNTUPLE_SUPPORT
923void QwBPMCavity::ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
929 TString thisprefix=prefix;
930 if(prefix.Contains(
"asym_"))
931 thisprefix.ReplaceAll(
"asym_",
"diff_");
934 fElement[
kQElem].ConstructNTupleAndVector(model,prefix,values,fieldPtrs);
937 if (
bFullSave)
fElement[i].ConstructNTupleAndVector(model,thisprefix,values,fieldPtrs);
939 fAbsPos[i].ConstructNTupleAndVector(model,thisprefix,values,fieldPtrs);
947void QwBPMCavity::FillNTupleVector(std::vector<Double_t>& values)
const
958 fAbsPos[i].FillNTupleVector(values);
974 fRelPos[i].SetEventCutMode(bcuts);
975 fAbsPos[i].SetEventCutMode(bcuts);
993#ifdef __USE_DATABASE__
996 std::vector <QwDBInterface> row_list;
999 fRelPos[i].AddEntriesToList(row_list);
1000 fAbsPos[i].AddEntriesToList(row_list);
1009 std::vector <QwErrDBInterface> row_list;
1012 fRelPos[i].AddErrEntriesToList(row_list);
1013 fAbsPos[i].AddErrEntriesToList(row_list);
1076 fRelPos[i].SetHardwareSum(relpos[i], sequencenumber);
1108 fElement[j].SetCalibrationFactor(value);
#define QwWarning
Predefined log drain for warnings.
#define QwMessage
Predefined log drain for regular messages.
static const UInt_t kBPMErrorFlag
static const UInt_t kInvalidSubelementIndex
Database interface for QwIntegrationPMT and subsystems.
Cavity beam position monitor implementation.
static std::ostream & endl(std::ostream &)
End of the line.
Configuration file parser with flexible tokenization and search capabilities.
Bool_t HasValue(TString &vname)
A helper class to manage a vector of branch entries for ROOT trees.
Concrete hardware channel for VQWK ADC modules (6x32-bit words)
VQwDataElement()
Default constructor.
virtual const TString & GetElementName() const
Get the name of this element.
Abstract base for concrete hardware channels implementing dual-operator pattern.
static UInt_t GetSubElementIndex(TString subname)
std::vector< QwErrDBInterface > GetErrDBEntry()
void SetDefaultSampleSize(Int_t sample_size) override
void AccumulateRunningSum(const VQwBPM &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
void ProcessEvent() override
void CalculateRunningAverage() override
Bool_t ApplySingleEventCuts() override
void GetAbsolutePosition() override
UInt_t GetEventcutErrorFlag() override
VQwHardwareChannel * GetSubelementByName(TString ch_name) override
void SetSubElementCalibrationFactor(Int_t j, Double_t value) override
std::array< QwVQWK_Channel, kNumAxes > fRelPos
static const TString subelement[kNumElements]
void FillHistograms() override
TString GetSubElementName(Int_t subindex) override
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override
void Ratio(QwBPMCavity &numer, QwBPMCavity &denom)
void SetEventData(Double_t *block, UInt_t sequencenumber)
void ClearEventData() override
std::vector< QwDBInterface > GetDBEntry()
void ConstructBranch(TTree *tree, TString &prefix) override
std::array< QwVQWK_Channel, kNumElements > fElement
std::array< QwVQWK_Channel, kNumAxes > fAbsPos
void EncodeEventData(std::vector< UInt_t > &buffer) override
void ConstructHistograms(TDirectory *folder, TString &prefix) override
VQwBPM & operator-=(const VQwBPM &value) override
void IncrementErrorCounters() override
void InitializeChannel(TString name)
void SetSingleEventCuts(TString ch_name, UInt_t errorflag, Double_t minX, Double_t maxX, Double_t stability, Double_t burplevel)
Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit),...
std::vector< QwVQWK_Channel > fBPMElementList
void SetEventCutMode(Int_t bcuts) override
static Bool_t ParseChannelName(const TString &channel, TString &detname, TString &subname, UInt_t &localindex)
void PrintValue() const override
void PrintInfo() const override
UInt_t UpdateErrorFlag() override
void PrintErrorCounters() const override
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber) override
void SetSubElementPedestal(Int_t j, Double_t value) override
void RandomizeEventData(int helicity=0, double time=0.0) override
VQwBPM & operator=(const VQwBPM &value) override
void DeaccumulateRunningSum(VQwBPM &value, Int_t ErrorMask=0xFFFFFFF) override
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override
static const Double_t kQwCavityCalibration
VQwBPM & operator+=(const VQwBPM &value) override
void Scale(Double_t factor) override
void FillTreeVector(QwRootTreeBranchVector &values) const override
Double_t fPositionCenter[3]
void SetRootSaveStatus(TString &prefix)
static const TString kAxisLabel[2]
void InitializeChannel(TString name)
Initialize common BPM state and set the element name.
static const Bool_t bDEBUG
virtual VQwBPM & operator=(const VQwBPM &value)=0