diff --git a/src/plugins/Utilities/SConscript b/src/plugins/Utilities/SConscript index 5a34544d2..d24cdff36 100644 --- a/src/plugins/Utilities/SConscript +++ b/src/plugins/Utilities/SConscript @@ -5,7 +5,7 @@ Import('*') # Default targets (always built) subdirs = ['danarest', 'evio_writer', 'evio-hddm'] -subdirs.extend(['2trackskim', 'pi0bcalskim', 'pi0fcalskim', 'run_summary', 'track_skimmer', 'trackeff_missing','ps_skim', 'trigger_skims', 'bigevents_skim', 'coherent_peak_skim','exclusivepi0skim']) +subdirs.extend(['2trackskim', 'pi0bcalskim', 'pi0fcalskim', 'run_summary', 'track_skimmer', 'trackeff_missing','ps_skim', 'trigger_skims', 'bigevents_skim', 'coherent_peak_skim','exclusivepi0skim','randomtrigger_skim']) subdirs.extend(['EventTagPi0','es_test','omega_skim','cal_high_energy_skim']) SConscript(dirs=subdirs, exports='env osname', duplicate=0) diff --git a/src/plugins/Utilities/randomtrigger_skim/JEventProcessor_randomtrigger_skim.cc b/src/plugins/Utilities/randomtrigger_skim/JEventProcessor_randomtrigger_skim.cc new file mode 100644 index 000000000..bd7d7c5a6 --- /dev/null +++ b/src/plugins/Utilities/randomtrigger_skim/JEventProcessor_randomtrigger_skim.cc @@ -0,0 +1,112 @@ +// +// JEventProcessor_randomtrigger_skim.cc +// +// JANA event processor plugin to skim random triggers to HDDM files +// +// Author: Sean Dobbs + +#include "JEventProcessor_randomtrigger_skim.h" +#include "TRIGGER/DL1Trigger.h" +#include "BCAL/DBCALHit.h" +#include "DAQ/DL1Info.h" +#include +#include + +// for initializing plugins +extern "C" { + void InitPlugin(JApplication *app) + { + InitJANAPlugin(app); + app->AddProcessor(new JEventProcessor_randomtrigger_skim(), true); + } +} // "extern C" + + +// variables to control which triggers get read out + +//------------------------------- +// init +//------------------------------- +jerror_t JEventProcessor_randomtrigger_skim::init(void) +{ + return NOERROR; +} + +//------------------------------- +// brun +//------------------------------- +jerror_t JEventProcessor_randomtrigger_skim::brun(JEventLoop *locEventLoop, int32_t runnumber) +{ + dBeamCurrentFactory = new DBeamCurrent_factory(); + dBeamCurrentFactory->init(); + dBeamCurrentFactory->brun(locEventLoop, runnumber); + + return NOERROR; +} + +//------------------------------- +// evnt +//------------------------------- +jerror_t JEventProcessor_randomtrigger_skim::evnt(JEventLoop *locEventLoop, uint64_t eventnumber) +{ + // Get HDDM writer + vector locEventWriterHDDMVector; + locEventLoop->Get(locEventWriterHDDMVector); + + // beam current and fiducial definition + vector beamCurrent; + locEventLoop->Get(beamCurrent); + + //bool is_cosmic_trigger = false; + bool is_random_trigger = false; + + const DL1Trigger *trig = NULL; + try { + locEventLoop->GetSingle(trig); + } catch (...) {} + + // parse the triggers we want to save + if (trig) { + + if (trig->fp_trig_mask & 0x800) { // Trigger front-panel bit 11 + // Periodic pulser trigger fired + is_random_trigger = true; + } + + } + + // make sure this is a random trigger event + if(!is_random_trigger) + return NOERROR; + + // make sure we can perform a fiducial beam current cut + if(beamCurrent.empty()) + return NOERROR; + + // make sure the beam is on + if(!beamCurrent[0]->is_fiducial) + return NOERROR; + + + // Save events to skim file + locEventWriterHDDMVector[0]->Write_HDDMEvent(locEventLoop, "random"); + + return NOERROR; +} + +//------------------------------- +// erun +//------------------------------- +jerror_t JEventProcessor_randomtrigger_skim::erun(void) +{ + return NOERROR; +} + +//------------------------------- +// fini +//------------------------------- +jerror_t JEventProcessor_randomtrigger_skim::fini(void) +{ + return NOERROR; +} + diff --git a/src/plugins/Utilities/randomtrigger_skim/JEventProcessor_randomtrigger_skim.h b/src/plugins/Utilities/randomtrigger_skim/JEventProcessor_randomtrigger_skim.h new file mode 100644 index 000000000..5ee71fb61 --- /dev/null +++ b/src/plugins/Utilities/randomtrigger_skim/JEventProcessor_randomtrigger_skim.h @@ -0,0 +1,46 @@ +// +// File: JEventProcessor_randomtrigger_skim.h +// Created: Wed Nov 9 15:08:37 EDT 2014 +// Creator: Paul Mattione +// + +#ifndef _JEventProcessor_randomtrigger_skim_ +#define _JEventProcessor_randomtrigger_skim_ + +#include +#include + +#include +#include +#include +#include +#include + +#include "evio_writer/DEventWriterEVIO.h" + +#include "PID/DChargedTrack.h" +#include "DAQ/DEPICSvalue.h" + +#include "DAQ/DBeamCurrent.h" +#include "DAQ/DBeamCurrent_factory.h" + +using namespace std; +using namespace jana; + +class JEventProcessor_randomtrigger_skim : public jana::JEventProcessor +{ + public: + + jerror_t init(void); ///< Called once at program start. + jerror_t brun(JEventLoop *loop, int32_t runnumber); ///< Called everytime a new run number is detected. + jerror_t evnt(JEventLoop *loop, uint64_t eventnumber); ///< Called every event. + jerror_t erun(void); ///< Called everytime run number changes, provided brun has been called. + jerror_t fini(void); ///< Called after last event of last event source has been processed. + + private: + DBeamCurrent_factory *dBeamCurrentFactory; + +}; + +#endif // _JEventProcessor_randomtrigger_skim_ + diff --git a/src/plugins/Utilities/randomtrigger_skim/SConscript b/src/plugins/Utilities/randomtrigger_skim/SConscript new file mode 100644 index 000000000..3005e0e91 --- /dev/null +++ b/src/plugins/Utilities/randomtrigger_skim/SConscript @@ -0,0 +1,13 @@ + + +import sbms + +# get env object and clone it +Import('*') +env = env.Clone() + +sbms.AddDANA(env) +sbms.AddROOT(env) +sbms.plugin(env) + +