Belle II Software  release-05-01-25
AsicBackgroundDetector Class Referenceabstract

Marks hits as background based on the result of a filter. More...

#include <AsicBackgroundDetector.h>

Inheritance diagram for AsicBackgroundDetector:
Collaboration diagram for AsicBackgroundDetector:

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invokation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invokation.
 

Public Member Functions

 AsicBackgroundDetector ()=default
 Default constructor.
 
void initialize () final
 Access database here:
 
void beginRun () final
 Reload channel map if needed.
 
std::string getDescription () final
 Short description of the findlet.
 
virtual void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the parameters to a module.
 
virtual void apply (std::vector< CDCWireHit > &wireHits) final
 Main algorithm marking hit as background.
 
virtual void exposeParameters (ModuleParamList *moduleParamList __attribute__((unused)), const std::string &prefix __attribute__((unused)))
 Forward prefixed parameters of this findlet to the module parameter list.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void beginEvent () override
 Receive and dispatch signal for the start of a new event.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector = typename ToVectorImpl< T >::Type
 Short hand for ToRangeImpl.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = Findlet< CDCWireHit & >
 Type of the base class.
 

Private Member Functions

void applyAsicFilter (std::vector< CDCWireHit * > &wireHits)
 Algorithm marking hit as background for each CDC ASIC. More...
 

Private Attributes

std::unique_ptr< DBArray< CDCChannelMap > > m_channelMapFromDB
 Channel map retrieved from DB.
 
std::map< int, std::pair< int, int > > m_map
 map from ewire to board/channel ID
 
size_t m_minimal_hit_number {4}
 min. number of hits in ASIC for background check
 
double m_deviation_from_median {10.}
 distance from median TDC, to be considered as bg.
 
size_t m_nsignal_max {4}
 max. number of signal-like hits in ASIC for background check
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happend before.
 
bool m_terminated = false
 Flag to keep track whether termination happend before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Marks hits as background based on the result of a filter.

Definition at line 36 of file AsicBackgroundDetector.h.

Member Function Documentation

◆ applyAsicFilter()

void applyAsicFilter ( std::vector< CDCWireHit * > &  wireHits)
private

Algorithm marking hit as background for each CDC ASIC.

This is abnormal situation, detected for few runs, related to CDC unpacker. Hits are to be marked as background.

Definition at line 95 of file AsicBackgroundDetector.cc.

96 {
97 
98  if (wireHits.size() < m_minimal_hit_number) {
99  return;
100  };
101 
102  if (wireHits.size() > 8) {
103  B2ERROR("Number of hits per asic should not exceed 8, observe too many hits." << LogVar("nHits", wireHits.size()));
105  for (auto& hit : wireHits) {
106  (*hit)->setBackgroundFlag();
107  (*hit)->setTakenFlag();
108  }
109  return;
110  }
111 
112  B2ASSERT("Number of hits per asic should be above 0 and can not exceed 8",
113  (wireHits.size() <= 8) && (wireHits.size() > 0));
114 
115  // compute median time:
116  vector<short> times;
117  for (auto& hit : wireHits) {
118  short tdc = hit->getHit()->getTDCCount();
119  times.push_back(tdc);
120  }
121  sort(times.begin(), times.end());
122  int mid = times.size() / 2;
123  double median = times.size() % 2 == 0 ? (times[mid] + times[mid - 1]) / 2 : times[mid];
124 
125 
126  size_t nbg = 0;
127  int adcOnMedian = 0;
128  int adcOffMedian = 0;
129  for (auto& hit : wireHits) {
130  int adc = hit->getHit()->getADCCount();
131  if (abs(hit->getHit()->getTDCCount() - median) < m_deviation_from_median) {
132  nbg++;
133  if (adc > adcOnMedian) adcOnMedian = adc;
134  } else {
135  if (adc > adcOffMedian) adcOffMedian = adc;
136  }
137  }
138 
139  if ((nbg < times.size()) // at least 1 hit with different TDC ("signal")
140  && (nbg > 1) // more than one candidate hits
141  && (nbg > times.size() - m_nsignal_max) // a few background hits
142  && (adcOnMedian < adcOffMedian) // triggered by large ADC "signal"
143  ) {
144 
145  // mark hits too close to the median time as background:
146  for (auto& hit : wireHits) {
147  if (abs(hit->getHit()->getTDCCount() - median) < m_deviation_from_median) {
148  (*hit)->setBackgroundFlag();
149  (*hit)->setTakenFlag();
150  }
151  }
152  }
153 }

The documentation for this class was generated from the following files:
Belle2::TrackFindingCDC::AsicBackgroundDetector::m_deviation_from_median
double m_deviation_from_median
distance from median TDC, to be considered as bg.
Definition: AsicBackgroundDetector.h:76
Belle2::TrackFindingCDC::AsicBackgroundDetector::m_minimal_hit_number
size_t m_minimal_hit_number
min. number of hits in ASIC for background check
Definition: AsicBackgroundDetector.h:73
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24
Belle2::TrackFindingCDC::AsicBackgroundDetector::m_nsignal_max
size_t m_nsignal_max
max. number of signal-like hits in ASIC for background check
Definition: AsicBackgroundDetector.h:79