Commit 24298a44 authored by dino's avatar dino
Browse files

Improved the speed of TrackingFilterOFT

Rudimentary implementation of TrackingFilterMGT


git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@909 170316e4-aea8-4b27-aad4-0380ec0519c9
parent ebc34dae
......@@ -36,17 +36,19 @@ CFLAGS += $(DEFINES)
CFLAGS += -I../common/
CFLAGS += -I../producers/Crystal/ -I../producers/Crystal/includeATCA
CFLAGS += -I../producers/AncillaryTCP
CFLAGS += -I../producers/Basic
CFLAGS += -I../filters/Preprocessing/ -I../filters/Preprocessing/includePrePSA
CFLAGS += -I../filters/Ancillary -I../filters/Ancillary/includeVME
CFLAGS += -I../filters/PSA/ -I../filters/PSA/includePSA
CFLAGS += -I../filters/Tracking/ -I../filters/Tracking/includeOFT
CFLAGS += -I../filters/Tracking/ -I../filters/Tracking/includeOFT -I../filters/Tracking/includeMGT
CFLAGS += -I../consumers/Basic
CFLAGS += -I../builders/
CFLAGS += -I../myADF0.2/ -I../myADF0.2/standalone/
CFLAGS += -I../PRISMA/src/lib_prisma/include/
CFLAGS += -I/usr/include/boost/
CFLAGS += -I/usr/include/skstream-0.3/ -I/usr/lib/skstream-0.3/include/
#CFLAGS += -fprofile-arcs -ftest-coverage
#CFLAGS += -pg
CFLAGS += -pg
CFLAGS += -g
SRCS =
......@@ -55,14 +57,17 @@ SRCS += ../common/cycleServer.cpp ../common/misc.cpp
SRCS += ../producers/Crystal/includeATCA/mezzanine.cpp ../producers/Crystal/includeATCA/fileATCA.cpp
SRCS += ../producers/Crystal/CrystalProducer.cpp ../producers/Crystal/CrystalProducerATCA.cpp
SRCS += ../producers/AncillaryTCP/AncillaryProducerTCP.cpp
#SRCS += ../producers/Basic/myBasicAFP.cpp
SRCS += ../filters/Preprocessing/PreprocessingFilter.cpp ../filters/Preprocessing/PreprocessingFilterPSA.cpp
SRCS += ../filters/Preprocessing/includePrePSA/mwdlib.cpp
SRCS += ../filters/Ancillary/AncillaryFilter.cpp ../filters/Ancillary/AncillaryFilterVME.cpp ../filters/Ancillary/AncillaryFilterATCA.cpp
SRCS += ../filters/Ancillary/includeVME/Converter.cpp
SRCS += ../filters/PSA/PSAFilter.cpp ../filters/PSA/PSAFilterGridSearch.cpp
SRCS += ../filters/PSA/includePSA/SignalBasis.cpp
SRCS += ../filters/Tracking/TrackingFilter.cpp ../filters/Tracking/TrackingFilterOFT.cpp
SRCS += ../filters/Tracking/TrackingFilter.cpp ../filters/Tracking/TrackingFilterOFT.cpp ../filters/Tracking/TrackingFilterMGT.cpp
SRCS += ../filters/Tracking/includeOFT/tracking_cluster.c ../filters/Tracking/includeOFT/tracking_data_manip.c ../filters/Tracking/includeOFT/tracking_events.c ../filters/Tracking/includeOFT/tracking_physics.c ../filters/Tracking/includeOFT/tracking_utilitaires.c
SRCS += ../filters/Tracking/includeMGT/mgt.c ../filters/Tracking/includeMGT/mgt_eclust.c ../filters/Tracking/includeMGT/mgt_etrack.c ../filters/Tracking/includeMGT/mgt_event.c ../filters/Tracking/includeMGT/mgt_geoagata.c ../filters/Tracking/includeMGT/mgt_vectorlib.c
#SRCS += ../producers/Basic/myBasicAFC.cpp
SRCS += ../builders/EventBuilder.cpp
SRCS += ../myADF0.2/ADFConfig.cpp ../myADF0.2/ADFObjects.cpp ../myADF0.2/AgataConfigurationFrame.cpp ../myADF0.2/AgataFrameFactory.cpp ../myADF0.2/AgataKeyFactory.cpp ../myADF0.2/BaseBuffer.cpp ../myADF0.2/BufferIO.cpp ../myADF0.2/CompositeFrame.cpp ../myADF0.2/ConfAgent.cpp ../myADF0.2/ConfigurationFrame.cpp ../myADF0.2/Counter.cpp ../myADF0.2/DataHandling.cpp ../myADF0.2/DefaultKeyFactory.cpp ../myADF0.2/FactoryItem.cpp ../myADF0.2/Frame.cpp ../myADF0.2/FrameBlock.cpp ../myADF0.2/FrameFactory.cpp ../myADF0.2/GObject.cpp ../myADF0.2/FrameIO.cpp ../myADF0.2/GenericFrame.cpp ../myADF0.2/AgataRawFrame.cpp ../myADF0.2/CrystalFrame.cpp ../myADF0.2/MetaFrame.cpp ../myADF0.2/Hits.cpp ../myADF0.2/Key.cpp ../myADF0.2/KeyFactory.cpp ../myADF0.2/NarvalInterface.cpp ../myADF0.2/Signals.cpp ../myADF0.2/Trigger.cpp ../myADF0.2/Version.cpp ../myADF0.2/standalone/LogCollector.cpp ../myADF0.2/standalone/CentralLog.cpp ../myADF0.2/standalone/LogMessage.cpp ../myADF0.2/BasicAFC.cpp ../myADF0.2/BasicAFP.cpp
SRCS += ../PRISMA/src/lib_prisma/src/prismaManager.cc ../PRISMA/src/lib_prisma/src/banGate.cc ../PRISMA/src/lib_prisma/src/banManager.cc ../PRISMA/src/lib_prisma/src/calCoef.cc ../PRISMA/src/lib_prisma/src/calManager.cc ../PRISMA/src/lib_prisma/src/CGaspBuffer.cc ../PRISMA/src/lib_prisma/src/ConfigurationFile.cc ../PRISMA/src/lib_prisma/src/detData.cc ../PRISMA/src/lib_prisma/src/fastSolver.cc ../PRISMA/src/lib_prisma/src/fullEvent.cc ../PRISMA/src/lib_prisma/src/massCalculator.cc ../PRISMA/src/lib_prisma/src/prismaIonCh.cc ../PRISMA/src/lib_prisma/src/prismaMcp.cc ../PRISMA/src/lib_prisma/src/prismaPPAC.cc ../PRISMA/src/lib_prisma/src/prismaSide.cc ../PRISMA/src/lib_prisma/src/RandomGenerator.cc ../PRISMA/src/lib_prisma/src/Vectors.cc ../PRISMA/src/lib_prisma/src/zedCalculator.cc
......
......@@ -16,7 +16,7 @@
#define WCT_BUFSIZE_ANC ( 256*1024) // for the Ancillary producer (must be < WCT_BUFSIZE)
#define WCT_BUFSIZE_AFP ( 1*1024*1024) // for the basic producer (must be < WCT_BUFSIZE)
#define WCT_THREADED // to run the various chains in parallel on a many-core system
//#define WCT_THREADED // to run the various chains in parallel on a many-core system
#include "commonDefs.h"
......@@ -40,6 +40,7 @@ FILTER PSAFilterGridSearch
FILTER AncillaryFilterVME
FILTER AncillaryFilterATCA
FILTER TrackingFilterOFT
FILTER TrackingFilterMGT
CONSUMER BasicAFC
*********************************************************/
......@@ -64,6 +65,7 @@ int TOTCHAINS = 1; // the real number of chains (including the global one, if pr
#include "TrackingFilterOFT.h" // 2
#include "AncillaryFilterVME.h" // 3
#include "AncillaryFilterATCA.h" // 4
#include "TrackingFilterMGT.h" // 5
// CONSUMER
#include "BasicAFC.h"
......@@ -102,7 +104,7 @@ using namespace std;
using namespace ADF;
struct ldata {
ldata() : libType(NONE), libReal(-1),
ldata() : libType((EActor)NONE), libReal(-1),
pActors(NULL), pGlobal(NULL) {}
EActor libType; // actor: -1 Undefined; 0 Builder; 1 Producer; 2 Filter; 3 Consumer
int libReal; // subtype: -1 Undefined; >=0 sequential identifiers of the various items
......@@ -792,6 +794,11 @@ bool topologyFactory()
ltmp->pActors = new AncillaryFilterATCA;
ltmp->libReal = 4;
}
else if(ltmp->libName == "TrackingFilterMGT") {
cout << "TrackingFilterMGT ..." << endl;
ltmp->pActors = new TrackingFilterMGT;
ltmp->libReal = 5;
}
else {
cout << "Unknown class [ " << nc << " " << nc << " ] " << ltmp->libName << endl;
return false;
......
......@@ -44,7 +44,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\PRISMA\src\lib_prisma\include;&quot;C:\Program Files (x86)\boost\boost_1_40&quot;;..\myADF0.2;..\myADF0.2\standalone;..\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;..\builders;C:\root\include"
AdditionalIncludeDirectories="..\PRISMA\src\lib_prisma\include;&quot;C:\Program Files (x86)\boost\boost_1_40&quot;;..\myADF0.2;..\myADF0.2\standalone;..\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"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;NRV_OFFLINE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
......@@ -276,7 +276,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\PRISMA\src\lib_prisma\include;&quot;C:\Program Files (x86)\boost\boost_1_40&quot;;..\myADF0.2;..\myADF0.2\standalone;..\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;..\builders;C:\root\include"
AdditionalIncludeDirectories="..\PRISMA\src\lib_prisma\include;&quot;C:\Program Files (x86)\boost\boost_1_40&quot;;..\myADF0.2;..\myADF0.2\standalone;..\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"
PreprocessorDefinitions="WIN64;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;NRV_OFFLINE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
......@@ -355,6 +355,14 @@
RelativePath="..\filters\Tracking\TrackingFilter.h"
>
</File>
<File
RelativePath="..\filters\Tracking\TrackingFilterMGT.cpp"
>
</File>
<File
RelativePath="..\filters\Tracking\TrackingFilterMGT.h"
>
</File>
<File
RelativePath="..\filters\Tracking\TrackingFilterOFT.cpp"
>
......@@ -411,6 +419,50 @@
>
</File>
</Filter>
<Filter
Name="IncludeMGT"
>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt.c"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt.h"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt_eclust.c"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt_etrack.c"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt_event.c"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt_externals.h"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt_geoagata.c"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt_useful.h"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt_vectorlib.c"
>
</File>
<File
RelativePath="..\filters\Tracking\includeMGT\mgt_vectorlib.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="PSA"
......@@ -870,14 +922,18 @@
<Filter
Name="consumers"
>
<File
RelativePath="..\myADF0.2\BasicAFC.cpp"
>
</File>
<File
RelativePath="..\myADF0.2\BasicAFC.h"
<Filter
Name="Basic"
>
</File>
<File
RelativePath="..\myADF0.2\BasicAFC.cpp"
>
</File>
<File
RelativePath="..\myADF0.2\BasicAFC.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="common"
......
......@@ -122,7 +122,7 @@ const int defTriggerSample = 10; // 60-10 useful samples passed to the PS
//////// PSAFilter ////////
///////////////////////////
#define TCOUNT 5 // number of threads to use to decompose signals
//#define TCOUNT 5 // number of threads to use to decompose signals
#define TMODULO 100 // how many events are distributed to each thread
#define USEADAPTIVE // to use the coarse-fine grid searh
#define PSA_LOCALSPECTRA // enable nDhist spectra
......
......@@ -10,6 +10,7 @@
#endif
#include "misc.h"
#include <ctime>
class ratemeter
{
......
......@@ -47,6 +47,23 @@ void stringTrim(std::string &str)
str = str.substr(0, ii+1);
}
void stringRemove(std::string &str, const std::string rem, bool by_char) {
if(by_char) {
size_t nn = str.find_first_of(rem);
while(nn != string::npos) {
str = str.substr(0, nn) + str.substr(nn+1);
nn = str.find_first_of(rem);
}
}
else {
size_t nn = str.find(rem);
while(nn != string::npos) {
str = str.substr(0, nn) + str.substr(nn+rem.size());
nn = str.find(rem);
}
}
}
bool stringSplit(std::string &line, const std::string sepa, std::string &keyw)
{
stringTrim(line);
......
......@@ -2,10 +2,9 @@
#define MISC_H_INCLUDED
#include <string>
#include <memory.h>
#include <ctime>
#include "commonDefs.h"
//#include <memory.h>
//#include <ctime>
//#include "commonDefs.h"
void stringTrim(std::string &str);
bool stringSplit(std::string &line, const std::string sepa, std::string &keyw);
......@@ -13,47 +12,48 @@ bool stringSplit(std::string &line, const std::string sepa, std::string &keyw,
bool stringIncrement(std::string &fn, int count = 1);
bool stringIncrement(std::string &fn, const std::string sp, int count = 1);
bool stringEq(const std::string &s1, const std::string &s2, bool ignorecase = true);
void stringRemove(std::string &str, const std::string rem, bool by_char = true);
int getKeyFromFile(const std::string filename, const std::string theKey, std::string &theValue, bool verbose = false);
void forceTailSlash(std::string &dr);
bool fileExists(std::string fname);
// bit values used in various places
enum retValue {
EvNormal = 0,
EvNewBuffer = 1,
EvNewFile = 2,
EvFinish = 4,
EvSkip = 8,
EvAgain = 16,
EvReturn = 32
};
//// bit values used in various places
//enum retValue {
// EvNormal = 0,
// EvNewBuffer = 1,
// EvNewFile = 2,
// EvFinish = 4,
// EvSkip = 8,
// EvAgain = 16,
// EvReturn = 32
//};
template<class T>
class median
{
public:
median() : a1(0), a2(0), an(0) {}
void reset(const T &a3) {a1=a3; a2=a3; an=a3;}
T exec(const T &a3) {
if(a1 < a2) {
if (a3 > a2) an = a2;
else if(a3 < a1) an = a1;
else an = a3;
}
else {
if (a3 > a1) an = a1;
else if(a3 < a2) an = a2;
else an = a3;
}
a1 = a2;
a2 = a3;
return an;
}
int myID;
T a1;
T a2;
T an;
};
//template<class T>
//class median
//{
//public:
// median() : a1(0), a2(0), an(0) {}
// void reset(const T &a3) {a1=a3; a2=a3; an=a3;}
// T exec(const T &a3) {
// if(a1 < a2) {
// if (a3 > a2) an = a2;
// else if(a3 < a1) an = a1;
// else an = a3;
// }
// else {
// if (a3 > a1) an = a1;
// else if(a3 < a2) an = a2;
// else an = a3;
// }
// a1 = a2;
// a2 = a3;
// return an;
// }
// int myID;
// T a1;
// T a2;
// T an;
//};
#endif
......@@ -8,6 +8,7 @@ ADFINCLUDE = -I$(WD)/../myADF0.2
CFLAGS = -fPIC -O2 -Wall -Wno-reorder $(DEBUG)
CFLAGS += $(GRUMACRO) $(USETHREADS) $(PCI_EXPRESS) $(BASIC_IO)
CFLAGS += $(ADFINCLUDE)
CFLAGS += -I$(WD)/Basic
#GRUSYS=/agata/tools/gru
#GRUINCLUDES=-I$(GRUSYS)/include -I$(GRUSYS)/vigru
......@@ -30,7 +31,7 @@ libBasicAFC : libBasicAFC.o
################### BasicAFC consumer ################
libBasicAFC.o : $(WD)/libBasicAFC.cpp
libBasicAFC.o : $(WD)/Basic/libBasicAFC.cpp
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
......
......@@ -12,7 +12,7 @@ CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1
CFLAGS += -I$(WD)/../common
CFLAGS += -I$(WD)/Preprocessing -I$(WD)/Preprocessing/includePrePSA
CFLAGS += -I$(WD)/PSA -I$(WD)/PSA/includePSA
CFLAGS += -I$(WD)/Tracking -I$(WD)/Tracking/includeOFT
CFLAGS += -I$(WD)/Tracking -I$(WD)/Tracking/includeOFT -I$(WD)/Tracking/includeMGT
CFLAGS += -I$(WD)/Ancillary -I$(WD)/Ancillary/includeVME
CFLAGS += -I$(WD)/../PRISMA/src/lib_prisma/include
......@@ -54,11 +54,18 @@ libPSAFilter: libPSAFilter.o\
libTrackingFilter: libTrackingFilter.o\
TrackingFilter.o\
TrackingFilterOFT.o\
TrackingFilterMGT.o\
tracking_cluster.o\
tracking_data_manip.o\
tracking_events.o\
tracking_physics.o\
tracking_utilitaires.o\
mgt.o\
mgt_eclust.o\
mgt_etrack.o\
mgt_event.o\
mgt_geoagata.o\
mgt_vectorlib.o\
cycleServer.o\
misc.o
@echo " Linking " $@
......@@ -133,7 +140,8 @@ SignalBasis.o : $(WD)/PSA/includePSA/SignalBasis.cpp\
libTrackingFilter.o: $(WD)/Tracking/libTrackingFilter.cpp\
$(WD)/Tracking/TrackingFilter.h\
$(WD)/Tracking/TrackingFilterOFT.h
$(WD)/Tracking/TrackingFilterOFT.h\
$(WD)/Tracking/TrackingFilterMGT.h
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
......@@ -173,6 +181,46 @@ tracking_utilitaires.o: $(WD)/Tracking/includeOFT/tracking_utilitaires.c\
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
TrackingFilterMGT.o: $(WD)/Tracking/TrackingFilterMGT.cpp\
$(WD)/Tracking/TrackingFilterMGT.h\
$(WD)/Tracking/TrackingFilter.h
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
mgt.o: $(WD)/Tracking/includeMGT/mgt.c\
$(WD)/Tracking/includeMGT/mgt.h\
$(WD)/Tracking/includeMGT/mgt_externals.h
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
mgt_eclust.o: $(WD)/Tracking/includeMGT/mgt_eclust.c\
$(WD)/Tracking/includeMGT/mgt.h\
$(WD)/Tracking/includeMGT/mgt_externals.h
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
mgt_etrack.o: $(WD)/Tracking/includeMGT/mgt_etrack.c\
$(WD)/Tracking/includeMGT/mgt.h\
$(WD)/Tracking/includeMGT/mgt_externals.h
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
mgt_event.o: $(WD)/Tracking/includeMGT/mgt_event.c\
$(WD)/Tracking/includeMGT/mgt.h\
$(WD)/Tracking/includeMGT/mgt_externals.h
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
mgt_geoagata.o: $(WD)/Tracking/includeMGT/mgt_geoagata.c\
$(WD)/Tracking/includeMGT/mgt.h\
$(WD)/Tracking/includeMGT/mgt_externals.h
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
mgt_vectorlib.o: $(WD)/Tracking/includeMGT/mgt_vectorlib.c\
$(WD)/Tracking/includeMGT/mgt_vectorlib.h
@echo "Compiling " $<
@g++ -c -fPIC $(CFLAGS) $(ROOTEXTRAS) $(GRUINCLUDES) $<
#################### AncillaryFilter ########
......
......@@ -117,6 +117,7 @@ struct PsaData
Int_t retValue; // used only by the threaded part
bool selectIt; // used to select events
PsaData() : crystal_id(0), crystal_status(0), evnumber(0), timestamp(0), shiftT0(0) {
memset(fTracesSG, 0, sizeof(fTracesSG));
memset(fTracesCC, 0, sizeof(fTracesCC));
......
......@@ -14,6 +14,7 @@ using namespace std;
// of the individual segments but should be excluded in real PSA.
//
const float dScale = 10.f; // mm
const float sScale = 1.f; // chan/keV of saved traces
const int specLenE = 16*1024;
......@@ -24,6 +25,7 @@ const int matOff = 50;
const int nPsaHitsValues = 16; // number of parameters written in Psa__-nn-F__Hits.fdat
const bool doSelect = false; // the selection has to be programmed manually in Process()
const bool doFit_T0 = false;
PSAFilterGridSearch::PSAFilterGridSearch()
{
......@@ -320,16 +322,13 @@ Int_t PSAFilterGridSearch::Process(int slot)
return 0;
}
// a fake PSA that places the inteaction points at the center of their net-charge segment
if(fPsaSegCenter) {
// just placing the points at the center of their net-charge segment
SetToSegCenter(pD, &pS);
// nothing more to do
return 0;
return 0; // nothing more to do
}
//////////////////////////////////////
//// this is the real grid search ////
//////////////////////////////////////
// proceed with the real grid search
int samp_first = pS.addr_first;
int samp_last = pS.addr_last;
......@@ -343,6 +342,7 @@ Int_t PSAFilterGridSearch::Process(int slot)
samp_last = samp_first + SFIXEDLEN - 1;
}
// initialize the ORDEREDSEARCH arrays (must be done even if not used)
for(int snn = 0; snn < sMult; snn++) {
pS.segOrder[snn] = snn;
pS.eneOrder[snn] = pS.netChargeEnergy[snn];
......@@ -371,17 +371,34 @@ Int_t PSAFilterGridSearch::Process(int slot)
#endif // PRECOARSESEARCH
#endif // ORDEREDSEARCH
//// if needed, clear the "fitted" trace
//if(fWriteNumTraces > 0)
memset(pS.rAmplitude, 0, sizeof(pS.rAmplitude)); // always needed to fit T0
// if needed, clear the "fitted" trace
if(doFit_T0 || fWriteNumTraces > 0)
memset(pS.rAmplitude, 0, sizeof(pS.rAmplitude));
/////////////////////////////////////////////////////////////////////
// the actual PSA on the prepared data
int usamp = ProcessEvent(pD, pS, sMult, samp_first, samp_last);
/////////////////////////////////////////////////////////////////////
if(doFit_T0) {
float dt0 = FitT0FromCore(pS, samp_first+usamp);
pD->shiftT0 = dt0;
}
// While writing the traces, save the results in the proper slot
if(fWriteNumTraces > 0) {
SaveTotalTrace(pS, slot);
}
////////////////////////////////////////////////////////////////
// the loop on the independently-analysed net-charge segments //
////////////////////////////////////////////////////////////////
return 0;
}
int PSAFilterGridSearch::ProcessEvent(PsaData *pD, pointExp &pS, int sMult, int samp_first, int samp_last)
{
char localMask[NCHAN+1];
int usamp = 0;
float fCcSg = pS.enerGe/pS.sumSegm;
for(int snn = 0; snn < sMult; snn++) {
int snum = pS.segOrder[snn];
......@@ -391,7 +408,28 @@ Int_t PSAFilterGridSearch::Process(int slot)
pS.netChargeSegment = netChSeg; // the point is considered to have this as the netcharge segment
#if 0
MakeLocalMask(localMask, pS, netChSeg);
#else
// code of the called function placed here to avoid the call in the GPU implementation
//void PSAFilterGridSearch::MakeLocalMask(char *localMask, pointExp &pS, int netChSeg) {
// set mask of segments for the search loop
strcpy(localMask, hmask[netChSeg]);
int sMult = pS.numNetCharges;
#ifndef USENETCHARGES
// skipping the net charge segment(s)
for(int ii = 0; ii < sMult; ii++) {
localMask[pS.netChargeSegnum[ii]] = '0';
}
#endif
#ifndef USECORETRACE
// remove also the core
localMask[NCHAN-1] = '0';
#endif
if(DIFFLAG > 0)
localMask[netChSeg] = '1'; // (ri)enable the segment-of-interest
//}
#endif
#if defined(ORDEREDSEARCH) && defined(PRECOARSESEARCH)
if(sMult > 1) {
......@@ -401,8 +439,30 @@ Int_t PSAFilterGridSearch::Process(int slot)
}
#endif
#if 0
// prepare sAmplitude from the subset of fAmplitude given by localMask
pS.MakeSearchWave(scaleFact, localMask);
#else
// code of the called function placed here to avoid the call in the GPU implementation
//void MakeSearchWave(float fact, char *mask) { const float yMax = NMETRIC2/2 - 10; // set range limits
const float yMax = NMETRIC2/2 - 10; // limits the data to the range
const float yMin = -NMETRIC2/2 + 10; // of the precalculated metrics
for(int iSegm = 0; iSegm < NSEGS; iSegm++) {
if(localMask[iSegm] != '0') {
gs_type *sA = pS.sAmplitude[iSegm]; // the wave to be composed
gs_type *fA = pS.fAmplitude[iSegm]; // taking the data from this
for(int kk=0; kk<NTIME; kk++) {
float yy = scaleFact*fA[kk];
if(yy > yMax)
yy = yMax;
if(yy < yMin)
yy = yMin;
sA[kk] = (gs_type)yy;
}
}
}
//}
#endif
if(DIFFLAG > 0) {
pS.sDiffNetCharge(DIFFLAG); // apply a delayed differentiation of DIFFLAG samples to the net charge segment of sAmplitude
......@@ -429,7 +489,7 @@ Int_t PSAFilterGridSearch::Process(int slot)
// save the results
pOut->enerSG = netChEner;
pOut->enerCC = netChEner*fCcSg;
pOut->enerCC = netChEner*pS.enerGe/pS.sumSegm; // fraction of CC energy
pOut->fx = fx; pOut->fy = fy; pOut->fz = fz;
pOut->dTns = pS.bestdt*float(SAMP_STEP); // saved in ns
pOut->chiSq = pS.chi2min;
......@@ -438,16 +498,17 @@ Int_t PSAFilterGridSearch::Process(int slot)
pOut->corrCC = bestPoint->trapCC; // must have been precalculated in AlgoSpecificInitialise
pOut->corrSG = bestPoint->trapSG;
// manual selection of events for waves and histograms
if(doSelect) {
if((netChSeg%6)==0 && fx>0 && fx<6 && fy>-5 && fy<5)
pD->selectIt = true;
}
//// manual selection of events for waves and histograms
//if(doSelect) {
// if((netChSeg%6)==0 && fx>0 && fx<6 && fy>-5 && fy<5)
// pD->selectIt = true;
//}
//if(fWriteNumTraces > 0) {
//// The best point is normalized to the experimental amplitude and accumulated in rAmplitude
// for the GPU implementation simply ignore this call
if(doFit_T0 || fWriteNumTraces > 0) {
// The best point is normalized to the experimental amplitude and accumulated in rAmplitude
StorePartialTrace(pS, bestPoint, scaleFact, samp_first, usamp); // always needed to fit T0
//}
}