StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
stage_0_202103.cxx
1 #include <stdio.h>
2 #include "fcs_trg_base.h"
3 
4 
5 /*
6  Changed from 8-timebin sum to highest ADC + 1 closes timebin.
7 
8  Also added simple peak-finding -- the maximum of the data
9  can't be on timebin 0 or 7.
10 
11 */
12 
13 // Running in FY21 as V02
14 
15 void fcs_trg_base::stage_0_202103(adc_tick_t adc, geom_t geo, ped_gain_t *pg, u_int *dta_out)
16 {
17  int sum = 0 ;
18  int peak = 0 ;
19  int last = 0 ;
20 
21  for(int tb=0;tb<8;tb++) {
22  u_short radc = adc.d[tb] ;
23 
24  switch(tb) {
25  case 0 :
26  last = radc ;
27  sum = radc ;
28  peak = 0 ;
29  break ;
30  case 1 :
31  if(radc>sum) peak |= 1 ;
32  sum += radc ;
33  last = radc ;
34  break ;
35  case 2 :
36  sum += radc ;
37  last = radc ;
38  break ;
39  case 3 :
40  sum += radc ;
41  last = radc ;
42  break ;
43  case 4 :
44  sum += radc ;
45  last = radc ;
46  break ;
47  case 5 :
48  sum += radc ;
49  last = radc ;
50  break ;
51  case 6 :
52  sum += radc ;
53  last = radc ;
54  break ;
55  case 7 :
56  default :
57  //printf("radc %d, last %d, peak %d\n",radc,last,peak) ;
58 
59  if(radc>=last && peak==0) {
60  sum = 0 ;
61  }
62  else {
63  sum += radc ;
64 
65  sum -= pg?pg->ped:0 ; // ped is now only 3*ch_ped!
66  if(sum < 0) sum = 0 ;
67 
68  if(sum>0 && fcs_trgDebug>=2){
69  if(geo.det<2){
70  printf("ns=%1d det=%1d dep=%2d ch=%2d sum=%6d gain=%6d s*g=%6d pT=%8.5f\n",
71  geo.ns,geo.det,geo.dep,geo.ch,
72  sum,pg->gain,(sum*pg->gain)>>8,
73  0.00024711*((sum*pg->gain)>>8) );
74  }else{
75  printf("ns=%1d det=%1d dep=%2d ch=%2d sum=%6d gain=%6d s*g=%6d MIP=%5.3f\n",
76  geo.ns,geo.det,geo.dep,geo.ch,
77  sum,pg->gain,(sum*pg->gain)>>8,
78  float((sum*pg->gain)>>8)/100.0);
79  }
80  }
81 
82  sum *= pg?pg->gain:0x100 ; // note that in FY21+ gain==1.0 is 0x100
83  sum >>= 8 ; // see note above
84 
85  }
86 
87  break ;
88  }
89  }
90 
91  //printf("... IN S0: %d\n",sum) ;
92 
93  *dta_out = sum ;
94 }