 |
Belle II Software
release-05-02-19
|
10 #include <tracking/trackFindingCDC/findlets/complete/AsicBackgroundLibraryCreator.h>
11 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
12 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
13 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
14 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
15 #include <tracking/trackFindingCDC/topology/CDCWire.h>
16 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
17 #include <framework/core/ModuleParamList.templateDetails.h>
18 #include <cdc/dataobjects/CDCHit.h>
19 #include <framework/logging/Logger.h>
25 using namespace TrackFindingCDC;
40 if (wireHit->isAxial()) {
41 recoPos2D = wireHit->reconstruct2D(trajectory2D);
46 const double z = trajectorySZ.
mapSToZ(arcLength);
49 const double driftLength = wireHit->getRefDriftLength();
52 recoPos2D = wirePos2DAtZ + disp2D;
54 const float distanceToHit = trajectory2D.
getDist2D(recoPos2D);
55 return abs(distanceToHit);
64 if ((*m_channelMapFromDB).isValid()) {
65 B2DEBUG(29,
"CDC Channel map is valid");
67 B2FATAL(
"CDC Channel map is not valid");
72 auto leavesCreator = [
this](TTree & tree) {
75 tree.Branch(
"ADC", &
m_adc_sig,
"ADC_Sig/S:ADC_bg/S");
78 tree.Branch(
"Board", &
m_board,
"board/b");
79 tree.Branch(
"Channel", &
m_channel,
"channel/b");
80 tree.Branch(
"Nhit", &
m_n_hit,
"nhit/b");
82 "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");
97 const int isl = cm.getISuperLayer();
98 const int il = cm.getILayer();
99 const int iw = cm.getIWire();
100 const int iBoard = cm.getBoardID();
101 const int iCh = cm.getBoardChannel();
102 const WireID wireId(isl, il, iw);
109 return "Finds suitable ASICs with a single hit attached to a track and uses them to create the library";
115 map< pair<int, int>, vector<const CDCWireHit*>> groupedByAsic;
118 B2ASSERT(
"Channel map NOT found for the channel",
m_map.count(eWire) > 0);
119 auto board =
m_map[eWire].first;
120 auto channel =
m_map[eWire].second;
121 auto asicID = pair<int, int>(board, channel / 8);
122 groupedByAsic[asicID].push_back(&wireHit);
124 for (
auto& [asicID, asicList] : groupedByAsic) {
134 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"minimalHitNumberASIC"),
136 "Required number of hits per ASIC for library creation",
139 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"AsicLibraryFileName"),
141 "ASIC library file name",
144 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"maximalDistanceSignal"),
146 "maximal distance in cm from track to signal hit",
149 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"minimalDistanceBackground"),
151 "minimal distance in cm from track to background hit",
154 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"useAxialHitsOnly"),
156 "use axial layers only",
159 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"writeExtraVars"),
161 "Write extra variables to the library",
164 moduleParamList->
addParameter(TrackFindingCDC::prefixed(prefix,
"minimalHitsOnTrack"),
166 "Required number of hits on track for library creation",
170 moduleParamList->
getParameter<std::string>(
"inputTracks").setDefaultValue(
"CDCTrackVector");
171 moduleParamList->
getParameter<std::string>(
"inputWireHits").setDefaultValue(
"CDCWireHitVector");
187 if (wireHits.size() > 8) {
188 B2ERROR(
"Number of hits per asic should not exceed 8, observe too many hits." <<
LogVar(
"nHits", wireHits.size()));
197 for (
auto& hit : wireHits) {
198 if (!(*hit)->hasBackgroundFlag() && (*hit)->hasTakenFlag()) {
217 const CDCTrack* signalTrack =
nullptr;
218 for (
auto& track : tracks) {
219 for (
auto& hit : track) {
220 if (&hit.getWireHit() == signal) {
221 signalTrack = &track;
225 if (signalTrack !=
nullptr) {
230 if (signalTrack ==
nullptr) {
231 B2DEBUG(29,
"AsicBackgroundLibraryCreator::No track found for the signal hit");
240 const auto& trajectory = signalTrack->getStartTrajectory3D();
244 for (
auto& hit : wireHits) {
246 const float dist = getDist2D(trajectory, hit);
273 for (
auto& hit : wireHits) {
274 auto eWire = hit->getWireID().getEWire();
275 auto channel =
m_map[eWire].second;
276 auto asicCH = channel % 8;
286 auto eWire = signal->getWireID().getEWire();
289 m_adc_sig = signal->getHit()->getADCCount();
size_t m_minimal_hits_on_track
min. number of hits on the track
Class to identify a wire inside the CDC.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
Class representing a sequence of three dimensional reconstructed hits.
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
UShort_t m_n_hit_track
Number of hits on the track.
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
unsigned short getEWire() const
Getter for encoded wire number.
Short_t m_adc_max_bg
Max. ADC background.
std::string m_library_name
output library name
double m_distance_background_min
minimal distance from track to background hit
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
double m_distance_signal_max
maximal distance from track to signal hit
std::unique_ptr< DBArray< CDCChannelMap > > m_channelMapFromDB
Channel map retrieved from DB.
asicChannel m_asic_info[8]
all 8 channels
Class to fill a tree from a set of variables.
Linear trajectory in sz space.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
Particle trajectory as it is seen in xy projection represented as a circle.
Vector2D getWirePos2DAtZ(const double z) const
Gives the xy projected position of the wire at the given z coordinate.
void initialize() override
Receive and dispatch signal before the start of the event processing.
double mapSToZ(const double s=0) const
Translates the travel distance to the z coordinate.
void beginRun() final
Reload channel map if needed.
UChar_t m_channel
signal channelID
Short_t m_adc_sig
ADC of the signal.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the sz trajectory.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.
virtual void exposeParameters(ModuleParamList *moduleParamList __attribute__((unused)), const std::string &prefix __attribute__((unused)))
Forward prefixed parameters of this findlet to the module parameter list.
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
Short_t TOT
Time over threshold.
Class to store variables with their name which were sent to the logging service.
bool m_write_extra_vars
extra vars to the library
float m_dist_bg
min. distance to non-linked hits
void terminate() final
write out the library
bool m_use_axial_hits_only
use axial layers only
void terminate() override
Receive and dispatch Signal for termination of the event processing.
std::unique_ptr< Recorder > m_recorder
Recorder for the root output.
UChar_t m_n_hit
For debuging, store also number of channels with hits.
float m_dist_signal
Distance to signal hit.
UChar_t m_board
signal boardID
void selectAsic(const std::vector< const CDCWireHit * > &wireHits, const std::vector< CDCTrack > &tracks)
Algorithm to select suitable ASIC for library creation.
std::string getDescription() final
Short description of the findlet.
Class representing a sense wire in the central drift chamber.
double getDist2D(const Vector2D &point) const
Calculates the distance from the point to the trajectory as seen from the xy projection.
std::map< int, std::pair< int, int > > m_map
map from ewire to board/channel ID
Class representing a hit wire in the central drift chamber.
The Module parameter list class.
size_t m_minimal_hit_number
min. number of hits in ASIC for background check
double calcArcLength2D(const Vector2D &point) const
Calculate the travel distance from the start position of the trajectory.
void apply(const std::vector< CDCWireHit > &wireHits, const std::vector< CDCTrack > &tracks) final
Main algorithm marking hit as background.
Particle full three dimensional trajectory.
void initialize() final
Access database here, open library for writing: