Skip to content
Snippets Groups Projects
Commit 6c82212c authored by Elmar Ritsch's avatar Elmar Ritsch Committed by Graeme Stewart
Browse files

making end-vertex writing configurable per detector region (ATLASSIM-2123) +...

making end-vertex writing configurable per detector region (ATLASSIM-2123) + fixing accidental overwrite of ISF_MC12PlusTruthService CfgGetter DB entry (ISF_HepMC_Services-00-07-00)

	* python/ISF_HepMC_ServicesConfigDb.py - fixing accidental overwrite of
	ISF_MC12PlusTruthService CfgGetter DB entry
	* src/HepMC_TruthSvc.h/cxx, python/ISF_HepMC_ServicesConfig.py - making
	end-vertex writing configurable per detector region (ATLASSIM-2123)
	* tag ISF_HepMC_Services-00-07-00

2015-07-10  John Chapman  <John.Chapman@cern.ch>
	* python/ISF_HepMC_ServicesConfig.py,
	python/ISF_HepMC_ServicesConfigDb.py - add CfgGetter method for
	ISF_MC12LLPTruthService, which should resolve ATLASSIM-1931.
	* tag ISF_HepMC_Services-00-06-02

2015-07-01  Zach Marshall <ZLMarshall@lbl.gov>
	* Removing much of the special handling of barcodes for Q-S particle
	simulation.  This implements the new notion of what the truth record
	should look like, following ATLASSIM-526
	* tag ISF_HepMC_Services-00-06-01

2015-06-17  John Chapman  <John.Chapman@cern.ch>

...
(Long ChangeLog diff - truncated)
parent 38e0dda1
No related branches found
No related tags found
No related merge requests found
......@@ -21,28 +21,36 @@ def getGenericTruthService(name="ISF_TruthService", **kwargs):
kwargs.setdefault('SkipIfNoChildren' , True)
kwargs.setdefault('SkipIfNoParentBarcode' , True)
kwargs.setdefault('StoreExtraBarcodes' , False)
kwargs.setdefault('AlwaysAttachEndVertexIfParentDies', False)
kwargs.setdefault('ForceEndVtxInRegions' , [ ] )
if 'longLived' in ISF_Flags.Simulator(): #FIXME this should be configured in a nicer way. ATLASSIM-526
kwargs.setdefault('QuasiStableParticlesIncluded', True)
from ISF_HepMC_Services.ISF_HepMC_ServicesConf import ISF__HepMC_TruthSvc
return ISF__HepMC_TruthSvc(name, **kwargs);
def getMC15TruthService(name="ISF_MC15TruthService", **kwargs):
# importing Reflex dictionary to access AtlasDetDescr::AtlasRegion enum
import ROOT, cppyy
cppyy.loadDictionary('AtlasDetDescrDict')
AtlasRegion = ROOT.AtlasDetDescr
kwargs.setdefault('BeamPipeTruthStrategies' , [ 'ISF_MCTruthStrategyGroupID_MC15' ] ) # this is used for beam pipe but not BeamPipeCentral which uses same as ID
kwargs.setdefault('IDTruthStrategies' , [ 'ISF_MCTruthStrategyGroupID_MC15', 'ISF_MCTruthStrategyGroupIDHadInt_MC15' ] )
kwargs.setdefault('CaloTruthStrategies' , [ 'ISF_MCTruthStrategyGroupCaloMuBrem', 'ISF_MCTruthStrategyGroupCaloDecay_MC15' ])
kwargs.setdefault('MSTruthStrategies' , [])
kwargs.setdefault('IgnoreUndefinedBarcodes' , False)
kwargs.setdefault('PassWholeVertices' , False) # new for MC15 - can write out partial vertices.
kwargs.setdefault('AlwaysAttachEndVertexIfParentDies', True)
kwargs.setdefault('ForceEndVtxInRegions' , [ AtlasRegion.fAtlasID ] )
return getGenericTruthService(name, **kwargs);
def getMC15aTruthService(name="ISF_MC15aTruthService", **kwargs):
kwargs.setdefault('AlwaysAttachEndVertexIfParentDies', False)
kwargs.setdefault('ForceEndVtxInRegions' , [ ] )
return getMC15TruthService(name, **kwargs);
def getMC15aPlusTruthService(name="ISF_MC15aPlusTruthService", **kwargs):
kwargs.setdefault('AlwaysAttachEndVertexIfParentDies', True)
# importing Reflex dictionary to access AtlasDetDescr::AtlasRegion enum
import ROOT, cppyy
cppyy.loadDictionary('AtlasDetDescrDict')
AtlasRegion = ROOT.AtlasDetDescr
kwargs.setdefault('ForceEndVtxInRegions' , [ AtlasRegion.fAtlasID ] )
return getMC15TruthService(name, **kwargs);
def getMC12TruthService(name="ISF_MC12TruthService", **kwargs):
......@@ -54,8 +62,19 @@ def getMC12TruthService(name="ISF_MC12TruthService", **kwargs):
kwargs.setdefault('PassWholeVertices' , True)
return getGenericTruthService(name, **kwargs);
def getMC12LLPTruthService(name="ISF_MC12TruthLLPService", **kwargs):
kwargs.setdefault('BeamPipeTruthStrategies' , [ 'ISF_MCTruthStrategyGroupID', 'ISF_LLPTruthStrategy' ] ) # this is used for beam pipe but not BeamPipeCentral which uses same as ID
kwargs.setdefault('IDTruthStrategies' , [ 'ISF_MCTruthStrategyGroupID', 'ISF_MCTruthStrategyGroupIDHadInt', 'ISF_LLPTruthStrategy' ] )
kwargs.setdefault('CaloTruthStrategies' , [ 'ISF_MCTruthStrategyGroupCaloMuBrem', 'ISF_LLPTruthStrategy' ])
kwargs.setdefault('MSTruthStrategies' , ['ISF_LLPTruthStrategy'])
return getMC12TruthService(name, **kwargs);
def getMC12PlusTruthService(name="ISF_MC12PlusTruthService", **kwargs):
kwargs.setdefault('AlwaysAttachEndVertexIfParentDies', True)
# importing Reflex dictionary to access AtlasDetDescr::AtlasRegion enum
import ROOT, cppyy
cppyy.loadDictionary('AtlasDetDescrDict')
AtlasRegion = ROOT.AtlasDetDescr
kwargs.setdefault('ForceEndVtxInRegions' , [ AtlasRegion.fAtlasID ] )
return getMC12TruthService(name, **kwargs);
def getValidationTruthService(name="ISF_ValidationTruthService", **kwargs):
......
......@@ -4,6 +4,7 @@ from AthenaCommon.CfgGetter import addTool, addService, addAlgorithm
addService("ISF_HepMC_Services.ISF_HepMC_ServicesConfig.getTruthService" , "ISF_TruthService")
addService("ISF_HepMC_Services.ISF_HepMC_ServicesConfig.getMC12TruthService" , "ISF_MC12TruthService")
addService("ISF_HepMC_Services.ISF_HepMC_ServicesConfig.getMC12PlusTruthService" , "ISF_MC12PlusTruthService")
addService("ISF_HepMC_Services.ISF_HepMC_ServicesConfig.getMC12LLPTruthService" , "ISF_MC12LLPTruthService")
addService("ISF_HepMC_Services.ISF_HepMC_ServicesConfig.getMC15aTruthService" , "ISF_MC15aTruthService")
addService("ISF_HepMC_Services.ISF_HepMC_ServicesConfig.getMC15aPlusTruthService" , "ISF_MC15aPlusTruthService")
addService("ISF_HepMC_Services.ISF_HepMC_ServicesConfig.getMC15TruthService" , "ISF_MC15TruthService")
......
......@@ -55,7 +55,8 @@ ISF::HepMC_TruthSvc::HepMC_TruthSvc(const std::string& name,ISvcLocator* svc) :
m_screenEmptyPrefix(),
m_storeExtraBCs(true),
m_passWholeVertex(true),
m_alwaysAttachDeadParentEndVertex(false),
m_forceEndVtxRegionsVec(),
m_forceEndVtx(),
m_quasiStableParticlesIncluded(false)
{
// the particle stack filler tool
......@@ -69,12 +70,14 @@ ISF::HepMC_TruthSvc::HepMC_TruthSvc(const std::string& name,ISvcLocator* svc) :
declareProperty("SkipIfNoParentBarcode", m_skipIfNoParentBarcode );
declareProperty("IgnoreUndefinedBarcodes", m_ignoreUndefinedBarcodes );
declareProperty("PassWholeVertices", m_passWholeVertex );
declareProperty("AlwaysAttachEndVertexIfParentDies", m_alwaysAttachDeadParentEndVertex);
// the truth strategies for the different SimGeoIDs
// the truth strategies for the different AtlasDetDescr regions
declareProperty("BeamPipeTruthStrategies", m_geoStrategyHandles[AtlasDetDescr::fAtlasForward] );
declareProperty("IDTruthStrategies", m_geoStrategyHandles[AtlasDetDescr::fAtlasID] );
declareProperty("CaloTruthStrategies", m_geoStrategyHandles[AtlasDetDescr::fAtlasCalo] );
declareProperty("MSTruthStrategies", m_geoStrategyHandles[AtlasDetDescr::fAtlasMS] );
declareProperty("CavernTruthStrategies", m_geoStrategyHandles[AtlasDetDescr::fAtlasCavern] );
// attach end-vertex if parent particle dies for the different AtlasDetDescr regions
declareProperty("ForceEndVtxInRegions", m_forceEndVtxRegionsVec );
declareProperty("StoreExtraBarcodes", m_storeExtraBCs);
declareProperty("QuasiStableParticlesIncluded", m_quasiStableParticlesIncluded);
......@@ -123,7 +126,8 @@ StatusCode ISF::HepMC_TruthSvc::initialize()
// (removes the gaudi overhead in each call)
m_barcodeSvcQuick = &(*m_barcodeSvc);
// retrieve all registered geo strategies (Athena Alg Tools)
// retrieve the strategies for each atlas region (Athena Alg Tools)
// and setup whether we want to write end-vertices in this region whenever a truth particle dies
for ( unsigned short geoID=AtlasDetDescr::fFirstAtlasRegion; geoID<AtlasDetDescr::fNumAtlasRegions; ++geoID) {
if ( m_geoStrategyHandles[geoID].retrieve().isFailure() ) {
ATH_MSG_FATAL( m_screenOutputPrefix << "Could not retrieve TruthStrategy Tool Array for SimGeoID="
......@@ -139,6 +143,12 @@ StatusCode ISF::HepMC_TruthSvc::initialize()
for ( unsigned short i = 0; i < curNumStrategies; ++i) {
m_geoStrategies[geoID][i] = &(*m_geoStrategyHandles[geoID][i]);
}
// create an end-vertex for all truth particles ending in the current AtlasRegion?
bool forceEndVtx = std::find( m_forceEndVtxRegionsVec.begin(),
m_forceEndVtxRegionsVec.end(),
geoID ) != m_forceEndVtxRegionsVec.end();
m_forceEndVtx[geoID] = forceEndVtx;
}
ATH_MSG_VERBOSE( "initialize() successful" );
......@@ -265,7 +275,7 @@ void ISF::HepMC_TruthSvc::registerTruthIncident( ISF::ITruthIncident& ti) {
// -> child particles will NOT be added to the TruthEvent collection
// attach parent particle end vertex if it gets killed by this interaction
if (m_alwaysAttachDeadParentEndVertex && !ti.parentSurvivesIncident() ) {
if ( m_forceEndVtx[geoID] && !ti.parentSurvivesIncident() ) {
HepMC::GenVertex *vtx = createGenVertexFromTruthIncident( ti);
m_mcEvent->add_vertex( vtx);
}
......@@ -371,28 +381,15 @@ HepMC::GenVertex *ISF::HepMC_TruthSvc::createGenVertexFromTruthIncident( ISF::IT
Barcode::PhysicsProcessCode processCode = ti.physicsProcessCode();
Barcode::ParticleBarcode parentBC = ti.parentBarcode();
std::vector<double> weights(2);
std::vector<double> weights(1);
weights[0] = static_cast<double>(parentBC);
weights[1] = static_cast<double>(processCode); //now saved in GenVertex::id() ATLASSIM-2055
// Check for a previous end vertex on this particle. If one existed, snip it
// Check for a previous end vertex on this particle. If one existed, then we should put down next to this
// a new copy of the particle. This is the agreed upon version of the quasi-stable particle truth, where
// the vertex at which we start Q-S simulation no longer conserves energy, but we keep both copies of the
// truth particles
bool setPersistent = true;
HepMC::GenParticle *parent = ti.parentParticle( setPersistent );
if (parent->end_vertex()){
if(m_quasiStableParticlesIncluded) {
ATH_MSG_VERBOSE("Parent particle found with an end vertex attached.");
ATH_MSG_VERBOSE("Will delete the old vertex and swap in the new one.");
}
else {
ATH_MSG_WARNING("Parent particle found with an end vertex attached. This should only happen");
ATH_MSG_WARNING("in the case of simulating quasi-stable particles. That functionality");
ATH_MSG_WARNING("is not yet validated in ISF, so you'd better know what you're doing.");
ATH_MSG_WARNING("Will delete the old vertex and swap in the new one.");
}
HepMC::GenVertex * old_vtx = parent->end_vertex();
old_vtx->remove_particle( parent );
delete old_vtx; // This should be nice and iterative
}
// generate vertex
Barcode::VertexBarcode vtxbcode = m_barcodeSvcQuick->newVertex( parentBC, processCode );
......@@ -408,10 +405,31 @@ HepMC::GenVertex *ISF::HepMC_TruthSvc::createGenVertexFromTruthIncident( ISF::IT
HepMC::GenVertex *vtx = new HepMC::GenVertex( ti.position(), vtxID, weights );
vtx->suggest_barcode( vtxbcode );
// add parent particle to vtx
vtx->add_particle_in( parent );
ATH_MSG_VERBOSE ( "End Vertex representing process: " << processCode << ", for parent with barcode "<<parentBC<<". Creating." );
ATH_MSG_VERBOSE ( "Parent: " << *parent);
if (parent->end_vertex()){
if(!m_quasiStableParticlesIncluded) {
ATH_MSG_WARNING("Parent particle found with an end vertex attached. This should only happen");
ATH_MSG_WARNING("in the case of simulating quasi-stable particles. That functionality");
ATH_MSG_WARNING("is not yet validated in ISF, so you'd better know what you're doing.");
ATH_MSG_WARNING("Will delete the old vertex and swap in the new one.");
}
HepMC::GenParticle *new_parent = new HepMC::GenParticle( *parent ); // Copy the old guy
// Change the barcode
new_parent->suggest_barcode( m_barcodeSvcQuick->newSecondary( parentBC ) );
// Add the new parent to the old production vertex
parent->production_vertex()->add_particle_out( new_parent );
// Now add the new vertex to the new parent
vtx->add_particle_in( new_parent );
ATH_MSG_VERBOSE ( "QS End Vertex representing process: " << processCode << ", for parent with barcode "<<parentBC<<". Creating." );
ATH_MSG_VERBOSE ( "Parent: " << *parent);
} else { // Normal simulation
// add parent particle to vtx
vtx->add_particle_in( parent );
ATH_MSG_VERBOSE ( "End Vertex representing process: " << processCode << ", for parent with barcode "<<parentBC<<". Creating." );
ATH_MSG_VERBOSE ( "Parent: " << *parent);
}
return vtx;
}
......
......@@ -109,8 +109,14 @@ namespace ISF {
bool m_storeExtraBCs;
bool m_passWholeVertex;
bool m_alwaysAttachDeadParentEndVertex; //!< attach end vertex to all parent particles if they die
std::vector<bool> m_forceEndVtxRegionsVec; //!< property containing AtlasRegions for which
// to write end-vtx
bool m_forceEndVtx[AtlasDetDescr::fNumAtlasRegions]; //!< attach end vertex to
// all parent particles if they die
bool m_quasiStableParticlesIncluded; //!< does this job simulate quasi-stable particles.
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment