Skip to content

Commit

Permalink
Merge pull request JeffersonLab#13 from JeffersonLab/bugfix-macos-com…
Browse files Browse the repository at this point in the history
…pilation

Merges the updates that were committed to the original "japan" repository to support compilation on macOS and compilation with llvm/clang on any system.
  • Loading branch information
paulmking authored May 21, 2024
2 parents 0692b13 + e9651f4 commit 03d4a26
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 68 deletions.
8 changes: 8 additions & 0 deletions Analysis/include/QwMollerADC_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ class QwMollerADC_Channel: public VQwHardwareChannel, public MQwMockable {
};
virtual ~QwMollerADC_Channel() { };

void CopyFrom(const QwMollerADC_Channel& value){
VQwHardwareChannel::CopyFrom(value);
fBlocksPerEvent = value.fBlocksPerEvent;
fNumberOfSamples_map = value.fNumberOfSamples_map;
fSaturationABSLimit = value.fSaturationABSLimit;
*this = value;
};


using VQwHardwareChannel::Clone;

Expand Down
15 changes: 15 additions & 0 deletions Analysis/include/QwScaler_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ class VQwScaler_Channel: public VQwHardwareChannel, public MQwMockable {
{ }
virtual ~VQwScaler_Channel() { };

void CopyFrom(const VQwScaler_Channel& value){
VQwHardwareChannel::CopyFrom(value);
fValue_Raw_Old = value.fValue_Raw_Old;
fValue_Raw = value.fValue_Raw;
fValue = value.fValue;
fValueM2 = value.fValueM2;
fValueError = value.fValueError;
fClockNormalization = value.fClockNormalization;
fNormChannelName = value.fNormChannelName;
fNeedsExternalClock = value.fNeedsExternalClock;
fIsDifferentialScaler = value.fIsDifferentialScaler;
};


/// \brief Initialize the fields in this object
void InitializeChannel(TString name, TString datatosave = "raw");

Expand Down Expand Up @@ -241,6 +255,7 @@ class QwScaler_Channel: public VQwScaler_Channel
QwScaler_Channel(const QwScaler_Channel& source, VQwDataElement::EDataToSave datatosave)
: VQwScaler_Channel(source,datatosave) { };

using VQwScaler_Channel::CopyFrom;
using VQwHardwareChannel::Clone;
VQwHardwareChannel* Clone(VQwDataElement::EDataToSave datatosave) const;

Expand Down
7 changes: 7 additions & 0 deletions Analysis/include/QwVQWK_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class QwVQWK_Channel: public VQwHardwareChannel, public MQwMockable {
};
virtual ~QwVQWK_Channel() { };

void CopyFrom(const QwVQWK_Channel& value){
VQwHardwareChannel::CopyFrom(value);
fBlocksPerEvent = value.fBlocksPerEvent;
fNumberOfSamples_map = value.fNumberOfSamples_map;
fSaturationABSLimit = value.fSaturationABSLimit;
*this = value;
};

using VQwHardwareChannel::Clone;

Expand Down
10 changes: 10 additions & 0 deletions Analysis/include/VQwDataElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ class VQwDataElement: public MQwHistograms {
/// Virtual destructor
virtual ~VQwDataElement() { };

virtual void CopyFrom(const VQwDataElement& value){
fElementName = value.fElementName;
// fNumberOfDataWords = value.fNumberOfDataWords;
fGoodEventCount = value.fGoodEventCount;
fSubsystemName = value.fSubsystemName;
fModuleType = value.fModuleType;
fErrorFlag = value.fErrorFlag;
fErrorConfigFlag = value.fErrorConfigFlag;
}

/*! \brief Is the name of this element empty? */
Bool_t IsNameEmpty() const { return fElementName.IsNull(); }
/*! \brief Set the name of this element */
Expand Down
2 changes: 2 additions & 0 deletions Analysis/include/VQwHardwareChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class VQwHardwareChannel: public VQwDataElement {
VQwHardwareChannel(const VQwHardwareChannel& value, VQwDataElement::EDataToSave datatosave);
virtual ~VQwHardwareChannel() { };

virtual void CopyFrom(const VQwHardwareChannel& value);

void ProcessOptions();

virtual VQwHardwareChannel* Clone() const{
Expand Down
23 changes: 23 additions & 0 deletions Analysis/src/VQwHardwareChannel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ VQwHardwareChannel::VQwHardwareChannel(const VQwHardwareChannel& value, VQwDataE
{
}

void VQwHardwareChannel::CopyFrom(const VQwHardwareChannel& value)
{
VQwDataElement::CopyFrom(value);
fNumberOfDataWords = value.fNumberOfDataWords;
fNumberOfSubElements = value.fNumberOfSubElements;
fDataToSave = value.fDataToSave;
fTreeArrayIndex = value.fTreeArrayIndex;
fTreeArrayNumEntries = value.fTreeArrayNumEntries;
fPedestal = value.fPedestal;
fCalibrationFactor = value.fCalibrationFactor;
kFoundPedestal = value.kFoundPedestal;
kFoundGain = value.kFoundGain;
bEVENTCUTMODE = value.bEVENTCUTMODE;
fULimit = value.fULimit;
fLLimit = value.fLLimit;
fStability = value.fStability;
fBurpThreshold = value.fBurpThreshold;
fBurpCountdown = value.fBurpCountdown;
fBurpHoldoff = value.fBurpHoldoff;
}



void VQwHardwareChannel::ProcessOptions(){
if (gQwOptions.HasValue("burp.holdoff"))
fBurpHoldoff=gQwOptions.GetValue<int>("burp.holdoff");
Expand Down
16 changes: 10 additions & 6 deletions Parity/include/QwBPMCavity.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "QwVQWK_Channel.h"
#include "VQwBPM.h"
#include "QwParameterFile.h"
#include "QwUtil.h"

// Forward declarations
class QwDBInterface;
Expand Down Expand Up @@ -49,9 +50,12 @@ class QwBPMCavity : public VQwBPM {
InitializeChannel(subsystemname, name);
};
QwBPMCavity(const QwBPMCavity& source)
: VQwBPM(source),
fElement(source.fElement),fRelPos(source.fRelPos),fAbsPos(source.fAbsPos)
{ }
: VQwBPM(source)
{
QwCopyArray(source.fElement, fElement);
QwCopyArray(source.fRelPos, fRelPos);
QwCopyArray(source.fAbsPos, fAbsPos);
}
virtual ~QwBPMCavity() { };

void InitializeChannel(TString name);
Expand Down Expand Up @@ -146,12 +150,12 @@ class QwBPMCavity : public VQwBPM {


protected:
QwVQWK_Channel fElement[kNumElements];
QwVQWK_Channel fRelPos[kNumAxes];
std::array<QwVQWK_Channel,kNumElements> fElement;//(kNumElements);
std::array<QwVQWK_Channel,kNumAxes> fRelPos;//(kNumAxes);

// These are the "real" data elements, to which the base class
// fAbsPos_base and fElement[kQElem]_base are pointers.
QwVQWK_Channel fAbsPos[kNumAxes];
std::array<QwVQWK_Channel,kNumAxes> fAbsPos;//(kNumAxes);


private:
Expand Down
24 changes: 14 additions & 10 deletions Parity/include/QwBPMStripline.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// Qweak headers
#include "VQwBPM.h"
#include "QwParameterFile.h"
#include "QwUtil.h"

// Forward declarations
#ifdef __USE_DATABASE__
Expand All @@ -38,34 +39,37 @@ class QwBPMStripline : public VQwBPM {

public:
static UInt_t GetSubElementIndex(TString subname);

public:
QwBPMStripline() { };
QwBPMStripline(TString name) {
InitializeChannel(name);
fRotationAngle = 45.0;
SetRotation(fRotationAngle);
bRotated=kTRUE;
};
};
QwBPMStripline(TString subsystemname, TString name) {
SetSubsystemName(subsystemname);
InitializeChannel(subsystemname, name);
fRotationAngle = 45.0;
SetRotation(fRotationAngle);
bRotated=kTRUE;
};
};
QwBPMStripline(TString subsystemname, TString name, TString type) {
SetSubsystemName(subsystemname);
InitializeChannel(subsystemname, name, type);
fRotationAngle = 45.0;
SetRotation(fRotationAngle);
bRotated=kTRUE;
};
};
QwBPMStripline(const QwBPMStripline& source)
: VQwBPM(source),
fWire(source.fWire),fRelPos(source.fRelPos),fAbsPos(source.fAbsPos),
fEffectiveCharge(source.fEffectiveCharge),fEllipticity(source.fEllipticity)
{ }
{
QwCopyArray(source.fWire, fWire);
QwCopyArray(source.fRelPos, fRelPos);
QwCopyArray(source.fAbsPos, fAbsPos);
}
virtual ~QwBPMStripline() { };

void InitializeChannel(TString name);
Expand Down Expand Up @@ -193,16 +197,16 @@ class QwBPMStripline : public VQwBPM {


protected:
T fWire[4];
T fRelPos[2];
std::array<T,4> fWire;//[4];
std::array<T,2> fRelPos;//[2];

// These are the "real" data elements, to which the base class
// fAbsPos_base and fEffectiveCharge_base are pointers.
T fAbsPos[2];
std::array<T,2> fAbsPos;//[2];
T fEffectiveCharge;
T fEllipticity;

private:
private:
// Functions to be removed
void SetEventData(Double_t* block, UInt_t sequencenumber);
std::vector<T> fBPMElementList;
Expand Down
27 changes: 14 additions & 13 deletions Parity/include/QwCombinedBPM.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// Qweak headers
#include "VQwHardwareChannel.h"
#include "VQwBPM.h"
#include "QwUtil.h"

// Forward declarations
#ifdef __USE_DATABASE__
Expand All @@ -39,7 +40,7 @@ class QwCombinedBPM : public VQwBPM {
//-------------------------------------------------------------------------
size_t GetNumberOfElements() {return fElement.size();};
TString GetSubElementName(Int_t index) {return fElement.at(index)->GetElementName();};
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------

QwCombinedBPM(){
};
Expand All @@ -55,12 +56,13 @@ class QwCombinedBPM : public VQwBPM {
};
QwCombinedBPM(const QwCombinedBPM& source)
: VQwBPM(source),
fSlope(source.fSlope),
fIntercept(source.fIntercept),
fMinimumChiSquare(source.fMinimumChiSquare),
fAbsPos(source.fAbsPos),
fEffectiveCharge(source.fEffectiveCharge)
{ }
{
QwCopyArray(source.fSlope, fSlope);
QwCopyArray(source.fIntercept, fIntercept);
QwCopyArray(source.fMinimumChiSquare, fMinimumChiSquare);
QwCopyArray(source.fAbsPos, fAbsPos);
}
virtual ~QwCombinedBPM() { };

using VQwBPM::EBeamPositionMonitorAxis;
Expand Down Expand Up @@ -184,7 +186,7 @@ class QwCombinedBPM : public VQwBPM {
Double_t SumOver( std::vector <Double_t> weight , std::vector <T> val);
void LeastSquareFit(VQwBPM::EBeamPositionMonitorAxis axis, std::vector<Double_t> fWeights) ; //bbbbb



/////
private:
Expand All @@ -204,20 +206,20 @@ class QwCombinedBPM : public VQwBPM {

protected:
/* This channel contains the beam slope w.r.t the X & Y axis at the target */
T fSlope[2];
std::array<T,2> fSlope;//[2];

/* This channel contains the beam intercept w.r.t the X & Y axis at the target */
T fIntercept[2];
std::array<T,2> fIntercept;//[2];

/*This channel gives the minimum chisquare value for the fit over target bpms*/
T fMinimumChiSquare[2];
std::array<T,2> fMinimumChiSquare;//[2];

// These are the "real" data elements, to which the base class
// fAbsPos_base and fEffectiveCharge_base are pointers.
T fAbsPos[2];
std::array<T,2> fAbsPos;//[2];
T fEffectiveCharge;

private:
private:
// Functions to be removed
void MakeBPMComboList();
std::vector<T> fBPMComboElementList;
Expand All @@ -227,4 +229,3 @@ class QwCombinedBPM : public VQwBPM {


#endif

24 changes: 13 additions & 11 deletions Parity/include/QwQPD.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "QwVQWK_Channel.h"
#include "VQwBPM.h"
#include "QwParameterFile.h"
#include "QwUtil.h"

// Forward declarations
#ifdef __USE_DATABASE__
Expand Down Expand Up @@ -46,16 +47,17 @@ class QwQPD : public VQwBPM {
InitializeChannel(subsystemname, name);
fQwQPDCalibration[0] = 1.0;
fQwQPDCalibration[1] = 1.0;
};
};
QwQPD(const QwQPD& source)
: VQwBPM(source),
fPhotodiode(source.fPhotodiode),
fRelPos(source.fRelPos),
fAbsPos(source.fAbsPos),
fEffectiveCharge(source.fEffectiveCharge)
{ }
{
QwCopyArray(source.fPhotodiode, fPhotodiode);
QwCopyArray(source.fRelPos, fRelPos);
QwCopyArray(source.fAbsPos, fAbsPos);
}
virtual ~QwQPD() { };

void InitializeChannel(TString name);
// new routine added to update necessary information for tree trimming
void InitializeChannel(TString subsystem, TString name);
Expand All @@ -66,7 +68,7 @@ class QwQPD : public VQwBPM {
}

void GetCalibrationFactors(Double_t AlphaX, Double_t AlphaY);

void ClearEventData();
Int_t ProcessEvBuffer(UInt_t* buffer,
UInt_t word_position_in_buffer,UInt_t indexnumber);
Expand Down Expand Up @@ -149,18 +151,18 @@ class QwQPD : public VQwBPM {
private:


static const TString subelement[4];
static const TString subelement[4];
/* Position calibration factor, transform ADC counts in mm */
Double_t fQwQPDCalibration[2];


protected:
QwVQWK_Channel fPhotodiode[4];
QwVQWK_Channel fRelPos[2];
std::array<QwVQWK_Channel,4> fPhotodiode;//[4];
std::array<QwVQWK_Channel,2> fRelPos;//[2];

// These are the "real" data elements, to which the base class
// fAbsPos_base and fEffectiveCharge_base are pointers.
QwVQWK_Channel fAbsPos[2];
std::array<QwVQWK_Channel,2> fAbsPos;//[2];
QwVQWK_Channel fEffectiveCharge;

std::vector<QwVQWK_Channel> fQPDElementList;
Expand Down
20 changes: 20 additions & 0 deletions Parity/include/QwUtil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Helper functions
//
// Created by Ole Hansen on 8/16/23.
//

#ifndef QWANALYSIS_QWUTIL_H
#define QWANALYSIS_QWUTIL_H

#include <algorithm>
#include <iterator>

// Copy C-style array a to b
template<typename T>
void QwCopyArray( const T& a, T& b ) {
for (size_t i=0; i<a.size(); i++){
b.at(i).CopyFrom(a.at(i));
}
}

#endif //QWANALYSIS_QWUTIL_H
Loading

0 comments on commit 03d4a26

Please sign in to comment.