BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/RawEvent/RawEvent-00-03-19/RawEvent/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 EmcTime(int timeChannel) { return ((double)timeChannel)/EMC_TIME_FACTOR; }
15 static int EmcTimeChannel (double time) { return (int)(time*EMC_TIME_FACTOR); }
16
17 static double EmcCharge(int measure, int chargeChannel)
18 {
19 switch(measure) {
20 case 3: //saturation of high measure
21 return ((double)chargeChannel)*EMC_CHARGE_HIGH_MEASURE/EMC_CHARGE_FACTOR;
22 break;
23 case 2:
24 return ((double)chargeChannel)*EMC_CHARGE_HIGH_MEASURE/EMC_CHARGE_FACTOR;
25 break;
26 case 1:
27 return ((double)chargeChannel)*EMC_CHARGE_MID_MEASURE/EMC_CHARGE_FACTOR;
28 break;
29 case 0:
30 return ((double)chargeChannel)*EMC_CHARGE_LOW_MEASURE/EMC_CHARGE_FACTOR;
31 break;
32 default:
33 std::cout<<"Wrong measure of EMC charge channel!"<<std::endl;
34 }
35 }
36
37 static int EmcChargeChannel(double charge)
38 {
39 if(charge>EMC_CHARGE_HIGH_MEASURE) {
40 return (int)(EMC_CHARGE_FACTOR-1);
41 } else if(charge>EMC_CHARGE_MID_MEASURE) {
42 return (int)(charge/(EMC_CHARGE_HIGH_MEASURE/EMC_CHARGE_FACTOR));
43 } else if(charge>EMC_CHARGE_LOW_MEASURE) {
44 return (int)(charge/(EMC_CHARGE_MID_MEASURE/EMC_CHARGE_FACTOR));
45 } else {
46 return (int)(charge/(EMC_CHARGE_LOW_MEASURE/EMC_CHARGE_FACTOR));
47 }
48 }
49
50 static int EmcChargeMeasure(double charge)
51 {
52 if(charge>EMC_CHARGE_HIGH_MEASURE) {
53 return 3;
54 } else if(charge>EMC_CHARGE_MID_MEASURE) {
55 return 2;
56 } else if(charge>EMC_CHARGE_LOW_MEASURE) {
57 return 1;
58 } else {
59 return 0;
60 }
61 }
62
63 static double TofTime(unsigned int timeChannel) { return ((double)timeChannel)*TOF_TIME_FACTOR; }
64 static unsigned int TofTimeChannel (double time) { return (unsigned int)(time/TOF_TIME_FACTOR); }
65
66 static double TofCharge(unsigned int chargeChannel)
67 {
68 double ADC = chargeChannel & 0x1fff ;
69 return ADC*TOF_CHARGE_FACTOR;
70 }
71
72 static unsigned int TofChargeChannel (double charge, double time)
73 {
74 unsigned int ADC = (unsigned) (charge/TOF_CHARGE_FACTOR);
75 unsigned int TDC = (unsigned) (time/TOF_TIME_FACTOR);
76 if(ADC>=8192)
77 {
78 ADC = (ADC | 0x080000); // if ADC_channel>=8192, set overflow flag = 1.
79 // The overlow flag is the 20th bit of the ADC_channel.
80 }
81 ADC = ( (TDC & 0x07e000) | ADC) ; // Store tclock into ADC_channel as qclock
82 //std::cout<<"ADC: "<<ADC<<std::endl;
83 //std::cout<<"TDC: "<<TDC<<std::endl;
84 //std::cout<<"qclock: "<<( ( ADC & 0x7e000 ) >> 13 );
85 //std::cout<<" tclock: "<<( ( TDC & 0x7e000 ) >> 13 )<<std::endl;
86 //if ( ( ( ADC & 0x7e000 ) >> 13 ) != (( TDC & 0x7e000 ) >> 13 ) )
87 // std::cout<<"qclock!=tclock"<<std::endl;
88 return ADC;
89 }
90
91private:
92 static const double MDC_TIME_FACTOR;
93 static const double MDC_CHARGE_FACTOR;
94
95 static const double TOF_TIME_FACTOR;
96 static const double TOF_CHARGE_FACTOR;
97
98 static const double EMC_CHARGE_HIGH_MEASURE;
99 static const double EMC_CHARGE_MID_MEASURE;
100 static const double EMC_CHARGE_LOW_MEASURE;
101 static const double EMC_TIME_FACTOR;
102 static const double EMC_CHARGE_FACTOR;
103};
104
105#endif
Double_t time
static unsigned int TofTimeChannel(double time)
static double TofTime(unsigned int timeChannel)
static double TofCharge(unsigned int chargeChannel)
static unsigned int TofChargeChannel(double charge, double time)
static double EmcCharge(int measure, int chargeChannel)
static double MdcCharge(int chargeChannel)