Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
lem::Heads Class Reference

Mapping from a subset of the library to their best matches. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-03-03/LEM/func/Heads.h"

Public Member Functions

 ~Heads ()
 
int NHeads () const
 
int HeadIdx (int i) const
 
int HeadSeqsLen () const
 
int ChildIdxFor (int head, int child) const
 
bool FlipEvenFor (int head, int child) const
 
bool FlipOddFor (int head, int child) const
 

Static Public Member Functions

static HeadsFromMMap (const std::string &libPath, bool touchAll)
 
static HeadsFromMMapOnDemand (const std::string &libPath)
 

Protected Member Functions

 Heads ()
 
 Heads (const Heads &)
 
Headsoperator= (const Heads &)
 

Protected Attributes

int fNHeads
 
intfHeadIdxs
 
int fHeadSeqsLen
 
int ** fHeadSeqs
 
long fMappingSize
 

Friends

std::ostream & operator<< (std::ostream &, const lem::Heads &)
 

Detailed Description

Mapping from a subset of the library to their best matches.

Definition at line 16 of file Heads.h.

Constructor & Destructor Documentation

lem::Heads::~Heads ( )

Definition at line 71 of file Heads.cxx.

72  {
73  // munmap(kHeadsAddr, fMappingSize);
74  }
lem::Heads::Heads ( )
inlineprotected

Definition at line 34 of file Heads.h.

References operator=().

Referenced by FromMMap(), and FromMMapOnDemand().

34 {}
lem::Heads::Heads ( const Heads )
protected

Member Function Documentation

int lem::Heads::ChildIdxFor ( int  head,
int  child 
) const

Definition at line 78 of file Heads.cxx.

References fHeadSeqs, and stan::math::head().

Referenced by lem::FindMatches(), and HeadSeqsLen().

79  {
80  // Strip out flip information
81  return fHeadSeqs[head][child]>>2;
82  }
int ** fHeadSeqs
Definition: Heads.h:41
Eigen::Matrix< T, Eigen::Dynamic, 1 > head(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, size_t n)
Definition: head.hpp:24
bool lem::Heads::FlipEvenFor ( int  head,
int  child 
) const

Definition at line 85 of file Heads.cxx.

References fHeadSeqs, and stan::math::head().

Referenced by lem::FindMatches(), and HeadSeqsLen().

86  {
87  // Extract information in this bit
88  return fHeadSeqs[head][child] & 1<<1;
89  }
int ** fHeadSeqs
Definition: Heads.h:41
Eigen::Matrix< T, Eigen::Dynamic, 1 > head(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, size_t n)
Definition: head.hpp:24
bool lem::Heads::FlipOddFor ( int  head,
int  child 
) const

Definition at line 92 of file Heads.cxx.

References fHeadSeqs, and stan::math::head().

Referenced by lem::FindMatches(), and HeadSeqsLen().

93  {
94  // Extract information in this bit
95  return fHeadSeqs[head][child] & 1<<0;
96  }
int ** fHeadSeqs
Definition: Heads.h:41
Eigen::Matrix< T, Eigen::Dynamic, 1 > head(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, size_t n)
Definition: head.hpp:24
Heads * lem::Heads::FromMMap ( const std::string libPath,
bool  touchAll 
)
static

Definition at line 23 of file Heads.cxx.

References ana::assert(), fHeadIdxs, fHeadSeqs, fHeadSeqsLen, fMappingSize, fNHeads, Heads(), MECModelEnuComparisons::i, and lem::MMapFileAtAddress().

Referenced by lem::LEM::beginJob(), lem::FindMatchesAlg::FindMatchesAlg(), lem::LEMLibrary::LEMLibrary(), and preload_lib().

24  {
25  Heads* heads = new Heads;
26 
27  heads->fMappingSize = MMapFileAtAddress(libPath+"/heads_map.bin", kHeadsAddr,
28  touchAll, "/tmp/lem_preload_heads.lock");
29 
30  heads->fNHeads = ((int*)kHeadsAddr)[0];
31  heads->fHeadSeqsLen = ((int*)kHeadsAddr)[1];
32 
33  heads->fHeadIdxs = ((int*)kHeadsAddr)+2;
34 
35  heads->fHeadSeqs = new int*[heads->fNHeads];
36  heads->fHeadSeqs[0] = ((int*)kHeadsAddr)+2+heads->fNHeads;
37  for(long i = 0; i < heads->fNHeads; ++i){
38  heads->fHeadSeqs[i] = heads->fHeadSeqs[0]+heads->fHeadSeqsLen*i;
39 
40  // If "i" is an int, the calculation overflows. Check nothing similar is
41  // reintroduced.
42  assert((char*)heads->fHeadSeqs[i] > kHeadsAddr);
43  }
44 
45  return heads;
46  }
Heads()
Definition: Heads.h:34
long MMapFileAtAddress(const std::string &fname, void *addr, bool touchAll, const std::string &lockName)
Definition: Util.cxx:18
assert(nhit_max >=nhit_nbins)
Heads * lem::Heads::FromMMapOnDemand ( const std::string libPath)
static

Definition at line 49 of file Heads.cxx.

References lem::CreateOnDemandMapping(), fHeadIdxs, fHeadSeqs, fHeadSeqsLen, fMappingSize, fNHeads, Heads(), and MECModelEnuComparisons::i.

Referenced by lem::LEM::beginJob(), and lem::LEMLibrary::LEMLibrary().

50  {
51  CreateOnDemandMapping((libPath+"/heads_map.bin").c_str(), kHeadsAddr);
52 
53  Heads* heads = new Heads;
54  heads->fMappingSize = 0;
55 
56  heads->fNHeads = ((int*)kHeadsAddr)[0];
57  heads->fHeadSeqsLen = ((int*)kHeadsAddr)[1];
58 
59  heads->fHeadIdxs = ((int*)kHeadsAddr)+2;
60 
61  heads->fHeadSeqs = new int*[heads->fNHeads];
62  heads->fHeadSeqs[0] = ((int*)kHeadsAddr)+2+heads->fNHeads;
63  for(int i = 0; i < heads->fNHeads; ++i){
64  heads->fHeadSeqs[i] = heads->fHeadSeqs[0]+heads->fHeadSeqsLen*i;
65  }
66 
67  return heads;
68  }
Heads()
Definition: Heads.h:34
void CreateOnDemandMapping(const std::string &fname, const char *base)
Definition: OnDemand.cxx:123
int lem::Heads::HeadIdx ( int  i) const
inline

Definition at line 27 of file Heads.h.

References fHeadIdxs, and MECModelEnuComparisons::i.

Referenced by lem::LEM::produce().

27 {return fHeadIdxs[i];}
int * fHeadIdxs
Definition: Heads.h:39
int lem::Heads::HeadSeqsLen ( ) const
inline

Definition at line 28 of file Heads.h.

References ChildIdxFor(), fHeadSeqsLen, FlipEvenFor(), FlipOddFor(), and stan::math::head().

Referenced by lem::FindMatches().

28 {return fHeadSeqsLen;}
int fHeadSeqsLen
Definition: Heads.h:40
int lem::Heads::NHeads ( ) const
inline

Definition at line 26 of file Heads.h.

References fNHeads.

Referenced by lem::LEM::produce().

26 {return fNHeads;}
int fNHeads
Definition: Heads.h:38
Heads& lem::Heads::operator= ( const Heads )
protected

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const lem::Heads  
)
friend

Definition at line 140 of file Heads.cxx.

141  {
142  os << hs.fNHeads << " heads, with " << hs.fHeadSeqsLen << " events each.";
143  return os;
144  }
int fHeadSeqsLen
Definition: Heads.h:40
int fNHeads
Definition: Heads.h:38

Member Data Documentation

int* lem::Heads::fHeadIdxs
protected

Definition at line 39 of file Heads.h.

Referenced by FromMMap(), FromMMapOnDemand(), HeadIdx(), and lem::HeadsTranspose::HeadIdx().

int** lem::Heads::fHeadSeqs
protected

Definition at line 41 of file Heads.h.

Referenced by ChildIdxFor(), FlipEvenFor(), FlipOddFor(), FromMMap(), and FromMMapOnDemand().

int lem::Heads::fHeadSeqsLen
protected

Definition at line 40 of file Heads.h.

Referenced by FromMMap(), FromMMapOnDemand(), HeadSeqsLen(), and lem::operator<<().

long lem::Heads::fMappingSize
protected

Definition at line 43 of file Heads.h.

Referenced by FromMMap(), FromMMapOnDemand(), and lem::HeadsTranspose::~HeadsTranspose().

int lem::Heads::fNHeads
protected

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