Skip to content

Commit

Permalink
Merge pull request #703 from kochebina/CoinSortOptions
Browse files Browse the repository at this point in the history
Remove keep-options in policy for CoinSorter
  • Loading branch information
kochebina authored Sep 18, 2024
2 parents 8dffdc3 + 82ba48a commit c3bd0c8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 15 deletions.
21 changes: 17 additions & 4 deletions source/digits_hits/include/GateCoincidenceSorter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,29 @@ class GateDigitizerMgr;

// 01/2016 Rewritten completely by [email protected]

// 2023 Added to GND [email protected]

/*
09/24 [email protected]
Simplification of number of options for multiple coincidences
remove "keep" and replace (or remove if double) with "take",
i.e. all coincidecnes are now written on disk
keepIfAllAreGoods = takeWinnerIfAllAreGoods
keepIfOnlyOneGood = takeWinnerIfOnlyOneGood
keepIfAnyIsGood = takeWinnerOfGoods
kKeepAll = removed
*/
typedef enum {kKillAll,
kTakeAllGoods,
kKillAllIfMultipleGoods,
kTakeWinnerOfGoods,
kTakeWinnerIfIsGood,
kTakeWinnerIfAllAreGoods,
kKeepIfAllAreGoods,
kKeepIfOnlyOneGood,
kKeepIfAnyIsGood,
kKeepAll} multiple_policy_t;
kTakeWinnerIfOnlyOneGood
//kKeepIfOnlyOneGood,
//kKeepIfAnyIsGood,
//kKeepAll
} multiple_policy_t;



Expand Down
51 changes: 41 additions & 10 deletions source/digits_hits/src/GateCoincidenceSorter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GateCoincidenceSorter::GateCoincidenceSorter(GateDigitizerMgr* itsDigitizerMgr,
m_minS (-1),
m_maxDeltaZ ( -1),
m_forceMinSecDifferenceToZero(false),
m_multiplesPolicy(kKeepIfAllAreGoods),
m_multiplesPolicy(kTakeWinnerIfAllAreGoods),
m_allDigiOpenCoincGate(false),
m_depth(1),
m_presortBufferSize(256),
Expand Down Expand Up @@ -132,15 +132,31 @@ void GateCoincidenceSorter::SetMultiplesPolicy(const G4String& policy)
else if (policy=="killAllIfMultipleGoods")
m_multiplesPolicy=kKillAllIfMultipleGoods;
else if (policy=="keepIfAnyIsGood")
m_multiplesPolicy=kKeepIfAnyIsGood;
{
m_multiplesPolicy= kTakeWinnerOfGoods;//kKeepIfAnyIsGood;
G4cout<<"WARNING (Coincidence Sorter): used policy keepIfAnyIsGood is outdated. Please, use takeWinnerOfGoods instead.\n";
}
else if (policy=="keepIfOnlyOneGood")
m_multiplesPolicy=kKeepIfOnlyOneGood;
else if (policy=="keepAll")
m_multiplesPolicy=kKeepAll;
{
m_multiplesPolicy= kTakeWinnerIfOnlyOneGood;//kKeepIfOnlyOneGood;
G4cout<<"WARNING (Coincidence Sorter): used policy keepIfOnlyOneGood is outdated. Please, use takeWinnerIfOnlyOneGood instead.\n";
}
else if (policy=="takeWinnerIfOnlyOneGood")
{
m_multiplesPolicy= kTakeWinnerIfOnlyOneGood;
}

//else if (policy=="keepAll")
// m_multiplesPolicy=kKeepAll;
else {
if (policy!="keepIfAllAreGoods")
G4cout<<"WARNING : policy not recognized, using default : keepMultiplesIfAllAreGoods\n";
m_multiplesPolicy=kKeepIfAllAreGoods;
if(policy == "keepIfAllAreGoods")
G4cout<<"WARNING (Coincidence Sorter): used policy keepIfAllAreGoods is outdated. Please, use takeWinnerIfAllAreGoods instead.\n";
else
if (policy!="takeWinnerIfAllAreGoods" )
G4cout<<"WARNING : policy not recognized, using default : takeWinnerIfAllAreGoods\n";

m_multiplesPolicy= kTakeWinnerIfAllAreGoods;//kKeepIfAllAreGoods;

}
}
//------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -454,9 +470,9 @@ void GateCoincidenceSorter::ProcessCompletedCoincidenceWindow(GateCoincidenceDig
return;
}

//G4cout<<"nGoods = "<< nGoods<<G4endl;
/*//G4cout<<"nGoods = "<< nGoods<<G4endl;
// all the Keep* policies pass on a multi-coincidence rather than breaking into pairs
if( ( (m_multiplesPolicy==kKeepIfAnyIsGood) /*&& (nGoods>0)*/ ) || // if nGoods = 0, we don't get here
if( ( (m_multiplesPolicy==kKeepIfAnyIsGood) /*&& (nGoods>0)*/ /*) || // if nGoods = 0, we don't get here
( (m_multiplesPolicy==kKeepIfOnlyOneGood) && (nGoods==1) ) ||
( (m_multiplesPolicy==kKeepIfAllAreGoods) && (nGoods==(nDigis*(nDigis-1)/2)) ) )
{
Expand All @@ -470,6 +486,21 @@ void GateCoincidenceSorter::ProcessCompletedCoincidenceWindow(GateCoincidenceDig
delete coincidence;
return;
}
*/
if ( (m_multiplesPolicy==kTakeWinnerIfOnlyOneGood) && (nGoods==1))
{
m_OutputCoincidenceDigiCollection->insert(coincidence);
return; // don't delete the coincidence
}
if( (m_multiplesPolicy==kTakeWinnerIfOnlyOneGood) )
{
delete coincidence;
return;
}




// find winner and count the goods
maxE = 0.0;
nGoods = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/digits_hits/src/GateCoincidenceSorterMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ GateCoincidenceSorterMessenger::GateCoincidenceSorterMessenger(GateCoincidenceSo
cmdName = GetDirectoryName()+"MultiplesPolicy";
MultiplePolicyCmd = new G4UIcmdWithAString(cmdName,this);
MultiplePolicyCmd->SetGuidance("How to treat multiples coincidences");
MultiplePolicyCmd->SetCandidates("killAll takeAllGoods killAllIfMultipleGoods takeWinnerOfGoods takeWinnerIfIsGood takeWinnerIfAllAreGoods keepAll keepIfAnyIsGood keepIfOnlyOneGood keepIfAllAreGoods");
MultiplePolicyCmd->SetCandidates("killAll takeAllGoods killAllIfMultipleGoods takeWinnerOfGoods takeWinnerIfIsGood takeWinnerIfAllAreGoods takeWinnerIfOnlyOneGood keepIfAllAreGoods keepIfOnlyOneGood keepIfAnyIsGood");

cmdName = GetDirectoryName()+"allDigiOpenCoincGate";
AllDigiOpenCoincGateCmd = new G4UIcmdWithABool(cmdName,this);
Expand Down

0 comments on commit c3bd0c8

Please sign in to comment.