Belle II Software  release-08-01-10
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 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 29 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 178 of file AsicBackgroundLibraryCreator.cc.

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

The documentation for this class was generated from the following files: