@@ -46,13 +46,15 @@ class sbndaq::MetricAnalyzer : public art::EDAnalyzer {
4646
4747private:
4848 std::string fmetric_instance_name;
49- std::string fmetric_module_label;
49+ std::vector<std::string> fmetric_module_labels;
50+ std::vector<int > fstream_labels;
5051
5152 std::string fspectdc_module_label;
5253 uint32_t fspectdc_etrig_ch;
5354
5455 TTree* tree;
5556 int _run, _subrun, _event;
57+ int _stream;
5658 float _flash_peakpe;
5759 float _flash_peaktime; // us
5860 float _trigger_dt; // us
@@ -66,7 +68,13 @@ sbndaq::MetricAnalyzer::MetricAnalyzer(fhicl::ParameterSet const& p)
6668 : EDAnalyzer{p} // ,
6769 // More initializers here.
6870{
69- fmetric_module_label = p.get <std::string>(" metric_module_label" ," pmtmetricproducer" );
71+ fmetric_module_labels = p.get <std::vector<std::string>>(" metric_module_labels" ,{" pmtmetricproducer" ,
72+ " pmtmetricbnbzero" ,
73+ " pmtmetricbnblight" ,
74+ " pmtmetricoffbeamzero" ,
75+ " pmtmetricoffbeamlight" ,
76+ " pmtmetriccrossingsmuon" });
77+ fstream_labels = p.get <std::vector<int >>(" stream_labels" ,{0 ,1 ,2 ,3 ,4 ,5 });
7078 fmetric_instance_name = p.get <std::string>(" metric_instance_name" ," " );
7179 fspectdc_module_label = p.get <std::string>(" spectdc_module_name" ," tdcdecoder" );
7280 fspectdc_etrig_ch = p.get <uint32_t >(" spectdc_etrig_ch" ,4 );
@@ -76,6 +84,7 @@ sbndaq::MetricAnalyzer::MetricAnalyzer(fhicl::ParameterSet const& p)
7684 tree->Branch (" run" ,&_run," run/I" );
7785 tree->Branch (" subrun" ,&_subrun," subrun/I" );
7886 tree->Branch (" event" ,&_event," event/I" );
87+ tree->Branch (" stream" ,&_stream," stream/I" );
7988 tree->Branch (" flash_peakpe" ,&_flash_peakpe," flash_peakpe/F" );
8089 tree->Branch (" flash_peaktime" ,&_flash_peaktime," flash_peaktime/F" );
8190 tree->Branch (" trigger_dt" ,&_trigger_dt," trigger_dt/F" );
@@ -91,27 +100,47 @@ void sbndaq::MetricAnalyzer::analyze(art::Event const& e)
91100 _event = e.id ().event ();
92101
93102 // initialize tree variables
103+ _stream = -1 ;
94104 _flash_peakpe = -999999999 ;
95105 _flash_peaktime = -999999999 ;
96106 _trigger_dt = -999999999 ;
97107 _timing_type = -1 ;
98108 _tdc_etrig = -999999999 ;
99109 _tdc_bes = -999999999 ;
100110
101- art::Handle<std::vector<sbnd::trigger::pmtSoftwareTrigger>> metricHandle;
102- if (fmetric_instance_name.empty ()) e.getByLabel (fmetric_module_label,metricHandle);
103- else e.getByLabel (fmetric_module_label,fmetric_instance_name,metricHandle);
104- if (!metricHandle.isValid () || metricHandle->size () == 0 ){
105- std::cout << " No Metrics found" << std::endl;
106- tree->Fill ();
111+ if (fstream_labels.size () != fmetric_module_labels.size ()){
112+ std::cout << " Error: stream labels and metric module labels are not the same size" << std::endl;
107113 return ;
108114 }
109- else {
115+
116+ bool found_metrics = false ;
117+
118+ size_t nlabels = fmetric_module_labels.size ();
119+ for (size_t i=0 ; i<nlabels; i++){
120+ auto label = fmetric_module_labels[i];
121+
122+ art::Handle<std::vector<sbnd::trigger::pmtSoftwareTrigger>> metricHandle;
123+ if (fmetric_instance_name.empty ()){
124+ e.getByLabel (label,metricHandle);
125+ }
126+ else {
127+ e.getByLabel (label,fmetric_instance_name,metricHandle);
128+ }
129+
130+ if (!metricHandle.isValid () || metricHandle->size () == 0 )
131+ continue ;
132+ found_metrics = true ;
110133 const std::vector<sbnd::trigger::pmtSoftwareTrigger> metric_v (*metricHandle);
111134 auto metric = metric_v[0 ];
112135 _trigger_dt = float (metric.trig_ts )/1e3 ;
113136 _flash_peakpe = metric.peakPE ;
114137 _flash_peaktime = metric.peaktime ;
138+ _stream = fstream_labels[i];
139+ }
140+ if (!found_metrics){
141+ std::cout << " No Metrics found" << std::endl;
142+ tree->Fill ();
143+ return ;
115144 }
116145
117146 // see if etrig exists
0 commit comments