Commit 8a9cb2c2 authored by dino's avatar dino
Browse files

Moved MixFFT stuff to agapro/common/MixFFT.cpp

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1163 170316e4-aea8-4b27-aad4-0380ec0519c9
parent b2145683
......@@ -39,7 +39,7 @@ ${ACTORS}/WinCtest
${ACTORS}/common
${ACTORS}/producers/Crystal ${ACTORS}/producers/Crystal/includeATCA
${ACTORS}/producers/AncillaryTCP
${ACTORS}/filters/Preprocessing ${ACTORS}/filters/Preprocessing/includePreprocessing
${ACTORS}/filters/Preprocessing
${ACTORS}/filters/Ancillary ${ACTORS}/filters/Ancillary/includeVME
${ACTORS}/filters/PSA ${ACTORS}/filters/PSA/includePSA
${ACTORS}/filters/PostPSA
......@@ -59,6 +59,7 @@ ${ACTORS}/common/misc.cpp
${ACTORS}/common/mwdlib.cpp
${ACTORS}/common/adetParams.cpp
${ACTORS}/common/TstampFilter.cpp
${ACTORS}/common/MixFFT.cpp
${ACTORS}/producers/Crystal/CrystalProducer.cpp
${ACTORS}/producers/Crystal/CrystalProducerATCA.cpp
${ACTORS}/producers/Crystal/includeATCA/mezzanine.cpp
......@@ -66,7 +67,6 @@ ${ACTORS}/producers/Crystal/includeATCA/fileATCA.cpp
${ACTORS}/producers/AncillaryTCP/AncillaryProducerTCP.cpp
${ACTORS}/filters/Preprocessing/PreprocessingFilter.cpp
${ACTORS}/filters/Preprocessing/PreprocessingFilterPSA.cpp
${ACTORS}/filters/Preprocessing/includePreprocessing/MixFFT.cpp
${ACTORS}/filters/Ancillary/AncillaryFilter.cpp
${ACTORS}/filters/Ancillary/AncillaryFilterVME.cpp
${ACTORS}/filters/Ancillary/AncillaryFilterATCA.cpp
......
......@@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\WinCtest;..\common;..\producers\Crystal;..\producers\Crystal\includeATCA;..\producers\AncillaryTCP;..\filters\Preprocessing;..\filters\Preprocessing\includePreprocessing;..\filters\Ancillary;..\filters\Ancillary\includeVME;..\filters\PSA;..\filters\PSA\includePSA;..\filters\Tracking;..\filters\Tracking\includeOFT;..\filters\Tracking\includeMGT;..\filters\PostPSA;..\builders;..\filters\Global;..\..\include;..\PRISMA\src\lib_prisma\include;"C:\Program Files (x86)\boost\boost_1_40";C:\root\include"
AdditionalIncludeDirectories="..\WinCtest;..\common;..\producers\Crystal;..\producers\Crystal\includeATCA;..\producers\AncillaryTCP;..\filters\Preprocessing;..\filters\Ancillary;..\filters\Ancillary\includeVME;..\filters\PSA;..\filters\PSA\includePSA;..\filters\Tracking;..\filters\Tracking\includeOFT;..\filters\Tracking\includeMGT;..\filters\PostPSA;..\builders;..\filters\Global;..\..\include;..\PRISMA\src\lib_prisma\include;"C:\Program Files (x86)\boost\boost_1_40";C:\root\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;NRV_TYPE=NRV_OFFLINE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -551,14 +551,6 @@
<Filter
Name="includePreprocessing"
>
<File
RelativePath="..\filters\Preprocessing\includePreprocessing\MixFFT.cpp"
>
</File>
<File
RelativePath="..\filters\Preprocessing\includePreprocessing\MixFFT.h"
>
</File>
</Filter>
</Filter>
<Filter
......@@ -865,6 +857,14 @@
RelativePath="..\common\misc.h"
>
</File>
<File
RelativePath="..\common\MixFFT.cpp"
>
</File>
<File
RelativePath="..\common\Mixfft.h"
>
</File>
<File
RelativePath="..\common\MultiHist.h"
>
......
......@@ -49,4 +49,3 @@ void fft(int n, double xRe[], double xIm[], double yRe[], double yIm[]);
};
#endif // #ifndef MIXFFT_H_INCLUDED
\ No newline at end of file
......@@ -497,14 +497,14 @@ public:
std::cout << "Cannot write histogram due to inconsistent internal structures" << std::endl;
return false;
}
int ii = 0;
size_t ii = 0;
if(uWrite)
ii = (int)uWrite(data, sizeof(T), lentot, fp);
ii = uWrite(data, sizeof(T), lentot, fp);
else
ii = (int)fwrite(data, sizeof(T), lentot, fp);
ii = fwrite(data, sizeof(T), lentot, fp);
if(doErase)
erase();
return (ii == lentot) ? true : false;
return ( int(ii)==lentot ) ? true : false;
}
bool write(bool erase = false, bool verbose = true) {
......
......@@ -422,7 +422,7 @@ bool InvertMatrix2(const double m[4], double invOut[4])
#if 0
#define indx(n1, n2) (n1*2+n2)
double unit[4]; memset(unit, 0, sizeof(unit));
double unit[4] = {0}; // memset(unit, 0, sizeof(unit));
for(int i1 = 0; i1 < 2; i1++) {
for(int i2 = 0; i2 < 2; i2++) {
double accu = 0;
......@@ -472,7 +472,7 @@ bool InvertMatrix3(const double m[9], double invOut[9])
#if 0
#define indx(n1, n2) (n1*3+n2)
double unit[9]; memset(unit, 0, sizeof(unit));
double unit[9] = {0}; // memset(unit, 0, sizeof(unit));
for(int i1 = 0; i1 < 3; i1++) {
for(int i2 = 0; i2 < 3; i2++) {
double accu = 0;
......@@ -619,7 +619,7 @@ bool InvertMatrix4(const double m[16], double invOut[16])
#if 0
#define indx(n1, n2) (n1*4+n2)
double unit[16]; memset(unit, 0, sizeof(unit));
double unit[16] = {0}; // memset(unit, 0, sizeof(unit));
for(int i1 = 0; i1 < 4; i1++) {
for(int i2 = 0; i2 < 4; i2++) {
double accu = 0;
......
......@@ -488,8 +488,7 @@ bool AncillaryFilterVME::processEventPRISMA()
// std:cout << "ppac " <<ii-60 <<"= "<< theMap[ii] << endl;
//}
int nParam[4][10] = {{0}};
//memset(nParam, 0, sizeof(nParam));
int nParam[4][10] = {{0}}; // memset(nParam, 0, sizeof(nParam));
Counter[4]++;
for (int zz=0; zz<4; zz++){
......
......@@ -56,7 +56,7 @@ PostPSAFilter::PostPSAFilter() :
fForceSegmentsToCore = false;
fSmearPosHit = 2.f;
fSmearPosHit = 0.f;
fRecalEnerCCoffs = fRecalEnerCCgain = 0; fRecalCC = false;
fRecalEnerSGoffs = fRecalEnerSGgain = 0; fRecalSG = false;
fShiftTimeCC = 0;
......@@ -275,7 +275,7 @@ void PostPSAFilter::process_initialise (UInt_t *error_code)
PostSpecEner->setComment("Energy spectra before and after Trapping correction");
hGroup.add(PostSpecEner);
if(fSmearPosHit > 0) {
if(fSmearPosHit>0 || fSegCenter || fDetCenter) {
PostMatrXYZ = new MultiHist<unsigned short>(4, matLen, matLen, matLen);
PostMatrXYZ->setFileName(fOdirPrefix+"Post?XYZ.matr");
PostMatrXYZ->setComment("zXY, yXZ, xYZ rPhiZ distributions of hits");
......@@ -972,6 +972,49 @@ Int_t PostPSAFilter::Process()
pMerged->valid = true;
}
#ifdef PPS_MULTIHIST
// 16) repeat PostMatrXYZ (overlapping to previous increments)
if(PostMatrXYZ && (fSegCenter || fDetCenter)) {
#define xAddr(fx) ( int((fx+matOff)/matPack) )
#define yAddr(fy) ( int((fy+matOff)/matPack) )
#define zAddr(fz) ( int((fz )/matPack) )
#define rAddr(rr) ( int((rr+matOff)/matPack) )
#define xAddrU(fx) ( int((fx+matOff) ) )
#define yAddrU(fy) ( int((fy+matOff) ) )
#define zAddrU(fz) ( int((fz ) ) )
#define rAddrU(rr) ( int((rr+matOff) ) )
for(UInt_t nh = 0; nh < number_of_hits; nh++) {
locHit_t *pLoc = locHit + nh;
if(!pLoc->valid)
continue;
float fx = pLoc->fx; int ix = xAddrU(fx);
float fy = pLoc->fy; int iy = yAddrU(fy);
float fz = pLoc->fz; int iz = zAddrU(fz);
int slice90 = 91 + (pLoc->Sg%6);
PostMatrXYZ->Incr(0, iz, ix, iy); // xy(z), x-axis horizontal
PostMatrXYZ->Incr(0, 0, ix, iy); // total projection
PostMatrXYZ->Incr(0, slice90, ix, iy); // the 6 slices in 91...96
PostMatrXYZ->Incr(1, iy, ix, iz); // xz(y), looking to the flat (i.e. view form y)
PostMatrXYZ->Incr(1, 0, ix, iz); // total projection
PostMatrXYZ->Incr(1, slice90, ix, iz); // the 6 slices in 91...96
PostMatrXYZ->Incr(2, ix, iy, iz); // yz(x), looking to the edge (i.e. view from x)
PostMatrXYZ->Incr(2, 0, iy, iz); // total projection
PostMatrXYZ->Incr(2, slice90, iy, iz); // the 6 slices in 91...96
float phi = float(RAD2DEG*atan2(fy,fx));
if(phi < 0) phi = 360 + phi; int iphi = int(phi*0.25f); // every 4 degrees
float rxy = sqrt(fx*fx + fy*fy); int irxy = int(rxy*1.00f); // possibly rescaled
PostMatrXYZ->Incr(3, irxy, iphi, iz); // phi, z
PostMatrXYZ->Incr(3, irxy/4 + matOff, iphi, iz); // 4 mm packing for r
PostMatrXYZ->Incr(3, 0, iphi, iz); // total projection
PostMatrXYZ->Incr(3, slice90, iphi, iz); // the 6 slices in 91...96
}
}
#endif
cServer.Exec(timestamp);
return 0;
......
......@@ -360,10 +360,8 @@ int PreprocessingFilterPSA::WriteTraces(bool all)
if(!fpPrepTraces)
return 0;
UShort_t ss[defTraceLengthRaw]; // short int buffer to write
UShort_t ee[defTraceLengthRaw]; // energies
memset(ss, 0, sizeof(ss));
memset(ee, 0, sizeof(ee));
UShort_t ss[defTraceLengthRaw] = {0}; // memset(ss, 0, sizeof(ss)); // short int buffer to write
UShort_t ee[defTraceLengthRaw] = {0}; // memset(ee, 0, sizeof(ee)); // energies
size_t nwritten = 0;
// ee 0...35 segments
for(UInt_t nn = 0; nn < CrystalInterface::kNbSegments; nn++) {
......@@ -1200,7 +1198,7 @@ float PreprocessingFilterPSA::FindTriggerTime (float *pT, float trigFract, int
// generate an up-sampled version of the TrigChan channels
const int UPNCHAN = 10; // could create problems if this ends-up off the wave
const int UPSCALE = 16;
float upsampled[UPNCHAN*UPSCALE]; memset(upsampled, 0, sizeof(upsampled));
float upsampled[UPNCHAN*UPSCALE] = {0}; // memset(upsampled, 0, sizeof(upsampled));
float *chh = fWW+fitChan1-1; // start with the previous
int iup = 0;
for(int nn = 0; nn <= trigChans; nn++) {
......@@ -1862,11 +1860,11 @@ int PreprocessingFilterPSA::noiseFFTmake(float sigMax)
return nDone;
}
// expecting data to point to the data-buffer of PreSpecFFT
// more tests once this becomes a non-static method
// static method registered in MultiHist_t as an alternative to fwrite in MultiHist<T>::write
// expecting data to point to the (float)[FFTnsegs][FFTnchan] data-buffer of PreSpecFFT
size_t PreprocessingFilterPSA::noiseFFTwrite(void *data, size_t size, size_t len, FILE *fp)
{
// minimal checks
// can only use const and static stuff for minimal checks
if(size != sizeof(float))
return 0;
if(len != FFTnsegs*FFTnchan)
......@@ -1895,13 +1893,13 @@ size_t PreprocessingFilterPSA::noiseFFTwrite(void *data, size_t size, size_t len
return num;
}
// Given that it has nothing to do with traces, this analysis should be ported to SortEnergy...
// Given that it has nothing to do with traces, this analysis could/should be ported to SortEnergy...
//
// Experimental_energies = Direct_xTalk_Matrix * real_segment_energies
// Done analytically for segMult 1,2,3, 4. Note that the energy of the individual segments for M2, M3 and M4
// makes no sense because we don't impose E > 0 (like in Non Negative Least Squares).
// Possible precision problems of the analytical solutions are simply ignored.
// For higher multiplicity use all non-hit segments to calculate total xTalk, attributing it to to CC:
// For higher multiplicity use all non-hit segments to calculate total xTalk, attributing it to CC:
// results are not much worse than analytically
// EXCLUDE2NDSLICE should not be used for the analytical cases (segMult 1, 2, 3)
......@@ -1949,8 +1947,8 @@ void PreprocessingFilterPSA::CoreEnergyFromXtalk(int segMult)
#if 1
else if(nSegs1 == 2) {
double dd[4]; memset(dd, 0, sizeof(dd)); // row-wise
double xd[2]; memset(xd, 0, sizeof(xd));
double dd[4] = {0}; // memset(dd, 0, sizeof(dd)); // row-wise
double xd[2] = {0}; // memset(xd, 0, sizeof(xd));
// 0 1
// 2 3
for(int nsx = 0; nsx < nSegs0; nsx++) {
......@@ -1979,8 +1977,8 @@ void PreprocessingFilterPSA::CoreEnergyFromXtalk(int segMult)
#if 1
else if(nSegs1 == 3) {
double dd[9]; memset(dd, 0, sizeof(dd)); // row-wise
double xd[3]; memset(xd, 0, sizeof(xd));
double dd[9] = {0}; // memset(dd, 0, sizeof(dd)); // row-wise
double xd[3] = {0}; // memset(xd, 0, sizeof(xd));
// 0 1 2
// 3 4 5
// 6 7 8
......@@ -2017,8 +2015,8 @@ void PreprocessingFilterPSA::CoreEnergyFromXtalk(int segMult)
#if 1
else if(nSegs1 == 4) {
double dd[16]; memset(dd, 0, sizeof(dd)); // row-wise
double xd[ 4]; memset(xd, 0, sizeof(xd));
double dd[16] = {0}; // memset(dd, 0, sizeof(dd)); // row-wise
double xd[ 4] = {0}; // memset(xd, 0, sizeof(xd));
// 0 1 2 3
// 4 5 6 7
// 8 9 10 11
......@@ -2185,8 +2183,8 @@ void PreprocessingFilterPSA::CoreEnergyFromXtalk(int segMult)
#if 1
else if(nSegs2 == 2) {
double dd[4]; memset(dd, 0, sizeof(dd)); // row-wise
double xd[2]; memset(xd, 0, sizeof(xd));
double dd[4] = {0}; // memset(dd, 0, sizeof(dd)); // row-wise
double xd[2] = {0}; // memset(xd, 0, sizeof(xd));
// 0 1
// 2 3
for(int nsx = 0; nsx < nSegs0; nsx++) {
......@@ -2216,8 +2214,8 @@ void PreprocessingFilterPSA::CoreEnergyFromXtalk(int segMult)
#if 1
else if(nSegs2 == 3) {
double dd[9]; memset(dd, 0, sizeof(dd)); // row-wise
double xd[3]; memset(xd, 0, sizeof(xd));
double dd[9] = {0}; // memset(dd, 0, sizeof(dd)); // row-wise
double xd[3] = {0}; // memset(xd, 0, sizeof(xd));
// 0 1 2
// 3 4 5
// 6 7 8
......@@ -2255,8 +2253,8 @@ void PreprocessingFilterPSA::CoreEnergyFromXtalk(int segMult)
#if 1
else if(nSegs2 == 4) {
double dd[16]; memset(dd, 0, sizeof(dd)); // row-wise
double xd[ 4]; memset(xd, 0, sizeof(xd));
double dd[16] = {0}; // memset(dd, 0, sizeof(dd)); // row-wise
double xd[ 4] = {0}; // memset(xd, 0, sizeof(xd));
// 0 1 2 3
// 4 5 6 7
// 8 9 10 11
......
......@@ -178,9 +178,9 @@ public:
void calcTTPulser (float tRefCC, int ss0, int ss1, int sm0, bool bEsTs);
void calcRiseTime ();
float FindRiseTime (float *data);
void CoreEnergyFromXtalk(int segMult);
int noiseFFTmake (float sigMax);
static size_t noiseFFTwrite(void *fData, size_t size, size_t len, FILE *fp); // should find a way to remove the static
void CoreEnergyFromXtalk (int segMult);
static size_t noiseFFTwrite(void *fData, size_t size, size_t len, FILE *fp);
#endif //PPF_MULTIHIST
};
......
......@@ -2040,7 +2040,7 @@ int TrackingFilter::PostProcessEvent()
}
}
// input and unused hits
float eDetUnused[180]; memset(eDetUnused, 0, sizeof(eDetUnused));
float eDetUnused[180] = {0}; // memset(eDetUnused, 0, sizeof(eDetUnused));
int dUnusedFirst = 179, dUnusedLast = 0;
float eSumUnused = 0;
int countUnused = 0;
......
......@@ -321,4 +321,4 @@ void initialize_geometry(double r_in, double r_out)
{
r_inner = r_in;
r_outer = r_out;
}
\ No newline at end of file
}
......@@ -629,8 +629,7 @@ int CrystalProducerATCA::WriteTraces()
if(!fpProdTraces)
return 0;
Short_t ee[defTraceLengthRaw];
memset(ee, 0, sizeof(ee));
Short_t ee[defTraceLengthRaw] = {0}; // memset(ee, 0, sizeof(ee));
size_t nwritten = 0;
// segments
......@@ -648,8 +647,7 @@ int CrystalProducerATCA::WriteTraces()
}
// 3 empty ones
Short_t vv[defTraceLengthRaw];
memset(vv, 0, sizeof(vv));
Short_t vv[defTraceLengthRaw] = {0}; // memset(vv, 0, sizeof(vv));
for(int nempty = 0; nempty < 3; nempty++) {
nwritten = fwrite(vv, sizeof(short), fTraceLengthRaw, fpProdTraces);
if(nwritten != fTraceLengthRaw)
......
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