-
Notifications
You must be signed in to change notification settings - Fork 3
fragment analysis: fix zero count bug, clean up code #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wjdanswjddl
wants to merge
4
commits into
area/27Apr22
Choose a base branch
from
feature/moonjung_FragmentDQMAna
base: area/27Apr22
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ### Description | ||
|
|
||
| Put description of request here. Include _Fixes #XXX_ to link to an issue. | ||
|
|
||
| _If the full description is in a PR from a different repo, simply link that here, and delete the rest._ | ||
|
|
||
| ### Related Repository Branches | ||
|
|
||
| List related branches from other repos here (links to PRs even better!), if not linked above. | ||
|
|
||
| ### Testing details | ||
| _(Note: edit as appropriate.)_ | ||
| - *Where it was tested*: (e.g. SBN-FD, SBN-ND, DAB, etc.) | ||
| - *Run number associated with test*: | ||
| - Other information: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,14 +54,22 @@ class sbndaq::FragmentDQMAna : public art::EDAnalyzer { | |
|
|
||
| private: | ||
| void analyze_fragment(artdaq::Fragment frag); | ||
| bool fVerbose; | ||
| int fReportingLevel; | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| //Define the constructor | ||
| sbndaq::FragmentDQMAna::FragmentDQMAna(fhicl::ParameterSet const & pset) | ||
| : EDAnalyzer(pset) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can pull configuration information in here (and supply defaults): |
||
| { | ||
|
|
||
| //configuration | ||
| fVerbose = pset.get<bool>("Verbose",false); | ||
| fReportingLevel = pset.get<int>("ReportingLevel",0); | ||
|
|
||
|
|
||
| if (pset.has_key("metrics")) { | ||
| sbndaq::InitializeMetricManager(pset.get<fhicl::ParameterSet>("metrics")); | ||
| } | ||
|
|
@@ -76,64 +84,50 @@ sbndaq::FragmentDQMAna::~FragmentDQMAna() | |
| //analyze_fragment | ||
| void sbndaq::FragmentDQMAna::analyze_fragment(artdaq::Fragment frag) { | ||
|
|
||
| artdaq::ContainerFragment cont_frag(frag); | ||
|
|
||
| unsigned int const fragid = frag.fragmentID(); | ||
| std::string fragment_id = std::to_string(fragid); | ||
|
|
||
| artdaq::ContainerFragment cont_frag(frag); | ||
| //get frag count | ||
| uint64_t frag_count = cont_frag.block_count(); | ||
| //get zero rate | ||
| uint64_t nzero; | ||
| uint64_t nzero = 0; | ||
| if (frag_count == 0) { nzero = 1; } | ||
| if (frag_count > 0) { nzero = 0; } | ||
|
|
||
| unsigned int const fragid = (cont_frag[0].get() -> fragmentID()); | ||
| std::string fragment_id = std::to_string(fragid); | ||
| int level = 2; | ||
| artdaq::MetricMode average = artdaq::MetricMode::Average; | ||
| artdaq::MetricMode rate = artdaq::MetricMode::Rate; | ||
| std::string group_name = "unknown_cont_frag"; | ||
|
|
||
| if (cont_frag.fragment_type() == 2) { | ||
| std::string group_name = "PMT_cont_frag"; | ||
| if (cont_frag.fragment_type() == sbndaq::detail::FragmentType::CAENV1730) {group_name = "PMT_cont_frag";} | ||
| else if (cont_frag.fragment_type() == sbndaq::detail::FragmentType::BERNCRTV2) {group_name = "CRT_cont_frag";} | ||
|
|
||
| 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, fReportingLevel, artdaq::MetricMode::Average); | ||
| sbndaq::sendMetric(group_name, fragment_id, "zero_rate", nzero, fReportingLevel, artdaq::MetricMode::Rate); | ||
|
|
||
| //std::cout << "sending: " << group_name << ":" << fragment_id << ", frag count: " << frag_count << ", nzero: " << nzero << std::endl; | ||
| if (fVerbose) {std::cout << "sending: " << group_name << ":" << fragment_id << ", frag count: " << frag_count << ", nzero: " << nzero << std::endl;} | ||
|
|
||
| } | ||
|
|
||
| if (cont_frag.fragment_type() == 14) { | ||
| std::string group_name = "CRT_cont_frag"; | ||
|
|
||
| sbndaq::sendMetric(group_name, fragment_id, "frag_count", frag_count, level, average); | ||
| sbndaq::sendMetric(group_name, fragment_id, "zero_rate", nzero, level, rate); | ||
|
|
||
| std::cout << "sending: " << group_name << ":" << fragment_id << ", frag count: " << frag_count << ", nzero: " << nzero << std::endl; | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
|
|
||
| //analyze | ||
| void sbndaq::FragmentDQMAna::analyze(art::Event const & evt) { | ||
|
|
||
| std::cout << "######################################################################" << std::endl; | ||
| std::cout << std::endl; | ||
| std::cout << "Run " << evt.run() << ", subrun " << evt.subRun()<< ", event " << evt.event(); | ||
| std::cout << std::endl; | ||
| if (fVerbose) { | ||
| std::cout << "######################################################################" << std::endl; | ||
| std::cout << std::endl; | ||
| std::cout << "Run " << evt.run() << ", subrun " << evt.subRun()<< ", event " << evt.event(); | ||
| std::cout << std::endl; | ||
| } | ||
|
|
||
| //save fragment counts for the event in a vector | ||
| std::vector<double> fragment_count; | ||
| std::vector<double> fragment_ID; | ||
|
|
||
| //loop over fragments in event | ||
| //two different loop logics, depending on whether we have fragment containers or fragments | ||
| 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 (fVerbose) {std::cout << "We have " << fragmentHandles.size() << " fragment collections." << std::endl;} | ||
|
|
||
| for (auto const& handle : fragmentHandles) { | ||
|
|
||
| //handle is art::Handle< std::vector<artdaq::Fragment> > | ||
|
|
||
| if (!handle.isValid() || handle->size() == 0) | ||
|
|
@@ -149,18 +143,6 @@ void sbndaq::FragmentDQMAna::analyze(art::Event const & evt) { | |
| artdaq::ContainerFragment cont_frag(frag); | ||
| analyze_fragment(frag); | ||
|
|
||
| //std::cout << "Container fragment type is " << (unsigned int)cont_frag.fragment_type() << std::endl; | ||
| //2:PMT, 14: CRT | ||
|
|
||
| // all fragments in one container fragment have the same fragment ID | ||
| //std::cout << "Container fragment ID is " << cont_frag[0].get() -> fragmentID() << std::endl; | ||
| //std::cout << "container fragment has " << (unsigned int)cont_frag.block_count() << " fragments" << std::endl; | ||
|
|
||
|
|
||
| fragment_count.push_back((unsigned int)cont_frag.block_count()); | ||
| fragment_ID.push_back(cont_frag[0].get()->fragmentID()); | ||
|
|
||
|
|
||
| }//end loop over handle | ||
| }//end loop over all handles | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
fas a way to indicate variable is a private member of the FragmentDQMAna class)