1 #ifndef NeXusEventCallback_H
2 #define NeXusEventCallback_H
6 typedef std::map< std::string,std::vector<int> >
int_map_t;
7 typedef std::map< std::string,std::vector<uint32_t> >
uint_map_t;
8 typedef std::map< std::string,std::vector<float> >
float_map_t;
71 typedef boost::pool_allocator<T,boost::default_user_allocator_new_delete,boost::details::pool::default_mutex,100000>
alloc;
82 typedef std::map< std::string, std::vector<IXNeXusFile*> >
det_file_t;
142 #define PHI 0x9e3779b9
144 static uint32_t Q[4096], c = 362436;
146 static void init_rand(uint32_t x)
152 Q[2] = x + PHI + PHI;
154 for (i = 3; i < 4096; i++)
155 Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
158 static uint32_t rand_cmwc(
void)
160 uint64_t t, a = 18782LL;
161 static uint32_t i = 4095;
162 uint32_t x, r = 0xfffffffe;
171 return (Q[i] = r - x);
179 static bool random_shift = Poco::Util::Application::instance().config().getBool(
"isisicp.randomeventbinshift",
true);
180 int tc_index =
static_cast<int>(det_ev[i].
time_channel) - 1;
182 if ( tc_index >= 0 && tc_index < crpt->ntc[tr-1] )
186 tim = crpt->
rtcb[tr-1][tc_index] +
187 (crpt->
rtcb[tr-1][tc_index+1] - crpt->
rtcb[tr-1][tc_index]) * ((
float)rand() / (float)(RAND_MAX+1));
191 tim = (crpt->
rtcb[tr-1][tc_index] + crpt->
rtcb[tr-1][tc_index+1]) / 2.0;
void allEventCallback(const DAEEventHeader *head, const DetectorEvent32 *det_ev, int n, int event_source_id, const int *mapping)
void noFrameCallbackNull(bool end_present, NoFrameCallbackMode mode, int event_source_id)
int getSpectrum(const DetectorEvent32 *det_ev, int event_source_id, int i)
returns -1 if spectrum out of range
std::map< std::string, std::vector< uint32_t > > uint_map_t
void openDataGroup(IXNeXusFile *nx, const std::string &name, bool create_zero_size_if_missing=false)
Poco::MemoryPool m_mempool
void closeDataGroup(const std::string &name)
static const int m_nexus_chunk_length
number of items in NeXus event list data chunk
void openDataGroup(const std::string &name, bool create_zero_size_if_missing=false)
void createEmptyFileStructure()
float rtcb[ISISCRPT_MAX_NTRG][ISISCRPT_MAX_TIMECHANB]
std::vector< float > m_frame_time
monitor events we did not save to file, instead just saving histograms
uint64_t m_raw_events_sum
int m_is_vetoing
last period number seen, used for change period log
float_map_t m_se_float_values
int currentWriteFrame() const
void makeDetName(int spec, std::string &det_name)
NeXusEventCallback * object
std::set< std::string > m_event_det
std::vector< float > m_frame_proton_charge
int m_good_frames
1 yes, 0 no (-1 means unknown, but just used for initialisation)
const int_map_t & event_id
static const int INVALID_FRAME_MARKER
static Poco::Mutex m_event_write_mutex
void updateCurrentWriteFrame(int frame, int event_source_id)
Poco::NotificationQueue m_queue
void allFrameCallback(const DAEEventHeader *head, int event_source_id)
this will get called for each frame for EACH event source
static Poco::Mutex m_frame_callback_mutex
int m_current_period
frame number we are currently processing
NeXusWorker(Poco::NotificationQueue &queue)
void processDataDae(const DAEEventHeader *head, const DetectorEvent32 *det_ev, int n, int event_source_id)
std::vector< int > m_frame_period
std::map< int, std::pair< int, time_t > > card_frame_t
boost::bimap< std::string, int > det_name_t
SimpleStore< int_map_t > m_int_map_store
NeXusWorkerData(NeXusEventCallback *object_, Poco::Event &ev_, const DAEEventHeader *head_, int event_source_id_, int nev_, const int_map_t &event_id_, const float_map_t &event_time_offset_)
const ISISCRPT_STRUCT * m_crpt
std::map< std::string, std::vector< IXNeXusFile * > > det_file_t
std::map< std::string, std::vector< int > > int_map_t
void writeEventsImpl(const DAEEventHeader *head, int event_source_id, int nev, const int_map_t &event_id, const float_map_t &event_time_offset)
static Poco::Condition m_event_write_cond
static float getTimeOffset(const ISISCRPT_STRUCT *crpt, const DetectorEvent32 *det_ev, int event_source_id, int tr, int i)
float getTimeOffset(const DetectorEvent32 *det_ev, int event_source_id, int tr, int i)
std::map< std::string, int > m_det_tr
const DAEEventHeader * head
boost::pool_allocator< T, boost::default_user_allocator_new_delete, boost::details::pool::default_mutex, 100000 > alloc
int dae1SpecForCard(int pos, int dae2_spec) const
if spectrum is out of range, returns -1
std::map< std::string, std::map< int, int > > frame_events_write_t
frame_events_write_t m_frame_events_write
std::vector< int > m_good_frame
void writeEvents(const DAEEventHeader *head, int event_source_id, int nev, const int_map_t &event_id, const float_map_t &event_time_offset)
SimpleStore< float_map_t > m_float_map_store
virtual void doWork(NeXusWorkerData *data)
std::vector< int > m_frame_number
std::map< int, uint32_t > m_frame_events_raw
uint_map_t m_se_uint_values
uint64_t m_good_events_sum
NXlogWriter< int > m_vetoing
NXlogWriter< int > m_period
int getRefEventDetCard(const std::vector< int > &ev_source_ids)
void noFrameCallbackEnd(bool end_present, NoFrameCallbackMode mode, int event_source_id)
std::vector< int > m_det_id
NeXusEventCallback(const ISISCRPT_STRUCT *crpt, IXNeXusFile *file, const std::vector< int > &ev_source_ids)
LONGLONG m_monitor_events_not_saved
events discarded as outside tcb time window
std::map< std::string, uint64_t > m_events_write_total
const float_map_t & event_time_offset
card_frame_t m_card_frame
uint64_t m_good_uamph_sum
Poco::Thread m_worker_thread
void closeDataGroup(IXNeXusFile *nx, const std::string &name)
if name is null string, do nothing
std::map< std::string, std::vector< float > > float_map_t