31 : includeUnmatchedHits_(include_unmatched_hits), dumpObs_(nullptr) {
36 for (
int i = 0;
i < 161;
i++) {
40 for (
unsigned int ii = 0;
ii < calibLines_.size();
ii++) {
42 if (calibLines_[
ii][0] ==
"TDC") {
43 if (calibLines_[
ii].size() == 4) {
44 int channel = atoi(calibLines_[
ii][1].c_str());
45 tdc_ped[channel] = atof(calibLines_[
ii][2].c_str());
50 <<
"Wrong TDC configuration format : expected 3 parameters, got " << calibLines_[
ii].size() - 1;
55 if (calibLines_[
ii][0] ==
"WC") {
56 if (calibLines_[
ii].size() == 6) {
57 int plane = atoi(calibLines_[
ii][1].c_str());
58 wc_[plane].
b0 = atof(calibLines_[
ii][2].c_str());
59 wc_[plane].
b1 = atof(calibLines_[
ii][3].c_str());
60 wc_[plane].
mean = atof(calibLines_[
ii][4].c_str());
61 wc_[plane].
sigma = atof(calibLines_[
ii][5].c_str());
66 <<
"Wrong Wire Chamber configuration format : expected 5 parameters, got " << calibLines_[
ii].size() - 1;
74 std::vector<Hit>
hits;
101 if (raw.
size() < 3 * 8) {
102 throw cms::Exception(
"Missing Data") <<
"No data in the TDC block";
105 const unsigned int* hitbase =
nullptr;
106 unsigned int totalhits = 0;
111 hitbase = (
const unsigned int*)(qdctdc);
120 hitbase = &(tdc->
hits[0]);
124 for (
unsigned int i = 0;
i < totalhits;
i++) {
126 h.channel = (hitbase[
i] & 0x7FC00000) >> 22;
134 for (
int i = 0;
i < 32;
i++)
138 hitbase = (
const unsigned int*)(qdctdc);
142 totalhits = (qdctdc->
n_tdc_hits & 0xFFFF0000) >> 16;
143 for (
unsigned int i = 0;
i < totalhits;
i++) {
146 h.channel = 129 + ((hitbase[
i] & 0x3F0000) >> 16);
149 if ((
h.channel - 129) < 32)
150 v775[(
h.channel - 129)] = (hitbase[
i] & 0xFFF);
158 std::vector<Hit>::const_iterator
j;
159 double trigger_time = 0;
160 double ttc_l1a_time = 0;
161 double laser_flash = 0;
162 double qie_phase = 0;
163 double TOF1S_time = 0;
164 double TOF1J_time = 0;
165 double TOF2S_time = 0;
166 double TOF2J_time = 0;
168 std::vector<double> m1hits, m2hits, m3hits, s1hits, s2hits, s3hits, s4hits, bh1hits, bh2hits, bh3hits, bh4hits,
172 switch (
j->channel) {
238 timing.setTimes(trigger_time, ttc_l1a_time, laser_flash, qie_phase, TOF1S_time, TOF1J_time, TOF2S_time, TOF2J_time);
240 m1hits, m2hits, m3hits, s1hits, s2hits, s3hits, s4hits, bh1hits, bh2hits, bh3hits, bh4hits, beam_coinc);
299 const int MAX_HITS = 100;
300 float hits1[MAX_HITS], hits2[MAX_HITS], hitsA[MAX_HITS];
301 int n1, n2, nA, chan1, chan2, chanA;
303 std::vector<double>
x;
305 for (
int plane = 0; plane <
PLANECOUNT; plane++) {
310 std::vector<double> plane_hits;
321 for (std::vector<Hit>::const_iterator
j =
hits.begin();
j !=
hits.end();
j++) {
322 if (
j->channel == chan1 && n1 < MAX_HITS) {
326 if (
j->channel == chan2 && n2 < MAX_HITS) {
330 if (
j->channel == chanA && nA < MAX_HITS) {
336 if (n1 != 0 && n2 != 0 &&
dumpObs_ !=
nullptr) {
337 fprintf(
dumpObs_,
"%d,%f,%f,%f,%f\n", plane, hits1[0], hits2[0], hitsA[0], hitsA[1]);
342 for (
int ii = 0;
ii < n1;
ii++) {
343 int jmin = -1, lmin = -1;
344 float dsumMin = 99999;
345 for (
int jj = 0;
jj < n2;
jj++) {
346 for (
int ll = 0; ll < nA; ll++) {
347 float dsum = fabs(
wc_[plane].
mean - hits1[
ii] - hits2[
jj] + 2.0 * hitsA[ll]);
348 if (dsum < (
N_SIGMA *
wc_[plane].sigma) && dsum < dsumMin) {
356 hit_time =
wc_[plane].
b0 +
wc_[plane].
b1 * (hits1[
ii] - hits2[jmin]);
357 if ((plane % 2) == 0) {
358 plane_hits.push_back(-hit_time);
360 plane_hits.push_back(hit_time);
363 hits2[jmin] = -99999;
369 for (
int ii = 0;
ii < n1;
ii++) {
370 if (hits1[
ii] < -99990)
372 for (
int jj = 0;
jj < n2;
jj++) {
373 if (hits2[
jj] < -99990)
375 hit_time =
wc_[plane].
b0 +
wc_[plane].
b1 * (hits1[
ii] - hits2[
jj]);
376 if ((plane % 2) == 0) {
377 plane_hits.push_back(-hit_time);
379 plane_hits.push_back(hit_time);
384 if ((plane % 2) == 0)
387 char chamber =
'A' + plane / 2;
static const int lcBeamCoincidence
static const int lcBeamHalo4
size_t size() const
Lenght of the data buffer in bytes.
static const int lcTTCL1ATime
static const int lcScint4
static const int lcScint3
static const int lcBeamHalo2
static const int lcLaserFlash
void reconstructWC(const std::vector< Hit > &hits, HcalTBEventPosition &pos) const
static const int lcScint1
void setCalib(const std::vector< std::vector< std::string > > &calibLines_)
static const int lcBeamHalo1
static const int lcTriggerTime
static const int lcQIEPhase
bool includeUnmatchedHits_
static const double N_SIGMA
static const int lcBeamHalo3
static const int PLANECOUNT
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void unpackHits(const FEDRawData &raw, std::vector< Hit > &hits, HcalTBTiming &timing) const
static const double TDC_OFFSET_CONSTANT
void unpack(const FEDRawData &raw, HcalTBEventPosition &pos, HcalTBTiming &timing) const
static const int WC_CHANNELIDS[PLANECOUNT *3]
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
struct hcaltb::HcalTBTDCUnpacker::WireChamberRecoData wc_[PLANECOUNT]
static const int lcScint2
void reconstructTiming(const std::vector< Hit > &hits, HcalTBTiming &timing) const