Belle II Software development
CDCHit.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <cdc/dataobjects/CDCHit.h>
10#include <cdc/dataobjects/CDCSimHit.h>
11#include <mdst/dataobjects/MCParticle.h>
12#include <framework/datastore/RelationVector.h>
13
14
15using namespace std;
16using namespace Belle2;
17
18CDCHit::CDCHit(unsigned short tdcCount, unsigned short charge,
19 unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire, unsigned short status, unsigned short tot,
20 signed short otherHitIndex, unsigned short leadingEdgeCharge)
21{
22 setTDCCount(tdcCount);
23 setADCCount(charge);
24 setWireID(iSuperLayer, iLayer, iWire);
25 setStatus(status);
26 setTOT(tot);
27 setOtherHitIndex(otherHitIndex);
28 setADCCountAtLeadingEdge(leadingEdgeCharge);
29}
30
31
33{
34 const auto* bgDigit = static_cast<const CDCHit*>(bg);
35 const unsigned short tdc4Sg = m_tdcCount;
36 const unsigned short adc4Sg = m_adcCount;
37 const unsigned short tot4Sg = m_tot;
38 const unsigned short tdc4Bg = bgDigit->getTDCCount();
39 const unsigned short adc4Bg = bgDigit->getADCCount();
40 const unsigned short tot4Bg = bgDigit->getTOT();
41 // B2DEBUG(28, "Sg tdc,adc,tot= " << tdc4Sg << " " << adc4Sg << " " << tot4Sg);
42 // B2DEBUG(28, "Bg tdc,adc,tot= " << tdc4Bg << " " << adc4Bg << " " << tot4Bg);
43 int diff = static_cast<int>(m_tdcCount) - static_cast<int>(bgDigit->getTDCCount());
44
45 // If the BG hit is faster than the true hit, the TDC count is replaced, and
46 // relation is removed.
47 // ADC counts are summed up.
48 if (diff < 0) {
49 *this = *bgDigit;
50 auto relSimHits = this->getRelationsFrom<CDCSimHit>();
51 for (int i = relSimHits.size() - 1; i >= 0; --i) {
52 relSimHits.remove(i);
53 }
54 auto relMCParticles = this->getRelationsFrom<MCParticle>();
55 for (int i = relMCParticles.size() - 1; i >= 0; --i) {
56 relMCParticles.remove(i);
57 }
58 }
59
60 m_adcCount = adc4Sg + adc4Bg;
61
62 //Set TOT for signal+background case. It is assumed that the start timing
63 //of a pulse (input to ADC) is given by the TDC-count. This is an
64 //approximation becasue analog (for ADC) and digital (for TDC) parts are
65 //different in the front-end electronics.
66 unsigned short s1 = tdc4Sg; //start time of 1st pulse
67 unsigned short s2 = tdc4Bg; //start time of 2nd pulse
68 unsigned short w1 = 32 * tot4Sg; //its width
69 unsigned short w2 = 32 * tot4Bg; //its width
70 if (tdc4Sg < tdc4Bg) {
71 s1 = tdc4Bg;
72 w1 = 32 * tot4Bg;
73 s2 = tdc4Sg;
74 w2 = 32 * tot4Sg;
75 }
76 const unsigned short e1 = s1 - w1; //end time of 1st pulse
77 const unsigned short e2 = s2 - w2; //end time of 2nd pulse
78 // B2DEBUG(28, "s1,e1,w1,s2,e2,w2= " << s1 << " " << e1 << " " << w1 << " " << s2 << " " << e2 << " " << w2);
79
80 double pulseW = w1 + w2;
81 if (e1 <= e2) {
82 pulseW = w1;
83 } else if (e1 <= s2) {
84 pulseW = s1 - e2;
85 }
86
87 // maxtot=29 is hard-coded now
88 m_tot = std::min(std::round(pulseW / 32.), 29.);
89 // B2DEBUG(28, "adcCount,tot= " << m_adcCount << " " << m_tot);
90
92}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
void setADCCountAtLeadingEdge(unsigned short adcCount)
Setter for ADCcount at leading edge.
Definition: CDCHit.h:154
void setTDCCount(short tdcCount)
Setter for TDC count.
Definition: CDCHit.h:128
DigitBase::EAppendStatus addBGDigit(const DigitBase *bg) override
Implementation of the base class function.
Definition: CDCHit.cc:32
unsigned short m_tdcCount
TDC count in ns.
Definition: CDCHit.h:279
CDCHit()
Empty constructor for ROOT IO.
Definition: CDCHit.h:43
void setOtherHitIndex(signed short index)
Setter for the other hit index.
Definition: CDCHit.h:141
unsigned short m_adcCount
ADC count of the integrated charge in the cell.
Definition: CDCHit.h:282
void setTOT(unsigned short tot)
Setter for TOT.
Definition: CDCHit.h:160
void setADCCount(unsigned short adcCount)
Setter for ADC count.
Definition: CDCHit.h:135
void setWireID(unsigned short iSuperLayer, unsigned short iLayer, unsigned short iWire)
Setter for Wire ID.
Definition: CDCHit.h:90
unsigned short m_tot
Time over threshod.
Definition: CDCHit.h:288
void setStatus(unsigned short status)
Setter for CDCHit status.
Definition: CDCHit.h:106
A common base for subdetector Digits.
Definition: DigitBase.h:26
EAppendStatus
Enum for return state of addBGDigit function.
Definition: DigitBase.h:32
@ c_DontAppend
do not append BG digit to digits
Definition: DigitBase.h:33
Abstract base class for different kinds of events.
STL namespace.