Belle II Software  release-05-02-19
AsicBackgroundLibraryCreator Class Referenceabstract

Finds ASICs with single signal hit, records info to the library. More...

#include <AsicBackgroundLibraryCreator.h>

Inheritance diagram for AsicBackgroundLibraryCreator:
Collaboration diagram for AsicBackgroundLibraryCreator:

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

 AsicBackgroundLibraryCreator ()=default
 Default constructor.
 
void initialize () final
 Access database here, open library for writing:
 
void beginRun () final
 Reload channel map if needed.
 
std::string getDescription () final
 Short description of the findlet.
 
void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the parameters to a module.
 
void apply (const std::vector< CDCWireHit > &wireHits, const std::vector< CDCTrack > &tracks) final
 Main algorithm marking hit as background.
 
void terminate () final
 write out the library
 
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.
 

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< const CDCWireHit, const CDCTrack >
 Type of the base class.
 

Private Member Functions

void selectAsic (const std::vector< const CDCWireHit * > &wireHits, const std::vector< CDCTrack > &tracks)
 Algorithm to select suitable ASIC for library creation. 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
 
std::string m_library_name {"CDCAsicLibrary.root"}
 output library name
 
size_t m_minimal_hit_number {1}
 min. number of hits in ASIC for background check
 
double m_distance_signal_max {0.25}
 maximal distance from track to signal hit
 
double m_distance_background_min {0.5}
 minimal distance from track to background hit
 
bool m_use_axial_hits_only {false}
 use axial layers only
 
bool m_write_extra_vars {false}
 extra vars to the library
 
size_t m_minimal_hits_on_track {40}
 min. number of hits on the track
 
std::unique_ptr< Recorderm_recorder
 Recorder for the root output.
 
asicChannel m_asic_info [8]
 all 8 channels
 
UChar_t m_board {0}
 signal boardID
 
UChar_t m_channel {0}
 signal channelID
 
UChar_t m_n_hit {0}
 For debuging, store also number of channels with hits.
 
float m_dist_signal {0}
 Distance to signal hit.
 
float m_dist_bg {0}
 min. distance to non-linked hits
 
Short_t m_adc_sig {0}
 ADC of the signal.
 
Short_t m_adc_max_bg {0}
 Max. ADC background.
 
UShort_t m_n_hit_track {0}
 Number of hits on the track.
 
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

Finds ASICs with single signal hit, records info to the library.

Definition at line 39 of file AsicBackgroundLibraryCreator.h.

Member Function Documentation

◆ selectAsic()

void selectAsic ( const std::vector< const CDCWireHit * > &  wireHits,
const std::vector< CDCTrack > &  tracks 
)
private

Algorithm to select suitable ASIC for library creation.

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

Definition at line 180 of file AsicBackgroundLibraryCreator.cc.

181 {
182 
183  if (wireHits.size() < m_minimal_hit_number) {
184  return;
185  };
186 
187  if (wireHits.size() > 8) {
188  B2ERROR("Number of hits per asic should not exceed 8, observe too many hits." << LogVar("nHits", wireHits.size()));
190  return;
191  }
192 
193 
194  // count taken non-background hits:
195  int count = 0;
196  const CDCWireHit* signal = nullptr;
197  for (auto& hit : wireHits) {
198  if (!(*hit)->hasBackgroundFlag() && (*hit)->hasTakenFlag()) {
199  count += 1;
200  signal = hit;
201  }
202  }
203 
204  // require one and only one taken hit
205  if (count != 1) {
206  return;
207  }
208 
209 
210  // check if only axial hits are used:
211 
212  if ((!signal->isAxial()) && m_use_axial_hits_only) {
213  return;
214  }
215 
216  // find the track to which this hit belongs
217  const CDCTrack* signalTrack = nullptr;
218  for (auto& track : tracks) {
219  for (auto& hit : track) {
220  if (&hit.getWireHit() == signal) {
221  signalTrack = &track;
222  break;
223  }
224  }
225  if (signalTrack != nullptr) {
226  break;
227  }
228  }
229 
230  if (signalTrack == nullptr) {
231  B2DEBUG(29, "AsicBackgroundLibraryCreator::No track found for the signal hit");
232  return;
233  }
234 
235  m_n_hit_track = signalTrack->size();
236 
238 
239  // check the distance from the track to each signal hit
240  const auto& trajectory = signalTrack->getStartTrajectory3D();
241 
242  m_dist_bg = 1000.;
243 
244  for (auto& hit : wireHits) {
245 
246  const float dist = getDist2D(trajectory, hit);
247 
248 
249  if (hit == signal) {
250  m_dist_signal = dist;
251  if (dist > m_distance_signal_max) return;
252  } else {
253  m_dist_bg = min(m_dist_bg, dist);
254  if (dist < m_distance_background_min) return;
255  }
256  }
257 
258 
259  // Ok, passes all cuts !
260 
261  // reset the library entries
262  for (auto& channel : m_asic_info) {
263  channel.TDC = -1;
264  channel.ADC = -1;
265  channel.TOT = -1;
266  }
267 
268  // add to the library
269 
270  m_n_hit = wireHits.size();
271 
272  m_adc_max_bg = 0;
273  for (auto& hit : wireHits) {
274  auto eWire = hit->getWireID().getEWire();
275  auto channel = m_map[eWire].second;
276  auto asicCH = channel % 8;
277  m_asic_info[asicCH].ADC = hit->getHit()->getADCCount();
278  m_asic_info[asicCH].TDC = hit->getHit()->getTDCCount();
279  m_asic_info[asicCH].TOT = hit->getHit()->getTOT();
280 
281  if (hit != signal) {
282  m_adc_max_bg = max(m_adc_max_bg, m_asic_info[asicCH].ADC);
283  }
284  }
285  // also signal hit info
286  auto eWire = signal->getWireID().getEWire();
287  m_channel = m_map[eWire].second;
288  m_board = m_map[eWire].first;
289  m_adc_sig = signal->getHit()->getADCCount();
290 
291  // make sure that ADC of the signal is >= than ADC of the background:
292  if (m_adc_sig < m_adc_max_bg) return;
293 
294  // write out
295  m_recorder->capture();
296 }

The documentation for this class was generated from the following files:
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_minimal_hits_on_track
size_t m_minimal_hits_on_track
min. number of hits on the track
Definition: AsicBackgroundLibraryCreator.h:97
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_n_hit_track
UShort_t m_n_hit_track
Number of hits on the track.
Definition: AsicBackgroundLibraryCreator.h:131
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_adc_max_bg
Short_t m_adc_max_bg
Max. ADC background.
Definition: AsicBackgroundLibraryCreator.h:128
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_distance_background_min
double m_distance_background_min
minimal distance from track to background hit
Definition: AsicBackgroundLibraryCreator.h:87
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_distance_signal_max
double m_distance_signal_max
maximal distance from track to signal hit
Definition: AsicBackgroundLibraryCreator.h:84
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_asic_info
asicChannel m_asic_info[8]
all 8 channels
Definition: AsicBackgroundLibraryCreator.h:105
Belle2::asicChannel::ADC
Short_t ADC
ADC info
Definition: CDCCrossTalkClasses.h:25
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_channel
UChar_t m_channel
signal channelID
Definition: AsicBackgroundLibraryCreator.h:111
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_adc_sig
Short_t m_adc_sig
ADC of the signal.
Definition: AsicBackgroundLibraryCreator.h:125
Belle2::asicChannel::TOT
Short_t TOT
Time over threshold.
Definition: CDCCrossTalkClasses.h:26
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_dist_bg
float m_dist_bg
min. distance to non-linked hits
Definition: AsicBackgroundLibraryCreator.h:122
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_use_axial_hits_only
bool m_use_axial_hits_only
use axial layers only
Definition: AsicBackgroundLibraryCreator.h:90
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_recorder
std::unique_ptr< Recorder > m_recorder
Recorder for the root output.
Definition: AsicBackgroundLibraryCreator.h:100
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_n_hit
UChar_t m_n_hit
For debuging, store also number of channels with hits.
Definition: AsicBackgroundLibraryCreator.h:114
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_dist_signal
float m_dist_signal
Distance to signal hit.
Definition: AsicBackgroundLibraryCreator.h:119
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_board
UChar_t m_board
signal boardID
Definition: AsicBackgroundLibraryCreator.h:108
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_map
std::map< int, std::pair< int, int > > m_map
map from ewire to board/channel ID
Definition: AsicBackgroundLibraryCreator.h:75
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::TrackFindingCDC::AsicBackgroundLibraryCreator::m_minimal_hit_number
size_t m_minimal_hit_number
min. number of hits in ASIC for background check
Definition: AsicBackgroundLibraryCreator.h:81
Belle2::asicChannel::TDC
Short_t TDC
TDC info
Definition: CDCCrossTalkClasses.h:24