diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/CMakeLists.txt b/Trigger/TrigHypothesis/TrigBjetHypo/CMakeLists.txt index a5259557e0aeb5fc7f3cbf9ae6e3f5eed33a3ad7..30de50557c95d0009c8256989282ab9a225de460 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/CMakeLists.txt +++ b/Trigger/TrigHypothesis/TrigBjetHypo/CMakeLists.txt @@ -17,6 +17,7 @@ atlas_depends_on_subdirs( PUBLIC Trigger/TrigEvent/TrigInDetEvent Trigger/TrigSteer/TrigInterfaces Trigger/TrigTools/TrigTrackJetFinderTool + Control/AthViews InnerDetector/InDetConditions/BeamSpotConditionsData PRIVATE Control/AthContainers @@ -48,7 +49,7 @@ atlas_add_component( TrigBjetHypo src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps xAODBase xAODTracking GaudiKernel Particle VxSecVertex TrigInDetEvent TrigInterfacesLib AthContainers GeoPrimitives EventInfo EventPrimitives FourMomUtils xAODBTagging xAODCore xAODJet xAODMuon BTaggingLib JetEvent VxVertex TrigCaloEvent TrigMuonEvent TrigNavigationLib TrigParticle TrigSteeringEvent DecisionHandlingLib ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps xAODBase xAODTracking GaudiKernel Particle VxSecVertex TrigInDetEvent TrigInterfacesLib AthContainers GeoPrimitives EventInfo EventPrimitives FourMomUtils xAODBTagging xAODCore xAODJet xAODMuon BTaggingLib JetEvent VxVertex TrigCaloEvent TrigMuonEvent TrigNavigationLib TrigParticle TrigSteeringEvent DecisionHandlingLib AthViews ) # Install files from the package: atlas_install_headers( TrigBjetHypo ) diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigBjetEtHypoTool.py b/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigBjetEtHypoTool.py index 0daf3797fe1d5729e7a7c1b63763d1fb187ecdcc..8eb3ca4b66f4cf4e970eb6e90514c995c5b2514a 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigBjetEtHypoTool.py +++ b/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigBjetEtHypoTool.py @@ -9,7 +9,7 @@ from AthenaCommon.Constants import VERBOSE,DEBUG #################################################################################################### -def TrigBjetEtHypoToolFromName( name, conf ): +def TrigBjetEtHypoToolFromName_j( name, conf ): from AthenaCommon.Constants import DEBUG """ set the name of the EtHypoTool (name=chain) and figure out the threshold and selection from conf """ @@ -26,26 +26,45 @@ def TrigBjetEtHypoToolFromName( name, conf ): for k, v in default_conf.items(): if k not in conf_dict: conf_dict[k] = v if conf_dict[k] == None: conf_dict[k] = v - - tool = getBjetEtHypoConfiguration( name,conf_dict ) - print "TrigBjetEtHypoToolFromName: name = %s, cut_j = %s, cut_gsc = %s "%(name,tool.EtThreshold,tool.GscThreshold ) + + from TrigBjetHypo.TrigBjetHypoConf import TrigBjetEtHypoTool + tool = TrigBjetEtHypoTool( name ) + tool.OutputLevel = DEBUG + tool.AcceptAll = False + tool.Multeplicity = int( conf_dict['multiplicity'] ) + tool.EtThreshold = float(conf_dict['threshold']) * GeV + + print "TrigBjetEtHypoToolFromName_j: name = %s, cut_j = %s "%(name,tool.EtThreshold) return tool + +def TrigBjetEtHypoToolFromName_gsc( name, conf ): + from AthenaCommon.Constants import DEBUG + """ set the name of the EtHypoTool (name=chain) and figure out the threshold and selection from conf """ + + default_conf = { 'threshold' : '0', + 'multiplicity' : '1', + 'gscThreshold' : '0', + 'bTag' : 'offperf', + 'bConfig' : 'split' } -#################################################################################################### + chain = conf + match = re_Bjet.match( chain ) + conf_dict = match.groupdict() -def getBjetEtHypoConfiguration( name,conf_dict ): - # Common for both gsc and non-gsc configurations - from TrigBjetHypo.TrigBjetHypoConf import TrigBjetEtHypoTool + for k, v in default_conf.items(): + if k not in conf_dict: conf_dict[k] = v + if conf_dict[k] == None: conf_dict[k] = v + from TrigBjetHypo.TrigBjetHypoConf import TrigBjetEtHypoTool tool = TrigBjetEtHypoTool( name ) - tool.OutputLevel = DEBUG - tool.AcceptAll = False - # Set Cut Thresholds - tool.EtThreshold = float(conf_dict['threshold']) * GeV - tool.GscThreshold = float(conf_dict['gscThreshold']) * GeV + tool.OutputLevel = DEBUG + tool.AcceptAll = False + tool.Multeplicity = int( conf_dict['multiplicity'] ) + tool.EtThreshold = float(conf_dict['gscThreshold']) * GeV + print "TrigBjetEtHypoToolFromName_gsc: name = %s, cut_j = %s "%(name,tool.EtThreshold) return tool - + #################################################################################################### if __name__ == "__main__": diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigGSCFexMTConfig.py b/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigGSCFexMTConfig.py index e6e9ecc70cf0188505458a38c126feb5ccc0fb78..c573e6bd5b9dc5e81716356263a5b0a54ba3e2f5 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigGSCFexMTConfig.py +++ b/Trigger/TrigHypothesis/TrigBjetHypo/python/TrigGSCFexMTConfig.py @@ -1,53 +1,49 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration from TrigBjetHypo.TrigBjetHypoConf import TrigGSCFexMT -#from TrigBjetHypo.TrigGSCFexTuning import * +#from TrigBjetHypo.TrigGSCFexTuning import * from AthenaCommon.Logging import logging -#from AthenaCommon.SystemOfUnits import mm, GeV +from AthenaCommon.SystemOfUnits import mm, GeV #commented here from AthenaCommon.AppMgr import ToolSvc -#from BTagging.BTaggingFlags import BTaggingFlags -#from BTagging.BTaggingConfiguration import getConfiguration -#BTagConfig = getConfiguration("Trig") -#BTagConfig.PrefixxAODBaseName(False) -#BTagConfig.PrefixVertexFinderxAODBaseName(False) -#BTagConfigSetupStatus = BTagConfig.setupJetBTaggerTool(ToolSvc, "AntiKt4EMTopo", SetupScheme="Trig", TaggerList=BTaggingFlags.TriggerTaggers) +#from BTagging.BTaggingFlags import BTaggingFlags #commented here +#from BTagging.BTaggingConfiguration import getConfiguration #commented here +#BTagConfig = getConfiguration("Trig") #commented here +#BTagConfig.PrefixxAODBaseName(False) #commented here +#BTagConfig.PrefixVertexFinderxAODBaseName(False) #commented here +#BTagConfigSetupStatus = BTagConfig.setupJetBTaggerTool(ToolSvc, "AntiKt4EMTopo", SetupScheme="Trig", TaggerList=BTaggingFlags.TriggerTaggers) #commented here from JetRec.JetRecCalibrationFinder import jrcf JetConfigSetupStatus = True -# johns hack from JetCalibTools.JetCalibToolsConf import JetCalibrationTool -def getGSCFexInstance( instance, version, algo ): - if instance=="EF" : - return GSCFex( instance=instance, version=version, algo=algo, name="EFGSCFex_"+algo ) +def getGSCFexInstance( theName ): + return GSCFex( name=theName, instance="EF" ) -def getGSCFexSplitInstance( instance, version, algo): - return GSCFexSplit( instance=instance, version=version, algo=algo, name=instance+"GSCFexSplit_"+algo ) +def getGSCFexSplitInstance( theName ): + return GSCFexSplit( name=theName, instance="EF" ) + +############################################################# +### EF Configuration +############################################################# class GSCFex (TrigGSCFexMT): __slots__ = [] - def __init__(self, instance, version, algo, name): + def __init__(self, instance, name): super( GSCFex, self ).__init__( name ) mlog = logging.getLogger('BtagHypoConfig.py') AllowedInstances = ["EF"] - AllowedVersions = ["2012"] - AllowedAlgos = ["EFID"] if instance not in AllowedInstances : mlog.error("Instance "+instance+" is not supported!") return None - if version not in AllowedVersions : - mlog.error("Version "+version+" is not supported!") - return None - - self.JetKey = "EFJet" + self.JetKey = "EFJet" self.PriVtxKey = "EFHistoPrmVtx" self.TrackKey = "InDetTrigTrackingxAODCnv_Bjet_EFID" @@ -61,37 +57,30 @@ class GSCFex (TrigGSCFexMT): print self.JetGSCCalibrationTool -########################################### +############################################################# # For split configuration -########################################### +############################################################# class GSCFexSplit (TrigGSCFexMT): __slots__ = [] - def __init__(self, instance, version, algo, name): + def __init__(self, instance, name, PriVtxKey="xPrimVx", TrackKey="InDetTrigTrackingxAODCnv_Bjet_IDTrig"): super( GSCFexSplit, self ).__init__( name ) mlog = logging.getLogger('BtagHypoConfig.py') AllowedInstances = ["EF", "MuJetChain"] - AllowedVersions = ["2012"] - AllowedAlgos = ["EFID"] if instance not in AllowedInstances : mlog.error("Instance "+instance+" is not supported!") return None - - if version not in AllowedVersions : - mlog.error("Version "+version+" is not supported!") - return None self.JetKey = "SplitJet" if instance=="MuJetChain" : self.JetKey = "FarawayJet" - instance = "EF" - self.PriVtxKey = "xPrimVx" #"EFHistoPrmVtx" - self.TrackKey = "InDetTrigTrackingxAODCnv_Bjet_IDTrig" + self.PriVtxKey = PriVtxKey + self.TrackKey = TrackKey # IMPORT OFFLINE TOOLS self.setupOfflineTools = True @@ -112,7 +101,6 @@ class GSCFexSplit (TrigGSCFexMT): from AthenaCommon.AppMgr import ToolSvc ToolSvc += myGSCTool self.JetGSCCalibrationTool = myGSCTool - print "Printing GSCCalibrationTool" print self.JetGSCCalibrationTool #JetCalibrationTool("myJCTool_trigger", # IsData=True, @@ -120,3 +108,4 @@ class GSCFexSplit (TrigGSCFexMT): # CalibSequence="JetArea_EtaJES_GSC", # JetCollection="AntiKt4EMTopo") + diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoAlgMT.cxx index d3e7eb85e7f19ae9d30e3426a80e626272eb5f09..b6fe575d9dacead21d5628d7aba688c53307957e 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoAlgMT.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoAlgMT.cxx @@ -5,38 +5,35 @@ #include "GaudiKernel/Property.h" #include "TrigBjetEtHypoAlgMT.h" #include "TrigSteeringEvent/PhiHelper.h" +#include "AthViews/ViewHelper.h" TrigBjetEtHypoAlgMT::TrigBjetEtHypoAlgMT( const std::string& name, ISvcLocator* pSvcLocator ) : ::HypoBase( name, pSvcLocator ) {} -TrigBjetEtHypoAlgMT::~TrigBjetEtHypoAlgMT() -{} +TrigBjetEtHypoAlgMT::~TrigBjetEtHypoAlgMT() {} StatusCode TrigBjetEtHypoAlgMT::initialize() { ATH_MSG_INFO ( "Initializing " << name() << "..." ); - ATH_MSG_DEBUG( "declareProperty review:" ); - ATH_MSG_DEBUG( " " << m_jetsKey ); - ATH_MSG_DEBUG( " " << m_outputJetsKey ); - ATH_MSG_DEBUG( " " << m_imposeZconstraint); - ATH_MSG_DEBUG( " " << m_etaHalfWidth ); - ATH_MSG_DEBUG( " " << m_phiHalfWidth ); - ATH_MSG_DEBUG( " " << m_zHalfWidth ); - ATH_MSG_DEBUG( " " << m_minJetEt ); - ATH_MSG_DEBUG( " " << m_maxJetEta ); + ATH_MSG_DEBUG( "declareProperty review:" ); + ATH_MSG_DEBUG( " " << m_useView ); + ATH_MSG_DEBUG( " " << m_roiLink ); + ATH_MSG_DEBUG( " " << m_jetLink ); + ATH_MSG_DEBUG( " " << m_multipleDecisions ); ATH_MSG_DEBUG( "Initializing Tools" ); - ATH_CHECK( m_hypoTools.retrieve() ); + ATH_CHECK( m_hypoTools.retrieve() ); ATH_MSG_DEBUG( "Initializing HandleKeys" ); - CHECK( m_jetsKey.initialize() ); - CHECK( m_outputJetsKey.initialize() ); - CHECK( m_outputRoiKey.initialize() ); - // FOLLOWING WILL CHANGE -- JUST FOR TEMPORARY DEBUGGING - CHECK( m_trackParticleContainerKey.initialize() ); // TMP - CHECK( m_roiKey.initialize() ); // TMP + CHECK( m_inputJetsKey.initialize() ); + CHECK( m_inputRoIKey.initialize() ); + CHECK( m_inputPrimaryVertexKey.initialize() ); + + // Deal with what is stored into View + if ( m_useView ) + renounce( m_inputJetsKey ); return StatusCode::SUCCESS; } @@ -55,158 +52,97 @@ StatusCode TrigBjetEtHypoAlgMT::execute_r( const EventContext& context ) const { // Taken from Jet code // Read in previous Decisions made before running this Hypo Alg. // The container should have only one such Decision in case we are cutting on 'j' threshold (for L1) + ATH_MSG_DEBUG( "Retrieving Previous Decision" ); SG::ReadHandle< TrigCompositeUtils::DecisionContainer > prevDecisionHandle = SG::makeHandle( decisionInput(),context ); CHECK( prevDecisionHandle.isValid() ); + const TrigCompositeUtils::DecisionContainer *prevDecisionContainer = prevDecisionHandle.get(); ATH_MSG_DEBUG( "Running with "<< prevDecisionContainer->size() <<" previous decisions"); - // ============================================================= - // Just for debugging -- WILL BE REMOVED - - // Retrieve ROIs from RoIBuilder // TMP - SG::ReadHandle< TrigRoiDescriptorCollection > superRoiHandle = SG::makeHandle( m_roiKey,context ); // TMP - CHECK( superRoiHandle.isValid() ); // TMP - const TrigRoiDescriptorCollection *superRoi = superRoiHandle.get(); // TMP - ATH_MSG_DEBUG( "Retrieved Super RoI Container with size " << superRoi->size() ); // TMP - for ( auto *roi : *superRoi ) // TMP - ATH_MSG_DEBUG( " ** roi : eta=" << roi->eta() <<" phi="<< roi->phi() ); // TMP - - // Retrieve Track Particles // TMP - SG::ReadHandle< xAOD::TrackParticleContainer > recoTracksContainerHandle = SG::makeHandle( m_trackParticleContainerKey,context ); // TMP - CHECK( recoTracksContainerHandle.isValid() ); // TMP - const xAOD::TrackParticleContainer *recoTracksContainer = recoTracksContainerHandle.get(); // TMP - ATH_MSG_DEBUG( "Retrieved " << recoTracksContainer->size() << " Track Particles from FTF step" ); // TMP - for ( auto *particle : *recoTracksContainer ) // TMP - ATH_MSG_DEBUG( " ** pt=" << particle->p4().Et()<<" eta="<< particle->eta() <<" phi="<< particle->phi() ); // TMP - - // ============================================================= - - // Retrieve Jet Container ( Calo Jets ) - SG::ReadHandle< xAOD::JetContainer > jetContainerHandle = SG::makeHandle( m_jetsKey,context ); - ATH_MSG_DEBUG( "Retrieved jets from : " << m_jetsKey.key() ); - CHECK( jetContainerHandle.isValid() ); + // Retrieve Jets + const xAOD::JetContainer *jetCollection = nullptr; + if ( not m_useView ) CHECK( retrieveJetsFromStoreGate( context,jetCollection ) ); + else CHECK( retrieveJetsFromEventView( context,jetCollection,prevDecisionHandle ) ); - const xAOD::JetContainer *jetCollection = jetContainerHandle.get(); ATH_MSG_DEBUG( "Found " << jetCollection->size()<< " jets." ); for ( const xAOD::Jet *jet : * jetCollection ) ATH_MSG_INFO(" -- Jet pt=" << jet->p4().Et() <<" eta="<< jet->eta() << " phi="<< jet->phi() ); - // Retrieve Primary Vertex - // Right now vertexing is not available. Using dummy vertex at (0,0,0) // TMP - const Amg::Vector3D *primaryVertex = nullptr; // TMP - - if ( m_imposeZconstraint ) { - ATH_MSG_DEBUG( "Retrieving primary vertex." ); - // Here we should retrieve the primary vertex // TO-DO - primaryVertex = new Amg::Vector3D( 0,0,0 ); // TMP - // Add protection against failure during primary vertex retrieval. // TO-DO - ATH_MSG_DEBUG( " ** PV = (" << primaryVertex->x() << - "," << primaryVertex->y() << - "," << primaryVertex->z() << ")" ); + // Retrieve RoI to be linked to the output decision + const TrigRoiDescriptorCollection *roiContainer = nullptr; + if ( not m_useView ) { + ATH_MSG_DEBUG( "Retrieving input TrigRoiDescriptorCollection with key: " << m_inputRoIKey ); + SG::ReadHandle< TrigRoiDescriptorCollection > roiContainerHandle = SG::makeHandle( m_inputRoIKey,context ); + CHECK( roiContainerHandle.isValid() ); + + roiContainer = roiContainerHandle.get(); + ATH_MSG_DEBUG( "Retrieved " << roiContainer->size() <<" input RoIs" ); + for ( const TrigRoiDescriptor *roi : *roiContainer ) + ATH_MSG_DEBUG( " ** eta="<< roi->eta() << " phi=" << roi->phi() ); } + // Retrieve Primary Vertex + const xAOD::VertexContainer *vertexContainer = nullptr; + CHECK( retrievePrimaryVertexFromStoreGate( context,vertexContainer ) ); + + ATH_MSG_DEBUG( "Found " << vertexContainer->size() << " vertices." ); + for ( const xAOD::Vertex *primVertex : *vertexContainer ) + ATH_MSG_DEBUG( " ** vertex = " + << primVertex->x() << "," + << primVertex->y() << "," + << primVertex->z() ); // ========================================================================================================================== // ** Prepare Outputs // ========================================================================================================================== - // Prepare Output - // Output RoIs -- WILL CHANGE -- TMP - std::unique_ptr< TrigRoiDescriptorCollection > roiContainer( new TrigRoiDescriptorCollection() ); // TMP - - // Output Jet Collection - std::unique_ptr< xAOD::JetContainer > outputJets( new xAOD::JetContainer() ); - std::unique_ptr< xAOD::JetAuxContainer > outputJetsAux( new xAOD::JetAuxContainer() ); - outputJets->setStore( outputJetsAux.get() ); - // Decisions - std::unique_ptr< TrigCompositeUtils::DecisionContainer > decisions = std::make_unique< TrigCompositeUtils::DecisionContainer >(); - std::unique_ptr< TrigCompositeUtils::DecisionAuxContainer > aux = std::make_unique< TrigCompositeUtils::DecisionAuxContainer >(); - decisions->setStore( aux.get() ); + std::unique_ptr< TrigCompositeUtils::DecisionContainer > outputDecision( new TrigCompositeUtils::DecisionContainer() ); + std::unique_ptr< TrigCompositeUtils::DecisionAuxContainer > outputAuxDecision( new TrigCompositeUtils::DecisionAuxContainer() ); + outputDecision->setStore( outputAuxDecision.get() ); // ========================================================================================================================== - // ** Creating ShortList of Jet Container + // ** Compute Decisions // ========================================================================================================================== + + const unsigned int nDecisions = m_multipleDecisions ? jetCollection->size() : 1; - // Make a copy of the jet containers - for ( const xAOD::Jet *jet : *jetCollection ) { - // We select Jets above a specific eta and pt range - if ( jet->p4().Et() < m_minJetEt ) { - ATH_MSG_DEBUG( "** Jet below the " << m_minJetEt.value() << " GeV threshold; Et " << jet->p4().Et() <<"; Skipping this Jet." ); - continue; - } - if ( fabs( jet->eta() ) > m_maxJetEta ) { - ATH_MSG_DEBUG( "** Jet outside the |eta| < " << m_maxJetEta.value() << " requirement; Eta = " << jet->eta() << "; Skipping this Jet." ); - continue; + unsigned int counter = 0; + for ( const ToolHandle< TrigBjetEtHypoTool >& tool : m_hypoTools ) { + const HLT::Identifier decisionId = tool->getId(); + + ATH_MSG_DEBUG( "Creating " << nDecisions << " output decision" ); + std::vector< TrigCompositeUtils::Decision* > newDecisions; + for ( unsigned int index(0); index<nDecisions; index++ ) { + // const std::string decisionName = name()+"_roi_"+std::to_string(index); + // ATH_MSG_DEBUG( " ** " << decisionName ); + newDecisions.push_back( TrigCompositeUtils::newDecisionIn( outputDecision.get() ) );//,decisionName ) ); } - ATH_MSG_DEBUG( "** Jet :: Et " << jet->p4().Et() <<"; Eta " << jet->eta() << "; Phi " << jet->phi() ); - // Protection in case there is not a Primary vertex but the Z contraint option is set to True - if ( m_imposeZconstraint && primaryVertex == nullptr ) { - // Not sure here what the best solution is. We can't change the m_imposeZconstraint value being const (and not thread safe) - ATH_MSG_ERROR( "Option for imposing Z constraint is set to True, but no primary vertex has been found." ); - return StatusCode::FAILURE; + bool pass = false; + CHECK( tool->decide( jetCollection,pass ) ); + if ( pass ) { + for( unsigned int index(0); index<nDecisions; index++ ) + TrigCompositeUtils::addDecisionID( decisionId,newDecisions.at(index) ); } - // Copy Jet - xAOD::Jet *toBeAdded = new xAOD::Jet(); - outputJets->push_back( toBeAdded ); - *toBeAdded = *jet; - - // Create RoI (we may require here PVz constraint) - double phiMinus = HLT::wrapPhi(jet->phi() - m_phiHalfWidth); - double phiPlus = HLT::wrapPhi(jet->phi() + m_phiHalfWidth); - - double etaMinus = jet->eta() - m_etaHalfWidth; - double etaPlus = jet->phi() + m_etaHalfWidth; - - // Impose Z matching (if enabled) - ATH_MSG_DEBUG( "Building RoI" ); - TrigRoiDescriptor *newRoI = nullptr; - if ( not m_imposeZconstraint ) { - newRoI = new TrigRoiDescriptor( jet->eta(),etaMinus, etaPlus, - jet->phi(), phiMinus, phiPlus ); - } else { - ATH_MSG_DEBUG( " ** Imposing Z constraint while building RoI" ); - double zMinus = primaryVertex->z() - m_zHalfWidth; - double zPlus = primaryVertex->z() + m_zHalfWidth; + // ========================================================================================================================== + // ** Linking objects to decision (inside Hypo Tool loop) + // ========================================================================================================================== + + if ( not m_useView ) { + for( unsigned int index(0); index<nDecisions; index++ ) + newDecisions.at(index)->setObjectLink( m_roiLink.value(),ElementLink< TrigRoiDescriptorCollection >( m_inputRoIKey.key(),index ) ); + ATH_MSG_DEBUG( "Linking RoIs `" << m_roiLink.value() << "` to output decision." ); - newRoI = new TrigRoiDescriptor( jet->eta(),etaMinus, etaPlus, - jet->phi(), phiMinus, phiPlus, - primaryVertex->z(),zMinus,zPlus ); + for( unsigned int index(0); index<nDecisions; index++ ) + newDecisions.at(index)->setObjectLink( m_jetLink.value(),ElementLink< xAOD::JetContainer >( m_inputJetsKey.key(),index ) ); + ATH_MSG_DEBUG( "Linking Jets `" << m_jetLink.value() << "` to output decision." ); } - ATH_MSG_DEBUG( " -- RoI : eta=" << newRoI->eta() << " phi=" << newRoI->phi() ); - - // Put protection against nullpointer // TO-DO - roiContainer->push_back( newRoI ); - } - - // ========================================================================================================================== - // ** Compute Decisions - // ========================================================================================================================== - - // Taken from Jet Code here - const TrigCompositeUtils::Decision *prevDecision = prevDecisionContainer->at(0); - TrigCompositeUtils::Decision *newDecision = TrigCompositeUtils::newDecisionIn( decisions.get() ); - // Link Jet Collection to decision so that I can use it in the following b-jet trigger steps (?) - newDecision->setObjectLink( "SplitJets", ElementLink< xAOD::JetContainer >( m_jetsKey.key(),0 ) ); - ATH_MSG_DEBUG( "Linking 'SplitJets' to output decisions" ); - - const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs { - TrigCompositeUtils::decisionIDs( prevDecision ).begin(), - TrigCompositeUtils::decisionIDs( prevDecision ).end() - }; - - // Decide (Hypo Tool) - for ( const ToolHandle< TrigBjetEtHypoTool >& tool : m_hypoTools ) { - const HLT::Identifier decisionId = tool->getId(); - // Check previous decision is 'passed' - if ( not TrigCompositeUtils::passed( decisionId.numeric() , previousDecisionIDs ) ) - continue; - bool pass = false; - CHECK( tool->decide( outputJets.get(),pass ) ); - // CHECK( tool->decide( jetCollection,pass ) ); - if ( pass ) TrigCompositeUtils::addDecisionID( decisionId,newDecision ); + + for( unsigned int index(0); index<nDecisions; index++ ) + TrigCompositeUtils::linkToPrevious( newDecisions.at(index),decisionInput().key(),counter ); + counter++; } // ========================================================================================================================== @@ -215,22 +151,70 @@ StatusCode TrigBjetEtHypoAlgMT::execute_r( const EventContext& context ) const { // Save Output Decisions SG::WriteHandle< TrigCompositeUtils::DecisionContainer > handle = SG::makeHandle( decisionOutput(), context ); - CHECK( handle.record( std::move( decisions ), std::move( aux ) ) ); + CHECK( handle.record( std::move(outputDecision),std::move(outputAuxDecision) ) ); ATH_MSG_DEBUG( "Exiting with " << handle->size() << " decisions" ); - // Save Output Jet Contaienr - SG::WriteHandle< xAOD::JetContainer > outputJetHandle = SG::makeHandle( m_outputJetsKey,context ); - ATH_MSG_DEBUG( "Saving jet collection " << m_outputJetsKey.key() << " with " << outputJets->size() << " elements " ); - CHECK( outputJetHandle.record( std::move( outputJets ), std::move( outputJetsAux ) ) ); - - // Output RoI Container -- WILL CHANGE -- TMP - SG::WriteHandle< TrigRoiDescriptorCollection > roiContainerHandle = SG::makeHandle( m_outputRoiKey,context ); // TMP - ATH_MSG_DEBUG( "Sabing roi collection " << m_outputRoiKey.key() << " with " << roiContainer->size() <<" elements " ); // TMP - CHECK( roiContainerHandle.record( std::move( roiContainer ) ) ); // TMP + return StatusCode::SUCCESS; +} +StatusCode TrigBjetEtHypoAlgMT::retrieveJetsFromStoreGate( const EventContext& context, + const xAOD::JetContainer*& jetCollection ) const { + SG::ReadHandle< xAOD::JetContainer > jetContainerHandle = SG::makeHandle( m_inputJetsKey,context ); + ATH_MSG_DEBUG( "Retrieved jets from : " << m_inputJetsKey.key() ); + CHECK( jetContainerHandle.isValid() ); + jetCollection = jetContainerHandle.get(); return StatusCode::SUCCESS; } +StatusCode TrigBjetEtHypoAlgMT::retrievePrimaryVertexFromStoreGate( const EventContext& context, + const xAOD::VertexContainer*& vertexContainer ) const { + SG::ReadHandle< xAOD::VertexContainer > vertexContainerHandle = SG::makeHandle( m_inputPrimaryVertexKey,context ); + ATH_MSG_DEBUG( "Retrieved primary vertex from : " << m_inputPrimaryVertexKey.key() ); + CHECK( vertexContainerHandle.isValid() ); + vertexContainer = vertexContainerHandle.get(); + return StatusCode::SUCCESS; +} +StatusCode TrigBjetEtHypoAlgMT::retrieveJetsFromEventView( const EventContext& context, + const xAOD::JetContainer*& jetCollection, + SG::ReadHandle< TrigCompositeUtils::DecisionContainer >& prevDecisionHandle ) const { + xAOD::JetContainer *output = new xAOD::JetContainer(); + std::unique_ptr< xAOD::JetAuxContainer > outputAux( new xAOD::JetAuxContainer() ); + output->setStore( outputAux.release() ); + + std::map< const TrigRoiDescriptor*,int > mapRoIs; + + for ( auto previousDecision: *prevDecisionHandle ) { + //get RoI + auto roiEL = previousDecision->objectLink<TrigRoiDescriptorCollection>( "initialRoI" ); + ATH_CHECK( roiEL.isValid() ); + const TrigRoiDescriptor* roi = *roiEL; + ATH_MSG_DEBUG( "Retrieved RoI from previous decision " ); + ATH_MSG_DEBUG( " ** eta=" << roi->eta() <<" phi="<< roi->phi() ); + + // Check the jet has not been already retrieved + if ( mapRoIs.find( roi ) != mapRoIs.end() ) continue; + mapRoIs[ roi ] = 1; + + // get View + auto viewEL = previousDecision->objectLink< ViewContainer >( "view" ); + ATH_CHECK( viewEL.isValid() ); + ATH_MSG_DEBUG( "Retrieved View" ); + SG::ReadHandle< xAOD::JetContainer > jetContainerHandle = ViewHelper::makeHandle( *viewEL, m_inputJetsKey, context); + ATH_CHECK( jetContainerHandle.isValid() ); + ATH_MSG_DEBUG ( "jet container handle size: " << jetContainerHandle->size() << "..." ); + const xAOD::JetContainer *jetContainer = jetContainerHandle.get(); + for ( const xAOD::Jet *jet : *jetContainer ) { + ATH_MSG_DEBUG( " *** pt=" << jet->p4().Et() << " eta="<< jet->eta()<< " phi=" << jet->phi() ); + + // Make a Copy + xAOD::Jet *copyJet = new xAOD::Jet(); + output->push_back( copyJet ); + *copyJet = *jet; + } + } + jetCollection = new xAOD::JetContainer( *output ); + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoAlgMT.h b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoAlgMT.h index 95703e32afcb4824f1e9522536ca57f338d9fddb..675eac792f5e821307240ad202bc7ff03c20fddc 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoAlgMT.h +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoAlgMT.h @@ -39,24 +39,26 @@ class TrigBjetEtHypoAlgMT : public ::HypoBase { private: TrigBjetEtHypoAlgMT(); + + StatusCode retrieveJetsFromStoreGate( const EventContext& context,const xAOD::JetContainer*& ) const; + StatusCode retrievePrimaryVertexFromStoreGate( const EventContext& context,const xAOD::VertexContainer*& ) const; + + StatusCode retrieveJetsFromEventView( const EventContext& context, + const xAOD::JetContainer*&, + SG::ReadHandle< TrigCompositeUtils::DecisionContainer >& ) const; + + private: ToolHandleArray< TrigBjetEtHypoTool > m_hypoTools {this,"HypoTools",{},"Hypo Tools"}; private: - // This part is taken from Jet Splitter - Gaudi::Property< bool > m_imposeZconstraint {this,"ImposeZconstraint",false,"Impose Constraint on PV z, thus selecting Jets pointing to PV"}; - Gaudi::Property< float > m_etaHalfWidth {this,"EtaHalfWidth",0.4,"Eta Half Width"}; - Gaudi::Property< float > m_phiHalfWidth {this,"PhiHalfWidth",0.4,"Phi Half Width"}; - Gaudi::Property< float > m_zHalfWidth {this,"ZHalfWidth",10.0,"Z Half Width in mm"}; - Gaudi::Property< float > m_minJetEt {this,"JetMinEt",15000,"Minimum of Output Jet Et in GeV"}; - Gaudi::Property< float > m_maxJetEta {this,"JetMaxEta",3.2,"Maximum eta acceptance of output Jet"}; - //=========== Handles - SG::ReadHandleKey< xAOD::JetContainer > m_jetsKey {this,"Jets","Jets","Input Jet Container Key"}; - SG::WriteHandleKey< xAOD::JetContainer > m_outputJetsKey {this,"OutputJets","SplitJets","Output Jet Container Key"}; - SG::WriteHandleKey< TrigRoiDescriptorCollection > m_outputRoiKey {this,"OutputRoi","SplitJet","Output RoI Container Key -- Same as OutputJets"}; - - // Just for checking I have reconstructed tracks and the roi for the super roi -- WILL CHANGE - SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleContainerKey {this,"TrackParticleContainerKey","xAODTracks",""}; - SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiKey {this,"RoiKey","Undefined",""}; + Gaudi::Property< bool > m_useView {this,"UseView",false,"Use configuration that supports Event View"}; + Gaudi::Property< bool > m_multipleDecisions {this,"MultipleDecisions",false,"Create multiple decisions, one per input RoI"}; + Gaudi::Property< std::string > m_roiLink {this,"RoILink","roi","RoI link to attach to the output decision"}; + Gaudi::Property< std::string > m_jetLink {this,"JetLink","jets","Jets link to attach to the output decision"}; + + SG::ReadHandleKey< xAOD::JetContainer > m_inputJetsKey {this,"Jets","Undefined","Input Jet Container Key"}; + SG::ReadHandleKey< TrigRoiDescriptorCollection > m_inputRoIKey {this,"RoIs","Undefined","Input RoIs that will be linked to the output decision"}; + SG::ReadHandleKey< xAOD::VertexContainer > m_inputPrimaryVertexKey {this,"PrimaryVertex","Undefined","Input Primary Vertex that will be linked to the output decision"}; }; #endif //> !TRIGBJETHYPO_TRIGBJETETHYPOALG_H diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoTool.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoTool.cxx index 6106eba6871404209a2a5ce590376ceea04e4034..b062b265640a485b6fd02c994a910329af2bf0be 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoTool.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoTool.cxx @@ -29,11 +29,10 @@ TrigBjetEtHypoTool::~TrigBjetEtHypoTool() {} StatusCode TrigBjetEtHypoTool::initialize() { ATH_MSG_INFO("Initializing TrigBjetEtHypoTool"); - ATH_MSG_DEBUG( "declareProperty review:" ); - ATH_MSG_DEBUG( " " << m_acceptAll ); - ATH_MSG_DEBUG( " " << m_etCalibration ); - ATH_MSG_DEBUG( " " << m_etThreshold ); - ATH_MSG_DEBUG( " " << m_gscThreshold ); + ATH_MSG_DEBUG( "declareProperty review:" ); + ATH_MSG_DEBUG( " " << m_acceptAll ); + ATH_MSG_DEBUG( " " << m_multeplicity ); + ATH_MSG_DEBUG( " " << m_etThreshold ); ATH_MSG_DEBUG( "Tool configured for chain/id: " << m_id ); return StatusCode::SUCCESS; @@ -46,51 +45,50 @@ StatusCode TrigBjetEtHypoTool::decide( const xAOD::JetContainer* jetCollection,b // Right now only considering single b-jet chains. // Will be revised with higher multeplicity - ATH_MSG_INFO( "Executing TrigBjetEtHypoTool " ); // DEBUG + ATH_MSG_DEBUG( "Executing "<< name() ); ATH_MSG_DEBUG( "Evaluating 'decide' on " << jetCollection->size() << " input jets " ); pass = false; + int nJets = 0; + + if ( m_acceptAll ) { + ATH_MSG_DEBUG( "REGTEST: AcceptAll property is set: taking all events" ); + ATH_MSG_DEBUG( "REGTEST: Trigger decision is 1" ); + pass = true; + return StatusCode::SUCCESS; + } + + ATH_MSG_DEBUG( "REGTEST: AcceptAll property not set: applying the selection" ); // Run on Jet Collection for ( const xAOD::Jet* jet : *jetCollection ) { ATH_MSG_DEBUG( "EtHypo on Jet " << jet->p4().Et() ); - ATH_MSG_DEBUG( " Threshold 'j' " << m_etThreshold ); - ATH_MSG_DEBUG( " Threshold 'gsc '" << m_gscThreshold ); + ATH_MSG_DEBUG( " Et Threshold " << m_etThreshold ); float et = jet->p4().Et(); + + ATH_MSG_DEBUG( "REGTEST: EF jet with et = " << et ); + ATH_MSG_DEBUG( "REGTEST: Requiring EF jets to satisfy 'j' Et > " << m_etThreshold ); - if ( m_acceptAll ) { - ATH_MSG_DEBUG( "REGTEST: AcceptAll property is set: taking all events" ); - ATH_MSG_DEBUG( "REGTEST: Trigger decision is 1" ); - pass = true; - } else { - ATH_MSG_DEBUG( "REGTEST: AcceptAll property not set: applying the selection" ); - ATH_MSG_DEBUG( "REGTEST: EF jet with et = " << et ); - ATH_MSG_DEBUG( "REGTEST: Requiring EF jets to satisfy 'j' Et > " << m_etThreshold ); - ATH_MSG_DEBUG( "REGTEST: Requiring EF jets to satisfy 'gsc' Et > " << m_gscThreshold ); - - if (et >= m_etThreshold) - pass = true; - - ATH_MSG_DEBUG( "REGTEST: Pass " << pass ); - } - - if ( pass ) { - ATH_MSG_DEBUG( "Selection cut satisfied, accepting the event" ); - } else { - ATH_MSG_DEBUG( "Selection cut not satisfied, rejecting the event" ); - } - - ATH_MSG_DEBUG( "REGTEST: Trigger decision is " << pass ); + if ( et >= m_etThreshold ) + nJets++; } + if ( nJets >= m_multeplicity ) + pass = true; + + if ( pass ) { + ATH_MSG_DEBUG( "Selection cut satisfied, accepting the event" ); + } else { + ATH_MSG_DEBUG( "Selection cut not satisfied, rejecting the event" ); + } + + ATH_MSG_DEBUG( "REGTEST: Trigger decision is " << pass ); return StatusCode::SUCCESS; } - // ----------------------------------------------------------------------------------------------------------------- - StatusCode TrigBjetEtHypoTool::finalize() { ATH_MSG_INFO( "Finalizing TrigBjetEtHypoTool" ); return StatusCode::SUCCESS; diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoTool.h b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoTool.h index 61f9e4962796cec66c40ffe0c25c1361fb4b1909..2a871cc3360a141fb96d385cd22568bcb8ffa617 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoTool.h +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetEtHypoTool.h @@ -57,12 +57,10 @@ class TrigBjetEtHypoTool : virtual public ::AthAlgTool { /** @brief DeclareProperty: if acceptAll flag is set to true, every event is taken. */ Gaudi::Property< bool > m_acceptAll {this,"AcceptAll",false,"if acceptAll flag is set to true, every event is taken"}; - /** @brief DeclareProperty: Et calibration on which to apply cut */ - Gaudi::Property< std::string > m_etCalibration {this,"EtCalibration","Split","Et calibration [Split or Gsc] on which to apply cut"}; + /** @brief DeclareProperty: Multeplicity requirement. */ + Gaudi::Property< int > m_multeplicity {this,"Multeplicity",1,"Multeplicity requirement"}; /** @brief DeclareProperty: Et threshold cut. */ Gaudi::Property< float > m_etThreshold {this,"EtThreshold",0.0,"Et threshold cut"}; - /** @brief DeclareProperty: Gsc threshold cut. */ - Gaudi::Property< float > m_gscThreshold {this,"GscThreshold",0.0,"Gsc threshold cut"}; }; inline const InterfaceID& TrigBjetEtHypoTool::interfaceID() diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetHypoAlgMT.cxx index 3d67872b6d0274dcec3d49b8a3379fe7b56aa2b9..fa48a143de29d341530831641eeda641bf817a8a 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetHypoAlgMT.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBjetHypoAlgMT.cxx @@ -51,53 +51,6 @@ StatusCode TrigBjetHypoAlgMT::execute_r( const EventContext& context ) const { ATH_MSG_DEBUG( "Running with "<< prevDecisionContainer->size() <<" previous decisions"); return StatusCode::SUCCESS; - - SG::ReadHandle< xAOD::BTaggingContainer > bTagHandle = SG::makeHandle( m_bTagKey, context ); - SG::ReadHandle< TrigRoiDescriptorCollection > roisHandle = SG::makeHandle( m_roisKey, context ); - - std::unique_ptr< DecisionContainer > decisions = std::make_unique< DecisionContainer >(); - std::unique_ptr< DecisionAuxContainer > aux = std::make_unique< DecisionAuxContainer >(); - decisions->setStore( aux.get() ); - - // prepare decision storage ( we could simplify it ) - // Lidija: should be checked once more - size_t counter = 0; - // ---->>>>>> - xAOD::BTaggingContainer::const_iterator bTagIter = bTagHandle->begin(); - for ( ; bTagIter != bTagHandle->end(); ++bTagIter, ++counter ) { - TrigCompositeUtils::Decision *d = newDecisionIn( decisions.get() ); - d->setObjectLink( "feature", ElementLink<xAOD::BTaggingContainer>( m_bTagKey.key(), counter ) ); - d->setObjectLink( "roi", ElementLink<TrigRoiDescriptorCollection>( m_roisKey.key(), counter ) ); - } - - - size_t index = 0; - for ( ; index < decisions->size(); ++index ) { - - const xAOD::BTagging *bTag = bTagHandle->at( index ); - const TrigRoiDescriptor *roiDescriptor = roisHandle->at( index ); - TrigCompositeUtils::Decision *decision = decisions->at( index ); - - - for ( const ToolHandle< TrigBjetHypoTool >& tool : m_hypoTools ) { - // interface of the tool needs to be suitable for current system, so no TrigComposite - // also no support for the multi-electrons yet ( will be additional method ) - if ( tool->decide( bTag, roiDescriptor ) ) { - addDecisionID( tool->decisionId(), decision ); - ATH_MSG_DEBUG( " + " << tool->name() ); - } else { - ATH_MSG_DEBUG( " - " << tool->name() ); - } - } - - } - - { - SG::WriteHandle< TrigCompositeUtils::DecisionContainer > handle = SG::makeHandle( m_decisionsKey, context ); - CHECK( handle.record( std::move( decisions ), std::move( aux ) ) ); - } - - return StatusCode::SUCCESS; } diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBtagFexMT.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBtagFexMT.cxx index 96712db02a307c28c9e66a719593f64d09990680..ba106f1e57342291b73a60400a7bb35809b8c65f 100755 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBtagFexMT.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigBtagFexMT.cxx @@ -97,148 +97,6 @@ StatusCode TrigBtagFexMT::execute() { ATH_MSG_DEBUG( "Executing TrigBtagFexMT" ); return StatusCode::SUCCESS; - - // Commenting everything here while waiting for b-taggging to be ready. - // This needs to be rewritten. - /* - // RETRIEVE INPUT CONTAINERS - const EventContext& ctx = getContext(); - SG::ReadHandle< xAOD::JetContainer > jetContainerHandle = SG::makeHandle( m_JetContainerKey,ctx ); - SG::ReadHandle< xAOD::VertexContainer > prmVtxContainerHandle = SG::makeHandle( m_VertexContainerKey,ctx ); - // SG::ReadHandle< xAOD::VertexContainer > backupPrmVtxContainerHandle = SG::makeHandle( m_BackUpVertexContainerKey,ctx ); - SG::ReadHandle< xAOD::TrackParticleContainer > trkParticlesHandle = SG::makeHandle( m_TrackParticleContainerKey,ctx ); - - // Temporary comment these lines - // const xAOD::VertexContainer* vertexes = nullptr; - // const xAOD::Vertex* primaryVertex = nullptr; - - bool usePVBackup = true; - */ - /* - if (getFeature(outputTE, vertexes, m_priVtxKey) == HLT::OK && vertexes != nullptr) { - ATH_MSG_DEBUG( "INPUT - xAOD::VertexContainer: " << m_priVtxKey << " has nVertexes = " << vertexes->size() ); - primaryVertex = getPrimaryVertex(vertexes); - if (primaryVertex){ - usePVBackup=false; - ATH_MSG_DEBUG( "INPUT - xAOD::VertexContainer: valid vertex found in " << m_priVtxKey ); - } - } - - if(m_usePriVtxKeyBackup && usePVBackup) { - vertexes = nullptr; - ATH_MSG_DEBUG( "INPUT - xAOD::VertexContainer: NO valid vertex found in " << m_priVtxKey << " - proceeding with backup option" ); - if (getFeature(outputTE, vertexes, m_priVtxKeyBackup) == HLT::OK && vertexes != nullptr) { - ATH_MSG_DEBUG( "INPUT - xAOD::VertexContainer: " << m_priVtxKeyBackup << " has nVertexes = " << vertexes->size() ); - primaryVertex = getPrimaryVertex(vertexes); - if (primaryVertex){ - usePVBackup=false; - ATH_MSG_DEBUG( "INPUT - xAOD::VertexContainer: valid vertex found in " << m_priVtxKeyBackup ); - } - } - } - */ - /* - if ( usePVBackup ) { - ATH_MSG_INFO( "INPUT - xAOD::VertexContainer: NO valid vertex found in " << m_BackUpVertexContainerKey << " - aborting..." ); - return StatusCode::FAILURE; - } - - // PREPARE PROCESSING AND OUTPUT CONTAINERS - // Prepare jet tagging - create temporary jet copy - xAOD::JetContainer::const_iterator jetitr = jetContainerHandle->begin(); - xAOD::Jet jet; - jet.makePrivateStore(**jetitr); - - // Prepare jet tagging - create SV output - std::unique_ptr< xAOD::VertexContainer > trigVertexContainer( new xAOD::VertexContainer() ); - std::unique_ptr< xAOD::VertexAuxContainer > trigSecVertexAuxContainer( new xAOD::VertexAuxContainer() ); - trigVertexContainer->setStore( trigSecVertexAuxContainer.get() ); - - // Prepare jet tagging - create JF output - std::unique_ptr< xAOD::BTagVertexContainer > trigBTagVertexContainer( new xAOD::BTagVertexContainer() ); - std::unique_ptr< xAOD::VertexAuxContainer > trigBTagSecVertexAuxContainer( new xAOD::VertexAuxContainer() ); - trigBTagVertexContainer->setStore( trigBTagSecVertexAuxContainer.get() ); - - // Prepare jet tagging - create BTagging output - std::unique_ptr< xAOD::BTaggingContainer > trigBTaggingContainer( new xAOD::BTaggingContainer() ); - std::unique_ptr< xAOD::BTaggingAuxContainer > trigBTaggingAuxContainer( new xAOD::BTaggingAuxContainer() ); - trigBTaggingContainer->setStore( trigBTaggingAuxContainer.get() ); - - xAOD::BTagging *trigBTagging = new xAOD::BTagging(); - trigBTaggingContainer->push_back(trigBTagging); - */ - // EXECUTE OFFLINE TOOLS - if ( m_setupOfflineTools == true ) { - /* - // Execute track association - if (!m_bTagTrackAssocTool.empty()) { - StatusCode jetIsAssociated; - - // Link the BTagging object to the jet for track association - ElementLink< xAOD::BTaggingContainer> linkBTagger; - linkBTagger.toContainedElement(*trigBTaggingContainer, trigBTagging); - jet.setBTaggingLink(linkBTagger); - - std::vector<xAOD::Jet*> jetsList; - jetsList.push_back(&jet); - ATH_MSG_VERBOSE( "#BTAG# Track association tool is not empty" ); - // We must pass the tracks explicitly to the track associator - jetIsAssociated = m_bTagTrackAssocTool->BTagTrackAssociation_exec(&jetsList, tracks); - - if ( jetIsAssociated.isFailure() ) { - ATH_MSG_DEBUG( "#BTAG# Failed to associate tracks to jet" ); - return HLT::MISSING_FEATURE; - } - } - else { - if(msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "#BTAG# Empty track association tool" << endmsg; - } - - // Execute secondary vertexing - StatusCode sc = m_bTagSecVtxTool->BTagSecVtx_exec(jet, trigBTagging, trigVertexContainer, trigBTagVertexContainer, primaryVertex); - if(sc.isFailure()) { - if(msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "#BTAG# Failed to reconstruct sec vtx" << endmsg; - } - - // Tag jet - sc = m_bTagTool->tagJet(jet, trigBTagging, primaryVertex); - if(sc.isFailure()) { - if(msgLvl() <= MSG::WARNING) msg() << MSG::WARNING << "#BTAG# Failed in taggers call" << endmsg; - } - */ - } - /* - // Dump results - ATH_MSG_DEBUG( "IP2D u/b: " << trigBTagging->IP2D_pu() << "/" << trigBTagging->IP2D_pb() - << " IP3D u/b: " << trigBTagging->IP3D_pu() << "/" << trigBTagging->IP3D_pb() - << " SV1 u/b: " << trigBTagging->SV1_pu() << "/" << trigBTagging->SV1_pb() - << " MV2c20 var: " << trigBTagging->auxdata<double>("MV2c20_discriminant") - << " MV2c10 var: " << trigBTagging->auxdata<double>("MV2c10_discriminant") ); - */ - // ATTACH FEATURES AND CLEAR TEMPORARY OBJECTS - - // Temporary comment these lines - // Create element link from the BTagging to the Jet container - // auto &jetAssociationLinks = trigBTagging->auxdata< std::vector< ElementLink< xAOD::IParticleContainer > > >("BTagBtagToJetAssociator"); - /* - if ( jets ) { - jetAssociationLinks.resize ( jets->size() ); - for( size_t i = 0; i < jets->size(); ++i ) { - jetAssociationLinks[i].toIndexedElement (*jets, i); - } - } - */ - /* - SG::WriteHandle< xAOD::BTaggingContainer > outputBTaggingContainerHandle = SG::makeHandle( m_outputBTaggingContainerKey,ctx ); - ATH_CHECK( outputBTaggingContainerHandle.record( std::move(trigBTaggingContainer),std::move(trigBTaggingAuxContainer) ) ); - - SG::WriteHandle< xAOD::VertexContainer > outputVtxContainerHandle = SG::makeHandle( m_outputVertexContainerKey,ctx ); - ATH_CHECK( outputVtxContainerHandle.record( std::move(trigVertexContainer),std::move(trigSecVertexAuxContainer) ) ); - - SG::WriteHandle< xAOD::BTagVertexContainer > outputBtagVtxContainerHandle = SG::makeHandle( m_outputBtagVertexContainerKey,ctx ); - ATH_CHECK( outputBtagVtxContainerHandle.record( std::move(trigBTagVertexContainer),std::move(trigBTagSecVertexAuxContainer) ) ); - */ - return StatusCode::SUCCESS; } diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigGSCFexMT.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigGSCFexMT.cxx index f5a28e8f0327e8c5ae0157ba33897632df9fd3d8..e202896b774dde26fa263e4fe0c5b49488704291 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigGSCFexMT.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigGSCFexMT.cxx @@ -53,13 +53,14 @@ StatusCode TrigGSCFexMT::initialize() { ATH_MSG_DEBUG( " " << m_TrackParticleContainerKey ); ATH_MSG_DEBUG( " " << m_jetOutputKey ); - ATH_MSG_DEBUG( "Initializing ReadHandleKeys" ); + ATH_MSG_DEBUG( "Initializing ReadHandleKeys" ); + ATH_CHECK( m_roiContainerKey.initialize() ); ATH_CHECK( m_JetContainerKey.initialize() ); ATH_CHECK( m_VertexContainerKey.initialize() ); ATH_CHECK( m_TrackParticleContainerKey.initialize() ); - ATH_CHECK( m_jetOutputKey.initialize() ); + ATH_CHECK( m_jetOutputKey.initialize() ); - ATH_MSG_DEBUG( "Retrieving Tools" ); + ATH_MSG_DEBUG( "Retrieving Tools" ); ATH_CHECK( m_jetGSCCalib_tool.retrieve() ); return StatusCode::SUCCESS; @@ -72,38 +73,48 @@ StatusCode TrigGSCFexMT::initialize() { StatusCode TrigGSCFexMT::execute() { ATH_MSG_DEBUG( "Executing TrigGSCFexMT" ); - // RETRIEVE INPUT CONTAINERS const EventContext& ctx = getContext(); + + // ============================================================================================================================== + // ** Retrieve Ingredients + // ============================================================================================================================== + + // Jets + ATH_MSG_DEBUG( "Ready to retrieve jets : " << m_JetContainerKey.key() ); SG::ReadHandle< xAOD::JetContainer > jetContainerHandle = SG::makeHandle( m_JetContainerKey,ctx ); - SG::ReadHandle< xAOD::VertexContainer > prmVtxContainerHandle = SG::makeHandle( m_VertexContainerKey,ctx ); - SG::ReadHandle< xAOD::TrackParticleContainer > trkParticlesHandle = SG::makeHandle( m_TrackParticleContainerKey,ctx ); + CHECK( jetContainerHandle.isValid() ); - // PREPARE PROCESSING AND OUTPUT CONTAINERS - // - // get primary vertex - // - xAOD::VertexContainer::const_iterator prmVtxIter = prmVtxContainerHandle->begin(); - const xAOD::Vertex *primaryVertex = *prmVtxIter; - - // Prepare jet tagging - create temporary jet copy - xAOD::Jet jet; - jet.makePrivateStore( **jetContainerHandle->begin() ); - - //======================================================= - - //std::cout << "TrigGSCFex: jet" - // << " pt: " << jet.p4().Pt() - // << " eta: " << jet.p4().Eta() - // << " phi: " << jet.p4().Phi() - // << " m: " << jet.p4().M() - // << std::endl; - // - //std::cout << "primaryVertex z" << primaryVertex->z() << std::endl; + const xAOD::JetContainer *jetContainer = jetContainerHandle.get(); + ATH_MSG_DEBUG( "Retrieved " << jetContainer->size() << " input Jets for GSC correction : " << m_JetContainerKey ); + for ( const xAOD::Jet *jet : *jetContainer ) + ATH_MSG_DEBUG( " ** Jet pt=" << jet->p4().Et() <<" eta="<< jet->eta()<< " phi="<< jet->phi() ); + + // Primary Vertex + ATH_MSG_DEBUG( "Ready to retrieve primary vertex : " << m_VertexContainerKey ); + SG::ReadHandle< xAOD::VertexContainer > vertexContainerHandle = SG::makeHandle( m_VertexContainerKey,ctx ); + CHECK( vertexContainerHandle.isValid() ); - //======================================================= + const xAOD::VertexContainer *vertexContainer = vertexContainerHandle.get(); + for ( const xAOD::Vertex *primVtx : *vertexContainer ) + ATH_MSG_DEBUG( " ** PV = " << primVtx->x() << "," << primVtx->y() << "," << primVtx->z() ); - // Compute and store GSC moments from precision tracks + // SG::ReadHandle< xAOD::VertexContainer > prmVtxContainerHandle = SG::makeHandle( m_VertexContainerKey,ctx ); + // SG::ReadHandle< xAOD::TrackParticleContainer > trkParticlesHandle = SG::makeHandle( m_TrackParticleContainerKey,ctx ); + + // ============================================================================================================================== + // ** Prepare Output + // ============================================================================================================================== + + std::unique_ptr< xAOD::JetContainer > calibrateJets( new xAOD::JetContainer() ); + std::unique_ptr< xAOD::JetAuxContainer > calibratedJetsAux( new xAOD::JetAuxContainer() ); + calibrateJets->setStore( calibratedJetsAux.get() ); + + // ============================================================================================================================== + // ** Calibrate Jets + // ============================================================================================================================== + + /* unsigned int nTrk(0); double width(0); double ptsum(0); @@ -169,13 +180,27 @@ StatusCode TrigGSCFexMT::execute() { // << " m: " << calJet->p4().M() // << std::endl; - std::unique_ptr< xAOD::JetContainer > jc( new xAOD::JetContainer() ); - std::unique_ptr< xAOD::JetTrigAuxContainer > trigJetTrigAuxContainer( new xAOD::JetTrigAuxContainer() ); - jc->setStore( trigJetTrigAuxContainer.get() ); - jc->push_back ( calJet ); + */ + ATH_MSG_DEBUG( "Ready to perform calibration" ); + for ( const xAOD::Jet *inJet : *jetContainer ) { + /* + xAOD::Jet *outJet = nullptr; + m_jetGSCCalib_tool->calibratedCopy( inJet,outJet ); + */ + xAOD::Jet *outJet = new xAOD::Jet(); + calibrateJets->push_back( outJet ); + *outJet = *inJet; + } + ATH_MSG_DEBUG( " ** Calibration performed" ); + for ( const xAOD::Jet *calJet : *calibrateJets ) + ATH_MSG_DEBUG( " -- pt=" << calJet->p4().Et() << " eta="<< calJet->eta() << " phi="<< calJet->phi() ); + + // ============================================================================================================================== + // ** Store Output + // ============================================================================================================================== - SG::WriteHandle< xAOD::JetContainer > OutputjetContainerHandle = SG::makeHandle( m_jetOutputKey,ctx ); - ATH_CHECK( OutputjetContainerHandle.record( std::move(jc),std::move(trigJetTrigAuxContainer) ) ); + SG::WriteHandle< xAOD::JetContainer > outputJetContainerHandle = SG::makeHandle( m_jetOutputKey,ctx ); + ATH_CHECK( outputJetContainerHandle.record( std::move(calibrateJets),std::move(calibratedJetsAux) ) ); return StatusCode::SUCCESS; } diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigGSCFexMT.h b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigGSCFexMT.h index 1d5da487f06bfd3afee9a319136fde9ad3fcb876..1c376e3d6c276c292ff1245d9b162650a6fb5054 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigGSCFexMT.h +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigGSCFexMT.h @@ -27,6 +27,8 @@ #include "TrigInterfaces/FexAlgo.h" #include "JetCalibTools/IJetCalibrationTool.h" +#include "xAODJet/JetContainer.h" +#include "xAODJet/JetAuxContainer.h" class MsgStream; @@ -64,6 +66,7 @@ class TrigGSCFexMT : public AthAlgorithm { Gaudi::Property< bool > m_setupOfflineTools {this,"setupOfflineTools",false,"Switch for offline tools"}; private : + SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiContainerKey {this,"RoIs","initialRoI","Initial RoIs"}; SG::ReadHandleKey< xAOD::JetContainer > m_JetContainerKey {this,"JetKey","SplitJet","Key for input jets to TrigGSCFexMT"}; SG::ReadHandleKey< xAOD::VertexContainer > m_VertexContainerKey {this,"PriVtxKey","xPrimVx","Key of primary vertexes to TrigGSCFexMT"}; SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrackParticleContainerKey {this,"TrackKey","InDetTrigTrackingxAODCnv_Bjet_IDTrig","Key for track particle container to TrigGSCFexMT"}; diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterMT.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterMT.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ec5b49fb9f0e20ede506883760f3c94a42319835 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterMT.cxx @@ -0,0 +1,189 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +// ************************************************ +// +// NAME: TrigJetSplitterMT.cxx +// PACKAGE: Trigger/TrigHypothesis/TrigBjetHypo +// +// ************************************************ + +#include "src/TrigJetSplitterMT.h" +#include "TrigSteeringEvent/PhiHelper.h" + +// ----------------------------------------------------------------------------------------------------------------- + +TrigJetSplitterMT::TrigJetSplitterMT(const std::string& name, ISvcLocator* pSvcLocator) : + AthAlgorithm(name, pSvcLocator) {} + +// ----------------------------------------------------------------------------------------------------------------- + +TrigJetSplitterMT::~TrigJetSplitterMT() {} + +// ----------------------------------------------------------------------------------------------------------------- + +StatusCode TrigJetSplitterMT::initialize() { + ATH_MSG_INFO( "Initializing " << name() ); + + ATH_MSG_DEBUG( "declareProperty review:" ); + ATH_MSG_DEBUG( " " << m_inputJetsKey ); + ATH_MSG_DEBUG( " " << m_outputJetsKey ); + ATH_MSG_DEBUG( " " << m_imposeZconstraint); + ATH_MSG_DEBUG( " " << m_etaHalfWidth ); + ATH_MSG_DEBUG( " " << m_phiHalfWidth ); + ATH_MSG_DEBUG( " " << m_zHalfWidth ); + ATH_MSG_DEBUG( " " << m_minJetEt ); + ATH_MSG_DEBUG( " " << m_maxJetEta ); + + ATH_MSG_DEBUG( "Initializing HandleKeys" ); + CHECK( m_inputJetsKey.initialize() ); + CHECK( m_outputJetsKey.initialize() ); + CHECK( m_outputRoiKey.initialize() ); + CHECK( m_outputVertexKey.initialize() ); // TMP + CHECK( m_inputRoIKey.initialize() ); // TMP + return StatusCode::SUCCESS; +} + + +// ----------------------------------------------------------------------------------------------------------------- + + +StatusCode TrigJetSplitterMT::execute() { + ATH_MSG_DEBUG( "Executing " << name() ); + + // ============================================================================================================================== + // ** Retrieve Ingredients + // ============================================================================================================================== + + const EventContext& context = getContext(); + + SG::ReadHandle< xAOD::JetContainer > inputJetContainerHandle = SG::makeHandle( m_inputJetsKey,context ); + ATH_MSG_DEBUG( "Retrieved jets from : " << m_inputJetsKey.key() ); + CHECK( inputJetContainerHandle.isValid() ); + + const xAOD::JetContainer *inputJetCollection = inputJetContainerHandle.get(); + ATH_MSG_DEBUG( "Found " << inputJetCollection->size() << " jets." ); + for ( const xAOD::Jet *jet : * inputJetCollection ) + ATH_MSG_INFO(" -- Jet pt=" << jet->p4().Et() <<" eta="<< jet->eta() << " phi="<< jet->phi() ); + + // Retrieve Primary Vertex + // Right now vertexing is not available. Using dummy vertex at (0,0,0) // TMP + std::unique_ptr< xAOD::VertexContainer > vertexContainer( new xAOD::VertexContainer() ); + std::unique_ptr< xAOD::VertexAuxContainer > vertexAuxContainer( new xAOD::VertexAuxContainer() ); + vertexContainer->setStore( vertexAuxContainer.get() ); + vertexContainer->push_back( new xAOD::Vertex() ); + + xAOD::Vertex *primaryVertex = vertexContainer->at(0); + + if ( m_imposeZconstraint ) { + // Here we should retrieve the primary vertex // TO-DO + // Add protection against failure during primary vertex retrieval. // TO-DO + ATH_MSG_DEBUG( " ** PV = (" << primaryVertex->x() << + "," << primaryVertex->y() << + "," << primaryVertex->z() << ")" ); + } + + // ============================================================================================================================== + // ** Prepare the outputs + // ============================================================================================================================== + + std::unique_ptr< TrigRoiDescriptorCollection > outputRoiContainer( new TrigRoiDescriptorCollection() ); + + std::unique_ptr< xAOD::JetContainer > outputJetContainer( new xAOD::JetContainer() ); + std::unique_ptr< xAOD::JetAuxContainer > outputJetAuxContainer( new xAOD::JetAuxContainer() ); + outputJetContainer->setStore( outputJetAuxContainer.get() ); + + // ============================================================================================================================== + // ** Creating ShortList of Jet Container + // ============================================================================================================================== + + CHECK( shortListJets( inputJetCollection,outputJetContainer,outputRoiContainer,primaryVertex ) ); + + // ============================================================================================================================== + // ** Store the outputs + // ============================================================================================================================== + + SG::WriteHandle< xAOD::JetContainer > outputJetContainerHandle = SG::makeHandle( m_outputJetsKey, context ); + CHECK( outputJetContainerHandle.record( std::move( outputJetContainer ), std::move( outputJetAuxContainer ) ) ); + ATH_MSG_DEBUG( "Exiting with " << outputJetContainerHandle->size() << " shortlisted jets" ); + + SG::WriteHandle< TrigRoiDescriptorCollection > outputRoIContainerHandle = SG::makeHandle( m_outputRoiKey,context ); + CHECK( outputRoIContainerHandle.record( std::move( outputRoiContainer ) ) ); + ATH_MSG_DEBUG( "Exiting with " << outputRoIContainerHandle->size() << " RoIs" ); + + // TMP Primary Vertex + SG::WriteHandle< xAOD::VertexContainer > outputPrimaryVertexContainerHandle = SG::makeHandle( m_outputVertexKey,context ); + CHECK( outputPrimaryVertexContainerHandle.record( std::move(vertexContainer),std::move(vertexAuxContainer) ) ); + ATH_MSG_DEBUG( "Exiting with " << outputPrimaryVertexContainerHandle->size() << " Primary Vertices" ); + + return StatusCode::SUCCESS; +} + + + +StatusCode TrigJetSplitterMT::finalize() { + return StatusCode::SUCCESS; +} + + +StatusCode TrigJetSplitterMT::shortListJets( const xAOD::JetContainer* jetCollection, + std::unique_ptr< xAOD::JetContainer >& outputJets, + std::unique_ptr< TrigRoiDescriptorCollection >& roiContainer, + const xAOD::Vertex* primaryVertex ) const { + + // Make a copy of the jet containers + for ( const xAOD::Jet *jet : *jetCollection ) { + // We select Jets above a specific eta and pt range + if ( jet->p4().Et() < m_minJetEt ) { + ATH_MSG_DEBUG( "** Jet below the " << m_minJetEt.value() << " GeV threshold; Et " << jet->p4().Et() <<"; Skipping this Jet." ); + continue; + } + if ( fabs( jet->eta() ) > m_maxJetEta ) { + ATH_MSG_DEBUG( "** Jet outside the |eta| < " << m_maxJetEta.value() << " requirement; Eta = " << jet->eta() << "; Skipping this Jet." ); + continue; + } + ATH_MSG_DEBUG( "** Jet :: Et " << jet->p4().Et() <<"; Eta " << jet->eta() << "; Phi " << jet->phi() ); + + // Protection in case there is not a Primary vertex but the Z contraint option is set to True + if ( m_imposeZconstraint && primaryVertex == nullptr ) { + // Not sure here what the best solution is. We can't change the m_imposeZconstraint value being const (and not thread safe) + ATH_MSG_ERROR( "Option for imposing Z constraint is set to True, but no primary vertex has been found." ); + return StatusCode::FAILURE; + } + + // Copy Jet + xAOD::Jet *toBeAdded = new xAOD::Jet(); + outputJets->push_back( toBeAdded ); + *toBeAdded = *jet; + + // Create RoI (we may require here PVz constraint) + double phiMinus = HLT::wrapPhi(jet->phi() - m_phiHalfWidth); + double phiPlus = HLT::wrapPhi(jet->phi() + m_phiHalfWidth); + + double etaMinus = jet->eta() - m_etaHalfWidth; + double etaPlus = jet->phi() + m_etaHalfWidth; + + // Impose Z matching (if enabled) + ATH_MSG_DEBUG( "Building RoI" ); + TrigRoiDescriptor *newRoI = nullptr; + if ( not m_imposeZconstraint ) { + newRoI = new TrigRoiDescriptor( jet->eta(),etaMinus, etaPlus, + jet->phi(), phiMinus, phiPlus ); + } else { + ATH_MSG_DEBUG( " ** Imposing Z constraint while building RoI" ); + double zMinus = primaryVertex->z() - m_zHalfWidth; + double zPlus = primaryVertex->z() + m_zHalfWidth; + + newRoI = new TrigRoiDescriptor( jet->eta(),etaMinus, etaPlus, + jet->phi(), phiMinus, phiPlus, + primaryVertex->z(),zMinus,zPlus ); + } + ATH_MSG_DEBUG( " -- RoI : eta=" << newRoI->eta() << " phi=" << newRoI->phi() ); + + // Put protection against nullpointer // TO-DO + roiContainer->push_back( newRoI ); + } + + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterMT.h b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterMT.h new file mode 100644 index 0000000000000000000000000000000000000000..5c3c1b8a5d91e71ef4d566189d227035ca8f89a0 --- /dev/null +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/TrigJetSplitterMT.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +// ************************************************ +// +// NAME: TrigJetSplitterMT.h +// PACKAGE: Trigger/TrigHypothesis/TrigBjetHypo +// +// AUTHOR: Carlo Varni +// EMAIL: carlo.varni@ge.infn.it +// +// ************************************************ + +#ifndef TRIGJETSPLITTER_MT_H +#define TRIGJETSPLITTER_MT_H + +#include "AthenaBaseComps/AthAlgorithm.h" +#include "StoreGate/ReadHandleKey.h" +#include "StoreGate/WriteHandleKey.h" + +#include "xAODJet/JetContainer.h" +#include "xAODJet/JetAuxContainer.h" + +#include "xAODTracking/VertexContainer.h" +#include "xAODTracking/VertexAuxContainer.h" + +#include "TrigSteeringEvent/TrigRoiDescriptorCollection.h" + +class TrigJetSplitterMT : public AthAlgorithm { + public: + /** @brief Constructor */ + TrigJetSplitterMT(const std::string&, ISvcLocator*); + /** @brief Destructor */ + ~TrigJetSplitterMT(); + + StatusCode initialize(); + StatusCode finalize(); + StatusCode execute(); + + private: + StatusCode shortListJets( const xAOD::JetContainer*, + std::unique_ptr< xAOD::JetContainer >&, + std::unique_ptr< TrigRoiDescriptorCollection >&, + const xAOD::Vertex* ) const; + + private: + Gaudi::Property< bool > m_imposeZconstraint {this,"ImposeZconstraint",false,"Impose Constraint on PV z, thus selecting Jets pointing to PV"}; + Gaudi::Property< float > m_etaHalfWidth {this,"EtaHalfWidth",0.4,"Eta Half Width"}; + Gaudi::Property< float > m_phiHalfWidth {this,"PhiHalfWidth",0.4,"Phi Half Width"}; + Gaudi::Property< float > m_zHalfWidth {this,"ZHalfWidth",10.0,"Z Half Width in mm"}; + Gaudi::Property< float > m_minJetEt {this,"JetMinEt",15000,"Minimum of Output Jet Et in GeV"}; + Gaudi::Property< float > m_maxJetEta {this,"JetMaxEta",3.2,"Maximum eta acceptance of output Jet"}; + //=========== Handles + SG::ReadHandleKey< xAOD::JetContainer > m_inputJetsKey {this,"Jets","Jets","Input Jet Container Key"}; + SG::WriteHandleKey< xAOD::JetContainer > m_outputJetsKey {this,"OutputJets","SplitJets","Output Jet Container Key"}; + SG::WriteHandleKey< TrigRoiDescriptorCollection > m_outputRoiKey {this,"OutputRoi","SplitJet","Output RoI Container Key -- Same as OutputJets"}; + SG::WriteHandleKey< xAOD::VertexContainer > m_outputVertexKey {this,"OutputVertex","PrimaryVertex","Output Vertex Key"}; // TMP + + // Tmp Part for creating custom jet collection. These Jets will be used for creating the output Jet collection + SG::ReadHandleKey< TrigRoiDescriptorCollection > m_inputRoIKey {this,"RoIs","FSJETRoI",""}; +}; + +#endif diff --git a/Trigger/TrigHypothesis/TrigBjetHypo/src/components/TrigBjetHypo_entries.cxx b/Trigger/TrigHypothesis/TrigBjetHypo/src/components/TrigBjetHypo_entries.cxx index 166a0e977a8e76a4b69fcd11f32804a8573d4b80..de451f61ef95e9045162844e1ab6147bd0e8305a 100644 --- a/Trigger/TrigHypothesis/TrigBjetHypo/src/components/TrigBjetHypo_entries.cxx +++ b/Trigger/TrigHypothesis/TrigBjetHypo/src/components/TrigBjetHypo_entries.cxx @@ -18,6 +18,7 @@ #include "../TrigGSCFexMT.h" #include "../TrigBtagFexMT.h" #include "../TrigRoiBuilderMT.h" +#include "../TrigJetSplitterMT.h" DECLARE_COMPONENT( TrigBjetHypoAllTE ) @@ -40,4 +41,5 @@ DECLARE_COMPONENT( TrigBjetEtHypoTool ) DECLARE_COMPONENT( TrigGSCFexMT ) DECLARE_COMPONENT( TrigBtagFexMT ) DECLARE_COMPONENT( TrigRoiBuilderMT ) +DECLARE_COMPONENT( TrigJetSplitterMT ) diff --git a/Trigger/TrigSteer/ViewAlgs/CMakeLists.txt b/Trigger/TrigSteer/ViewAlgs/CMakeLists.txt index 36220443e49e1f8e260bef13b1f95998efc1657a..3651dbe8c139adf9b2c063302231a2aa2163f23f 100644 --- a/Trigger/TrigSteer/ViewAlgs/CMakeLists.txt +++ b/Trigger/TrigSteer/ViewAlgs/CMakeLists.txt @@ -13,6 +13,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthLinks Event/xAOD/xAODTrigCalo Event/xAOD/xAODTrigEgamma + Event/xAOD/xAODJet PRIVATE Control/AthViews Control/StoreGate @@ -26,7 +27,7 @@ atlas_depends_on_subdirs( PUBLIC atlas_add_library( ViewAlgsLib src/*.cxx PUBLIC_HEADERS ViewAlgs - LINK_LIBRARIES xAODTrigger GaudiKernel AthViews xAODTrigCalo xAODTrigEgamma + LINK_LIBRARIES xAODTrigger GaudiKernel AthViews xAODTrigCalo xAODTrigEgamma xAODJet PRIVATE_LINK_LIBRARIES AthenaBaseComps CxxUtils TrigConfHLTData TrigSteeringEvent DecisionHandlingLib ) atlas_add_component( ViewAlgs diff --git a/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithm.h b/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithm.h index 3b711053060329083d86766d6f36db79b0e38a66..8a85120a95ac3da53280d04d667afb89821cb3ec 100644 --- a/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithm.h +++ b/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithm.h @@ -34,10 +34,10 @@ class EventViewCreatorAlgorithm : public ::InputMakerBase virtual StatusCode initialize() override; virtual StatusCode execute_r(const EventContext&) const override; virtual StatusCode finalize() override { return StatusCode::SUCCESS; } - private: + protected: EventViewCreatorAlgorithm(); - + //Output views for merging SG::WriteHandleKey< ViewContainer > m_viewsKey{ this, "Views", "Unspecified", "The key of views collection produced" }; diff --git a/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithmWithJets.cxx b/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithmWithJets.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1406d3f89c801dde045aed7fd5a583d4e77e276f --- /dev/null +++ b/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithmWithJets.cxx @@ -0,0 +1,172 @@ +/* + General-purpose view creation algorithm <bwynne@cern.ch> + + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#include "EventViewCreatorAlgorithmWithJets.h" +#include "AthLinks/ElementLink.h" +#include "AthViews/ViewHelper.h" +#include "AthViews/View.h" +#include "DecisionHandling/TrigCompositeUtils.h" +#include "DecisionHandling/HLTIdentifier.h" + + +EventViewCreatorAlgorithmWithJets::EventViewCreatorAlgorithmWithJets( const std::string& name, ISvcLocator* pSvcLocator ) + : EventViewCreatorAlgorithm( name, pSvcLocator ) {} + +EventViewCreatorAlgorithmWithJets::~EventViewCreatorAlgorithmWithJets() {} + +StatusCode EventViewCreatorAlgorithmWithJets::initialize() { + EventViewCreatorAlgorithm::initialize(); + + ATH_CHECK( m_inViewJets.initialize() ); + + return StatusCode::SUCCESS; +} + +StatusCode EventViewCreatorAlgorithmWithJets::execute_r( const EventContext& context ) const { + auto outputHandles = decisionOutputs().makeHandles( context ); + // make the views + auto viewVector = std::make_unique< ViewContainer >(); + auto contexts = std::vector<EventContext>( ); + unsigned int viewCounter = 0; + unsigned int conditionsRun = getContext().getExtension<Atlas::ExtendedEventContext>().conditionsRun(); + + // const TrigRoiDescriptor* previousRoI = 0; + // mapping RoI with index of the View in the vector + // This is used to link the same view to differnt decisions that come from the same RoI + std::map <const TrigRoiDescriptor*, int> viewMap; + std::map <const TrigRoiDescriptor*, int>::iterator itViewMap; + int outputIndex = -1; + // Loop over all input containers, which are of course TrigComposites, and request their features + // this is the same as InputMaker, apart from the view creation. The loop can be splitted in two loops, to have one common part + for ( auto inputKey: decisionInputs() ) { + outputIndex++; + auto inputHandle = SG::makeHandle( inputKey, context ); + if( not inputHandle.isValid() ) { + ATH_MSG_DEBUG( "Got no decisions from input " << inputKey.key() ); + continue; + } + + if( inputHandle->size() == 0 ) { // input filtered out + ATH_MSG_ERROR( "Got 0 decisions from valid input "<< inputKey.key()<<". Is it expected?"); + return StatusCode::FAILURE; + } + ATH_MSG_DEBUG( "Got input " << inputKey.key() << " with " << inputHandle->size() << " elements" ); + + // prepare output decisions + auto outputDecisions = std::make_unique<TrigCompositeUtils::DecisionContainer>(); + auto decAux = std::make_unique<TrigCompositeUtils::DecisionAuxContainer>(); + outputDecisions->setStore( decAux.get() ); + + const TrigRoiDescriptor* prevRoIDescriptor = nullptr; + int inputCounter = -1; + for ( auto inputDecision: *inputHandle ) { + inputCounter++; + // Retrieve jets ... + ATH_MSG_DEBUG( "Checking there are jets linked to decision object" ); + TrigCompositeUtils::LinkInfo< xAOD::JetContainer > jetELInfo = TrigCompositeUtils::findLink< xAOD::JetContainer >( inputDecision,m_jetsLink ); + ATH_CHECK( jetELInfo.isValid() ); + const xAOD::Jet *jet = *jetELInfo.link; + ATH_MSG_DEBUG( "Placing xAOD::JetContainer " ); + ATH_MSG_DEBUG( " -- pt="<< jet->p4().Et() <<" eta="<< jet->eta() << " phi="<< jet->phi() ); + + // pull RoI descriptor + TrigCompositeUtils::LinkInfo<TrigRoiDescriptorCollection> roiELInfo = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(inputDecision, m_roisLink ); + ATH_CHECK( roiELInfo.isValid() ); + // associate this RoI to output decisions + auto roiDescriptor = *roiELInfo.link; + ATH_MSG_DEBUG( "Placing TrigRoiDescriptor " ); + ATH_MSG_DEBUG( " " << *roiDescriptor ); + + TrigCompositeUtils::Decision* newDecision = nullptr; + if ( prevRoIDescriptor != roiDescriptor ) { + //make one TC decision output per input and connect to previous + newDecision = TrigCompositeUtils::newDecisionIn( outputDecisions.get(), name() ); + TrigCompositeUtils::linkToPrevious( newDecision, inputKey.key(), inputCounter ); + insertDecisions( inputDecision, newDecision ); + newDecision->setObjectLink( "initialRoI", roiELInfo.link ); + newDecision->setObjectLink( "jets", jetELInfo.link ); + prevRoIDescriptor = roiDescriptor; + } else { + newDecision = outputDecisions.get()->back(); + newDecision->setObjectLink( "seedEnd", ElementLink<TrigCompositeUtils::DecisionContainer>( inputHandle.key(), inputCounter ) ); + insertDecisions( inputDecision, newDecision ); + ATH_MSG_DEBUG("No need to create another output decision object, just adding decision IDs"); + } + + // search for existing view + itViewMap = viewMap.find(roiDescriptor); + if ( itViewMap != viewMap.end() ) { + int iview = itViewMap->second; + newDecision->setObjectLink( "view", ElementLink< ViewContainer >(m_viewsKey.key(), iview ) ); //adding view to TC + ATH_MSG_DEBUG( "Adding already mapped view " << iview << " in ViewVector , to new decision"); + // need to check if this View has parent views? can we have more than one parent views? + } else { + + ATH_MSG_DEBUG( "Positive decisions on RoI, preparing view" ); + + // make the view + ATH_MSG_DEBUG( "Making the View" ); + auto newView = ViewHelper::makeView( name()+"_view", viewCounter++, m_viewFallThrough ); //pointer to the view + viewVector->push_back( newView ); + contexts.emplace_back( context ); + contexts.back().setExtension( Atlas::ExtendedEventContext( viewVector->back(), conditionsRun ) ); + + // link decision to this view + newDecision->setObjectLink( "view", ElementLink< ViewContainer >(m_viewsKey.key(), viewVector->size()-1 ));//adding view to TC + viewMap[roiDescriptor]=viewVector->size()-1; + ATH_MSG_DEBUG( "Adding new view to new decision; storing view in viewVector component " << viewVector->size()-1 ); + + ATH_CHECK( linkViewToParent( inputDecision, viewVector->back() ) ); + ATH_CHECK( placeRoIInView( roiDescriptor, viewVector->back(), contexts.back() ) ); + ATH_CHECK( placeJetInView( jet, viewVector->back(), contexts.back() ) ); + } + } + + ATH_MSG_DEBUG( "Recording output key " << decisionOutputs()[ outputIndex ].key() <<" of size "<< outputDecisions->size() <<" at index "<< outputIndex); + ATH_CHECK( outputHandles[outputIndex].record( std::move( outputDecisions ), std::move( decAux ) ) ); + } + + ATH_MSG_DEBUG( "Launching execution in " << viewVector->size() << " views" ); + ATH_CHECK( ViewHelper::ScheduleViews( viewVector.get(), // Vector containing views + m_viewNodeName, // CF node to attach views to + context, // Source context + m_scheduler.get() ) ); + + // store views + auto viewsHandle = SG::makeHandle( m_viewsKey ); + ATH_CHECK( viewsHandle.record( std::move( viewVector ) ) ); + ATH_MSG_DEBUG( "Store "<< viewsHandle->size() <<" Views"); + + size_t validInputCount = countInputHandles( context ); + size_t validOutputCount = 0; + for ( auto outHandle: outputHandles ) { + if( not outHandle.isValid() ) continue; + validOutputCount++; + } + + ATH_MSG_DEBUG("Produced " << validOutputCount << " decisions containers"); + if(validInputCount != validOutputCount ) { + ATH_MSG_ERROR("Found " << validInputCount << " inputs and " << validOutputCount << " outputs"); + return StatusCode::FAILURE; + } + printDecisions( outputHandles ); + return StatusCode::SUCCESS; +} + +StatusCode EventViewCreatorAlgorithmWithJets::placeJetInView( const xAOD::Jet* theObject, SG::View* view, const EventContext& context ) const { + // fill the Jet output collection + ATH_MSG_DEBUG( "Adding Jet To View : " << m_inViewJets.key() ); + auto oneObjectCollection = std::make_unique< ConstDataVector< xAOD::JetContainer > >(); + oneObjectCollection->clear( SG::VIEW_ELEMENTS ); + oneObjectCollection->push_back( theObject ); + + //store in the view + auto handle = SG::makeHandle( m_inViewJets,context ); + ATH_CHECK( handle.setProxyDict( view ) ); + ATH_CHECK( handle.record( std::move( oneObjectCollection ) ) ); + return StatusCode::SUCCESS; +} + diff --git a/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithmWithJets.h b/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithmWithJets.h new file mode 100644 index 0000000000000000000000000000000000000000..ff84d82709d468fccd032bdf2fdb76aaa2d09b2f --- /dev/null +++ b/Trigger/TrigSteer/ViewAlgs/src/EventViewCreatorAlgorithmWithJets.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ViewAlgs_EventViewCreatorAlgorithmWithJets_h +#define ViewAlgs_EventViewCreatorAlgorithmWithJets_h + +#include "EventViewCreatorAlgorithm.h" + +#include "xAODJet/JetContainer.h" +#include "xAODJet/JetAuxContainer.h" + + /** + * @class EventViewCreatorAlgorithmWithJets + * @brief Used at the start of a sequence to create the EventViews: retrieves filtered collection via menu decision from previous step and writes it out directly so it can be used as input by the reco alg that follows in sequence. + **/ + +class EventViewCreatorAlgorithmWithJets : public EventViewCreatorAlgorithm { + public: + EventViewCreatorAlgorithmWithJets( const std::string& name, ISvcLocator* pSvcLocator ); + virtual ~EventViewCreatorAlgorithmWithJets(); + + virtual StatusCode initialize() override; + virtual StatusCode execute_r(const EventContext&) const override; + + private: + + StatusCode placeJetInView( const xAOD::Jet* theObject, + SG::View* view, + const EventContext& context ) const; + + EventViewCreatorAlgorithmWithJets(); + + SG::WriteHandleKey< ConstDataVector<xAOD::JetContainer> > m_inViewJets {this,"InViewJets","Unspecified","Name with which the Jets should be inserted into the views"}; + + Gaudi::Property< std::string > m_jetsLink {this,"JetsLink","Unspecified","Name of EL to Jet object linked to the decision"}; +}; + +#endif + diff --git a/Trigger/TrigSteer/ViewAlgs/src/components/ViewAlgs_entries.cxx b/Trigger/TrigSteer/ViewAlgs/src/components/ViewAlgs_entries.cxx index be3e4f9570bc3ef023f3e97b3e3175e3b98b19f0..ba298d3a4cb8a2697bcc8ea1f1bac654968dd0e9 100644 --- a/Trigger/TrigSteer/ViewAlgs/src/components/ViewAlgs_entries.cxx +++ b/Trigger/TrigSteer/ViewAlgs/src/components/ViewAlgs_entries.cxx @@ -1,10 +1,12 @@ #include "../EventViewCreatorAlgorithm.h" +#include "../EventViewCreatorAlgorithmWithJets.h" #include "../MergeViews.h" DECLARE_COMPONENT( EventViewCreatorAlgorithm ) +DECLARE_COMPONENT( EventViewCreatorAlgorithmWithJets ) DECLARE_COMPONENT( MergeViews ) diff --git a/Trigger/TrigValidation/TrigUpgradeTest/CMakeLists.txt b/Trigger/TrigValidation/TrigUpgradeTest/CMakeLists.txt index ddb170e8c220cc4b7e2da31fdbc8192d909e5f23..8693552052141b8eb25743fd9ca5134fc741af5e 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/CMakeLists.txt +++ b/Trigger/TrigValidation/TrigUpgradeTest/CMakeLists.txt @@ -172,7 +172,7 @@ file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_bJetMenu ) atlas_add_test( bJetMenu SCRIPT test/test_bjet_menu.sh PROPERTIES TIMEOUT 1000 - EXTRA_PATTERNS "-s TriggerSummaryStep.*HLT_.*|TriggerMonitorFinal.*HLT_.*|TrigSignatureMoniMT.*HLT_.*" + EXTRA_PATTERNS "-s TrigSignatureMoniMT.*HLT_.*" PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unitTestRun_bJetMenu ) diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/bjetMenuDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/bjetMenuDefs.py index 9bb1754f774d77c7b36c8401600fbe12196ff171..1e9b7244cdf691c6578150e91f964b643a837e7c 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/bjetMenuDefs.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/bjetMenuDefs.py @@ -2,6 +2,7 @@ # from AthenaCommon.Constants import VERBOSE,DEBUG,INFO +import AthenaCommon.CfgMgr as CfgMgr # Set InDet Flags from InDetRecExample.InDetJobProperties import InDetFlags @@ -26,8 +27,12 @@ include("InDetRecExample/InDetRecConditionsAccess.py") def getBJetSequence( step ): if step == "j": return bJetStep1Sequence() + if step == "jALLTE": + return bJetStep1SequenceALLTE() if step == "gsc": - return bJetStep1Sequence() + return bJetStep2Sequence() + if step == "gscALLTE": + return bJetStep2SequenceALLTE() if step == "bTag": return bJetStep1Sequence() return None @@ -43,11 +48,9 @@ def bJetStep1Sequence(): # input maker from DecisionHandling.DecisionHandlingConf import InputMakerForRoI - InputMakerAlg = InputMakerForRoI("JetInputMaker", OutputLevel = DEBUG, LinkName="initialRoI") - InputMakerAlg.RoIs='FSJETRoI' - InputMakerAlg.OutputLevel = DEBUG + InputMakerAlg = InputMakerForRoI("JetInputMaker",OutputLevel=INFO) InputMakerAlg.LinkName = "initialRoI" - + InputMakerAlg.RoIs='FSJETRoI' # Construct jets from TrigUpgradeTest.jetDefs import jetRecoSequence @@ -55,7 +58,6 @@ def bJetStep1Sequence(): # Start with b-jet-specific algo sequence # Construct RoI. Needed input for Fast Tracking - # WILL BE REMOVED IN THE FUTURE from TrigBjetHypo.TrigBjetHypoConf import TrigRoiBuilderMT RoIBuilder = TrigRoiBuilderMT("RoIBuilder") RoIBuilder.OutputLevel = DEBUG @@ -76,37 +78,218 @@ def bJetStep1Sequence(): # Getting output track particle container name TrackParticlesName = "" for viewAlg in viewAlgs: + viewAlg.OutputLevel = INFO if viewAlg.name() == "InDetTrigTrackParticleCreatorAlg": TrackParticlesName = viewAlg.TrackParticlesName + # Primary Vertex goes here + + # Shortlis of jets + from TrigBjetHypo.TrigBjetHypoConf import TrigJetSplitterMT + jetSplitter = TrigJetSplitterMT("TrigJetSplitterMT") + jetSplitter.OutputLevel = DEBUG + jetSplitter.ImposeZconstraint = True + jetSplitter.Jets = sequenceOut + jetSplitter.OutputJets = "SplitJets" + jetSplitter.OutputRoi = "SplitJets" + jetSplitter.OutputVertex = "PrimaryVertex" # TMP + fastTrackingSequence = parOR("fastTrackingSequence",viewAlgs) - bJetEtSequence = seqAND("bJetEtSequence",[ RoIBuilder,fastTrackingSequence] ) + bJetEtSequence = seqAND("bJetEtSequence",[ RoIBuilder,fastTrackingSequence,jetSplitter] ) # hypo from TrigBjetHypo.TrigBjetHypoConf import TrigBjetEtHypoAlgMT - from TrigBjetHypo.TrigBjetEtHypoTool import TrigBjetEtHypoToolFromName - hypo = TrigBjetEtHypoAlgMT("TrigBjetEtHypoAlgMT") + from TrigBjetHypo.TrigBjetEtHypoTool import TrigBjetEtHypoToolFromName_j + hypo = TrigBjetEtHypoAlgMT("TrigBjetEtHypoAlgMT_step1") hypo.OutputLevel = DEBUG - hypo.Jets = sequenceOut - hypo.OutputJets = "SplitJets" - # These two are only for temporary debug. Will be removed - hypo.TrackParticleContainerKey = TrackParticlesName - hypo.RoiKey = RoIBuilder.RoIOutputKey + hypo.Jets = jetSplitter.OutputJets + hypo.RoIs = jetSplitter.OutputRoi + hypo.PrimaryVertex = jetSplitter.OutputVertex + hypo.RoILink = "initialRoI" # To be used in following step EventView + hypo.JetLink = "jets" # To be used in following step with EventView + hypo.MultipleDecisions = True # For creating multiple decisions in the next step # Sequence - BjetAthSequence = seqAND("BjetAthSequence",eventAlgs + [InputMakerAlg,recoSequence,bJetEtSequence]) + BjetAthSequence = seqAND("BjetAthSequence_step1",eventAlgs + [InputMakerAlg,recoSequence,bJetEtSequence]) return MenuSequence( Sequence = BjetAthSequence, Maker = InputMakerAlg, Hypo = hypo, - HypoToolGen = TrigBjetEtHypoToolFromName ) + HypoToolGen = TrigBjetEtHypoToolFromName_j ) + +def bJetStep1SequenceALLTE(): + # menu components + from AthenaCommon.CFElements import parOR, seqAND, seqOR, stepSeq + from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import MenuSequence + + # input maker + from DecisionHandling.DecisionHandlingConf import InputMakerForRoI + InputMakerAlg = InputMakerForRoI("JetInputMaker",OutputLevel=INFO) + InputMakerAlg.LinkName="initialRoI" + InputMakerAlg.RoIs='FSJETRoI' + + # Construct jets + from TrigUpgradeTest.jetDefs import jetRecoSequence + (recoSequence, sequenceOut) = jetRecoSequence( InputMakerAlg.RoIs ) + + # Start with b-jet-specific algo sequence + # Construct RoI. Needed input for Fast Tracking + from TrigBjetHypo.TrigBjetHypoConf import TrigRoiBuilderMT + RoIBuilder = TrigRoiBuilderMT("RoIBuilder") + RoIBuilder.JetInputKey = sequenceOut + RoIBuilder.RoIOutputKey = "EMViewRoIs" # Default for Fast Tracking Algs + + # Fast Tracking + from TrigUpgradeTest.InDetSetup import makeInDetAlgs + (viewAlgs, eventAlgs) = makeInDetAlgs() + + from TrigFastTrackFinder.TrigFastTrackFinder_Config import TrigFastTrackFinder_Jet + theFTF_Jet = TrigFastTrackFinder_Jet() + theFTF_Jet.isRoI_Seeded = True + theFTF_Jet.RoIs = RoIBuilder.RoIOutputKey + viewAlgs.append( theFTF_Jet ) + + # Getting output track particle container name + TrackParticlesName = "" + for viewAlg in viewAlgs: + if viewAlg.name() == "InDetTrigTrackParticleCreatorAlg": + TrackParticlesName = viewAlg.TrackParticlesName + + # Primary Vertex goes here + + # Shortlis of jets + from TrigBjetHypo.TrigBjetHypoConf import TrigJetSplitterMT + jetSplitter = TrigJetSplitterMT("TrigJetSplitterMT") + jetSplitter.ImposeZconstraint = True + jetSplitter.Jets = sequenceOut + jetSplitter.OutputJets = "SplitJets" + jetSplitter.OutputRoi = "SplitJets" + jetSplitter.OutputVertex = "PrimaryVertex" # TMP + + fastTrackingSequence = parOR("fastTrackingSequence",viewAlgs) + bJetEtSequence = seqAND("bJetEtSequence",[ RoIBuilder,fastTrackingSequence,jetSplitter] ) + + # hypo + from TrigBjetHypo.TrigBjetHypoConf import TrigBjetEtHypoAlgMT + from TrigBjetHypo.TrigBjetEtHypoTool import TrigBjetEtHypoToolFromName_j + hypo = TrigBjetEtHypoAlgMT("TrigBjetEtHypoAlgMT_step1_ALLTE") + hypo.OutputLevel = DEBUG + hypo.Jets = jetSplitter.OutputJets + hypo.RoIs = jetSplitter.OutputRoi + hypo.PrimaryVertex = jetSplitter.OutputVertex + hypo.RoILink = "initialRoI" # To be used in following step EventView + hypo.JetLink = "jets" # To be used in following step with EventView + hypo.MultipleDecisions = False # For creating multiple decisions in the next step + + # Sequence + BjetAthSequence = seqAND("BjetAthSequence_step1_ALLTE",eventAlgs + [InputMakerAlg,recoSequence,bJetEtSequence]) + + return MenuSequence( Sequence = BjetAthSequence, + Maker = InputMakerAlg, + Hypo = hypo, + HypoToolGen = TrigBjetEtHypoToolFromName_j ) + # ==================================================================================================== # step 2: precision tracking, gsc calibration and cut on gsc-corrected threshold # ==================================================================================================== +def bJetStep2Sequence(): + # menu components + from AthenaCommon.CFElements import parOR, seqAND, seqOR, stepSeq + from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import MenuSequence + + # Event View Creator Algorithm + from ViewAlgs.ViewAlgsConf import EventViewCreatorAlgorithmWithJets + InputMakerAlg = EventViewCreatorAlgorithmWithJets("BJetInputMaker_step2") + InputMakerAlg.OutputLevel = DEBUG + InputMakerAlg.ViewFallThrough = True # Access Store Gate for retrieving data + InputMakerAlg.ViewPerRoI = True # If True it creates one view per RoI + InputMakerAlg.Views = "BJetViews" # Name of output view + # RoIs + InputMakerAlg.InViewRoIs = "InViewRoIs" # Name RoIs are inserted in the view + InputMakerAlg.RoIsLink = "initialRoI" # RoIs linked to previous decision + # Jets + InputMakerAlg.InViewJets = "InViewJets" # Name Jets are inserted in the view + InputMakerAlg.JetsLink = "jets" # Jets linked to previous decision + + # Precision Tracking + + # gsc correction + from TrigBjetHypo.TrigGSCFexMTConfig import getGSCFexSplitInstance + theGSC = getGSCFexSplitInstance("GSCFexSplitInstance") + theGSC.OutputLevel = DEBUG + theGSC.RoIs = InputMakerAlg.InViewRoIs + theGSC.JetKey = InputMakerAlg.InViewJets + theGSC.PriVtxKey = "PrimaryVertex" + theGSC.JetOutputKey = "GSCJets" + + step2Sequence = seqAND("step2Sequence",[theGSC]); + InputMakerAlg.ViewNodeName = "step2Sequence" + + # hypo + from TrigBjetHypo.TrigBjetHypoConf import TrigBjetEtHypoAlgMT + from TrigBjetHypo.TrigBjetEtHypoTool import TrigBjetEtHypoToolFromName_gsc + hypo = TrigBjetEtHypoAlgMT("TrigBjetEtHypoAlg_step2") + hypo.OutputLevel = DEBUG + hypo.RoIs = "initialRoI" #InputMakerAlg.InViewRoIs + hypo.Jets = theGSC.JetOutputKey + hypo.PrimaryVertex = "PrimaryVertex" + hypo.RoILink = InputMakerAlg.RoIsLink # To be used in following step EventView + hypo.JetLink = InputMakerAlg.JetsLink # To be used in following step with EventView + hypo.UseView = True + + # Sequence + BjetAthSequence = seqAND("BjetAthSequence_step2",[InputMakerAlg,step2Sequence]) + + return MenuSequence( Sequence = BjetAthSequence, + Maker = InputMakerAlg, + Hypo = hypo, + HypoToolGen = TrigBjetEtHypoToolFromName_gsc ) + + +def bJetStep2SequenceALLTE(): + # menu components + from AthenaCommon.CFElements import parOR, seqAND, seqOR, stepSeq + from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import MenuSequence + + # input maker + from DecisionHandling.DecisionHandlingConf import InputMakerForRoI + InputMakerAlg = InputMakerForRoI("BJetInputMaker_step2_ALLTE") + InputMakerAlg.OutputLevel = DEBUG + InputMakerAlg.LinkName="initialRoI" + InputMakerAlg.RoIs="SplitJets" + + # gsc correction + from TrigBjetHypo.TrigGSCFexMTConfig import getGSCFexSplitInstance + theGSC = getGSCFexSplitInstance("GSCFexSplitInstance_ALLTE") + theGSC.OutputLevel = DEBUG + theGSC.JetKey = "SplitJets" + theGSC.JetOutputKey = "GSCJets" + theGSC.PriVtxKey = "PrimaryVertex" + + # hypo + from TrigBjetHypo.TrigBjetHypoConf import TrigBjetEtHypoAlgMT + from TrigBjetHypo.TrigBjetEtHypoTool import TrigBjetEtHypoToolFromName_gsc + hypo = TrigBjetEtHypoAlgMT("TrigBjetEtHypoAlg_step2ALLTE") + hypo.OutputLevel = DEBUG + hypo.Jets = theGSC.JetOutputKey + hypo.RoIs = InputMakerAlg.RoIs + hypo.PrimaryVertex = "PrimaryVertex" + hypo.RoILink = "initialRoI" + hypo.JetLink = "jets" + + # Sequence + BjetAthSequence = seqAND("BjetAthSequence_step2ALLTE",[InputMakerAlg,theGSC]) + + return MenuSequence( Sequence = BjetAthSequence, + Maker = InputMakerAlg, + Hypo = hypo, + HypoToolGen = TrigBjetEtHypoToolFromName_gsc ) + # ==================================================================================================== # step 3: secondary vertex and b-tagging # ==================================================================================================== + diff --git a/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py b/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py index 0a91c5391e0a30f7eea95a03ba8dddbe948dce36..f31513c5dc80ef0c353c83dcc24de7c3cdd63465 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/python/jetDefs.py @@ -52,7 +52,7 @@ def jetRecoSequence(RoIs): algo1.TrigDataAccessMT=svcMgr.TrigCaloDataAccessSvc algo1.roiMode = True algo1.CellsName="CellsClusters" - algo1.OutputLevel=VERBOSE +# algo1.OutputLevel=VERBOSE jetRecoSequence += algo1 @@ -60,7 +60,7 @@ def jetRecoSequence(RoIs): from TrigCaloRec.TrigCaloRecConfig import TrigCaloClusterMakerMT_topo algo2 = TrigCaloClusterMakerMT_topo(doMoments=True, doLC=False, cells="CellsClusters") # algo2.Cells = "CellsClusters" - algo2.OutputLevel = VERBOSE +# algo2.OutputLevel = VERBOSE jetRecoSequence += algo2 print algo2 for tool in algo2.ClusterMakerTools: @@ -78,12 +78,12 @@ def jetRecoSequence(RoIs): pseudoJetGetter.InputContainer = 'StoreGateSvc+caloclusters' pseudoJetGetter.OutputContainer = 'StoreGateSvc+PseudoJetEMTopo' pseudoJetGetter.Label = '' - pseudoJetGetter.OutputLevel = DEBUG +# pseudoJetGetter.OutputLevel = DEBUG ToolSvc += pseudoJetGetter algo3 = PseudoJetAlgorithm() - algo3.OutputLevel = VERBOSE +# algo3.OutputLevel = VERBOSE algo3.PJGetter = pseudoJetGetter jetRecoSequence += algo3 @@ -106,12 +106,12 @@ def jetRecoSequence(RoIs): from JetRec.JetRecConf import JetFromPseudojet jetBuilder = JetFromPseudojet(name+'JetBuilder') - jetBuilder.OutputLevel = DEBUG +# jetBuilder.OutputLevel = DEBUG ToolSvc += jetBuilder jetFinder = JetFinder(name+'JetFinder') jetFinder.JetBuilder = jetBuilder - jetFinder.OutputLevel = DEBUG +# jetFinder.OutputLevel = DEBUG jetFinder.JetAlgorithm = 'AntiKt' jetFinder.VariableRMinRadius = -1 jetFinder.VariableRMassScale = -1 @@ -128,7 +128,7 @@ def jetRecoSequence(RoIs): jetRecTool.JetFinder = jetFinder jetRecTool.JetModifiers = [] jetRecTool.Trigger = False - jetRecTool.OutputLevel = DEBUG +# jetRecTool.OutputLevel = DEBUG jetRecTool.InputPseudoJets = ['StoreGateSvc+PseudoJetEMTopo'] ToolSvc += jetRecTool diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/bJetMenu.ref b/Trigger/TrigValidation/TrigUpgradeTest/share/bJetMenu.ref index 4e770b61763cf69ce1f73751fcd99b23476c335c..8fb2a183c47fa8d6ffdae06b4affcbe9a4275ff4 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/bJetMenu.ref +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/bJetMenu.ref @@ -1,6 +1,6 @@ -TrigSignatureMoniMT INFO HLT_j35_gsc45_bmv2c1070 20 20 0 0 -TrigSignatureMoniMT INFO HLT_j35_gsc45_bmv2c1070 decisions 0 -TrigSignatureMoniMT INFO HLT_j35_gsc45_bmv2c1070_split 20 20 0 0 -TrigSignatureMoniMT INFO HLT_j35_gsc45_bmv2c1070_split decisions 0 -TrigSignatureMoniMT INFO HLT_j35_gsc45_boffperf_split 20 20 0 0 -TrigSignatureMoniMT INFO HLT_j35_gsc45_boffperf_split decisions 0 +TrigSignatureMoniMT INFO HLT_j35_gsc45_bmv2c1070 100 100 14 14 14 +TrigSignatureMoniMT INFO HLT_j35_gsc45_bmv2c1070 decisions 25 14 +TrigSignatureMoniMT INFO HLT_j35_gsc45_bmv2c1070_split 100 100 14 14 14 +TrigSignatureMoniMT INFO HLT_j35_gsc45_bmv2c1070_split decisions 25 14 +TrigSignatureMoniMT INFO HLT_j35_gsc45_boffperf_split 100 100 14 14 14 +TrigSignatureMoniMT INFO HLT_j35_gsc45_boffperf_split decisions 25 14 diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/bjet.menu.py b/Trigger/TrigValidation/TrigUpgradeTest/share/bjet.menu.py index cdadbd5d4ab254556a48118c943268d8e8b779c7..99f779fb72ed55bf1653273b6c46ac02468f4abf 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/bjet.menu.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/bjet.menu.py @@ -12,12 +12,16 @@ from TriggerMenuMT.HLTMenuConfig.Menu.MenuComponents import Chain, ChainStep # We should retrieve all the steps here from TrigUpgradeTest.bjetMenuDefs import getBJetSequence +step1ALLTE = ChainStep("Step1ALLTE_bjet", [getBJetSequence('jALLTE')]) +step2ALLTE = ChainStep("Step2ALLTE_bjet", [getBJetSequence('gscALLTE')]) + step1 = ChainStep("Step1_bjet", [getBJetSequence('j')]) +step2 = ChainStep("Step2_bjet", [getBJetSequence('gsc')]) testChains = [ - Chain(name='HLT_j35_gsc45_boffperf_split' , Seed="L1_J20", ChainSteps=[step1] ), - Chain(name='HLT_j35_gsc45_bmv2c1070_split', Seed="L1_J20", ChainSteps=[step1] ), - Chain(name='HLT_j35_gsc45_bmv2c1070' , Seed="L1_J20", ChainSteps=[step1] ) + Chain(name='HLT_j35_gsc45_boffperf_split' , Seed="L1_J20", ChainSteps=[step1,step2] ), + Chain(name='HLT_j35_gsc45_bmv2c1070_split', Seed="L1_J20", ChainSteps=[step1,step2] ), + Chain(name='HLT_j35_gsc45_bmv2c1070' , Seed="L1_J20", ChainSteps=[step1,step2] ) ] ################################# diff --git a/Trigger/TrigValidation/TrigUpgradeTest/test/test_bjet_menu.sh b/Trigger/TrigValidation/TrigUpgradeTest/test/test_bjet_menu.sh index e1cfed2abf368e3bb2925e366f6668f4ff69c1eb..125f7839ead1c1511aeda1e0e66c2ecd0f56335c 100755 --- a/Trigger/TrigValidation/TrigUpgradeTest/test/test_bjet_menu.sh +++ b/Trigger/TrigValidation/TrigUpgradeTest/test/test_bjet_menu.sh @@ -2,5 +2,4 @@ # art-type: build # art-include: master/Athena - -athena --threads=1 --skipEvents=10 --evtMax=20 --filesInput="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1" TrigUpgradeTest/bjet.menu.py +athena --threads=1 --skipEvents=0 --evtMax=100 --filesInput="/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data17_13TeV.00327265.physics_EnhancedBias.merge.RAW._lb0100._SFO-1._0001.1" TrigUpgradeTest/bjet.menu.py