Belle II Software development
CDCTrigger2DFinderModule Class Reference
Inheritance diagram for CDCTrigger2DFinderModule:
Module PathElement

Public Types

enum  EModulePropFlags {
  c_Input = 1 ,
  c_Output = 2 ,
  c_ParallelProcessingCertified = 4 ,
  c_HistogramManager = 8 ,
  c_InternalSerializer = 16 ,
  c_TerminateInAllProcesses = 32 ,
  c_DontCollectStatistics = 64
}
 Each module can be tagged with property flags, which indicate certain features of the module. More...
 
typedef ModuleCondition::EAfterConditionPath EAfterConditionPath
 Forward the EAfterConditionPath definition from the ModuleCondition.
 

Public Member Functions

 CDCTrigger2DFinderModule ()
 Constructor.
 
virtual void initialize () override
 Initialize the module and check module parameters.
 
virtual void event () override
 Run tracking.
 
virtual void terminate () override
 Clean up.
 
int fastInterceptFinder (cdcMap &hits, double x1_s, double x2_s, double y1_s, double y2_s, unsigned iterations, unsigned ix_s, unsigned iy_s)
 Fast intercept finder Divide Hough plane recursively to find cells with enough crossing lines.
 
unsigned short countSL (bool *superLayers)
 count the number of super layers with hits
 
bool shortTrack (bool *superLayers)
 check the short track condition (= hits in the inner super layers rather than any super layers)
 
void connectedRegions ()
 Combine Hough candidates to tracks by merging connected cells.
 
void addNeighbors (const CDCTriggerHoughCand &center, const std::vector< CDCTriggerHoughCand > &candidates, std::vector< CDCTriggerHoughCand > &merged, std::vector< CDCTriggerHoughCand > &rejected, unsigned short nSLmax) const
 Recursive function to add combine connected cells.
 
bool inList (const CDCTriggerHoughCand &a, const std::vector< CDCTriggerHoughCand > &list) const
 Check if candidate is in list.
 
bool connected (const CDCTriggerHoughCand &a, const CDCTriggerHoughCand &b) const
 Check if candidates are connected.
 
void mergeIdList (std::vector< unsigned > &merged, std::vector< unsigned > &a, std::vector< unsigned > &b)
 Merge lists a and b and put the result in merged.
 
void patternClustering (const cdcMap &inputMap)
 Combine Hough candidates to tracks by a fixed pattern algorithm.
 
bool connectedLR (unsigned patternL, unsigned patternR)
 Check for left/right connection of patterns in 2 x 2 squares.
 
bool connectedUD (unsigned patternD, unsigned patternU)
 Check for up/down connection of patterns in 2 x 2 squares.
 
bool connectedDiag (unsigned patternLD, unsigned patternRU)
 Check for diagonal connected of patterns in 2 x 2 squares.
 
unsigned topRightSquare (std::vector< unsigned > &pattern)
 Find the top right square within a cluster of 2 x 2 squares In case of ambiguity, top is favored over right @ return index of corner within pattern vector.
 
unsigned topRightCorner (unsigned pattern)
 Find the top right corner within 2 x 2 square.
 
unsigned bottomLeftCorner (unsigned pattern)
 Find the bottom left corner within 2 x 2 square.
 
void findAllCrossingHits (std::vector< unsigned > &list, double x1, double x2, double y1, double y2, const cdcMap &inputMap)
 Find all hits in inputMap whose Hough curve crosses the rectangle with corners (x1, y1) and (x2, y2) and add the hit indices to list.
 
void selectHits (std::vector< unsigned > &list, std::vector< unsigned > &selected, std::vector< unsigned > &unselected)
 Select one hit per super layer.
 
virtual std::vector< std::string > getFileNames (bool outputFiles)
 Return a list of output filenames for this modules.
 
virtual void beginRun ()
 Called when entering a new run.
 
virtual void endRun ()
 This method is called if the current run ends.
 
const std::string & getName () const
 Returns the name of the module.
 
const std::string & getType () const
 Returns the type of the module (i.e.
 
const std::string & getPackage () const
 Returns the package this module is in.
 
const std::string & getDescription () const
 Returns the description of the module.
 
void setName (const std::string &name)
 Set the name of the module.
 
void setPropertyFlags (unsigned int propertyFlags)
 Sets the flags for the module properties.
 
LogConfiggetLogConfig ()
 Returns the log system configuration.
 
void setLogConfig (const LogConfig &logConfig)
 Set the log system configuration.
 
void setLogLevel (int logLevel)
 Configure the log level.
 
void setDebugLevel (int debugLevel)
 Configure the debug messaging level.
 
void setAbortLevel (int abortLevel)
 Configure the abort log level.
 
void setLogInfo (int logLevel, unsigned int logInfo)
 Configure the printed log information for the given level.
 
void if_value (const std::string &expression, const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 Add a condition to the module.
 
void if_false (const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 A simplified version to add a condition to the module.
 
void if_true (const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
 A simplified version to set the condition of the module.
 
bool hasCondition () const
 Returns true if at least one condition was set for the module.
 
const ModuleConditiongetCondition () const
 Return a pointer to the first condition (or nullptr, if none was set)
 
const std::vector< ModuleCondition > & getAllConditions () const
 Return all set conditions for this module.
 
bool evalCondition () const
 If at least one condition was set, it is evaluated and true returned if at least one condition returns true.
 
std::shared_ptr< PathgetConditionPath () const
 Returns the path of the last true condition (if there is at least one, else reaturn a null pointer).
 
Module::EAfterConditionPath getAfterConditionPath () const
 What to do after the conditional path is finished.
 
std::vector< std::shared_ptr< Path > > getAllConditionPaths () const
 Return all condition paths currently set (no matter if the condition is true or not).
 
bool hasProperties (unsigned int propertyFlags) const
 Returns true if all specified property flags are available in this module.
 
bool hasUnsetForcedParams () const
 Returns true and prints error message if the module has unset parameters which the user has to set in the steering file.
 
const ModuleParamListgetParamList () const
 Return module param list.
 
template<typename T >
ModuleParam< T > & getParam (const std::string &name) const
 Returns a reference to a parameter.
 
bool hasReturnValue () const
 Return true if this module has a valid return value set.
 
int getReturnValue () const
 Return the return value set by this module.
 
std::shared_ptr< PathElementclone () const override
 Create an independent copy of this module.
 
std::shared_ptr< boost::python::list > getParamInfoListPython () const
 Returns a python list of all parameters.
 

Static Public Member Functions

static void exposePythonAPI ()
 Exposes methods of the Module class to Python.
 

Protected Member Functions

virtual void def_initialize ()
 Wrappers to make the methods without "def_" prefix callable from Python.
 
virtual void def_beginRun ()
 Wrapper method for the virtual function beginRun() that has the implementation to be used in a call from Python.
 
virtual void def_event ()
 Wrapper method for the virtual function event() that has the implementation to be used in a call from Python.
 
virtual void def_endRun ()
 This method can receive that the current run ends as a call from the Python side.
 
virtual void def_terminate ()
 Wrapper method for the virtual function terminate() that has the implementation to be used in a call from Python.
 
void setDescription (const std::string &description)
 Sets the description of the module.
 
void setType (const std::string &type)
 Set the module type.
 
template<typename T >
void addParam (const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
 Adds a new parameter to the module.
 
template<typename T >
void addParam (const std::string &name, T &paramVariable, const std::string &description)
 Adds a new enforced parameter to the module.
 
void setReturnValue (int value)
 Sets the return value for this module as integer.
 
void setReturnValue (bool value)
 Sets the return value for this module as bool.
 
void setParamList (const ModuleParamList &params)
 Replace existing parameter list.
 

Protected Attributes

std::string m_hitCollectionName
 Name of the StoreArray containing the input track segment hits.
 
std::string m_outputCollectionName
 Name of the StoreArray containing the tracks found by the Hough tracking.
 
std::string m_clusterCollectionName
 Name of the StoreArray containing the clusters formed in the Hough plane.
 
unsigned m_nCellsPhi
 number of Hough cells in phi
 
unsigned m_nCellsR
 number of Hough cells in 1/r
 
double m_minPt
 Hough plane limit in Pt [GeV].
 
int m_shiftPt
 shift the Hough plane in 1/r to avoid curvature 0 tracks < 0: shift in negative direction (negative half is larger) 0: no shift (same limits for negative and positive half)

‍0: shift in positive direction (positive half is larger)


 
double maxR = 0.
 Hough plane limit in 1/r [1/cm].
 
double shiftR = 0.
 Hough plane shift in 1/r [1/cm].
 
unsigned maxIterations = 0
 number of iterations for the fast peak finder, smallest n such that 2^(n+1) > max(nCellsPhi, nCellsR).
 
unsigned nCells = 0
 number of cells for the fast peak finder: 2^(maxIterations + 1).
 
unsigned m_minHits
 minimum number of hits from different super layers in a Hough cell to form a candidate
 
unsigned m_minHitsShort
 short tracks require hits in the first minHitsShort super layers to form a candidate
 
unsigned m_minCells
 minimum number of cells in a cluster to form a track
 
bool m_onlyLocalMax
 switch to ignore candidates connected to cells with higher super layer count
 
unsigned m_connect
 number of neighbors to check for connection (4: direct, 6: direct + upper right and lower left corner, 8: direct + all corners)
 
bool m_ignore2nd
 switch to skip second priority hits
 
bool m_usePriority
 switch between priority position and center position of track segment
 
bool m_requireSL0
 switch to check separately for a hit in the innermost super layer
 
bool m_suppressClone
 switch to send only the first found track and suppress the subsequent clones
 
bool m_usehitpattern
 switch to use hit pattern inside TSF
 
bool m_useadc
 switch to use hit pattern inside TSF with ADC cut
 
unsigned m_storePlane
 switch to save the Hough plane in DataStore (0: don't save, 1: save only peaks, 2: save full plane)
 
bool m_clusterPattern
 switch for clustering algorithm (if true use nested patterns)
 
unsigned m_clusterSizeX
 maximum cluster size for pattern algorithm
 
unsigned m_clusterSizeY
 maximum cluster size for pattern algorithm
 
bool m_hitRelationsFromCorners
 switch for creating relations to hits in the pattern clustering algorithm.
 
std::string m_testFilename
 filename for test output for firmware debugging
 
std::ofstream testFile
 filestream for test output for firmware debugging
 
cdcMap hitMap
 map of TS hits containing <iHit, <iSL, (x, y)>> with iHit: hit index in StoreArray iSL: super layer index
 
std::vector< CDCTriggerHoughCandhoughCand
 Hough Candidates.
 
double radius [9][5] = {{0.}}
 Radius of the CDC layers with priority wires (2 per super layer).
 
unsigned TSoffset [10] = {0}
 Number of track segments up to super layer.
 
StoreArray< CDCTriggerSegmentHitm_segmentHits
 list of track segment hits
 
StoreArray< CDCTriggerTrackm_tracks
 list of found tracks
 
StoreArray< CDCTriggerHoughClusterm_clusters
 list of clusters in the Hough map
 
StoreObjPtr< TMatrix > m_houghPlane
 matrix containing the Hough plane
 

Private Member Functions

std::list< ModulePtrgetModules () const override
 no submodules, return empty list
 
std::string getPathString () const override
 return the module name.
 
void setParamPython (const std::string &name, const boost::python::object &pyObj)
 Implements a method for setting boost::python objects.
 
void setParamPythonDict (const boost::python::dict &dictionary)
 Implements a method for reading the parameter values from a boost::python dictionary.
 

Private Attributes

std::string m_name
 The name of the module, saved as a string (user-modifiable)
 
std::string m_type
 The type of the module, saved as a string.
 
std::string m_package
 Package this module is found in (may be empty).
 
std::string m_description
 The description of the module.
 
unsigned int m_propertyFlags
 The properties of the module as bitwise or (with |) of EModulePropFlags.
 
LogConfig m_logConfig
 The log system configuration of the module.
 
ModuleParamList m_moduleParamList
 List storing and managing all parameter of the module.
 
bool m_hasReturnValue
 True, if the return value is set.
 
int m_returnValue
 The return value.
 
std::vector< ModuleConditionm_conditions
 Module condition, only non-null if set.
 

Detailed Description

Definition at line 84 of file CDCTrigger2DFinderModule.h.

Member Typedef Documentation

◆ EAfterConditionPath

Forward the EAfterConditionPath definition from the ModuleCondition.

Definition at line 88 of file Module.h.

Member Enumeration Documentation

◆ EModulePropFlags

enum EModulePropFlags
inherited

Each module can be tagged with property flags, which indicate certain features of the module.

Enumerator
c_Input 

This module is an input module (reads data).

c_Output 

This module is an output module (writes data).

c_ParallelProcessingCertified 

This module can be run in parallel processing mode safely (All I/O must be done through the data store, in particular, the module must not write any files.)

c_HistogramManager 

This module is used to manage histograms accumulated by other modules.

c_InternalSerializer 

This module is an internal serializer/deserializer for parallel processing.

c_TerminateInAllProcesses 

When using parallel processing, call this module's terminate() function in all processes().

This will also ensure that there is exactly one process (single-core if no parallel modules found) or at least one input, one main and one output process.

c_DontCollectStatistics 

No statistics is collected for this module.

Definition at line 77 of file Module.h.

77 {
78 c_Input = 1,
79 c_Output = 2,
85 };
@ c_HistogramManager
This module is used to manage histograms accumulated by other modules.
Definition: Module.h:81
@ c_Input
This module is an input module (reads data).
Definition: Module.h:78
@ c_DontCollectStatistics
No statistics is collected for this module.
Definition: Module.h:84
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
@ c_InternalSerializer
This module is an internal serializer/deserializer for parallel processing.
Definition: Module.h:82
@ c_Output
This module is an output module (writes data).
Definition: Module.h:79
@ c_TerminateInAllProcesses
When using parallel processing, call this module's terminate() function in all processes().
Definition: Module.h:83

Constructor & Destructor Documentation

◆ CDCTrigger2DFinderModule()

Constructor.


Definition at line 35 of file CDCTrigger2DFinderModule.cc.

35 : Module()
36{
37 //Set module properties
38 setDescription("Hough tracking algorithm for CDC trigger.");
40
41 // Define module parameters
42 addParam("hitCollectionName", m_hitCollectionName,
43 "Name of the input StoreArray of CDCTriggerSegmentHits.",
44 string(""));
45 addParam("outputCollectionName", m_outputCollectionName,
46 "Name of the StoreArray holding the tracks found in the Hough tracking.",
47 string("TRGCDC2DFinderTracks"));
48 addParam("clusterCollectionName", m_clusterCollectionName,
49 "Name of the StoreArray holding the clusters formed in the Hough plane.",
50 string(""));
51 addParam("nCellsPhi", m_nCellsPhi,
52 "Number of Hough cells in phi (limits: [-180, 180]). Must be an even number.",
53 (unsigned)(160));
54 addParam("nCellsR", m_nCellsR,
55 "Number of Hough cells in 1/r. Must be an even number.",
56 (unsigned)(34));
57 addParam("minPt", m_minPt,
58 "Minimum Pt [GeV]. "
59 "Hough plane limits in 1/r are [-1/r(minPt), 1/r(minPt)]", (double)(0.3));
60 addParam("shiftPt", m_shiftPt,
61 "Shift the Hough plane by 1/4 cell size in 1/r to avoid "
62 "curvature 0 tracks (<0: shift in negative direction, "
63 "0: no shift, >0: shift in positive direction).", 0);
64
65 addParam("minHits", m_minHits,
66 "Minimum hits from different super layers required in a peak cell.",
67 (unsigned)(4));
68 addParam("minHitsShort", m_minHitsShort,
69 "Minimum hits required required in a peak cell for a short track"
70 " (must be in the first minHitsShort super layers).",
71 (unsigned)(4));
72 addParam("minCells", m_minCells,
73 "Peaks with less than minCells connected cells are ignored.",
74 (unsigned)(2));
75 addParam("onlyLocalMax", m_onlyLocalMax,
76 "Switch to remove cells connected to a cell with higher super layer count.",
77 false);
78 addParam("connect", m_connect,
79 "Definition for connected cells. 4: direct (left/right/top/bottom), "
80 "6: direct + 2 diagonal (top right/bottom left), "
81 "8: direct + all diagonal (top right/top left/bottom right/bottom left)",
82 (unsigned)(6));
83 addParam("ignore2ndPriority", m_ignore2nd,
84 "Switch to skip second priority hits.", false);
85 addParam("usePriorityPosition", m_usePriority,
86 "If true, use wire position of priority cell in track segment, "
87 "otherwise use wire position of center cell.", true);
88 addParam("requireSL0", m_requireSL0,
89 "Switch to check separately for a hit in the innermost superlayer.", false);
90 addParam("storeHoughPlane", m_storePlane,
91 "Switch for saving Hough plane as TMatrix in DataStore. "
92 "0: don't store anything, 1: store only peaks, 2: store full plane "
93 "(will increase runtime).", (unsigned)(0));
94 addParam("clusterPattern", m_clusterPattern,
95 "use nested pattern algorithm to find clusters", true);
96 addParam("clusterSizeX", m_clusterSizeX,
97 "maximum number of 2 x 2 squares in cluster for pattern algorithm",
98 (unsigned)(3));
99 addParam("clusterSizeY", m_clusterSizeY,
100 "maximum number of 2 x 2 squares in cluster for pattern algorithm",
101 (unsigned)(3));
102 addParam("hitRelationsFromCorners", m_hitRelationsFromCorners,
103 "Switch for creating relations to hits in the pattern algorithm. "
104 "If true, create relations from cluster corners, otherwise "
105 "from estimated cluster center (might not have relations).", false);
106
107 addParam("testFilename", m_testFilename,
108 "If not empty, a file with input (hits) and output (tracks) "
109 "for each event is written (for firmware debugging).", string(""));
110
111 addParam("suppressClone", m_suppressClone,
112 "Switch to send only the first found track and suppress the "
113 "subsequent clones.", false);
114
115 addParam("usehitpattern", m_usehitpattern,
116 "Switch to use hit pattern inside TSF ", false);
117
118 addParam("useadc", m_useadc,
119 "Switch to use ADC. Can be used with usehitpattern enabled. ", false);
120}
bool m_usehitpattern
switch to use hit pattern inside TSF
std::string m_testFilename
filename for test output for firmware debugging
unsigned m_minCells
minimum number of cells in a cluster to form a track
bool m_useadc
switch to use hit pattern inside TSF with ADC cut
unsigned m_minHitsShort
short tracks require hits in the first minHitsShort super layers to form a candidate
unsigned m_nCellsR
number of Hough cells in 1/r
int m_shiftPt
shift the Hough plane in 1/r to avoid curvature 0 tracks < 0: shift in negative direction (negative h...
std::string m_outputCollectionName
Name of the StoreArray containing the tracks found by the Hough tracking.
unsigned m_nCellsPhi
number of Hough cells in phi
bool m_usePriority
switch between priority position and center position of track segment
bool m_clusterPattern
switch for clustering algorithm (if true use nested patterns)
bool m_hitRelationsFromCorners
switch for creating relations to hits in the pattern clustering algorithm.
unsigned m_storePlane
switch to save the Hough plane in DataStore (0: don't save, 1: save only peaks, 2: save full plane)
bool m_ignore2nd
switch to skip second priority hits
unsigned m_connect
number of neighbors to check for connection (4: direct, 6: direct + upper right and lower left corner...
bool m_suppressClone
switch to send only the first found track and suppress the subsequent clones
unsigned m_clusterSizeX
maximum cluster size for pattern algorithm
double m_minPt
Hough plane limit in Pt [GeV].
bool m_requireSL0
switch to check separately for a hit in the innermost super layer
unsigned m_minHits
minimum number of hits from different super layers in a Hough cell to form a candidate
std::string m_clusterCollectionName
Name of the StoreArray containing the clusters formed in the Hough plane.
std::string m_hitCollectionName
Name of the StoreArray containing the input track segment hits.
bool m_onlyLocalMax
switch to ignore candidates connected to cells with higher super layer count
unsigned m_clusterSizeY
maximum cluster size for pattern algorithm
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
Module()
Constructor.
Definition: Module.cc:30
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560

Member Function Documentation

◆ addNeighbors()

void addNeighbors ( const CDCTriggerHoughCand center,
const std::vector< CDCTriggerHoughCand > &  candidates,
std::vector< CDCTriggerHoughCand > &  merged,
std::vector< CDCTriggerHoughCand > &  rejected,
unsigned short  nSLmax 
) const

Recursive function to add combine connected cells.

All candidates are compared to center. Connected candidates are added to the merged list. If the module option onlyLocalMax is on, connected cells with SLcount lower than the cluster maximum are added to the rejected list instead. The function is called recursively for all connected candidates.

Parameters
centerstarting candidate
candidateslist of candidates compared to center
mergedlist for storing all candidates belonging to the cluster
rejectedlist for storing rejected candidates (connected, but lower SLcount, not in any other cluster either)
nSLmaxhighest SLcount for this cluster

Definition at line 290 of file CDCTriggerHoughtrafo.cc.

295{
296 for (unsigned icand = 0; icand < candidates.size(); ++icand) {
297 B2DEBUG(120, "compare center " << center.getID()
298 << " to " << candidates[icand].getID());
299 if (inList(candidates[icand], merged) || inList(candidates[icand], rejected)) {
300 B2DEBUG(120, " " << candidates[icand].getID() << " already in list");
301 continue;
302 }
303 bool reject = inList(center, rejected);
304 if (connected(center, candidates[icand])) {
305 if (m_onlyLocalMax && candidates[icand].getSLcount() < nSLmax) {
306 B2DEBUG(100, " lower than highest SLcount, rejected");
307 rejected.push_back(candidates[icand]);
308 } else if (m_onlyLocalMax && !reject && candidates[icand].getSLcount() > nSLmax) {
309 B2DEBUG(100, " new highest SLcount, clearing list");
310 nSLmax = candidates[icand].getSLcount();
311 for (unsigned imerged = 0; imerged < merged.size(); ++imerged) {
312 rejected.push_back(merged[imerged]);
313 }
314 merged.clear();
315 merged.push_back(candidates[icand]);
316 } else if (m_onlyLocalMax && candidates[icand].getSLcount() > center.getSLcount()) {
317 B2DEBUG(100, " connected to rejected cell, skip");
318 continue;
319 } else if (m_onlyLocalMax && reject) {
320 B2DEBUG(100, " connected to rejected cell, rejected");
321 rejected.push_back(candidates[icand]);
322 } else {
323 B2DEBUG(100, " connected");
324 merged.push_back(candidates[icand]);
325 }
326 vector<CDCTriggerHoughCand> cpyCand = candidates;
327 cpyCand.erase(cpyCand.begin() + icand);
328 addNeighbors(candidates[icand], cpyCand, merged, rejected, nSLmax);
329 }
330 }
331}
bool inList(const CDCTriggerHoughCand &a, const std::vector< CDCTriggerHoughCand > &list) const
Check if candidate is in list.
bool connected(const CDCTriggerHoughCand &a, const CDCTriggerHoughCand &b) const
Check if candidates are connected.
void addNeighbors(const CDCTriggerHoughCand &center, const std::vector< CDCTriggerHoughCand > &candidates, std::vector< CDCTriggerHoughCand > &merged, std::vector< CDCTriggerHoughCand > &rejected, unsigned short nSLmax) const
Recursive function to add combine connected cells.
unsigned getID() const
Get candidate number.
unsigned short getSLcount() const
Get super layer count.
int getID(const std::vector< double > &breaks, double t)
get id of the time point t
Definition: calibTools.h:60

◆ beginRun()

virtual void beginRun ( void  )
inlinevirtualinherited

Called when entering a new run.

Called at the beginning of each run, the method gives you the chance to change run dependent constants like alignment parameters, etc.

This method can be implemented by subclasses.

Reimplemented in ARICHBackgroundModule, BeamabortModule, BgoModule, CaveModule, ClawModule, CLAWSModule, DosiModule, FANGSModule, He3tubeModule, MicrotpcModule, Ph1bpipeModule, Ph1sustrModule, PindiodeModule, PlumeModule, QcsmonitorModule, SrsensorModule, GetEventFromSocketModule, CalibrationCollectorModule, EventsOfDoomBusterModule, CosmicsAlignmentValidationModule, EnergyBiasCorrectionModule, ChargedPidMVAModule, ChargedPidMVAMulticlassModule, CurlTaggerModule, LowEnergyPi0IdentificationExpertModule, LowEnergyPi0VetoExpertModule, ParticleVertexFitterModule, PhotonEfficiencySystematicsModule, TagVertexModule, TreeFitterModule, arichBtestModule, ARICHDigitizerModule, ARICHDQMModule, ARICHRateCalModule, ARICHReconstructorModule, B2BIIMCParticlesMonitorModule, B2BIIConvertBeamParamsModule, B2BIIConvertMdstModule, B2BIIFixMdstModule, B2BIIMdstInputModule, BelleMCOutputModule, BeamBkgGeneratorModule, BeamBkgHitRateMonitorModule, BeamBkgMixerModule, BeamBkgTagSetterModule, BGOverlayInputModule, AnalysisPhase1StudyModule, NtuplePhase1_v6Module, ReprocessorModule, BeamabortStudyModule, BeamDigitizerModule, BgoDigitizerModule, BgoStudyModule, ClawDigitizerModule, ClawStudyModule, ClawsDigitizerModule, ClawsStudyModule, CsiDigitizer_v2Module, CsIDigitizerModule, CsiModule, CsiStudy_v2Module, CsIStudyModule, DosiDigitizerModule, DosiStudyModule, FANGSDigitizerModule, FANGSStudyModule, He3DigitizerModule, He3tubeStudyModule, MicrotpcStudyModule, TpcDigitizerModule, PinDigitizerModule, PindiodeStudyModule, PlumeDigitizerModule, QcsmonitorDigitizerModule, QcsmonitorStudyModule, CDCCosmicAnalysisModule, CDCCRTestModule, cdcDQM7Module, CDCDQMModule, CDCPackerModule, CDCRecoTrackFilterModule, CDCUnpackerModule, DAQPerfModule, RxSocketModule, TxSocketModule, DqmHistoManagerModule, MonitorDataModule, TrackAnaModule, Ds2SampleModule, ReceiveEventModule, HLTDQM2ZMQModule, ElapsedTimeModule, DeSerializerPXDModule, GenRawSendModule, SerializerModule, CertifyParallelModule, Ds2RawModule, Ds2RbufModule, EvReductionModule, FastRbuf2DsModule, Raw2DsModule, RawInputModule, Rbuf2DsModule, Rbuf2RbufModule, Ds2RawFileModule, PartialSeqRootReaderModule, SeqRootMergerModule, StorageDeserializerModule, StorageSerializerModule, IPDQMModule, PhysicsObjectsDQMModule, PhysicsObjectsMiraBelleBhabhaModule, PhysicsObjectsMiraBelleDst2Module, PhysicsObjectsMiraBelleDstModule, PhysicsObjectsMiraBelleHadronModule, PhysicsObjectsMiraBelleModule, ECLBackgroundModule, ECLChargedPIDModule, ECLChargedPIDDataAnalysisModule, ECLChargedPIDDataAnalysisValidationModule, ECLChargedPIDMVAModule, ECLClusterPSDModule, ECLCovarianceMatrixModule, ECLCRFinderModule, ECLDataAnalysisModule, ECLDigitCalibratorModule, ECLDigitizerModule, ECLDigitizerPureCsIModule, EclDisplayModule, ECLDQMModule, ECLDQMConnectedRegionsModule, ECLDQMEXTENDEDModule, ECLDQMOutOfTimeDigitsModule, ECLFinalizerModule, ECLHitDebugModule, ECLLocalMaximumFinderModule, ECLLocalRunCalibratorModule, ECLLOMModule, ECLPackerModule, ECLShowerCorrectorModule, ECLShowerShapeModule, ECLSplitterN1Module, ECLSplitterN2Module, ECLUnpackerModule, ECLWaveformFitModule, HistoModule, SubEventModule, SwitchDataStoreModule, EventInfoPrinterModule, EventLimiterModule, IoVDependentConditionModule, ProgressModule, RandomBarrierModule, GearboxModule, HistoManagerModule, StatisticsSummaryModule, SeqRootInputModule, SeqRootOutputModule, RxModule, TxModule, EvtGenDecayModule, EvtGenInputModule, OverrideGenerationFlagsModule, KKGenInputModule, CreateFieldMapModule, ExportGeometryModule, SoftwareTriggerModule, SoftwareTriggerHLTDQMModule, StatisticsTimingHLTDQMModule, BKLMAnaModule, BKLMDigitAnalyzerModule, BKLMSimHistogrammerModule, BKLMTrackingModule, EKLMDataCheckerModule, KLMClusterAnaModule, KLMClusterEfficiencyModule, KLMClustersReconstructorModule, KLMDigitizerModule, KLMDigitTimeShifterModule, KLMDQMModule, KLMDQM2Module, KLMPackerModule, KLMReconstructorModule, KLMScintillatorSimulatorModule, KLMUnpackerModule, MVAExpertModule, MVAMultipleExpertsModule, MVAPrototypeModule, AWESOMEBasicModule, PXDBackgroundModule, PXDRawDQMChipsModule, PXDClustersFromTracksModule, PXDPerformanceModule, PXDClusterizerModule, Convert2RawDetModule, CDCDedxDQMModule, CDCDedxValidationModule, EventT0DQMModule, EventT0ValidationModule, DataWriterModule, ECLExpertModule, KLMExpertModule, KlongValidationModule, KLMMuonIDDNNExpertModule, FullSimModule, MaterialScanModule, SVDBackgroundModule, SVDClusterCalibrationsMonitorModule, SVDHotStripFinderModule, SVDLatencyCalibrationModule, SVDLocalCalibrationsCheckModule, SVDLocalCalibrationsMonitorModule, SVDPositionErrorScaleFactorImporterModule, SVDTimeCalibrationsMonitorModule, SVDDQMHitTimeModule, svdDumpModule, SVDPackerModule, SVDB4CommissioningPlotsModule, SVDClusterEvaluationModule, SVDClusterEvaluationTrueInfoModule, SVDClusterFilterModule, SVDMaxStripTTreeModule, SVDOccupancyAnalysisModule, SVDPerformanceModule, SVDPerformanceTTreeModule, SVDShaperDigitsFromTracksModule, SVDClusterizerModule, SVDCoGTimeEstimatorModule, SVDDataFormatCheckModule, SVDMissingAPVsClusterCreatorModule, SVDRecoDigitCreatorModule, SVD3SamplesEmulatorModule, SVDDigitizerModule, SVDEventInfoSetterModule, SVDTriggerQualityGeneratorModule, SVDSpacePointCreatorModule, SVDTimeGroupingModule, SVDUnpackerModule, TOPBackgroundModule, TOPBunchFinderModule, TOPChannelMaskerModule, TOPChannelT0MCModule, TOPDigitizerModule, TOPTriggerDigitizerModule, TOPDoublePulseGeneratorModule, TOPDQMModule, TOPGainEfficiencyCalculatorModule, TOPLaserHitSelectorModule, TOPInterimFENtupleModule, TOPLaserCalibratorModule, TOPMCTrackMakerModule, TOPModuleT0CalibratorModule, TOPNtupleModule, TOPPackerModule, TOPRawDigitConverterModule, TOPTBCComparatorModule, TOPTimeBaseCalibratorModule, TOPTimeRecalibratorModule, TOPUnpackerModule, TOPWaveformFeatureExtractorModule, TOPXTalkChargeShareSetterModule, DQMHistoModuleBase, SVDEventT0EstimatorModule, ExtModule, FlipQualityModule, BeamSpotMonitorModule, KinkFinderModule, MCV0MatcherModule, MCTrackCandClassifierModule, MuidModule, PXDROIFinderModule, SVDROIFinderAnalysisModule, SVDROIFinderModule, SPTCmomentumSeedRetrieverModule, SPTCvirtualIPRemoverModule, TrackCreatorModule, TrackFinderMCTruthRecoTracksModule, EffPlotsModule, HitXPModule, TrackingPerformanceEvaluationModule, V0findingPerformanceEvaluationModule, TrackQETrainingDataCollectorModule, TrackQualityEstimatorMVAModule, SecMapTrainerBaseModule, SecMapTrainerVXDTFModule, TrackFinderVXDAnalizerModule, VXDSimpleClusterizerModule, QualityEstimatorVXDModule, VXDQETrainingDataCollectorModule, VXDQualityEstimatorMVAModule, SectorMapBootstrapModule, SegmentNetworkProducerModule, TrackFinderVXDBasicPathFinderModule, TrackFinderVXDCellOMatModule, VXDTFTrainingDataCollectorModule, FindletModule< AFindlet >, FindletModule< HitBasedT0Extractor >, FindletModule< CKFToSVDSeedFindlet >, FindletModule< CKFToSVDFindlet >, FindletModule< CosmicsTrackMergerFindlet >, FindletModule< DATCONFPGAFindlet >, FindletModule< MCVXDCDCTrackMergerFindlet >, FindletModule< vxdHoughTracking::SVDHoughTracking >, FindletModule< CKFToCDCFindlet >, FindletModule< CKFToCDCFromEclFindlet >, FindletModule< CKFToPXDFindlet >, FindletModule< AsicBackgroundLibraryCreator >, FindletModule< CDCTrackingEventLevelMdstInfoFillerFromHitsFindlet >, FindletModule< CDCTrackingEventLevelMdstInfoFillerFromSegmentsFindlet >, FindletModule< AxialSegmentPairCreator >, FindletModule< AxialStraightTrackFinder >, FindletModule< AxialTrackCreatorMCTruth >, FindletModule< AxialTrackCreatorSegmentHough >, FindletModule< AxialTrackFinderHough >, FindletModule< AxialTrackFinderLegendre >, FindletModule< ClusterBackgroundDetector >, FindletModule< ClusterPreparer >, FindletModule< ClusterRefiner< BridgingWireHitRelationFilter > >, FindletModule< FacetCreator >, FindletModule< HitReclaimer >, FindletModule< MonopoleAxialTrackFinderLegendre >, FindletModule< MonopoleStereoHitFinder >, FindletModule< MonopoleStereoHitFinderQuadratic >, FindletModule< SegmentCreatorFacetAutomaton >, FindletModule< SegmentCreatorMCTruth >, FindletModule< SegmentFinderFacetAutomaton >, FindletModule< SegmentFitter >, FindletModule< SegmentLinker >, FindletModule< SegmentOrienter >, FindletModule< SegmentPairCreator >, FindletModule< SegmentRejecter >, FindletModule< SegmentTrackCombiner >, FindletModule< SegmentTripleCreator >, FindletModule< StereoHitFinder >, FindletModule< SuperClusterCreator >, FindletModule< TrackCombiner >, FindletModule< TrackCreatorSegmentPairAutomaton >, FindletModule< TrackCreatorSegmentTripleAutomaton >, FindletModule< TrackCreatorSingleSegments >, FindletModule< TrackExporter >, FindletModule< TrackFinderAutomaton >, FindletModule< TrackFinderCosmics >, FindletModule< TrackFinder >, FindletModule< TrackFinderSegmentPairAutomaton >, FindletModule< TrackFinderSegmentTripleAutomaton >, FindletModule< TrackFlightTimeAdjuster >, FindletModule< TrackLinker >, FindletModule< TrackOrienter >, FindletModule< TrackQualityAsserter >, FindletModule< TrackQualityEstimator >, FindletModule< TrackRejecter >, FindletModule< WireHitBackgroundDetector >, FindletModule< WireHitCreator >, FindletModule< WireHitPreparer >, CDCTriggerNeuroDQMModule, CDCTriggerNeuroDQMOnlineModule, CDCTriggerNDFinderModule, CDCTriggerTSFModule, TRGCDCModule, TRGCDCETFUnpackerModule, TRGCDCT2DDQMModule, TRGCDCT3DConverterModule, TRGCDCT3DDQMModule, TRGCDCT3DUnpackerModule, TRGCDCTSFDQMModule, TRGCDCTSFUnpackerModule, TRGCDCTSStreamModule, CDCTriggerUnpackerModule, MCMatcherTRGECLModule, TRGECLFAMModule, TRGECLModule, TRGECLBGTCHitModule, TRGECLDQMModule, TRGECLEventTimingDQMModule, TRGECLQAMModule, TRGECLRawdataAnalysisModule, TRGECLTimingCalModule, TRGECLUnpackerModule, TRGGDLModule, TRGEFFDQMModule, TRGGDLDQMModule, TRGGDLDSTModule, TRGGDLSummaryModule, TRGGDLUnpackerModule, TRGGRLMatchModule, TRGGRLModule, TRGGRLProjectsModule, TRGGRLDQMModule, TRGGRLUnpackerModule, KLMTriggerModule, TRGTOPDQMModule, TRGTOPTRD2TTSConverterModule, TRGTOPUnpackerModule, TRGTOPUnpackerWaveformModule, TRGTOPWaveformPlotterModule, TRGRAWDATAModule, VXDMisalignmentModule, DQMHistAnalysisARICHModule, DQMHistAnalysisCDCDedxModule, DQMHistAnalysisCDCEpicsModule, DQMHistAnalysisCDCMonObjModule, DQMHistAnalysisDAQMonObjModule, DQMHistAnalysisECLModule, DQMHistAnalysisECLConnectedRegionsModule, DQMHistAnalysisECLShapersModule, DQMHistAnalysisECLSummaryModule, DQMHistAnalysisEpicsExampleModule, DQMHistAnalysisEventT0EfficiencyModule, DQMHistAnalysisEventT0TriggerJitterModule, DQMHistAnalysisExampleModule, DQMHistAnalysisExampleFlagsModule, DQMHistAnalysisHLTModule, DQMHistAnalysisInput2Module, DQMHistAnalysisInputPVSrvModule, DQMHistAnalysisInputRootFileModule, DQMHistAnalysisInputTestModule, DQMHistAnalysisKLMModule, DQMHistAnalysisKLM2Module, DQMHistAnalysisMiraBelleModule, DQMHistAnalysisOutputMonObjModule, DQMHistAnalysisOutputRelayMsgModule, DQMHistAnalysisPeakModule, DQMHistAnalysisPXDERModule, DQMHistAnalysisPXDFitsModule, DQMHistAnalysisSVDClustersOnTrackModule, DQMHistAnalysisSVDDoseModule, DQMHistAnalysisSVDEfficiencyModule, DQMHistAnalysisSVDGeneralModule, DQMHistAnalysisSVDOccupancyModule, DQMHistAnalysisSVDOnMiraBelleModule, DQMHistAnalysisSVDUnpackerModule, DQMHistAnalysisTOPModule, DQMHistAnalysisTrackingAbortModule, DQMHistAnalysisTrackingHLTModule, DQMHistAnalysisTRGECLModule, DQMHistAutoCanvasModule, DQMHistComparitorModule, DQMHistDeltaHistoModule, DQMHistReferenceModule, DQMHistSnapshotsModule, DAQMonitorModule, DelayDQMModule, V0ObjectsDQMModule, ECLDQMInjectionModule, PyModule, PXDBgTupleProducerModule, PXDMCBgTupleProducerModule, PXDDAQDQMModule, PXDDQMClustersModule, PXDDQMCorrModule, PXDDQMEfficiencyModule, PXDDQMEfficiencySelftrackModule, PXDDQMExpressRecoModule, PXDGatedDHCDQMModule, PXDGatedModeDQMModule, PXDInjectionDQMModule, PXDRawDQMCorrModule, PXDRawDQMModule, PXDROIDQMModule, PXDTrackClusterDQMModule, PXDDigitizerModule, PXDPackerModule, PXDUnpackerModule, TTDDQMModule, DetectorOccupanciesDQMModule, SVDDQMClustersOnTrackModule, SVDDQMDoseModule, SVDDQMExpressRecoModule, SVDDQMInjectionModule, SVDUnpackerDQMModule, PXDclusterFilterModule, PXDdigiFilterModule, PXDROIFinderAnalysisModule, TrackingAbortDQMModule, VXDDQMExpressRecoModule, vxdDigitMaskingModule, DQMHistAnalysisDeltaEpicsMonObjExampleModule, DQMHistAnalysisDeltaTestModule, DQMHistAnalysisEpicsOutputModule, DQMHistAnalysisPhysicsModule, DQMHistAnalysisPXDChargeModule, DQMHistAnalysisPXDCMModule, DQMHistAnalysisPXDDAQModule, DQMHistAnalysisPXDEffModule, DQMHistAnalysisPXDInjectionModule, DQMHistAnalysisPXDReductionModule, DQMHistAnalysisPXDTrackChargeModule, DQMHistAnalysisRooFitExampleModule, DQMHistAnalysisRunNrModule, DQMHistAnalysisTRGModule, DQMHistInjectionModule, and DQMHistOutputToEPICSModule.

Definition at line 147 of file Module.h.

147{};

◆ bottomLeftCorner()

unsigned bottomLeftCorner ( unsigned  pattern)

Find the bottom left corner within 2 x 2 square.

In case of ambiguity left corner is returned. x . -> return this one . x @ return index of corner within pattern

Definition at line 780 of file CDCTriggerHoughtrafo.cc.

781{
782 // scan pattern from left to right:
783 // 2 3
784 // 0 1
785 if (pattern & 1) return 0;
786 if ((pattern >> 2) & 1) {
787 if ((pattern >> 1) & 1) {
788 setReturnValue(false);
789 B2DEBUG(100, "bottomLeftCorner not unique");
790 }
791 return 2;
792 }
793 if ((pattern >> 1) & 1) return 1;
794 return 3;
795}
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220

◆ clone()

std::shared_ptr< PathElement > clone ( ) const
overridevirtualinherited

Create an independent copy of this module.

Note that parameters are shared, so changing them on a cloned module will also affect the original module.

Implements PathElement.

Definition at line 179 of file Module.cc.

180{
182 newModule->m_moduleParamList.setParameters(getParamList());
183 newModule->setName(getName());
184 newModule->m_package = m_package;
185 newModule->m_propertyFlags = m_propertyFlags;
186 newModule->m_logConfig = m_logConfig;
187 newModule->m_conditions = m_conditions;
188
189 return newModule;
190}
std::shared_ptr< Module > registerModule(const std::string &moduleName, std::string sharedLibPath="") noexcept(false)
Creates an instance of a module and registers it to the ModuleManager.
static ModuleManager & Instance()
Exception is thrown if the requested module could not be created by the ModuleManager.
const ModuleParamList & getParamList() const
Return module param list.
Definition: Module.h:363
const std::string & getName() const
Returns the name of the module.
Definition: Module.h:187
const std::string & getType() const
Returns the type of the module (i.e.
Definition: Module.cc:41
unsigned int m_propertyFlags
The properties of the module as bitwise or (with |) of EModulePropFlags.
Definition: Module.h:512
LogConfig m_logConfig
The log system configuration of the module.
Definition: Module.h:514
std::vector< ModuleCondition > m_conditions
Module condition, only non-null if set.
Definition: Module.h:521
std::string m_package
Package this module is found in (may be empty).
Definition: Module.h:510
std::shared_ptr< Module > ModulePtr
Defines a pointer to a module object as a boost shared pointer.
Definition: Module.h:43

◆ connected()

bool connected ( const CDCTriggerHoughCand a,
const CDCTriggerHoughCand b 
) const

Check if candidates are connected.

Definition at line 344 of file CDCTriggerHoughtrafo.cc.

346{
347 double ax1 = a.getCoord().first.X();
348 double ax2 = a.getCoord().second.X();
349 double ay1 = a.getCoord().first.Y();
350 double ay2 = a.getCoord().second.Y();
351 double bx1 = b.getCoord().first.X();
352 double bx2 = b.getCoord().second.X();
353 double by1 = b.getCoord().first.Y();
354 double by2 = b.getCoord().second.Y();
355 // direct neighbors
356 bool direct = ((ax2 == bx1 && ay1 == by1) || // right
357 (ax1 == bx2 && ay1 == by1) || // left
358 (ax1 == bx1 && ay2 == by1) || // above
359 (ax1 == bx1 && ay1 == by2) || // below
360 (ax1 + 2. * M_PI == bx2 && ay1 == by1) ||
361 (ax2 == bx1 + 2. * M_PI && ay1 == by1));
362 // diagonal connections
363 bool diagRise = ((ax2 == bx1 && ay2 == by1) || // right above
364 (ax1 == bx2 && ay1 == by2) || // left below
365 (ax1 + 2. * M_PI == bx2 && ay1 == by2) ||
366 (ax2 == bx1 + 2. * M_PI && ay2 == by1));
367 bool diagFall = ((ax1 == bx2 && ay2 == by1) || // left above
368 (ax2 == bx1 && ay1 == by2) || // right below
369 (ax2 == bx1 + 2. * M_PI && ay1 == by2) ||
370 (ax1 + 2. * M_PI == bx2 && ay2 == by1));
371 if (m_connect == 4) return direct;
372 else if (m_connect == 6) return (direct || diagRise);
373 else if (m_connect == 8) return (direct || diagRise || diagFall);
374 else B2WARNING("Unknown option for connect " << m_connect << ", using default.");
375 return (direct || diagRise);
376}

◆ connectedDiag()

bool connectedDiag ( unsigned  patternLD,
unsigned  patternRU 
)

Check for diagonal connected of patterns in 2 x 2 squares.

Definition at line 719 of file CDCTriggerHoughtrafo.cc.

720{
721 if (m_connect == 4) return false;
722
723 // connected if
724 // . .
725 // x .
726 // . x
727 // . .
728 return (((patternRU >> 0) & 1) && ((patternLD >> 3) & 1));
729}

◆ connectedLR()

bool connectedLR ( unsigned  patternL,
unsigned  patternR 
)

Check for left/right connection of patterns in 2 x 2 squares.

Definition at line 662 of file CDCTriggerHoughtrafo.cc.

663{
664 // connected if
665 // . x | x . or . . | . .
666 // . . | . . . x | x .
667 bool connectDirect = (((patternL >> 3) & 1) && ((patternR >> 2) & 1)) ||
668 (((patternL >> 1) & 1) && ((patternR >> 0) & 1));
669 // connected if
670 // . . | x .
671 // . x | . .
672 bool connectRise = ((patternL >> 1) & 1) && ((patternR >> 2) & 1);
673 // connected if
674 // . x | . .
675 // . . | x .
676 bool connectFall = ((patternL >> 3) & 1) && ((patternR >> 0) & 1);
677
678 if (m_connect == 4) return connectDirect;
679 else if (m_connect == 6) return (connectDirect || connectRise);
680 else if (m_connect == 8) return (connectDirect || connectRise || connectFall);
681 else B2WARNING("Unknown option for connect " << m_connect << ", using default.");
682 return (connectDirect || connectRise);
683}

◆ connectedRegions()

void connectedRegions ( )

Combine Hough candidates to tracks by merging connected cells.

The track coordinate is the center of gravity of the resulting cell cluster.

Definition at line 179 of file CDCTriggerHoughtrafo.cc.

180{
181 vector<vector<CDCTriggerHoughCand>> regions;
182 vector<CDCTriggerHoughCand> cpyCand = houghCand;
183
184 // debug: print candidate list
185 B2DEBUG(50, "houghCand number " << cpyCand.size());
186 for (unsigned icand = 0; icand < houghCand.size(); ++icand) {
187 coord2dPair coord = houghCand[icand].getCoord();
188 B2DEBUG(100, houghCand[icand].getID()
189 << " nSL " << houghCand[icand].getSLcount()
190 << " x1 " << coord.first.X() << " x2 " << coord.second.X()
191 << " y1 " << coord.first.Y() << " y2 " << coord.second.Y());
192 }
193
194 // combine connected cells to regions
195 while (cpyCand.size() > 0) {
196 B2DEBUG(100, "make new region");
197 vector<CDCTriggerHoughCand> region;
198 vector<CDCTriggerHoughCand> rejected;
199 CDCTriggerHoughCand start = cpyCand[0];
200 cpyCand.erase(cpyCand.begin());
201 region.push_back(start);
202 addNeighbors(start, cpyCand, region, rejected, start.getSLcount());
203 regions.push_back(region);
204 for (auto cand = cpyCand.begin(); cand != cpyCand.end();) {
205 if (inList(*cand, region) || inList(*cand, rejected))
206 cpyCand.erase(cand);
207 else
208 ++cand;
209 }
210 }
211
212 // find center of gravity for each region
213 for (unsigned ir = 0; ir < regions.size(); ++ir) {
214 B2DEBUG(50, "region " << ir << " (" << regions[ir].size() << " cells).");
215 // skip regions with size below cut
216 if (regions[ir].size() < m_minCells) {
217 B2DEBUG(50, "Skipping region with " << regions[ir].size() << " cells.");
218 continue;
219 }
220 double xfirst = regions[ir][0].getCoord().first.X();
221 double x = 0;
222 double y = 0;
223 int n = 0;
224 vector<unsigned> mergedList;
225 int xmin = m_nCellsPhi;
226 int xmax = 0;
227 int ymin = m_nCellsR;
228 int ymax = 0;
229 vector<ROOT::Math::XYVector> cellIds = {};
230 for (unsigned ir2 = 0; ir2 < regions[ir].size(); ++ir2) {
231 coord2dPair hc = regions[ir][ir2].getCoord();
232 B2DEBUG(100, " " << regions[ir][ir2].getID()
233 << " nSL " << regions[ir][ir2].getSLcount()
234 << " x1 " << hc.first.X() << " x2 " << hc.second.X()
235 << " y1 " << hc.first.Y() << " y2 " << hc.second.Y());
236 int ix = floor((hc.first.X() + M_PI) / 2. / M_PI * m_nCellsPhi + 0.5);
237 int iy = floor((hc.first.Y() + maxR - shiftR) / 2. / maxR * m_nCellsR + 0.5);
238 x += (hc.first.X() + hc.second.X());
239 if (xfirst - hc.first.X() > M_PI) {
240 x += 4 * M_PI;
241 ix += m_nCellsPhi;
242 } else if (hc.first.X() - xfirst > M_PI) {
243 x -= 4 * M_PI;
244 ix -= m_nCellsPhi;
245 }
246 y += (hc.first.Y() + hc.second.Y());
247 n += 1;
248 vector<unsigned> idList = regions[ir][ir2].getIdList();
249 mergeIdList(mergedList, mergedList, idList);
250 xmin = min(xmin, ix);
251 xmax = max(xmax, ix);
252 ymin = min(ymin, iy);
253 ymax = max(ymax, iy);
254 cellIds.push_back(ROOT::Math::XYVector(ix, iy));
255 }
256 x *= 0.5 / n;
257 if (x > M_PI)
258 x -= 2 * M_PI;
259 else if (x <= -M_PI)
260 x += 2 * M_PI;
261 y *= 0.5 / n;
262 B2DEBUG(50, "x " << x << " y " << y);
263
264 // select 1 hit per super layer
265 vector<unsigned> selectedList = {};
266 vector<unsigned> unselectedList = {};
267 selectHits(mergedList, selectedList, unselectedList);
268
269 // save track
270 const CDCTriggerTrack* track =
271 m_tracks.appendNew(x, 2. * y, 0.);
272 // relations to selected hits
273 for (unsigned i = 0; i < selectedList.size(); ++i) {
274 unsigned its = selectedList[i];
275 track->addRelationTo(m_segmentHits[its]);
276 }
277 // relations to additional hits get a negative weight
278 for (unsigned i = 0; i < unselectedList.size(); ++i) {
279 unsigned its = unselectedList[i];
280 track->addRelationTo(m_segmentHits[its], -1.);
281 }
282 // save detail information about the cluster
283 const CDCTriggerHoughCluster* cluster =
284 m_clusters.appendNew(xmin, xmax, ymin, ymax, cellIds);
285 track->addRelationTo(cluster);
286 }
287}
std::vector< CDCTriggerHoughCand > houghCand
Hough Candidates.
StoreArray< CDCTriggerSegmentHit > m_segmentHits
list of track segment hits
double maxR
Hough plane limit in 1/r [1/cm].
double shiftR
Hough plane shift in 1/r [1/cm].
void selectHits(std::vector< unsigned > &list, std::vector< unsigned > &selected, std::vector< unsigned > &unselected)
Select one hit per super layer.
StoreArray< CDCTriggerTrack > m_tracks
list of found tracks
void mergeIdList(std::vector< unsigned > &merged, std::vector< unsigned > &a, std::vector< unsigned > &b)
Merge lists a and b and put the result in merged.
StoreArray< CDCTriggerHoughCluster > m_clusters
list of clusters in the Hough map
Cluster created by the Hough finder of the CDC trigger.
Track created by the CDC trigger.
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
std::pair< ROOT::Math::XYVector, ROOT::Math::XYVector > coord2dPair
Hough Tuples.

◆ connectedUD()

bool connectedUD ( unsigned  patternD,
unsigned  patternU 
)

Check for up/down connection of patterns in 2 x 2 squares.

Definition at line 686 of file CDCTriggerHoughtrafo.cc.

687{
688 // connected if
689 // . . . .
690 // x . . x
691 // --- or ---
692 // x . . x
693 // . . . .
694 bool connectDirect = (((patternU >> 0) & 1) && ((patternD >> 2) & 1)) ||
695 (((patternU >> 1) & 1) && ((patternD >> 3) & 1));
696 // connected if
697 // . .
698 // . x
699 // ---
700 // x .
701 // . .
702 bool connectRise = ((patternU >> 1) & 1) && ((patternD >> 2) & 1);
703 // connected if
704 // . .
705 // x .
706 // ---
707 // . x
708 // . .
709 bool connectFall = ((patternU >> 0) & 1) && ((patternD >> 3) & 1);
710
711 if (m_connect == 4) return connectDirect;
712 else if (m_connect == 6) return (connectDirect || connectRise);
713 else if (m_connect == 8) return (connectDirect || connectRise || connectFall);
714 else B2WARNING("Unknown option for connect " << m_connect << ", using default.");
715 return (connectDirect || connectRise);
716}

◆ countSL()

unsigned short countSL ( bool *  superLayers)

count the number of super layers with hits

Parameters
superLayersarray of hit/no hit for all super layers

Definition at line 24 of file CDCTriggerHoughtrafo.cc.

25{
26 if (m_requireSL0 && !layer[0]) return 0;
27 unsigned short lcnt = 0;
28 for (int i = 0; i < CDC_SUPER_LAYERS; ++i) {
29 if (layer[i] == true) ++lcnt;
30 }
31 return lcnt;
32}

◆ def_beginRun()

virtual void def_beginRun ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function beginRun() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 426 of file Module.h.

426{ beginRun(); }
virtual void beginRun()
Called when entering a new run.
Definition: Module.h:147

◆ def_endRun()

virtual void def_endRun ( )
inlineprotectedvirtualinherited

This method can receive that the current run ends as a call from the Python side.

For regular C++-Modules that forwards the call to the regular endRun() method.

Reimplemented in PyModule.

Definition at line 439 of file Module.h.

439{ endRun(); }
virtual void endRun()
This method is called if the current run ends.
Definition: Module.h:166

◆ def_event()

virtual void def_event ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function event() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 432 of file Module.h.

432{ event(); }
virtual void event()
This method is the core of the module.
Definition: Module.h:157

◆ def_initialize()

virtual void def_initialize ( )
inlineprotectedvirtualinherited

Wrappers to make the methods without "def_" prefix callable from Python.

Overridden in PyModule. Wrapper method for the virtual function initialize() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 420 of file Module.h.

420{ initialize(); }
virtual void initialize()
Initialize the Module.
Definition: Module.h:109

◆ def_terminate()

virtual void def_terminate ( )
inlineprotectedvirtualinherited

Wrapper method for the virtual function terminate() that has the implementation to be used in a call from Python.

Reimplemented in PyModule.

Definition at line 445 of file Module.h.

445{ terminate(); }
virtual void terminate()
This method is called at the end of the event processing.
Definition: Module.h:176

◆ endRun()

virtual void endRun ( void  )
inlinevirtualinherited

This method is called if the current run ends.

Use this method to store information, which should be aggregated over one run.

This method can be implemented by subclasses.

Reimplemented in BeamabortModule, BgoModule, CaveModule, ClawModule, CLAWSModule, DosiModule, FANGSModule, He3tubeModule, MicrotpcModule, Ph1bpipeModule, Ph1sustrModule, PindiodeModule, PlumeModule, QcsmonitorModule, SrsensorModule, GetEventFromSocketModule, CalibrationCollectorModule, AlignDQMModule, CosmicsAlignmentValidationModule, CurlTaggerModule, LowEnergyPi0IdentificationExpertModule, LowEnergyPi0VetoExpertModule, arichBtestModule, ARICHDQMModule, B2BIIMCParticlesMonitorModule, B2BIIConvertMdstModule, B2BIIMdstInputModule, BelleMCOutputModule, BeamBkgGeneratorModule, BeamBkgHitRateMonitorModule, BeamBkgMixerModule, BeamBkgTagSetterModule, BGOverlayInputModule, AnalysisPhase1StudyModule, NtuplePhase1_v6Module, ReprocessorModule, BeamabortStudyModule, BeamDigitizerModule, BgoDigitizerModule, BgoStudyModule, ClawDigitizerModule, ClawStudyModule, ClawsDigitizerModule, ClawsStudyModule, CsiDigitizer_v2Module, CsIDigitizerModule, CsiModule, CsiStudy_v2Module, CsIStudyModule, DosiDigitizerModule, DosiStudyModule, FANGSDigitizerModule, FANGSStudyModule, He3DigitizerModule, He3tubeStudyModule, MicrotpcStudyModule, TpcDigitizerModule, TPCStudyModule, PinDigitizerModule, PindiodeStudyModule, PlumeDigitizerModule, QcsmonitorDigitizerModule, QcsmonitorStudyModule, CDCCosmicAnalysisModule, CDCCRTestModule, cdcDQM7Module, CDCDQMModule, CDCPackerModule, CDCRecoTrackFilterModule, CDCUnpackerModule, DAQPerfModule, RxSocketModule, TxSocketModule, DqmHistoManagerModule, MonitorDataModule, TrackAnaModule, Ds2SampleModule, ReceiveEventModule, HLTDQM2ZMQModule, HLTDs2ZMQModule, ElapsedTimeModule, DeSerializerPXDModule, GenRawSendModule, Root2RawModule, SerializerModule, CertifyParallelModule, Ds2RawModule, Ds2RbufModule, EvReductionModule, FastRbuf2DsModule, Raw2DsModule, RawInputModule, Rbuf2DsModule, Rbuf2RbufModule, Ds2RawFileModule, PartialSeqRootReaderModule, SeqRootMergerModule, StorageDeserializerModule, StorageRootOutputModule, StorageSerializerModule, PhysicsObjectsDQMModule, PhysicsObjectsMiraBelleBhabhaModule, PhysicsObjectsMiraBelleDst2Module, PhysicsObjectsMiraBelleDstModule, PhysicsObjectsMiraBelleHadronModule, PhysicsObjectsMiraBelleModule, ECLBackgroundModule, ECLChargedPIDModule, ECLChargedPIDDataAnalysisModule, ECLChargedPIDDataAnalysisValidationModule, ECLClusterPSDModule, ECLCovarianceMatrixModule, ECLCRFinderModule, ECLDataAnalysisModule, ECLDigitCalibratorModule, ECLDigitizerModule, ECLDigitizerPureCsIModule, EclDisplayModule, ECLDQMModule, ECLDQMEXTENDEDModule, ECLFinalizerModule, ECLHitDebugModule, ECLLocalMaximumFinderModule, ECLLocalRunCalibratorModule, ECLLOMModule, ECLPackerModule, ECLShowerCorrectorModule, ECLShowerShapeModule, ECLSplitterN1Module, ECLSplitterN2Module, ECLUnpackerModule, ECLWaveformFitModule, HistoModule, SubEventModule, SwitchDataStoreModule, EventInfoPrinterModule, RandomBarrierModule, HistoManagerModule, StatisticsSummaryModule, SeqRootInputModule, SeqRootOutputModule, RxModule, TxModule, ZMQTxInputModule, ZMQTxWorkerModule, EvtGenDecayModule, OverrideGenerationFlagsModule, BKLMAnaModule, BKLMDigitAnalyzerModule, BKLMSimHistogrammerModule, BKLMTrackingModule, EKLMDataCheckerModule, KLMClusterEfficiencyModule, KLMClustersReconstructorModule, KLMDigitizerModule, KLMDQMModule, KLMDQM2Module, KLMPackerModule, KLMReconstructorModule, KLMScintillatorSimulatorModule, KLMUnpackerModule, AWESOMEBasicModule, PXDBackgroundModule, PXDClustersFromTracksModule, PXDPerformanceModule, Convert2RawDetModule, PrintDataModule, PrintEventRateModule, Root2BinaryModule, CDCDedxDQMModule, CDCDedxValidationModule, EventT0ValidationModule, DataWriterModule, KlongValidationModule, KLMMuonIDDNNExpertModule, FullSimModule, SVDBackgroundModule, SVDClusterCalibrationsMonitorModule, SVDHotStripFinderModule, SVDLatencyCalibrationModule, SVDLocalCalibrationsMonitorModule, SVDPositionErrorScaleFactorImporterModule, SVDTimeCalibrationsMonitorModule, svdDumpModule, SVDPackerModule, SVDB4CommissioningPlotsModule, SVDClusterEvaluationModule, SVDClusterEvaluationTrueInfoModule, SVDClusterFilterModule, SVDOccupancyAnalysisModule, SVDPerformanceModule, SVDShaperDigitsFromTracksModule, SVDClusterizerModule, SVDCoGTimeEstimatorModule, SVDDataFormatCheckModule, SVDRecoDigitCreatorModule, SVD3SamplesEmulatorModule, SVDTriggerQualityGeneratorModule, SVDUnpackerModule, TOPBackgroundModule, TOPChannelT0MCModule, TOPTriggerDigitizerModule, TOPDoublePulseGeneratorModule, TOPGainEfficiencyCalculatorModule, TOPLaserHitSelectorModule, TOPInterimFENtupleModule, TOPLaserCalibratorModule, TOPMCTrackMakerModule, TOPNtupleModule, TOPPackerModule, TOPRawDigitConverterModule, TOPTBCComparatorModule, TOPTimeBaseCalibratorModule, TOPUnpackerModule, TOPWaveformFeatureExtractorModule, TOPWaveformQualityPlotterModule, TOPXTalkChargeShareSetterModule, ExtModule, GenfitVisModule, MCV0MatcherModule, MCTrackCandClassifierModule, MuidModule, MCSlowPionPXDROICreatorModule, PXDROIFinderModule, SVDROIDQMModule, SVDROIFinderAnalysisModule, SVDROIFinderModule, RT2SPTCConverterModule, SPTCmomentumSeedRetrieverModule, SPTCvirtualIPRemoverModule, TrackFinderMCTruthRecoTracksModule, EffPlotsModule, HitXPModule, TrackingPerformanceEvaluationModule, V0findingPerformanceEvaluationModule, SecMapTrainerBaseModule, SecMapTrainerVXDTFModule, TrackFinderVXDAnalizerModule, VXDSimpleClusterizerModule, NoKickCutsEvalModule, SectorMapBootstrapModule, VXDTFTrainingDataCollectorModule, FindletModule< AFindlet >, FindletModule< HitBasedT0Extractor >, FindletModule< CKFToSVDSeedFindlet >, FindletModule< CKFToSVDFindlet >, FindletModule< CosmicsTrackMergerFindlet >, FindletModule< DATCONFPGAFindlet >, FindletModule< MCVXDCDCTrackMergerFindlet >, FindletModule< vxdHoughTracking::SVDHoughTracking >, FindletModule< CKFToCDCFindlet >, FindletModule< CKFToCDCFromEclFindlet >, FindletModule< CKFToPXDFindlet >, FindletModule< AsicBackgroundLibraryCreator >, FindletModule< CDCTrackingEventLevelMdstInfoFillerFromHitsFindlet >, FindletModule< CDCTrackingEventLevelMdstInfoFillerFromSegmentsFindlet >, FindletModule< AxialSegmentPairCreator >, FindletModule< AxialStraightTrackFinder >, FindletModule< AxialTrackCreatorMCTruth >, FindletModule< AxialTrackCreatorSegmentHough >, FindletModule< AxialTrackFinderHough >, FindletModule< AxialTrackFinderLegendre >, FindletModule< ClusterBackgroundDetector >, FindletModule< ClusterPreparer >, FindletModule< ClusterRefiner< BridgingWireHitRelationFilter > >, FindletModule< FacetCreator >, FindletModule< HitReclaimer >, FindletModule< MonopoleAxialTrackFinderLegendre >, FindletModule< MonopoleStereoHitFinder >, FindletModule< MonopoleStereoHitFinderQuadratic >, FindletModule< SegmentCreatorFacetAutomaton >, FindletModule< SegmentCreatorMCTruth >, FindletModule< SegmentFinderFacetAutomaton >, FindletModule< SegmentFitter >, FindletModule< SegmentLinker >, FindletModule< SegmentOrienter >, FindletModule< SegmentPairCreator >, FindletModule< SegmentRejecter >, FindletModule< SegmentTrackCombiner >, FindletModule< SegmentTripleCreator >, FindletModule< StereoHitFinder >, FindletModule< SuperClusterCreator >, FindletModule< TrackCombiner >, FindletModule< TrackCreatorSegmentPairAutomaton >, FindletModule< TrackCreatorSegmentTripleAutomaton >, FindletModule< TrackCreatorSingleSegments >, FindletModule< TrackExporter >, FindletModule< TrackFinderAutomaton >, FindletModule< TrackFinderCosmics >, FindletModule< TrackFinder >, FindletModule< TrackFinderSegmentPairAutomaton >, FindletModule< TrackFinderSegmentTripleAutomaton >, FindletModule< TrackFlightTimeAdjuster >, FindletModule< TrackLinker >, FindletModule< TrackOrienter >, FindletModule< TrackQualityAsserter >, FindletModule< TrackQualityEstimator >, FindletModule< TrackRejecter >, FindletModule< WireHitBackgroundDetector >, FindletModule< WireHitCreator >, FindletModule< WireHitPreparer >, CDCTriggerNeuroDQMModule, CDCTriggerNeuroDQMOnlineModule, CDCTriggerNDFinderModule, TRGCDCModule, TRGCDCETFUnpackerModule, TRGCDCT2DDQMModule, TRGCDCT3DConverterModule, TRGCDCT3DDQMModule, TRGCDCT3DUnpackerModule, TRGCDCTSFDQMModule, TRGCDCTSFUnpackerModule, TRGCDCTSStreamModule, MCMatcherTRGECLModule, TRGECLFAMModule, TRGECLModule, TRGECLBGTCHitModule, TRGECLDQMModule, TRGECLQAMModule, TRGECLRawdataAnalysisModule, TRGECLTimingCalModule, TRGECLUnpackerModule, TRGGDLModule, TRGEFFDQMModule, TRGGDLDQMModule, TRGGDLDSTModule, TRGGDLSummaryModule, TRGGDLUnpackerModule, TRGGRLMatchModule, TRGGRLModule, TRGGRLProjectsModule, TRGGRLDQMModule, TRGGRLUnpackerModule, KLMTriggerModule, TRGTOPDQMModule, TRGTOPTRD2TTSConverterModule, TRGTOPUnpackerModule, TRGTOPUnpackerWaveformModule, TRGTOPWaveformPlotterModule, TRGRAWDATAModule, DQMHistAnalysisARICHModule, DQMHistAnalysisARICHMonObjModule, DQMHistAnalysisCDCDedxModule, DQMHistAnalysisCDCEpicsModule, DQMHistAnalysisCDCMonObjModule, DQMHistAnalysisDAQMonObjModule, DQMHistAnalysisECLModule, DQMHistAnalysisECLConnectedRegionsModule, DQMHistAnalysisECLOutOfTimeDigitsModule, DQMHistAnalysisECLShapersModule, DQMHistAnalysisECLSummaryModule, DQMHistAnalysisEpicsExampleModule, DQMHistAnalysisExampleModule, DQMHistAnalysisExampleFlagsModule, DQMHistAnalysisHLTMonObjModule, DQMHistAnalysisInput2Module, DQMHistAnalysisInputPVSrvModule, DQMHistAnalysisInputTestModule, DQMHistAnalysisKLMModule, DQMHistAnalysisKLM2Module, DQMHistAnalysisMiraBelleModule, DQMHistAnalysisMonObjModule, DQMHistAnalysisOutputFileModule, DQMHistAnalysisOutputMonObjModule, DQMHistAnalysisOutputRelayMsgModule, DQMHistAnalysisPXDFitsModule, DQMHistAnalysisSVDClustersOnTrackModule, DQMHistAnalysisSVDDoseModule, DQMHistAnalysisSVDEfficiencyModule, DQMHistAnalysisSVDGeneralModule, DQMHistAnalysisSVDOccupancyModule, DQMHistAnalysisSVDOnMiraBelleModule, DQMHistAnalysisSVDUnpackerModule, DQMHistAnalysisTOPModule, DQMHistAnalysisTRGECLModule, DQMHistAnalysisTRGEFFModule, DQMHistAnalysisTRGGDLModule, DQMHistComparitorModule, DQMHistDeltaHistoModule, DQMHistReferenceModule, DQMHistSnapshotsModule, PyModule, SVDUnpackerDQMModule, TrackSetEvaluatorHopfieldNNDEVModule, vxdDigitMaskingModule, DQMHistAnalysisDeltaEpicsMonObjExampleModule, DQMHistAnalysisDeltaTestModule, DQMHistAnalysisEpicsOutputModule, DQMHistAnalysisPhysicsModule, DQMHistAnalysisPXDChargeModule, DQMHistAnalysisPXDTrackChargeModule, DQMHistAnalysisRooFitExampleModule, DQMHistAnalysisTRGModule, and DQMHistOutputToEPICSModule.

Definition at line 166 of file Module.h.

166{};

◆ evalCondition()

bool evalCondition ( ) const
inherited

If at least one condition was set, it is evaluated and true returned if at least one condition returns true.

If no condition or result value was defined, the method returns false. Otherwise, the condition is evaluated and true returned, if at least one condition returns true. To speed up the evaluation, the condition strings were already parsed in the method if_value().

Returns
True if at least one condition and return value exists and at least one condition expression was evaluated to true.

Definition at line 96 of file Module.cc.

97{
98 if (m_conditions.empty()) return false;
99
100 //okay, a condition was set for this Module...
101 if (!m_hasReturnValue) {
102 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
103 }
104
105 for (const auto& condition : m_conditions) {
106 if (condition.evaluate(m_returnValue)) {
107 return true;
108 }
109 }
110 return false;
111}
int m_returnValue
The return value.
Definition: Module.h:519
bool m_hasReturnValue
True, if the return value is set.
Definition: Module.h:518

◆ event()

void event ( void  )
overridevirtual

Run tracking.

Pair of <counter, cdcPair>, for hits with indices

Reimplemented from Module.

Definition at line 164 of file CDCTrigger2DFinderModule.cc.

165{
166 /* Clean hits */
167 hitMap.clear();
168 houghCand.clear();
169
170 /* set default return value */
171 setReturnValue(true);
172
173 if (m_testFilename != "") {
174 testFile << StoreObjPtr<EventMetaData>()->getEvent() << " "
175 << m_segmentHits.getEntries() << endl;
176 }
177
178 if (m_segmentHits.getEntries() == 0) {
179 //B2WARNING("CDCTracking: tsHitsCollection is empty!");
180 return;
181 }
182
183 /* get CDCHits coordinates in conformal space */
184 for (int iHit = 0; iHit < m_segmentHits.getEntries(); iHit++) {
185 unsigned short iSL = m_segmentHits[iHit]->getISuperLayer();
186 if (m_testFilename != "") {
187 testFile << iSL << " " << m_segmentHits[iHit]->getSegmentID() - TSoffset[iSL] << " "
188 << m_segmentHits[iHit]->getPriorityPosition() << endl;
189 }
190 if (iSL % 2) continue;
191 if (m_ignore2nd && m_segmentHits[iHit]->getPriorityPosition() < 3) continue;
192
193 if (m_usehitpattern) {
194 unsigned hitpattern;
195 if (m_useadc) hitpattern = m_segmentHits[iHit]->gethitpattern_adc();
196 else hitpattern = m_segmentHits[iHit]->gethitpattern();
197 int nhitpattern = 0;
198 if (iSL == 0)nhitpattern = 15;
199 else nhitpattern = 11;
200 for (int i = 0; i < nhitpattern; i++) {
201 if ((hitpattern & (1 << i)) != 0) {
202 double phi = m_segmentHits[iHit]->getSegmentID() - TSoffset[iSL];
203 if (iSL != 0 && i == 0) phi = phi - 1;
204 else if (iSL != 0 && i == 1) phi = phi + 0;
205 else if (iSL != 0 && i == 2) phi = phi + 1;
206 else if (iSL != 0 && i == 3) phi = phi - 0.5;
207 else if (iSL != 0 && i == 4) phi = phi + 0.5;
208 else if (iSL != 0 && i == 5) phi = phi + 0;
209 else if (iSL != 0 && i == 6) phi = phi - 0.5;
210 else if (iSL != 0 && i == 7) phi = phi + 0.5;
211 else if (iSL != 0 && i == 8) phi = phi - 1;
212 else if (iSL != 0 && i == 9) phi = phi + 0;
213 else if (iSL != 0 && i == 10) phi = phi + 1;
214 else if (iSL == 0 && i == 0) phi = phi + 0;
215 else if (iSL == 0 && i == 1) phi = phi - 0.5;
216 else if (iSL == 0 && i == 2) phi = phi + 0.5;
217 else if (iSL == 0 && i == 3) phi = phi - 1;
218 else if (iSL == 0 && i == 4) phi = phi + 0;
219 else if (iSL == 0 && i == 5) phi = phi + 1;
220 else if (iSL == 0 && i == 6) phi = phi - 1.5;
221 else if (iSL == 0 && i == 7) phi = phi - 0.5;
222 else if (iSL == 0 && i == 8) phi = phi + 0.5;
223 else if (iSL == 0 && i == 9) phi = phi + 1.5;
224 else if (iSL == 0 && i == 10) phi = phi - 2;
225 else if (iSL == 0 && i == 11) phi = phi - 1;
226 else if (iSL == 0 && i == 12) phi = phi + 0;
227 else if (iSL == 0 && i == 13) phi = phi + 1;
228 else if (iSL == 0 && i == 14) phi = phi + 2;
229 phi = phi * 2. * M_PI / (TSoffset[iSL + 1] - TSoffset[iSL]);
230 int iLayer = 0;
231 if (iSL != 0 && i == 0) iLayer = 0;
232 else if (iSL != 0 && i == 1) iLayer = 0;
233 else if (iSL != 0 && i == 2) iLayer = 0;
234 else if (iSL != 0 && i == 3) iLayer = 1;
235 else if (iSL != 0 && i == 4) iLayer = 1;
236 else if (iSL != 0 && i == 5) iLayer = 2;
237 else if (iSL != 0 && i == 6) iLayer = 3;
238 else if (iSL != 0 && i == 7) iLayer = 3;
239 else if (iSL != 0 && i == 8) iLayer = 4;
240 else if (iSL != 0 && i == 9) iLayer = 4;
241 else if (iSL != 0 && i == 10) iLayer = 4;
242 else if (iSL == 0 && i == 0) iLayer = 0;
243 else if (iSL == 0 && i == 1) iLayer = 1;
244 else if (iSL == 0 && i == 2) iLayer = 1;
245 else if (iSL == 0 && i == 3) iLayer = 2;
246 else if (iSL == 0 && i == 4) iLayer = 2;
247 else if (iSL == 0 && i == 5) iLayer = 2;
248 else if (iSL == 0 && i == 6) iLayer = 3;
249 else if (iSL == 0 && i == 7) iLayer = 3;
250 else if (iSL == 0 && i == 8) iLayer = 3;
251 else if (iSL == 0 && i == 9) iLayer = 3;
252 else if (iSL == 0 && i == 10) iLayer = 4;
253 else if (iSL == 0 && i == 11) iLayer = 4;
254 else if (iSL == 0 && i == 12) iLayer = 4;
255 else if (iSL == 0 && i == 13) iLayer = 4;
256 else if (iSL == 0 && i == 14) iLayer = 4;
257
258 double r = radius[iSL][iLayer];
259 ROOT::Math::XYVector pos(cos(phi) / r, sin(phi) / r);
260 hitMap.insert(std::make_pair(iHit * 15 + i, std::make_pair(iSL * 5 + iLayer, pos)));
261 }
262 }
263 } else {
264 double phi = m_segmentHits[iHit]->getSegmentID() - TSoffset[iSL];
265 if (m_usePriority) {
266 phi += 0.5 * (((m_segmentHits[iHit]->getPriorityPosition() >> 1) & 1)
267 - (m_segmentHits[iHit]->getPriorityPosition() & 1));
268 }
269 phi = phi * 2. * M_PI / (TSoffset[iSL + 1] - TSoffset[iSL]);
270 double r = radius[iSL][int(m_usePriority &&
271 m_segmentHits[iHit]->getPriorityPosition() < 3)];
272 ROOT::Math::XYVector pos(cos(phi) / r, sin(phi) / r);
273 hitMap.insert(std::make_pair(iHit, std::make_pair(iSL, pos)));
274 }
275 }
276
277 /* Extent the Hough plane such that the cell number is a power of 2 (same for x and y).
278 * This is for the fast peak finder, which divides the Hough plane in half in each step.
279 * Peaks found outside of the actual limits are ignored. */
280 maxIterations = ceil(log2(max(m_nCellsPhi, m_nCellsR))) - 1;
281 nCells = pow(2, maxIterations + 1);
282 /* limits in phi: [-pi, pi] + extra cells */
283 double rectX = M_PI * nCells / m_nCellsPhi;
284 /* limits in R: [-R(minPt), R(minPt)] + extra cells + shift */
285 maxR = 0.5 * Const::speedOfLight * 1.5e-4 / m_minPt;
286 double rectY = maxR * nCells / m_nCellsR;
287 shiftR = 0;
288 if (m_shiftPt < 0) {
289 shiftR = -maxR / 2. / m_nCellsR;
290 } else if (m_shiftPt > 0) {
291 shiftR = maxR / 2. / m_nCellsR;
292 }
293
294 B2DEBUG(50, "extending Hough plane to " << maxIterations << " iterations, "
295 << nCells << " cells: phi in ["
296 << -rectX * 180. / M_PI << ", " << rectX * 180. / M_PI
297 << "] deg, 1/r in [" << -rectY + shiftR << ", " << rectY + shiftR << "] /cm");
298
299 /* prepare matrix for storing the Hough plane */
300 if (m_storePlane > 0) {
303 }
304
305 // hit map containing only the early hits
306 cdcMap fastHitMap;
307 if (m_suppressClone && !hitMap.empty()) {
308 // find the first track candidates in Hough plane
309 // only for z0 resolution study with single-track events
310 // This will surely fail with multi-track ones,
311 // in which case we really need tick-by-tick simulation for all hits.
312
314 typedef pair<int, cdcPair> cdcHitPair;
315 // sequential hit map, ordered by TS found time
316 typedef vector<cdcHitPair> cdcSeqMap;
317 cdcSeqMap seqHitMap;
318 // copy hit map to sequential hit map and sort it by TS found time
319 for (auto hit : hitMap) {
320 seqHitMap.push_back(hit);
321 }
322 sort(seqHitMap.begin(), seqHitMap.end(), [this](cdcHitPair i, cdcHitPair j) {
323 return m_segmentHits[i.first]->foundTime() < m_segmentHits[j.first]->foundTime();
324 });
325 auto seqHitItr = seqHitMap.begin();
326 /* layer filter */
327 vector<bool> layerHit(CDC_SUPER_LAYERS, false);
328 // data clock cycle in unit of 2ns
329 short period = 16;
330 short firstTick = m_segmentHits[(*seqHitMap.begin()).first]->foundTime() / period + 1;
331 short lastTick = m_segmentHits[(*(seqHitMap.end() - 1)).first]->foundTime() / period + 1;
332 // add TS hits in every clock cycle until a track candidate is found
333 for (auto tick = firstTick * period; tick < lastTick * period; tick += period) {
334 int nHitInCycle = 0;
335 for (auto itr = seqHitItr; itr < seqHitMap.end(); ++itr) {
336 cdcHitPair currentHit = *itr;
337 // start from the first hit over SL threshold
338 if (count(layerHit.begin(), layerHit.end(), true) >= m_minHits &&
339 m_segmentHits[currentHit.first]->foundTime() > tick) {
340 break;
341 }
342 nHitInCycle++;
343 layerHit[m_segmentHits[currentHit.first]->getISuperLayer()] = true;
344 }
345 copy_n(seqHitItr, nHitInCycle, inserter(fastHitMap, fastHitMap.end()));
346 fastInterceptFinder(fastHitMap, -rectX, rectX, -rectY + shiftR, rectY + shiftR, 0, 0, 0);
347 B2DEBUG(20, "at tick " << tick << ", number of candidates: " << houghCand.size());
348 if (!houghCand.empty()) {
349 B2DEBUG(10, "found a track at clock " << tick << " with "
350 << fastHitMap.size() << "hits");
351 break;
352 }
353 advance(seqHitItr, nHitInCycle);
354 }
355 } else {
356 /* find track candidates in Hough plane using all TS hits */
357 fastInterceptFinder(hitMap, -rectX, rectX, -rectY + shiftR, rectY + shiftR, 0, 0, 0);
358 if (!houghCand.empty()) {
359 B2DEBUG(10, "found a track with " << hitMap.size() << "hits");
360 }
361 }
362
363 /* merge track candidates */
365 patternClustering(fastHitMap);
366 else
368
369 if (m_testFilename != "") {
370 testFile << m_tracks.getEntries() << endl;
371 for (int i = 0; i < m_tracks.getEntries(); ++i) {
372 float ix = (m_tracks[i]->getPhi0() - M_PI_4) * m_nCellsPhi / 2. / M_PI - 0.5;
373 float iy = (m_tracks[i]->getOmega() / 2. + maxR - shiftR) * m_nCellsR / 2. / maxR - 0.5;
374 testFile << round(2 * ix) / 2. << " " << round(2 * iy) / 2. << " "
375 << m_tracks[i]->getChargeSign() << endl;
378 testFile << hits.size() << endl;
379 for (unsigned ihit = 0; ihit < hits.size(); ++ihit) {
380 unsigned short iSL = hits[ihit]->getISuperLayer();
381 testFile << iSL << " " << hits[ihit]->getSegmentID() - TSoffset[iSL] << " "
382 << hits[ihit]->getPriorityPosition() << " "
383 << hits.weight(ihit) << endl;
384 }
385 }
386 }
387}
int fastInterceptFinder(cdcMap &hits, double x1_s, double x2_s, double y1_s, double y2_s, unsigned iterations, unsigned ix_s, unsigned iy_s)
Fast intercept finder Divide Hough plane recursively to find cells with enough crossing lines.
std::ofstream testFile
filestream for test output for firmware debugging
unsigned maxIterations
number of iterations for the fast peak finder, smallest n such that 2^(n+1) > max(nCellsPhi,...
StoreObjPtr< TMatrix > m_houghPlane
matrix containing the Hough plane
void patternClustering(const cdcMap &inputMap)
Combine Hough candidates to tracks by a fixed pattern algorithm.
unsigned nCells
number of cells for the fast peak finder: 2^(maxIterations + 1).
cdcMap hitMap
map of TS hits containing <iHit, <iSL, (x, y)>> with iHit: hit index in StoreArray iSL: super layer i...
unsigned TSoffset[10]
Number of track segments up to super layer.
double radius[9][5]
Radius of the CDC layers with priority wires (2 per super layer).
void connectedRegions()
Combine Hough candidates to tracks by merging connected cells.
Combination of several CDCHits to a track segment hit for the trigger.
static const double speedOfLight
[cm/ns]
Definition: Const.h:695
Class for type safe access to objects that are referred to in relations.
bool create(bool replace=false)
Create a default object in the data store.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
std::map< int, cdcPair > cdcMap
Map of <counter, cdcPair>, for hits with indices.

◆ exposePythonAPI()

void exposePythonAPI ( )
staticinherited

Exposes methods of the Module class to Python.

Definition at line 325 of file Module.cc.

326{
327 // to avoid confusion between std::arg and boost::python::arg we want a shorthand namespace as well
328 namespace bp = boost::python;
329
330 docstring_options options(true, true, false); //userdef, py sigs, c++ sigs
331
332 void (Module::*setReturnValueInt)(int) = &Module::setReturnValue;
333
334 enum_<Module::EAfterConditionPath>("AfterConditionPath",
335 R"(Determines execution behaviour after a conditional path has been executed:
336
337.. attribute:: END
338
339 End processing of this path after the conditional path. (this is the default for if_value() etc.)
340
341.. attribute:: CONTINUE
342
343 After the conditional path, resume execution after this module.)")
344 .value("END", Module::EAfterConditionPath::c_End)
345 .value("CONTINUE", Module::EAfterConditionPath::c_Continue)
346 ;
347
348 /* Do not change the names of >, <, ... we use them to serialize conditional pathes */
349 enum_<Belle2::ModuleCondition::EConditionOperators>("ConditionOperator")
356 ;
357
358 enum_<Module::EModulePropFlags>("ModulePropFlags",
359 R"(Flags to indicate certain low-level features of modules, see :func:`Module.set_property_flags()`, :func:`Module.has_properties()`. Most useful flags are:
360
361.. attribute:: PARALLELPROCESSINGCERTIFIED
362
363 This module can be run in parallel processing mode safely (All I/O must be done through the data store, in particular, the module must not write any files.)
364
365.. attribute:: HISTOGRAMMANAGER
366
367 This module is used to manage histograms accumulated by other modules
368
369.. attribute:: TERMINATEINALLPROCESSES
370
371 When using parallel processing, call this module's terminate() function in all processes. This will also ensure that there is exactly one process (single-core if no parallel modules found) or at least one input, one main and one output process.
372)")
373 .value("INPUT", Module::EModulePropFlags::c_Input)
374 .value("OUTPUT", Module::EModulePropFlags::c_Output)
375 .value("PARALLELPROCESSINGCERTIFIED", Module::EModulePropFlags::c_ParallelProcessingCertified)
376 .value("HISTOGRAMMANAGER", Module::EModulePropFlags::c_HistogramManager)
377 .value("INTERNALSERIALIZER", Module::EModulePropFlags::c_InternalSerializer)
378 .value("TERMINATEINALLPROCESSES", Module::EModulePropFlags::c_TerminateInAllProcesses)
379 ;
380
381 //Python class definition
382 class_<Module, PyModule> module("Module", R"(
383Base class for Modules.
384
385A module is the smallest building block of the framework.
386A typical event processing chain consists of a Path containing
387modules. By inheriting from this base class, various types of
388modules can be created. To use a module, please refer to
389:func:`Path.add_module()`. A list of modules is available by running
390``basf2 -m`` or ``basf2 -m package``, detailed information on parameters is
391given by e.g. ``basf2 -m RootInput``.
392
393The 'Module Development' section in the manual provides detailed information
394on how to create modules, setting parameters, or using return values/conditions:
395https://xwiki.desy.de/xwiki/rest/p/f4fa4/#HModuleDevelopment
396
397)");
398 module
399 .def("__str__", &Module::getPathString)
400 .def("name", &Module::getName, return_value_policy<copy_const_reference>(),
401 "Returns the name of the module. Can be changed via :func:`set_name() <Module.set_name()>`, use :func:`type() <Module.type()>` for identifying a particular module class.")
402 .def("type", &Module::getType, return_value_policy<copy_const_reference>(),
403 "Returns the type of the module (i.e. class name minus 'Module')")
404 .def("set_name", &Module::setName, args("name"), R"(
405Set custom name, e.g. to distinguish multiple modules of the same type.
406
407>>> path.add_module('EventInfoSetter')
408>>> ro = path.add_module('RootOutput', branchNames=['EventMetaData'])
409>>> ro.set_name('RootOutput_metadata_only')
410>>> print(path)
411[EventInfoSetter -> RootOutput_metadata_only]
412
413)")
414 .def("description", &Module::getDescription, return_value_policy<copy_const_reference>(),
415 "Returns the description of this module.")
416 .def("package", &Module::getPackage, return_value_policy<copy_const_reference>(),
417 "Returns the package this module belongs to.")
418 .def("available_params", &_getParamInfoListPython,
419 "Return list of all module parameters as `ModuleParamInfo` instances")
420 .def("has_properties", &Module::hasProperties, (bp::arg("properties")),
421 R"DOCSTRING(Allows to check if the module has the given properties out of `ModulePropFlags` set.
422
423>>> if module.has_properties(ModulePropFlags.PARALLELPROCESSINGCERTIFIED):
424>>> ...
425
426Parameters:
427 properties (int): bitmask of `ModulePropFlags` to check for.
428)DOCSTRING")
429 .def("set_property_flags", &Module::setPropertyFlags, args("property_mask"),
430 "Set module properties in the form of an OR combination of `ModulePropFlags`.");
431 {
432 // python signature is too crowded, make ourselves
433 docstring_options subOptions(true, false, false); //userdef, py sigs, c++ sigs
434 module
435 .def("if_value", &Module::if_value,
436 (bp::arg("expression"), bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
437 R"DOCSTRING(if_value(expression, condition_path, after_condition_path=AfterConditionPath.END)
438
439Sets a conditional sub path which will be executed after this
440module if the return value set in the module passes the given ``expression``.
441
442Modules can define a return value (int or bool) using ``setReturnValue()``,
443which can be used in the steering file to split the Path based on this value, for example
444
445>>> module_with_condition.if_value("<1", another_path)
446
447In case the return value of the ``module_with_condition`` for a given event is
448less than 1, the execution will be diverted into ``another_path`` for this event.
449
450You could for example set a special return value if an error occurs, and divert
451the execution into a path containing :b2:mod:`RootOutput` if it is found;
452saving only the data producing/produced by the error.
453
454After a conditional path has executed, basf2 will by default stop processing
455the path for this event. This behaviour can be changed by setting the
456``after_condition_path`` argument.
457
458Parameters:
459 expression (str): Expression to determine if the conditional path should be executed.
460 This should be one of the comparison operators ``<``, ``>``, ``<=``,
461 ``>=``, ``==``, or ``!=`` followed by a numerical value for the return value
462 condition_path (Path): path to execute in case the expression is fulfilled
463 after_condition_path (AfterConditionPath): What to do once the ``condition_path`` has been executed.
464)DOCSTRING")
465 .def("if_false", &Module::if_false,
466 (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
467 R"DOC(if_false(condition_path, after_condition_path=AfterConditionPath.END)
468
469Sets a conditional sub path which will be executed after this module if
470the return value of the module evaluates to False. This is equivalent to
471calling `if_value` with ``expression=\"<1\"``)DOC")
472 .def("if_true", &Module::if_true,
473 (bp::arg("condition_path"), bp::arg("after_condition_path")= Module::EAfterConditionPath::c_End),
474 R"DOC(if_true(condition_path, after_condition_path=AfterConditionPath.END)
475
476Sets a conditional sub path which will be executed after this module if
477the return value of the module evaluates to True. It is equivalent to
478calling `if_value` with ``expression=\">=1\"``)DOC");
479 }
480 module
481 .def("has_condition", &Module::hasCondition,
482 "Return true if a conditional path has been set for this module "
483 "using `if_value`, `if_true` or `if_false`")
484 .def("get_all_condition_paths", &_getAllConditionPathsPython,
485 "Return a list of all conditional paths set for this module using "
486 "`if_value`, `if_true` or `if_false`")
487 .def("get_all_conditions", &_getAllConditionsPython,
488 "Return a list of all conditional path expressions set for this module using "
489 "`if_value`, `if_true` or `if_false`")
490 .add_property("logging", make_function(&Module::getLogConfig, return_value_policy<reference_existing_object>()),
@ c_GE
Greater or equal than: ">=".
@ c_SE
Smaller or equal than: "<=".
@ c_GT
Greater than: ">"
@ c_NE
Not equal: "!=".
@ c_EQ
Equal: "=" or "=="
@ c_ST
Smaller than: "<"
Base class for Modules.
Definition: Module.h:72
LogConfig & getLogConfig()
Returns the log system configuration.
Definition: Module.h:225
void if_value(const std::string &expression, const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
Add a condition to the module.
Definition: Module.cc:79
void if_true(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to set the condition of the module.
Definition: Module.cc:90
void setLogConfig(const LogConfig &logConfig)
Set the log system configuration.
Definition: Module.h:230
const std::string & getDescription() const
Returns the description of the module.
Definition: Module.h:202
void if_false(const std::shared_ptr< Path > &path, EAfterConditionPath afterConditionPath=EAfterConditionPath::c_End)
A simplified version to add a condition to the module.
Definition: Module.cc:85
bool hasCondition() const
Returns true if at least one condition was set for the module.
Definition: Module.h:311
const std::string & getPackage() const
Returns the package this module is in.
Definition: Module.h:197
void setName(const std::string &name)
Set the name of the module.
Definition: Module.h:214
bool hasProperties(unsigned int propertyFlags) const
Returns true if all specified property flags are available in this module.
Definition: Module.cc:160
std::string getPathString() const override
return the module name.
Definition: Module.cc:192

◆ fastInterceptFinder()

int fastInterceptFinder ( cdcMap hits,
double  x1_s,
double  x2_s,
double  y1_s,
double  y2_s,
unsigned  iterations,
unsigned  ix_s,
unsigned  iy_s 
)

Fast intercept finder Divide Hough plane recursively to find cells with enough crossing lines.

Parameters
hitsmap of hit coordinates in conformal space
x1_s,x2_s,y1_s,y2_slimits of starting rectangle
iterationscurrent iteration index
ix_s,iy_sindices of starting rectangle

Definition at line 57 of file CDCTriggerHoughtrafo.cc.

62{
63 string indent = "";
64 for (unsigned i = 0; i < iterations; ++i) indent += " ";
65 B2DEBUG(150, indent << "intercept finder iteration " << iterations
66 << " x1 " << x1_s * 180 / M_PI << " x2 " << x2_s * 180 / M_PI
67 << " y1 " << y1_s << " y2 " << y2_s
68 << " ix " << ix_s << " iy " << iy_s);
69
70 int i, j, iHit;
71 double unitx, unity;
72 double y1, y2;
73 double m, a;
74 cdcPair hp;
75 unsigned short iSL;
76 // list of hit indices crossing the current rectangle
77 vector<unsigned> idx_list;
78
79 // limits of divided rectangles
80 double x1_d, x2_d, y1_d, y2_d;
81
82 // cell indices in full plane
83 unsigned ix, iy;
84
85 unitx = ((x2_s - x1_s) / 2.0);
86 unity = ((y2_s - y1_s) / 2.0);
87
88 // divide x axis in half
89 for (i = 0; i < 2 ; ++i) {
90 // divide y axis in half
91 for (j = 0; j < 2; ++j) {
92 x1_d = x1_s + i * unitx;
93 x2_d = x1_s + (i + 1) * unitx;
94 y1_d = y1_s + j * unity;
95 y2_d = y1_s + (j + 1) * unity;
96
97 ix = 2 * ix_s + i;
98 iy = 2 * iy_s + j;
99
100 // skip extra cells outside of the Hough plane
101 if (x2_d <= -M_PI || x1_d >= M_PI || y2_d <= -maxR + shiftR || y1_d >= maxR + shiftR) {
102 B2DEBUG(150, indent << "skip Hough cell outside of plane limits");
103 continue;
104 }
105
106 // if the cell size in phi is too large, the hit calculation is not reliable
107 // -> continue to next iteration without hit check
108 if (iterations != maxIterations && unitx > M_PI / 2.) {
109 fastInterceptFinder(hits, x1_d, x2_d, y1_d, y2_d, iterations + 1, ix, iy);
110 continue;
111 }
112
113 idx_list.clear();
114 bool layerHit[CDC_SUPER_LAYERS] = {false}; /* For layer filter */
115 for (auto it = hits.begin(); it != hits.end(); ++it) {
116 iHit = it->first;
117 hp = it->second;
118 iSL = hp.first;
119 m = hp.second.X();
120 a = hp.second.Y();
121
122 // calculate Hough curve with slightly enlarged limits to avoid errors due to rounding
123 y1 = m * sin(x1_d - 1e-10) - a * cos(x1_d - 1e-10);
124 y2 = m * sin(x2_d + 1e-10) - a * cos(x2_d + 1e-10);
125 // skip decreasing half of the sine (corresponds to curl back half of the track)
126 if (iterations == maxIterations && y1 > y2) continue;
127 if (!((y1 > y2_d && y2 > y2_d) || (y1 < y1_d && y2 < y1_d))) {
128 if (iterations == maxIterations) {
129 idx_list.push_back(iHit);
130 }
131 layerHit[iSL] = true; /* layer filter */
132 }
133 }
134 unsigned short nSL = countSL(layerHit);
135 B2DEBUG(150, indent << "i " << i << " j " << j
136 << " layerHit " << int(layerHit[0]) << int(layerHit[2])
137 << int(layerHit[4]) << int(layerHit[6]) << int(layerHit[8])
138 << " nSL " << nSL);
139 //std::cout << indent << "i " << i << " j " << j
140 // << " layerHit " << int(layerHit[0]) << int(layerHit[2])
141 // << int(layerHit[4]) << int(layerHit[6]) << int(layerHit[8])
142 // << " nSL " << nSL << std::endl;
143 if (nSL >= m_minHits || shortTrack(layerHit)) {
144 if (iterations != maxIterations) {
145 fastInterceptFinder(hits, x1_d, x2_d, y1_d, y2_d, iterations + 1, ix, iy);
146 } else {
147 ROOT::Math::XYVector v1(x1_d, y1_d);
148 ROOT::Math::XYVector v2(x2_d, y2_d);
149 houghCand.push_back(CDCTriggerHoughCand(idx_list, make_pair(v1, v2),
150 nSL, houghCand.size()));
151 if (m_storePlane > 0) {
152 (*m_houghPlane)[ix - (nCells - m_nCellsPhi) / 2][iy - (nCells - m_nCellsR) / 2] = nSL;
153 }
154 }
155 } else if (m_storePlane > 1) {
156 // to store the full Hough plane, we need to continue the iteration
157 // to minimal cell size everywhere
158 for (unsigned min = m_minHits - 1; min > 0; --min) {
159 if (nSL >= min) {
160 if (iterations != maxIterations) {
161 fastInterceptFinder(hits, x1_d, x2_d, y1_d, y2_d, iterations + 1, ix, iy);
162 } else {
163 (*m_houghPlane)[ix - (nCells - m_nCellsPhi) / 2][iy - (nCells - m_nCellsR) / 2] = nSL;
164 }
165 break;
166 }
167 }
168 }
169 }
170 }
171
172 return 0;
173}
unsigned short countSL(bool *superLayers)
count the number of super layers with hits
bool shortTrack(bool *superLayers)
check the short track condition (= hits in the inner super layers rather than any super layers)
std::pair< unsigned short, ROOT::Math::XYVector > cdcPair
Pair of <iSuperLayer, (x, y)>, for hits in conformal space.
const std::vector< double > v2
MATLAB generated random vector.
const std::vector< double > v1
MATLAB generated random vector.

◆ findAllCrossingHits()

void findAllCrossingHits ( std::vector< unsigned > &  list,
double  x1,
double  x2,
double  y1,
double  y2,
const cdcMap inputMap 
)

Find all hits in inputMap whose Hough curve crosses the rectangle with corners (x1, y1) and (x2, y2) and add the hit indices to list.

Definition at line 416 of file CDCTriggerHoughtrafo.cc.

420{
421 double m, a, y1_h, y2_h;
422 for (int iHit = 0; iHit < m_segmentHits.getEntries(); iHit++) {
423 unsigned short iSL = m_segmentHits[iHit]->getISuperLayer();
424 if (iSL % 2) continue;
425 // associate only the hits actually used to form the cluster
426 if (m_suppressClone && inputMap.find(iHit) == inputMap.end()) continue;
427 //TODO: add options: center cell / active priority cell / all priority cells
428 vector<double> phi = {0, 0, 0};
429 phi[0] = m_segmentHits[iHit]->getSegmentID() - TSoffset[iSL];
430 phi[1] = phi[0] + 0.5;
431 phi[2] = phi[0] - 0.5;
432 vector<double> r = {radius[iSL][0], radius[iSL][1], radius[iSL][1]};
433 for (unsigned i = 0; i < 3; ++i) {
434 phi[i] *= 2. * M_PI / (TSoffset[iSL + 1] - TSoffset[iSL]);
435 m = cos(phi[i]) / r[i];
436 a = sin(phi[i]) / r[i];
437 // calculate Hough curve with slightly enlarged limits to avoid errors due to rounding
438 y1_h = m * sin(x1 - 1e-10) - a * cos(x1 - 1e-10);
439 y2_h = m * sin(x2 + 1e-10) - a * cos(x2 + 1e-10);
440 // skip decreasing half of the sine (corresponds to curl back half of the track)
441 if (y1_h > y2_h) continue;
442 if (!((y1_h > y2 && y2_h > y2) || (y1_h < y1 && y2_h < y1))) {
443 list.push_back(iHit);
444 break;
445 }
446 }
447 }
448}

◆ getAfterConditionPath()

Module::EAfterConditionPath getAfterConditionPath ( ) const
inherited

What to do after the conditional path is finished.

(defaults to c_End if no condition is set)

Definition at line 133 of file Module.cc.

134{
135 if (m_conditions.empty()) return EAfterConditionPath::c_End;
136
137 //okay, a condition was set for this Module...
138 if (!m_hasReturnValue) {
139 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
140 }
141
142 for (const auto& condition : m_conditions) {
143 if (condition.evaluate(m_returnValue)) {
144 return condition.getAfterConditionPath();
145 }
146 }
147
148 return EAfterConditionPath::c_End;
149}

◆ getAllConditionPaths()

std::vector< std::shared_ptr< Path > > getAllConditionPaths ( ) const
inherited

Return all condition paths currently set (no matter if the condition is true or not).

Definition at line 150 of file Module.cc.

151{
152 std::vector<std::shared_ptr<Path>> allConditionPaths;
153 for (const auto& condition : m_conditions) {
154 allConditionPaths.push_back(condition.getPath());
155 }
156
157 return allConditionPaths;
158}

◆ getAllConditions()

const std::vector< ModuleCondition > & getAllConditions ( ) const
inlineinherited

Return all set conditions for this module.

Definition at line 324 of file Module.h.

325 {
326 return m_conditions;
327 }

◆ getCondition()

const ModuleCondition * getCondition ( ) const
inlineinherited

Return a pointer to the first condition (or nullptr, if none was set)

Definition at line 314 of file Module.h.

315 {
316 if (m_conditions.empty()) {
317 return nullptr;
318 } else {
319 return &m_conditions.front();
320 }
321 }

◆ getConditionPath()

std::shared_ptr< Path > getConditionPath ( ) const
inherited

Returns the path of the last true condition (if there is at least one, else reaturn a null pointer).


Definition at line 113 of file Module.cc.

114{
115 PathPtr p;
116 if (m_conditions.empty()) return p;
117
118 //okay, a condition was set for this Module...
119 if (!m_hasReturnValue) {
120 B2FATAL("A condition was set for '" << getName() << "', but the module did not set a return value!");
121 }
122
123 for (const auto& condition : m_conditions) {
124 if (condition.evaluate(m_returnValue)) {
125 return condition.getPath();
126 }
127 }
128
129 // if none of the conditions were true, return a null pointer.
130 return p;
131}
std::shared_ptr< Path > PathPtr
Defines a pointer to a path object as a boost shared pointer.
Definition: Path.h:35

◆ getDescription()

const std::string & getDescription ( ) const
inlineinherited

Returns the description of the module.

Definition at line 202 of file Module.h.

202{return m_description;}
std::string m_description
The description of the module.
Definition: Module.h:511

◆ getFileNames()

virtual std::vector< std::string > getFileNames ( bool  outputFiles)
inlinevirtualinherited

Return a list of output filenames for this modules.

This will be called when basf2 is run with "--dry-run" if the module has set either the c_Input or c_Output properties.

If the parameter outputFiles is false (for modules with c_Input) the list of input filenames should be returned (if any). If outputFiles is true (for modules with c_Output) the list of output files should be returned (if any).

If a module has sat both properties this member is called twice, once for each property.

The module should return the actual list of requested input or produced output filenames (including handling of input/output overrides) so that the grid system can handle input/output files correctly.

This function should return the same value when called multiple times. This is especially important when taking the input/output overrides from Environment as they get consumed when obtained so the finalized list of output files should be stored for subsequent calls.

Reimplemented in RootInputModule, StorageRootOutputModule, and RootOutputModule.

Definition at line 134 of file Module.h.

135 {
136 return std::vector<std::string>();
137 }

◆ getLogConfig()

LogConfig & getLogConfig ( )
inlineinherited

Returns the log system configuration.

Definition at line 225 of file Module.h.

225{return m_logConfig;}

◆ getModules()

std::list< ModulePtr > getModules ( ) const
inlineoverrideprivatevirtualinherited

no submodules, return empty list

Implements PathElement.

Definition at line 506 of file Module.h.

506{ return std::list<ModulePtr>(); }

◆ getName()

const std::string & getName ( ) const
inlineinherited

Returns the name of the module.

This can be changed via e.g. set_name() in the steering file to give more useful names if there is more than one module of the same type.

For identifying the type of a module, using getType() (or type() in Python) is recommended.

Definition at line 187 of file Module.h.

187{return m_name;}
std::string m_name
The name of the module, saved as a string (user-modifiable)
Definition: Module.h:508

◆ getPackage()

const std::string & getPackage ( ) const
inlineinherited

Returns the package this module is in.

Definition at line 197 of file Module.h.

197{return m_package;}

◆ getParamInfoListPython()

std::shared_ptr< boost::python::list > getParamInfoListPython ( ) const
inherited

Returns a python list of all parameters.

Each item in the list consists of the name of the parameter, a string describing its type, a python list of all default values and the description of the parameter.

Returns
A python list containing the parameters of this parameter list.

Definition at line 279 of file Module.cc.

280{
282}
std::shared_ptr< boost::python::list > getParamInfoListPython() const
Returns a python list of all parameters.
ModuleParamList m_moduleParamList
List storing and managing all parameter of the module.
Definition: Module.h:516

◆ getParamList()

const ModuleParamList & getParamList ( ) const
inlineinherited

Return module param list.

Definition at line 363 of file Module.h.

363{ return m_moduleParamList; }

◆ getPathString()

std::string getPathString ( ) const
overrideprivatevirtualinherited

return the module name.

Implements PathElement.

Definition at line 192 of file Module.cc.

193{
194
195 std::string output = getName();
196
197 for (const auto& condition : m_conditions) {
198 output += condition.getString();
199 }
200
201 return output;
202}

◆ getReturnValue()

int getReturnValue ( ) const
inlineinherited

Return the return value set by this module.

This value is only meaningful if hasReturnValue() is true

Definition at line 381 of file Module.h.

381{ return m_returnValue; }

◆ getType()

const std::string & getType ( ) const
inherited

Returns the type of the module (i.e.

class name minus 'Module')

Definition at line 41 of file Module.cc.

42{
43 if (m_type.empty())
44 B2FATAL("Module type not set for " << getName());
45 return m_type;
46}
std::string m_type
The type of the module, saved as a string.
Definition: Module.h:509

◆ hasCondition()

bool hasCondition ( ) const
inlineinherited

Returns true if at least one condition was set for the module.

Definition at line 311 of file Module.h.

311{ return not m_conditions.empty(); };

◆ hasProperties()

bool hasProperties ( unsigned int  propertyFlags) const
inherited

Returns true if all specified property flags are available in this module.

Parameters
propertyFlagsOred EModulePropFlags which should be compared with the module flags.

Definition at line 160 of file Module.cc.

161{
162 return (propertyFlags & m_propertyFlags) == propertyFlags;
163}

◆ hasReturnValue()

bool hasReturnValue ( ) const
inlineinherited

Return true if this module has a valid return value set.

Definition at line 378 of file Module.h.

378{ return m_hasReturnValue; }

◆ hasUnsetForcedParams()

bool hasUnsetForcedParams ( ) const
inherited

Returns true and prints error message if the module has unset parameters which the user has to set in the steering file.

Definition at line 166 of file Module.cc.

167{
169 std::string allMissing = "";
170 for (const auto& s : missing)
171 allMissing += s + " ";
172 if (!missing.empty())
173 B2ERROR("The following required parameters of Module '" << getName() << "' were not specified: " << allMissing <<
174 "\nPlease add them to your steering file.");
175 return !missing.empty();
176}
std::vector< std::string > getUnsetForcedParams() const
Returns list of unset parameters (if they are required to have a value.

◆ if_false()

void if_false ( const std::shared_ptr< Path > &  path,
EAfterConditionPath  afterConditionPath = EAfterConditionPath::c_End 
)
inherited

A simplified version to add a condition to the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

It is equivalent to the if_value() method, using the expression "<1". This method is meant to be used together with the setReturnValue(bool value) method.

Parameters
pathShared pointer to the Path which will be executed if the return value is false.
afterConditionPathWhat to do after executing 'path'.

Definition at line 85 of file Module.cc.

86{
87 if_value("<1", path, afterConditionPath);
88}

◆ if_true()

void if_true ( const std::shared_ptr< Path > &  path,
EAfterConditionPath  afterConditionPath = EAfterConditionPath::c_End 
)
inherited

A simplified version to set the condition of the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

It is equivalent to the if_value() method, using the expression ">=1". This method is meant to be used together with the setReturnValue(bool value) method.

Parameters
pathShared pointer to the Path which will be executed if the return value is true.
afterConditionPathWhat to do after executing 'path'.

Definition at line 90 of file Module.cc.

91{
92 if_value(">=1", path, afterConditionPath);
93}

◆ if_value()

void if_value ( const std::string &  expression,
const std::shared_ptr< Path > &  path,
EAfterConditionPath  afterConditionPath = EAfterConditionPath::c_End 
)
inherited

Add a condition to the module.

Please note that successive calls of this function will add more than one condition to the module. If more than one condition results in true, only the last of them will be used.

See https://xwiki.desy.de/xwiki/rest/p/a94f2 or ModuleCondition for a description of the syntax.

Please be careful: Avoid creating cyclic paths, e.g. by linking a condition to a path which is processed before the path where this module is located in.

Parameters
expressionThe expression of the condition.
pathShared pointer to the Path which will be executed if the condition is evaluated to true.
afterConditionPathWhat to do after executing 'path'.

Definition at line 79 of file Module.cc.

80{
81 m_conditions.emplace_back(expression, path, afterConditionPath);
82}

◆ initialize()

void initialize ( void  )
overridevirtual

Initialize the module and check module parameters.

Reimplemented from Module.

Definition at line 123 of file CDCTrigger2DFinderModule.cc.

124{
127 m_clusters.registerInDataStore(m_clusterCollectionName);
128
131
132 if (m_storePlane > 0) m_houghPlane.registerInDataStore("HoughPlane");
133
135 int layerId = 3;
136 int nTS = 0;
137 for (int iSL = 0; iSL < 9; ++iSL) {
138 TSoffset[iSL] = nTS;
139 nTS += cdc.nWiresInLayer(layerId);
140 TSoffset[iSL + 1] = nTS;
141 if (!m_usehitpattern) {
142 for (int priority = 0; priority < 2; ++ priority) {
143 radius[iSL][priority] = cdc.senseWireR(layerId + priority);
144 }
145 } else {
146 for (int priority = 0; priority < 5; ++ priority) {
147 if (iSL == 0) radius[iSL][priority] = cdc.senseWireR(layerId + priority);
148 else radius[iSL][priority] = cdc.senseWireR(layerId + priority - 2);
149 }
150 }
151 layerId += (iSL > 0 ? 6 : 7);
152 }
153
154 if (m_testFilename != "") {
156 }
157
158 if (m_suppressClone) {
159 B2INFO("2D finder will exit with the first track candidate in time.");
160 }
161}
The Class for CDC Geometry Parameters.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140

◆ inList()

bool inList ( const CDCTriggerHoughCand a,
const std::vector< CDCTriggerHoughCand > &  list 
) const

Check if candidate is in list.

Definition at line 334 of file CDCTriggerHoughtrafo.cc.

336{
337 for (unsigned i = 0; i < list.size(); ++i) {
338 if (a == list[i]) return true;
339 }
340 return false;
341}

◆ mergeIdList()

void mergeIdList ( std::vector< unsigned > &  merged,
std::vector< unsigned > &  a,
std::vector< unsigned > &  b 
)

Merge lists a and b and put the result in merged.

Definition at line 382 of file CDCTriggerHoughtrafo.cc.

385{
386 bool found;
387
388 for (auto it = a.begin(); it != a.end(); ++it) {
389 found = false;
390 for (auto it_in = merged.begin(); it_in != merged.end(); ++it_in) {
391 if (*it_in == *it) {
392 found = true;
393 break;
394 }
395 }
396 if (!found) {
397 merged.push_back(*it);
398 }
399 }
400
401 for (auto it = b.begin(); it != b.end(); ++it) {
402 found = false;
403 for (auto it_in = merged.begin(); it_in != merged.end(); ++it_in) {
404 if (*it_in == *it) {
405 found = true;
406 break;
407 }
408 }
409 if (!found) {
410 merged.push_back(*it);
411 }
412 }
413}

◆ patternClustering()

void patternClustering ( const cdcMap inputMap)

Combine Hough candidates to tracks by a fixed pattern algorithm.

The Hough plane is first divided in 2 x 2 squares, then squares are combined.

Definition at line 488 of file CDCTriggerHoughtrafo.cc.

489{
490 // fill a matrix of 2 x 2 squares
491 TMatrix plane2(m_nCellsPhi / 2, m_nCellsR / 2);
492 TMatrix planeIcand(m_nCellsPhi, m_nCellsR);
493 for (unsigned icand = 0; icand < houghCand.size(); ++icand) {
494 double x = (houghCand[icand].getCoord().first.X() +
495 houghCand[icand].getCoord().second.X()) / 2.;
496 unsigned ix = floor((x + M_PI) / 2. / M_PI * m_nCellsPhi);
497 double y = (houghCand[icand].getCoord().first.Y() +
498 houghCand[icand].getCoord().second.Y()) / 2.;
499 unsigned iy = floor((y + maxR - shiftR) / 2. / maxR * m_nCellsR);
500 plane2[ix / 2][iy / 2] += 1 << ((ix % 2) + 2 * (iy % 2));
501 planeIcand[ix][iy] = icand;
502 B2DEBUG(100, "candidate " << icand << " at ix " << ix << " iy " << iy);
503 }
504 // look for clusters of 2 x 2 squares in a (rX x rY) region
505 unsigned nX = m_nCellsPhi / 2;
506 unsigned nY = m_nCellsR / 2;
507 unsigned rX = m_clusterSizeX;
508 unsigned rY = m_clusterSizeY;
509 for (unsigned ix = 0; ix < nX; ++ix) {
510 for (unsigned iy = 0; iy < nY; ++iy) {
511 if (!plane2[ix][iy]) continue;
512 // check if we are in a lower left corner
513 unsigned ileft = (ix - 1 + nX) % nX;
514 B2DEBUG(100, "ix " << ix << " iy " << iy);
515 if (connectedLR(plane2[ileft][iy], plane2[ix][iy]) ||
516 (iy > 0 && connectedUD(plane2[ix][iy - 1], plane2[ix][iy])) ||
517 (iy > 0 && connectedDiag(plane2[ileft][iy - 1], plane2[ix][iy]))) {
518 B2DEBUG(100, "skip connected square");
519 continue;
520 }
521 // form cluster
522 vector<unsigned> pattern(rX * rY, 0);
523 pattern[0] = plane2[ix][iy];
524 vector<ROOT::Math::XYVector> cellIds = {ROOT::Math::XYVector(2 * ix, 2 * iy)};
525 for (unsigned ix2 = 0; ix2 < rX; ++ix2) {
526 for (unsigned iy2 = 0; iy2 < rY; ++iy2) {
527 if (iy + iy2 >= nY) continue;
528 unsigned ip = ix2 + rX * iy2;
529 unsigned iright = (ix + ix2 + nX) % nX;
530 ileft = (iright - 1 + nX) % nX;
531 B2DEBUG(100, "ix2 " << ix2 << " ileft " << ileft << " iright " << iright);
532 if ((ix2 > 0 && // check left/right connection
533 pattern[ip - 1] &&
534 connectedLR(plane2[ileft][iy + iy2], plane2[iright][iy + iy2])) ||
535 (iy2 > 0 && // check up/down connection
536 pattern[ip - rX] &&
537 connectedUD(plane2[iright][iy + iy2 - 1], plane2[iright][iy + iy2])) ||
538 (ix2 > 0 && iy2 > 0 && // check diagonal connection
539 pattern[ip - rX - 1] &&
540 connectedDiag(plane2[ileft][iy + iy2 - 1], plane2[iright][iy + iy2]))) {
541 pattern[ip] = plane2[iright][iy + iy2];
542 B2DEBUG(100, "connect cell " << iright << " " << iy + iy2);
543 cellIds.push_back(ROOT::Math::XYVector(2 * (ix + ix2), 2 * (iy + iy2)));
544 }
545 }
546 }
547 B2DEBUG(100, "cluster starting at " << ix << " " << iy);
548 // check if cluster continues beyond defined area
549 bool overflowRight = false;
550 bool overflowTop = false;
551 for (unsigned iy2 = 0; iy2 < rY; ++iy2) {
552 unsigned ip = rX - 1 + rX * iy2;
553 if (!pattern[ip]) continue;
554 unsigned iright = (ix + rX + nX) % nX;
555 ileft = (iright - 1 + nX) % nX;
556 if (connectedLR(plane2[ileft][iy + iy2], plane2[iright][iy + iy2]) ||
557 ((iy + iy2 + 1 < nY) &&
558 connectedDiag(plane2[ileft][iy + iy2], plane2[iright][iy + iy2 + 1]))) {
559 setReturnValue(false);
560 overflowRight = true;
561 }
562 }
563 if (iy + rY < nY) {
564 for (unsigned ix2 = 0; ix2 < rX; ++ix2) {
565 unsigned ip = ix2 + rX * (rY - 1);
566 if (!pattern[ip]) continue;
567 unsigned iright = (ix + ix2 + 1 + nX) % nX;
568 ileft = (iright - 1 + nX) % nX;
569 if (connectedUD(plane2[ileft][iy + rY - 1], plane2[ileft][iy + rY]) ||
570 connectedDiag(plane2[ileft][iy + rY - 1], plane2[iright][iy + rY])) {
571 setReturnValue(false);
572 overflowTop = true;
573 }
574 }
575 }
576 if (overflowRight && !overflowTop) {
577 B2DEBUG(100, "cluster extends right of " << rX << " x " << rY << " area");
578 } else if (overflowTop && !overflowRight) {
579 B2DEBUG(100, "cluster extends above " << rX << " x " << rY << " area");
580 } else if (overflowRight && overflowTop) {
581 B2DEBUG(100, "cluster extends right and above " << rX << " x " << rY << " area");
582 }
583 // find corners of cluster
584 unsigned topRight2 = topRightSquare(pattern);
585 unsigned topRight = topRightCorner(pattern[topRight2]);
586 unsigned bottomLeft = bottomLeftCorner(pattern[0]);
587 B2DEBUG(100, "topRight2 " << topRight2 << " topRight " << topRight << " bottomLeft " << bottomLeft);
588 // average over corners to find cluster center
589 unsigned ixTR = 2 * (topRight2 % m_clusterSizeX) + (topRight % 2);
590 unsigned ixBL = bottomLeft % 2;
591 unsigned iyTR = 2 * (topRight2 / m_clusterSizeX) + (topRight / 2);
592 unsigned iyBL = bottomLeft / 2;
593 B2DEBUG(100, "ixTR " << ixTR << " ixBL " << ixBL << " iyTR " << iyTR << " iyBL " << iyBL);
594 // skip size 1 clusters
595 if (m_minCells > 1 && ixTR == ixBL && iyTR == iyBL) {
596 B2DEBUG(100, "skipping cluster of size 1");
597 continue;
598 }
599 float centerX = 2 * ix + (ixTR + ixBL) / 2.;
600 if (centerX >= m_nCellsPhi) centerX -= m_nCellsPhi;
601 float centerY = 2 * iy + (iyTR + iyBL) / 2.;
602 B2DEBUG(100, "center at cell (" << centerX << ", " << centerY << ")");
603 // convert to coordinates
604 double x = -M_PI + (centerX + 0.5) * 2. * M_PI / m_nCellsPhi;
605 double y = -maxR + shiftR + (centerY + 0.5) * 2. * maxR / m_nCellsR;
606 B2DEBUG(100, "center coordinates (" << x << ", " << y << ")");
607 // get list of related hits
608 vector <unsigned> idList = {};
610 unsigned icandTR = planeIcand[(ixTR + 2 * ix) % m_nCellsPhi][iyTR + 2 * iy];
611 unsigned icandBL = planeIcand[ixBL + 2 * ix][iyBL + 2 * iy];
612 vector<unsigned> candIdListTR = houghCand[icandTR].getIdList();
613 vector<unsigned> candIdListBL = houghCand[icandBL].getIdList();
614 mergeIdList(idList, candIdListTR, candIdListBL);
615 B2DEBUG(100, "merge id lists from candidates " << icandTR << " and " << icandBL);
616 } else {
617 double dx = M_PI / m_nCellsPhi;
618 double dy = maxR / m_nCellsR;
619 double x1 = (round(centerX) == centerX) ? x - dx : x - 2 * dx;
620 double x2 = (round(centerX) == centerX) ? x + dx : x + 2 * dx;
621 double y1 = (round(centerY) == centerY) ? y - dy : y - 2 * dy;
622 double y2 = (round(centerY) == centerY) ? y + dy : y + 2 * dy;
623 findAllCrossingHits(idList, x1, x2, y1, y2, inputMap);
624 }
625 if (idList.size() == 0) {
626 setReturnValue(false);
627 B2DEBUG(100, "id list empty");
628 }
629
630 // select 1 hit per super layer
631 vector<unsigned> selectedList = {};
632 vector<unsigned> unselectedList = {};
633 selectHits(idList, selectedList, unselectedList);
634
635 // save track
636 const CDCTriggerTrack* track =
637 m_tracks.appendNew(x, 2. * y, 0.);
638 // relations to selected hits
639 for (unsigned i = 0; i < selectedList.size(); ++i) {
640 unsigned its = selectedList[i];
641 track->addRelationTo(m_segmentHits[its]);
642 }
643 // relations to additional hits get a negative weight
644 for (unsigned i = 0; i < unselectedList.size(); ++i) {
645 unsigned its = unselectedList[i];
646 track->addRelationTo(m_segmentHits[its], -1.);
647 }
648 // save detail information about the cluster
649 const CDCTriggerHoughCluster* cluster =
650 m_clusters.appendNew(2 * ix, 2 * (ix + m_clusterSizeX) - 1,
651 2 * iy, 2 * (iy + m_clusterSizeY) - 1,
652 cellIds);
653 track->addRelationTo(cluster);
654 }
655 }
656}
bool connectedLR(unsigned patternL, unsigned patternR)
Check for left/right connection of patterns in 2 x 2 squares.
unsigned topRightCorner(unsigned pattern)
Find the top right corner within 2 x 2 square.
bool connectedUD(unsigned patternD, unsigned patternU)
Check for up/down connection of patterns in 2 x 2 squares.
void findAllCrossingHits(std::vector< unsigned > &list, double x1, double x2, double y1, double y2, const cdcMap &inputMap)
Find all hits in inputMap whose Hough curve crosses the rectangle with corners (x1,...
unsigned bottomLeftCorner(unsigned pattern)
Find the bottom left corner within 2 x 2 square.
bool connectedDiag(unsigned patternLD, unsigned patternRU)
Check for diagonal connected of patterns in 2 x 2 squares.
unsigned topRightSquare(std::vector< unsigned > &pattern)
Find the top right square within a cluster of 2 x 2 squares In case of ambiguity, top is favored over...

◆ selectHits()

void selectHits ( std::vector< unsigned > &  list,
std::vector< unsigned > &  selected,
std::vector< unsigned > &  unselected 
)

Select one hit per super layer.

Parameters
listinput list of hit Ids
selectedselected hit Ids are added to selected
unselectedthe rest of the hit Ids are added to unselected

Definition at line 454 of file CDCTriggerHoughtrafo.cc.

457{
458 std::vector<int> bestPerSL(5, -1);
459 for (unsigned i = 0; i < list.size(); ++i) {
460 unsigned iax = m_segmentHits[list[i]]->getISuperLayer() / 2;
461 bool firstPriority = (m_segmentHits[list[i]]->getPriorityPosition() == 3);
462 if (bestPerSL[iax] < 0) {
463 bestPerSL[iax] = i;
464 } else {
465 unsigned itsBest = list[bestPerSL[iax]];
466 bool firstBest = (m_segmentHits[itsBest]->getPriorityPosition() == 3);
467 // selection rules:
468 // first priority, higher ID
469 if ((firstPriority && !firstBest) ||
470 (firstPriority == firstBest &&
471 m_segmentHits[list[i]]->getSegmentID() > m_segmentHits[itsBest]->getSegmentID())) {
472 bestPerSL[iax] = i;
473 }
474 }
475 }
476
477 for (unsigned i = 0; i < list.size(); ++i) {
478 unsigned iax = m_segmentHits[list[i]]->getISuperLayer() / 2;
479 if (int(i) == bestPerSL[iax]) selected.push_back(list[i]);
480 else unselected.push_back(list[i]);
481 }
482}

◆ setAbortLevel()

void setAbortLevel ( int  abortLevel)
inherited

Configure the abort log level.

Definition at line 67 of file Module.cc.

68{
69 m_logConfig.setAbortLevel(static_cast<LogConfig::ELogLevel>(abortLevel));
70}
ELogLevel
Definition of the supported log levels.
Definition: LogConfig.h:26
void setAbortLevel(ELogLevel abortLevel)
Configure the abort level.
Definition: LogConfig.h:112

◆ setDebugLevel()

void setDebugLevel ( int  debugLevel)
inherited

Configure the debug messaging level.

Definition at line 61 of file Module.cc.

62{
63 m_logConfig.setDebugLevel(debugLevel);
64}
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: LogConfig.h:98

◆ setDescription()

void setDescription ( const std::string &  description)
protectedinherited

Sets the description of the module.

Parameters
descriptionA description of the module.

Definition at line 214 of file Module.cc.

215{
216 m_description = description;
217}

◆ setLogConfig()

void setLogConfig ( const LogConfig logConfig)
inlineinherited

Set the log system configuration.

Definition at line 230 of file Module.h.

230{m_logConfig = logConfig;}

◆ setLogInfo()

void setLogInfo ( int  logLevel,
unsigned int  logInfo 
)
inherited

Configure the printed log information for the given level.

Parameters
logLevelThe log level (one of LogConfig::ELogLevel)
logInfoWhat kind of info should be printed? ORed combination of LogConfig::ELogInfo flags.

Definition at line 73 of file Module.cc.

74{
75 m_logConfig.setLogInfo(static_cast<LogConfig::ELogLevel>(logLevel), logInfo);
76}
void setLogInfo(ELogLevel logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition: LogConfig.h:127

◆ setLogLevel()

void setLogLevel ( int  logLevel)
inherited

Configure the log level.

Definition at line 55 of file Module.cc.

56{
57 m_logConfig.setLogLevel(static_cast<LogConfig::ELogLevel>(logLevel));
58}
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:25

◆ setName()

void setName ( const std::string &  name)
inlineinherited

Set the name of the module.

Note
The module name is set when using the REG_MODULE macro, but the module can be renamed before calling process() using the set_name() function in your steering file.
Parameters
nameThe name of the module

Definition at line 214 of file Module.h.

214{ m_name = name; };

◆ setParamList()

void setParamList ( const ModuleParamList params)
inlineprotectedinherited

Replace existing parameter list.

Definition at line 501 of file Module.h.

501{ m_moduleParamList = params; }

◆ setParamPython()

void setParamPython ( const std::string &  name,
const boost::python::object &  pyObj 
)
privateinherited

Implements a method for setting boost::python objects.

The method supports the following types: list, dict, int, double, string, bool The conversion of the python object to the C++ type and the final storage of the parameter value is done in the ModuleParam class.

Parameters
nameThe unique name of the parameter.
pyObjThe object which should be converted and stored as the parameter value.

Definition at line 234 of file Module.cc.

235{
236 LogSystem& logSystem = LogSystem::Instance();
237 logSystem.updateModule(&(getLogConfig()), getName());
238 try {
240 } catch (std::runtime_error& e) {
241 throw std::runtime_error("Cannot set parameter '" + name + "' for module '"
242 + m_name + "': " + e.what());
243 }
244
245 logSystem.updateModule(nullptr);
246}
Class for logging debug, info and error messages.
Definition: LogSystem.h:46
void updateModule(const LogConfig *moduleLogConfig=nullptr, const std::string &moduleName="")
Sets the log configuration to the given module log configuration and sets the module name This method...
Definition: LogSystem.h:191
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
void setParamPython(const std::string &name, const PythonObject &pyObj)
Implements a method for setting boost::python objects.

◆ setParamPythonDict()

void setParamPythonDict ( const boost::python::dict &  dictionary)
privateinherited

Implements a method for reading the parameter values from a boost::python dictionary.

The key of the dictionary has to be the name of the parameter and the value has to be of one of the supported parameter types.

Parameters
dictionaryThe python dictionary from which the parameter values are read.

Definition at line 249 of file Module.cc.

250{
251
252 LogSystem& logSystem = LogSystem::Instance();
253 logSystem.updateModule(&(getLogConfig()), getName());
254
255 boost::python::list dictKeys = dictionary.keys();
256 int nKey = boost::python::len(dictKeys);
257
258 //Loop over all keys in the dictionary
259 for (int iKey = 0; iKey < nKey; ++iKey) {
260 boost::python::object currKey = dictKeys[iKey];
261 boost::python::extract<std::string> keyProxy(currKey);
262
263 if (keyProxy.check()) {
264 const boost::python::object& currValue = dictionary[currKey];
265 setParamPython(keyProxy, currValue);
266 } else {
267 B2ERROR("Setting the module parameters from a python dictionary: invalid key in dictionary!");
268 }
269 }
270
271 logSystem.updateModule(nullptr);
272}
void setParamPython(const std::string &name, const boost::python::object &pyObj)
Implements a method for setting boost::python objects.
Definition: Module.cc:234

◆ setPropertyFlags()

void setPropertyFlags ( unsigned int  propertyFlags)
inherited

Sets the flags for the module properties.

Parameters
propertyFlagsbitwise OR of EModulePropFlags

Definition at line 208 of file Module.cc.

209{
210 m_propertyFlags = propertyFlags;
211}

◆ setReturnValue() [1/2]

void setReturnValue ( bool  value)
protectedinherited

Sets the return value for this module as bool.

The bool value is saved as an integer with the convention 1 meaning true and 0 meaning false. The value can be used in the steering file to divide the analysis chain into several paths.

Parameters
valueThe value of the return value.

Definition at line 227 of file Module.cc.

228{
229 m_hasReturnValue = true;
230 m_returnValue = value;
231}

◆ setReturnValue() [2/2]

void setReturnValue ( int  value)
protectedinherited

Sets the return value for this module as integer.

The value can be used in the steering file to divide the analysis chain into several paths.

Parameters
valueThe value of the return value.

Definition at line 220 of file Module.cc.

221{
222 m_hasReturnValue = true;
223 m_returnValue = value;
224}

◆ setType()

void setType ( const std::string &  type)
protectedinherited

Set the module type.

Only for use by internal modules (which don't use the normal REG_MODULE mechanism).

Definition at line 48 of file Module.cc.

49{
50 if (!m_type.empty())
51 B2FATAL("Trying to change module type from " << m_type << " is not allowed, the value is assumed to be fixed.");
52 m_type = type;
53}

◆ shortTrack()

bool shortTrack ( bool *  superLayers)

check the short track condition (= hits in the inner super layers rather than any super layers)

Parameters
superLayersarray of hit/no hit for all super layers

Definition at line 35 of file CDCTriggerHoughtrafo.cc.

36{
37 unsigned short lcnt = 0;
38 // check axial super layers (even layer number),
39 // break at first layer without hit
40 for (int i = 0; i < CDC_SUPER_LAYERS; i += 2) {
41 if (layer[i] == true) ++lcnt;
42 else break;
43 }
44 return (lcnt >= m_minHitsShort);
45}

◆ terminate()

void terminate ( void  )
overridevirtual

Clean up.

Reimplemented from Module.

Definition at line 390 of file CDCTrigger2DFinderModule.cc.

391{
392 if (m_testFilename != "") testFile.close();
393}

◆ topRightCorner()

unsigned topRightCorner ( unsigned  pattern)

Find the top right corner within 2 x 2 square.

In case of ambiguity right corner is returned. x . . x -> return this one @ return index of corner within pattern

Definition at line 762 of file CDCTriggerHoughtrafo.cc.

763{
764 // scan pattern from right to left:
765 // 2 3
766 // 0 1
767 if ((pattern >> 3) & 1) return 3;
768 if ((pattern >> 1) & 1) {
769 if ((pattern >> 2) & 1) {
770 setReturnValue(false);
771 B2DEBUG(100, "topRightCorner not unique");
772 }
773 return 1;
774 }
775 if ((pattern >> 2) & 1) return 2;
776 return 0;
777}

◆ topRightSquare()

unsigned topRightSquare ( std::vector< unsigned > &  pattern)

Find the top right square within a cluster of 2 x 2 squares In case of ambiguity, top is favored over right @ return index of corner within pattern vector.

Definition at line 732 of file CDCTriggerHoughtrafo.cc.

733{
734 // scan from top right corner until an active square is found
735 for (unsigned index = pattern.size() - 1; index > 0; --index) {
736 if (!pattern[index]) continue;
737 // check for ambiguity
738 unsigned ix = index % m_clusterSizeX;
739 unsigned iy = index / m_clusterSizeX;
740 if (ix < m_clusterSizeX - 1 && iy > 0) {
741 bool unique = true;
742 for (unsigned index2 = index - 1; index2 > 0; --index2) {
743 if (!pattern[index2]) continue;
744 unsigned ix2 = index2 % m_clusterSizeX;
745 unsigned iy2 = index2 / m_clusterSizeX;
746 if (iy2 < iy && ix2 > ix) {
747 unique = false;
748 break;
749 }
750 }
751 if (!unique) {
752 setReturnValue(false);
753 B2DEBUG(100, "topRightSquare not unique");
754 }
755 }
756 return index;
757 }
758 return 0;
759}

Member Data Documentation

◆ hitMap

cdcMap hitMap
protected

map of TS hits containing <iHit, <iSL, (x, y)>> with iHit: hit index in StoreArray iSL: super layer index

(x, y): coordinates in conformal space

Definition at line 265 of file CDCTrigger2DFinderModule.h.

◆ houghCand

std::vector<CDCTriggerHoughCand> houghCand
protected

Hough Candidates.

Definition at line 267 of file CDCTrigger2DFinderModule.h.

◆ m_clusterCollectionName

std::string m_clusterCollectionName
protected

Name of the StoreArray containing the clusters formed in the Hough plane.

Definition at line 186 of file CDCTrigger2DFinderModule.h.

◆ m_clusterPattern

bool m_clusterPattern
protected

switch for clustering algorithm (if true use nested patterns)

Definition at line 242 of file CDCTrigger2DFinderModule.h.

◆ m_clusters

StoreArray<CDCTriggerHoughCluster> m_clusters
protected

list of clusters in the Hough map

Definition at line 279 of file CDCTrigger2DFinderModule.h.

◆ m_clusterSizeX

unsigned m_clusterSizeX
protected

maximum cluster size for pattern algorithm

Definition at line 244 of file CDCTrigger2DFinderModule.h.

◆ m_clusterSizeY

unsigned m_clusterSizeY
protected

maximum cluster size for pattern algorithm

Definition at line 246 of file CDCTrigger2DFinderModule.h.

◆ m_conditions

std::vector<ModuleCondition> m_conditions
privateinherited

Module condition, only non-null if set.

Definition at line 521 of file Module.h.

◆ m_connect

unsigned m_connect
protected

number of neighbors to check for connection (4: direct, 6: direct + upper right and lower left corner, 8: direct + all corners)

Definition at line 221 of file CDCTrigger2DFinderModule.h.

◆ m_description

std::string m_description
privateinherited

The description of the module.

Definition at line 511 of file Module.h.

◆ m_hasReturnValue

bool m_hasReturnValue
privateinherited

True, if the return value is set.

Definition at line 518 of file Module.h.

◆ m_hitCollectionName

std::string m_hitCollectionName
protected

Name of the StoreArray containing the input track segment hits.

Definition at line 182 of file CDCTrigger2DFinderModule.h.

◆ m_hitRelationsFromCorners

bool m_hitRelationsFromCorners
protected

switch for creating relations to hits in the pattern clustering algorithm.

true: create relations for all hits passing through the corners of a cluster, false: create relations for all hits passing though the estimated center of the cluster (can be 0 hits if center is not part of the cluster)

Definition at line 253 of file CDCTrigger2DFinderModule.h.

◆ m_houghPlane

StoreObjPtr<TMatrix> m_houghPlane
protected

matrix containing the Hough plane

Definition at line 281 of file CDCTrigger2DFinderModule.h.

◆ m_ignore2nd

bool m_ignore2nd
protected

switch to skip second priority hits

Definition at line 223 of file CDCTrigger2DFinderModule.h.

◆ m_logConfig

LogConfig m_logConfig
privateinherited

The log system configuration of the module.

Definition at line 514 of file Module.h.

◆ m_minCells

unsigned m_minCells
protected

minimum number of cells in a cluster to form a track

Definition at line 215 of file CDCTrigger2DFinderModule.h.

◆ m_minHits

unsigned m_minHits
protected

minimum number of hits from different super layers in a Hough cell to form a candidate

Definition at line 210 of file CDCTrigger2DFinderModule.h.

◆ m_minHitsShort

unsigned m_minHitsShort
protected

short tracks require hits in the first minHitsShort super layers to form a candidate

Definition at line 213 of file CDCTrigger2DFinderModule.h.

◆ m_minPt

double m_minPt
protected

Hough plane limit in Pt [GeV].

Definition at line 192 of file CDCTrigger2DFinderModule.h.

◆ m_moduleParamList

ModuleParamList m_moduleParamList
privateinherited

List storing and managing all parameter of the module.

Definition at line 516 of file Module.h.

◆ m_name

std::string m_name
privateinherited

The name of the module, saved as a string (user-modifiable)

Definition at line 508 of file Module.h.

◆ m_nCellsPhi

unsigned m_nCellsPhi
protected

number of Hough cells in phi

Definition at line 188 of file CDCTrigger2DFinderModule.h.

◆ m_nCellsR

unsigned m_nCellsR
protected

number of Hough cells in 1/r

Definition at line 190 of file CDCTrigger2DFinderModule.h.

◆ m_onlyLocalMax

bool m_onlyLocalMax
protected

switch to ignore candidates connected to cells with higher super layer count

Definition at line 217 of file CDCTrigger2DFinderModule.h.

◆ m_outputCollectionName

std::string m_outputCollectionName
protected

Name of the StoreArray containing the tracks found by the Hough tracking.

Definition at line 184 of file CDCTrigger2DFinderModule.h.

◆ m_package

std::string m_package
privateinherited

Package this module is found in (may be empty).

Definition at line 510 of file Module.h.

◆ m_propertyFlags

unsigned int m_propertyFlags
privateinherited

The properties of the module as bitwise or (with |) of EModulePropFlags.

Definition at line 512 of file Module.h.

◆ m_requireSL0

bool m_requireSL0
protected

switch to check separately for a hit in the innermost super layer

Definition at line 227 of file CDCTrigger2DFinderModule.h.

◆ m_returnValue

int m_returnValue
privateinherited

The return value.

Definition at line 519 of file Module.h.

◆ m_segmentHits

StoreArray<CDCTriggerSegmentHit> m_segmentHits
protected

list of track segment hits

Definition at line 275 of file CDCTrigger2DFinderModule.h.

◆ m_shiftPt

int m_shiftPt
protected

shift the Hough plane in 1/r to avoid curvature 0 tracks < 0: shift in negative direction (negative half is larger) 0: no shift (same limits for negative and positive half)

‍0: shift in positive direction (positive half is larger)

Definition at line 197 of file CDCTrigger2DFinderModule.h.

◆ m_storePlane

unsigned m_storePlane
protected

switch to save the Hough plane in DataStore (0: don't save, 1: save only peaks, 2: save full plane)

Definition at line 240 of file CDCTrigger2DFinderModule.h.

◆ m_suppressClone

bool m_suppressClone
protected

switch to send only the first found track and suppress the subsequent clones

Definition at line 230 of file CDCTrigger2DFinderModule.h.

◆ m_testFilename

std::string m_testFilename
protected

filename for test output for firmware debugging

Definition at line 256 of file CDCTrigger2DFinderModule.h.

◆ m_tracks

StoreArray<CDCTriggerTrack> m_tracks
protected

list of found tracks

Definition at line 277 of file CDCTrigger2DFinderModule.h.

◆ m_type

std::string m_type
privateinherited

The type of the module, saved as a string.

Definition at line 509 of file Module.h.

◆ m_useadc

bool m_useadc
protected

switch to use hit pattern inside TSF with ADC cut

Definition at line 236 of file CDCTrigger2DFinderModule.h.

◆ m_usehitpattern

bool m_usehitpattern
protected

switch to use hit pattern inside TSF

Definition at line 233 of file CDCTrigger2DFinderModule.h.

◆ m_usePriority

bool m_usePriority
protected

switch between priority position and center position of track segment

Definition at line 225 of file CDCTrigger2DFinderModule.h.

◆ maxIterations

unsigned maxIterations = 0
protected

number of iterations for the fast peak finder, smallest n such that 2^(n+1) > max(nCellsPhi, nCellsR).

Initialized at 0 by the SW shifter

Definition at line 204 of file CDCTrigger2DFinderModule.h.

◆ maxR

double maxR = 0.
protected

Hough plane limit in 1/r [1/cm].

Initialized at 0 by the SW shifter

Definition at line 199 of file CDCTrigger2DFinderModule.h.

◆ nCells

unsigned nCells = 0
protected

number of cells for the fast peak finder: 2^(maxIterations + 1).

Initialized at 0 by the SW shifter

Definition at line 206 of file CDCTrigger2DFinderModule.h.

◆ radius

double radius[9][5] = {{0.}}
protected

Radius of the CDC layers with priority wires (2 per super layer).

Initialized at 0 by the SW shifter

Definition at line 270 of file CDCTrigger2DFinderModule.h.

◆ shiftR

double shiftR = 0.
protected

Hough plane shift in 1/r [1/cm].

Initialized at 0 by the SW shifter

Definition at line 201 of file CDCTrigger2DFinderModule.h.

◆ testFile

std::ofstream testFile
protected

filestream for test output for firmware debugging

Definition at line 258 of file CDCTrigger2DFinderModule.h.

◆ TSoffset

unsigned TSoffset[10] = {0}
protected

Number of track segments up to super layer.

Initialized at 0 by the SW shifter

Definition at line 272 of file CDCTrigger2DFinderModule.h.


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