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

Commit bf286de5 authored by dino's avatar dino
Browse files

Removed bug in the treatment of detector groups (TrackingFilter and...

Removed bug in the treatment of detector groups (TrackingFilter and GlobalFilter) due to using memcpy instead of memmove for overlapping regions. The problem did showed up in Linux, not in Windows.

git-svn-id: svn://gal-serv.lnl.infn.it/agata/trunk/narval_emulator@1192 170316e4-aea8-4b27-aad4-0380ec0519c9
parent 3f44825e
......@@ -573,7 +573,7 @@ bool topologyRead(string topo)
loopIndValue = 0;
loopIndActor = 0;
loopState = true;
cout << endl;
//cout << endl;
continue;
}
......@@ -1408,7 +1408,7 @@ bool topologyInit()
for(unsigned int nc = 0; nc < theChains.size(); nc++) {
ChainOfActors * pChain = theChains[nc];
cout << "\n Initializing chain " << nc << endl;
cout << "\n INITIALIZING CHAIN " << nc << endl;
bool printmsg = true;
for(int na = 0; na < pChain->numActors; na++) {
error_config = 0; error_init = 0;
......
......@@ -66,7 +66,7 @@ EventBuilder::~EventBuilder() {
//PrintStat();
}
bool EventBuilder::Reset(int nque, int wminfold, int wsumbus, int zsumbus)
bool EventBuilder::Reset(int nque, int wminfold, int wsumbusL, int wsumbusR)
{
if(nQueues > 0) {
// remove previous stuff
......@@ -112,8 +112,8 @@ bool EventBuilder::Reset(int nque, int wminfold, int wsumbus, int zsumbus)
timeout = 100*tst1second;
// checks to ensure consistency (0 <=z <=w)
int tR = abs(wsumbus);
int tL = abs(zsumbus);
int tL = abs(wsumbusL);
int tR = abs(wsumbusR);
if(tR >= tL) {
sumbusL = tL;
sumbusR = tR;
......@@ -525,7 +525,7 @@ void EventBuilder::CheckEvent_Tstamp()
}
// this is for "merger" behaviour: pass over what has tStamp >= left AND the queue with the lowest Tstamp (minChain)
// It works for only because in AGATA the ancillaries arrive always (?) ~ 100 samples before the Ge detectors
// It works only because in AGATA the ancillaries arrive always (?) ~ 100 samples before the Ge detectors
// To do this properly in all situation one has to write a real EventMerger which knows the purpose of the input queues
if(sumbusL>0) {
ULong64_t tstampL = minTstamp + sumbusL;
......@@ -610,7 +610,7 @@ bool EventBuilder::InitBuilder()
if(!InitKeys(nQueues))
return false;
Reset(nQueues, minFold, (int)sumbusR, (int)sumbusL);
Reset(nQueues, minFold, (int)sumbusL, (int)sumbusR);
if(useEventNumber)
cout << "\n ==> " << gActualClass << " uses EventNumber" << endl;
......@@ -690,7 +690,7 @@ UInt_t EventBuilder::GetParameters(Bool_t doList)
// decode the command file
string className = "EventBuilder";
if(doList) {conf.Show(className); return 0;}
string confFile = GetConfPath() + gMotherClass + ".conf";
string confFile = GetConfPath() + fActualClass + ".conf";
int rv = conf.Read(className, confFile);
if(rv)
return rv; // Read() error
......@@ -699,10 +699,14 @@ UInt_t EventBuilder::GetParameters(Bool_t doList)
if(conf.Seen("BuilderType")) {
if( stringEq(bType, "TimeStamp") ) {
useEventNumber = false;
if(conf.Count("BuilderType") > 1)
sumbusR = btV1;
if(conf.Count("BuilderType") > 2)
sumbusR = btV1;
if(conf.Count("BuilderType") == 2) {
sumbusL = 0;
sumbusR = btV1;
}
if(conf.Count("BuilderType") == 3) {
sumbusL = btV1;
sumbusR = btV2;
}
}
else if( stringEq(bType, "EventNumber") ) {
useEventNumber = true;
......
......@@ -115,7 +115,7 @@ public:
virtual ~EventBuilder();
bool Reset(int nque , int wminfold = 1, int wsumbus = 100, int zsumbus = 0);
bool Reset(int nque , int wminfold = 1, int wsumbusL = 0, int wsumbusR = 100);
bool setChain(int ichain, ChainLocker * pLock) {
inQueLocker[ichain] = pLock;
......
......@@ -446,6 +446,7 @@ size_t ConfReader::Par::Restore(char *storage)
if(count>0) {
if(!strcmp(type, "str")) {
std::string *str = (std::string*)vptr;
str->erase();
for(int nn = 0; nn < count; nn++) {
size_t strLength = 0;
memcpy(&strLength, storage+totSize, sizeof(size_t));
......
......@@ -1126,7 +1126,7 @@ int GlobalFilter::RemoveInvalidCrystals()
if(cryst[nCry].valid == true) {
if(iCry != nCry) {
memcpy(cryst+iCry, cryst+nCry, sizeof(crystdata));
memcpy(pEXYZ+iHit, pEXYZ+cryst[iCry].hit1st, cryst[iCry].nhits*sizeof(exyzHit));
memmove(pEXYZ+iHit, pEXYZ+cryst[iCry].hit1st, cryst[iCry].nhits*sizeof(exyzHit)); // NOT memcpy because regions can overlap !!
cryst[iCry].hit1st = iHit;
iHit += cryst[iCry].nhits;
for(int ih = cryst[iCry].hit1st; ih < iHit; ih++) {
......
......@@ -162,7 +162,7 @@ TrackingFilter::TrackingFilter() :
fEsumGroup0 = 0;
fEsumGroup1 = 0;
fGroupEvents[0] = fGroupEvents[1] = 0; // before and after gating conditions on groups
fTrackEvents[0] = fTrackEvents[1] = 0; // in and out of tracking algo
fTrackEvents[0] = fTrackEvents[1] = fTrackEvents[2] = fTrackEvents[3] = 0; // in and out of tracking algo
// 3D representation of hits inside placed crystals and z-intercepts of lines joining them (used in 2011_week52)
fMatrZYX = false; // mm to subtract to the z coordinate for the positions inside the crystals
......@@ -275,6 +275,12 @@ TrackingFilter::TrackingFilter() :
gaspBuffer = NULL;
#endif // TRF_WRITE_GSORT
//cout << "sizeof(crystdata)" << sizeof(crystdata) << endl;
//cout << "sizeof(exyzHit) " << sizeof(exyzHit) << endl;
//cout << "sizeof(trGamma) " << sizeof(trGamma) << endl;
//cout << "sizeof(rotTr3D) " << sizeof(rotTr3D) << endl;
//cout << "sizeof(parGate) " << sizeof(parGate) << endl;
}
TrackingFilter::~TrackingFilter()
......@@ -322,10 +328,12 @@ TrackingFilter::~TrackingFilter()
cout << " Number of events after group gating " << fGroupEvents[1] << endl;
cout << " #################################### " << endl;
}
if(!fExcludeTracking) {
if(!fExcludeTracking && fTrackEvents[0]) {
cout << " #################################### " << endl;
cout << " Number of events sent to tracking " << fTrackEvents[0] << endl;
cout << " Number of events with tracked gammas " << fTrackEvents[1] << endl;
cout << " Number of hits sent to tracking " << fTrackEvents[1] << endl;
cout << " Number of gammas out of tracking " << fTrackEvents[2] << endl;
cout << " Number of events with tracked gammas " << fTrackEvents[3] << endl;
cout << " #################################### " << endl;
}
#ifdef TRF_WRITE_GSORT
......@@ -578,9 +586,9 @@ void TrackingFilter::DefineTriggers(UInt_t *error_code)
*error_code = 100 + rerr;
return;
}
cout << "Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&3)?1:0) << "] event:data &event:data:psa &" << fAncRawFrameStr << endl;
cout << "##### Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&3)?1:0) << "] event:data &event:data:psa &" << fAncRawFrameStr << endl;
nTriggerEventData_11 = trigNums++; // event:data:psa WITH data:rancN
cout << "Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&3)?1:0) << "] event:data &event:data:psa !" << fAncRawFrameStr << endl;
cout << "##### Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&3)?1:0) << "] event:data &event:data:psa !" << fAncRawFrameStr << endl;
nTriggerEventData_10 = trigNums++; // event:data:psa WITHOUT data:rancN
#endif
......@@ -607,7 +615,7 @@ void TrackingFilter::DefineTriggers(UInt_t *error_code)
*error_code = 100 + rerr;
return;
}
cout << "Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&4)?1:0) << "] " << trigName << endl;
cout << "##### Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&4)?1:0) << "] " << trigName << endl;
nTriggerEventData_01 = trigNums++;
#endif
......@@ -630,7 +638,7 @@ void TrackingFilter::DefineTriggers(UInt_t *error_code)
*error_code = 100 + rerr;
return;
}
cout << "Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&8)?1:0) << "] " << trigName << endl;
cout << "##### Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&8)?1:0) << "] " << trigName << endl;
nTriggerEventDataPSA = trigNums++;
#endif
......@@ -654,7 +662,7 @@ void TrackingFilter::DefineTriggers(UInt_t *error_code)
*error_code = 100 + rerr;
return;
}
cout << "Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&16)?1:0) << "] " << trigName << endl;
cout << "##### Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&16)?1:0) << "] " << trigName << endl;
nTriggerDataPSA = trigNums++;
#endif
......@@ -675,7 +683,7 @@ void TrackingFilter::DefineTriggers(UInt_t *error_code)
*error_code = 100 + rerr;
return;
}
cout << "Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&32)?1:0) << "] " << trigName << endl;
cout << "##### Trigger " << setw(2) << trigNums << " [" << ((whichTriggers&32)?1:0) << "] " << trigName << endl;
nTriggerDataRawAnc = trigNums++;
#endif
......@@ -751,13 +759,14 @@ UInt_t TrackingFilter::ProcessBlock(ADF::FrameBlock &inBlock, ADF::FrameBlock &o
if(!errStatus) {
// tracking is done only if PreProcessEvent OK;
if(number_of_hits)
if(number_of_hits) {
fTrackEvents[0]++;
fTrackEvents[1] += number_of_hits;
}
if(fExcludeTracking) {
errStatus = 0; // OK if tracking excluded
}
else if(fAcceptAllHits) {
fTrackEvents[0]++;
errStatus = TrackingFilter::Process(); // accept everything as individual gammas
}
else {
......@@ -770,8 +779,10 @@ UInt_t TrackingFilter::ProcessBlock(ADF::FrameBlock &inBlock, ADF::FrameBlock &o
Log << error << " During : Process()" << dolog;
break;
}
if(number_of_gammas)
fTrackEvents[1]++;
if(number_of_gammas) {
fTrackEvents[2] += number_of_gammas;
fTrackEvents[3]++;
}
}
else {
// Event rejected by PreProcessEvent (e.g. because there are no PSA hits or out of gates)
......@@ -1378,7 +1389,7 @@ int TrackingFilter::RemoveInvalidCrystals()
if(cryst[nCry].valid == true) {
if(iCry != nCry) {
memcpy(cryst+iCry, cryst+nCry, sizeof(crystdata));
memcpy(pEXYZ+iHit, pEXYZ+cryst[iCry].hit1st, cryst[iCry].nhits*sizeof(exyzHit));
memmove(pEXYZ+iHit, pEXYZ+cryst[iCry].hit1st, cryst[iCry].nhits*sizeof(exyzHit)); // NOT memcpy because regions can overlap !!
cryst[iCry].hit1st = iHit;
iHit += cryst[iCry].nhits;
for(int ih = cryst[iCry].hit1st; ih < iHit; ih++) {
......@@ -2002,6 +2013,9 @@ void TrackingFilter::WriteInputHits()
trueHits++;
etot += pEXYZ[ii].E;
}
//else {
// should not happen
//}
}
// first come the Ancillary, if present
......@@ -2229,6 +2243,7 @@ int TrackingFilter::PostProcessEvent()
bool TrackingFilter::AnalysisOfGroups(int type)
{
// to be done
return true;
}
......@@ -2243,11 +2258,9 @@ bool TrackingFilter::AnalysisOfCrystals()
const float tr0 = 0.5f*specLenT1;
const float tr1 = 0.5f*specLenT2;
int trueNumber = 0;
float esumCC = 0;
for(int nn1 = 0; nn1 < number_of_crystals; nn1++) {
crystdata *pCr1 = cryst + nn1;
trueNumber++;
int id1 = SM180(pCr1->id); // off range should return fNumgeDets-1
esumCC += pCr1->CCE0;
if(GlobSpec_EC) {
......@@ -2298,7 +2311,7 @@ bool TrackingFilter::AnalysisOfCrystals()
}
}
if(GlobSpec_Fold)
GlobSpec_Fold->Incr(0, trueNumber);
GlobSpec_Fold->Incr(0, number_of_crystals);
if(GlobSpec_XYZ) {
for(int nn = 0; nn < number_of_hits; nn++) {
......@@ -2341,10 +2354,10 @@ bool TrackingFilter::AnalysisOfCrystals()
if(GlobSpec_EE) {
GlobSpec_EE->Incr(0, 8, int(fEnergyGain*esumCC)); // [0][8] input sum energy
if(trueNumber==1)
if(number_of_crystals==1)
GlobSpec_EE->Incr(0, 9, int(fEnergyGain*esumCC)); // [0][9] input single crystal
}
if(GlobSpec_ES && trueNumber > 0 && trueNumber < fNumGeDets) {
if(GlobSpec_ES && number_of_crystals > 0 && number_of_crystals < fNumGeDets) {
GlobSpec_ES->Incr(0, 0, int(esumCC)); // total sum energy
GlobSpec_ES->Incr(0, number_of_crystals, int(esumCC)); // sum energy [fold]
}
......
......@@ -145,7 +145,7 @@ protected:
exyzHit *pEXYZ;
int number_of_hits;
rotTr3D *rotTr; // placmento of detectors
rotTr3D *rotTr; // placement of detectors
trGamma *pGams;
int number_of_gammas;
......@@ -292,8 +292,8 @@ protected:
std::vector<parGate> fGroupGate;
std::vector<bool> fGroupRemove;
UInt_t fGroupEvents[2]; // number of events before and after gating on groups
UInt_t fTrackEvents[2]; // number of events sent-to and received-from the Tracking algo
ULong64_t fGroupEvents[2]; // number of events before and after gating on groups
ULong64_t fTrackEvents[4]; // number of events sent-to and received-from the Tracking algo
Float_t fEnergyGain; // gain of energy spectra
......
......@@ -135,7 +135,7 @@ void TrackingFilterMGT::MoveMGTStructures()
pg->T = pEXYZ[iH1].T; // timing of gamma, taken from the first hit
for(Int_t kk = 0; kk < pg->nH; kk++) {
pg->iH[kk] = pc->ppc[kk]->pid; // original PSA hit of the interaction point
pEXYZ[pg->iH[kk]].Gam = pc->ppc[kk]->ng; // gamma to which the hit has been assigned
pEXYZ[pg->iH[kk]].Gam = nn; // gamma to which the hit has been assigned
}
if(fVerbose) {
if(nn == 0) printf("gam#");
......
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