L1Trigger/L1TTrackMatch/plugins/L1TrackSelectionProducer.cc
// ------------ method called to produce the data  ------------
method called to produce the data
method called to produce the data
void L1TrackSelectionProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
  auto vTTTrackOutput = std::make_unique<TTTrackRefCollection>();
  auto vTTTrackAssociatedOutput = std::make_unique<TTTrackRefCollection>();
  auto vTTTrackEmulationOutput = std::make_unique<TTTrackRefCollection>();
  auto vTTTrackAssociatedEmulationOutput = std::make_unique<TTTrackRefCollection>();
  const TrackerTopology& tTopo = iSetup.getData(tTopoToken_);
  TTTrackCollectionHandle l1TracksHandle;
  edm::Handle<l1t::VertexCollection> l1VerticesHandle;
  edm::Handle<l1t::VertexWordCollection> l1VerticesEmulationHandle;
  l1t::Vertex leadingVertex;
  l1t::VertexWord leadingEmulationVertex;
  iEvent.getByToken(l1TracksToken_, l1TracksHandle);
  size_t nOutputApproximate = l1TracksHandle->size();
  if (processSimulatedTracks_) {
    if (doDeltaZCutSim_) {
      iEvent.getByToken(l1VerticesToken_, l1VerticesHandle);
      leadingVertex = l1VerticesHandle->at(0);
      if (debug_ >= 2) {
        edm::LogInfo("L1TrackSelectionProducer") << "leading vertex z0 = " << leadingVertex.z0();
      }
    }
    vTTTrackOutput->reserve(nOutputApproximate);
    vTTTrackAssociatedOutput->reserve(nOutputApproximate);
  }
  if (processEmulatedTracks_) {
    if (doDeltaZCutEmu_) {
      iEvent.getByToken(l1VerticesEmulationToken_, l1VerticesEmulationHandle);
      leadingEmulationVertex = l1VerticesEmulationHandle->at(0);
      if (debug_ >= 2) {
        edm::LogInfo("L1TrackSelectionProducer") << "leading emulation vertex z0 = " << leadingEmulationVertex.z0();
      }
    }
    vTTTrackEmulationOutput->reserve(nOutputApproximate);
    vTTTrackAssociatedEmulationOutput->reserve(nOutputApproximate);
  }
  TTTrackPtMinEtaMaxZ0MaxNStubsMinSelector kinSel(ptMin_, absEtaMax_, absZ0Max_, nStubsMin_);
  TTTrackWordPtMinEtaMaxZ0MaxNStubsMinSelector kinSelEmu(ptMin_, absEtaMax_, absZ0Max_, nStubsMin_);
  TTTrackBendChi2Chi2RZChi2RPhiMaxSelector chi2Sel(bendChi2Max_, reducedChi2RZMax_, reducedChi2RPhiMax_);
  TTTrackWordBendChi2Chi2RZChi2RPhiMaxSelector chi2SelEmu(bendChi2Max_, reducedChi2RZMax_, reducedChi2RPhiMax_);
  TTTrackDeltaZMaxSelector deltaZSel(deltaZMaxEtaBounds_, deltaZMax_);
  TTTrackWordDeltaZMaxSelector deltaZSelEmu(deltaZMaxEtaBounds_, deltaZMax_);
  TTTrackNPSStubsMinSelector nPSStubsSel(nPSStubsMin_, tTopo);
  for (size_t i = 0; i < nOutputApproximate; i++) {
    const auto& track = l1TracksHandle->at(i);
    if (processSimulatedTracks_ && kinSel(track) && nPSStubsSel(track) && chi2Sel(track)) {
      vTTTrackOutput->push_back(TTTrackRef(l1TracksHandle, i));
      if (doDeltaZCutSim_ && deltaZSel(track, leadingVertex)) {
        vTTTrackAssociatedOutput->push_back(TTTrackRef(l1TracksHandle, i));
      }
    }
    if (processEmulatedTracks_ && kinSelEmu(track) && chi2SelEmu(track)) {
      vTTTrackEmulationOutput->push_back(TTTrackRef(l1TracksHandle, i));
      if (doDeltaZCutEmu_ && deltaZSelEmu(track, leadingEmulationVertex)) {
        vTTTrackAssociatedEmulationOutput->push_back(TTTrackRef(l1TracksHandle, i));
      }
    }
  }
  if (debug_ >= 2) {
    printDebugInfo(l1TracksHandle,
                   vTTTrackOutput,
                   vTTTrackEmulationOutput,
                   vTTTrackAssociatedOutput,
                   vTTTrackAssociatedEmulationOutput);
  }
  if (processSimulatedTracks_) {
    iEvent.put(std::move(vTTTrackOutput), outputCollectionName_);
    if (doDeltaZCutSim_) {
      iEvent.put(std::move(vTTTrackAssociatedOutput), outputCollectionName_ + "Associated");
    }
  }
  if (processEmulatedTracks_) {
    iEvent.put(std::move(vTTTrackEmulationOutput), outputCollectionName_ + "Emulation");
    if (doDeltaZCutEmu_) {
      iEvent.put(std::move(vTTTrackAssociatedEmulationOutput), outputCollectionName_ + "AssociatedEmulation");
    }
  }
}
void L1TrackSelectionProducer :: produce ( edm :: StreamID , edm :: Event & iEvent , const edm :: EventSetup & iSetup ) const { auto vTTTrackOutput = std :: make_unique < TTTrackRefCollection > ( ) ; auto vTTTrackAssociatedOutput = std :: make_unique < TTTrackRefCollection > ( ) ; auto vTTTrackEmulationOutput = std :: make_unique < TTTrackRefCollection > ( ) ; auto vTTTrackAssociatedEmulationOutput = std :: make_unique < TTTrackRefCollection > ( ) ; const TrackerTopology & tTopo = iSetup . getData ( tTopoToken_ ) ; TTTrackCollectionHandle l1TracksHandle ; edm :: Handle < l1t :: VertexCollection > l1VerticesHandle ; edm :: Handle < l1t :: VertexWordCollection > l1VerticesEmulationHandle ; l1t :: Vertex leadingVertex ; l1t :: VertexWord leadingEmulationVertex ; iEvent . getByToken ( l1TracksToken_ , l1TracksHandle ) ; size_t nOutputApproximate = l1TracksHandle -> size ( ) ; if ( processSimulatedTracks_ ) { if ( doDeltaZCutSim_ ) { iEvent . getByToken ( l1VerticesToken_ , l1VerticesHandle ) ; leadingVertex = l1VerticesHandle -> at ( 0 ) ; if ( debug_ >= 2 ) { edm :: LogInfo ( " " ) << " " << leadingVertex . z0 ( ) ; } } vTTTrackOutput -> reserve ( nOutputApproximate ) ; vTTTrackAssociatedOutput -> reserve ( nOutputApproximate ) ; } if ( processEmulatedTracks_ ) { if ( doDeltaZCutEmu_ ) { iEvent . getByToken ( l1VerticesEmulationToken_ , l1VerticesEmulationHandle ) ; leadingEmulationVertex = l1VerticesEmulationHandle -> at ( 0 ) ; if ( debug_ >= 2 ) { edm :: LogInfo ( " " ) << " " << leadingEmulationVertex . z0 ( ) ; } } vTTTrackEmulationOutput -> reserve ( nOutputApproximate ) ; vTTTrackAssociatedEmulationOutput -> reserve ( nOutputApproximate ) ; } TTTrackPtMinEtaMaxZ0MaxNStubsMinSelector kinSel ( ptMin_ , absEtaMax_ , absZ0Max_ , nStubsMin_ ) ; TTTrackWordPtMinEtaMaxZ0MaxNStubsMinSelector kinSelEmu ( ptMin_ , absEtaMax_ , absZ0Max_ , nStubsMin_ ) ; TTTrackBendChi2Chi2RZChi2RPhiMaxSelector chi2Sel ( bendChi2Max_ , reducedChi2RZMax_ , reducedChi2RPhiMax_ ) ; TTTrackWordBendChi2Chi2RZChi2RPhiMaxSelector chi2SelEmu ( bendChi2Max_ , reducedChi2RZMax_ , reducedChi2RPhiMax_ ) ; TTTrackDeltaZMaxSelector deltaZSel ( deltaZMaxEtaBounds_ , deltaZMax_ ) ; TTTrackWordDeltaZMaxSelector deltaZSelEmu ( deltaZMaxEtaBounds_ , deltaZMax_ ) ; TTTrackNPSStubsMinSelector nPSStubsSel ( nPSStubsMin_ , tTopo ) ; for ( size_t i = 0 ; i < nOutputApproximate ; i ++ ) { const auto & track = l1TracksHandle -> at ( i ) ; if ( processSimulatedTracks_ && kinSel ( track ) && nPSStubsSel ( track ) && chi2Sel ( track ) ) { vTTTrackOutput -> push_back ( TTTrackRef ( l1TracksHandle , i ) ) ; if ( doDeltaZCutSim_ && deltaZSel ( track , leadingVertex ) ) { vTTTrackAssociatedOutput -> push_back ( TTTrackRef ( l1TracksHandle , i ) ) ; } } if ( processEmulatedTracks_ && kinSelEmu ( track ) && chi2SelEmu ( track ) ) { vTTTrackEmulationOutput -> push_back ( TTTrackRef ( l1TracksHandle , i ) ) ; if ( doDeltaZCutEmu_ && deltaZSelEmu ( track , leadingEmulationVertex ) ) { vTTTrackAssociatedEmulationOutput -> push_back ( TTTrackRef ( l1TracksHandle , i ) ) ; } } } if ( debug_ >= 2 ) { printDebugInfo ( l1TracksHandle , vTTTrackOutput , vTTTrackEmulationOutput , vTTTrackAssociatedOutput , vTTTrackAssociatedEmulationOutput ) ; } if ( processSimulatedTracks_ ) { iEvent . put ( std :: move ( vTTTrackOutput ) , outputCollectionName_ ) ; if ( doDeltaZCutSim_ ) { iEvent . put ( std :: move ( vTTTrackAssociatedOutput ) , outputCollectionName_ + " " ) ; } } if ( processEmulatedTracks_ ) { iEvent . put ( std :: move ( vTTTrackEmulationOutput ) , outputCollectionName_ + " " ) ; if ( doDeltaZCutEmu_ ) { iEvent . put ( std :: move ( vTTTrackAssociatedEmulationOutput ) , outputCollectionName_ + " " ) ; } } }
method called to produce the data
method called to produce the data
// Tracker Topology // Select tracks based on the floating point TTTrack // Select tracks based on the bitwise accurate TTTrack_TrackWord // Put the outputs into the event