9#include <top/dataobjects/TOPDigit.h>
10#include <top/dataobjects/TOPRawDigit.h>
11#include <top/dataobjects/TOPSimHit.h>
12#include <mdst/dataobjects/MCParticle.h>
13#include <framework/datastore/RelationVector.h>
31 if (sample < 0)
return 256 + sample % 256;
38 const auto* bgDigit =
static_cast<const TOPDigit*
>(bg);
39 double diff =
m_time - bgDigit->getTime();
44 const double time[2] = {
m_time, bgDigit->getTime()};
45 const double rawTime[2] = {
m_rawTime, bgDigit->getRawTime()};
46 const int pulseHeight[2] = {
m_pulseHeight, bgDigit->getPulseHeight()};
47 double sum = pulseHeight[0] + pulseHeight[1];
49 m_time = (time[0] * pulseHeight[0] + time[1] * pulseHeight[1]) / sum;
50 m_rawTime = (rawTime[0] * pulseHeight[0] + rawTime[1] * pulseHeight[1]) / sum;
55 m_time = (time[0] + time[1]) / 2;
56 m_rawTime = (rawTime[0] + rawTime[1]) / 2;
62 double reweight = sum > 0 ? pulseHeight[0] / sum : 0.5;
63 auto relSimHits = this->getRelationsTo<TOPSimHit>();
64 for (
size_t i = 0; i < relSimHits.size(); ++i) {
65 float weight = relSimHits.weight(i) * reweight;
66 relSimHits.setWeight(i, weight);
68 auto relRawDigits = this->getRelationsTo<TOPRawDigit>();
69 for (
size_t i = 0; i < relRawDigits.size(); ++i) {
70 float weight = relRawDigits.weight(i) * reweight;
71 relRawDigits.setWeight(i, weight);
73 auto relMCParticles = this->getRelationsTo<MCParticle>();
74 for (
size_t i = 0; i < relMCParticles.size(); ++i) {
75 float weight = relMCParticles.weight(i) * reweight;
76 relMCParticles.setWeight(i, weight);
84 auto relSimHits = this->getRelationsTo<TOPSimHit>();
85 for (
int i = relSimHits.size() - 1; i >= 0; --i) {
88 auto relRawDigits = this->getRelationsTo<TOPRawDigit>();
89 for (
int i = relRawDigits.size() - 1; i >= 0; --i) {
90 relRawDigits.remove(i);
92 auto relMCParticles = this->getRelationsTo<MCParticle>();
93 for (
int i = relMCParticles.size() - 1; i >= 0; --i) {
94 relMCParticles.remove(i);
A common base for subdetector Digits.
EAppendStatus
Enum for return state of addBGDigit function.
@ c_DontAppend
do not append BG digit to digits
@ c_Append
append BG digit to digits
Class to store TOP digitized hits (output of TOPDigitizer or raw data unpacker) relations to TOPSimHi...
float m_time
calibrated time in [ns], t0-subtracted
float m_rawTime
raw time expressed in samples (TDC bins)
unsigned short m_firstWindow
first ASIC window of the merged waveform
int m_pulseHeight
pulse height [ADC counts]
static float s_doubleHitResolution
double hit resolving time in [ns]
DigitBase::EAppendStatus addBGDigit(const DigitBase *bg) override
Implementation of the base class function.
int getModulo256Sample() const
Returns sample number modulo 256.
static float s_pileupTime
pile-up time in [ns]
Abstract base class for different kinds of events.