8 #include "art/Framework/Core/EDAnalyzer.h"
9 #include "art/Framework/Core/ModuleMacros.h"
10 #include "art/Framework/Principal/Event.h"
11 #include "art/Framework/Principal/Handle.h"
13 #include "canvas/Utilities/Exception.h"
15 #include "sbndaq-artdaq-core/Overlays/Common/BernCRTFragment.hh"
16 #include "artdaq-core/Data/Fragment.hh"
17 #include "artdaq-core/Data/ContainerFragment.hh"
18 #include "sbndaq-artdaq-core/Overlays/FragmentType.hh"
20 #include "sbndaq-artdaq-core/Overlays/Common/BernCRTTranslator.hh"
23 #include "art_root_io/TFileService.h"
39 class CrtNoiseMonTool;
142 return (hit.fragment_ID & 0x3100) == 0x3100;
148 std::vector<icarus::crt::BernCRTTranslator> hit_vector;
150 auto fragmentHandles = evt.getMany<artdaq::Fragments>();
151 for (
auto handle : fragmentHandles) {
152 if (!handle.isValid() || handle->size() == 0)
155 auto this_hit_vector = icarus::crt::BernCRTTranslator::getCRTData(*handle);
157 hit_vector.insert(hit_vector.end(),this_hit_vector.begin(),this_hit_vector.end());
161 for(
auto &
hit : hit_vector) {
163 uint8_t mac5 =
hit.mac5;
165 if(
hit.flags==7)
continue;
167 const uint64_t runtime = (
hit.this_poll_start-
hit.run_start_time) *1.0
e-9;
168 const double dt = (
hit.this_poll_start-
hit.last_poll_start)*1.0
e-9;
169 const float rate = 1.0e-3*
hit.hits_in_poll/dt;
175 if(macToRateSideTime[mac5].
size()!=0 && macToRateSideTime[mac5].back() == runtime)
continue;
176 macToRateSideTime[mac5].push_back(runtime);
177 macToRateSide[mac5].push_back(rate);
180 if(macToRateTopTime[mac5].
size()!=0 && macToRateTopTime[mac5].back() == runtime)
continue;
181 macToRateTopTime[mac5].push_back(runtime);
182 macToRateTop[mac5].push_back(rate);
190 art::ServiceHandle<art::TFileService>
tfs;
243 for(
auto it=macToRateSide.begin(); it!=macToRateSide.end(); it++){
245 uint8_t mac = (*it).first;
248 std::string htitle =
"noise rate: mac5 "+
std::to_string(mac)+
" [Side CRT]";
249 TH1F *
h = tfs->make<TH1F>(hname.c_str(),htitle.c_str(),4000,0.0,40.0);
250 h->GetXaxis()->SetTitle(
"rate [kHz]");
251 h->GetXaxis()->SetTitleSize(0.04);
252 h->GetXaxis()->SetLabelSize(0.04);
253 h->GetYaxis()->SetLabelSize(0.04);
256 const size_t n = macToRateSide[mac].size();
257 float* rate =
new float[
n];
258 float* time =
new float[
n];
260 for(
size_t i=0; i<
n; i++){
261 rate[i] = macToRateSide[mac][i];
262 time[i] = macToRateSideTime[mac][i];
267 std::cout <<
"mean rate before division: " << meanRate << std::endl;
269 std::cout <<
"mean rate averaged over " << n <<
" points: " << meanRate << std::endl;
272 std::cout <<
"relative (to 30kHz) average "+htitle <<
" = " << meanRate << std::endl;
275 std::string gtitle =
"noise rate: mac5 "+
std::to_string(mac)+
" [Side CRT]";
276 TGraph *
g = tfs->make<TGraph>(
n,time,rate);
277 g->SetName(gname.c_str());
278 g->SetTitle(gtitle.c_str());
279 g->GetXaxis()->SetTitle(
"run time [s]");
280 g->GetYaxis()->SetTitle(
"rate [kHz]");
281 g->GetXaxis()->SetTitleSize(0.04);
282 g->GetYaxis()->SetTitleSize(0.04);
283 g->GetXaxis()->SetLabelSize(0.04);
284 g->GetYaxis()->SetLabelSize(0.04);
286 g->SetMarkerStyle(8);
295 for(
auto it=macToRateTop.begin(); it!=macToRateTop.end(); it++){
297 uint8_t mac = (*it).first;
300 std::string htitle =
"noise rate: mac5 "+
std::to_string(mac)+
" [Top CRT]";
301 TH1F *
h = tfs->make<TH1F>(hname.c_str(),htitle.c_str(),4000,0.0,40.0);
302 h->GetXaxis()->SetTitle(
"rate [kHz]");
303 h->GetXaxis()->SetTitleSize(0.04);
304 h->GetXaxis()->SetLabelSize(0.04);
305 h->GetYaxis()->SetLabelSize(0.04);
308 const size_t n = macToRateTop[mac].size();
309 float* rate =
new float[
n];
310 float* time =
new float[
n];
312 for(
size_t i=0; i<
n; i++){
313 rate[i] = macToRateTop[mac][i];
314 time[i] = macToRateTopTime[mac][i];
319 std::cout <<
"mean rate before division: " << meanRate << std::endl;
321 std::cout <<
"mean rate averaged over " << n <<
" points: " << meanRate << std::endl;
324 std::cout <<
"relative (to 30kHz) average "+htitle <<
" = " << meanRate << std::endl;
327 std::string gtitle =
"noise rate: mac5 "+
std::to_string(mac)+
" [Top CRT]";
328 TGraph *
g = tfs->make<TGraph>(
n,time,rate);
329 g->SetName(gname.c_str());
330 g->SetTitle(gtitle.c_str());
331 g->GetXaxis()->SetTitle(
"run time [s]");
332 g->GetYaxis()->SetTitle(
"rate [kHz]");
333 g->GetXaxis()->SetTitleSize(0.04);
334 g->GetYaxis()->SetTitleSize(0.04);
335 g->GetXaxis()->SetLabelSize(0.04);
336 g->GetYaxis()->SetLabelSize(0.04);
338 g->SetMarkerStyle(8);
std::size_t size(FixedBins< T, C > const &) noexcept
std::string to_string(WindowPattern const &pattern)
art::ServiceHandle< art::TFileService > tfs
BEGIN_PROLOG could also be cout