31#include "TCollection.h"
46 void Copy(TObject& rhs) const override;
57 std::cout <<
"Failed to set scaler " << scaler <<
", index " << index <<
" is out of range 0 - "
63 fScaler = std::vector<uint32_t>(data, data + size);
89 void Print(Option_t* opt =
"")
const override;
90 void Clear(Option_t* opt =
"")
override;
106 explicit TScaler(
bool loadIntoMap =
false);
107 explicit TScaler(TTree*,
bool loadIntoMap =
false);
114 void Copy(TObject& obj) const override;
116 std::vector<UInt_t>
GetScaler(UInt_t address, ULong64_t time) const;
117 UInt_t
GetScaler(UInt_t address, ULong64_t time,
size_t index) const;
126 void Clear(Option_t* opt =
"")
override;
128 TH1D*
Draw(UInt_t address,
size_t index = 0, Option_t* option =
"");
129 TH1D*
Draw(UInt_t lowAddress, UInt_t highAddress,
size_t index = 0, Option_t* option =
"");
130 TH1D*
DrawRawTimes(UInt_t address, Double_t lowtime, Double_t hightime,
size_t index = 0, Option_t* option =
"");
134 static double GetLastScaler(TTree* tree =
nullptr, UInt_t address = 0xffff,
size_t nominator = 2,
size_t denominator = 1)
138 if(tree ==
nullptr) {
139 tree =
static_cast<TTree*
>(gDirectory->Get(
"RateScaler"));
140 if(tree ==
nullptr) {
141 std::cerr << __PRETTY_FUNCTION__ <<
": no tree provided and failed to find \"RateScaler\" in " << gDirectory->GetName() << std::endl;
146 tree->SetBranchAddress(
"ScalerData", &scalerData);
148 for(Long64_t entry = tree->GetEntries() - 1; entry >= 0; --entry) {
149 tree->GetEntry(entry);
150 if(scalerData->
GetAddress() != address) {
continue; }
152 if(nominator >= scalers.size() || denominator >= scalers.size()) {
153 std::cerr << __PRETTY_FUNCTION__ <<
": trying to get nominator " << nominator <<
" and denominator " << denominator <<
" from vector of size " << scalers.size() << std::endl;
156 return static_cast<double>(scalers[nominator]) / scalers[denominator];
158 std::cerr << __PRETTY_FUNCTION__ <<
": failed to find any entry for address " <<
hex(address, 4) << std::endl;
168 std::map<UInt_t, std::map<ULong64_t, std::vector<UInt_t>>>
fScalerMap;
std::string hex(T val, int width=-1)
void Clear(Option_t *opt="") override
std::vector< UInt_t > fScaler
UInt_t GetScaler(size_t index) const
ULong64_t GetTimeStamp() const
void Copy(TObject &rhs) const override
UInt_t GetNetworkPacketId() const
std::vector< UInt_t > GetScaler() const
void Print(Option_t *opt="") const override
void SetScaler(size_t index, UInt_t scaler)
void SetAddress(UInt_t address)
UInt_t GetAddress() const
void SetScaler(UInt_t *data, int size)
void SetNetworkPacketId(UInt_t networkId)
void ResizeScaler(size_t newSize=1)
UInt_t GetLowTimeStamp() const
void SetLowTimeStamp(UInt_t lowTime)
UInt_t GetHighTimeStamp() const
TScalerData(TScalerData &&) noexcept=default
void SetHighTimeStamp(UInt_t highTime)
std::map< UInt_t, std::map< ULong64_t, int > > fNumberOfTimePeriods
!
std::map< UInt_t, std::map< ULong64_t, int > > GetNumberOfTimePeriods()
ULong64_t fTotalTimePeriod
!
std::map< UInt_t, ULong64_t > GetTimePeriodMap()
void Clear(Option_t *opt="") override
TH1D * DrawRawTimes(UInt_t address, Double_t lowtime, Double_t hightime, size_t index=0, Option_t *option="")
static double GetLastScaler(TTree *tree=nullptr, UInt_t address=0xffff, size_t nominator=2, size_t denominator=1)
std::map< ULong64_t, int > fTotalNumberOfTimePeriods
!
std::map< UInt_t, ULong64_t > fTimePeriod
! a map between addresses and time differences (used to calculate the time period)
std::vector< UInt_t > GetScaler(UInt_t address, ULong64_t time) const
std::map< std::pair< UInt_t, UInt_t >, TH1D * > fHistRange
! map to store histograms for address-ranges
TScalerData * fScalerData
TScaler(bool loadIntoMap=false)
std::map< UInt_t, TH1D * > fHist
! map to store histograms that have already been drawn
UInt_t GetScalerDifference(UInt_t address, ULong64_t time, size_t index) const
std::map< UInt_t, std::map< ULong64_t, std::vector< UInt_t > > > fScalerMap
! an address-map of timestamp mapped scaler values
void Copy(TObject &obj) const override
ULong64_t GetTimePeriod(UInt_t address)
TScaler(TScaler &&) noexcept=default
void ReadTree(bool loadIntoMap)
TH1D * Draw(UInt_t address, size_t index=0, Option_t *option="")
ULong64_t NumberOfScalerReadouts() const