ROOT logo
#ifndef ROOT_TreeSearch_PatternGenerator
#define ROOT_TreeSearch_PatternGenerator

///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// TreeSearch::PatternGenerator                                              //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

#include "Pattern.h"
#include "PatternTree.h"
#include <vector>

using std::vector;

namespace TreeSearch {

  class PatternGenerator {
    //    friend class Test_PatternGenerator;
  public:
    PatternGenerator();
    virtual ~PatternGenerator();

    PatternTree* Generate( TreeParam_t parameters );
    PatternTree* Generate( UInt_t maxdepth, Double_t detector_width, 
			   const char* zpos, Double_t maxslope );

    struct Statistics_t {
      UInt_t nPatterns, nLinks, nBytes, MaxChildListLength, nHashBytes;
      ULong64_t nAllPatterns;
      Double_t  BuildTime;
    };

    Pattern* GetRoot() const { return fHashTable[0].fPattern; }
    const Statistics_t& GetStatistics() const { return fStats; }

    void  Print( Option_t* opt="", std::ostream& os = std::cout ) const;

  private:

    class HashNode {
      friend class PatternGenerator;
    private:
      Pattern* fPattern;    // Bit pattern treenode
      UInt_t   fMinDepth;   // Minimum valid depth for this pattern (<=16)
      void     UsedAtDepth( UInt_t depth ) {
	if( depth < fMinDepth ) fMinDepth = depth;
      }
    public:
      HashNode( Pattern* pat = 0 ) : fPattern(pat), fMinDepth(kMaxUInt) {}
      Pattern* GetPattern() const { return fPattern; }
    };

    UInt_t         fNlevels;     // Number of levels of the tree (0-nlevels-1)
    UInt_t         fNplanes;     // Number of hitpattern planes
    Double_t       fMaxSlope;    // Max allowed slope, normalized units (0-1)
    vector<double> fZ;           // z positions of planes, normalized (0-1)

    vector<HashNode> fHashTable; // Hashtab for indexing patterns during build
    Statistics_t   fStats;       // Tree statistics

    HashNode* AddHash( Pattern* pat );
    void      CalcStatistics();
    void      ClearStatistics();
    void      DeleteTree();
    HashNode* Find( const Pattern& pat );
    UInt_t    Hash( const Pattern& pat ) const;
    bool      LineTest( const Pattern& pat ) const;
    void      MakeChildNodes( HashNode* parent, UInt_t depth );
    bool      SlopeTest( const Pattern& pat, UInt_t depth ) const;

    ClassDef(PatternGenerator,0)   // Generator for pattern template database

  }; // end class PatternGenerator

///////////////////////////////////////////////////////////////////////////////

}  // end namespace TreeSearch

#endif
 PatternGenerator.h:1
 PatternGenerator.h:2
 PatternGenerator.h:3
 PatternGenerator.h:4
 PatternGenerator.h:5
 PatternGenerator.h:6
 PatternGenerator.h:7
 PatternGenerator.h:8
 PatternGenerator.h:9
 PatternGenerator.h:10
 PatternGenerator.h:11
 PatternGenerator.h:12
 PatternGenerator.h:13
 PatternGenerator.h:14
 PatternGenerator.h:15
 PatternGenerator.h:16
 PatternGenerator.h:17
 PatternGenerator.h:18
 PatternGenerator.h:19
 PatternGenerator.h:20
 PatternGenerator.h:21
 PatternGenerator.h:22
 PatternGenerator.h:23
 PatternGenerator.h:24
 PatternGenerator.h:25
 PatternGenerator.h:26
 PatternGenerator.h:27
 PatternGenerator.h:28
 PatternGenerator.h:29
 PatternGenerator.h:30
 PatternGenerator.h:31
 PatternGenerator.h:32
 PatternGenerator.h:33
 PatternGenerator.h:34
 PatternGenerator.h:35
 PatternGenerator.h:36
 PatternGenerator.h:37
 PatternGenerator.h:38
 PatternGenerator.h:39
 PatternGenerator.h:40
 PatternGenerator.h:41
 PatternGenerator.h:42
 PatternGenerator.h:43
 PatternGenerator.h:44
 PatternGenerator.h:45
 PatternGenerator.h:46
 PatternGenerator.h:47
 PatternGenerator.h:48
 PatternGenerator.h:49
 PatternGenerator.h:50
 PatternGenerator.h:51
 PatternGenerator.h:52
 PatternGenerator.h:53
 PatternGenerator.h:54
 PatternGenerator.h:55
 PatternGenerator.h:56
 PatternGenerator.h:57
 PatternGenerator.h:58
 PatternGenerator.h:59
 PatternGenerator.h:60
 PatternGenerator.h:61
 PatternGenerator.h:62
 PatternGenerator.h:63
 PatternGenerator.h:64
 PatternGenerator.h:65
 PatternGenerator.h:66
 PatternGenerator.h:67
 PatternGenerator.h:68
 PatternGenerator.h:69
 PatternGenerator.h:70
 PatternGenerator.h:71
 PatternGenerator.h:72
 PatternGenerator.h:73
 PatternGenerator.h:74
 PatternGenerator.h:75
 PatternGenerator.h:76
 PatternGenerator.h:77
 PatternGenerator.h:78
 PatternGenerator.h:79
 PatternGenerator.h:80