diff --git a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/InDetDxAOD.py b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/InDetDxAOD.py index d85617d32903125864a8027e259f402228c71de5..dc0beb3c002b60c08d03ff354615b5ac036cc694 100644 --- a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/InDetDxAOD.py +++ b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/InDetDxAOD.py @@ -3,12 +3,21 @@ ################# ## Load common flags from AthenaCommon.JobProperties import jobproperties as athCommonFlags +from DerivationFrameworkInDet.InDetCommon import * # Select active sub-systems dumpPixInfo=True dumpSctInfo=True dumpTrtInfo=False +# Thin hits to store only the ones on-track +thinHitsOnTrack=True + +# Thin track collection, if necessary +# Example (p_T > 1.0 GeV && delta_z0 < 5 mm): +# InDetTrackParticles.pt > 1*GeV && abs(DFCommonInDetTrackZ0AtPV) < 5.0 +thinTrackSelection = "InDetTrackParticles.pt > 0.1*GeV" + # Bytestream errors (for sub-systems who have implemented it) dumpBytestreamErrors=True @@ -179,12 +188,11 @@ if dumpPixInfo: ################# -### Setup derivation framework +### Setup Augmentation tools ################# -from AthenaCommon import CfgMgr +augmentationTools=[] -# DerivationJob is COMMON TO ALL DERIVATIONS -DerivationFrameworkJob = CfgMgr.AthSequencer("MySeq2") +from AthenaCommon import CfgMgr # Set up stream auditor from AthenaCommon.AppMgr import ServiceMgr as svcMgr @@ -194,8 +202,6 @@ svcMgr.DecisionSvc.CalcStats = True # Add the TSOS augmentation tool to the derivation framework -augmentationTools=[] - from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackStateOnSurfaceDecorator DFTSOS = DerivationFramework__TrackStateOnSurfaceDecorator(name = "DFTrackStateOnSurfaceDecorator", ContainerName = "InDetTrackParticles", @@ -289,12 +295,47 @@ if dumpLArCollisionTime: print lArCollisionTimeDecorator.properties() - +#==================================================================== +# Skimming Tools +#==================================================================== +skimmingTools = [] + +#minimumbiasTrig = '(L1_RD0_FILLED)' +# +#if not IsMonteCarlo: +# from DerivationFrameworkTools.DerivationFrameworkToolsConf import DerivationFramework__xAODStringSkimmingTool +# TrigSkimmingTool = DerivationFramework__xAODStringSkimmingTool(name = "TrigSkimmingTool", expression = minimumbiasTrig) +# ToolSvc += TrigSkimmingTool +# skimmingTools.append(TrigSkimmingTool) +# print "InDetDxAOD.py TrigSkimmingTool: ", TrigSkimmingTool + +#==================================================================== +# Thinning Tools +#==================================================================== +thinningTools = [] + +# TrackParticles directly +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackParticleThinning +IDTRKThinningTool = DerivationFramework__TrackParticleThinning(name = "IDTRKThinningTool", + ThinningService = "IDTRKThinningSvc", + SelectionString = thinTrackSelection, + InDetTrackParticlesKey = "InDetTrackParticles", + ThinHitsOnTrack = thinHitsOnTrack) +ToolSvc += IDTRKThinningTool +thinningTools.append(IDTRKThinningTool) + +#==================================================================== +# Create the derivation Kernel and setup output stream +#==================================================================== # Add the derivation job to the top AthAlgSeqeuence +# DerivationJob is COMMON TO ALL DERIVATIONS +DerivationFrameworkJob = CfgMgr.AthSequencer("MySeq2") from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__CommonAugmentation -DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("DFTSOS_KERN", - AugmentationTools = augmentationTools, - OutputLevel =INFO) +DerivationFrameworkJob += CfgMgr.DerivationFramework__DerivationKernel("DFTSOS_KERN", + AugmentationTools = augmentationTools, + SkimmingTools = skimmingTools, + ThinningTools = thinningTools, + OutputLevel = INFO) topSequence += DerivationFrameworkJob if (printIdTrkDxAODConf): @@ -304,12 +345,25 @@ if (printIdTrkDxAODConf): ################# ### Steer output file content ################# +## Add service for metadata +ToolSvc += CfgMgr.xAODMaker__TriggerMenuMetaDataTool( +"TriggerMenuMetaDataTool" ) +svcMgr.MetaDataSvc.MetaDataTools += [ ToolSvc.TriggerMenuMetaDataTool ] + + +## Steer output file from OutputStreamAthenaPool.MultipleStreamManager import MSMgr from D2PDMaker.D2PDHelpers import buildFileName from PrimaryDPDMaker.PrimaryDPDFlags import primDPD streamName = primDPD.WriteDAOD_IDTRKVALIDStream.StreamName fileName = buildFileName( primDPD.WriteDAOD_IDTRKVALIDStream ) IDTRKVALIDStream = MSMgr.NewPoolRootStream( streamName, fileName ) +IDTRKVALIDStream.AcceptAlgs(["DFTSOS_KERN"]) +from AthenaServices.Configurables import ThinningSvc, createThinningSvc +augStream = MSMgr.GetStream( streamName ) +evtStream = augStream.GetEventStream() +svcMgr += createThinningSvc( svcName="IDTRKThinningSvc", outStreams=[evtStream] ) + excludedAuxData = "-caloExtension.-cellAssociation.-clusterAssociation.-trackParameterCovarianceMatrices.-parameterX.-parameterY.-parameterZ.-parameterPX.-parameterPY.-parameterPZ.-parameterPosition" # Add generic event information @@ -354,8 +408,10 @@ if dumpTruthInfo: IDTRKVALIDStream.AddItem("xAOD::TruthEventContainer#*") IDTRKVALIDStream.AddItem("xAOD::TruthEventAuxContainer#*") -# Add trigger information +# Add trigger information (including metadata) if dumpTriggerInfo: + IDTRKVALIDStream.AddMetaDataItem("xAOD::TriggerMenuContainer#TriggerMenu") + IDTRKVALIDStream.AddMetaDataItem("xAOD::TriggerMenuAuxContainer#TriggerMenuAux.") IDTRKVALIDStream.AddItem("TileCellContainer#MBTSContainer") IDTRKVALIDStream.AddItem("xAOD::TrigDecision#xTrigDecision") IDTRKVALIDStream.AddItem("BCM_RDO_Container#BCM_RDOs") diff --git a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/SCTxAOD.py b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/SCTxAOD.py new file mode 100644 index 0000000000000000000000000000000000000000..061bc41457e7e2da032d60fa3430c32cff7c43e3 --- /dev/null +++ b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/share/SCTxAOD.py @@ -0,0 +1,201 @@ +################# +### Steering options +################# +## Load common flags +from AthenaCommon.JobProperties import jobproperties as athCommonFlags + +# Bytestream errors (for sub-systems who have implemented it) +dumpBytestreamErrors=True + +# Unassociated hits decorations +dumpUnassociatedHits=True + +# Force to do not dump truth info if set to False +# (otherwise determined by autoconf below) +dumpTruthInfo=True + +# Saves partial trigger information in the output stream (none otherwise) +dumpTriggerInfo=True + +# Print settings for main tools +printSctDxAODConf = True + +## Autoconfiguration adjustements +isSctDxAODSimulation = False +if (globalflags.DataSource == 'geant4'): + isSctDxAODSimulation = True + +if ( 'dumpTruthInfo' in dir() ): + dumpTruthInfo = dumpTruthInfo and isSctDxAODSimulation + +## Other settings +# Prefix for decoration, if any +prefixName = "" + +## More fine-tuning available for each tool/alg below (default value shown) + + +################# +### Setup decorators tools +################# + + + +from InDetPrepRawDataToxAOD.InDetPrepRawDataToxAODConf import SCT_PrepDataToxAOD +xAOD_SCT_PrepDataToxAOD = SCT_PrepDataToxAOD( name = "xAOD_SCT_PrepDataToxAOD") + ## Content steering Properties (default value shown as comment) +xAOD_SCT_PrepDataToxAOD.OutputLevel=INFO +xAOD_SCT_PrepDataToxAOD.UseTruthInfo = dumpTruthInfo +xAOD_SCT_PrepDataToxAOD.WriteRDOinformation = True + #xAOD_SCT_PrepDataToxAOD.WriteSDOs = True + #xAOD_SCT_PrepDataToxAOD.WriteSiHits = True # if available + +topSequence += xAOD_SCT_PrepDataToxAOD +if (printSctDxAODConf): + print xAOD_SCT_PrepDataToxAOD + print xAOD_SCT_PrepDataToxAOD.properties() + + + +################# +### Setup derivation framework +################# +from AthenaCommon import CfgMgr + +# DerivationJob is COMMON TO ALL DERIVATIONS +DerivationFrameworkJob = CfgMgr.AthSequencer("MySeq2") + +# Set up stream auditor +from AthenaCommon.AppMgr import ServiceMgr as svcMgr +if not hasattr(svcMgr, 'DecisionSvc'): + svcMgr += CfgMgr.DecisionSvc() +svcMgr.DecisionSvc.CalcStats = True + + +# Add the TSOS augmentation tool to the derivation framework +augmentationTools=[] + +from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__TrackStateOnSurfaceDecorator +DFTSOS = DerivationFramework__TrackStateOnSurfaceDecorator(name = "DFTrackStateOnSurfaceDecorator", + ContainerName = "InDetTrackParticles", + DecorationPrefix = prefixName, + StoreTRT = False, + StoreSCT = True, + StorePixel = False, + IsSimulation = isSctDxAODSimulation, + OutputLevel = INFO) +ToolSvc += DFTSOS +augmentationTools+=[DFTSOS] + + +# Add BS error augmentation tool +if dumpBytestreamErrors: + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__EventInfoBSErrDecorator + DFEI = DerivationFramework__EventInfoBSErrDecorator(name = "DFEventInfoBSErrDecorator", + ContainerName = "EventInfo", + DecorationPrefix = prefixName, + OutputLevel =INFO) + ToolSvc += DFEI + augmentationTools+=[DFEI] + if (printSctDxAODConf): + print DFEI + print DFEI.properties() + +# Add Unassociated hits augmentation tool +if dumpUnassociatedHits: + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__UnassociatedHitsGetterTool + unassociatedHitsGetterTool = DerivationFramework__UnassociatedHitsGetterTool (name = 'unassociatedHitsGetter', + TrackCollection = "Tracks", + + PixelClusters = "PixelClusters", + SCTClusterContainer = "SCT_Clusters", + TRTDriftCircleContainer = "TRT_DriftCircles") + ToolSvc += unassociatedHitsGetterTool + if (printSctDxAODConf): + print unassociatedHitsGetterTool + print unassociatedHitsGetterTool.properties() + + from DerivationFrameworkInDet.DerivationFrameworkInDetConf import DerivationFramework__UnassociatedHitsDecorator + unassociatedHitsDecorator = DerivationFramework__UnassociatedHitsDecorator (name ='unassociatedHitsDecorator', + UnassociatedHitsGetter = unassociatedHitsGetterTool, + ContainerName = "EventInfo", + DecorationPrefix = prefixName, + OutputLevel =INFO) + ToolSvc += unassociatedHitsDecorator + augmentationTools+=[unassociatedHitsDecorator] + if (printSctDxAODConf): + print unassociatedHitsDecorator + print unassociatedHitsDecorator.properties() + + +# Add the derivation job to the top AthAlgSeqeuence +from DerivationFrameworkCore.DerivationFrameworkCoreConf import DerivationFramework__CommonAugmentation +DerivationFrameworkJob += CfgMgr.DerivationFramework__CommonAugmentation("DFTSOS_KERN", + AugmentationTools = augmentationTools, + OutputLevel =INFO) + +topSequence += DerivationFrameworkJob +if (printSctDxAODConf): + print DerivationFrameworkJob + print DerivationFrameworkJob.properties() + +################# +### Steer output file content +################# + +from OutputStreamAthenaPool.MultipleStreamManager import MSMgr +from D2PDMaker.D2PDHelpers import buildFileName +from PrimaryDPDMaker.PrimaryDPDFlags import primDPD +streamName = primDPD.WriteDAOD_SCTVALIDStream.StreamName +fileName = buildFileName( primDPD.WriteDAOD_SCTVALIDStream ) +SCTVALIDStream = MSMgr.NewPoolRootStream( streamName, fileName ) +excludedAuxData = "-caloExtension.-cellAssociation.-clusterAssociation.-trackParameterCovarianceMatrices.-parameterX.-parameterY.-parameterZ.-parameterPX.-parameterPY.-parameterPZ.-parameterPosition" + +# Add generic event information +SCTVALIDStream.AddItem("xAOD::EventInfo#*") +SCTVALIDStream.AddItem("xAOD::EventAuxInfo#*") + +# Add track particles collection and traclets (if available) +SCTVALIDStream.AddItem("xAOD::TrackParticleContainer#InDetTrackParticles") +SCTVALIDStream.AddItem("xAOD::TrackParticleAuxContainer#InDetTrackParticlesAux."+excludedAuxData) + +# Add vertices +SCTVALIDStream.AddItem("xAOD::VertexContainer#PrimaryVertices") +SCTVALIDStream.AddItem("xAOD::VertexAuxContainer#PrimaryVerticesAux.-vxTrackAtVertex") + +# Add links and measurements +SCTVALIDStream.AddItem("xAOD::TrackStateValidationContainer#*") +SCTVALIDStream.AddItem("xAOD::TrackStateValidationAuxContainer#*") +SCTVALIDStream.AddItem("xAOD::TrackMeasurementValidationContainer#*") +SCTVALIDStream.AddItem("xAOD::TrackMeasurementValidationAuxContainer#*") + +# Add info about electrons and muons (are small containers) +SCTVALIDStream.AddItem("xAOD::MuonContainer#Muons") +SCTVALIDStream.AddItem("xAOD::MuonAuxContainer#MuonsAux.") +SCTVALIDStream.AddItem("xAOD::ElectronContainer#Electrons") +SCTVALIDStream.AddItem("xAOD::ElectronAuxContainer#ElectronsAux.") +SCTVALIDStream.AddItem("xAOD::TrackParticleContainer#GSFTrackParticles") +SCTVALIDStream.AddItem("xAOD::TrackParticleAuxContainer#GSFTrackParticlesAux."+excludedAuxData) + +# Add truth-related information +if dumpTruthInfo: + SCTVALIDStream.AddItem("xAOD::TruthParticleContainer#*") + SCTVALIDStream.AddItem("xAOD::TruthParticleAuxContainer#TruthParticlesAux.-caloExtension") + SCTVALIDStream.AddItem("xAOD::TruthVertexContainer#*") + SCTVALIDStream.AddItem("xAOD::TruthVertexAuxContainer#*") + SCTVALIDStream.AddItem("xAOD::TruthEventContainer#*") + SCTVALIDStream.AddItem("xAOD::TruthEventAuxContainer#*") + +# Add trigger information +if dumpTriggerInfo: + SCTVALIDStream.AddItem("TileCellContainer#MBTSContainer") + SCTVALIDStream.AddItem("xAOD::TrigDecision#xTrigDecision") + SCTVALIDStream.AddItem("BCM_RDO_Container#BCM_RDOs") + SCTVALIDStream.AddItem("xAOD::TrigNavigation#TrigNavigation") + SCTVALIDStream.AddItem("xAOD::TrigConfKeys#TrigConfKeys") + SCTVALIDStream.AddItem("HLT::HLTResult#HLTResult_HLT") + SCTVALIDStream.AddItem("xAOD::TrigDecisionAuxInfo#xTrigDecisionAux.") + SCTVALIDStream.AddItem("xAOD::TrigNavigationAuxInfo#TrigNavigationAux.") + +if (printSctDxAODConf): + print SCTVALIDStream diff --git a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/SCT_PrepDataToxAOD.cxx b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/SCT_PrepDataToxAOD.cxx index 44b6d41c0ada67e545be6886158733e497138aa5..ca1efec6ef654abebe9f54bc74bb60aecbb7030d 100644 --- a/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/SCT_PrepDataToxAOD.cxx +++ b/InnerDetector/InDetEventCnv/InDetPrepRawDataToxAOD/src/SCT_PrepDataToxAOD.cxx @@ -221,6 +221,9 @@ StatusCode SCT_PrepDataToxAOD::execute() // Set local error matrix xprd->setLocalPosition(locX,locY); + + + const Amg::MatrixX& localCov = prd->localCovariance(); if(localCov.size() == 1){ xprd->setLocalPositionError( localCov(0,0), 0., 0. ); @@ -240,6 +243,7 @@ StatusCode SCT_PrepDataToxAOD::execute() //Add SCT specific information const InDet::SiWidth cw = prd->width(); xprd->auxdata<int>("size") = (int)cw.colRow()[0]; + xprd->auxdata<int>("hitsInThirdTimeBin") = (int)(prd->hitsInThirdTimeBin()); xprd->auxdata<int>("bec") = m_SCTHelper->barrel_ec(clusterId) ; xprd->auxdata<int>("layer") = m_SCTHelper->layer_disk(clusterId) ;