CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataUtil.h
Go to the documentation of this file.
1#ifndef RawDataUtil_H
2#define RawDataUtil_H
3#include <iostream>
4
6public:
7
8 static double MdcTime(int timeChannel) { return ((double)timeChannel)*MDC_TIME_FACTOR; }
9 static int MdcTimeChannel (double time) { return (int)(time/MDC_TIME_FACTOR); }
10
11 static double MdcCharge(int chargeChannel) { return ((double)chargeChannel)*MDC_CHARGE_FACTOR; }
12 static int MdcChargeChannel (double charge) { return (int)(charge/MDC_CHARGE_FACTOR); }
13
14 static double CgemTime(int timeChannel) { return ((double)timeChannel)*CGEM_TIME_FACTOR; }
15 static int CgemTimeChannel (double time) { return (int)(time/CGEM_TIME_FACTOR); }
16
17 static double CgemCharge(int chargeChannel) { return ((double)chargeChannel)*CGEM_CHARGE_FACTOR; }
18 static int CgemChargeChannel (double charge) { return (int)(charge/CGEM_CHARGE_FACTOR); }
19
20 static double EmcTime(int timeChannel) { return ((double)timeChannel)/EMC_TIME_FACTOR; }
21 static int EmcTimeChannel (double time) { return (int)(time*EMC_TIME_FACTOR); }
22
23 static double EmcCharge(int measure, int chargeChannel)
24 {
25 switch(measure) {
26 case 3: //saturation of high measure
27 return ((double)chargeChannel)*EMC_CHARGE_HIGH_MEASURE/EMC_CHARGE_FACTOR;
28 break;
29 case 2:
30 return ((double)chargeChannel)*EMC_CHARGE_HIGH_MEASURE/EMC_CHARGE_FACTOR;
31 break;
32 case 1:
33 return ((double)chargeChannel)*EMC_CHARGE_MID_MEASURE/EMC_CHARGE_FACTOR;
34 break;
35 case 0:
36 return ((double)chargeChannel)*EMC_CHARGE_LOW_MEASURE/EMC_CHARGE_FACTOR;
37 break;
38 default:
39 std::cout<<"Wrong measure of EMC charge channel!"<<std::endl;
40 }
41 }
42
43 static int EmcChargeChannel(double charge)
44 {
45 if(charge>EMC_CHARGE_HIGH_MEASURE) {
46 return (int)(EMC_CHARGE_FACTOR-1);
47 } else if(charge>EMC_CHARGE_MID_MEASURE) {
48 return (int)(charge/(EMC_CHARGE_HIGH_MEASURE/EMC_CHARGE_FACTOR));
49 } else if(charge>EMC_CHARGE_LOW_MEASURE) {
50 return (int)(charge/(EMC_CHARGE_MID_MEASURE/EMC_CHARGE_FACTOR));
51 } else {
52 return (int)(charge/(EMC_CHARGE_LOW_MEASURE/EMC_CHARGE_FACTOR));
53 }
54 }
55
56 static int EmcChargeMeasure(double charge)
57 {
58 if(charge>EMC_CHARGE_HIGH_MEASURE) {
59 return 3;
60 } else if(charge>EMC_CHARGE_MID_MEASURE) {
61 return 2;
62 } else if(charge>EMC_CHARGE_LOW_MEASURE) {
63 return 1;
64 } else {
65 return 0;
66 }
67 }
68
69 static double TofTime(unsigned int timeChannel) { return ((double)timeChannel)*TOF_TIME_FACTOR; }
70 static unsigned int TofTimeChannel (double time) { return (unsigned int)(time/TOF_TIME_FACTOR); }
71
72 static double TofCharge(unsigned int chargeChannel)
73 {
74 double ADC = chargeChannel & 0x1fff ;
75 return ADC*TOF_CHARGE_FACTOR;
76 }
77
78 static unsigned int TofChargeChannel (double charge, double time)
79 {
80 unsigned int ADC = (unsigned) (charge/TOF_CHARGE_FACTOR);
81 unsigned int TDC = (unsigned) (time/TOF_TIME_FACTOR);
82 if(ADC>=8192)
83 {
84 ADC = (ADC | 0x080000); // if ADC_channel>=8192, set overflow flag = 1.
85 // The overlow flag is the 20th bit of the ADC_channel.
86 }
87 ADC = ( (TDC & 0x07e000) | ADC) ; // Store tclock into ADC_channel as qclock
88 //std::cout<<"ADC: "<<ADC<<std::endl;
89 //std::cout<<"TDC: "<<TDC<<std::endl;
90 //std::cout<<"qclock: "<<( ( ADC & 0x7e000 ) >> 13 );
91 //std::cout<<" tclock: "<<( ( TDC & 0x7e000 ) >> 13 )<<std::endl;
92 //if ( ( ( ADC & 0x7e000 ) >> 13 ) != (( TDC & 0x7e000 ) >> 13 ) )
93 // std::cout<<"qclock!=tclock"<<std::endl;
94 return ADC;
95 }
96
97private:
98 static const double MDC_TIME_FACTOR;
99 static const double MDC_CHARGE_FACTOR;
100
101 static const double CGEM_TIME_FACTOR;
102 static const double CGEM_CHARGE_FACTOR;
103
104 static const double TOF_TIME_FACTOR;
105 static const double TOF_CHARGE_FACTOR;
106
107 static const double EMC_CHARGE_HIGH_MEASURE;
108 static const double EMC_CHARGE_MID_MEASURE;
109 static const double EMC_CHARGE_LOW_MEASURE;
110 static const double EMC_TIME_FACTOR;
111 static const double EMC_CHARGE_FACTOR;
112};
113
114#endif
Double_t time
static double EmcTime(int timeChannel)
Definition: RawDataUtil.h:20
static int EmcChargeChannel(double charge)
Definition: RawDataUtil.h:43
static int CgemTimeChannel(double time)
Definition: RawDataUtil.h:15
static int MdcTimeChannel(double time)
Definition: RawDataUtil.h:9
static int EmcChargeMeasure(double charge)
Definition: RawDataUtil.h:56
static int MdcChargeChannel(double charge)
Definition: RawDataUtil.h:12
static double CgemCharge(int chargeChannel)
Definition: RawDataUtil.h:17
static double MdcTime(int timeChannel)
Definition: RawDataUtil.h:8
static unsigned int TofTimeChannel(double time)
Definition: RawDataUtil.h:70
static double TofTime(unsigned int timeChannel)
Definition: RawDataUtil.h:69
static double TofCharge(unsigned int chargeChannel)
Definition: RawDataUtil.h:72
static double CgemTime(int timeChannel)
Definition: RawDataUtil.h:14
static int EmcTimeChannel(double time)
Definition: RawDataUtil.h:21
static int CgemChargeChannel(double charge)
Definition: RawDataUtil.h:18
static unsigned int TofChargeChannel(double charge, double time)
Definition: RawDataUtil.h:78
static double EmcCharge(int measure, int chargeChannel)
Definition: RawDataUtil.h:23
static double MdcCharge(int chargeChannel)
Definition: RawDataUtil.h:11