Commit 6aca1a5b authored by dino's avatar dino
Browse files

Added an Ancillary-gamma matrix (64x256x2048) in TrackingFilter

The interval for cyclic writing of "local spectra" is now based on time (as derived
from the timestamp) by calling xxx.Exec(timestamp) while it is as before on number of events the method
is invoked without parameters.

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@820 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 4bee68e9
......@@ -637,7 +637,7 @@ void topologyPrint(int nchains)
// instantiation of objects and fine-grained re-classification of actors
bool topologyFactory()
{
NUMCHAINS = theChains.size();
NUMCHAINS = (int)theChains.size();
for(unsigned int nc = 0; nc < theChains.size(); nc++) {
chain * cc = theChains[nc];
......
......@@ -10,8 +10,8 @@
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory="F:\tdata\week27\Dante-4"
CommandArguments="Conf4/Topology.conf Conf4"
WorkingDirectory="E:\tdata\short_2"
CommandArguments="Conf/Topology.conf Conf"
Attach="false"
DebuggerType="3"
Remote="1"
......
......@@ -366,10 +366,10 @@ void EventBuilder::process_block( int ichain,
}
}
cServer.Exec();
cServer.Exec(tstKey1);
}
opos = 5; // where to start writing next event, relative to obuf
opos = 5; // where to start writing next event, relative to obuf
}
*used_osize = osiz*4 ;
......
......@@ -8,7 +8,7 @@
#include "nDhist.h"
#include "cycleServer.h"
const UInt_t dataSize = 2*1024*1024; // size of input queues
const UInt_t dataSize = 10*1024*1024; // size of input queues
const UInt_t maxHalfBuffs = 2; // max number of input half-buffers held in queue
const UInt_t maxErrors = 40; // max number "errors"
......
......@@ -71,7 +71,8 @@
const unsigned long long tst1second = 100000000;
// events after which to write spectra and perform cyclic checks
const unsigned int defaultCycle = 10000;
const unsigned int defaultCycleEvts = 10000;
const unsigned int defaultCycleTime = 100;
//const double RAD2DEG = 180./acos(-1.);
const double RAD2DEG = 57.29577951308232286464772187173366546630859375;
......@@ -140,7 +141,7 @@ const int defTriggerSample = 10; // 60-10 useful samples passed to the PS
//#define EXTENDED_OUTPUT // Oft_Hits contain also timestamp and eventnumber
//#define WRITE_TRACKED // Write the tracked gammas into the Oft_TrackedEnergies ascii file
#define TF_ROOTTREE
//#define TF_ROOTTREE
//////////////////////////
//////// WinCtest ////////
......
......@@ -57,7 +57,6 @@ void cycleServer::Prompt(int id, unsigned int nevs, unsigned int bsize)
unsigned int cycleServer::ExecLong()
{
unsigned int actions = 0;
if(!hGroup)
return actions;
......@@ -66,9 +65,10 @@ unsigned int cycleServer::ExecLong()
return actions; // to avoid useless re-writing
if( hGroup->write(true, false) ) {
sCount = mCount;
actions |= 1;
}
sCount = mCount;
tLast = tThis;
if( comFile.empty() )
return actions;
......@@ -80,4 +80,3 @@ unsigned int cycleServer::ExecLong()
return actions;
}
......@@ -62,26 +62,42 @@ class cycleServer
unsigned int rCount; // write spectra after rCount events
unsigned int mCount; // counter of analyzed events
unsigned int sCount; // mCount of last saved spectra
unsigned int tStep; // write spectra after tStep seconds (as derived from timestamp)
unsigned int tLast; // tst-seconds of last write
unsigned int tThis; // tst-seconds of this call
ratemeter mRate; // analysis-rate estimator
nDhistGroup *hGroup; // pointers of all defined nDhist spectra
std::string myName; // name of the actor, used in Prompt()
std::string comFile; // where to look for commands to spectrum-erase and change rCount
unsigned int ExecLong();
unsigned int ExecLong(); // actions performed when it is time dump spectra
bool CheckComFile(bool remove = false);
public:
cycleServer(unsigned int cycle = defaultCycle) :
rCount(cycle), mCount(0), sCount(0), hGroup(NULL) {}
cycleServer(unsigned int cycle = defaultCycleTime, bool isTime = true) : hGroup(NULL),
rCount(defaultCycleEvts), tStep(defaultCycleTime), mCount(0), sCount(0) {
rCount = isTime ? defaultCycleTime : defaultCycleEvts;
}
void SetHistGroup(nDhistGroup *hg) { hGroup = hg; }
void SetCycle(unsigned int cycle = defaultCycle) { rCount = cycle; }
void SetCycle(unsigned int cycle = defaultCycleEvts) { rCount = cycle; }
void SetCommandFile(std::string name) { comFile = name; }
void Start(nDhistGroup *hg, std::string name, unsigned int cycle = defaultCycle);
void Start(nDhistGroup *hg, std::string name, unsigned int cycle = defaultCycleEvts);
unsigned int Exec() {
if( ++mCount%rCount )
return 0;
return ExecLong();
}
unsigned int Exec(unsigned long long tstNew) {
++mCount;
tThis = (unsigned int)(tstNew/tst1second);
if(!tLast) {
tLast = tThis;
return 0;
}
if( (tThis - tLast) < tStep)
return 0;
return ExecLong();
}
void Finish() {
ExecLong();
if(hGroup)
......
......@@ -25,7 +25,8 @@ enum retValue {
EvNewFile = 2,
EvFinish = 4,
EvSkip = 8,
EvAgain = 16
EvAgain = 16,
EvReturn = 32
};
template<class T>
......
......@@ -135,7 +135,7 @@ public:
void setPadSize(unsigned int pd) {padSize = pd;}
unsigned int getPadSize() {
makePadString(0);
return padString.size();
return (unsigned int)padString.size();
}
bool write(bool erase = false, bool verbose = true) {
if(!initialized) {
......
......@@ -4,8 +4,10 @@
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <memory.h>
template <typename T>
class sAppend
{
......
......@@ -55,14 +55,14 @@ fTrigger("data:ranc0")
AncillaryFilter::~AncillaryFilter()
{
if(Converter) {
for(UInt_t nn = 0; nn < TotNumMod; nn++) {
if(Converter[nn].Value) delete [] Converter[nn].Value;
if(Converter[nn].Threshold) delete [] Converter[nn].Threshold;
if(Converter[nn].Offset) delete [] Converter[nn].Offset;
if(Converter[nn].Gain) delete [] Converter[nn].Gain;
}
delete [] Converter;
Converter = NULL;
//for(UInt_t nn = 0; nn < TotNumMod; nn++) {
// if(Converter[nn].Value) delete [] Converter[nn].Value;
// if(Converter[nn].Threshold) delete [] Converter[nn].Threshold;
// if(Converter[nn].Offset) delete [] Converter[nn].Offset;
// if(Converter[nn].Gain) delete [] Converter[nn].Gain;
// }
}
if(rawBuf)
......
......@@ -248,7 +248,7 @@ Int_t AncillaryFilterATCA::Process()
}
MakeSpectra();
cServer.Exec();
cServer.Exec(timestamp);
return 0;
}
......
......@@ -183,7 +183,7 @@ Int_t AncillaryFilterVME::Process()
#endif // AF_DANTE
cServer.Exec();
cServer.Exec(timestamp);
return 0;
}
......
......@@ -11,11 +11,12 @@ bool Converter_t::Setup(std::string name, EModule type, UInt_t crate, UInt_t slo
if(Threshold) delete [] Threshold;
if(Offset) delete [] Offset;
if(Gain) delete [] Gain;
Value = new Float_t[NumChan];
Threshold = new Float_t[NumChan];
Offset = new Float_t[NumChan];
Gain = new Float_t[NumChan];
for(UInt_t nn = 0; nn < NumChan; nn++) {
UInt_t nnnn = (NumChan > 0) ? NumChan : 1;
Value = new Float_t[nnnn];
Threshold = new Float_t[nnnn];
Offset = new Float_t[nnnn];
Gain = new Float_t[nnnn];
for(UInt_t nn = 0; nn < nnnn; nn++) {
Value[nn] = 0;
Threshold[nn] = 1;
Offset[nn] = 0;
......
......@@ -11,12 +11,18 @@ class Converter_t
public:
enum EModule { NONE, ADC, TDC, SCALER };
Converter_t() : Crate(0), Slot(0), NumChan(0), Type(NONE),
Value(NULL), Threshold(NULL), Offset(NULL), Gain(NULL) {;}
Converter_t() : Type(NONE), Crate(0), Slot(0), NumChan(0), Value(NULL),
Threshold(NULL), Offset(NULL), Gain(NULL) {;}
virtual ~Converter_t() {
if(Value) delete [] Value;
if(Threshold) delete [] Threshold;
if(Offset) delete [] Offset;
if(Gain) delete [] Gain;
}
bool Setup(std::string name, EModule type, UInt_t crate, UInt_t slot, UInt_t nchan);
void Clear() { memset(Value, 0, NumChan*sizeof(Float_t)); }
void Clear() { if(NumChan) memset(Value, 0, NumChan*sizeof(Float_t)); }
Float_t xValue(UInt_t chan) {
if(chan > NumChan || Value[chan] < Threshold[chan] )
if(chan >= NumChan || Value[chan] < Threshold[chan] )
return 0;
return Offset[chan] + Value[chan]*Gain[chan];
}
......
......@@ -172,7 +172,6 @@ Int_t PSAFilterGridSearch::AlgoSpecificInitialise()
//sigma->setComment ("chisquare");
//hGroup.add(sigma);
matPos = new nDhist<unsigned int>(2,10, matLen, matLen);
matPos->setFileName(fOdirPrefix+"Psa?XYZR.matr");
matPos->setComment("XY, XZ, YZ, rZ hits and XY hits as a function of Z");
......@@ -186,16 +185,6 @@ Int_t PSAFilterGridSearch::AlgoSpecificInitialise()
bDoSpec = specEner || tZero || sigma;
bDoMats = matPos || matSeg;
if(fWriteNumTraces > 0) {
std::ostringstream filename;
filename << "Psa__" << fWriteNumTraces << "-2-37-" << fTraceLengthPSA << "-S__Traces.samp";
fnPsaTraces = fOdirPrefix+filename.str();
cout << "Opening PSA traces file " << fnPsaTraces << endl;
fpPsaTraces = fopen(fnPsaTraces.c_str(), "wb");
memset(slot_fAmplitude, 0, sizeof(slot_fAmplitude)); // locally saved trace
memset(slot_rAmplitude, 0, sizeof(slot_rAmplitude)); // locally saved trace
}
#ifdef WRITE_PSA_HITS
cout << "Opening PSA hits file " << "Psa_Hits.txt" << endl;
fpPsaHits = fopen("Psa_Hits.txt", "w");
......@@ -211,6 +200,20 @@ Int_t PSAFilterGridSearch::AlgoSpecificInitialise()
// Limit the maximum number of fired segments
fPsaMaxSegMult = min(12, fPsaMaxSegMult);
if(fWriteNumTraces > 0) {
std::ostringstream filename;
filename << "Psa__" << fWriteNumTraces << "-2-37-" << fTraceLengthPSA << "-S__Traces.samp";
fnPsaTraces = fOdirPrefix+filename.str();
cout << "Opening PSA traces file " << fnPsaTraces << endl;
fpPsaTraces = fopen(fnPsaTraces.c_str(), "wb");
if(!fpPsaTraces) {
cout << "Error: could not open " << fnPsaTraces << endl;
return 1;
}
memset(slot_fAmplitude, 0, sizeof(slot_fAmplitude)); // locally saved trace
memset(slot_rAmplitude, 0, sizeof(slot_rAmplitude)); // locally saved trace
}
return 0;
}
......@@ -421,12 +424,15 @@ int PSAFilterGridSearch::WriteTraces(int slot)
{
// Twice NCHAN(=37) traces NTIME(=100) channels each: total event length is 7400 cannels
if(!fpPsaTraces)
return 0;
int rstat = 0;
int toWrite = NTIME;
size_t toWrite = NTIME;
if(NSAMP < toWrite) toWrite = NSAMP;
for(int ns = 0; ns < NCHAN; ns++) {
int nwritten = fwrite(&slot_fAmplitude[slot][ns*NTIME], sizeof(short), toWrite, fpPsaTraces);
size_t nwritten = fwrite(&slot_fAmplitude[slot][ns*NTIME], sizeof(short), toWrite, fpPsaTraces);
if(nwritten != toWrite) {
rstat = 1;
fWriteNumTraces = 1;
......@@ -435,7 +441,7 @@ int PSAFilterGridSearch::WriteTraces(int slot)
}
for(int ns = 0; ns < NCHAN; ns++) {
int nwritten = fwrite(&slot_rAmplitude[slot][ns*NTIME], sizeof(short), toWrite, fpPsaTraces);
size_t nwritten = fwrite(&slot_rAmplitude[slot][ns*NTIME], sizeof(short), toWrite, fpPsaTraces);
if(nwritten != toWrite) {
rstat = 1;
fWriteNumTraces = 1;
......@@ -445,9 +451,10 @@ int PSAFilterGridSearch::WriteTraces(int slot)
finish:
fWriteNumTraces--;
if(fWriteNumTraces <= 0) {
if(fWriteNumTraces < 1) {
cout << " Closing PSA traces file " << fnPsaTraces << endl;
fclose(fpPsaTraces);
fpPsaTraces = NULL;
}
return rstat;
......@@ -725,7 +732,7 @@ Int_t PSAFilterGridSearch::PostProcess(int slot)
// sigma->incr(sMult, isigma);
//}
cServer.Exec();
cServer.Exec(pD->timestamp);
#ifdef WRITE_PSA_HITS
// Francesco' s imaging format (check if still correct)
......@@ -742,6 +749,8 @@ Int_t PSAFilterGridSearch::PostProcess(int slot)
if(fWriteNumTraces > 0) {
int rv = WriteTraces(slot);
if(rv)
return rv;
}
return 0;
......
......@@ -83,7 +83,6 @@ public:
Float_t GetHitSegThreshold() {return fHitSegThreshold;}
int WriteTraces(int slot);
private:
// this is needed to have the possibility to write the traces in a thread-safe mode
short slot_fAmplitude[TCOUNT*TMODULO][NCHAN*NTIME]; // locally saved trace
......
......@@ -3,6 +3,7 @@
#include <cmath>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
......@@ -61,9 +62,9 @@ int SignalBasis::ReadBasis(std::string fname, bool keep)
return ReadBasisFormatVentu(ofp1, keep);
}
else if (!bVentu && bBartB) {
int numSignals = fSize/sizeof(bbhit_t);
size_t numSignals = fSize/sizeof(bbhit_t);
printf("Reading Bart\'s basis containing %d signals ...\n", numSignals);
return ReadBasisFormatBartB(ofp1, keep, numSignals);
return ReadBasisFormatBartB(ofp1, keep, (int)numSignals);
}
else {
printf("Cannot decide format of signal basis\n");
......
......@@ -27,7 +27,7 @@ const unsigned int cfdDelay2 = 9;
PreprocessingFilterPSA::PreprocessingFilterPSA() :
PrepSpec_Ener(NULL), PrepSpec_Esum(NULL),
matrEE(NULL), matrSS(NULL), matrET(NULL), matrTT1(NULL), matrTT2(NULL), matrXT(NULL),
specTT1(NULL), specTT2(NULL)
specTT1(NULL), specTT2(NULL), fpPrepTraces(NULL)
{
ccE1 = 0;
ccE2 = 0;
......@@ -228,7 +228,7 @@ Int_t PreprocessingFilterPSA::Process()
return rv;
}
cServer.Exec();
cServer.Exec(timestamp);
return 0;
}
......@@ -238,11 +238,28 @@ int PreprocessingFilterPSA::WriteTraces()
// to be adjusted (to float ?) when the rescaling will be removed
// 42 traces 160 channels each: total event length is of 6720 cannels
// Opening the file must be done here because in AlgoSpecificInitialize fTraceLengthRaw
// is not yet set to the actual value as obtained form the data itself
if(fWriteNumTraces>0 && fpPrepTraces==NULL) {
std::ostringstream filename;
filename << "Prep__" << fWriteNumTraces << "-42-" << fTraceLengthRaw << "-S__Traces.samp";
fnPrepTraces = fOdirPrefix+filename.str();
cout << "Opening Preprocessing traces file " << fnPrepTraces << endl;
fpPrepTraces = fopen(fnPrepTraces.c_str(), "wb");
if(!fpPrepTraces) {
cout << "Error: could not open " << fnPrepTraces << endl;
return 1;
}
}
if(!fpPrepTraces)
return 0;
UShort_t ss[defTraceLengthRaw];
UShort_t ee[defTraceLengthRaw];
memset(ss, 0, sizeof(ss));
memset(ee, 0, sizeof(ee));
UInt_t nwritten = 0;
size_t nwritten = 0;
// segments
for(UInt_t nn = 0; nn < CrystalInterface::kNbSegments; nn++) {
UShort_t *ps = ss;
......@@ -270,19 +287,25 @@ int PreprocessingFilterPSA::WriteTraces()
ee[CrystalInterface::kNbSegments+CrystalInterface::kNbCores ] = crystal_id;
ee[CrystalInterface::kNbSegments+CrystalInterface::kNbCores+1] = 1000*crystal_status;
CopyEventTags((unsigned short *)(ee+CrystalInterface::kNbSegments+CrystalInterface::kNbCores+2));
// energies, id, status, eventnumber and timestamp
nwritten = fwrite(ee, sizeof(short), fTraceLengthRaw, fpPrepTraces);
if(nwritten != fTraceLengthRaw)
return 1;
// TFA and CFD recalculated from
// extra stuff
// TFA
GetTimingTraces((short *)uTracesCC[CC.itrig]);
nwritten = fwrite(sTFA, sizeof(short), fTraceLengthRaw, fpPrepTraces); // !!!!!!!!!!!!!!
if(nwritten != fTraceLengthRaw)
return 1;
// CFD recalculated from
nwritten = fwrite(sCFD, sizeof(short), fTraceLengthRaw, fpPrepTraces);
if(nwritten != fTraceLengthRaw)
return 1;
// empty one to have a "round" number
// energies, id, status, eventnumber and timestamp
nwritten = fwrite(ee, sizeof(short), fTraceLengthRaw, fpPrepTraces);
if(nwritten != fTraceLengthRaw)
return 1;
// empty trace to have a "round" (6 x 7) number
memset(ee, 0, sizeof(ee));
nwritten = fwrite(ee, sizeof(short), fTraceLengthRaw, fpPrepTraces);
if(nwritten != fTraceLengthRaw)
......@@ -290,9 +313,10 @@ int PreprocessingFilterPSA::WriteTraces()
fWriteNumTraces--;
if(fWriteNumTraces <= 0) {
if(fWriteNumTraces < 1) {
cout << " Closing Preprocessing traces file " << fnPrepTraces << endl;
fclose(fpPrepTraces);
fpPrepTraces = NULL;
}
return 0;
......@@ -374,14 +398,6 @@ bool PreprocessingFilterPSA::initPresort()
//PrepSpec_Esum->setComment("sum energy of segments before and after xTalk correction");
//hGroup.add(PrepSpec_Esum);
if(fWriteNumTraces > 0) {
std::ostringstream filename;
filename << "Prep__" << fWriteNumTraces << "-42-" << fTraceLengthRaw << "-S__Traces.samp";
fnPrepTraces = fOdirPrefix+filename.str();
cout << "Opening Preprocessing traces file " << fnPrepTraces << endl;
fpPrepTraces = fopen(fnPrepTraces.c_str(), "wb");
}
return true;
}
......
......@@ -105,6 +105,7 @@ fFrameRaw(NULL)
OftSpec_TZ = NULL;
OftSpec_EA = NULL;
OftSpec_TA = NULL;
OftSpec_AG = NULL;
#endif
RecoilVc = 0;
......@@ -477,7 +478,7 @@ Int_t TrackingFilter::Process()
{
//cout << "WARNING!! Empty TrackingFilter::Process()" << endl;
cServer.SetCycle(0xFFFFFFFF); // to avoid writing empty spectra
cServer.Exec();
cServer.Exec(timestamp);
return 0;
}
......@@ -544,7 +545,7 @@ UInt_t TrackingFilter::ProcessBlock(ADF::FrameBlock &in, ADF::FrameBlock &out)
continue;
}
else {
cServer.Exec();
cServer.Exec(timestamp);
}
// fill the output buffer
......@@ -769,6 +770,17 @@ bool TrackingFilter::AnalysisGeAncillary()
OftSpec_EA->Incr(1, ii1, eG); // coinc. energy of the core
if( rVc )
OftSpec_EE->Incr(1, eG); // total energy spectrum
if(OftSpec_AG) {
eG = int(cryst[nn1].CCE0/2.f); // fixed gain 2 keV/chan
if(eG > 0 && eG < 2048) {
int nnmx = OftSpec_AG->getLenSpec(0);
for(int nns = 0; nns < nnmx; nns++) {
if(rawBuf[nns] > 200 && rawBuf[nns] < 4000) { // to be adjusted with sensible limits
OftSpec_AG->Incr(nns, int(rawBuf[nns]/16.f), eG);
}
}
}
}
}
#endif
}
......@@ -1200,6 +1212,11 @@ void TrackingFilter::InitGenStructures()
OftSpec_TA->setComment("Difference of tstamps between crystals and ancillary");
hGroup.add(OftSpec_TA);
OftSpec_AG = new nDhist<unsigned short>(64, 256, 2048);
OftSpec_AG->setFileName(fOdirPrefix+"Oft?AG.matr");
OftSpec_AG->setComment("num-Eanc-Egamma");
hGroup.add(OftSpec_AG);
#endif //#ifdef LOCALSPECTRA
// for Doppler correction
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment