4 #include <onlmon/OnlMon.h>
5 #include <onlmon/OnlMonServer.h>
7 #include <Event/msg_profile.h>
8 #include <Event/Event.h>
34 std::vector<double>
out;
35 std::transform( point_list.begin(), point_list.end(), std::back_inserter( out ), [](
const auto&
p ) {
return p.first; } );
42 std::vector<double>
out;
43 std::transform( point_list.begin(), point_list.end(), std::back_inserter( out ), [](
const auto&
p ) {
return p.second; } );
54 const auto tpotcalib = getenv(
"TPOTCALIB");
57 std::cout <<
"TpotMon::TpotMon - TPOTCALIB environment variable not set" << std::endl;
71 std::cout <<
"TpotMon::Init - m_max_sample: " <<
m_max_sample << std::endl;
79 std::cout <<
"TpotMon::Init -"
81 <<
" No calibration loaded"
90 for(
const auto& fee_id:fee_id_list )
98 m_counters =
new TH1F(
"m_counters",
"counters", 10, 0, 10 );
105 m_detector_multiplicity_phi =
new TH2Poly(
"m_detector_multiplicity_phi",
"multiplicity (#phi); z (cm); x (cm)", -120, 120, -60, 60 );
106 m_detector_occupancy_phi =
new TH2Poly(
"m_detector_occupancy_phi",
"occupancy (#phi); z (cm); x (cm);occupancy (%)", -120, 120, -60, 60 );
109 m_detector_multiplicity_z =
new TH2Poly(
"m_detector_multiplicity_z",
"multiplicity (z); z (cm); x (cm)", -120, 120, -60, 60 );
110 m_detector_occupancy_z =
new TH2Poly(
"m_detector_occupancy_z",
"occupancy (z); z (cm); x(cm);occupancy (%)", -120, 120, -60, 60 );
117 h->GetXaxis()->SetTitleOffset(1);
118 h->GetYaxis()->SetTitleOffset(0.65);
123 m_resist_multiplicity_phi =
new TH2Poly(
"m_resist_multiplicity_phi",
"multiplicity (#phi); z (cm); x (cm)", -120, 120, -60, 60 );
124 m_resist_occupancy_phi =
new TH2Poly(
"m_resist_occupancy_phi",
"occupancy (#phi); z (cm); x (cm);occupancy (%)", -120, 120, -60, 60 );
127 m_resist_multiplicity_z =
new TH2Poly(
"m_resist_multiplicity_z",
"multiplicity (z); z (cm); x (cm)", -120, 120, -60, 60 );
128 m_resist_occupancy_z =
new TH2Poly(
"m_resist_occupancy_z",
"occupancy (z); z (cm); x(cm);occupancy (%)", -120, 120, -60, 60 );
135 h->GetXaxis()->SetTitleOffset(1);
136 h->GetYaxis()->SetTitleOffset(0.65);
143 h->GetXaxis()->SetTitleOffset(1);
144 h->GetYaxis()->SetTitleOffset(0.65);
148 for(
const auto& fee_id:fee_id_list )
157 Form(
"m_counts_sample_%s", detector_name.c_str() ),
158 Form(
"hit count vs sample (%s);sample;counts", detector_name.c_str() ),
160 h->GetXaxis()->SetTitleOffset(1.);
161 h->GetYaxis()->SetTitleOffset(1.65);
167 Form(
"m_adc_sample_%s", detector_name.c_str() ),
168 Form(
"adc count vs sample (%s);sample;adc", detector_name.c_str() ),
171 h->GetXaxis()->SetTitleOffset(1.);
172 h->GetYaxis()->SetTitleOffset(1.65);
173 se->registerHisto(
this, detector_histograms.
m_adc_sample);
177 static constexpr
double max_hit_charge = 1024;
179 Form(
"m_hit_charge_%s", detector_name.c_str() ),
180 Form(
"hit charge distribution (%s);adc", detector_name.c_str() ),
181 100, 0, max_hit_charge );
182 se->registerHisto(
this, detector_histograms.
m_hit_charge);
186 Form(
"m_hit_multiplicity_%s", detector_name.c_str() ),
187 Form(
"hit multiplicity (%s);#hits", detector_name.c_str() ),
193 Form(
"m_hit_vs_channel_%s", detector_name.c_str() ),
194 Form(
"hit profile (%s);channel", detector_name.c_str() ),
221 auto increment = []( TH1*
h,
int bin,
double weight = 1.0 )
222 { h->SetBinContent(bin, h->GetBinContent(bin)+weight ); };
228 if( !event ) {
return 0; }
240 double fullevent_weight = 0;
243 std::unique_ptr<Packet> packet(event->
getPacket(packet_id));
248 { std::cout <<
"TpotMon::process_event - packet " << packet_id <<
" not found" << std::endl; }
253 const auto n_waveforms = packet->iValue(0,
"NR_WF" );
263 { std::cout <<
"TpotMon::process_event - n_waveforms: " << n_waveforms << std::endl; }
264 for(
int i=0;
i<n_waveforms; ++
i )
266 auto channel = packet->iValue(
i,
"CHANNEL" );
267 int fee_id = packet->iValue(
i,
"FEE" );
268 int samples = packet->iValue(
i,
"SAMPLES" );
278 std::cout <<
"TpotMon::process_event - invalid fee_id: " << fee_id << std::endl;
281 const auto& detector_histograms = iter->second;
290 <<
"TpotMon::process_event -"
291 <<
" waveform: " <<
i
292 <<
" fee: " << fee_id
294 <<
" samples: " << samples
298 for(
int is = 0; is < samples; ++is )
300 const auto adc = packet->iValue(
i, is );
302 if( is_signal ) detector_histograms.m_counts_sample->Fill( is );
303 detector_histograms.m_adc_sample->Fill( is, adc );
304 detector_histograms.m_hit_charge->Fill( adc );
308 bool is_signal =
false;
311 const auto adc = packet->iValue(
i, is );
323 detector_histograms.m_hit_vs_channel->Fill( strip_index );
326 ++multiplicity[fee_id];
329 switch( segmentation )
351 { detector_histograms.m_hit_multiplicity->Fill( multiplicity[fee_id] ); }
354 auto copy_content = []( TH2Poly*
source, TH2Poly* destination,
double scale )
356 for(
int bin = 0; bin < source->GetNumberOfBins(); ++bin )
357 { destination->SetBinContent( bin+1, source->GetBinContent( bin+1 )*scale ); }
385 for( TH1*
h:std::initializer_list<TH1*>{hlist.m_counts_sample, hlist.m_adc_sample, hlist.m_hit_charge, hlist.m_hit_multiplicity, hlist.m_hit_vs_channel } )
399 h2->AddBin( boundaries.size(), &get_x( boundaries )[0], &get_y( boundaries )[0] );
412 h2->AddBin( boundaries.size(), &get_x( boundaries )[0], &get_y( boundaries )[0] );