Commit 5636eab1 authored by John Derek Chapman's avatar John Derek Chapman Committed by Graeme Stewart
Browse files

src/MergeTruthJetsTool.*: Adding filterPassed setting for both approaches....

src/MergeTruthJetsTool.*: Adding filterPassed setting for both approaches. Based on original code by Zach. Requires PileUpTools-01-16-01 or later. ATLASSIM-1621. Tagging: MCTruthSimAlgs-01-02-00 (MCTruthSimAlgs-01-02-00)

	* src/MergeTruthJetsTool.*: Adding filterPassed setting for
	PileUpTools approach. Requires PileUpTools-01-16-01 or
	later. ATLASSIM-1621.
	* Tagging: MCTruthSimAlgs-01-02-00

2014-10-08  Zach Marshall <ZLMarshall@lbl.gov>

	* src/MergeTruthJetsTool: Adding filterPassed false setting for
	Algorithms-approach. ATLASSIM-1621.

2014-10-02  John Chapman  <John.Chapman@cern.ch>

	* python/MCTruthSimAlgsConfig.py, python/MCTruthSimAlgsConfigDb.py
	- Add two new named configurations for MergeMcEventCollTool:
	SignalOnlyMcEventCollTool - this one throws away all the pile-up
	GenEvent truth. InTimeOnlyMcEventCollTool - this one keeps all the
	in-time GenEvent truth info for signal and background and throws
	away all the out-of-time GenEvent truth. ATLASSIM-64
	* Tagging: MCTruthSimAlgs-01-01-03
...
(Long ChangeLog diff - truncated)
parent cf62c70a
......@@ -5,10 +5,7 @@ from AthenaCommon import CfgMgr
############################################################################
def MergeMcEventCollTool(name="MergeMcEventCollTool", **kwargs):
if digitizationFlags.doXingByXingPileUp(): # PileUpTool approach
kwargs.setdefault("FirstXing", -30000)
kwargs.setdefault("LastXing", 30000)
def genericMergeMcEventCollTool(name="MergeMcEventCollTool", **kwargs):
kwargs.setdefault("TruthCollKey", "TruthEvent")
kwargs.setdefault("LowTimeToKeep", -50.5)
kwargs.setdefault("HighTimeToKeep", 50.5)
......@@ -23,12 +20,34 @@ def MergeMcEventCollTool(name="MergeMcEventCollTool", **kwargs):
kwargs.setdefault("SaveInTimeMinBias", True)
kwargs.setdefault("SaveOutOfTimeMinBias", True)
kwargs.setdefault("SaveRestOfMinBias", False)
kwargs.setdefault("DoSlimming", True)
kwargs.setdefault("AddBackgroundCollisionVertices", True)
kwargs.setdefault("CompressOutputCollection", False)
return CfgMgr.MergeMcEventCollTool(name, **kwargs)
def MergeMcEventCollTool(name="MergeMcEventCollTool", **kwargs):
if digitizationFlags.doXingByXingPileUp(): # PileUpTool approach
kwargs.setdefault("FirstXing", -30000)
kwargs.setdefault("LastXing", 30000)
kwargs.setdefault("DoSlimming", True)
kwargs.setdefault("OnlySaveSignalTruth", False)
return genericMergeMcEventCollTool(name, **kwargs)
def SignalOnlyMcEventCollTool(name="SignalOnlyMcEventCollTool", **kwargs):
if digitizationFlags.doXingByXingPileUp(): # PileUpTool approach
kwargs.setdefault("FirstXing", 0)
kwargs.setdefault("LastXing", 0)
kwargs.setdefault("OnlySaveSignalTruth", True)
return genericMergeMcEventCollTool(name, **kwargs)
def InTimeOnlyMcEventCollTool(name="InTimeOnlyMcEventCollTool", **kwargs):
if digitizationFlags.doXingByXingPileUp(): # PileUpTool approach
kwargs.setdefault("FirstXing", 0)
kwargs.setdefault("LastXing", 0)
kwargs.setdefault("DoSlimming", False)
kwargs.setdefault("OnlySaveSignalTruth", False)
return genericMergeMcEventCollTool(name, **kwargs)
############################################################################
# The earliest bunch crossing time for which interactions will be sent
......
......@@ -17,6 +17,8 @@ addTool("MCTruthSimAlgs.MCTruthSimAlgsConfig.MergeRecoTimingObjTool" , "
addTool("MCTruthSimAlgs.MCTruthSimAlgsConfig.MergeHijingParsTool" , "MergeHijingParsTool")
addTool("MCTruthSimAlgs.MCTruthSimAlgsConfig.MergeMcEventCollTool" , "MergeMcEventCollTool")
addTool("MCTruthSimAlgs.MCTruthSimAlgsConfig.SignalOnlyMcEventCollTool" , "SignalOnlyMcEventCollTool")
addTool("MCTruthSimAlgs.MCTruthSimAlgsConfig.InTimeOnlyMcEventCollTool" , "InTimeOnlyMcEventCollTool")
addTool("MCTruthSimAlgs.MCTruthSimAlgsConfig.MergeGenericMuonSimHitCollTool" , "MergeGenericMuonSimHitCollTool")
addTool("MCTruthSimAlgs.MCTruthSimAlgsConfig.MergeMicromegasSimHitCollTool" , "MergeMicromegasSimHitCollTool")
......
......@@ -16,7 +16,10 @@ MergeTruthJetsTool::MergeTruthJetsTool(const std::string& type,
PileUpToolBase(type, name, parent),m_intool(""),
m_pMergeSvc("PileUpMergeSvc", name),
m_inTimeOutputJetContainer(NULL),
m_outOfTimeOutputJetContainer(NULL)
m_outOfTimeOutputJetContainer(NULL),
m_first_event(true),
m_signal_max_pT(-1.),
m_pileup_max_pT(-1.)
{
declareInterface<IPileUpTool>(this);
declareProperty("InputTool", m_intool);
......@@ -25,6 +28,8 @@ MergeTruthJetsTool::MergeTruthJetsTool(const std::string& type,
declareProperty("OutOfTimeTruthJetCollKey", m_outOfTimeOutputJetCollKey="OutOfTimeAntiKt4TruthJets");
declareProperty("InTimePtCut", m_inTimePtCut=10.0*Gaudi::Units::GeV);
declareProperty("OutOfTimePtCut", m_outOfTimePtCut=15.0*Gaudi::Units::GeV);
declareProperty("VetoOnInTime", m_vetoOnInTime=false);
declareProperty("IncludeSignalJets", m_includeSignalJets=false, "Include signal jets in the pileup truth jet collections, if they exist");
}
StatusCode MergeTruthJetsTool::initialize() {
ATH_MSG_DEBUG ( "Initializing " << name() << " - package version " << PACKAGE_VERSION );
......@@ -60,13 +65,22 @@ StatusCode MergeTruthJetsTool::processBunchXing(int bunchXing,
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG ( "processBunchXing: bunch Crossing = " << bunchXing << " JetContainer size = " << inputJetContainer->size());
double pileup_this_pT=-1.;
if (bunchXing==0) {
processJetContainer(&(*inputJetContainer), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0);
if (m_first_event) {//FIXME this may not be robust in the case that there is no TruthJet container from the signal event.
m_signal_max_pT = processJetContainer(&(*inputJetContainer), 0, m_inTimePtCut, 0.0);
m_first_event=false;
if (!m_includeSignalJets) {
continue;
}
}
pileup_this_pT=processJetContainer(&(*inputJetContainer), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0);
}
else {
const float timeOfBCID(static_cast<float>(iEvt->time()));
processJetContainer(&(*inputJetContainer), m_outOfTimeOutputJetContainer, m_outOfTimePtCut, timeOfBCID);
pileup_this_pT=processJetContainer(&(*inputJetContainer), m_outOfTimeOutputJetContainer, m_outOfTimePtCut, timeOfBCID);
}
if (pileup_this_pT>m_pileup_max_pT) m_pileup_max_pT=pileup_this_pT;
}
} else {
ATH_MSG_DEBUG ( "processBunchXing: No JetContainers found." );
......@@ -135,6 +149,7 @@ StatusCode MergeTruthJetsTool::processAllSubEvents()
typedef PileUpMergeSvc::TimedList<xAOD::JetContainer>::type TruthJetList;
TruthJetList truthList;
double pileup_this_pT=-1.;
if ( (m_pMergeSvc->retrieveSubEvtsData(m_inputJetCollKey, truthList)).isSuccess() ) {
if (!truthList.empty()) {
......@@ -144,18 +159,29 @@ StatusCode MergeTruthJetsTool::processAllSubEvents()
while (jetColl_iter!=endOfJetColls) {
//FIXME we are forced to do a deep copy
if (static_cast<int>((jetColl_iter)->first.time())==0) {
processJetContainer(&(*((jetColl_iter)->second)), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0);
if (m_first_event) {//FIXME this may not be robust in the case that there is no TruthJet container from the signal event.
m_signal_max_pT = processJetContainer(&(*((jetColl_iter)->second)), 0, m_inTimePtCut, 0.0);
m_first_event=false;
if (!m_includeSignalJets) {
continue;
}
}
pileup_this_pT=processJetContainer(&(*((jetColl_iter)->second)), m_inTimeOutputJetContainer, m_inTimePtCut, 0.0);
}
else {
const float timeOfBCID(static_cast<float>((jetColl_iter)->first.time()));
processJetContainer(&(*((jetColl_iter)->second)), m_outOfTimeOutputJetContainer, m_outOfTimePtCut, timeOfBCID);
pileup_this_pT=processJetContainer(&(*((jetColl_iter)->second)), m_outOfTimeOutputJetContainer, m_outOfTimePtCut, timeOfBCID);
}
if (pileup_this_pT>m_pileup_max_pT) m_pileup_max_pT=pileup_this_pT;
++jetColl_iter;
}
} else ATH_MSG_DEBUG ( "processAllSubEvents: TruthJetList is empty" );
} else ATH_MSG_ERROR ( "processAllSubEvents: Can not find TruthJetList" );
// Veto event when m_pileup_max_pT>m_signal_max_pT
if (m_pileup_max_pT>m_signal_max_pT) m_filterPassed = false;
if(this->record(m_inTimeOutputJetContainer, m_inTimeOutputJetCollKey).isFailure()) { //This call also records the JetMomentMap.
ATH_MSG_ERROR ( "processAllSubEvents: Failed to record InTimeOutputJetContainer" );
return StatusCode::FAILURE;
......@@ -176,14 +202,17 @@ StatusCode MergeTruthJetsTool::processAllSubEvents()
}
//use a float for timeOfBCID as Jet moments are stored as floats.
void MergeTruthJetsTool::processJetContainer(const xAOD::JetContainer* inputJetContainer, xAOD::JetContainer *outputJetContainer, const double& ptCut, const float& timeOfBCID)
double MergeTruthJetsTool::processJetContainer(const xAOD::JetContainer* inputJetContainer, xAOD::JetContainer *outputJetContainer, const double& ptCut, const float& timeOfBCID)
{
double max_pT=-1.;
const xAOD::JetContainer::const_iterator endOfJets(inputJetContainer->end());
for (xAOD::JetContainer::const_iterator jetIter(inputJetContainer->begin()); jetIter != endOfJets; ++jetIter) {
if (!(*jetIter) || (*jetIter)->pt()<ptCut) {
ATH_MSG_VERBOSE( "processJetContainer: Jet with pT = " << (*jetIter)->pt() << " GeV failed ptCut of " << ptCut << "GeV." );
continue;
}
if (max_pT<(*jetIter)->pt()) max_pT=(*jetIter)->pt();
if (!outputJetContainer) continue;
ATH_MSG_VERBOSE( "processJetContainer: Jet with pT = " << (*jetIter)->pt() << " GeV passed ptCut of " << ptCut << "GeV." );
xAOD::Jet* pjet = new xAOD::Jet();
outputJetContainer->push_back(pjet);
......@@ -194,5 +223,5 @@ void MergeTruthJetsTool::processJetContainer(const xAOD::JetContainer* inputJetC
//we will have to live without it.
outputJetContainer->back()->setAttribute("Timing", timeOfBCID);
}
return;
return max_pT;
}
......@@ -43,9 +43,12 @@ public:
///Merge the Truth JetContainers using the PileUpMergeSvc
virtual StatusCode processAllSubEvents();
///implementation of filter reset
virtual void resetFilter() { m_first_event=true; m_signal_max_pT=-1.; m_pileup_max_pT=-1.; m_filterPassed=true; }
private:
/// JetContainer Loop
virtual void processJetContainer(const xAOD::JetContainer* inputJetContainer, xAOD::JetContainer *outputJetContainer, const double& ptCut, const float& timeOfBCID);
virtual double processJetContainer(const xAOD::JetContainer* inputJetContainer, xAOD::JetContainer *outputJetContainer, const double& ptCut, const float& timeOfBCID);
StatusCode record(const xAOD::JetContainer* pjets, std::string jetcontainername) const;
ToolHandle<IJetExecuteTool> m_intool;
ServiceHandle<PileUpMergeSvc> m_pMergeSvc;
......@@ -56,5 +59,10 @@ private:
std::string m_outOfTimeOutputJetCollKey;
double m_inTimePtCut;
double m_outOfTimePtCut;
bool m_vetoOnInTime;
bool m_includeSignalJets;
bool m_first_event;
double m_signal_max_pT;
double m_pileup_max_pT;
};
#endif //MCTRUTHSIMALGS_MERGETRUTHJETSTOOL_H
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