Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pull_request_template.md
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:
72 changes: 27 additions & 45 deletions sbndqm/dqmAnalysis/FragmentAna/FragmentDQMAna_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,22 @@ class sbndaq::FragmentDQMAna : public art::EDAnalyzer {

private:
void analyze_fragment(artdaq::Fragment frag);
bool fVerbose;
int fReportingLevel;

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)
  {
  ...

{

//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"));
}
Expand All @@ -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)
Expand All @@ -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

Expand Down
22 changes: 9 additions & 13 deletions sbndqm/dqmAnalysis/FragmentAna/fragmentDQMAna_testing.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@ process_name: FragmentDQMAnaTesting

services: {
# TFileService: { fileName: "crt_test_1.root" }
# RedisConnection: {
# host: "icarus-db01.fnal.gov"
# }
# message: @local::standard_debug
# InitMetricManager: {
# connections: {
# #fast: @local::redis_metric_fast
# #slow: @local::redis_metric_slow
# #archive: @local::redis_metric_archive
# }
# }
RedisConnection: @local::redis_connection
# host: "icarus-db01.fnal.gov"
InitMetricManager: {
connections: {
archive: @local::redis_metric_archive
}
}
}

services.RedisConnection.host: "icarus-db01.fnal.gov"

analysis_config:
{
Verbose: true
ReportingLevel: 0
}

#source is a root file
source:
Expand Down Expand Up @@ -52,8 +48,8 @@ physics:

groups: {
PMT_cont_frag : [8204, 8208, 8206, 8203, 8200, 8202, 8209, 8194, 8214, 8199, 8211, 8213, 8198, 8215, 8205, 8212, 8201, 8210, 8192, 8196, 8195, 8197, 8207, 8193]
CRT_cont_frag : [12551, 12568, 12614, 12598, 12595, 12593, 12591, 12618, 12586, 12559, 12576, 12580, 12552, 12605, 12560, 12594, 12570, 12630, 12550, 12615, 12589, 12620, 12554, 12578, 12596, 12627, 12641, 12621, 12588, 12590, 12637, 12555, 12638, 12579, 12553, 12563, 12608, 12592, 12634, 12585, 12632, 12583, 12624, 12558, 12566, 12613, 12597, 12635, 12622, 12610, 12587, 12603, 12629, 12600, 12569, 12584, 12609, 12581, 12606, 12619, 12561, 12626, 12577, 12548, 12582, 12607, 12625, 12631, 12599, 12575, 12617, 12573, 12628, 12640, 12557, 12639, 12567, 12636, 12616, 12545, 12601, 12549, 12572, 12571, 12623, 12547, 12633, 12565, 12612, 12602, 12604, 12611, 12574]

CRT_cont_frag : [13038, 12978, 13043, 12892, 12857, 12890, 12941, 12936, 12950, 12891, 12872, 12987, 12983, 12960, 12984, 12961, 12888, 12863, 13051, 12980, 13041, 12937, 13040, 12897, 13034, 12976, 12870, 12882, 13031, 12974, 13047, 12585, 12560, 12592, 12552, 12550, 12986, 12866, 13053, 13033, 12881, 12972, 12925, 12981, 12883, 13042, 12919, 12914, 12916, 12924, 13054, 13045, 12964, 12998, 12887, 12952, 12966, 12900, 12904, 12865, 13049, 12864, 12885, 12915, 12802, 12922, 12954, 12982, 12867, 12938, 13044, 12989, 12955, 12907, 12988, 12970, 12917, 12861, 13004, 12990, 12858, 12609, 12977, 13052, 12926, 12880, 12901, 13048, 13003, 12898, 12962, 12943, 12895, 12973, 12942, 13035, 12600, 12586, 12933, 12947, 12905, 12968, 12629, 12569, 12599, 12561, 12637, 12636, 12913, 12630, 12593, 12610, 12628, 12581, 12622, 12979, 12555, 12570, 12554, 12638, 12605, 12611, 12587, 12563, 12639, 12576, 13037, 12616, 12806, 12969, 12912, 12939, 12920, 12934, 13032, 12985, 12944, 12929, 13002, 12930, 12860, 12631, 12859, 13050, 12862, 13046, 12965, 12902, 12945, 12894, 12935, 12551, 13039, 12553, 12948, 12910, 12589, 12620, 12641, 12579, 12573, 12588, 12633, 12567, 12574, 12613, 12634, 12580, 12619, 12607, 12624, 12604, 12568, 12548, 12545, 12635, 12614, 12623, 12618, 12590, 12608, 12583, 12584, 12617, 12615, 12591, 12612, 12601, 12575, 12594, 12595, 12627, 12571, 12557, 12565, 12577, 12596, 12602, 12640, 12621, 12626, 12932, 12632, 12558, 12572, 12566, 12597, 12603, 12606, 12549, 12547, 12625, 12582, 12578, 12559, 12598]
}


Expand Down