Public Member Functions | Private Member Functions | Private Attributes | List of all members
dune::VDColdboxTDEChannelMapService Class Reference

#include <VDColdboxTDEChannelMapService.h>

Public Member Functions

 VDColdboxTDEChannelMapService (fhicl::ParameterSet const &p, art::ActivityRegistry &areg)
 
std::string getMapName () const
 
int MapToCRP (int seqch, int &crp, int &view, int &chv) const
 
int MapToDAQ (int crp, int view, int chv, int &seqch) const
 
boost::optional< tde::ChannelIdfind_by_seqn (unsigned seqn) const
 
std::vector< tde::ChannelIdfind_by_seqn (unsigned from, unsigned to) const
 
std::vector< tde::ChannelIdfind_by_crate (unsigned crate, bool ordered=true) const
 
std::vector< tde::ChannelIdfind_by_crate_card (unsigned crate, unsigned card, bool ordered=true) const
 
boost::optional< tde::ChannelIdfind_by_crate_card_chan (unsigned crate, unsigned card, unsigned chan) const
 
std::vector< tde::ChannelIdfind_by_crp (unsigned crp, bool ordered=true) const
 
std::vector< tde::ChannelIdfind_by_crp_view (unsigned crp, unsigned view, bool ordered=true) const
 
boost::optional< tde::ChannelIdfind_by_crp_view_chan (unsigned crp, unsigned view, unsigned chan) const
 
unsigned ncrates () const
 
unsigned ncrps () const
 
unsigned ntot () const
 
unsigned ncards (unsigned crate) const
 
unsigned nviews (unsigned crp) const
 
void print (std::vector< tde::ChannelId > &vec)
 
std::set< unsigned > get_crateidx ()
 
std::set< unsigned > get_crpidx ()
 

Private Member Functions

void clearMap ()
 
void initMap (std::string mapname, unsigned ncrates=1, unsigned ncards=10, unsigned nviews=1)
 
void add (unsigned seq, unsigned crate, unsigned card, unsigned cch, unsigned crp, unsigned view, unsigned vch, unsigned short state=0)
 
template<typename Index , typename KeyExtractor >
std::size_t cdistinct (const Index &i, KeyExtractor key)
 
void simpleMap (unsigned ncrates, unsigned ncards, unsigned nviews)
 
void vdcb1crpMap ()
 
std::vector< tde::ChannelIdfilter (std::vector< tde::ChannelId > &sel) const
 

Private Attributes

int fLogLevel
 
tde::ChannelTable chanTable
 
std::string mapname_
 
std::set< unsigned > crateidx_
 
std::set< unsigned > crpidx_
 
unsigned ncrates_
 
unsigned ncrps_
 
unsigned ntot_
 
unsigned nch_
 

Detailed Description

Definition at line 138 of file VDColdboxTDEChannelMapService.h.

Constructor & Destructor Documentation

dune::VDColdboxTDEChannelMapService::VDColdboxTDEChannelMapService ( fhicl::ParameterSet const &  p,
art::ActivityRegistry areg 
)
explicit

Definition at line 56 of file VDColdboxTDEChannelMapService_service.cc.

58 {
59  mapname_ = "";
60  ntot_ = 0;
61  ncrates_ = 0;
62  ncrps_ = 0;
63  nch_ = 64;
64 
65  std::string MapName = p.get<std::string>("MapName", "vdcb1crp");
66  unsigned ncrateInMap = p.get<unsigned>("MapCrateNb", 3);
67  unsigned ncardsInMap = p.get<unsigned>("MapCardNb", 10);
68  unsigned nviewsInMap = p.get<unsigned>("MapViewNb", 1);
69  fLogLevel = p.get<int>("LogLevel", 0);
70  //initialize channel map
71  initMap( MapName, ncrateInMap, ncardsInMap, nviewsInMap );
72 
73  if( fLogLevel >= 3){
74  auto all_chans = find_by_seqn(0, ntot());
75  print( all_chans );
76  }
77 }
std::string string
Definition: nybbler.cc:12
void initMap(std::string mapname, unsigned ncrates=1, unsigned ncards=10, unsigned nviews=1)
void print(std::vector< tde::ChannelId > &vec)
p
Definition: test.py:223
boost::optional< tde::ChannelId > find_by_seqn(unsigned seqn) const

Member Function Documentation

void dune::VDColdboxTDEChannelMapService::add ( unsigned  seq,
unsigned  crate,
unsigned  card,
unsigned  cch,
unsigned  crp,
unsigned  view,
unsigned  vch,
unsigned short  state = 0 
)
private

Definition at line 145 of file VDColdboxTDEChannelMapService_service.cc.

148 {
149  chanTable.insert( ChannelId(seq, crate, card, cch, crp, view, vch, state) );
150  //
151  ntot_ = chanTable.size();
152 
153  crateidx_.insert( crate );
154  ncrates_ = crateidx_.size();
155 
156  crpidx_.insert( crp );
157  ncrps_ = crpidx_.size();
158 }
struct dune::tde::crate crate
template<typename Index , typename KeyExtractor >
std::size_t dune::VDColdboxTDEChannelMapService::cdistinct ( const Index i,
KeyExtractor  key 
)
inlineprivate

Definition at line 195 of file VDColdboxTDEChannelMapService.h.

196  {
197  std::size_t res = 0;
198  for(auto it=i.begin(),it_end=i.end();it!=it_end;)
199  {
200  ++res;
201  it = i.upper_bound( key(*it) );
202  }
203  return res;
204  }
def key(type, name=None)
Definition: graph.py:13
void dune::VDColdboxTDEChannelMapService::clearMap ( )
private

Definition at line 102 of file VDColdboxTDEChannelMapService_service.cc.

103 {
104  tde::ChannelTable().swap( chanTable );
105  ncrates_ = 0;
106  ncrps_ = 0;
107  ntot_ = 0;
108  mapname_ = "";
109  crateidx_.clear();
110  crpidx_.clear();
111 }
multi_index_container< ChannelId, indexed_by< ordered_unique< tag< IndexRawSeqn >, const_mem_fun< ChannelId, const unsigned,&ChannelId::seqn > >, hashed_unique< tag< IndexRawSeqnHash >, const_mem_fun< ChannelId, const unsigned,&ChannelId::seqn > >, hashed_non_unique< tag< IndexCrate >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crate > >, hashed_non_unique< tag< IndexCrateCard >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::card > > >, ordered_unique< tag< IndexCrateCardChan >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::card >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::cardch > > >, hashed_unique< tag< IndexCrateCardChanHash >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crate >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::card >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::cardch > > >, hashed_non_unique< tag< IndexCrp >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crp > >, hashed_non_unique< tag< IndexCrpView >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::view > > >, ordered_unique< tag< IndexCrpViewChan >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::view >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::viewch > > >, hashed_unique< tag< IndexCrpViewChanHash >, composite_key< ChannelId, const_mem_fun< ChannelId, const unsigned short,&ChannelId::crp >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::view >, const_mem_fun< ChannelId, const unsigned short,&ChannelId::viewch > > > > > ChannelTable
std::vector<tde::ChannelId> dune::VDColdboxTDEChannelMapService::filter ( std::vector< tde::ChannelId > &  sel) const
inlineprivate

Definition at line 214 of file VDColdboxTDEChannelMapService.h.

215  {
216  std::vector<tde::ChannelId> res;
217  for( auto &c : sel )
218  if( c.exists() ) res.push_back( c );
219  return res;
220  }
std::vector< ChannelId > dune::VDColdboxTDEChannelMapService::find_by_crate ( unsigned  crate,
bool  ordered = true 
) const

Definition at line 200 of file VDColdboxTDEChannelMapService_service.cc.

201 {
202  if( not ordered ) // get from hashed index
203  {
204  const auto r = chanTable.get<dune::tde::IndexCrate>().equal_range( crate );
205  std::vector<ChannelId> res(r.first, r.second);
206  return res;
207  }
208 
209  const auto r = chanTable.get<dune::tde::IndexCrateCardChan>().equal_range( boost::make_tuple(crate) );
210  std::vector<ChannelId> res(r.first, r.second);
211 
212  return res;
213 }
struct dune::tde::crate crate
std::vector< ChannelId > dune::VDColdboxTDEChannelMapService::find_by_crate_card ( unsigned  crate,
unsigned  card,
bool  ordered = true 
) const

Definition at line 217 of file VDColdboxTDEChannelMapService_service.cc.

218 {
219  if( not ordered ) // get from hashed index
220  {
221  const auto r = chanTable.get<dune::tde::IndexCrateCard>().equal_range( boost::make_tuple(crate, card) );
222  std::vector<ChannelId> res(r.first, r.second);
223  return res;
224  }
225 
226  // ordered accodring to channel number
227  const auto r = chanTable.get<dune::tde::IndexCrateCardChan>().equal_range( boost::make_tuple( crate, card) );
228  std::vector<ChannelId> res(r.first, r.second);
229 
230  return res;
231 }
struct dune::tde::crate crate
boost::optional< ChannelId > dune::VDColdboxTDEChannelMapService::find_by_crate_card_chan ( unsigned  crate,
unsigned  card,
unsigned  chan 
) const

Definition at line 235 of file VDColdboxTDEChannelMapService_service.cc.

237 {
238  auto it = chanTable.get<dune::tde::IndexCrateCardChanHash>().find( boost::make_tuple(crate, card, chan) );
239  if( it != chanTable.get<dune::tde::IndexCrateCardChanHash>().end() )
240  return *it;
241 
242  return boost::optional<ChannelId>();
243 }
struct dune::tde::crate crate
std::vector< ChannelId > dune::VDColdboxTDEChannelMapService::find_by_crp ( unsigned  crp,
bool  ordered = true 
) const

Definition at line 247 of file VDColdboxTDEChannelMapService_service.cc.

248 {
249  if( not ordered ) // get from hashed index
250  {
251  const auto r = chanTable.get<dune::tde::IndexCrp>().equal_range( crp );
252  std::vector<ChannelId> res(r.first, r.second);
253  return res;
254  }
255 
256  const auto r = chanTable.get<dune::tde::IndexCrpViewChan>().equal_range( crp );
257  std::vector<ChannelId> res(r.first, r.second);
258  //return res;
259  return res;
260 }
std::vector< ChannelId > dune::VDColdboxTDEChannelMapService::find_by_crp_view ( unsigned  crp,
unsigned  view,
bool  ordered = true 
) const

Definition at line 264 of file VDColdboxTDEChannelMapService_service.cc.

265 {
266  if( not ordered ) // get from hashed index
267  {
268  const auto r = chanTable.get<dune::tde::IndexCrpView>().equal_range( boost::make_tuple(crp, view) );
269  std::vector<ChannelId> res(r.first, r.second);
270  return res;
271  }
272 
273  // ordered accodring to channel number
274  const auto r = chanTable.get<dune::tde::IndexCrpViewChan>().equal_range( boost::make_tuple(crp, view) );
275  std::vector<ChannelId> res(r.first, r.second);
276  return res;
277 }
boost::optional< ChannelId > dune::VDColdboxTDEChannelMapService::find_by_crp_view_chan ( unsigned  crp,
unsigned  view,
unsigned  chan 
) const

Definition at line 281 of file VDColdboxTDEChannelMapService_service.cc.

283 {
284  auto it = chanTable.get<dune::tde::IndexCrpViewChanHash>().find( boost::make_tuple(crp, view, chan) );
285  if( it != chanTable.get<dune::tde::IndexCrpViewChanHash>().end() )
286  return *it;
287 
288  return boost::optional<ChannelId>();
289 }
boost::optional< ChannelId > dune::VDColdboxTDEChannelMapService::find_by_seqn ( unsigned  seqn) const

Definition at line 163 of file VDColdboxTDEChannelMapService_service.cc.

164 {
165  auto it = chanTable.get<dune::tde::IndexRawSeqnHash>().find( seqn );
166  if( it != chanTable.get<dune::tde::IndexRawSeqnHash>().end() )
167  return *it;
168 
169  return boost::optional<ChannelId>();
170 }
std::vector< ChannelId > dune::VDColdboxTDEChannelMapService::find_by_seqn ( unsigned  from,
unsigned  to 
) const

Definition at line 174 of file VDColdboxTDEChannelMapService_service.cc.

175 {
176  if( to < from ) std::swap( from, to );
177 
178  std::vector<ChannelId> res;
179 
180  if( from == to )
181  {
182  if( boost::optional<ChannelId> id = find_by_seqn( from ) )
183  res.push_back( *id );
184  //auto it = chanTable.find(from);
185  //if( it != chanTable.end() )
186  //res.push_back( *it );
187  }
188  else
189  {
190  auto first = chanTable.get<dune::tde::IndexRawSeqn>().lower_bound( from );
191  auto last = chanTable.get<dune::tde::IndexRawSeqn>().upper_bound( to );
192  res.insert( res.begin(), first, last );
193  }
194 
195  return res;
196 }
void swap(Handle< T > &a, Handle< T > &b)
boost::optional< tde::ChannelId > find_by_seqn(unsigned seqn) const
std::set< unsigned > dune::VDColdboxTDEChannelMapService::get_crateidx ( )
inline

Definition at line 180 of file VDColdboxTDEChannelMapService.h.

180 { return crateidx_; }
std::set< unsigned > dune::VDColdboxTDEChannelMapService::get_crpidx ( )
inline

Definition at line 181 of file VDColdboxTDEChannelMapService.h.

181 { return crpidx_; }
std::string dune::VDColdboxTDEChannelMapService::getMapName ( ) const
inline
void dune::VDColdboxTDEChannelMapService::initMap ( std::string  mapname,
unsigned  ncrates = 1,
unsigned  ncards = 10,
unsigned  nviews = 1 
)
private

Definition at line 82 of file VDColdboxTDEChannelMapService_service.cc.

84 {
85  // already defined?
86  if( mapname_.compare( mapname ) == 0 ) {
87  return;
88  }
89 
90  clearMap();
91  mapname_ = mapname;
92  if( mapname.compare("vdcb1crp") == 0 ) {
93  vdcb1crpMap();
94  } else {
96  }
97 }
void simpleMap(unsigned ncrates, unsigned ncards, unsigned nviews)
int dune::VDColdboxTDEChannelMapService::MapToCRP ( int  seqch,
int &  crp,
int &  view,
int &  chv 
) const

Definition at line 293 of file VDColdboxTDEChannelMapService_service.cc.

294 {
295  crp = view = chv = -1;
296  if( boost::optional<ChannelId> id = find_by_seqn( (unsigned)seqch ) )
297  {
298  if( !id->exists() ) return -1;
299  crp = id->crp();
300  view = id->view();
301  chv = id->viewch();
302  return 1;
303  }
304 
305  return -1;
306 }
boost::optional< tde::ChannelId > find_by_seqn(unsigned seqn) const
int dune::VDColdboxTDEChannelMapService::MapToDAQ ( int  crp,
int  view,
int  chv,
int &  seqch 
) const

Definition at line 310 of file VDColdboxTDEChannelMapService_service.cc.

311 {
312  seqch = -1;
313  if( boost::optional<ChannelId> id = find_by_crp_view_chan( (unsigned)crp, (unsigned)view, (unsigned)chv ) )
314  {
315  if( !id->exists() ) return -1;
316  seqch = id->seqn();
317  return 1;
318  }
319  return -1;
320 }
boost::optional< tde::ChannelId > find_by_crp_view_chan(unsigned crp, unsigned view, unsigned chan) const
unsigned dune::VDColdboxTDEChannelMapService::ncards ( unsigned  crate) const

Definition at line 324 of file VDColdboxTDEChannelMapService_service.cc.

325 {
326  // assumes it is sorted according to card number
327  unsigned count = 0;
328  auto r = chanTable.get<dune::tde::IndexCrateCardChan>().equal_range( crate );
329  ssize_t last = -1;
330  for( ChannelId const &ch : boost::make_iterator_range( r ) )
331  {
332  if( !ch.exists() ) continue;
333  unsigned val = ch.card();
334  if( val != last )
335  {
336  count++;
337  last = val;
338  }
339  }
340 
341  return count;
342 }
struct dune::tde::crate crate
unsigned dune::VDColdboxTDEChannelMapService::ncrates ( ) const
inline
unsigned dune::VDColdboxTDEChannelMapService::ncrps ( ) const
inline
unsigned dune::VDColdboxTDEChannelMapService::ntot ( ) const
inline
unsigned dune::VDColdboxTDEChannelMapService::nviews ( unsigned  crp) const

Definition at line 346 of file VDColdboxTDEChannelMapService_service.cc.

347 {
348  // assumes it is sorted according to crp number
349  unsigned count = 0;
350  auto r = chanTable.get<dune::tde::IndexCrpViewChan>().equal_range( crp );
351  ssize_t last = -1;
352  for( ChannelId const &ch : boost::make_iterator_range( r ) )
353  {
354  if( !ch.exists() ) continue;
355  unsigned val = ch.view();
356  if( val != last )
357  {
358  count++;
359  last = val;
360  }
361  }
362 
363  return count;
364 }
void dune::VDColdboxTDEChannelMapService::print ( std::vector< tde::ChannelId > &  vec)

Definition at line 368 of file VDColdboxTDEChannelMapService_service.cc.

369 {
370  for( auto it = vec.begin();it!=vec.end();++it )
371  {
372  unsigned seqn = it->seqn();
373  unsigned crate = it->crate();
374  unsigned card = it->card();
375  unsigned cch = it->cardch();
376  unsigned crp = it->crp();
377  unsigned view = it->view();
378  unsigned vch = it->viewch();
379  unsigned state = it->state();
380  bool exists = it->exists();
381  std::cout<<std::setw(7)<<seqn
382  <<std::setw(4)<<crate
383  <<std::setw(3)<<card
384  <<std::setw(3)<<cch
385  <<std::setw(3)<<crp
386  <<std::setw(2)<<view
387  <<std::setw(4)<<vch
388  <<std::setw(2)<<state
389  <<std::setw(2)<<exists<<std::endl;
390  }
391 }
crate(int id, int cards)
bool exists(std::string path)
struct dune::tde::crate crate
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
QTextStream & endl(QTextStream &s)
void dune::VDColdboxTDEChannelMapService::simpleMap ( unsigned  ncrates,
unsigned  ncards,
unsigned  nviews 
)
private

Definition at line 116 of file VDColdboxTDEChannelMapService_service.cc.

118 {
119  unsigned nctot = ncards * ncrates; // total number of cards
120  unsigned ncview = nctot / nviews; // allocate the same for each view
121  unsigned nch = nch_; // number of ch per card (fixed)
122 
123  unsigned seqn = 0;
124  unsigned crate = 0;
125  unsigned crp = 0;
126  unsigned view = 0;
127  unsigned vch = 0;
128  for( unsigned card = 0; card < nctot; card++ )
129  {
130  if( card > 0 ) {
131  if( card % ncards == 0 ) crate++;
132  if( card % ncview == 0 ) {view++; vch=0;}
133  }
134  for( unsigned ch = 0; ch < nch; ch++ ){
135  add( seqn++, crate, card % ncards, ch, crp, view, vch++);
136  }
137  }
138  //
139 }
void add(unsigned seq, unsigned crate, unsigned card, unsigned cch, unsigned crp, unsigned view, unsigned vch, unsigned short state=0)
struct dune::tde::crate crate
void dune::VDColdboxTDEChannelMapService::vdcb1crpMap ( )
private

Definition at line 394 of file VDColdboxTDEChannelMapService_service.cc.

394  {
395 
396  //int ncrates = 3;
397  int nslots = 10;
398  int nview = 3;
399 
400  // utca crate 1
401  dune::tde::crate c1( 0, nslots );
402  vector<int> c1_kel{34, 36, 35, 38, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49};
403  c1.add_crp_connection( 0, 0, c1_kel );
404 
405  // utca crate 2
406  dune::tde::crate c2( 1, nslots );
407  vector<int> c2_kel{14, 16, 15, 18, 17, 19, 20, 22, 21, 25, 23, 24, 26, 27, 28, 32, 29, 30, 31, 33};
408  c2.add_crp_connection( 0, 0, c2_kel );
409 
410  // utca crate 3
411  dune::tde::crate c3( 2, nslots );
412  vector<int> c3_kel{0, 2, 1, 5, 3, 4, 6, 7, 8, 12, 9, 10, 11, 13};
413  c3.add_crp_connection( 0, 0, c3_kel );
414 
415  vector<dune::tde::crate> crates{c1, c2, c3};
416 
417  // all connector mappings should include ADC channel inversion on AMCs
418  // the inversion is in group of 8ch: AMC ch 0 -> 7 should be remapped to 7 -> 0
419 
420  // kel connector orientation in a given view, chans 0 -> 31
421  vector<unsigned> kel_nor = { 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9,
422  8, 23, 22, 21, 20, 19, 18, 17, 16, 31, 30, 29, 28, 27, 26, 25, 24 };
423  // kel connector orientation in a given view, chans 31 -> 0
424  vector<unsigned> kel_inv = {24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22,
425  23, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7 };
426 
427 
428  // kel connectors for each view sorted in the view channel order
429  // induction 1
430  vector<int> kel_view0{1,5,8,12,15,18,21,25,28,32,35,38};
431  std::reverse(kel_view0.begin(), kel_view0.end());
432  // induction 2
433  vector<int> kel_view1{40,41,42,43,44,45,46,47,48,49, 13,11,10,9,7,6,4,3,2,0};
434  // collection
435  vector<int> kel_view2{14,16,17,19,20,22,23,24,26,27,29,30,31,33,34,36,37,39};
436  std::reverse(kel_view2.begin(), kel_view2.end());
437 
438 
439  dune::tde::crp_connectors crp_conn( 0, nview );
440  int ch_start = 0;
441  for( auto const k : kel_view0 ){
442  //crp_conn.add_connector( k, 0, true, ch_start );
443  crp_conn.add_connector( k, 0, false, ch_start );
444  ch_start += dune::tde::ch_per_kel;
445  }
446  ch_start = 0;
447  for( auto const k : kel_view1 ){
448  //bool reverse = (k <= 13);
449  bool reverse = (k > 13);
450  crp_conn.add_connector( k, 1, reverse, ch_start );
451  ch_start += dune::tde::ch_per_kel;
452  }
453 
454  ch_start = 0;
455  for( auto const k : kel_view2 ){
456  //crp_conn.add_connector( k, 2, true, ch_start );
457  crp_conn.add_connector( k, 2, false, ch_start );
458  ch_start += dune::tde::ch_per_kel;
459  }
460 
461  // only one crp
462  unsigned crp_id = 0;
463  unsigned seqn = 0;
464 
465  // map the existing DAQ channels to 4th view
466  // not connected view id
467  unsigned view_na = (unsigned)nview;
468  unsigned view_na_ch = 0;
469 
470  for( auto const &utca : crates ) {
471  unsigned utca_id = (unsigned)utca._id;
472  //if( utca_id <= 1 ) continue;
473  auto utca_conn = utca._crp_conn;
474  auto utca_nconn = utca_conn.size();
475  auto utca_slots = (unsigned)utca._cards;
476  for( unsigned amc = 0; amc < utca_slots; ++amc ){
477  // unconnected AMCs
478  if( amc >= utca_nconn ){
479  for( unsigned cardch = 0; cardch < dune::tde::ch_per_amc; ++cardch ){
480  add( seqn++, utca_id, amc, cardch, crp_id, view_na, view_na_ch++, 1);
481  }
482  continue;
483  }
484 
485  // connected to CRU
486  auto conn = utca_conn[ amc ];
487  unsigned islot = (unsigned)std::get<0>(conn);
488  //unsigned icrp = (unsigned)std::get<1>(conn);
489  auto kel1_id = std::get<2>(conn);
490  auto kel2_id = std::get<3>(conn);
491  if( islot != amc ){
492  throw cet::exception("VDColdboxTDEChannelMap")
493  <<"Mismatch in slot and AMC index: slot "
494  << islot<<" != amc "<<amc<<"\n";
495  //amc = islot;
496  }
497 
498  // 1st connector
499  if( kel1_id < (int)crp_conn._kels.size() ){
500  auto kel_ = std::next(crp_conn._kels.begin(), kel1_id);
501  if( kel_->_id != kel1_id ) {
502  throw cet::exception("VDColdboxTDEChannelMap")
503  <<"Mismatch in KEL1 numbering\n";
504  }
505 
506  vector<unsigned> order_ = (kel_->_reverse)? kel_inv : kel_nor;
507  unsigned iview = (unsigned)kel_->_view;
508  unsigned vch_start = (unsigned)kel_->_first_view_ch;
509  for( unsigned cardch = 0; cardch < dune::tde::ch_per_kel; ++cardch ){
510  unsigned viewch = vch_start + order_[cardch];
511  add( seqn++, utca_id, amc, cardch, crp_id, iview, viewch, 0);
512  }
513  } // 1st connector
514 
515  // 2nd connector
516  if( kel2_id < (int)crp_conn._kels.size() ){
517  auto kel_ = std::next(crp_conn._kels.begin(), kel2_id);
518  if( kel_->_id != kel2_id ) {
519  throw cet::exception("VDColdboxTDEChannelMap")
520  <<"Mismatch in KEL2 numbering\n";
521  }
522 
523  vector<unsigned> order_ = (kel_->_reverse)? kel_inv : kel_nor;
524  unsigned iview = (unsigned)kel_->_view;
525  unsigned vch_start = (unsigned)kel_->_first_view_ch;
526  for( unsigned cardch = 0; cardch < dune::tde::ch_per_kel; ++cardch ){
527  unsigned viewch = vch_start + order_[cardch];
528  add( seqn++, utca_id, amc, cardch + dune::tde::ch_per_kel, crp_id, iview, viewch, 0);
529  }
530  }// 2nd connector
531  } // loop over AMCs
532  } // loop over crates
533 
534  //cout<<" seqn = "<<seqn<<endl;
535  // that is it...
536 }
void add(unsigned seq, unsigned crate, unsigned card, unsigned cch, unsigned crp, unsigned view, unsigned vch, unsigned short state=0)
const short ch_per_amc
const short ch_per_kel
static unsigned int reverse(QString &chars, unsigned char *level, unsigned int a, unsigned int b)
Definition: qstring.cpp:11649
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

tde::ChannelTable dune::VDColdboxTDEChannelMapService::chanTable
private

Definition at line 224 of file VDColdboxTDEChannelMapService.h.

std::set< unsigned > dune::VDColdboxTDEChannelMapService::crateidx_
private

Definition at line 226 of file VDColdboxTDEChannelMapService.h.

std::set< unsigned > dune::VDColdboxTDEChannelMapService::crpidx_
private

Definition at line 227 of file VDColdboxTDEChannelMapService.h.

int dune::VDColdboxTDEChannelMapService::fLogLevel
private

Definition at line 223 of file VDColdboxTDEChannelMapService.h.

std::string dune::VDColdboxTDEChannelMapService::mapname_
private

Definition at line 225 of file VDColdboxTDEChannelMapService.h.

unsigned dune::VDColdboxTDEChannelMapService::nch_
private

Definition at line 231 of file VDColdboxTDEChannelMapService.h.

unsigned dune::VDColdboxTDEChannelMapService::ncrates_
private

Definition at line 228 of file VDColdboxTDEChannelMapService.h.

unsigned dune::VDColdboxTDEChannelMapService::ncrps_
private

Definition at line 229 of file VDColdboxTDEChannelMapService.h.

unsigned dune::VDColdboxTDEChannelMapService::ntot_
private

Definition at line 230 of file VDColdboxTDEChannelMapService.h.


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