Commit 29fb21a8 authored by dino's avatar dino
Browse files

PostPsaFilter can produce the distribution of timestamps; various changes in the "LOCALSPECTRA"

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1137 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 0e300999
......@@ -285,8 +285,11 @@
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\PRISMA\src\lib_prisma\include;"C:\Program Files (x86)\boost\boost_1_40";..\common;..\producers\Crystal;..\producers\Crystal\includeATCA;..\producers\AncillaryTCP;..\filters\Preprocessing;..\filters\Preprocessing\includePrePSA;..\filters\Ancillary;..\filters\Ancillary\includeVME;..\filters\PSA;..\filters\PSA\includePSA;..\filters\Tracking;..\filters\Tracking\includeOFT;..\filters\Tracking\includeMGT;..\builders;C:\root\include;..\filters\PostPSA;..\filters\Global;..\..\include"
PreprocessorDefinitions="WIN64;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;NRV_TYPE=NRV_OFFLINE"
ExceptionHandling="1"
RuntimeLibrary="2"
BufferSecurityCheck="false"
EnableFunctionLevelLinking="true"
DisableLanguageExtensions="false"
UsePrecompiledHeader="0"
WarningLevel="3"
WarnAsError="true"
......
......@@ -649,13 +649,15 @@ Int_t AncillaryFilter::SetInput()
ADF::RawFrame *frame_in = dynamic_cast<ADF::RawFrame *> (fFrameRaw_In->GetFrame());
UInt_t lenChar = frame_in->Read(); // length of the data buffer in bytes
if(lenChar > rawBufSize*sizeof(UInt_t) ) {
//if(lenChar > rawBufSize*sizeof(UInt_t) ) {
if(lenChar != rawBufSize*sizeof(UInt_t) ) {
if(rawBuf)
delete [] rawBuf;
rawBufSize = (lenChar+3)/sizeof(UInt_t);
rawBuf = new UInt_t[rawBufSize];
memset(rawBuf, 0, rawBufSize*sizeof(UInt_t));
}
memset(rawBuf, 0, rawBufSize*sizeof(UInt_t));
frame_in->RawBuffer().Export((Char_t*)rawBuf, lenChar);
......
......@@ -1194,7 +1194,7 @@ void GlobalFilter::GetParameters(UInt_t *error_code)
ok = 2 == sscanf(data.c_str(), "%d %f", &fSizeMatr_gg2, &fGainMatr_gg2);
KEND;
KPAR("Details", "", "list input events in symbolic form (very slow and incompletee)");
KPAR("Details", "", "list input events in symbolic form (very slow and incomplete)");
fDebug = true;
ok = true;
KEND;
......
......@@ -2553,7 +2553,7 @@ Int_t PSAFilterGridSearch::AlgoSpecificPostProcess(int slot)
float rr = sqrt(fx*fx + fy*fy);
// positions inside the crystal
if(PsaMatrXYZR || PsaMatrSeg ||PsaMatrXYZ) {
incrPosMats(-1, 0, fx, fy, fz, rr); // PsaMatrXYZ
incrPosMats(-((netChSeg%6)+1), 0, fx, fy, fz, rr); // PsaMatrXYZ
if(pOut->enerSG >= lowSegEnergy) { // not too-low energy
incrPosMats(netChSeg, 0, fx, fy, fz, rr); // 0 --> all hits
if(nh < numXYZ-3)
......@@ -2634,12 +2634,15 @@ void PSAFilterGridSearch::incrPosMats(int netChSeg, int nhi, float fx, float fy,
if(netChSeg < 0) {
if(PsaMatrXYZ) {
int slice90 = 90 - netChSeg; // negative value passed is -((netChSeg%6)+1
PsaMatrXYZ->Incr(0, 0, xAddrU(fx), yAddrU(fy) ); // total projection
PsaMatrXYZ->Incr(0, zAddrU(fz), xAddrU(fx), yAddrU(fy) );
PsaMatrXYZ->Incr(1, 0, xAddrU(fx), zAddrU(fz) );
PsaMatrXYZ->Incr(0, slice90, xAddrU(fx), yAddrU(fy) );
PsaMatrXYZ->Incr(0, zAddrU(fz), xAddrU(fx), yAddrU(fy) ); // the slices in 91...96
PsaMatrXYZ->Incr(1, 0, xAddrU(fx), zAddrU(fz) ); // total projection
PsaMatrXYZ->Incr(1, yAddrU(fy), xAddrU(fx), zAddrU(fz) );
PsaMatrXYZ->Incr(2, 0, yAddrU(fy), zAddrU(fz) );
PsaMatrXYZ->Incr(2, 0, yAddrU(fy), zAddrU(fz) ); // total projection
PsaMatrXYZ->Incr(2, xAddrU(fx), yAddrU(fy), zAddrU(fz) );
}
return;
}
......
......@@ -72,6 +72,10 @@ PostPSAFilter::PostPSAFilter() :
fPostAccepted = true;
fNewCrystalID = -1; // no change
bWriteTstampDiff = false;
sTstampDiff = NULL;
tStampOld = 0;
fUseMultiHist = true;
#ifdef PSA_MULTIHIST
PostSpecEner = NULL; PostMatrXYZ = NULL; PostMatrRZE = NULL;
......@@ -80,6 +84,9 @@ PostPSAFilter::PostPSAFilter() :
PostPSAFilter::~PostPSAFilter()
{
if(bWriteTstampDiff && sTstampDiff)
delete sTstampDiff;
sTstampDiff = NULL;
}
void PostPSAFilter::process_config(const Char_t *directory_path, UInt_t *error_code)
......@@ -202,6 +209,10 @@ void PostPSAFilter::process_initialise (UInt_t *error_code)
cServer.SetCommandFile(GetConfPath() + gMotherClass + ".live");
if(bWriteTstampDiff) {
sTstampDiff = new sAppend<UInt_t>(fOdirPrefix+"PSA__0-2048-UI__tstdiff.bdat", 2048);
}
#ifdef PPS_MULTIHIST
if(fUseMultiHist) {
PostSpecEner = new MultiHist<unsigned int>(4, 40, specLenE);
......@@ -347,6 +358,11 @@ void PostPSAFilter::GetParameters(UInt_t *error_code)
ok = 1 == sscanf(data.c_str(), "%f", &fEnergyGain);
KEND;
KPAR("WriteTstampDiff", "", "Write list-mode of time stamp difference");
bWriteTstampDiff = true;
ok = true;
KEND;
KPAR("NoMultiHist", "", "exclude flat binary spectra");
fUseMultiHist = false;
ok = true;
......@@ -597,6 +613,26 @@ Int_t PostPSAFilter::Process()
}
}
if(bWriteTstampDiff) {
if(tStampOld == 0) {
#if 1
// seconds and fraction of seconds of first timestamp, assuming 100 Ms/s
sTstampDiff->add(UInt_t(timestamp/100000000));
sTstampDiff->add(UInt_t(timestamp-100000000*(timestamp/100000000)));
#else
// time stamp of first event, written in little endian
sTstampDiff->add(UInt_t(timestamp & 0xFFFFFFFF));
sTstampDiff->add(UInt_t(timestamp >> 32));
#endif
}
else {
ULong64_t tstdiff = timestamp - tStampOld;
sTstampDiff->add(UInt_t(tstdiff & 0xFFFFFFFF));
}
}
tStampOld = timestamp;
#ifdef PPS_MULTIHIST
if(PostSpecEner) {
const int NSEGS = ADF::CrystalInterface::kNbSegments; // 36
......@@ -649,11 +685,13 @@ Int_t PostPSAFilter::Process()
float fx = pLoc->fx;
float fy = pLoc->fy;
float fz = pLoc->fz;
int slice90 = 91 + (pLoc->Sg%6);
PostMatrXYZ->Incr(0, 0, xAddrU(fx), yAddrU(fy) ); // total projection
PostMatrXYZ->Incr(0, zAddrU(fz), xAddrU(fx), yAddrU(fy) );
PostMatrXYZ->Incr(1, 0, xAddrU(fx), zAddrU(fz) );
PostMatrXYZ->Incr(0, slice90, xAddrU(fx), yAddrU(fy) ); // the 6 slices in 91...96
PostMatrXYZ->Incr(1, 0, xAddrU(fx), zAddrU(fz) ); // total projection
PostMatrXYZ->Incr(1, yAddrU(fy), xAddrU(fx), zAddrU(fz) );
PostMatrXYZ->Incr(2, 0, yAddrU(fy), zAddrU(fz) );
PostMatrXYZ->Incr(2, 0, yAddrU(fy), zAddrU(fz) ); // total projection
PostMatrXYZ->Incr(2, xAddrU(fx), yAddrU(fy), zAddrU(fz) );
}
}
......@@ -707,16 +745,17 @@ Int_t PostPSAFilter::Process()
// Move the integer part of the trace position to the timestamp, removing most of the
// time-walk due to the use of a LE trigger in the preprocessing elctronics.
// CoreT[0] holds the fractional part; CoreT[1] is left unchanged for control purposes
const float T0 = 40.f; // final position of data
float tpos = CoreT[0] - T0 ; // in samples
const float T0 = 40.f; // final position of data (samples)
const int TS = 1; // scale time units
float tpos = (CoreT[0] - T0)*TS ; // in samples
if(tpos >= 0) {
int itst = int(tpos + 0.5f);
timestamp += itst;
timestamp = TS*timestamp + itst;
tpos -= itst;
}
else {
int itst = int(-tpos + 0.5f);
timestamp -= itst;
timestamp = TS*timestamp - itst;
tpos += itst;
}
CoreT[0] = tpos + T0; // no change to CoreT[1]
......
......@@ -18,7 +18,7 @@
# include "MultiHist.h"
#endif
#include "cycleServer.h"
#include "sAppend.h"
#include "adetParams.h"
#include <ctime>
......@@ -66,6 +66,9 @@ protected:
// to test how to add anonymous parameters
//ADF::Anonymous myAno;
Bool_t bWriteTstampDiff;
sAppend<UInt_t> *sTstampDiff;
unsigned long long tStampOld; // to build the time-stamp difference, managed by Process()
bool fUseMultiHist;
#ifdef PPS_MULTIHIST
......
......@@ -115,12 +115,9 @@ public:
MultiHist<unsigned short> *PreMatrEcTc;
MultiHist<unsigned short> *PreMatrEsTs;
MultiHist<unsigned short> *PreMatrEeTr;
MultiHist<unsigned short> *PreMatrTT1;
MultiHist<unsigned short> *PreMatrTT2;
MultiHist<unsigned short> *PreMatrTT3;
MultiHist<unsigned short> *PreMatrTT;
MultiHist<unsigned short> *PreMatrXT;
MultiHist<unsigned int > *PreSpecTT1;
MultiHist<unsigned int > *PreSpecTT2;
MultiHist<unsigned int > *PreSpecTT;
MultiHist<unsigned int > *PreSpecExtalk;
MultiHist<unsigned short> *PreMatrExtalk;
#endif //PPF_MULTIHIST
......@@ -176,9 +173,8 @@ public:
void calcEEmatrix (float *eSg, float *eCc, float **sSg, float **sCc);
void calcSSmatrix (float *ee);
void calcXTmatrix (float *pSG_Ener);
void calcTT (float tRefCC, MultiHist<unsigned int> *pSecTT, MultiHist<unsigned short> *matrTT, MultiHist<unsigned short> *matrETsg);
void calcTTPulser (float tRefCC, MultiHist<unsigned int> *pSecTT, MultiHist<unsigned short> *matrTT, MultiHist<unsigned short> *matrETsg);
void CheckTiming (float *data);
void calcTT (float tRefCC, int ss0, int ss1, int sm0, bool bEsTs);
void calcTTPulser (float tRefCC, int ss0, int ss1, int sm0, bool bEsTs);
void calcRiseTime ();
float FindRiseTime (float *data);
void CoreEnergyFromXtalk (int segMult);
......
......@@ -1556,7 +1556,7 @@ void TrackingFilter::GetParameters(UInt_t *error_code)
ok = 2 == sscanf(data.c_str(), "%d %f", &fSizeMatr_gg2, &fGainMatr_gg2);
KEND;
KPAR("Details", "", "list input events in symbolic form (very slow and incompletee)");
KPAR("Details", "", "list input events in symbolic form (very slow and incomplete)");
fDetails = true;
ok = true;
KEND;
......@@ -1701,12 +1701,12 @@ void TrackingFilter::InitGenStructures()
TrackSpec_TS = new MultiHist<unsigned int>(fNumGeDets, fNumGeDets, specLenT1);
TrackSpec_TS->setFileName(fOdirPrefix+"Track?TS.spec");
TrackSpec_TS->setComment("T_gamma-gamma from timestamp (samples)");
TrackSpec_TS->setComment("T_crystal-T_crystal from timestamp (samples)");
hGroup.add(TrackSpec_TS);
TrackSpec_TT = new MultiHist<unsigned int>(fNumGeDets, fNumGeDets, specLenT1);
TrackSpec_TT->setFileName(fOdirPrefix+"Track?TT.spec");
TrackSpec_TT->setComment("T_gamma-gamma from CFD (ns)");
TrackSpec_TT->setComment("T_crystal-T_crystal (ns)");
hGroup.add(TrackSpec_TT);
TrackSpec_TG = new MultiHist<unsigned int>(2, 4*specLenT1);
......@@ -2078,7 +2078,7 @@ int TrackingFilter::PostProcessEvent()
eSumTracked += pg->E;
if(hasRecoil) {
TrackSpec_EE->Incr(1, 2, int(fEnergyGain*pg->E)); // 1-2 Tracked in coinc with ancillary
TrackSpec_EE->Incr(1, 2 + pg->type, int(fEnergyGain*pg->E)); // 0-3 Photo=1 0-4 Compt=2 0-5 pair=3
TrackSpec_EE->Incr(1, 2 + pg->type, int(fEnergyGain*pg->E)); // 1-3 Photo=1 1-4 Compt=2 1-5 pair=3
eSumTrackedA += pg->E;
}
}
......@@ -2207,9 +2207,9 @@ bool TrackingFilter::AnalysisOfCrystals()
}
}
if(TrackSpec_EE) {
TrackSpec_EE->Incr(0, 8, int(fEnergyGain*esumCC));
TrackSpec_EE->Incr(0, 8, int(fEnergyGain*esumCC)); // 0-8 input sum energy
if(number_of_crystals==1)
TrackSpec_EE->Incr(0, 9, int(fEnergyGain*esumCC));
TrackSpec_EE->Incr(0, 9, int(fEnergyGain*esumCC)); // 0-9 input single detector
}
if(TrackSpec_ES && number_of_crystals > 0 && number_of_crystals < fNumGeDets) {
TrackSpec_ES->Incr(0, 0, int(esumCC)); // total sum energy
......
......@@ -182,7 +182,7 @@ protected:
MultiHist<unsigned short> *TrackMatr_AG; // ind-anc-gamma for the ancillary detector
MultiHist<unsigned short> *TrackSpec_TTA; // ind-anc-Tgamma for the ancillary detector
MultiHist<unsigned short> *TrackMatr_ETA; // ind-anc-Tgamma for the ancillary detector
MultiHist<unsigned short> *TrackMatr_gg1; // gamma-time(cc-anc)
MultiHist<unsigned short> *TrackMatr_gg1; // gamma-gamma of input data (crystal-crystal)
MultiHist<unsigned short> *TrackMatr_gg2; // gamma-gamma of tracked and doppler corrected data data
MultiHist<unsigned short> *TrackMatr_ETC; // gamma-trigger
MultiHist<unsigned short> *TrackMatr_SGSG; // SG-SG counts for all pairs
......
......@@ -2,7 +2,7 @@
#include "mgt_externals.h"
#define PHOTODIST 40. // min. distance (mm) from other points to accept photoelectric effect
#define PHOTOFACT 1. // scale factor for chi2 of photoelectric effect (also to consider /dist_dd)
#define PHOTOFACT 1. // scale factor for chi2 of photoelectric effect (bigger==less photo; also to consider /dist_dd)
#define CLUSTDIST 60. // min. distance (mm) around a cluster to increase acceptance
#define CHI2TIMES 1.0 // works with chi2Accept*CHI2TIMES but accepts only until chi2Accept
//#define CHI2TIMES 10.0 // works with chi2Accept*CHI2TIMES but accepts only until chi2Accept
......
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