86 std::map<int, TOPDigit*> hitInfoMap;
87 for (
auto& digit : digits) {
89 if (digit.getHitQuality() == TOPDigit::c_Junk)
continue;
91 const auto* rawDigit = digit.getRelated<
TOPRawDigit>();
92 if (!rawDigit)
continue;
95 if (waveform and
isCrossTalk(waveform->getWaveform(), TMath::FloorNint(digit.getRawTime()), digit.getPulseHeight()))
96 digit.setHitQuality(TOPDigit::c_CrossTalk);
99 int slotId = digit.getModuleID();
100 unsigned int channelId = digit.getChannel();
101 double rawTime = digit.getRawTime();
102 for (
auto& digit2 : digits) {
103 if (digit2.getChannel() != channelId || digit2.getModuleID() != slotId)
continue;
104 if (digit2.getHitQuality() == TOPDigit::c_CrossTalk
106 digit.setHitQuality(TOPDigit::c_CrossTalk);
110 if (digit.getHitQuality() == TOPDigit::c_CrossTalk)
continue;
112 int globalPixelId = (digit.getModuleID() - 1) * 512 + digit.
getPixelID() - 1;
113 while (hitInfoMap.count(globalPixelId) > 0)globalPixelId += 10000;
114 hitInfoMap[globalPixelId] = &digit;
120 for (
auto& digit : digits) {
122 if (digit.getHitQuality() == TOPDigit::c_Junk
123 || digit.getHitQuality() == TOPDigit::c_CrossTalk)
continue;
125 short pixelId = digit.getPixelID();
126 short slotId = digit.getModuleID();
127 short pmtId = digit.getPMTNumber();
128 double hitTime = digit.getTime();
129 double charge = digit.getIntegral();
130 bool isPrimaryChargeShare =
true;
131 std::vector<TOPDigit*> vSecondaryCandidates;
133 int adjacentPixelIds[] = { pixelId - 1 - c_NPixelsPerRow, pixelId - c_NPixelsPerRow, pixelId + 1 - c_NPixelsPerRow, pixelId + 1,
134 pixelId + 1 + c_NPixelsPerRow, pixelId + c_NPixelsPerRow, pixelId - 1 + c_NPixelsPerRow, pixelId - 1
137 for (
const auto& adjacentPixelId : adjacentPixelIds) {
138 if (adjacentPixelId > 0 && adjacentPixelId <= 512) {
139 int globalPixelId = (slotId - 1) * 512 + adjacentPixelId - 1;
140 while (hitInfoMap.count(globalPixelId) > 0) {
142 if (pmtId != hitInfoMap[globalPixelId]->getPMTNumber()
143 or TMath::Abs(hitTime - hitInfoMap[globalPixelId]->getTime()) >
m_timeCut) {
144 globalPixelId += 10000;
continue;
147 float adjacentIntegral = hitInfoMap[globalPixelId]->getIntegral();
149 if (charge > adjacentIntegral
150 or (charge == adjacentIntegral && pixelId > hitInfoMap[globalPixelId]->getPixelID())) {
151 vSecondaryCandidates.push_back(hitInfoMap[globalPixelId]);
152 hitInfoMap[globalPixelId]->setSecondaryChargeShare();
154 isPrimaryChargeShare =
false;
157 globalPixelId += 10000;
159 if (!isPrimaryChargeShare)
break;
163 if (isPrimaryChargeShare && vSecondaryCandidates.size() > 0) {
164 digit.setPrimaryChargeShare();
167 for (
auto& vSecondaryCandidate : vSecondaryCandidates) {
168 digit.setPulseHeight(digit.getPulseHeight() + vSecondaryCandidate->getPulseHeight());
169 vSecondaryCandidate->setPulseHeight(0.0);
171 digit.setIntegral(digit.getIntegral() + vSecondaryCandidate->getIntegral());
172 vSecondaryCandidate->setIntegral(0.0);
191 int nWfmSampling = wfm.size();
192 for (
int iWin = 0 ; iWin < 16 ; iWin++) {
196 if (jRawTime > 0 && jRawTime < nWfmSampling - 1 && wfm[jRawTime] < height / 2. && wfm[jRawTime + 1] > height / 2.) {
197 bool preValleyExist =
false;
198 short preValleyDepth = -1;
201 for (
int iSample = jRawTime ; iSample - 1 > 0 ; iSample--) {
203 else if (wfm[iSample] - wfm[iSample - 1] >= 0)
continue;
205 preValleyDepth = (-1) * wfm[iSample];
209 preValleyExist =
true;
215 if (!preValleyExist)
return false;
219 short valley_adc = 9999;
220 for (
int jSample = jRawTime ; jSample < nWfmSampling - 1 ; jSample++) {
222 if ((wfm[jSample + 1] - wfm[jSample])*sign > 0)
continue;
224 if (sign < 0 && valley_adc > height + 1)
225 valley_adc = wfm[jSample];
226 if (sign > 0 && valley_adc < height) {
233 sign = (sign > 0 ? -1 : 1);