Skip to content

Commit

Permalink
Add plugin to save random trigger events to HDDM
Browse files Browse the repository at this point in the history
  • Loading branch information
sdobbs committed Jan 16, 2018
1 parent b0f648a commit dc75b53
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugins/Utilities/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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 <HDDM/DEventWriterHDDM.h>
#include <DAQ/DBeamCurrent.h>

// 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<const DEventWriterHDDM*> locEventWriterHDDMVector;
locEventLoop->Get(locEventWriterHDDMVector);

// beam current and fiducial definition
vector<const DBeamCurrent*> 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;
}

Original file line number Diff line number Diff line change
@@ -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 <string>
#include <vector>

#include <JANA/JEventProcessor.h>
#include <JANA/JEventLoop.h>
#include <JANA/JApplication.h>
#include <JANA/JEventSource.h>
#include <JANA/JEvent.h>

#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_

13 changes: 13 additions & 0 deletions src/plugins/Utilities/randomtrigger_skim/SConscript
Original file line number Diff line number Diff line change
@@ -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)


0 comments on commit dc75b53

Please sign in to comment.