16#ifdef HAS_RNTUPLE_SUPPORT
17#include "ROOT/RNTupleModel.hxx"
18#include "ROOT/RNTupleWriter.hxx"
19#include "ROOT/RField.hxx"
27#ifdef __USE_DATABASE__
28#include "QwParitySchema.h"
135 for(
size_t i=0;i<this->
fWord.size();i++)
137 this->
fWord[i].fWordName=source.
fWord[i].fWordName;
138 this->
fWord[i].fModuleType=source.
fWord[i].fModuleType;
139 this->
fWord[i].fWordType=source.
fWord[i].fWordType;
174 (
"helicity.seed", po::value<int>(),
175 "Number of bits in random seed");
177 (
"helicity.bitpattern", po::value<std::string>(),
178 "Helicity bit pattern: 0x1 (pair), 0x9 (quartet), 0x69 (octet), 0x666999 (hexo-quad), 0x66669999 (octo-quad)");
180 (
"helicity.patternoffset", po::value<int>(),
181 "Set 1 when pattern starts with 1 or 0 when starts with 0");
183 (
"helicity.patternphase", po::value<int>(),
184 "Maximum pattern phase");
186 (
"helicity.delay", po::value<int>(),
187 "Default delay is 2 patterns, set at the helicity map file.");
189 (
"helicity.toggle-mode", po::value<bool>()->default_bool_value(
false),
190 "Activates helicity toggle-mode, overriding the 'delay', 'patternphase', 'bitpattern', and 'seed' options.");
199 if (options.
HasValue(
"helicity.patternoffset")) {
200 if (options.
GetValue<
int>(
"helicity.patternoffset") == 1
201 || options.
GetValue<
int>(
"helicity.patternoffset") == 0) {
207 if (options.
HasValue(
"helicity.patternphase")) {
208 if (options.
GetValue<
int>(
"helicity.patternphase") % 2 == 0) {
214 if (options.
HasValue(
"helicity.seed")) {
215 if (options.
GetValue<
int>(
"helicity.seed") == 24
216 || options.
GetValue<
int>(
"helicity.seed") == 30) {
222 if (options.
HasValue(
"helicity.delay")) {
227 if (options.
HasValue(
"helicity.bitpattern")) {
229 << options.
GetValue<std::string>(
"helicity.bitpattern")
231 std::string hex = options.
GetValue<std::string>(
"helicity.bitpattern");
238 if (options.
GetValue<
bool>(
"helicity.toggle-mode")) {
263 Bool_t results=kFALSE;
302 QwWarning <<
"QwHelicity::IsGoodEventNumber: \n this is not a good event number indeed:" <<
QwLog::endl;
326 QwWarning <<
"QwHelicity::IsGoodPhaseNumber: not a good phase number \t"
351 QwError <<
"QwHelicity::IsGoodHelicity : The helicity reported in event "
353 <<
" is not what we expect from the randomseed. Not a good event nor pattern"
356 QwError <<
"QwHelicity::IsGoodHelicity - The helicity reported in event "
358 <<
" is not what we expect according to pattern structure. Not a good event nor pattern"
377 for (
size_t i=0;i<
fWord.size();i++)
438 QwMessage <<
"\n*********QwHelicity Error Summary****************"
440 QwMessage <<
"First helicity gate counter: "
442 <<
"; last helicity gate counter: "
447 <<
"; last pattern counter: "
453 QwMessage <<
"Number of multiplet-sync-bit errors: "
456 QwMessage <<
"Number of helicity prediction errors: "
459 QwMessage <<
"---------------------------------------------------\n"
513 Bool_t ldebug=kFALSE;
515 static UInt_t lastuserbits = 0xFF;
518 if(scaleroffset==1 || scaleroffset==0) {
524 lastuserbits = userbits;
526 if (lastuserbits==0xFF) {
529 if ((lastuserbits & 0x8) == 0x8) {
539 if ((lastuserbits & 0x4) == 0x4){
550 QwError <<
" QwHelicity::ProcessEvent finding a missed read event in the scaler" <<
QwLog::endl;
552 std::cout <<
" QwHelicity::ProcessEvent :" << scaleroffset <<
" events were missed \n";
553 std::cout <<
" before manipulation \n";
562 for (UInt_t i=0;i<scaleroffset;i++) {
575 std::cout <<
" after manipulation \n";
585 static Bool_t firstevent = kTRUE;
586 static Bool_t firstpattern = kTRUE;
587 static Bool_t fake_the_counters=kFALSE;
606 if (!fake_the_counters){
617 firstpattern = kFALSE;
646 QwError <<
"QwHelicity::ProcessEvent read event# ("
657 QwError <<
"QwHelicity::ProcessEvent: The Multiplet Sync bit is set, but the Pattern Phase is ("
673 QwError <<
"QwHelicity::ProcessEvent: Both the H+ and H- bits are set: thisinputregister=="
693 static Bool_t firstpattern = kTRUE;
696 firstpattern = kFALSE;
702 QwError <<
"QwHelicity::ProcessEvent read event# ("
738 Bool_t ldebug = kFALSE;
755 QwError <<
"QwHelicity::ProcessEvent no instructions on how to decode the helicity !!!!" <<
QwLog::endl;
796 std::vector<UInt_t> localbuffer;
802 UInt_t userbit = 0x0;
807 localbuffer.push_back(0x1);
808 localbuffer.push_back(0xa);
809 localbuffer.push_back(0xa);
810 localbuffer.push_back(0x0);
811 localbuffer.push_back(0x20);
812 localbuffer.push_back(userbit);
814 for (
int i = 0; i < 64; i++) localbuffer.push_back(0x0);
818 UInt_t input_register = 0x0;
824 localbuffer.push_back(input_register);
825 localbuffer.push_back(0x0);
830 for (
int i = 0; i < 17; i++) localbuffer.push_back(0x0);
839 std::vector<UInt_t> subbankheader;
840 std::vector<UInt_t> rocheader;
841 if (localbuffer.size() > 0) {
844 subbankheader.clear();
845 subbankheader.push_back(localbuffer.size() + 1);
846 subbankheader.push_back((
fCurrentBank_ID << 16) | (0x01 << 8) | (1 & 0xff));
851 rocheader.push_back(subbankheader.size() + localbuffer.size() + 1);
852 rocheader.push_back((
fCurrentROC_ID << 16) | (0x10 << 8) | (1 & 0xff));
856 buffer.insert(buffer.end(), rocheader.begin(), rocheader.end());
857 buffer.insert(buffer.end(), subbankheader.begin(), subbankheader.end());
858 buffer.insert(buffer.end(), localbuffer.begin(), localbuffer.end());
864 QwOut <<
"===========================\n"
865 <<
"This event: Event#, Pattern#, PatternPhase#="
869 QwOut <<
"Previous event: Event#, Pattern#, PatternPhase#="
873 QwOut <<
"delta = \n(fEventNumberOld)-(fMaxPatternPhase)x(fPatternNumberOld)-(fPatternPhaseNumberOld)= "
875 QwOut <<
"Helicity Reported, Delayed, Actual ="
886 Bool_t ldebug=kFALSE;
909 if (mapstr.
PopValue(
"patternphase",value)) {
913 if (mapstr.
PopValue(
"patternbits",valuestr)) {
916 if (mapstr.
PopValue(
"inputregmask_fakemps",value)) {
919 if (mapstr.
PopValue(
"inputregmask_helicity",value)) {
923 if (mapstr.
PopValue(
"inputregmask_helplus",value)) {
926 if (mapstr.
PopValue(
"inputregmask_helminus",value)) {
929 if (mapstr.
PopValue(
"inputregmask_pattsync",value)) {
932 if (mapstr.
PopValue(
"inputregmask_pairsync",value)) {
935 if (mapstr.
PopValue(
"fakempsbit",value)) {
939 if (mapstr.
PopValue(
"numberpatternsdelayed",value)) {
942 if (mapstr.
PopValue(
"randseedbits",value)) {
943 if (value==24 || value==30)
946 if (mapstr.
PopValue(
"patternphaseoffset",value)) {
949 if (mapstr.
PopValue(
"helpluseventtype",value)) {
952 if (mapstr.
PopValue(
"helminuseventtype",value)) {
955 if (mapstr.
PopValue(
"helicitydecodingmode",valuestr)) {
956 if (valuestr==
"InputRegisterMode") {
959 }
else if (valuestr==
"UserbitMode"){
962 }
else if (valuestr==
"HelLocalyMadeUp"){
965 }
else if (valuestr==
"InputMollerMode") {
969 QwError <<
"The helicity decoding mode read in file " << mapfile
970 <<
" is not recognized in function QwHelicity::LoadChannelMap \n"
977 if ((bankindex+1)>0){
978 UInt_t numbanks = UInt_t(bankindex+1);
981 std::pair<Int_t, Int_t>(
fWord.size(),
fWord.size()));
1001 if(modtype==
"SKIP"){
1002 if (modnum<=0) wordsofar+=1;
1003 else wordsofar+=modnum;
1004 }
else if(modtype!=
"WORD"|| dettype!=
"helicitydata") {
1005 QwError <<
"QwHelicity::LoadChannelMap: Unknown detector type: "
1006 << dettype <<
", the detector " << namech <<
" will not be decoded "
1019 fWord.push_back(localword);
1037 if(namech.Contains(
"mps_counter")) {
1040 if(namech.Contains(
"pat_counter")) {
1050 std::cout <<
"Done with Load map channel \n";
1051 for(
size_t i=0;i<
fWord.size();i++)
1053 std::cout <<
" kUserbit=" <<
kUserbit <<
"\n";
1063 QwDebug <<
"QwHelicity::LoadChannelMap:"
1064 <<
" We are in Moller Helicity Mode, with HelPlusEventType = "
1069 QwError <<
"QwHelicity::LoadChannelMap:"
1070 <<
" We are in Moller Helicity Mode, and the HelPlus and HelMinus event types are not set properly."
1073 <<
". Please correct the helicity map file!"
1092 Bool_t lkDEBUG = kFALSE;
1099 if (index >= 0 && num_words > 0) {
1102 QwDebug <<
"QwHelicity::ProcessEvBuffer: "
1103 <<
"Begin processing ROC" << roc_id
1104 <<
" and subbank " << bank_id
1105 <<
" number of words=" << num_words <<
QwLog::endl;
1108 if(
fWord[i].fWordInSubbank+1<= (Int_t) num_words) {
1109 fWord[i].fValue=buffer[
fWord[i].fWordInSubbank];
1111 QwWarning <<
"QwHelicity::ProcessEvBuffer: There is not enough word in the buffer to read data for "
1113 QwWarning <<
"QwHelicity::ProcessEvBuffer: Words in this buffer:" << num_words
1114 <<
" trying to read word number =" <<
fWord[i].fWordInSubbank <<
QwLog::endl;
1118 QwDebug <<
"QwHelicity::ProcessEvBuffer: Done with Processing this event" <<
QwLog::endl;
1119 for(
size_t i=0;i<
fWord.size();i++) {
1120 std::cout <<
" word number = " << i <<
" ";
1172 throw std::invalid_argument(
"SetFirstBits currently only supports 24 bits.");
1174 UShort_t firstbits[nbits+1];
1175 for (
unsigned int i = 0; i < nbits+1; i++) firstbits[i] = (seed >> i) & 0x1;
1186 if (TRegexp(
"diff_").Index(prefix,&len) == 0
1187 || TRegexp(
"asym[1-9]*_").Index(prefix,&len) == 0)
1189 else if (TRegexp(
"yield_").Index(prefix,&len) == 0)
1198 if (folder != NULL) folder->cd();
1209 basename=
"pattern_polarity";
1212 for (
size_t i=0; i<
fWord.size(); i++){
1213 basename=
"hel_"+
fWord[i].fWordName;
1222 basename=prefix+
"delta_event_number";
1225 basename=prefix+
"delta_pattern_number";
1228 basename=prefix+
"pattern_phase";
1231 basename=prefix+
"helicity";
1234 for (
size_t i=0; i<
fWord.size(); i++){
1235 basename=prefix+
fWord[i].fWordName;
1241 QwError <<
"QwHelicity::ConstructHistograms this prefix--" << prefix <<
"-- is not unknown:: no histo created" <<
QwLog::endl;
1263 for (
size_t i=0; i<
fWord.size(); i++){
1285 for (
size_t i=0; i<
fWord.size(); i++){
1314 basename =
"delayed_helicity";
1316 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1318 basename =
"reported_helicity";
1320 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1322 basename =
"pattern_phase";
1324 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1326 basename =
"pattern_number";
1328 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1330 basename =
"pattern_seed";
1332 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1334 basename =
"event_number";
1336 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1338 for (
size_t i=0; i<
fWord.size(); i++)
1340 basename =
fWord[i].fWordName;
1342 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1347 basename =
"actual_helicity";
1349 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1351 basename =
"actual_pattern_polarity";
1353 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1355 basename =
"actual_previous_pattern_polarity";
1357 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1359 basename =
"delayed_pattern_polarity";
1361 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1363 basename =
"pattern_number";
1365 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1367 basename =
"pattern_seed";
1369 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1371 for (
size_t i=0; i<
fWord.size(); i++)
1373 basename =
fWord[i].fWordName;
1375 tree->Branch(basename, &(values.
back<Double_t>()), basename+
"/I");
1396 basename =
"delayed_helicity";
1399 basename =
"reported_helicity";
1402 basename =
"pattern_phase";
1405 basename =
"pattern_number";
1408 basename =
"pattern_seed";
1411 basename =
"event_number";
1416 basename =
"actual_helicity";
1419 basename =
"actual_pattern_polarity";
1422 basename =
"actual_previous_pattern_polarity";
1425 basename =
"delayed_pattern_polarity";
1428 basename =
"pattern_number";
1431 basename =
"pattern_seed";
1434 for (
size_t i=0; i<
fWord.size(); i++)
1436 basename =
fWord[i].fWordName;
1437 tree->Branch(basename, &
fWord[i].fValue, basename+
"/I");
1458 basename =
"delayed_helicity";
1461 basename =
"reported_helicity";
1464 basename =
"pattern_phase";
1467 basename =
"pattern_number";
1470 basename =
"pattern_seed";
1473 basename =
"event_number";
1478 basename =
"actual_helicity";
1481 basename =
"actual_pattern_polarity";
1484 basename =
"actual_previous_pattern_polarity";
1487 basename =
"delayed_pattern_polarity";
1490 basename =
"pattern_number";
1493 basename =
"pattern_seed";
1496 for (
size_t i=0; i<
fWord.size(); i++)
1498 basename =
fWord[i].fWordName;
1499 tree->Branch(basename,&
fWord[i].fValue, basename+
"/I");
1521 for (
size_t i=0; i<
fWord.size(); i++)
1532 for (
size_t i=0; i<
fWord.size(); i++){
1540#ifdef HAS_RNTUPLE_SUPPORT
1541void QwHelicity::ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString &prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs)
1553 basename =
"delayed_helicity";
1554 values.push_back(0.0);
1555 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1557 basename =
"reported_helicity";
1558 values.push_back(0.0);
1559 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1561 basename =
"pattern_phase";
1562 values.push_back(0.0);
1563 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1565 basename =
"pattern_number";
1566 values.push_back(0.0);
1567 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1569 basename =
"pattern_seed";
1570 values.push_back(0.0);
1571 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1573 basename =
"event_number";
1574 values.push_back(0.0);
1575 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1577 for (
size_t i=0; i<
fWord.size(); i++)
1579 basename =
fWord[i].fWordName;
1580 values.push_back(0.0);
1581 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1586 basename =
"actual_helicity";
1587 values.push_back(0.0);
1588 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1590 basename =
"actual_pattern_polarity";
1591 values.push_back(0.0);
1592 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1594 basename =
"actual_previous_pattern_polarity";
1595 values.push_back(0.0);
1596 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1598 basename =
"delayed_pattern_polarity";
1599 values.push_back(0.0);
1600 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1602 basename =
"pattern_number";
1603 values.push_back(0.0);
1604 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1606 basename =
"pattern_seed";
1607 values.push_back(0.0);
1608 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1610 for (
size_t i=0; i<
fWord.size(); i++){
1611 basename =
fWord[i].fWordName;
1612 values.push_back(0.0);
1613 fieldPtrs.push_back(model->MakeField<Double_t>(basename.Data()));
1620void QwHelicity::FillNTupleVector(std::vector<Double_t>& values)
const
1632 for (
size_t i=0; i<
fWord.size(); i++)
1633 values[index++] =
fWord[i].fValue;
1643 for (
size_t i=0; i<
fWord.size(); i++){
1644 values[index++] =
fWord[i].fValue;
1650#ifdef __USE_DATABASE__
1653 if (type==
"yield" || type==
"asymmetry")
1673 Bool_t status =
false;
1711 const UInt_t IB1 = 1;
1712 const UInt_t IB3 = 4;
1713 const UInt_t IB4 = 8;
1714 const UInt_t IB24 = 8388608;
1715 const UInt_t MASK = IB1+IB3+IB4+IB24;
1727 ranseed = (((ranseed^MASK) << 1)|IB1);
1744 UInt_t bit7 = (ranseed & 0x00000040) != 0;
1745 UInt_t bit28 = (ranseed & 0x08000000) != 0;
1746 UInt_t bit29 = (ranseed & 0x10000000) != 0;
1747 UInt_t bit30 = (ranseed & 0x20000000) != 0;
1749 UInt_t result = (bit30 ^ bit29 ^ bit28 ^ bit7) & 0x1;
1755 ranseed = ( (ranseed << 1) | result ) & 0x3FFFFFFF;
1764 QwDebug <<
" Entering QwHelicity::GetRandomSeed \n";
1781 for(
size_t i=1;i<25;i++)
1782 std::cout << i <<
" : " << first24randbits[i] <<
"\n";
1785 for(
size_t i=24;i>=5;i--) b[i]= first24randbits[24-i+1];
1788 b[4] = first24randbits[21]^b[24];
1789 b[3] = first24randbits[22]^b[24]^b[23];
1790 b[2] = first24randbits[23]^b[23]^b[22];
1791 b[1] = first24randbits[24]^b[21]^b[22]^b[24];
1794 for(
size_t i=24;i>=1;i--) ranseed = (ranseed << 1) | (b[i]&1);
1796 ranseed = ranseed&0xFFFFFF;
1799 QwDebug <<
" Exiting QwHelicity::GetRandomSeed \n";
1809 Int_t ldebug = kFALSE;
1811 if(ldebug) std::cout <<
"Entering QwHelicity::RunPredictor for fEventNumber, " <<
fEventNumber
1842 Int_t localbit,indexnum,shiftnum;
1843 indexnum = TMath::FloorNint(localphase/32.);
1844 shiftnum = localphase - indexnum*32;
1861 std::cout <<
"Predicted Polarity ::: Delayed ="
1864 std::cout <<
"Predicted Helicity ::: Delayed Helicity=" <<
fHelicityDelayed
1876 Bool_t status =
false;
1891 Bool_t ldebug = kFALSE;
1892 const UInt_t ranbit_goal = 24;
1897 if (
n_ranbits==ranbit_goal)
return kTRUE;
1906 static UShort_t first24bits[25];
1917 std::cout <<
" event number" <<
fEventNumber <<
", fPatternNumber"
1926 std::cout <<
"Collected 24 random bits. Get the random seed for the predictor." <<
"\n";
1927 for(UInt_t i=0;i<ranbit_goal;i++) std::cout <<
" i:bit =" << i <<
":" << first24bits[i] <<
"\n";
1952 QwError <<
"QwHelicity::CollectRandBits We cannot handle negative delay(prediction) in the reported helicity. Exiting." <<
QwLog::endl;
1963 QwError <<
"QwHelicity::CollectRandBits, while collecting the seed, we encountered non continuous events: need to reset the seed collecting " <<
QwLog::endl
1964 <<
" event number=" <<
fEventNumber <<
", fPatternNumber="
1985 const UInt_t ranbit_goal = 30;
1989 if (
n_ranbits == ranbit_goal)
return kTRUE;
1995 QwMessage <<
"Collecting information (";
2016 QwDebug <<
"QwHelicity:: CollectRandBits30: done Collecting 30 randbits" <<
QwLog::endl;
2036 QwError <<
"QwHelicity::CollectRandBits30: We cannot handle negative delay(prediction) in the reported helicity. Exiting." <<
QwLog::endl;
2046 QwWarning <<
"QwHelicity::CollectRandBits30: While collecting the seed, we encountered non continuous events: Need to reset the seed collecting " <<
QwLog::endl;
2055 Bool_t ldebug=kFALSE;
2057 if(ldebug) std::cout <<
"Entering QwHelicity::PredictHelicity \n";
2070 if(ldebug) std::cout <<
"QwHelicity::PredictHelicity=>Predicting the helicity \n";
2078 if(ldebug) std::cout <<
"n_ranbit exiting the function = " <<
n_ranbits <<
"\n";
2093 QwWarning <<
"QwHelicity : SetHelicityDelay :: helicity delay is set to 0."
2094 <<
" Disabling helicity predictor and using reported helicity information."
2102 QwError <<
"QwHelicity::SetHelicityDelay We cannot handle negative delay in the prediction of delayed helicity. Exiting.." <<
QwLog::endl;
2140 Bool_t ldebug = kFALSE;
2148 for(
size_t i=0;i<input->
fWord.size();i++)
2149 this->
fWord[i].fValue=input->
fWord[i].fValue;
2176 std::cout <<
"QwHelicity::operator = this->fPatternNumber=" << this->
fPatternNumber << std::endl;
2177 std::cout <<
"input->fPatternNumber=" << input->
fPatternNumber <<
"\n";
2227 for (
size_t i=0; i<
fWord.size(); i++) {
2229 std::min(
fWord[i].fValue, input->
fWord[i].fValue);
2260 if(
typeid(*value)!=
typeid(*
this)) {
2272 UInt_t bitpattern = 0;
2282 }
else if (patternsize%2==0 && patternsize>0 && patternsize < 129){
2283 int num_int = TMath::CeilNint(patternsize/32.);
2286 bitpattern = 0x69969669;
2288 for (
int i = 1; i<num_int; i++){
2299 QwError <<
"QwHelicity::BuildHelicityBitPattern: "
2300 <<
"Unable to build standard bit pattern for pattern size of "
2301 << patternsize <<
". Try a pattern of 0x69."
2311 QwMessage <<
"QwHelicity::BuildHelicityBitPattern: "
2312 <<
"Built pattern 0x";
2316 QwMessage << std::dec <<
"for pattern size "
Helper functions and utilities for ROOT histogram management.
QwHistogramHelper gQwHists
Globally defined instance of the QwHistogramHelper class.
A logfile class, based on an identical class in the Hermes analyzer.
#define QwOut
Predefined log drain for explicit output.
#define QwError
Predefined log drain for errors.
#define QwWarning
Predefined log drain for warnings.
#define QwMessage
Predefined log drain for regular messages.
#define QwDebug
Predefined log drain for debugging output.
ROOT file and tree management wrapper classes.
#define REGISTER_SUBSYSTEM_FACTORY(A)
static const UInt_t kErrorFlag_Helicity
static const UInt_t kGlobalCut
static const UInt_t kEventCutMode3
Helicity state management and pattern recognition.
std::vector< TH1_ptr > fHistograms
Histograms associated with this data element.
Utility class for histogram creation and management.
static std::ostream & endl(std::ostream &)
End of the line.
Command-line and configuration file options processor.
T GetValue(const std::string &key)
Get a templated value.
bool HasValue(const std::string &key)
Has this key been defined.
po::options_description_easy_init AddOptions(const std::string &blockname="Specialized options")
Add an option to a named block or create new block.
Configuration file parser with flexible tokenization and search capabilities.
T GetTypedNextToken()
Get next token into specific type.
Bool_t PopValue(const std::string keyname, T &retvalue)
void TrimWhitespace(TString::EStripType head_tail=TString::kBoth)
void SetCommentChars(const std::string value)
Set various sets of special characters.
const std::pair< TString, TString > GetParamFileNameContents()
A helper class to manage a vector of branch entries for ROOT trees.
size_type size() const noexcept
void push_back(const std::string &name, const char type='D')
void SetValue(size_type index, Double_t val)
Word-level data manipulation and bit operations.
BankID_t fCurrentBank_ID
Bank ID (and Marker word) that is currently being processed;.
Int_t GetSubbankIndex() const
UInt_t GetEventTypeMask() const
Get event type mask.
virtual VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
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.
void SetDataLoaded(Bool_t flag)
ROCID_t fCurrentROC_ID
ROC ID that is currently being processed.
Bool_t HasDataLoaded() const
Subsystem for helicity state management and pattern recognition.
Int_t LoadEventCuts(TString filename) override
Optional event cut file.
Bool_t Compare(VQwSubsystem *source)
Int_t fNumMissedEventBlocks
void ConstructBranch(TTree *tree, TString &prefix) override
Construct the branch and tree vector.
Bool_t CheckIORegisterMask(const UInt_t &ioregister, const UInt_t &mask) const
void SetHelicityBitPattern(TString hex)
void ProcessEventInputRegisterMode()
virtual Bool_t IsGoodHelicity()
void ProcessOptions(QwOptions &options) override
Process the command line options.
void MergeCounters(VQwSubsystem *value)
void SetFirstBits(UInt_t nbits, UInt_t firstbits)
UInt_t GetRandbit30(UInt_t &ranseed)
Int_t GetHelicityDelayed()
Int_t fPatternNumberFirst
Long_t GetPatternNumber()
Int_t fDelayedPatternPolarity
Reported polarity of the current pattern.
void ClearEventData() override
Bool_t CollectRandBits30()
Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words) override
Int_t fPatternPhaseOffset
Bool_t IsGoodPatternNumber()
Int_t fPatternPhaseNumberOld
Bool_t IsGoodPhaseNumber()
virtual UInt_t GetRandbit(UInt_t &ranseed)
Int_t fPatternPhaseNumber
std::vector< QwWord > fWord
UInt_t kEventTypeHelMinus
void FillHistograms() override
Fill the histograms for this subsystem.
VQwSubsystem & operator+=(VQwSubsystem *value) override
void SetHelicityDelay(Int_t delay)
static const Int_t kUndefinedHelicity
Int_t LoadInputParameters(TString pedestalfile) override
Mandatory parameter file definition.
void SetHistoTreeSave(const TString &prefix)
virtual Bool_t CollectRandBits()
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Construct the branch and tree vector.
UInt_t GetEventcutErrorFlag() override
Return the error flag to the top level routines related to stability checks and ErrorFlag updates.
Int_t LoadChannelMap(TString mapfile) override
Mandatory map file definition.
void PrintErrorCounters() const override
Bool_t IsGoodEventNumber()
Int_t fPreviousPatternPolarity
True polarity of the previous pattern.
Int_t fHelicityDecodingMode
QwHelicity()
Private default constructor (not implemented, will throw linker error on use)
UInt_t fInputReg_HelMinus
UInt_t BuildHelicityBitPattern(Int_t patternsize)
@ kDefaultInputReg_FakeMPS
@ kDefaultInputReg_PatternSync
@ kDefaultInputReg_HelPlus
@ kDefaultInputReg_HelMinus
void CheckPatternNum(VQwSubsystem *value)
Int_t ProcessEvBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words) override
TODO: The non-event-type-aware ProcessEvBuffer routine should be replaced with the event-type-aware v...
void SetEventPatternPhase(Int_t event, Int_t pattern, Int_t phase)
void FillTreeVector(QwRootTreeBranchVector &values) const override
Fill the tree vector.
void ProcessEventUserbitMode()
Process helicity information from userbit configuration data.
VQwSubsystem & operator=(VQwSubsystem *value) override
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom) override
static const std::vector< UInt_t > kDefaultHelicityBitPattern
UInt_t fInputReg_PairSync
void ClearErrorCounters()
Int_t GetHelicityActual()
Bool_t fSuppressMPSErrorMsgs
std::vector< UInt_t > fHelicityBitPattern
UInt_t fInputReg_PatternSync
Bool_t ApplySingleEventCuts() override
Apply the single event cuts.
void ProcessEventInputMollerMode()
size_t fTreeArrayNumEntries
void ProcessEvent() override
UInt_t GetRandbit24(UInt_t &ranseed)
void AccumulateRunningSum(VQwSubsystem *value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
Update the running sums for devices.
std::vector< std::pair< Int_t, Int_t > > fWordsPerSubbank
Bool_t CollectRandBits24()
void IncrementErrorCounters() override
Increment the error counters.
Int_t GetHelicityReported()
UInt_t GetRandomSeed(UShort_t *first24randbits)
void EncodeEventData(std::vector< UInt_t > &buffer) override
Int_t fActualPatternPolarity
True polarity of the current pattern.
VQwSubsystemParity()
Private default constructor (not implemented, will throw linker error on use)
virtual void FillDB(QwParityDB *, TString)
Fill the database.
virtual void FillErrDB(QwParityDB *, TString)