45 void Copy(TObject& rhs) const override;
56 std::cout <<
"Failed to set scaler " << scaler <<
", index " << index <<
" is out of range 0 - "
62 fScaler = std::vector<uint32_t>(data, data + size);
88 void Print(Option_t* opt =
"")
const override;
89 void Clear(Option_t* opt =
"")
override;
105 explicit TScaler(
bool loadIntoMap =
false);
106 explicit TScaler(TTree*,
bool loadIntoMap =
false);
113 void Copy(TObject& obj) const override;
115 std::vector<UInt_t>
GetScaler(UInt_t address, ULong64_t time) const;
116 UInt_t
GetScaler(UInt_t address, ULong64_t time,
size_t index) const;
125 void Clear(Option_t* opt =
"")
override;
127 TH1D*
Draw(UInt_t address,
size_t index = 0, Option_t* option =
"");
128 TH1D*
Draw(UInt_t lowAddress, UInt_t highAddress,
size_t index = 0, Option_t* option =
"");
129 TH1D*
DrawRawTimes(UInt_t address, Double_t lowtime, Double_t hightime,
size_t index = 0, Option_t* option =
"");
133 static double GetLastScaler(TTree* tree =
nullptr, UInt_t address = 0xffff,
size_t nominator = 2,
size_t denominator = 1)
137 if(tree ==
nullptr) {
138 tree =
static_cast<TTree*
>(gDirectory->Get(
"RateScaler"));
139 if(tree ==
nullptr) {
140 std::cerr << __PRETTY_FUNCTION__ <<
": no tree provided and failed to find \"RateScaler\" in " << gDirectory->GetName() << std::endl;
145 tree->SetBranchAddress(
"ScalerData", &scalerData);
147 for(Long64_t entry = tree->GetEntries() - 1; entry >= 0; --entry) {
148 tree->GetEntry(entry);
149 if(scalerData->
GetAddress() != address) {
continue; }
151 if(nominator >= scalers.size() || denominator >= scalers.size()) {
152 std::cerr << __PRETTY_FUNCTION__ <<
": trying to get nominator " << nominator <<
" and denominator " << denominator <<
" from vector of size " << scalers.size() << std::endl;
155 return static_cast<double>(scalers[nominator]) / scalers[denominator];
157 std::cerr << __PRETTY_FUNCTION__ <<
": failed to find any entry for address " <<
hex(address, 4) << std::endl;
167 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