Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit bdfb2d6b authored by dino's avatar dino
Browse files

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1146 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 53359588
#include "TstampFilter.h"
#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;
......@@ -10,10 +11,10 @@ TstampFilter::TstampFilter()
}
TstampFilter::TstampFilter(std::string tstampFile, int tolerance)
TstampFilter::TstampFilter(std::string tstampFile, int tolerance, int id)
{
Reset();
Initialize(tstampFile, tolerance);
Initialize(tstampFile, tolerance, id);
}
TstampFilter::~TstampFilter()
......@@ -27,13 +28,14 @@ void TstampFilter::Reset()
fTstampFile.clear();
fFromFile = false;
fTstampFILE = NULL;
fMyId = -1;
fTimestamp = 0;
fTolerance = 0;
fCount = 0;
//memset(fStats, 0, sizeof(fStats));
}
bool TstampFilter::Initialize(std::string tstampFile, int tolerance)
bool TstampFilter::Initialize(std::string tstampFile, int tolerance, int id)
{
if(fTstampFILE)
......@@ -54,14 +56,35 @@ bool TstampFilter::Initialize(std::string tstampFile, int tolerance)
}
cout << "Opened timestamp file " << fTstampFile << endl;
fTimestamp = 0x0FFFFFFFFFFFFFFFULL;
int nn = fscanf(fTstampFILE, "%lld", &fTimestamp);
if(nn != 1) {
cout << "Error reading " << fTstampFile << endl;
//*error_code = 134;
//Log << dolog;
return false;
fMyId = id;
if(fMyId < 0) { // only tstamp present in file
int nn = fscanf(fTstampFILE, "%lld", &fTimestamp);
if(nn != 1) {
cout << "Error reading " << fTstampFile << endl;
//*error_code = 134;
//Log << dolog;
return false;
}
cout << "First timestamp " << fTimestamp << endl;
}
else {
id = -1;
int nnr = 0;
while(true) {
int nn = fscanf(fTstampFILE, "%d %lld", & id, &fTimestamp);
if(nn != 2) {
cout << "Error reading " << fTstampFile << endl;
//*error_code = 134;
//Log << dolog;
return false;
}
nnr++;
if(id == fMyId) {
cout << "Id and first timestamp " << setw(3) << fMyId << " " << fTimestamp << " (found after " << nnr << " lines)" << endl;
break;
}
}
}
cout << "First timestamp " << fTimestamp << endl;
fCount = 1;
fFromFile = true;
fTolerance = tolerance;
......@@ -71,18 +94,43 @@ bool TstampFilter::Initialize(std::string tstampFile, int tolerance)
void TstampFilter::NextTstamp()
{
ULong64_t tstOld = fTimestamp;
while(true) {
int nn = fscanf(fTstampFILE, "%lld", &fTimestamp);
if(nn != 1) {
cout << "Error reading " << fTstampFile << endl;
fTimestamp = 0xFFFFFFFFFFFFFFFFULL;
break;
}
if(fTimestamp != tstOld) { // ignore repeated timestamps
fCount++;
break;
}
if(fMyId < 0) {
// timestamp only
while(true) {
int nn = fscanf(fTstampFILE, "%lld", &fTimestamp);
if(nn != 1) {
cout << "Error reading " << fTstampFile << endl;
fTimestamp = 0xFFFFFFFFFFFFFFFFULL;
return;
}
if(fTimestamp != tstOld) { // ignore repeated timestamps
fCount++;
return;
}
} // while()
}
else {
// id timestamp
int id = -1;
int nr = 0;
while(true) {
while(true) {
int nn = fscanf(fTstampFILE, "%d %lld", &id, &fTimestamp);
if(nn != 2) {
cout << "Error reading " << fTstampFile << endl;
fTimestamp = 0xFFFFFFFFFFFFFFFFULL;
return;
}
nr++;
if(id != fMyId)
continue;
if(fTimestamp != tstOld) { // ignore repeated timestamps
fCount++;
return;
}
} // while(true)
} // while(true)
} // else
}
bool TstampFilter::CheckTstamp(ULong64_t timestamp)
......
......@@ -6,6 +6,7 @@
typedef unsigned long long ULong64_t;
typedef unsigned int UInt_t;
typedef int Int_t;
typedef bool Bool_t;
class TstampFilter
......@@ -14,16 +15,17 @@ public:
Bool_t fFromFile;
std::string fTstampFile;
FILE *fTstampFILE;
Int_t fMyId;
ULong64_t fTolerance;
ULong64_t fTimestamp;
UInt_t fCount;
//UInt_t fStats[1000];
TstampFilter();
TstampFilter(std::string tstampFile, int tolerance);
TstampFilter(std::string tstampFile, int tolerance, int id = -1);
virtual ~TstampFilter();
void Reset();
bool Initialize(std::string tstampFile, int tolerance);
bool Initialize(std::string tstampFile, int tolerance, int id = -1);
bool IsReady() {return fFromFile;}
bool CheckTstamp(ULong64_t timestamp);
void NextTstamp();
......
......@@ -72,6 +72,7 @@ fTrigger("data:ranc0")
fTstampFilterFile.clear();
fTstampFilterTolerance = 0;
fTstampFilterId = -1;
fTstampFilter = NULL;
stop_called = false;
......@@ -166,7 +167,7 @@ void AncillaryFilter::process_initialise ( UInt_t *error_code )
fFrameIO.SetStatus(BaseFrameIO::kIdle);
if(fTstampFilterFile.size()) {
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance);
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance, fTstampFilterId);
if( !fTstampFilter->IsReady() ) {
*error_code = 200 + rerr;
return;
......@@ -266,13 +267,14 @@ void AncillaryFilter::GetParameters(UInt_t *error_code)
ok = true;
KEND;
KPAR("TstampFile", "%s %d", "File_with_timestams_to_selct Width_of_selection");
KPAR("TstampFile", "%s %d %d", "File_with_timestams_to_selct Width_of_selection, ID of crystal (-1 if not present in file)");
ok = data.size() > 0;
string value1, value2;
stringSplit(data, value1, value2);
fTstampFilterFile = value1;
if(value2.size())
fTstampFilterTolerance = atoi(value2.c_str());
ok = 2 == sscanf(value2.c_str(), "%d %d", &fTstampFilterTolerance, &fTstampFilterId);
//if(value2.size())
// fTstampFilterTolerance = atoi(value2.c_str());
KEND;
KPAR("DanteChan", "%d %d %d", "T X Y channels of DANTE data");
......
......@@ -75,6 +75,7 @@ protected:
std::string fTstampFilterFile;
UInt_t fTstampFilterTolerance;
Int_t fTstampFilterId;
TstampFilter *fTstampFilter;
Bool_t stop_called;
......
......@@ -78,6 +78,7 @@ PostPSAFilter::PostPSAFilter() :
fTstampFilterFile.clear();
fTstampFilterTolerance = 0;
fTstampFilterId = -1;
fTstampFilter = NULL;
fUseMultiHist = true;
......@@ -218,7 +219,7 @@ void PostPSAFilter::process_initialise (UInt_t *error_code)
}
if(fTstampFilterFile.size()) {
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance);
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance, fTstampFilterId);
if( !fTstampFilter->IsReady() ) {
*error_code = 200 + rerr;
return;
......@@ -308,13 +309,14 @@ void PostPSAFilter::GetParameters(UInt_t *error_code)
ok = true;
KEND;
KPAR("TstampFile", "%s %d", "File_with_timestams_to_selct Width_of_selection");
KPAR("TstampFile", "%s %d %d", "File_with_timestams_to_selct Width_of_selection, ID of crystal (-1 if not present in file)");
ok = data.size() > 0;
string value1, value2;
stringSplit(data, value1, value2);
fTstampFilterFile = value1;
if(value2.size())
fTstampFilterTolerance = atoi(value2.c_str());
ok = 2 == sscanf(value2.c_str(), "%d %d", &fTstampFilterTolerance, &fTstampFilterId);
//if(value2.size())
// fTstampFilterTolerance = atoi(value2.c_str());
KEND;
KPAR("CoreEnergyGate", "%f %f", "acceptance window on core energy (keV)");
......
......@@ -43,6 +43,7 @@ protected:
std::string fTstampFilterFile;
UInt_t fTstampFilterTolerance;
Int_t fTstampFilterId;
TstampFilter *fTstampFilter;
UShort_t crystal_id;
......
......@@ -80,6 +80,7 @@ PreprocessingFilter::PreprocessingFilter() :
fTstampFilterFile.clear();
fTstampFilterTolerance = 0;
fTstampFilterId = -1;
fTstampFilter = NULL;
//fBlockIn.SetModeIO(ConfAgent::kRead);
......@@ -179,7 +180,7 @@ void PreprocessingFilter::process_initialise ( UInt_t *error_code )
}
if(fTstampFilterFile.size()) {
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance);
fTstampFilter = new TstampFilter(GetConfPath()+fTstampFilterFile, fTstampFilterTolerance, fTstampFilterId);
if( !fTstampFilter->IsReady() ) {
*error_code = 200 + rerr;
return;
......@@ -264,13 +265,14 @@ void PreprocessingFilter::GetParameters(UInt_t *error_code)
ok = 1 == sscanf(data.c_str(), "%d", &fWriteNumTraces);
KEND;
KPAR("TstampFile", "%s %d", "File_with_timestams_to_selct Width_of_selection");
KPAR("TstampFile", "%s %d %d", "File_with_timestams_to_selct Width_of_selection, ID of crystal (-1 if not present in file)");
ok = data.size() > 0;
string value1, value2;
stringSplit(data, value1, value2);
fTstampFilterFile = value1;
if(value2.size())
fTstampFilterTolerance = atoi(value2.c_str());
ok = 2 == sscanf(value2.c_str(), "%d %d", &fTstampFilterTolerance, &fTstampFilterId);
//if(value2.size())
// fTstampFilterTolerance = atoi(value2.c_str());
KEND;
KPAR("CoreEnergyGate", "%f %f", "acceptance window on core energy (keV)");
......
......@@ -44,6 +44,7 @@ protected:
std::string fTstampFilterFile;
UInt_t fTstampFilterTolerance;
Int_t fTstampFilterId;
TstampFilter *fTstampFilter;
// original unsigned-short traces
......
......@@ -136,12 +136,14 @@ TrackingFilter::TrackingFilter() :
cryst = new crystdata[fNumGeDets];
fDetEnerMin = 20.f; // should be much wider
fDetEnerMin = 20.f; // should be much wider
fDetEnerMax = 20000.f;
fSumEnerMin = 20.f; // should be much wider
fSumEnerMin = 20.f; // should be much wider
fSumEnerMax = fNumGeDets*fDetEnerMax;
fDetFoldMin = 0; // i.e. keep events with no gamma detectors
fDetFoldMin = 0; // i.e. keep events with no gamma detectors
fDetFoldMax = fNumGeDets;
fHitFoldMin = 0; // i.e. keep events with no gamma detectors
fHitFoldMax = 1000000; // big enough
fEnergyGain = 1.f;
......@@ -1246,13 +1248,13 @@ Int_t TrackingFilter::SetOutput()
int TrackingFilter::PreProcessEvent()
{
if(number_of_hits == 0)
if(number_of_crystals < fDetFoldMin || number_of_crystals > fDetFoldMax)
return 1;
if(number_of_crystals < fDetFoldMin || number_of_crystals > fDetFoldMax)
if(number_of_hits < fHitFoldMin || number_of_hits > fHitFoldMax)
return 1;
if(fCoreSumEnergy < fSumEnerMin || fCoreSumEnergy > fSumEnerMax)
if(fCoreSumEnergy < fSumEnerMin || fCoreSumEnergy > fSumEnerMax)
return 1;
if( !AnalysisOfCrystals() )
......@@ -1458,10 +1460,14 @@ void TrackingFilter::GetParameters(UInt_t *error_code)
ok = 2 == sscanf(data.c_str(), "%f %f", &fSumEnerMin, &fSumEnerMax);
KEND;
KPAR("DetectorFoldGate", "%d %d", "event selection based on number of detectors");
KPAR("NumCrystalsGate", "%d %d", "event selection based on number of fired detectors");
ok = 2 == sscanf(data.c_str(), "%d %d", &fDetFoldMin, &fDetFoldMax);
KEND;
KPAR("NumHitsGate", "%d %d", "event selection based on roral number of fired segments");
ok = 2 == sscanf(data.c_str(), "%d %d", &fHitFoldMin, &fHitFoldMax);
KEND;
// ???????
KPAR("WriteMgtData", "%s ...", "Ancillary &| Timing &| Extended write file of input hits for analysis with mgt");
#ifdef TFR_WRITE_HITS_MGT
......
......@@ -274,6 +274,8 @@ protected:
Float_t fSumEnerMax;
Int_t fDetFoldMin;
Int_t fDetFoldMax;
Int_t fHitFoldMin;
Int_t fHitFoldMax;
Float_t fEnergyGain; // gain of energy spectra
......
......@@ -338,6 +338,14 @@ UInt_t CrystalProducerATCA::ProcessBlock (ADF::FrameBlock &outBlock)
timestamp1st = timestamp;
}
// to be implemented
//if(fTstampFilter) {
// if(!fTstampFilter->CheckTstamp(timestamp)) {
// crystal_status = 1;
// continue;
// }
//}
// process the input buffer making some analysis
if( Process() ) {
error_code = 8;
......@@ -561,7 +569,7 @@ Int_t CrystalProducerATCA::Process()
}
#endif //CRP_MULTIHIST
// this part placed here (instead being in WriteOriginalData()) so as to execute for all events
// this part placed here (instead of being in WriteOriginalData()) so as to execute for all events
if(bWriteTstampDiff) {
if(tStampOld == 0) {
#if 1
......
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