#include <cstdlib>
#include "hadaq/TdcProcessor.h"
#include "hadaq/TrbProcessor.h"
#include "hadaq/HldProcessor.h"
#include "base/ProcMgr.h"
#include "custom.h"
void first()
{
hadaq::CustomProcessor *custom = new hadaq::CustomProcessor(trb3, 0x8143, 32);
const char* calname = getenv("CALNAME");
if ((calname==0) || (*calname==0)) calname = "test_";
const char* calmode = getenv("CALMODE");
int cnt = (calmode && *calmode) ? atoi(calmode) : 100000;
const char* caltrig = getenv("CALTRIG");
unsigned trig = (caltrig && *caltrig) ? atoi(caltrig) : 0xd;
const char* uset = getenv("USETEMP");
unsigned use_temp = 0;
if ((uset!=0) && (*uset!=0) && (strcmp(uset,"1")==0)) use_temp = 0x80000000;
printf("HLD configure calibration calfile:%s cnt:%d trig:%X temp:%X\n", calname, cnt, trig, use_temp);
}
{
printf("Called after all sub-components are created\n");
if (hld==0) return;
if (trb==0) continue;
printf(
"Configure %s!\n", trb->
GetName());
}
unsigned firsttdc = 0;
if (tdc==0) continue;
if (firsttdc == 0) firsttdc = tdc->
GetID();
printf(
"Configure %s!\n", tdc->
GetName());
for (int i=2;i<52;i++) {
}
if (tdc->
GetID() == 0x0507) {
}
}
}
void SetHistFilling(int lvl)
Set histogram fill level for all processors.
Definition: ProcMgr.cxx:103
void SetTriggeredAnalysis(bool on=true)
Enabled/disable triggered analysis is configured.
Definition: ProcMgr.h:192
static ProcMgr * instance()
Return global instance of processor manager, provided by framework.
Definition: ProcMgr.cxx:46
virtual void SetStoreKind(unsigned kind=1)
Set store kind for all processors.
Definition: ProcMgr.cxx:119
unsigned GetID() const
Get processor ID.
Definition: base/Processor.h:222
const char * GetName() const
Get processor name.
Definition: base/Processor.h:220
HLD processor.
Definition: HldProcessor.h:93
TdcProcessor * GetTDC(unsigned indx) const
Get TDC by index.
Definition: HldProcessor.cxx:122
TrbProcessor * GetTRB(unsigned indx) const
Get TRB by index.
Definition: HldProcessor.cxx:89
void ConfigureCalibration(const std::string &fileprefix, long period, unsigned trig=0xFFFF)
Configure calibration modes.
Definition: HldProcessor.cxx:159
unsigned NumberOfTDC() const
Return number of TDCs in all TRBs.
Definition: HldProcessor.cxx:111
unsigned NumberOfTRB() const
Return number of TRBs.
Definition: HldProcessor.cxx:81
TDC processor.
Definition: TdcProcessor.h:32
static void SetAllHistos(bool on=true)
Automatically create histograms for all channels - even they not appear in data.
Definition: TdcProcessor.cxx:76
void SetToTRange(double tot_0xd, double hmin, double hmax)
set real ToT value for 0xD trigger and min/max for histogram accumulation default is 30ns,...
Definition: TdcProcessor.cxx:437
static void SetTriggerDWindow(double low=-25, double high=50)
Configure window (in nanoseconds), where time stamps from 0xD trigger will be accepted for calibratio...
Definition: TdcProcessor.cxx:93
static void SetToTCalibr(int minstat=100, double rms=0.15)
Configure ToT calibration parameters.
Definition: TdcProcessor.cxx:104
static void SetDefaults(unsigned numfinebins=600, unsigned totrange=100, unsigned hist2dreduced=10)
Set default values for TDC creation.
Definition: TdcProcessor.cxx:57
void SetRefChannel(unsigned ch, unsigned refch, unsigned reftdc=0xffff, int npoints=5000, double left=-10., double right=10., bool twodim=false)
Set reference signal for the TDC channel ch.
Definition: TdcProcessor.cxx:516
void SetUseLastHit(bool on=true)
When enabled, last hit time in the channel used for reference time calculations By default,...
Definition: TdcProcessor.h:686
TRB processor.
Definition: TrbProcessor.h:46
static void SetHUBRange(unsigned min, unsigned max)
Define range for HUBs, used when auto mode is enabled.
Definition: TrbProcessor.h:285
void SetAutoCreate(bool on=true)
enable autocreation mode if necessary, works for single event
Definition: TrbProcessor.h:152
static void SetDefaults(unsigned numch=65, unsigned edges=0x1, bool ignore_sync=true)
Set defaults for the next creation of TDC processors.
Definition: TrbProcessor.cxx:35
void SetPrintErrors(int cnt=100)
Set number of errors which could be printed.
Definition: TrbProcessor.h:191
static void SetTDCRange(unsigned min, unsigned max)
Define range for TDCs, used when auto mode is enabled.
Definition: TrbProcessor.h:278
#ifndef CustomProcessor_h
#define CustomProcessor_h
#include "hadaq/SubProcessor.h"
namespace hadaq {
class TrbProcessor;
class CustomProcessor : public SubProcessor {
friend class TrbProcessor;
protected:
unsigned fNumChannels;
base::H1handle fChannels;
public:
CustomProcessor(TrbProcessor* trb, unsigned subid, unsigned numchannels = 33);
virtual ~CustomProcessor() {}
unsigned NumChannels() const { return fNumChannels; }
virtual bool SecondBufferScan(
const base::Buffer&) {
return true; }
};
}
hadaq::CustomProcessor::CustomProcessor(TrbProcessor* trb, unsigned subid, unsigned numchannels) :
hadaq::SubProcessor(trb, "CUST_%04X", subid),
fNumChannels(numchannels)
{
fChannels = MakeH1("CustomChannels", "Messages per channels", numchannels, 0, numchannels, "ch");
}
bool hadaq::CustomProcessor::FirstBufferScan(
const base::Buffer &buf)
{
uint32_t* arr = (uint32_t*) buf.
ptr();
for (unsigned n=0;n<len;n++) {
uint32_t data = arr[n];
unsigned chid = data & 0xff;
if (chid >= fNumChannels)
chid = chid % fNumChannels;
FillH1(fChannels, chid);
}
return true;
}
#endif
Memory management class.
Definition: Buffer.h:49
unsigned datalen() const
Returns length of memory buffer.
Definition: Buffer.h:81
void * ptr(unsigned shift=0) const
return pointer with shift
Definition: Buffer.h:87