38 #ifndef __PDDP_CHANNEL_MAP_H__ 39 #define __PDDP_CHANNEL_MAP_H__ 45 #include <boost/multi_index_container.hpp> 46 #include <boost/multi_index/ordered_index.hpp> 47 #include <boost/multi_index/composite_key.hpp> 48 #include <boost/multi_index/hashed_index.hpp> 49 #include <boost/multi_index/identity.hpp> 50 #include <boost/multi_index/mem_fun.hpp> 51 #include <boost/range/iterator_range.hpp> 52 #include <boost/tuple/tuple.hpp> 53 #include <boost/optional.hpp> 70 unsigned short crate_, card_, cardch_;
79 unsigned short crate,
unsigned short card,
unsigned short cardch,
80 unsigned short crp,
unsigned short view,
unsigned short viewch,
81 unsigned short state = 0 ) :
82 seqn_(seqn), crate_(crate), card_(card), cardch_(cardch), crp_(crp), view_(view), viewch_(viewch), state_(state) {;}
86 const unsigned seqn()
const {
return seqn_; }
87 const unsigned short crate()
const {
return crate_; }
88 const unsigned short card()
const {
return card_; }
89 const unsigned short cardch()
const {
return cardch_; }
90 const unsigned short crp()
const {
return crp_; }
91 const unsigned short view()
const {
return view_; }
92 const unsigned short viewch()
const {
return viewch_; }
93 const unsigned short state()
const {
return state_; }
94 const bool exists()
const {
return (state_ == 0); }
115 typedef multi_index_container<
118 ordered_unique< tag<IndexRawSeqn>, const_mem_fun< DPChannelId, const unsigned, &DPChannelId::seqn > >,
119 hashed_unique< tag<IndexRawSeqnHash>, const_mem_fun< DPChannelId, const unsigned, &DPChannelId::seqn > >,
120 hashed_non_unique< tag<IndexCrate>, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::crate > >,
121 hashed_non_unique< tag<IndexCrateCard>, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::crate >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::card > > >,
122 ordered_unique< tag<IndexCrateCardChan>, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::crate >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::card >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::cardch > > >,
123 hashed_unique< tag<IndexCrateCardChanHash>, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::crate >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::card >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::cardch > > >,
124 hashed_non_unique< tag<IndexCrp>, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::crp > >,
125 hashed_non_unique< tag<IndexCrpView>, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::crp >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::view > > >,
126 ordered_unique< tag<IndexCrpViewChan>, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::crp >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::view >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::viewch > > >,
127 hashed_unique< tag<IndexCrpViewChanHash>, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::crp >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::view >, const_mem_fun< DPChannelId, const unsigned short, &DPChannelId::viewch > > >
143 int MapToCRP(
int seqch,
int &crp,
int &view,
int &chv)
const;
144 int MapToDAQ(
int crp,
int view,
int chv,
int &seqch)
const;
151 boost::optional<DPChannelId> find_by_seqn(
unsigned seqn )
const;
152 std::vector<DPChannelId> find_by_seqn(
unsigned from,
unsigned to )
const;
155 std::vector<DPChannelId> find_by_crate(
unsigned crate,
bool ordered =
true )
const;
156 std::vector<DPChannelId> find_by_crate_card(
unsigned crate,
unsigned card,
157 bool ordered =
true )
const;
158 boost::optional<DPChannelId> find_by_crate_card_chan(
unsigned crate,
159 unsigned card,
unsigned chan )
const;
161 std::vector<DPChannelId> find_by_crp(
unsigned crp,
bool ordered =
true )
const;
162 std::vector<DPChannelId> find_by_crp_view(
unsigned crp,
unsigned view,
bool ordered =
true )
const;
163 boost::optional<DPChannelId> find_by_crp_view_chan(
unsigned crp,
164 unsigned view,
unsigned chan )
const;
167 unsigned ncrps()
const {
return ncrps_; }
168 unsigned ntot()
const {
return ntot_; }
169 unsigned ncards(
unsigned crate )
const;
170 unsigned nviews(
unsigned crp )
const;
173 void print( std::vector<DPChannelId> &vec );
183 void initMap(
std::string mapname,
unsigned ncrates = 1,
184 unsigned ncards = 10,
unsigned nviews = 1 );
186 void add(
unsigned seq,
unsigned crate,
unsigned card,
unsigned cch,
187 unsigned crp,
unsigned view,
unsigned vch,
unsigned short state = 0);
189 template<
typename Index,
typename KeyExtractor>
193 for(
auto it=i.begin(),it_end=i.end();it!=it_end;)
196 it = i.upper_bound(
key(*it) );
202 void simpleMap(
unsigned ncrates,
unsigned ncards,
unsigned nviews );
212 std::vector<DPChannelId>
filter( std::vector<DPChannelId> &sel )
const 214 std::vector<DPChannelId> res;
216 if(
c.exists() ) res.push_back(
c );
DPChannelId(unsigned seqn, unsigned short crate, unsigned short card, unsigned short cardch, unsigned short crp, unsigned short view, unsigned short viewch, unsigned short state=0)
const unsigned short crate() const
Coord add(Coord c1, Coord c2)
const unsigned short card() const
std::set< unsigned > get_crpidx()
std::set< unsigned > crateidx_
const bool exists() const
const unsigned seqn() const
bool operator<(const DPChannelId &rhs) const
const unsigned short viewch() const
std::vector< DPChannelId > filter(std::vector< DPChannelId > &sel) const
const unsigned short crp() const
struct dune::tde::crate crate
#define DECLARE_ART_SERVICE(svc, scope)
const unsigned short state() const
std::size_t cdistinct(const Index &i, KeyExtractor key)
const unsigned short view() const
std::set< unsigned > get_crateidx()
std::string getMapName() const
multi_index_container< DPChannelId, indexed_by< ordered_unique< tag< IndexRawSeqn >, const_mem_fun< DPChannelId, const unsigned,&DPChannelId::seqn > >, hashed_unique< tag< IndexRawSeqnHash >, const_mem_fun< DPChannelId, const unsigned,&DPChannelId::seqn > >, hashed_non_unique< tag< IndexCrate >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::crate > >, hashed_non_unique< tag< IndexCrateCard >, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::crate >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::card > > >, ordered_unique< tag< IndexCrateCardChan >, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::crate >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::card >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::cardch > > >, hashed_unique< tag< IndexCrateCardChanHash >, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::crate >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::card >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::cardch > > >, hashed_non_unique< tag< IndexCrp >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::crp > >, hashed_non_unique< tag< IndexCrpView >, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::crp >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::view > > >, ordered_unique< tag< IndexCrpViewChan >, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::crp >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::view >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::viewch > > >, hashed_unique< tag< IndexCrpViewChanHash >, composite_key< DPChannelId, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::crp >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::view >, const_mem_fun< DPChannelId, const unsigned short,&DPChannelId::viewch > > > > > DPChannelTable
const unsigned short cardch() const
std::set< unsigned > crpidx_