33 { 1875, ChannelType::kCommonStopTDC },
34 { 1877, ChannelType::kCommonStopTDC },
35 { 1881, ChannelType::kADC },
36 { 1872, ChannelType::kCommonStopTDC },
37 { 3123, ChannelType::kADC },
38 { 1182, ChannelType::kADC },
39 { 792, ChannelType::kADC },
40 { 775, ChannelType::kCommonStopTDC },
41 { 767, ChannelType::kCommonStopTDC },
42 { 3201, ChannelType::kCommonStopTDC },
43 { 6401, ChannelType::kCommonStopTDC },
44 { 1190, ChannelType::kCommonStopTDC },
45 { 250, ChannelType::kMultiFunctionADC },
53 [mod](
const ModuleDef&
m ) {
return m.model == mod; });
57 type = ChannelType::kUndefined;
70 if( cstart &&
type == ChannelType::kCommonStopTDC )
71 type = ChannelType::kCommonStartTDC;
72 else if( !cstart &&
type == ChannelType::kCommonStartTDC )
73 type = ChannelType::kCommonStopTDC;
80 type = ChannelType::kCommonStartTDC;
82 type = ChannelType::kCommonStopTDC;
88 type = ChannelType::kADC;
95 fMap.reserve(map.capacity());
96 for(
const auto&
m : map ) {
98#
if __cplusplus >= 201402L
99 std::make_unique<Module>(*
m)
148 bool reverse = (chan_lo > chan_hi);
150#if __cplusplus >= 201402L
151 auto pm = make_unique<Module>();
167 m.refindex = refindex;
171 m.SetResolution(0.0);
184 m.type = ChannelType::kUndefined;
187 m.type = ChannelType::kUndefined;
189 fMap.push_back(std::move(pm));
203 auto found = find_if( ALL(
fMap), [crate,slot,
chan](
const unique_ptr<Module>&
d)
204 {
return (
d->crate == crate &&
d->slot == slot &&
205 d->lo <=
chan && chan <= d->
hi );
208 return (found !=
fMap.end()) ? found->get() :
nullptr;
246 typedef vector<Int_t>::size_type
vsiz_t;
270 UInt_t prev_first = 1, prev_nchan = 0;
273 Int_t plane = 0, signal = 0,
model = 0, rchan = -1, ref = -1;
276 for(
vsiz_t i = 0; i < values.size(); i += tuple_size ) {
281 if( i + tuple_size > values.size() ) {
288 first = values[i + k++];
300 first = prev_first + prev_nchan;
303 model = values[i + k++];
305 rchan = values[i + k++];
307 ref = values[i + k++];
309 plane = values[i + k++];
311 signal = values[i + k++];
313 auto crate =
static_cast<UInt_t>(values[i]);
314 auto slot =
static_cast<UInt_t>(values[i+1]);
315 auto ch_lo =
static_cast<UInt_t>(values[i+2]);
316 auto ch_hi =
static_cast<UInt_t>(values[i+3]);
317 ret =
AddModule(crate, slot, ch_lo, ch_hi,
335 for(
const auto &
m :
fMap )
336 sum +=
m->GetNchan();
352 for(
const auto&
m :
fMap ) {
353 UInt_t m_min = do_ref ?
m->refindex :
m->first;
354 UInt_t m_max = do_ref ?
m->refindex :
m->first +
m->hi -
m->lo;
368 cout <<
"Size: " <<
GetSize() << endl;
369 for(
const auto&
m :
fMap ) {
371 << setw(5) <<
m->crate
372 << setw(5) <<
m->slot
375 << setw(5) <<
m->first
376 << setw(5) <<
m->model;
378 cout << setw(4) <<
" ADC";
380 cout << setw(4) <<
" TDC";
381 cout << setw(5) <<
m->refchan
382 << setw(5) <<
m->refindex
383 << setw(8) <<
m->resolution
384 << setw(5) <<
m->plane
385 << setw(5) <<
m->signal
396 fMap.shrink_to_fit();
405 [](
const unique_ptr<Module>&
a,
const unique_ptr<Module>&
b) {
406 if(
a->crate <
b->crate )
return true;
407 if(
a->crate >
b->crate )
return false;
408 if(
a->slot <
b->slot )
return true;
409 if(
a->slot >
b->slot )
return false;
410 return (
a->lo <
b->lo);
432 : fDetMap(detmap), fEvData(evdata), fMod(nullptr), fNMod(fDetMap.GetSize()),
433 fNTotChan(fDetMap.GetTotNumChan()), fNChan(0), fIMod(-1), fIChan(-1)
446 ostr <<
"Event " << fHitInfo.ev <<
", ";
448 << fHitInfo.crate <<
"/" << fHitInfo.slot <<
"/"
449 << fHitInfo.chan <<
"/" << fHitInfo.hit <<
": ";
450 if( txt and *txt ) ostr << txt;
else ostr <<
"Unspecified error.";
454#define CRATE_SLOT( x ) (x).crate, (x).slot
468 fMod = fDetMap.GetModule(fIMod);
470 throw std::logic_error(
"NULL detector map module. Program bug. "
472 fHitInfo.set_crate_slot(fMod);
473 fHitInfo.module = fEvData.GetModule(
CRATE_SLOT(fHitInfo));
474 fNChan = fEvData.GetNumChan(
CRATE_SLOT(fHitInfo));
481 if( chan < fMod->lo or
chan > fMod->hi )
484 fHitInfo.chan =
chan;
485 fHitInfo.nhit = nhit;
488 ostr <<
"No hits on active "
489 << (fHitInfo.type == ChannelType::kADC ?
"ADC" :
"TDC")
490 <<
" channel. Should never happen. Decoder bug. Call expert.";
491 throw std::logic_error(msg(ostr.str().c_str()));
495 fHitInfo.hit = (fHitInfo.type == ChannelType::kCommonStopTDC) ? nhit - 1 : 0;
498 Int_t lchan = fMod->ConvertToLogicalChannel(
chan);
499 if( fDetMap.fStartAtZero )
501 if( lchan < 0 or
static_cast<UInt_t>(lchan) >=
size() ) {
503 size_t lmin = 1, lmax =
size();
504 if( fDetMap.fStartAtZero ) { --lmin; --lmax; }
505 ostr <<
"Illegal logical detector channel " << lchan <<
"."
506 <<
"Must be between " << lmin <<
" and " << lmax <<
". Fix database.";
507 throw std::invalid_argument(msg(ostr.str().c_str()));
509 fHitInfo.lchan = lchan;
519 fNMod = fDetMap.GetSize();
529 :
Iterator(detmap, evdata, false), fIHit(-1)
541 if(
LOOPDONE(fIHit, fHitInfo.nhit) ) {
543 if( !Iterator::operator
bool() )
547 if(
NO_NEXT(fIHit, fHitInfo.nhit) )
549 fHitInfo.hit = fIHit;
size_t size(const MatrixT &matrix)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
static bool NO_NEXT(Int_t &i, UInt_t n)
static const vector< ModuleDef > module_list
static bool LOOPDONE(Int_t i, UInt_t n)
const THaEvData & fEvData
std::string msg(const char *txt) const
virtual Iterator & operator++()
void SetResolution(Double_t resolution)
void SetTDCMode(Bool_t cstart)
void SetModel(Int_t model)
Decoder::ChannelType type
MultiHitIterator()=delete
virtual Iterator & operator++()
virtual Module * Find(UInt_t crate, UInt_t slot, UInt_t chan)
void GetMinMaxChan(UInt_t &min, UInt_t &max, ECountMode mode=kLogicalChan) const
virtual Int_t AddModule(UInt_t crate, UInt_t slot, UInt_t chan_lo, UInt_t chan_hi, UInt_t first=0, Int_t model=0, Int_t refindex=-1, Int_t refchan=-1, UInt_t plane=0, UInt_t signal=0)
virtual void Print(Option_t *opt="") const
void CopyMap(const ModuleVec_t &map)
THaDetMap::Iterator MakeIterator(const THaEvData &evdata)
UInt_t GetNchan(UInt_t i) const
std::vector< std::unique_ptr< Module > > ModuleVec_t
THaDetMap::MultiHitIterator MakeMultiHitIterator(const THaEvData &evdata)
virtual Int_t Fill(const std::vector< Int_t > &values, UInt_t flags=0)
UInt_t GetTotNumChan() const
THaDetMap & operator=(const THaDetMap &)
vector< int >::size_type vsiz_t
double min(double x, double y)
double max(double x, double y)