-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1032 from JeffersonLab/sdobbs_triggerskim
Add plugin to save random trigger events to HDDM
- Loading branch information
Showing
4 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
src/plugins/Utilities/randomtrigger_skim/JEventProcessor_randomtrigger_skim.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
46 changes: 46 additions & 0 deletions
46
src/plugins/Utilities/randomtrigger_skim/JEventProcessor_randomtrigger_skim.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|