8 #include <onlmon/OnlMon.h>
9 #include <onlmon/OnlMonDB.h>
10 #include <onlmon/OnlMonServer.h>
12 #include <Event/Event.h>
13 #include <Event/msg_profile.h>
14 #include <Event/oncsSubConstants.h>
51 M.
setMapNames(
"AutoPad-R1-RevA.sch.ChannelMapping.csv",
"AutoPad-R2-RevA-Pads.sch.ChannelMapping.csv",
"AutoPad-R3-RevA.sch.ChannelMapping.csv");
65 const char *tpccalib = getenv(
"TPCCALIB");
68 std::cout <<
"TPCCALIB environment variable not set" << std::endl;
72 std::ifstream calib(fullfile);
76 printf(
"doing the Init\n");
77 tpchist1 =
new TH1F(
"tpcmon_hist1",
"test 1d histo", 101, 0., 100.);
78 tpchist2 =
new TH2F(
"tpcmon_hist2",
"test 2d histo", 101, 0., 100., 101, 0., 100.);
87 NorthSideADC_clusterXY_R1 =
new TH2F(
"NorthSideADC_clusterXY_R1" ,
"(ADC-Pedestal) > 5#sigma North Side", 400, -800, 800, 400, -800, 800);
92 NorthSideADC_clusterXY_R2 =
new TH2F(
"NorthSideADC_clusterXY_R2" ,
"(ADC-Pedestal) > 5#sigma North Side", 400, -800, 800, 400, -800, 800);
97 NorthSideADC_clusterXY_R3 =
new TH2F(
"NorthSideADC_clusterXY_R3" ,
"(ADC-Pedestal) > 5#sigma North Side", 400, -800, 800, 400, -800, 800);
103 SouthSideADC_clusterXY_R1 =
new TH2F(
"SouthSideADC_clusterXY_R1" ,
"(ADC-Pedestal) > 5#sigma South Side", 400, -800, 800, 400, -800, 800);
108 SouthSideADC_clusterXY_R2 =
new TH2F(
"SouthSideADC_clusterXY_R2" ,
"(ADC-Pedestal) > 5#sigma South Side", 400, -800, 800, 400, -800, 800);
113 SouthSideADC_clusterXY_R3 =
new TH2F(
"SouthSideADC_clusterXY_R3" ,
"(ADC-Pedestal) > 5#sigma South Side", 400, -800, 800, 400, -800, 800);
121 NorthSideADC_clusterXY_R1_unw =
new TH2F(
"NorthSideADC_clusterXY_R1_unw" ,
"(ADC-Pedestal) > 5#sigma North Side", 400, -800, 800, 400, -800, 800);
154 NorthSideADC_clusterZY =
new TH2F(
"NorthSideADC_clusterZY" ,
"(ADC-Pedestal) > 5#sigma North Side", 206, -1030, 1030, 400, -800, 800);
155 SouthSideADC_clusterZY =
new TH2F(
"SouthSideADC_clusterZY" ,
"(ADC-Pedestal) > 5#sigma South Side", 206, -1030, 1030, 400, -800, 800);
160 NorthSideADC_clusterZY_unw =
new TH2F(
"NorthSideADC_clusterZY_unw" ,
"(ADC-Pedestal) > 5#sigma North Side", 206, -1030, 1030, 400, -800, 800);
161 SouthSideADC_clusterZY_unw =
new TH2F(
"SouthSideADC_clusterZY_unw" ,
"(ADC-Pedestal) > 5#sigma South Side", 206, -1030, 1030, 400, -800, 800);
168 char ADC_vs_SAMPLE_str[100];
169 char ADC_vs_SAMPLE_xaxis_str[100];
170 sprintf(ADC_vs_SAMPLE_str,
"ADC Counts vs Sample: SECTOR %i",
MonitorServerId());
171 sprintf(ADC_vs_SAMPLE_xaxis_str,
"Sector %i: ADC Time bin [1/20MHz]",
MonitorServerId());
172 ADC_vs_SAMPLE =
new TH2F(
"ADC_vs_SAMPLE", ADC_vs_SAMPLE_str, 360, 0, 360, 256, 0, 1024);
177 char ADC_vs_SAMPLE_large_str[100];
178 char ADC_vs_SAMPLE_xaxis_large_str[100];
179 sprintf(ADC_vs_SAMPLE_large_str,
"ADC Counts vs Large Sample: SECTOR %i",
MonitorServerId());
180 sprintf(ADC_vs_SAMPLE_xaxis_large_str,
"Sector %i: ADC Time bin [1/20MHz]",
MonitorServerId());
181 ADC_vs_SAMPLE_large =
new TH2F(
"ADC_vs_SAMPLE_large", ADC_vs_SAMPLE_large_str, 1080, 0, 1080, 256, 0, 1024);
186 char sample_size_title_str[100];
187 sprintf(sample_size_title_str,
"Distribution of Sample Sizes in Events: SECTOR %i",
MonitorServerId());
188 sample_size_hist =
new TH1F(
"sample_size_hist" , sample_size_title_str, 1000, 0.5, 1000.5);
193 Check_Sums =
new TH1F(
"Check_Sums" ,
"Entries vs Fee*8 + SAMPA in Events",208,-0.5, 207.5);
194 Check_Sums->SetXTitle(
"FEE_NUM*8 + SAMPA_ADRR");
199 char checksum_title_str[100];
200 sprintf(checksum_title_str,
"Check Sum Error Probability vs Fee*8 + SAMPA in Events: SECTOR %i",
MonitorServerId());
201 Check_Sum_Error =
new TH1F(
"Check_Sum_Error" , checksum_title_str,208,-0.5, 207.5);
207 char MAXADC_str[100];
210 sprintf(MAXADC_str,
"MAX ADC per Waveform in SLIDING WINDOW: SECTOR %i",
MonitorServerId());
212 MAXADC =
new TH2F(
"MAXADC" , MAXADC_str,1025,-0.5, 1024.5,3,-0.5,2.5);
213 MAXADC->SetXTitle(
"LocalMAX ADC in Waveform [ADU]");
214 MAXADC->SetYTitle(
"Entries");
217 for(
int i = 0;
i < 3;
i++ )
219 sprintf(YLabel_str,
"R%i",
i+1);
220 MAXADC->GetYaxis()->SetBinLabel(
i+1,YLabel_str);
221 MAXADC->GetYaxis()->SetLabelSize(0.12);
222 MAXADC->GetXaxis()->SetLabelSize(0.04);
226 char RAWADC_1D_titlestr[100];
227 char MAXADC_1D_titlestr[100];
228 char SUBADC_1D_titlestr[100];
230 sprintf(RAWADC_1D_titlestr,
"RAW ADC for Sector %i R1",
MonitorServerId());
231 sprintf(MAXADC_1D_titlestr,
"MAX ADC in SLIDING WINDOW for Sector %i R1",
MonitorServerId());
232 sprintf(SUBADC_1D_titlestr,
"PEDEST_SUB RAW ADC for Sector %i R1",
MonitorServerId());
234 RAWADC_1D_R1 =
new TH1F(
"RAWADC_1D_R1",RAWADC_1D_titlestr,1025,-0.5,1024.5);
235 MAXADC_1D_R1 =
new TH1F(
"MAXADC_1D_R1",MAXADC_1D_titlestr,1025,-0.5,1024.5);
236 PEDEST_SUB_1D_R1 =
new TH1F(
"PEDEST_SUB_1D_R1",SUBADC_1D_titlestr,1125,-100.5,1024.5);
255 sprintf(RAWADC_1D_titlestr,
"RAW ADC for Sector %i R2",
MonitorServerId());
256 sprintf(MAXADC_1D_titlestr,
"MAX ADC for Sector %i R2",
MonitorServerId());
257 sprintf(SUBADC_1D_titlestr,
"PEDEST_SUB RAW ADC for Sector %i R2`",
MonitorServerId());
259 RAWADC_1D_R2 =
new TH1F(
"RAWADC_1D_R2",RAWADC_1D_titlestr,1025,-0.5,1024.5);
260 MAXADC_1D_R2 =
new TH1F(
"MAXADC_1D_R2",MAXADC_1D_titlestr,1025,-0.5,1024.5);
261 PEDEST_SUB_1D_R2 =
new TH1F(
"PEDEST_SUB_1D_R2",SUBADC_1D_titlestr,1125,-100.5,1024.5);
280 sprintf(RAWADC_1D_titlestr,
"RAW ADC for Sector %i R3",
MonitorServerId());
281 sprintf(MAXADC_1D_titlestr,
"MAX ADC for Sector %i R3",
MonitorServerId());
282 sprintf(SUBADC_1D_titlestr,
"PEDEST_SUB RAW ADC for Sector %i R3",
MonitorServerId());
284 RAWADC_1D_R3 =
new TH1F(
"RAWADC_1D_R3",RAWADC_1D_titlestr,1025,-0.5,1024.5);
285 MAXADC_1D_R3 =
new TH1F(
"MAXADC_1D_R3",MAXADC_1D_titlestr,1025,-0.5,1024.5);
286 PEDEST_SUB_1D_R3 =
new TH1F(
"PEDEST_SUB_1D_R3",SUBADC_1D_titlestr,1125,-100.5,1024.5);
306 char Layer_ChannelPhi_ADC_weighted_title_str[256];
307 sprintf(Layer_ChannelPhi_ADC_weighted_title_str,
"Layer vs Channel Phi");
309 Layer_ChannelPhi_ADC_weighted =
new TH2F(
"Layer_ChannelPhi_ADC_weighted",Layer_ChannelPhi_ADC_weighted_title_str,4610,-2305.5,2304.5,61,-0.5,59.5);
383 std::cout <<
"TpcMon::process_event - Event not found" << std::endl;
389 std::cout <<
"TpcMon::process_event - Special Event type >= 8, moving on" << std::endl;
394 float North_Side_Arr[36] = {0};
395 float South_Side_Arr[36] = {0};
397 std::vector<int> store_ten;
398 std::vector<int> median_and_stdev_vec;
405 int firstpacket=4001;
412 int lastpacket = firstpacket+232;
415 for(
int packet = firstpacket; packet < lastpacket; packet++)
427 int nr_of_waveforms = p->
iValue(0,
"NR_WF");
430 bool is_channel_stuck = 0;
432 for(
int wf = 0; wf < nr_of_waveforms; wf++)
450 int fee = p->
iValue(wf,
"FEE");
451 int sampaAddress = p->
iValue(wf,
"SAMPAADDRESS");
452 int checksumError = p->
iValue(wf,
"CHECKSUMERROR");
458 int nr_Samples = p->
iValue(wf,
"SAMPLES");
464 int FEE_R[26]={2, 2, 1, 1, 1, 3, 3, 3, 3, 3, 3, 2, 2, 1, 2, 2, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3};
469 int FEE_map[26]={4, 5, 0, 2, 1, 11, 9, 10, 8, 7, 6, 0, 1, 3, 7, 6, 5, 4, 3, 2, 0, 2, 1, 3, 5, 4};
478 int feeM = FEE_map[fee];
479 if(FEE_R[fee]==2) feeM += 6;
480 if(FEE_R[fee]==3) feeM += 14;
483 double R =
M.
getR(feeM, channel);
511 int mid = floor(nr_Samples/2);
517 is_channel_stuck = 1;
519 for(
int si=0;si < nr_Samples; si++ )
521 median_and_stdev_vec.push_back(p->
iValue(wf,si));
528 float noise = result.second;
533 float pedest_sub_wf_max = 0.;
535 for(
int s =0;
s < nr_Samples ;
s++ )
544 if( adc > wf_max){ wf_max = adc; t_max =
s; pedest_sub_wf_max = adc -
pedestal;}
546 if(
s >= 10 &&
s <= 19)
548 store_ten.push_back(adc);
556 store_ten.erase(store_ten.begin());
557 store_ten.push_back(adc);
559 int max_of_previous_10 = *max_element(store_ten.begin(), store_ten.end());
561 if(adc == max_of_previous_10 && (checksumError == 0 && is_channel_stuck == 0))
571 if( checksumError == 0 && is_channel_stuck == 0)
593 if( ((
serverid < 12 && (pedest_sub_wf_max) > 5.0*noise)) && layer != 0 )
601 else if( (
serverid >=12 && (pedest_sub_wf_max) > 5.0*noise) && layer != 0)
611 is_channel_stuck = 0;
615 median_and_stdev_vec.clear();
630 tpchist2->Fill((
float) idummy, (
float) idummy, 1.);
639 for(
int tpciter = 1; tpciter < 73 ; tpciter++){
641 Locate(tpciter, &r, &theta);
659 if( fee_id == 2 || fee_id == 3 || fee_id == 4 || fee_id == 13 || fee_id == 16 || fee_id == 17 ){mod_id = 0;}
661 else if( fee_id == 0 || fee_id == 1 || fee_id == 11 || fee_id == 12 || fee_id == 14 || fee_id == 15 || fee_id == 18 || fee_id == 19 ){mod_id = 1;}
663 else if( fee_id == 5 || fee_id == 6 || fee_id ==7 || fee_id == 8 || fee_id == 9 || fee_id == 10 || fee_id == 20 || fee_id == 21 || fee_id == 22 || fee_id == 23 || fee_id == 24 || fee_id == 25 ){mod_id = 2;}
675 if( fee_id == 2 || fee_id == 3 || fee_id == 4 || fee_id == 13 || fee_id == 16 || fee_id == 17 ){mod_id = 3*sec_id + 0;}
677 else if( fee_id == 0 || fee_id == 1 || fee_id == 11 || fee_id == 12 || fee_id == 14 || fee_id == 15 || fee_id == 18 || fee_id == 19 ){mod_id = 3*sec_id + 1;}
679 else if( fee_id == 5 || fee_id == 6 || fee_id ==7 || fee_id == 8 || fee_id == 9 || fee_id == 10 || fee_id == 20 || fee_id == 21 || fee_id == 22 || fee_id == 23 || fee_id == 24 || fee_id == 25 ){mod_id = 3*sec_id + 2;}
688 float CSIDE_angle_bins[12] = { 0.1*2.*TMath::Pi()/12 , 1.1*2.*TMath::Pi()/12 , 2.1*2.*TMath::Pi()/12 , 3.1*2.*TMath::Pi()/12 , 4.1*2.*TMath::Pi()/12 , 5.1*2.*TMath::Pi()/12 , 6.1*2.*TMath::Pi()/12 , 7.1*2.*TMath::Pi()/12 , 8.1*2.*TMath::Pi()/12 , 9.1*2.*TMath::Pi()/12 , 10.1*2.*TMath::Pi()/12 , 11.1*2.*TMath::Pi()/12 };
690 float ASIDE_angle_bins[12] = { 6.1*2.*TMath::Pi()/12 , 5.1*2.*TMath::Pi()/12 , 4.1*2.*TMath::Pi()/12 , 3.1*2.*TMath::Pi()/12 , 2.1*2.*TMath::Pi()/12 , 1.1*2.*TMath::Pi()/12 , 0.1*2.*TMath::Pi()/12 , 11.1*2.*TMath::Pi()/12 , 10.1*2.*TMath::Pi()/12 , 9.1*2.*TMath::Pi()/12 , 8.1*2.*TMath::Pi()/12 , 7.1*2.*TMath::Pi()/12 };
707 *thbin = CSIDE_angle_bins[TMath::FloorNint((
id-1)/3)];
710 *thbin = ASIDE_angle_bins[TMath::FloorNint((
id-37)/3)];
714 int TpcMon::Max_Nine(
int one,
int two,
int three,
int four,
int five,
int six,
int seven,
int eight,
int nine)
717 int nine_array[9] = {one, two, three, four, five, six, seven, eight, nine};
719 for(
int i = 0;
i < 9;
i++ )
721 if( nine_array[
i] > max ){max = nine_array[
i];}
730 if(server_id >= 12){side_id=1;}
739 std::vector<int> sortedValues =
values;
740 std::sort(sortedValues.begin(), sortedValues.end());
741 size_t size = sortedValues.size();
746 median = (sortedValues[size / 2 - 1] + sortedValues[size / 2]) / 2.0;
750 median = sortedValues[size / 2];
753 std::vector<int> selectedValues;
756 for (
int value : values) {
757 if (
value >= median - 40 &&
value <= median + 40)
759 selectedValues.push_back(
value);
765 for (
int value : selectedValues)
769 float mean = sum / selectedValues.size();
772 float sumSquares = 0.0;
775 for (
int value : selectedValues)
778 sumSquares += std::pow(diff, 2);
780 float variance = sumSquares / selectedValues.size();
781 float stdDev = std::sqrt(variance);
783 return std::make_pair(median, stdDev);