Commit 2776f63e authored by Elmar Ritsch's avatar Elmar Ritsch Committed by Graeme Stewart
Browse files

take BarcodeService from ISF_Flags (ATLASSIM-1658) (ISF_HepMC_Services-00-02-01)

	* python/ISF_HepMC_ServicesConfig.py - take BarcodeService from ISF_Flags
	(ATLASSIM-1658)
	* tag ISF_HepMC_Services-00-02-01

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

	* ISF_HepMC_Services/HepMC_TruthSvc.h - add m_passWholeVertex
	property. ATLASSIM-1603.
	* src/HepMC_TruthSvc.cxx - add PassWholeVertices property (default
	True for back-compatibility). Call
	ITruthIncident::setPassWholeVertices in
	HepMC_TruthSvc::registerTruthIncident. ATLASSIM-1603.
	* python/ISF_HepMC_ServicesConfig.py - add getMC15TruthService
	method and set new PassWholeVertices property to True for
	ISF_ValidationTruthService and
	ISF_MC12TruthService. ATLASSIM-1603.
	* tag ISF_HepMC_Services-00-02-00

2014-10-20  Zach Marshall <ZLMarshall@lbl.gov>
...
(Long ChangeLog diff - truncated)
parent e12b4558
......@@ -43,64 +43,65 @@ namespace ISF {
typedef ToolHandleArray<ITruthStrategy> TruthStrategyArray;
/** @class HepMC_TruthSvc
HepMC based version of the ISF::ITruthSvc,
currently it takes an ITruthIncident base class (!@TODO resolve to HepMC_TruthIncident )
currently it takes an ITruthIncident base class
@author Andreas.Salzburger -at- cern.ch , Elmar.Ritsch -at- cern.ch
*/
*/
class HepMC_TruthSvc : public AthService, public ITruthSvc {
public:
//** Constructor with parameters */
HepMC_TruthSvc( const std::string& name, ISvcLocator* pSvcLocator );
/** Destructor */
virtual ~HepMC_TruthSvc();
/** Athena algorithm's interface method initialize() */
StatusCode initialize();
/** Athena algorithm's interface method finalize() */
StatusCode finalize();
/** Register a truth incident */
void registerTruthIncident( ITruthIncident& truthincident);
/** Initialize the Truth Svc at the beginning of each event */
StatusCode initializeTruthCollection();
/** Finalize the Truth Svc at the end of each event*/
StatusCode releaseEvent();
/** Query the interfaces. **/
StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
private:
StoreGateSvc *m_storeGate; //!< The storegate svc
ServiceHandle<Barcode::IBarcodeSvc> m_barcodeSvc; //!< The Barcode service
Barcode::IBarcodeSvc *m_barcodeSvcQuick; //!< The Barcode service for quick access
std::string m_collectionName; //!< name of the output McEventCollection
McEventCollection *m_mcEventCollection; //!< pointer to the McEventCollection
HepMC::GenEvent *m_mcEvent;
/** the truth strategie applied (as AthenaToolHandle Array) */
TruthStrategyArray m_geoStrategyHandles[AtlasDetDescr::fNumAtlasRegions];
/** for faster access: using an internal pointer to the actual ITruthStrategy instances */
ITruthStrategy** m_geoStrategies[AtlasDetDescr::fNumAtlasRegions];
unsigned short m_numStrategies[AtlasDetDescr::fNumAtlasRegions];
/** MCTruth steering */
bool m_skipIfNoSecondaries; //!< do not record incident if numSecondaries==0
bool m_skipIfNoPrimaryBarcode; //!< do not record if primaryBarcode==fUndefinedBarcode
bool m_ignoreUndefinedBarcodes;//!< do/don't abort if retrieve an undefined barcode
std::string m_screenOutputPrefix;
std::string m_screenEmptyPrefix;
bool m_storeExtraBCs;
};
public:
//** Constructor with parameters */
HepMC_TruthSvc( const std::string& name, ISvcLocator* pSvcLocator );
/** Destructor */
virtual ~HepMC_TruthSvc();
/** Athena algorithm's interface method initialize() */
StatusCode initialize();
/** Athena algorithm's interface method finalize() */
StatusCode finalize();
/** Register a truth incident */
void registerTruthIncident( ITruthIncident& truthincident);
/** Initialize the Truth Svc at the beginning of each event */
StatusCode initializeTruthCollection();
/** Finalize the Truth Svc at the end of each event*/
StatusCode releaseEvent();
/** Query the interfaces. **/
StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
private:
StoreGateSvc *m_storeGate; //!< The storegate svc
ServiceHandle<Barcode::IBarcodeSvc> m_barcodeSvc; //!< The Barcode service
Barcode::IBarcodeSvc *m_barcodeSvcQuick; //!< The Barcode service for quick access
std::string m_collectionName; //!< name of the output McEventCollection
McEventCollection *m_mcEventCollection; //!< pointer to the McEventCollection
HepMC::GenEvent *m_mcEvent;
/** the truth strategie applied (as AthenaToolHandle Array) */
TruthStrategyArray m_geoStrategyHandles[AtlasDetDescr::fNumAtlasRegions];
/** for faster access: using an internal pointer to the actual ITruthStrategy instances */
ITruthStrategy** m_geoStrategies[AtlasDetDescr::fNumAtlasRegions];
unsigned short m_numStrategies[AtlasDetDescr::fNumAtlasRegions];
/** MCTruth steering */
bool m_skipIfNoSecondaries; //!< do not record incident if numSecondaries==0
bool m_skipIfNoPrimaryBarcode; //!< do not record if primaryBarcode==fUndefinedBarcode
bool m_ignoreUndefinedBarcodes;//!< do/don't abort if retrieve an undefined barcode
std::string m_screenOutputPrefix;
std::string m_screenEmptyPrefix;
bool m_storeExtraBCs;
bool m_passWholeVertex;
};
}
......
......@@ -21,8 +21,24 @@ def getTruthService(name="ISF_TruthService", **kwargs):
else :
return getMC12TruthService( name, **kwargs );
def getMC15TruthService(name="ISF_MC15TruthService", **kwargs):
kwargs.setdefault('BarcodeSvc' , ISF_Flags.BarcodeService() )
kwargs.setdefault('McEventCollection' , 'TruthEvent')
kwargs.setdefault('SkipIfNoSecondaries' , True)
kwargs.setdefault('SkipIfNoPrimaryBarcode' , True)
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('StoreExtraBarcodes' , False)
kwargs.setdefault('PassWholeVertices' , False) # new for MC15 - can write out partial vertices.
from ISF_HepMC_Services.ISF_HepMC_ServicesConf import ISF__HepMC_TruthSvc
return ISF__HepMC_TruthSvc(name, **kwargs);
def getMC12TruthService(name="ISF_MC12TruthService", **kwargs):
kwargs.setdefault('BarcodeSvc' , getService('ISF_MC12BarcodeSvc'))
kwargs.setdefault('BarcodeSvc' , ISF_Flags.BarcodeService() )
kwargs.setdefault('McEventCollection' , 'TruthEvent')
kwargs.setdefault('SkipIfNoSecondaries' , True)
kwargs.setdefault('SkipIfNoPrimaryBarcode' , True)
......@@ -32,12 +48,13 @@ def getMC12TruthService(name="ISF_MC12TruthService", **kwargs):
kwargs.setdefault('MSTruthStrategies' , [])
kwargs.setdefault('IgnoreUndefinedBarcodes' , False)
kwargs.setdefault('StoreExtraBarcodes' , False)
kwargs.setdefault('PassWholeVertices' , True)
from ISF_HepMC_Services.ISF_HepMC_ServicesConf import ISF__HepMC_TruthSvc
return ISF__HepMC_TruthSvc(name, **kwargs);
def getValidationTruthService(name="ISF_ValidationTruthService", **kwargs):
kwargs.setdefault('BarcodeSvc' , getService('ISF_ValidationBarcodeSvc'))
kwargs.setdefault('BarcodeSvc' , ISF_Flags.BarcodeService() )
kwargs.setdefault('McEventCollection' , 'TruthEvent')
kwargs.setdefault('SkipIfNoSecondaries' , True)
kwargs.setdefault('SkipIfNoPrimaryBarcode' , True)
......@@ -47,6 +64,7 @@ def getValidationTruthService(name="ISF_ValidationTruthService", **kwargs):
kwargs.setdefault('MSTruthStrategies' , [])
kwargs.setdefault('IgnoreUndefinedBarcodes' , True)
kwargs.setdefault('StoreExtraBarcodes' , False)
kwargs.setdefault('PassWholeVertices' , True)
from ISF_HepMC_Services.ISF_HepMC_ServicesConf import ISF__HepMC_TruthSvc
return ISF__HepMC_TruthSvc(name, **kwargs);
......@@ -53,7 +53,8 @@ ISF::HepMC_TruthSvc::HepMC_TruthSvc(const std::string& name,ISvcLocator* svc) :
m_ignoreUndefinedBarcodes(false),
m_screenOutputPrefix("isf >> "),
m_screenEmptyPrefix(),
m_storeExtraBCs(true)
m_storeExtraBCs(true),
m_passWholeVertex(true)
{
// the particle stack filler tool
declareProperty("McEventCollection", m_collectionName );
......@@ -65,7 +66,7 @@ ISF::HepMC_TruthSvc::HepMC_TruthSvc(const std::string& name,ISvcLocator* svc) :
declareProperty("SkipIfNoSecondaries", m_skipIfNoSecondaries );
declareProperty("SkipIfNoPrimaryBarcode", m_skipIfNoPrimaryBarcode );
declareProperty("IgnoreUndefinedBarcodes", m_ignoreUndefinedBarcodes );
declareProperty("PassWholeVertices", m_passWholeVertex );
// the truth strategies for the different SimGeoIDs
declareProperty("BeamPipeTruthStrategies", m_geoStrategyHandles[AtlasDetDescr::fAtlasForward] );
declareProperty("IDTruthStrategies", m_geoStrategyHandles[AtlasDetDescr::fAtlasID] );
......@@ -213,6 +214,9 @@ StatusCode ISF::HepMC_TruthSvc::releaseEvent() {
/** Register a truth incident */
void ISF::HepMC_TruthSvc::registerTruthIncident( ISF::ITruthIncident& truth) {
// pass whole vertex or individual secondaries
truth.setPassWholeVertices(m_passWholeVertex);
// the GeoID
AtlasDetDescr::AtlasRegion geoID = truth.geoID();
......@@ -265,6 +269,19 @@ void ISF::HepMC_TruthSvc::registerTruthIncident( ISF::ITruthIncident& truth) {
weights[0] = static_cast<double>(primBC);
weights[1] = static_cast<double>(processCode);
// Check for a previous end vertex on this particle. If one existed, snip it
bool setPersistent = true;
HepMC::GenParticle *prim = truth.primaryParticle( setPersistent );
if (prim->end_vertex()){
ATH_MSG_WARNING("Primary 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 = prim->end_vertex();
old_vtx->remove_particle( prim );
delete old_vtx; // This should be nice and iterative
}
// generate vertex
HepMC::GenVertex *vtx = new HepMC::GenVertex( truth.position(), 0, weights ); // 0 = barcode, overwritten below
Barcode::VertexBarcode vtxbcode = m_barcodeSvcQuick->newVertex( primBC, processCode );
......@@ -279,8 +296,6 @@ void ISF::HepMC_TruthSvc::registerTruthIncident( ISF::ITruthIncident& truth) {
vtx->suggest_barcode( vtxbcode);
// add primary particle to vtx
bool setPersistent = true;
HepMC::GenParticle *prim = truth.primaryParticle( setPersistent);
vtx->add_particle_in( prim );
// update primary barcode and add it to the vertex as outgoing particle
......
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