Skip to content

Commit

Permalink
Merge pull request #187 from pjwinnetou/master
Browse files Browse the repository at this point in the history
IPA function to get # of valid FEEs w/o accessing waveform info
  • Loading branch information
mpurschke authored Aug 31, 2024
2 parents e97682f + 85bcb32 commit ee6c6bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions newbasic/oncsSub_idtpcfeev4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ int oncsSub_idtpcfeev4::tpc_gtm_decode()

if (_is_gtm_decoded ) return 0;
_is_gtm_decoded = 1;
NR_VALIDFEE=0;

unsigned int payload_length = 2 * (getLength() - SEVTHEADERLENGTH - getPadding() );

unsigned int index = 0;

unsigned short *buffer = ( unsigned short *) &SubeventHdr->data;
std::bitset<26> fee_seen;


// demultiplexer
while (index < payload_length)
Expand All @@ -124,11 +127,15 @@ int oncsSub_idtpcfeev4::tpc_gtm_decode()
{

unsigned int fee_id = buffer[index] & 0xff;
if (!fee_seen[fee_id]) {
fee_seen[fee_id] = true;
NR_VALIDFEE++;
}
// coutfl << " index = " << index << " fee_id = " << fee_id << " len = " << datalength << endl;
++index;
if (fee_id < MAX_FEECOUNT)
{
index += datalength;
index += datalength;
}
if (index >= payload_length) break;
}
Expand All @@ -139,7 +146,7 @@ int oncsSub_idtpcfeev4::tpc_gtm_decode()
// memcpy?
for (unsigned int i = 0; i < 16; i++)
{
buf[i] = buffer[index++];
buf[i] = buffer[index++];
}

decode_gtm_data(buf);
Expand Down Expand Up @@ -338,6 +345,12 @@ long long oncsSub_idtpcfeev4::lValue(const int n, const char *what)
{
return gtm_data.size();
}

else if ( strcmp(what,"NR_VALIDFEE") == 0 )
{
return NR_VALIDFEE;
}


else if (strcmp(what, "TAGGER_TYPE") == 0 )
{
Expand Down
2 changes: 2 additions & 0 deletions newbasic/oncsSub_idtpcfeev4.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "oncsSubevent.h"
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <limits>
Expand Down Expand Up @@ -56,6 +57,7 @@ class oncsSub_idtpcfeev4 : public oncsSubevent_w2 {
int decode_gtm_data(unsigned short gtm[16]);

int _broken;
unsigned long NR_VALIDFEE = 0;

int _is_decoded{0};
int _is_gtm_decoded{0};
Expand Down

0 comments on commit ee6c6bd

Please sign in to comment.