13#ifdef HAS_RNTUPLE_SUPPORT
14#include "ROOT/RNTupleModel.hxx"
15#include "ROOT/RField.hxx"
53 for (
size_t i = 0; i <
fScaler.size(); i++) {
70 const TString default_norm_channel =
"1";
72 Name_to_Scaler_Map_t::iterator current_norm_channel =
fName_Map.find(default_norm_channel);
73 double current_norm_factor = 1;
75 std::vector<Name_to_Scaler_Map_t::iterator> norm_channel;
76 std::vector<double> norm_factor;
80 UInt_t buffer_offset = 0;
83 Bool_t differential =
false;
102 TString varname, varvalue;
107 if (varname ==
"norm") {
116 current_norm_channel =
fName_Map.find(channame);
118 current_norm_factor = lexical_cast<double>(channorm);
119 }
catch (boost::bad_lexical_cast&) {
120 current_norm_factor = 1;
124 }
else if (varname ==
"scaler_buffer_offset") {
126 buffer_offset = value;
127 }
else if (varname ==
"header") {
133 }
else if (varname ==
"differential") {
136 differential = lexical_cast<bool>(varvalue);
137 }
catch (boost::bad_lexical_cast&) {
138 differential =
false;
158 if (modtype ==
"SIS3801" || modtype ==
"SIS3801D24" || modtype ==
"SIS3801D32") {
159 offset = QwSIS3801D24_Channel::GetBufferOffset(modnum, channum, header)+buffer_offset;
160 }
else if (modtype ==
"STR7200") {
161 offset = QwSIS3801D32_Channel::GetBufferOffset(modnum, channum, header)+buffer_offset;
175 QwVerbose <<
"Registering " << modtype <<
" " << keyword
179 <<
" at mod " << modnum <<
", chan " << channum
183 if (modtype ==
"SIS3801" || modtype ==
"SIS3801D24")
185 else if (modtype ==
"SIS3801D32")
187 else if (modtype ==
"STR7200")
203 fNorm.push_back(std::pair<VQwScaler_Channel*,double>(0,1));
206 norm_channel.push_back(current_norm_channel);
207 norm_factor.push_back(current_norm_factor);
213 for (Name_to_Scaler_Map_t::iterator iter =
fName_Map.begin(); iter !=
fName_Map.end(); iter++) {
214 if (iter->second == -1 && iter->first != default_norm_channel) {
221 for (
size_t i = 0; i <
fScaler.size(); i++) {
222 Int_t norm_index = norm_channel.at(i)->second;
223 if (norm_index < 0) {
225 fNorm.at(i).first = 0;
226 fNorm.at(i).second = 1;
230 fNorm.at(i).second = norm_factor.at(i);
232 fNorm.at(norm_index).first = 0;
233 fNorm.at(norm_index).second = 1;
258 varname.Remove(TString::kBoth,
' ');
265 QwMessage <<
"Parameters scaler channel " << varname <<
": "
266 <<
"ped = " << varped <<
", "
268 fScaler[index]->SetPedestal(varped);
269 fScaler[index]->SetCalibrationFactor(varcal);
284 for (
size_t i = 0; i <
fScaler.size(); i++) {
285 fScaler.at(i)->ClearEventData();
313 UInt_t words_read = 0;
318 if (subbank >= 0 && num_words > 0) {
326 for (
size_t modnum = 0; modnum <
fSubbank_Map[subbank].size(); modnum++) {
327 for (
size_t channum = 0; channum <
fSubbank_Map[subbank].at(modnum).size(); channum++) {
328 Int_t index =
fSubbank_Map[subbank].at(modnum).at(channum);
331 words_read +=
fScaler[index]->ProcessEvBuffer(&(buffer[offset]), num_words - offset);
335 words_read = num_words;
346 for (
size_t i = 0; i <
fScaler.size(); i++) {
351 for (
size_t i = 0; i <
fScaler.size(); i++) {
352 if (
fNorm.at(i).first) {
362 for(
size_t i = 0; i <
fScaler.size(); i++) {
363 fScaler.at(i)->ConstructHistograms(folder, prefix);
370 for(
size_t i = 0; i <
fScaler.size(); i++) {
371 fScaler.at(i)->FillHistograms();
378 for (
size_t i = 0; i <
fScaler.size(); i++) {
379 fScaler.at(i)->ConstructBranchAndVector(tree, prefix, values);
386 for(
size_t i = 0; i <
fScaler.size(); i++) {
387 fScaler.at(i)->FillTreeVector(values);
391#ifdef HAS_RNTUPLE_SUPPORT
392void QwScaler::ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
394 for (
size_t i = 0; i <
fScaler.size(); i++) {
395 fScaler.at(i)->ConstructNTupleAndVector(model, prefix, values, fieldPtrs);
399void QwScaler::FillNTupleVector(std::vector<Double_t>& values)
const
401 for(
size_t i = 0; i <
fScaler.size(); i++) {
402 fScaler.at(i)->FillNTupleVector(values);
415 for (
size_t i = 0; i <
fScaler.size(); i++) {
429 for (
size_t i = 0; i <
fScaler.size(); i++) {
443 for (
size_t i = 0; i <
fScaler.size(); i++) {
459 for (
size_t i = 0; i <
fScaler.size(); i++) {
470 for (
size_t i = 0; i <
fScaler.size(); i++) {
482 for (
size_t i = 0; i <
fScaler.size(); i++) {
483 fScaler.at(i)->AccumulateRunningSum(scaler->
fScaler.at(i), count, ErrorMask);
495 for (
size_t i = 0; i <
fScaler.size(); i++) {
496 fScaler.at(i)->DeaccumulateRunningSum(scaler->
fScaler.at(i), ErrorMask);
506 for (
size_t i = 0; i <
fScaler.size(); i++) {
507 fScaler.at(i)->CalculateRunningAverage();
561 if (value == 0)
return kFALSE;
564 Bool_t result = kTRUE;
565 if (
typeid(*value) !=
typeid(*
this)) {
586 for (
size_t i = 0; i <
fScaler.size(); i++) {
587 QwOut <<
" scaler " << i <<
": ";
598 for(
size_t i = 0; i <
fScaler.size(); i++) {
class QwScaler_Channel< 0x00ffffff, 0 > QwSIS3801D24_Channel
class QwScaler_Channel< 0xffffffff, 0 > QwSTR7200_Channel
class QwScaler_Channel< 0xffffffff, 0 > QwSIS3801D32_Channel
#define QwVerbose
Predefined log drain for verbose messages.
#define QwOut
Predefined log drain for explicit output.
#define QwError
Predefined log drain for errors.
#define QwMessage
Predefined log drain for regular messages.
Parameter file parsing and management.
#define REGISTER_SUBSYSTEM_FACTORY(A)
Scaler subsystem for counting and rate measurements.
static std::ostream & endl(std::ostream &)
End of the line.
Command-line and configuration file options processor.
Configuration file parser with flexible tokenization and search capabilities.
T GetTypedNextToken()
Get next token into specific type.
void TrimWhitespace(TString::EStripType head_tail=TString::kBoth)
Bool_t HasVariablePair(const std::string &separatorchars, std::string &varname, std::string &varvalue)
void SetCommentChars(const std::string value)
Set various sets of special characters.
void AddBreakpointKeyword(std::string keyname)
void TrimComment(const char commentchar)
std::string GetNextToken(const std::string &separatorchars)
Get next token as a string.
static UInt_t GetUInt(const TString &varvalue)
const std::pair< TString, TString > GetParamFileNameContents()
A helper class to manage a vector of branch entries for ROOT trees.
Abstract base class for scaler channels.
virtual void SetDifferentialScaler(Bool_t diff)
BankID_t fCurrentBank_ID
Bank ID (and Marker word) that is currently being processed;.
Int_t GetSubbankIndex() const
virtual VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
virtual void PrintInfo() const
Print some information about the subsystem.
void RegisterRocBankMarker(QwParameterFile &mapstr)
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
std::map< TString, TString > fDetectorMaps
Map of file name to full path or content.
VQwSubsystem(const TString &name)
Constructor with name.
ROCID_t fCurrentROC_ID
ROC ID that is currently being processed.
Subsystem managing scaler modules and derived rates.
void ClearEventData() override
void Scale(Double_t factor) override
Int_t LoadChannelMap(TString mapfile) override
Int_t LoadInputParameters(TString pedestalfile) override
Bool_t Compare(VQwSubsystem *source)
Int_t LoadEventCuts(TString filename) override
Optional event cut file.
void AccumulateRunningSum(VQwSubsystem *value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
void ProcessOptions(QwOptions &options) override
Bool_t ApplySingleEventCuts() override
Apply the single event cuts.
void CalculateRunningAverage() override
void DeaccumulateRunningSum(VQwSubsystem *value, Int_t ErrorMask=0xFFFFFFF) override
VQwSubsystem & operator-=(VQwSubsystem *value) override
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Name_to_Scaler_Map_t fName_Map
void Ratio(VQwSubsystem *value1, VQwSubsystem *value2) override
Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words) override
std::vector< std::pair< VQwScaler_Channel *, double > > fNorm
void FillHistograms() override
Module_Channel_to_Scaler_Map_t fModuleChannel_Map
Int_t ProcessEvBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words) override
UInt_t GetEventcutErrorFlag() override
Return the error flag to the top level routines related to stability checks and ErrorFlag updates.
std::vector< UInt_t > fBufferOffset
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
void IncrementErrorCounters() override
Increment the error counters.
std::vector< VQwScaler_Channel * > fScaler
QwScaler()
Private default constructor (not implemented, will throw linker error on use)
VQwSubsystem & operator=(VQwSubsystem *value) override
void FillTreeVector(QwRootTreeBranchVector &values) const override
void PrintErrorCounters() const override
~QwScaler() override
Destructor.
Subbank_to_Scaler_Map_t fSubbank_Map
VQwSubsystem & operator+=(VQwSubsystem *value) override
void PrintInfo() const override
Int_t GetChannelIndex(TString channelName, UInt_t module_number)
void ProcessEvent() override
void PrintValue() const override
VQwSubsystemParity()
Private default constructor (not implemented, will throw linker error on use)