Belle II Software development
AsicBackgroundLibraryCreator Class Referenceabstract

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

#include <AsicBackgroundLibraryCreator.h>

Inheritance diagram for AsicBackgroundLibraryCreator:
Findlet< const TrackingUtilities::CDCWireHit, const TrackingUtilities::CDCTrack > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using IOTypes
 Types that should be served to apply on invocation.
 
using IOTypes
 Types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 

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< TrackingUtilities::CDCWireHit > &wireHits, const std::vector< TrackingUtilities::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
 Short hand for ToRangeImpl.
 
using ToVector
 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 = TrackingUtilities::Findlet<const TrackingUtilities::CDCWireHit, const TrackingUtilities::CDCTrack >
 Type of the base class.
 

Private Member Functions

void selectAsic (const std::vector< const TrackingUtilities::CDCWireHit * > &wireHits, const std::vector< TrackingUtilities::CDCTrack > &tracks)
 Algorithm to select suitable ASIC for library creation.
 

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< TrackingUtilities::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 debugging, 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 happened before.
 
bool m_terminated = false
 Flag to keep track whether termination happened 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 31 of file AsicBackgroundLibraryCreator.h.

Member Typedef Documentation

◆ IOTypes [1/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOTypes [2/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors [1/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ IOVectors [2/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

Type of the base class.

Definition at line 35 of file AsicBackgroundLibraryCreator.h.

◆ ToVector [1/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

◆ ToVector [2/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener * psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 55 of file CompositeProcessingSignalListener.cc.

56{
58}
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
References to subordinary signal processing listener contained in this findlet.

◆ apply()

void apply ( const std::vector< TrackingUtilities::CDCWireHit > & wireHits,
const std::vector< TrackingUtilities::CDCTrack > & tracks )
final

Main algorithm marking hit as background.

Definition at line 111 of file AsicBackgroundLibraryCreator.cc.

112{
113
114 std::map< std::pair<int, int>, std::vector<const CDCWireHit*>> groupedByAsic;
115 for (const CDCWireHit& wireHit : wireHits) {
116 auto eWire = wireHit.getWireID().getEWire();
117 B2ASSERT("Channel map NOT found for the channel", m_map.count(eWire) > 0);
118 auto board = m_map[eWire].first;
119 auto channel = m_map[eWire].second;
120 auto asicID = std::pair<int, int>(board, channel / 8); // ASIC are groups of 8 channels
121 groupedByAsic[asicID].push_back(&wireHit);
122 };
123 for (auto& asicList : groupedByAsic) {
124 selectAsic(asicList.second, tracks);
125 };
126
127 return;
128}
void selectAsic(const std::vector< const TrackingUtilities::CDCWireHit * > &wireHits, const std::vector< TrackingUtilities::CDCTrack > &tracks)
Algorithm to select suitable ASIC for library creation.
std::map< int, std::pair< int, int > > m_map
map from ewire to board/channel ID

◆ beginEvent()

void beginEvent ( )
overridevirtualinherited

Receive and dispatch signal for the start of a new event.

Reimplemented from ProcessingSignalListener.

Reimplemented in DATCONFPGAFindlet, SpacePointTagger< AResult, ACluster >, SpacePointTagger< Belle2::CKFToPXDResult, Belle2::PXDCluster >, SpacePointTagger< Belle2::CKFToSVDResult, Belle2::SVDCluster >, MCSymmetric< BaseAxialSegmentPairFilter >, MCSymmetric< BaseAxialSegmentPairFilter >, MCSymmetric< BaseFacetFilter >, MCSymmetric< BaseFacetFilter >, MCSymmetric< BaseFacetRelationFilter >, MCSymmetric< BaseFacetRelationFilter >, MCSymmetric< BaseSegmentPairFilter >, MCSymmetric< BaseSegmentPairFilter >, MCSymmetric< BaseSegmentPairRelationFilter >, MCSymmetric< BaseSegmentPairRelationFilter >, MCSymmetric< BaseSegmentRelationFilter >, MCSymmetric< BaseSegmentRelationFilter >, MCSymmetric< BaseSegmentTripleFilter >, MCSymmetric< BaseSegmentTripleFilter >, MCSymmetric< BaseSegmentTripleRelationFilter >, MCSymmetric< BaseSegmentTripleRelationFilter >, MCSymmetric< BaseTrackRelationFilter >, MCSymmetric< BaseTrackRelationFilter >, MonopoleStereoHitFinder, MonopoleStereoHitFinderQuadratic, SegmentCreatorMCTruth, SegmentFinderFacetAutomaton, SegmentTrackCombiner, SegmentTrackTruthVarSet, StereoHitFinder, StereoHitTruthVarSet, TrackFinderAutomaton, TrackFinderSegmentPairAutomaton, TrackFinderSegmentTripleAutomaton, TruthAxialSegmentPairVarSet, TruthSegmentVarSet, TruthTrackVarSet, WireHitMCMultiLoopBlocker, FindletStoreArrayInput< TWrappedFindlet >, SharingHitsMatcher< ACollectorItem, ACollectionItem >, SharingHitsMatcher< Belle2::TrackingUtilities::CDCTrack, Belle2::TrackingUtilities::CDCSegment2D >, StoreVectorSwapper< IOType, a_alwaysWrite >, StoreVectorSwapper< Belle2::TrackingUtilities::CDCFacet >, StoreVectorSwapper< Belle2::TrackingUtilities::CDCSegment2D >, StoreVectorSwapper< Belle2::TrackingUtilities::CDCSegmentPair >, StoreVectorSwapper< Belle2::TrackingUtilities::CDCSegmentTriple >, StoreVectorSwapper< Belle2::TrackingUtilities::CDCTrack >, StoreVectorSwapper< Belle2::TrackingUtilities::CDCWireHit, true >, RecoTrackStorer, ROIFinder, and SVDHoughTracking.

Definition at line 31 of file CompositeProcessingSignalListener.cc.

32{
35 psl->beginEvent();
36 }
37}
virtual void beginEvent()
Receive signal for the start of a new event.
ProcessingSignalListener()
Allow default construction.

◆ beginRun()

void beginRun ( )
finalvirtual

Reload channel map if needed.

Reimplemented from ProcessingSignalListener.

Definition at line 91 of file AsicBackgroundLibraryCreator.cc.

92{
94 // Load map from DB:
95 for (const auto& cm : (*m_channelMapFromDB)) {
96 const int isl = cm.getISuperLayer();
97 const int il = cm.getILayer();
98 const int iw = cm.getIWire();
99 const int iBoard = cm.getBoardID();
100 const int iCh = cm.getBoardChannel();
101 const WireID wireId(isl, il, iw);
102 m_map[wireId.getEWire()] = std::pair<int, int>(iBoard, iCh);
103 }
104}
std::unique_ptr< DBArray< CDCChannelMap > > m_channelMapFromDB
Channel map retrieved from DB.

◆ endRun()

void endRun ( )
overridevirtualinherited

Receive and dispatch signal for the end of the run.

Reimplemented from ProcessingSignalListener.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
virtual void endRun()
Receive signal for the end of the run.

◆ exposeParameters()

void exposeParameters ( ModuleParamList * moduleParamList,
const std::string & prefix )
finalvirtual

Expose the parameters to a module.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 130 of file AsicBackgroundLibraryCreator.cc.

131{
132 Super::exposeParameters(moduleParamList, prefix);
133 moduleParamList->addParameter(prefixed(prefix, "minimalHitNumberASIC"),
135 "Required number of hits per ASIC for library creation",
137
138 moduleParamList->addParameter(prefixed(prefix, "AsicLibraryFileName"),
140 "ASIC library file name",
142
143 moduleParamList->addParameter(prefixed(prefix, "maximalDistanceSignal"),
145 "maximal distance in cm from track to signal hit",
147
148 moduleParamList->addParameter(prefixed(prefix, "minimalDistanceBackground"),
150 "minimal distance in cm from track to background hit",
152
153 moduleParamList->addParameter(prefixed(prefix, "useAxialHitsOnly"),
155 "use axial layers only",
157
158 moduleParamList->addParameter(prefixed(prefix, "writeExtraVars"),
160 "Write extra variables to the library",
162
163 moduleParamList->addParameter(prefixed(prefix, "minimalHitsOnTrack"),
165 "Required number of hits on track for library creation",
167
168 // set some defaults:
169 moduleParamList->getParameter<std::string>("inputTracks").setDefaultValue("CDCTrackVector");
170 moduleParamList->getParameter<std::string>("inputWireHits").setDefaultValue("CDCWireHitVector");
171}
double m_distance_signal_max
maximal distance from track to signal hit
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
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ getDescription()

std::string getDescription ( )
finalvirtual

Short description of the findlet.

Reimplemented from Findlet< const TrackingUtilities::CDCWireHit, const TrackingUtilities::CDCTrack >.

Definition at line 106 of file AsicBackgroundLibraryCreator.cc.

107{
108 return "Finds suitable ASICs with a single hit attached to a track and uses them to create the library";
109}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
finalvirtual

Access database here, open library for writing:

Reimplemented from ProcessingSignalListener.

Definition at line 57 of file AsicBackgroundLibraryCreator.cc.

58{
60 // database:
61 m_channelMapFromDB = std::make_unique<DBArray<CDCChannelMap>> ();
62
63 if ((*m_channelMapFromDB).isValid()) {
64 B2DEBUG(29, "CDC Channel map is valid");
65 } else {
66 B2FATAL("CDC Channel map is not valid");
67 }
68
69 // Library for writing
70
71 auto leavesCreator = [this](TTree & tree) {
73 tree.Branch("Dist", &m_dist_signal, "DistSig/f:DistBg/f");
74 tree.Branch("ADC", &m_adc_sig, "ADC_Sig/S:ADC_bg/S");
75 tree.Branch("Track", &m_n_hit_track, "tr_nhit/S");
76 }
77 tree.Branch("Board", &m_board, "board/b");
78 tree.Branch("Channel", &m_channel, "channel/b");
79 tree.Branch("Nhit", &m_n_hit, "nhit/b");
80 tree.Branch("Asic", &m_asic_info[0],
81 "TDC0/S:ADC0/S:TOT0/S:TDC1/S:ADC1/S:TOT1/S:TDC2/S:ADC2/S:TOT2/S:TDC3/S:ADC3/S:TOT3/S:TDC4/S:ADC4/S:TOT4/S:TDC5/S:ADC5/S:TOT5/S:TDC6/S:ADC6/S:TOT6/S:TDC7/S:ADC7/S:TOT7/S");
82 return;
83 };
84
85 m_recorder.reset(new Recorder(
86 leavesCreator
88 , "ASIC"));
89}
UChar_t m_n_hit
For debugging, store also number of channels with hits.
std::unique_ptr< TrackingUtilities::Recorder > m_recorder
Recorder for the root output.

◆ selectAsic()

void selectAsic ( const std::vector< const TrackingUtilities::CDCWireHit * > & wireHits,
const std::vector< TrackingUtilities::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 179 of file AsicBackgroundLibraryCreator.cc.

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

◆ terminate()

void terminate ( )
finalvirtual

Member Data Documentation

◆ m_adc_max_bg

Short_t m_adc_max_bg {0}
private

Max. ADC background.

Definition at line 123 of file AsicBackgroundLibraryCreator.h.

123{0};

◆ m_adc_sig

Short_t m_adc_sig {0}
private

ADC of the signal.

Definition at line 120 of file AsicBackgroundLibraryCreator.h.

120{0};

◆ m_asic_info

asicChannel m_asic_info[8]
private

all 8 channels

Definition at line 100 of file AsicBackgroundLibraryCreator.h.

◆ m_board

UChar_t m_board {0}
private

signal boardID

Definition at line 103 of file AsicBackgroundLibraryCreator.h.

103{0};

◆ m_channel

UChar_t m_channel {0}
private

signal channelID

Definition at line 106 of file AsicBackgroundLibraryCreator.h.

106{0};

◆ m_channelMapFromDB

std::unique_ptr<DBArray<CDCChannelMap> > m_channelMapFromDB
private

Channel map retrieved from DB.

Definition at line 67 of file AsicBackgroundLibraryCreator.h.

◆ m_dist_bg

float m_dist_bg {0}
private

min. distance to non-linked hits

Definition at line 117 of file AsicBackgroundLibraryCreator.h.

117{0};

◆ m_dist_signal

float m_dist_signal {0}
private

Distance to signal hit.

Definition at line 114 of file AsicBackgroundLibraryCreator.h.

114{0};

◆ m_distance_background_min

double m_distance_background_min {0.5}
private

minimal distance from track to background hit

Definition at line 82 of file AsicBackgroundLibraryCreator.h.

82{0.5};

◆ m_distance_signal_max

double m_distance_signal_max {0.25}
private

maximal distance from track to signal hit

Definition at line 79 of file AsicBackgroundLibraryCreator.h.

79{0.25};

◆ m_initialized

bool m_initialized = false
privateinherited

Flag to keep track whether initialization happened before.

Definition at line 52 of file ProcessingSignalListener.h.

◆ m_initializedAs

std::string m_initializedAs
privateinherited

Name of the type during initialisation.

Definition at line 58 of file ProcessingSignalListener.h.

◆ m_library_name

std::string m_library_name {"CDCAsicLibrary.root"}
private

output library name

Definition at line 73 of file AsicBackgroundLibraryCreator.h.

73{"CDCAsicLibrary.root"};

◆ m_map

std::map<int, std::pair<int, int> > m_map
private

map from ewire to board/channel ID

Definition at line 70 of file AsicBackgroundLibraryCreator.h.

◆ m_minimal_hit_number

size_t m_minimal_hit_number {1}
private

min. number of hits in ASIC for background check

Definition at line 76 of file AsicBackgroundLibraryCreator.h.

76{1};

◆ m_minimal_hits_on_track

size_t m_minimal_hits_on_track {40}
private

min. number of hits on the track

Definition at line 92 of file AsicBackgroundLibraryCreator.h.

92{40};

◆ m_n_hit

UChar_t m_n_hit {0}
private

For debugging, store also number of channels with hits.

Definition at line 109 of file AsicBackgroundLibraryCreator.h.

109{0};

◆ m_n_hit_track

UShort_t m_n_hit_track {0}
private

Number of hits on the track.

Definition at line 126 of file AsicBackgroundLibraryCreator.h.

126{0};

◆ m_recorder

std::unique_ptr<TrackingUtilities::Recorder> m_recorder
private

Recorder for the root output.

Definition at line 95 of file AsicBackgroundLibraryCreator.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 60 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated = false
privateinherited

Flag to keep track whether termination happened before.

Definition at line 55 of file ProcessingSignalListener.h.

◆ m_use_axial_hits_only

bool m_use_axial_hits_only {false}
private

use axial layers only

Definition at line 85 of file AsicBackgroundLibraryCreator.h.

85{false};

◆ m_write_extra_vars

bool m_write_extra_vars {false}
private

extra vars to the library

Definition at line 88 of file AsicBackgroundLibraryCreator.h.

88{false};

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