142 : fNumPlanes(fNumLayers),fNumWires(fNumLayers)
194 double detectorwidth,
199 int ia, ie, hashint =
hashgen();
200 unsigned oldwidth = binwidth;
201 char *oldpattern = pattern;
205 ia = (int) floor (pos_start / detectorwidth * binwidth);
209 ie = (int) floor (pos_end / detectorwidth * binwidth);
215 for (
int j = ia; j <= ie; j++) {
221 pattern = oldpattern;
227 if (i >= (
signed int) binwidth)
232 hash[i] = ((hash[i]<<1) + hashint)|1 ;
281 double detectorwidth,
286 _setpoints (position - resolution, position + resolution,
287 detectorwidth, binwidth, pattern, hash);
354 _setpoint (off + h1, res1, width, binwidth, pa, hasha);
355 _setpoint (off + h2, res2, width, binwidth, pb, hashb);
360 _setpoint (off + 0.5 * (h1+h2), 0.5 * (res1+res2), width, binwidth, pa, hasha);
415 double detectorwidth,
429 detectorwidth, binwidth, pattern, hash);
434 detectorwidth, binwidth, pattern, hash);
461 for (
unsigned int row = 0; row <
fNumPlanes; row++)
478 if(wire_diff<5 && offset!=-1){
479 if (tl->
a_beg == front && front == tl->
a_end )
502 for (
unsigned int row = 0; row <
fNumLayers; ++row) {
506 if (newa[row] && olda[row] != newa[row]) {
514 if (! diff && offset!=-1) {
515 if ((newmiss == 0 && oldmiss == 0) ||
516 (!newa[0] && !olda[0]) ||
517 (!newa[fNumPlanes-1] && !olda[fNumPlanes-1]) ||
518 (newmiss && !oldmiss && (!newa[0] || !newa[fNumPlanes-1])) ||
519 (oldmiss && !newmiss && (!olda[0] || !olda[fNumPlanes-1]))
521 if (tl->
a_beg > front)
523 if (tl->
a_end < front)
525 if (tl->
b_beg > back)
527 if (tl->
b_end < back)
572 bool search_debug_level=0;
573 if(search_debug_level)
574 std::cout <<
"entering _SearchTreeLines with level" << level <<
" and row_offset " << row_offset << std::endl;
575 int nextlevel = level + 1;
619 unsigned long pattern_start = (
unsigned long) 0xffffffffL;
620 pattern_start <<= level + 1;
621 pattern_start &= (
unsigned long) 0xffffffffL >> (32 -
fMaxLevel);
630 static int has_planes[4];
631 unsigned int missed_planes =0 ;
632 if(level == 0 && numwires==0){
633 for(
unsigned int plane=0;plane<
fNumPlanes;plane++){
647 unsigned int missed_rows = 0;
648 if (level == 0 && numwires>0 ) {
649 for (
unsigned int row = 0; row <
fNumPlanes; row++) {
686 unsigned long pattern_offset = pattern_start + offset;
687 int* tree_pattern = tree->
fBit;
689 unsigned int matched_wires = 0;
702 for (
unsigned int row = 0; row <
fNumWires; row++) {
703 int bin = (*tree_pattern++);
710 if ((
int) row < firstwire) firstwire = row;
711 if ((
int) row > lastwire) lastwire = row;
718 for (
unsigned int row = 0; row <
fNumWires; row++) {
719 int bin = (*tree_pattern++);
720 if(search_debug_level)
721 std::cout <<
"for level" << level <<
" bin:" << bin << std::endl;
723 patterns.at(row)=bin;
729 if ((
int) row < firstwire) firstwire = row;
730 if ((
int) row > lastwire && bin != 0) lastwire = row;
735 else if (bin == 0 && has_hits[row] == 0) {
745 int* tree_pattern_copy = tree->
fBit;
750 for(
unsigned int row=0;row<
fNumWires;row++){
751 int bin = (*tree_pattern_copy++);
754 if ((
int)row > firstwire && (
int)row <= lastwire){
757 else if (has_hits[row] == 0) matched_wires++;
758 else if(goofy<1) {matched_wires++;goofy++;}
764 if(search_debug_level){
765 std::cout <<
"matched_wires: " << matched_wires << std::endl;
766 std::cout <<
"missed rows: " << missed_rows << std::endl;
786 for (
unsigned int wire = 0; wire <
fNumWires; wire++) {
787 if (offset - tree->
fBit[wire] > backbin)
788 backbin = offset - tree->
fBit[wire];
793 for (
unsigned int wire = 0; wire <
fNumWires; wire++) {
794 if (offset + tree->
fBit[wire] > backbin)
795 backbin = offset + tree->
fBit[wire];
801 int frontbin = reverse ? offset - tree->
fBit[0]
802 : offset + tree->
fBit[0];
803 for (
unsigned int wire = 0; wire <
fNumWires; wire++) {
804 int bin = reverse ? offset - tree->
fBit[wire]
805 : offset + tree->
fBit[wire];
821 if (!
exists(hashpat, frontbin, backbin, row_offset)) {
833 memcpy(treeline->
fHashArray, hashpat,
sizeof(
int) * fNumWires);
846 if (search_debug_level) {
847 std::cout <<
"first wire: " << firstwire << std::endl;
848 std::cout <<
"last wire: " << lastwire << std::endl;
851 if (firstwire != lastwire) {
853 }
else delete treeline;
861 if(search_debug_level)
862 std::cout <<
"not the deepest level,begin recursive call!" << std::endl;
863 for (
int rev = 0; rev < 4; rev += 2) {
870 int off2 = (offset << 1) + 1;
871 for (
int off = 0; off < 2; off++)
872 _SearchTreeLines (*cnode++, nextlevel, off2 - off, row_offset, 2, numwires);
875 int off2 = (offset << 1);
876 for (
int off = 0; off < 2; off++)
877 _SearchTreeLines (*cnode++, nextlevel, off2 + off, row_offset, 0, numwires);
916 unsigned long pattern_offset = pattern_start + offset;
917 int* tree_pattern = tree->
fBit;
918 unsigned int matched_planes = 0;
922 for (
unsigned int plane = 0; plane <
fNumPlanes; ++plane) {
923 int bin=(*tree_pattern++);
930 for (
unsigned int plane = 0; plane <
fNumPlanes; ++plane) {
931 int bin=(*tree_pattern++);
932 patterns.at(plane)=pattern_offset + bin;
933 if (
static_pattern[plane][pattern_offset + bin] || has_planes[plane]==0) {
941 else if(goofy_r2==0 && missed_planes==0 && level==
fMaxLevel-1){
963 int frontbin = reverse ? offset - tree->
fBit[0]
964 : offset + tree->
fBit[0];
967 for (
unsigned int plane = 0; plane <
fNumPlanes; plane++) {
968 int bin = reverse ? offset - tree->
fBit[plane]
969 : offset + tree->
fBit[plane];
980 if (!
exists(hashpat, frontbin, backbin, -1)) {
992 memcpy(treeline->
fHashArray, hashpat,
sizeof(
int) * fNumPlanes);
1004 for (
int rev = 0; rev < 4; rev += 2) {
1006 if (rev ^ reverse) {
1007 int off2 = (offset << 1) + 1;
1008 for (
int off = 0; off < 2; off++){
1012 int off2 = offset << 1;
1013 for (
int off = 0; off < 2; off++) {
1088 std::vector<int> wiregroups;
1089 int last_wire_with_hit = -1;
1090 for (
int wire = 0; wire < numwires; wire++) {
1092 if (pattern[wire][(1UL << maxlevel) - 2] == 1) {
1094 for (
int wiregroup = std::max(wire - numlayers + 1, last_wire_with_hit);
1095 wiregroup <
std::min(numwires - numlayers + 1, wire); wiregroup++) {
1096 if (wiregroup < 0)
continue;
1097 wiregroups.push_back(wiregroup);
1100 last_wire_with_hit = wire;
1105 for (
size_t i = 0; i < wiregroups.size(); i++) {
unsigned int fPattern_fMaxRows
int * fBit
Hit pattern, one bin specified per detector layer.
unsigned int fMaxMissedPlanes
Maximum number of missed planes in region 2.
int exists(int *newa, int front, int back, int offset)
int fHashArray[2 *MAX_LAYERS]
///< all hits that satisfy road requirement
#define TREESEARCH_MAX_TREELINES
QwTrackingTreeSearch()
Constructor.
void SetMatchingPattern(std::vector< int > &box)
Set the matching pattern.
int fMaxLevel
Maximum level of this tree search.
int fR3Offset
offset of demultiplexed group of 8
int GetElement() const
Get the element number.
shortnode * GetNode()
Get the node to this tree region.
void Print(bool recursive=false, int indent=0)
Print some debugging information.
A container for the pattern databases for each detector region.
unsigned int & fNumPlanes
Number of region 2 HDC planes.
bool fShowMatchingPatterns
Flag to show matching patterns when found.
int fR3LastWire
first and last wire in group of 8
unsigned int & fNumWires
Number of region 3 VDC wires.
unsigned int fMaxMissedWires
Maximum number of missed wires in region 3.
T GetValue(const std::string &key)
Get a templated value.
int fMinLevel
Minimum level at which this node is valid.
void setpoint(double off, double h1, double res1, double h2, double res2, double width, unsigned binwidth, char *pa, char *pb, int *hasha, int *hashb)
#define QwDebug
Predefined log drain for debugging output.
A logfile class, based on an identical class in the Hermes analyzer.
std::vector< QwTreeLine * > fTreeLineList
shortnode * son[4]
Each tree has four son nodes.
Draft skeleton for the decoding-to-QTR interface class.
void _SearchTreeLines(shortnode *node, int level, int offset, int row_offset, int reverse, int numwires)
Recursive tree search algorithm.
void _setpoints(double pos_start, double pos_end, double detectorwidth, unsigned binwidth, char *pattern, int *hash)
Performs the treesearch algorithm to generate one treeline.
const Double_t & GetDriftDistance() const
int b_end
bin in last layer
shorttree * GetTree(int i=0) const
Get the tree.
Definition of a shortnode, the short version of a nodenode.
Definition of the one-dimensional track stubs.
bool IsVoid() const
Is this tree line void?
void _setpoint(double position, double resolution, double detectorwidth, unsigned binwidth, char *pattern, int *hash)
One-dimensional (u, v, or x) track stubs and associated hits.
int fNumMiss
number of planes without hits
std::vector< QwTreeLine * > GetListOfTreeLines()
Get the list of tree lines.
static std::ostream & endl(std::ostream &)
End of the line.
double GetElementSpacing() const
shortnode * GetNext() const
Get the next node.
const QwDetectorInfo * GetDetectorInfo() const
Get the detector info pointer.
An options class which parses command line, config file and environment.
QwTreeLine * SearchTreeLines(QwTrackingTreeRegion *searchtree, char *pattern[16], int *hashpat[16], int maxlevel, int numwires, int numlayers)
Search for the tree lines consistent with the hit pattern.
unsigned int fPattern_fMaxBins
Hit structure uniquely defining each hit.
int a_end
bin in first layer
unsigned int fNumLayers
Number of detector layers (general concept)
#define QwWarning
Predefined log drain for warnings.
virtual ~QwTrackingTreeSearch()
Destructor.
int TsSetPoint(double detectorwidth, double wirespacing, QwHit *hit, char *pattern, int *hash, unsigned binwidth)
Method to set the tree pattern.
double GetTrackResolution() const
#define QwError
Predefined log drain for errors.