1 #ifndef STFTTHITCALIBMAKER_HELPER_H
2 #define STFTTHITCALIBMAKER_HELPER_H
7 #define MIN_BCID_SAMPLES 200
15 bool ready( UShort_t uuid ){
16 return ( dbcidHist.count( uuid ) > 0 && dbcidHist[uuid].size() > MIN_BCID_SAMPLES );
19 void fill( UShort_t uuid, Short_t dbcid ){
20 dbcidHist[ uuid ][ dbcid ]++;
21 if ( dbcidHist[ uuid ].size() > MIN_BCID_SAMPLES ){
22 auto x = std::max_element(dbcidHist[ uuid ].begin(), dbcidHist[ uuid ].end(),
23 [](
const pair<Short_t, Int_t>& p1,
const pair<Short_t, Int_t>& p2) {
24 return p1.second < p2.second; });
25 dbcidAnchor[ uuid ] = x->first;
29 Short_t time( UShort_t uuid, Short_t dbcid ){
30 return dbcid - dbcidAnchor[ uuid ];
33 Short_t anchor( UShort_t uuid ) {
34 if ( dbcidAnchor.count( uuid ) == 0 )
36 return dbcidAnchor[ uuid ];
40 size_t samples( UShort_t uuid ) {
41 if ( dbcidHist.count(uuid) > 0 ){
43 for (
auto kv : dbcidHist[uuid] ){
51 map<Short_t, Int_t> histFor( UShort_t uuid ) {
52 return dbcidHist[ uuid ];
55 map< UShort_t, Short_t> &getAnchorMap(){
69 map< UShort_t, map<Short_t, Int_t> > dbcidHist;
73 map< UShort_t, Short_t> dbcidAnchor;