-
Notifications
You must be signed in to change notification settings - Fork 9
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 #772 from JeffersonLab/helicity_tools
Helicity tools
- Loading branch information
Showing
20 changed files
with
1,442 additions
and
5 deletions.
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
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,37 @@ | ||
// $Id$ | ||
// | ||
// File: DBeamHelicity.h | ||
// | ||
|
||
#ifndef _DBeamHelicity_ | ||
#define _DBeamHelicity_ | ||
|
||
#include <JANA/JObject.h> | ||
#include <JANA/JFactory.h> | ||
|
||
class DBeamHelicity:public jana::JObject{ | ||
public: | ||
JOBJECT_PUBLIC(DBeamHelicity); | ||
|
||
// Need to add notes on meanings (Mark?) | ||
bool pattern_sync; | ||
bool t_settle; | ||
bool helicity; | ||
bool pair_sync; | ||
bool ihwp; // from EPICS variable (0=IN and 1=OUT) | ||
bool beam_on; // from EPICS variable (0=OFF and 1=ON) | ||
|
||
// This method is used primarily for pretty printing | ||
// the second argument to AddString is printf style format | ||
void toStrings(vector<pair<string,string> > &items)const{ | ||
AddString(items, "pattern sync", "%d", pattern_sync); | ||
AddString(items, "t_settle", "%d", t_settle); | ||
AddString(items, "helicity", "%d", helicity); | ||
AddString(items, "pair_sync", "%d", pair_sync); | ||
AddString(items, "ihwp", "%d", ihwp); | ||
AddString(items, "beam_on", "%d", beam_on); | ||
} | ||
}; | ||
|
||
#endif // _DBeamHelicity_ | ||
|
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,123 @@ | ||
// $Id$ | ||
// | ||
// File: DBeamHelicity_factory.cc | ||
// | ||
|
||
#include <iostream> | ||
#include <iomanip> | ||
#include <algorithm> | ||
#include <cmath> | ||
#include <mutex> | ||
using namespace std; | ||
|
||
#include <DANA/DStatusBits.h> | ||
#include <DAQ/DCODAEventInfo.h> | ||
#include <DAQ/DCODAROCInfo.h> | ||
#include <DAQ/DHELIDigiHit.h> | ||
#include <DAQ/DEPICSvalue.h> | ||
#include "DBeamHelicity_factory.h" | ||
using namespace jana; | ||
|
||
//init static class variable | ||
int DBeamHelicity_factory::dIHWP = 0; | ||
int DBeamHelicity_factory::dBeamOn = 1; | ||
|
||
//------------------ | ||
// init | ||
//------------------ | ||
jerror_t DBeamHelicity_factory::init(void) | ||
{ | ||
|
||
return NOERROR; | ||
} | ||
|
||
//------------------ | ||
// brun | ||
//------------------ | ||
jerror_t DBeamHelicity_factory::brun(jana::JEventLoop *loop, int32_t runnumber) | ||
{ | ||
|
||
// Grab information from CCDB tables here | ||
|
||
// Constants for determined helicity pattern (from Ken) | ||
|
||
// Half Waveplate status at run start (could be from RCDB?) | ||
|
||
return NOERROR; | ||
} | ||
|
||
//------------------ | ||
// evnt | ||
//------------------ | ||
jerror_t DBeamHelicity_factory::evnt(JEventLoop *loop, uint64_t eventnumber){ | ||
double beamcurr = 0.0; | ||
double beamthresh = 10.0; | ||
|
||
// get info from EPICS variables | ||
vector<const DEPICSvalue*> epicsvalues; | ||
loop->Get(epicsvalues); | ||
bool isEPICS = loop->GetJEvent().GetStatusBit(kSTATUS_EPICS_EVENT); | ||
|
||
//kl I don't thing this works. Each thread has a separate instance of the factory, so these values only get set in the thread which | ||
//processed the EPICS event. Locking doesn't help. Worry about this lated when everything is moved into a factory. | ||
if(isEPICS) { | ||
for(vector<const DEPICSvalue*>::const_iterator val_itr = epicsvalues.begin(); val_itr != epicsvalues.end(); val_itr++) { | ||
const DEPICSvalue* epics_val = *val_itr; | ||
if(epics_val->name == "IGL1I00DI24_24M"){ | ||
dIHWP = atoi(epics_val->sval.c_str()); | ||
} | ||
if(epics_val->name == "IBCAD00CRCUR6"){ | ||
beamcurr = atof(epics_val->sval.c_str()); | ||
if(beamcurr > beamthresh) dBeamOn = 1; | ||
else dBeamOn = 0; | ||
std::cout << "Got IBCAD00CRCUR6 = " << beamcurr << ". Setting dBeamOn = " << dBeamOn << "Event = "<< eventnumber << endl; | ||
} | ||
} | ||
return NOERROR; | ||
} | ||
|
||
// get helicity bits from fADC | ||
vector<const DHELIDigiHit*> locHELIDigiHits; | ||
loop->Get(locHELIDigiHits); | ||
if(locHELIDigiHits.empty()) return NOERROR; | ||
|
||
DBeamHelicity *locBeamHelicity = new DBeamHelicity; | ||
locBeamHelicity->pattern_sync = 0; | ||
locBeamHelicity->t_settle = 0; | ||
locBeamHelicity->helicity = 0; | ||
locBeamHelicity->pair_sync = 0; | ||
locBeamHelicity->ihwp = dIHWP; | ||
locBeamHelicity->beam_on = dBeamOn; | ||
|
||
for(size_t loc_i=0; loc_i<locHELIDigiHits.size(); loc_i++) { | ||
|
||
const DHELIDigiHit *locHELIDigiHit = locHELIDigiHits[loc_i]; | ||
|
||
if(locHELIDigiHit->pulse_integral < 1000) continue; // threshold for signal | ||
|
||
if(locHELIDigiHit->chan == 0) locBeamHelicity->pattern_sync = 1; | ||
if(locHELIDigiHit->chan == 1) locBeamHelicity->t_settle = 1; | ||
if(locHELIDigiHit->chan == 2) locBeamHelicity->helicity = 1; | ||
if(locHELIDigiHit->chan == 3) locBeamHelicity->pair_sync = 1; | ||
} | ||
|
||
_data.push_back(locBeamHelicity); | ||
|
||
return NOERROR; | ||
} | ||
|
||
//------------------ | ||
// erun | ||
//------------------ | ||
jerror_t DBeamHelicity_factory::erun(void) | ||
{ | ||
return NOERROR; | ||
} | ||
|
||
//------------------ | ||
// fini | ||
//------------------ | ||
jerror_t DBeamHelicity_factory::fini(void) | ||
{ | ||
return NOERROR; | ||
} |
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,28 @@ | ||
// $Id$ | ||
// | ||
// File: DBeamHelicity_factory.h | ||
// | ||
|
||
#ifndef _DBeamHelicity_factory_ | ||
#define _DBeamHelicity_factory_ | ||
|
||
#include <JANA/JFactory.h> | ||
#include "DBeamHelicity.h" | ||
|
||
class DBeamHelicity_factory:public jana::JFactory<DBeamHelicity>{ | ||
public: | ||
DBeamHelicity_factory(){}; | ||
~DBeamHelicity_factory(){}; | ||
|
||
static int dIHWP; | ||
static int dBeamOn; | ||
|
||
jerror_t init(void); ///< Called once at program start. | ||
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber); ///< Called everytime a new run number is detected. | ||
jerror_t evnt(jana::JEventLoop *eventLoop, 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. | ||
}; | ||
|
||
#endif // _DBeamHelicity_factory_ | ||
|
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,38 @@ | ||
#ifndef _DHELIDigiHit_ | ||
#define _DHELIDigiHit_ | ||
|
||
#include <JANA/JObject.h> | ||
#include <JANA/JFactory.h> | ||
|
||
class DHELIDigiHit:public jana::JObject{ | ||
public: | ||
JOBJECT_PUBLIC(DHELIDigiHit); | ||
|
||
int chan; ///< channel number 0-3 | ||
uint32_t pulse_integral; ///< identified pulse integral as returned by FPGA algorithm | ||
uint32_t pulse_time; ///< identified pulse time as returned by FPGA algorithm | ||
uint32_t pedestal; ///< pedestal info used by FPGA (if any) | ||
uint32_t QF; ///< Quality Factor from FPGA algorithms | ||
uint32_t nsamples_integral; ///< number of samples used in integral | ||
uint32_t nsamples_pedestal; ///< number of samples used in pedestal | ||
uint32_t pulse_peak; ///< maximum sample in pulse | ||
|
||
uint32_t datasource; ///< 0=window raw data, 1=old(pre-Fall16) firmware, 2=Df250PulseData | ||
|
||
// This method is used primarily for pretty printing | ||
// the second argument to AddString is printf style format | ||
void toStrings(vector<pair<string,string> > &items)const{ | ||
AddString(items, "chan", "%d", chan); | ||
AddString(items, "pulse_integral", "%d", pulse_integral); | ||
AddString(items, "pulse_peak", "%d", pulse_peak); | ||
AddString(items, "pulse_time", "%d", pulse_time); | ||
AddString(items, "pedestal", "%d", pedestal); | ||
AddString(items, "QF", "%d", QF); | ||
AddString(items, "nsamples_integral", "%d", nsamples_integral); | ||
AddString(items, "nsamples_pedestal", "%d", nsamples_pedestal); | ||
} | ||
|
||
}; | ||
|
||
#endif // _DHELIDigiHit_ | ||
|
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
Oops, something went wrong.