13#ifdef HAS_RNTUPLE_SUPPORT
14#include "ROOT/RNTupleModel.hxx"
15#include "ROOT/RField.hxx"
50 for (
size_t i = 0; i <
fScaler.size(); i++) {
67 const TString default_norm_channel =
"1";
69 Name_to_Scaler_Map_t::iterator current_norm_channel =
fName_Map.find(default_norm_channel);
70 double current_norm_factor = 1;
72 std::vector<Name_to_Scaler_Map_t::iterator> norm_channel;
73 std::vector<double> norm_factor;
77 UInt_t buffer_offset = 0;
80 Bool_t differential =
false;
99 TString varname, varvalue;
104 if (varname ==
"norm") {
113 current_norm_channel =
fName_Map.find(channame);
115 current_norm_factor = lexical_cast<double>(channorm);
116 }
catch (boost::bad_lexical_cast&) {
117 current_norm_factor = 1;
121 }
else if (varname ==
"scaler_buffer_offset") {
123 buffer_offset = value;
124 }
else if (varname ==
"header") {
130 }
else if (varname ==
"differential") {
133 differential = lexical_cast<bool>(varvalue);
134 }
catch (boost::bad_lexical_cast&) {
135 differential =
false;
155 if (modtype ==
"SIS3801" || modtype ==
"SIS3801D24" || modtype ==
"SIS3801D32") {
156 offset = QwSIS3801D24_Channel::GetBufferOffset(modnum, channum, header)+buffer_offset;
157 }
else if (modtype ==
"STR7200") {
158 offset = QwSIS3801D32_Channel::GetBufferOffset(modnum, channum, header)+buffer_offset;
172 QwVerbose <<
"Registering " << modtype <<
" " << keyword
176 <<
" at mod " << modnum <<
", chan " << channum
180 if (modtype ==
"SIS3801" || modtype ==
"SIS3801D24")
182 else if (modtype ==
"SIS3801D32")
184 else if (modtype ==
"STR7200")
200 fNorm.push_back(std::pair<VQwScaler_Channel*,double>(0,1));
203 norm_channel.push_back(current_norm_channel);
204 norm_factor.push_back(current_norm_factor);
210 for (Name_to_Scaler_Map_t::iterator iter =
fName_Map.begin(); iter !=
fName_Map.end(); iter++) {
211 if (iter->second == -1 && iter->first != default_norm_channel) {
218 for (
size_t i = 0; i <
fScaler.size(); i++) {
219 Int_t norm_index = norm_channel.at(i)->second;
220 if (norm_index < 0) {
222 fNorm.at(i).first = 0;
223 fNorm.at(i).second = 1;
227 fNorm.at(i).second = norm_factor.at(i);
229 fNorm.at(norm_index).first = 0;
230 fNorm.at(norm_index).second = 1;
255 varname.Remove(TString::kBoth,
' ');
262 QwMessage <<
"Parameters scaler channel " << varname <<
": "
263 <<
"ped = " << varped <<
", "
265 fScaler[index]->SetPedestal(varped);
266 fScaler[index]->SetCalibrationFactor(varcal);
281 for (
size_t i = 0; i <
fScaler.size(); i++) {
282 fScaler.at(i)->ClearEventData();
310 UInt_t words_read = 0;
315 if (subbank >= 0 && num_words > 0) {
323 for (
size_t modnum = 0; modnum <
fSubbank_Map[subbank].size(); modnum++) {
324 for (
size_t channum = 0; channum <
fSubbank_Map[subbank].at(modnum).size(); channum++) {
325 Int_t index =
fSubbank_Map[subbank].at(modnum).at(channum);
328 words_read +=
fScaler[index]->ProcessEvBuffer(&(buffer[offset]), num_words - offset);
332 words_read = num_words;
343 for (
size_t i = 0; i <
fScaler.size(); i++) {
348 for (
size_t i = 0; i <
fScaler.size(); i++) {
349 if (
fNorm.at(i).first) {
359 for(
size_t i = 0; i <
fScaler.size(); i++) {
360 fScaler.at(i)->ConstructHistograms(folder, prefix);
367 for(
size_t i = 0; i <
fScaler.size(); i++) {
368 fScaler.at(i)->FillHistograms();
375 for (
size_t i = 0; i <
fScaler.size(); i++) {
376 fScaler.at(i)->ConstructBranchAndVector(tree, prefix, values);
383 for(
size_t i = 0; i <
fScaler.size(); i++) {
384 fScaler.at(i)->FillTreeVector(values);
388#ifdef HAS_RNTUPLE_SUPPORT
389void QwScaler::ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
391 for (
size_t i = 0; i <
fScaler.size(); i++) {
392 fScaler.at(i)->ConstructNTupleAndVector(model, prefix, values, fieldPtrs);
396void QwScaler::FillNTupleVector(std::vector<Double_t>& values)
const
398 for(
size_t i = 0; i <
fScaler.size(); i++) {
399 fScaler.at(i)->FillNTupleVector(values);
412 for (
size_t i = 0; i <
fScaler.size(); i++) {
426 for (
size_t i = 0; i <
fScaler.size(); i++) {
440 for (
size_t i = 0; i <
fScaler.size(); i++) {
456 for (
size_t i = 0; i <
fScaler.size(); i++) {
467 for (
size_t i = 0; i <
fScaler.size(); i++) {
479 for (
size_t i = 0; i <
fScaler.size(); i++) {
480 fScaler.at(i)->AccumulateRunningSum(scaler->
fScaler.at(i), count, ErrorMask);
492 for (
size_t i = 0; i <
fScaler.size(); i++) {
493 fScaler.at(i)->DeaccumulateRunningSum(scaler->
fScaler.at(i), ErrorMask);
503 for (
size_t i = 0; i <
fScaler.size(); i++) {
504 fScaler.at(i)->CalculateRunningAverage();
558 if (value == 0)
return kFALSE;
561 Bool_t result = kTRUE;
562 if (
typeid(*value) !=
typeid(*
this)) {
583 for (
size_t i = 0; i <
fScaler.size(); i++) {
584 QwOut <<
" scaler " << i <<
": ";
595 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.
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.
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)