Skip to content

fragment analysis: fix zero count bug, clean up code#22

Open
wjdanswjddl wants to merge 4 commits into
area/27Apr22from
feature/moonjung_FragmentDQMAna
Open

fragment analysis: fix zero count bug, clean up code#22
wjdanswjddl wants to merge 4 commits into
area/27Apr22from
feature/moonjung_FragmentDQMAna

Conversation

@wjdanswjddl

Copy link
Copy Markdown
Contributor

Description

fix zero count bug: now gets fragment ID directly
code cleaned up: unused lines erased, comments -> verbose

Related Repository Branches

Testing details

tested with icarus data file w/ 50 events, filename: data_dl4_fstrmBNB_run7344_57_20211214T091133.root
*not: this file does not contain any empty container fragment events

@wesketchum wesketchum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! just some minor last changes to make things more configurable. I'll handle merging in and testing at ICARUS though.

}

/*****/
bool verbose = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove from here. This makes it a global variable, but it'd be better to make it part of the class and get configuration from pset. See comments below.

@@ -57,6 +58,7 @@ class sbndaq::FragmentDQMAna : public art::EDAnalyzer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add some configurable class elements (using f as a way to indicate variable is a private member of the FragmentDQMAna class)

const bool fVerbose;
const int fReportingLevel;


//Define the constructor
sbndaq::FragmentDQMAna::FragmentDQMAna(fhicl::ParameterSet const & pset)
: EDAnalyzer(pset)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can pull configuration information in here (and supply defaults):

sbndaq::FragmentDQMAna::FragmentDQMAna(fhicl::ParameterSet const & pset)
  : EDAnalyzer(pset)
  , fVerbose(pset.get<bool>("Verbose",false);
  , fReportingLevel(pset.get<int>("ReportingLevel",0)
  {
  ...

void sbndaq::FragmentDQMAna::analyze_fragment(artdaq::Fragment frag) {

artdaq::ContainerFragment cont_frag(frag);
int level = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the level declaration here.


sbndaq::sendMetric(group_name, fragment_id, "frag_count", frag_count, level, average);
sbndaq::sendMetric(group_name, fragment_id, "zero_rate", nzero, level, rate);
sbndaq::sendMetric(group_name, fragment_id, "frag_count", frag_count, level, artdaq::MetricMode::Average);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

level --> fReportingLevel now (if you use my changes above). Same on next line.

sbndaq::sendMetric(group_name, fragment_id, "zero_rate", nzero, level, artdaq::MetricMode::Rate);

std::cout << "sending: " << group_name << ":" << fragment_id << ", frag count: " << frag_count << ", nzero: " << nzero << std::endl;
if (verbose) {std::cout << "sending: " << group_name << ":" << fragment_id << ", frag count: " << frag_count << ", nzero: " << nzero << std::endl;}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verbose --> fVerbose if you use my changes above.

std::cout << std::endl;
std::cout << "Run " << evt.run() << ", subrun " << evt.subRun()<< ", event " << evt.event();
std::cout << std::endl;
if (verbose) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verbose --> fVerbose again

auto fragmentHandles = evt.getMany<artdaq::Fragments>(); //returns std::vector< art::Handle< std::vector<artdaq::Fragment> > >

std::cout << "We have " << fragmentHandles.size() << " fragment collections." << std::endl;
if (verbose) {std::cout << "We have " << fragmentHandles.size() << " fragment collections." << std::endl;}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verbose --> fVerbose (one more time!)


analysis_config:
{
verbose: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you take my changes, should now be Verbose: false (though you can also remove it, and it will default to false.

@wjdanswjddl wjdanswjddl left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've committed these changes, tested with the same data file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants