CMS 3D CMS Logo

HcalTBQADCUnpacker.cc
Go to the documentation of this file.
3 
4 // QADC channels
5 static const int N_QADCS_ALLOWED = 6;
6 
7 // Channel to logical unit
8 // TB04
9 static const int aScint1 = 52; // 14x14 cm
10 static const int aScint2 = 53; // 4x4 cm
11 static const int aScint3 = 54; // 2x2 cm
12 static const int aScint4 = 66; // 14x14 cm
13 static const int aMuonV = 56; // Behind the table
14 static const int aMuonV3 = 64; // on HB1
15 static const int aMuonV6 = 62; // on HB2
16 static const int aMuonVH1 = 67; // Oct. muon veto wall
17 static const int aMuonVH2 = 68; // Oct. muon veto wall
18 static const int aMuonVH3 = 69; // Oct. muon veto wall
19 static const int aMuonVH4 = 70; // Oct. muon veto wall
20 static const int aCerenkov2 = 49; // el id
21 static const int aCerenkov3 = 59; // pi/proton separation
22 static const int aSCI_VLE = 65; // VLE line
23 static const int aSCI_521 = 57;
24 static const int aSCI_528 = 58;
25 // TB06
26 static const int bMuonV1 = 0; // Muon veto wall
27 static const int bMuonV2 = 1; // Muon veto wall
28 static const int bMuonV3 = 2; // Muon veto wall
29 static const int bMuonV4 = 3; // Muon veto wall
30 static const int bMuonV5 = 4; // Muon veto wall
31 static const int bMuonV6 = 5; // Muon veto wall
32 static const int bMuonV7 = 6; // Muon veto wall
33 static const int bMuonV8 = 7; // Muon veto wall
34 static const int bMuonVF = 10; // Behind the table
35 static const int bMuonVB = 11; // Behind a beam dump
36 static const int bScint1 = 12; // 14x14 cm
37 static const int bScint2 = 13; // 4x4 cm
38 static const int bScint3 = 14; // 2x2 cm
39 static const int bScint4 = 15; // 14x14 cm
40 static const int bCerenkov1 = 16; // in HE line
41 static const int bCerenkov2 = 17; // el id in VLE
42 static const int bCerenkov3 = 18; // pi/proton id
43 static const int bTOF1S = 20; // TOF1S (S=Saleve side, TOF1 upstream)
44 static const int bTOF1J = 21; // TOF1J (J=Jura side)
45 static const int bTOF2S = 22; // TOF2S (TOF2 downstream)
46 static const int bTOF2J = 23; // TOF2J
47 static const int bSCI_521 = 24; // In HE beam line for now
48 static const int bSCI_528 = 25; // NC
49 static const int bVH2 = 27; // beam halo left from particle view
50 static const int bVH4 = 28; // beam halo down
51 static const int bVH3 = 29; // beam halo up
52 static const int bVH1 = 30; // beam halo right from particle view
53 
54 namespace hcaltb {
55 
57 
60  unsigned short data[N_QADCS_ALLOWED * 32];
61  unsigned int cdfTrailer0, cdfTrailer1;
62  };
63 
66  unsigned int n_qdc_hits; // Count of QDC channels
67  unsigned int n_tdc_hits; // upper/lower TDC counts
68  unsigned short qdc_values[4];
69  };
70 
71  // Sets the pedestal and gain
72  void HcalTBQADCUnpacker::setCalib(const std::vector<std::vector<std::string> >& calibLines_) {
73  // The default pedestal and gain
74  for (int i = 0; i < N_QADCS_ALLOWED * 32; i++) {
75  qdc_ped[i] = 0.;
76  qdc_gain[i] = 1.;
77  }
78  // Pedestal and gains from configuration file.
79  for (unsigned int ii = 0; ii < calibLines_.size(); ii++) {
80  if (calibLines_[ii][0] == "QDC") {
81  if (calibLines_[ii].size() == 4) {
82  int channel = atoi(calibLines_[ii][1].c_str());
83  qdc_ped[channel] = atof(calibLines_[ii][2].c_str());
84  qdc_gain[channel] = atof(calibLines_[ii][3].c_str());
85  // printf("Got QDC %i ped %f , gain %f\n",channel, qdc_ped[channel],qdc_gain[channel]);
86  } else {
87  throw cms::Exception("Incomplete configuration")
88  << "Wrong QADC configuration format: expected 3 parameters, got " << calibLines_[ii].size() - 1;
89  }
90  }
91  } // End of calibLines.
92  }
93 
94  void HcalTBQADCUnpacker::unpack(const FEDRawData& raw, HcalTBBeamCounters& beamadc, bool is04) const {
95  if (raw.size() < 3 * 8) {
96  throw cms::Exception("Missing Data") << "No data in the QDC block";
97  }
98 
99  if (is04) {
100  const ClassicQADCDataFormat* qadc = (const ClassicQADCDataFormat*)raw.data();
101  double qdc_calib_hits[N_QADCS_ALLOWED * 32];
102  // Applying mask, pedestal subtraction and gain.
103  for (unsigned int i = 0; i < N_QADCS_ALLOWED * 32; i++)
104  qdc_calib_hits[i] = ((qadc->data[i] & 0xFFF) - qdc_ped[i]) / qdc_gain[i];
105 
106  // Ecal energy sum should go here.
107  double Ecal7x7 = 0.;
108  for (int i = 0; i < 49; i++)
109  Ecal7x7 += qdc_calib_hits[i];
110 
111  beamadc.setADCs04(qdc_calib_hits[aMuonV],
112  qdc_calib_hits[aMuonV3],
113  qdc_calib_hits[aMuonV6],
114  qdc_calib_hits[aMuonVH1],
115  qdc_calib_hits[aMuonVH2],
116  qdc_calib_hits[aMuonVH3],
117  qdc_calib_hits[aMuonVH4],
118  qdc_calib_hits[aCerenkov2],
119  qdc_calib_hits[aCerenkov3],
120  qdc_calib_hits[aSCI_VLE],
121  qdc_calib_hits[aSCI_521],
122  qdc_calib_hits[aSCI_528],
123  qdc_calib_hits[aScint1],
124  qdc_calib_hits[aScint2],
125  qdc_calib_hits[aScint3],
126  qdc_calib_hits[aScint4],
127  Ecal7x7);
128  } else {
129  const CombinedTDCQDCDataFormat* qdctdc = (const CombinedTDCQDCDataFormat*)raw.data();
130  double qdc_calib_hits[32];
131  for (unsigned int i = 0; i < qdctdc->n_qdc_hits; i++)
132  qdc_calib_hits[i] = ((qdctdc->qdc_values[i] & 0xFFF) - qdc_ped[i]) / qdc_gain[i];
133 
134  beamadc.setADCs06(qdc_calib_hits[bMuonVF],
135  qdc_calib_hits[bMuonVB],
136  qdc_calib_hits[bMuonV1],
137  qdc_calib_hits[bMuonV2],
138  qdc_calib_hits[bMuonV3],
139  qdc_calib_hits[bMuonV4],
140  qdc_calib_hits[bMuonV5],
141  qdc_calib_hits[bMuonV6],
142  qdc_calib_hits[bMuonV7],
143  qdc_calib_hits[bMuonV8],
144  qdc_calib_hits[bCerenkov1],
145  qdc_calib_hits[bCerenkov2],
146  qdc_calib_hits[bCerenkov3],
147  qdc_calib_hits[bScint1],
148  qdc_calib_hits[bScint2],
149  qdc_calib_hits[bScint3],
150  qdc_calib_hits[bScint4],
151  qdc_calib_hits[bTOF1S],
152  qdc_calib_hits[bTOF1J],
153  qdc_calib_hits[bTOF2S],
154  qdc_calib_hits[bTOF2J],
155  qdc_calib_hits[bSCI_521],
156  qdc_calib_hits[bSCI_528],
157  qdc_calib_hits[bVH1],
158  qdc_calib_hits[bVH2],
159  qdc_calib_hits[bVH3],
160  qdc_calib_hits[bVH4]);
161  }
162  }
163 
164 } // namespace hcaltb
bTOF1S
static const int bTOF1S
Definition: HcalTBQADCUnpacker.cc:43
aCerenkov2
static const int aCerenkov2
Definition: HcalTBQADCUnpacker.cc:20
bVH2
static const int bVH2
Definition: HcalTBQADCUnpacker.cc:49
mps_fire.i
i
Definition: mps_fire.py:428
hcaltb::ClassicQADCDataFormat::cdfHeader1
unsigned int cdfHeader1
Definition: HcalTBQADCUnpacker.cc:59
aScint4
static const int aScint4
Definition: HcalTBQADCUnpacker.cc:12
bTOF1J
static const int bTOF1J
Definition: HcalTBQADCUnpacker.cc:44
bMuonV1
static const int bMuonV1
Definition: HcalTBQADCUnpacker.cc:26
hcaltb::HcalTBQADCUnpacker::unpack
void unpack(const FEDRawData &raw, HcalTBBeamCounters &beamadc, bool is04_=true) const
Definition: HcalTBQADCUnpacker.cc:94
hcaltb::CombinedTDCQDCDataFormat
Definition: HcalTBQADCUnpacker.cc:64
bScint1
static const int bScint1
Definition: HcalTBQADCUnpacker.cc:36
hcaltb::HcalTBQADCUnpacker::qdc_ped
double qdc_ped[192]
Definition: HcalTBQADCUnpacker.h:15
HcalTBBeamCounters
Definition: HcalTBBeamCounters.h:8
hcaltb::HcalTBQADCUnpacker::HcalTBQADCUnpacker
HcalTBQADCUnpacker()
Definition: HcalTBQADCUnpacker.cc:56
bCerenkov1
static const int bCerenkov1
Definition: HcalTBQADCUnpacker.cc:40
bMuonV3
static const int bMuonV3
Definition: HcalTBQADCUnpacker.cc:28
hcaltb::CombinedTDCQDCDataFormat::qdc_values
unsigned short qdc_values[4]
Definition: HcalTBQADCUnpacker.cc:68
bVH1
static const int bVH1
Definition: HcalTBQADCUnpacker.cc:52
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
bCerenkov3
static const int bCerenkov3
Definition: HcalTBQADCUnpacker.cc:42
aScint1
static const int aScint1
Definition: HcalTBQADCUnpacker.cc:9
hcaltb::ClassicQADCDataFormat::cdfTrailer1
unsigned int cdfTrailer1
Definition: HcalTBQADCUnpacker.cc:61
hcaltb::ClassicQADCDataFormat
Definition: HcalTBQADCUnpacker.cc:58
bMuonV2
static const int bMuonV2
Definition: HcalTBQADCUnpacker.cc:27
hcaltb::HcalTBQADCUnpacker::setCalib
void setCalib(const std::vector< std::vector< std::string > > &calibLines_)
Definition: HcalTBQADCUnpacker.cc:72
bMuonVB
static const int bMuonVB
Definition: HcalTBQADCUnpacker.cc:35
hcaltb::HcalTBQADCUnpacker::qdc_gain
double qdc_gain[192]
Definition: HcalTBQADCUnpacker.h:16
bSCI_528
static const int bSCI_528
Definition: HcalTBQADCUnpacker.cc:48
bScint3
static const int bScint3
Definition: HcalTBQADCUnpacker.cc:38
bTOF2J
static const int bTOF2J
Definition: HcalTBQADCUnpacker.cc:46
hcaltb::CombinedTDCQDCDataFormat::n_qdc_hits
unsigned int n_qdc_hits
Definition: HcalTBQADCUnpacker.cc:66
hcaltb::CombinedTDCQDCDataFormat::cdfHeader3
unsigned int cdfHeader3
Definition: HcalTBQADCUnpacker.cc:65
aMuonV6
static const int aMuonV6
Definition: HcalTBQADCUnpacker.cc:15
aMuonV3
static const int aMuonV3
Definition: HcalTBQADCUnpacker.cc:14
aMuonVH1
static const int aMuonVH1
Definition: HcalTBQADCUnpacker.cc:16
bMuonV7
static const int bMuonV7
Definition: HcalTBQADCUnpacker.cc:32
HcalTBBeamCounters::setADCs04
void setADCs04(double VMadc, double V3adc, double V6adc, double VH1adc, double VH2adc, double VH3adc, double VH4adc, double CK2adc, double CK3adc, double SciVLEadc, double Sci521adc, double Sci528adc, double S1adc, double S2adc, double S3adc, double S4adc, double Ecal7x7)
Definition: HcalTBBeamCounters.cc:43
bMuonV6
static const int bMuonV6
Definition: HcalTBQADCUnpacker.cc:31
HcalTBQADCUnpacker.h
bMuonV4
static const int bMuonV4
Definition: HcalTBQADCUnpacker.cc:29
hcaltb
Definition: HcalTBQADCUnpacker.h:6
aCerenkov3
static const int aCerenkov3
Definition: HcalTBQADCUnpacker.cc:21
aScint2
static const int aScint2
Definition: HcalTBQADCUnpacker.cc:10
bVH3
static const int bVH3
Definition: HcalTBQADCUnpacker.cc:51
bScint2
static const int bScint2
Definition: HcalTBQADCUnpacker.cc:37
aMuonVH3
static const int aMuonVH3
Definition: HcalTBQADCUnpacker.cc:18
aScint3
static const int aScint3
Definition: HcalTBQADCUnpacker.cc:11
bMuonV5
static const int bMuonV5
Definition: HcalTBQADCUnpacker.cc:30
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
bSCI_521
static const int bSCI_521
Definition: HcalTBQADCUnpacker.cc:47
HcalTBBeamCounters::setADCs06
void setADCs06(double VMFadc, double VMBadc, double VM1adc, double VM2adc, double VM3adc, double VM4adc, double VM5adc, double VM6adc, double VM7adc, double VM8adc, double CK1adc, double CK2adc, double CK3adc, double S1adc, double S2adc, double S3adc, double S4adc, double TOF1Sadc, double TOF1Jadc, double TOF2Sadc, double TOF2Jadc, double Sci521adc, double Sci528adc, double BH1adc, double BH2adc, double BH3adc, double BH4adc)
Definition: HcalTBBeamCounters.cc:80
hcaltb::ClassicQADCDataFormat::cdfTrailer0
unsigned int cdfTrailer0
Definition: HcalTBQADCUnpacker.cc:61
hcaltb::CombinedTDCQDCDataFormat::cdfHeader1
unsigned int cdfHeader1
Definition: HcalTBQADCUnpacker.cc:65
bMuonV8
static const int bMuonV8
Definition: HcalTBQADCUnpacker.cc:33
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
bVH4
static const int bVH4
Definition: HcalTBQADCUnpacker.cc:50
bCerenkov2
static const int bCerenkov2
Definition: HcalTBQADCUnpacker.cc:41
hcaltb::ClassicQADCDataFormat::cdfHeader2
unsigned int cdfHeader2
Definition: HcalTBQADCUnpacker.cc:59
hcaltb::CombinedTDCQDCDataFormat::cdfHeader2
unsigned int cdfHeader2
Definition: HcalTBQADCUnpacker.cc:65
aSCI_528
static const int aSCI_528
Definition: HcalTBQADCUnpacker.cc:24
Exception
Definition: hltDiff.cc:246
aMuonV
static const int aMuonV
Definition: HcalTBQADCUnpacker.cc:13
hcaltb::CombinedTDCQDCDataFormat::n_tdc_hits
unsigned int n_tdc_hits
Definition: HcalTBQADCUnpacker.cc:67
Exception.h
aMuonVH4
static const int aMuonVH4
Definition: HcalTBQADCUnpacker.cc:19
hcaltb::ClassicQADCDataFormat::cdfHeader3
unsigned int cdfHeader3
Definition: HcalTBQADCUnpacker.cc:59
aSCI_VLE
static const int aSCI_VLE
Definition: HcalTBQADCUnpacker.cc:22
hcaltb::ClassicQADCDataFormat::data
unsigned short data[N_QADCS_ALLOWED *32]
Definition: HcalTBQADCUnpacker.cc:60
hcaltb::ClassicQADCDataFormat::cdfHeader0
unsigned int cdfHeader0
Definition: HcalTBQADCUnpacker.cc:59
bTOF2S
static const int bTOF2S
Definition: HcalTBQADCUnpacker.cc:45
bScint4
static const int bScint4
Definition: HcalTBQADCUnpacker.cc:39
hcaltb::CombinedTDCQDCDataFormat::cdfHeader0
unsigned int cdfHeader0
Definition: HcalTBQADCUnpacker.cc:65
cuy.ii
ii
Definition: cuy.py:590
aSCI_521
static const int aSCI_521
Definition: HcalTBQADCUnpacker.cc:23
N_QADCS_ALLOWED
static const int N_QADCS_ALLOWED
Definition: HcalTBQADCUnpacker.cc:5
aMuonVH2
static const int aMuonVH2
Definition: HcalTBQADCUnpacker.cc:17
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
bMuonVF
static const int bMuonVF
Definition: HcalTBQADCUnpacker.cc:34