ATLAS Offline Software
MuonSegmentFilterAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MuonSegmentFilterAlg.h"
6 #include "TrkSurfaces/Surface.h"
7 MuonSegmentFilterAlg::MuonSegmentFilterAlg(const std::string& name, ISvcLocator* pSvcLocator) : AthReentrantAlgorithm(name, pSvcLocator) {}
8 
10  ATH_CHECK(m_idHelperSvc.retrieve());
11  ATH_CHECK(m_outKey.initialize());
12 
13  ATH_CHECK(m_inKey.initialize());
14 
15  return StatusCode::SUCCESS;
16 }
17 
18 StatusCode MuonSegmentFilterAlg::execute(const EventContext& ctx) const {
19 
20  SG::ReadHandle<Trk::SegmentCollection> segment_container(m_inKey, ctx);
21  if (!segment_container.isValid()){
22  ATH_MSG_FATAL("Failed to retrieve segment container "<<m_inKey.fullKey());
23  }
24 
25 
28  for (const Trk::Segment* seg : *segment_container){
29  if (keep_segment(seg)) out_handle->push_back(seg);
30  }
31  if (m_trash_unfiltered && !segment_container->empty() && out_handle->size() == segment_container->size()){
32  ATH_MSG_DEBUG("The input and output container are the same. Clear output container");
33  out_handle->clear();
34  }
35 
36 
37 
38  return StatusCode::SUCCESS;
39 }
41  for (const Trk::MeasurementBase* meas : segment->containedMeasurements()){
43  const Identifier id = meas->associatedSurface().associatedDetectorElementIdentifier();
44  if (!m_thin_stations.empty()){
45  const StIdx::StIndex stationIndex = m_idHelperSvc->stationIndex(id);
46  if (std::find_if(m_thin_stations.begin(), m_thin_stations.end(), [stationIndex](const int idx){
47  return idx == stationIndex;
48  }) != m_thin_stations.end() ) return false;
49  }
50  if (!m_thin_layers.empty()){
51  const StIdx::LayerIndex layerIndex = m_idHelperSvc->layerIndex(id);
52  if (std::find_if(m_thin_layers.begin(),m_thin_layers.end(),[layerIndex](const int idx)
53  {return idx == layerIndex;})!= m_thin_layers.end()) return false;
54  }
55  if (!m_thin_technology.empty()){
56  const StIdx::TechnologyIndex technologyIndex = m_idHelperSvc->technologyIndex(id);
57  if (std::find_if(m_thin_technology.begin(),m_thin_technology.end(),[technologyIndex](const int idx ){
58  return idx == technologyIndex;
59  })!= m_thin_technology.end()) return false;
60  }
61  if (!m_thin_region.empty()){
62  const StIdx::DetectorRegionIndex regionIndex = m_idHelperSvc->regionIndex(id);
63  if (std::find_if(m_thin_region.begin(),m_thin_region.end(),[regionIndex](const int idx){
64  return regionIndex == idx;
65  }) != m_thin_region.end() ) return false;
66  }
68  if (!m_thin_chamber_idx.empty()){
69  const StIdx::ChIndex chamberIdx = m_idHelperSvc->chamberIndex(id);
70  if (std::find_if(m_thin_chamber_idx.begin(),m_thin_chamber_idx.end(),[chamberIdx](const int idx){
71  return idx == chamberIdx;}) != m_thin_chamber_idx.end()) return false;
72  }
73  }
74  return true;
75 }
MuonSegmentFilterAlg::m_thin_technology
Gaudi::Property< std::vector< int > > m_thin_technology
Definition: MuonSegmentFilterAlg.h:54
MuonSegmentFilterAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonSegmentFilterAlg.cxx:18
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonSegmentFilterAlg::m_thin_stations
Gaudi::Property< std::vector< int > > m_thin_stations
Definition: MuonSegmentFilterAlg.h:52
Surface.h
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
MuonSegmentFilterAlg::MuonSegmentFilterAlg
MuonSegmentFilterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonSegmentFilterAlg.cxx:7
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Muon::MuonStationIndex::LayerIndex
LayerIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:38
MuonSegmentFilterAlg::m_thin_layers
Gaudi::Property< std::vector< int > > m_thin_layers
Definition: MuonSegmentFilterAlg.h:53
MuonSegmentFilterAlg.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MuonSegmentFilterAlg::keep_segment
bool keep_segment(const Trk::Segment *segment) const
Definition: MuonSegmentFilterAlg.cxx:40
MuonSegmentFilterAlg::m_outKey
SG::WriteHandleKey< ConstDataVector< Trk::SegmentCollection > > m_outKey
Definition: MuonSegmentFilterAlg.h:35
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::Segment
Definition: TrkEvent/TrkSegment/TrkSegment/Segment.h:56
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonSegmentFilterAlg::m_thin_region
Gaudi::Property< std::vector< int > > m_thin_region
Definition: MuonSegmentFilterAlg.h:55
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
MuonSegmentFilterAlg::m_trash_unfiltered
Gaudi::Property< bool > m_trash_unfiltered
If no segments are removed from the container then empty the entire container as the algoritihms depe...
Definition: MuonSegmentFilterAlg.h:60
Muon::MuonStationIndex::DetectorRegionIndex
DetectorRegionIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:47
Trk::MeasurementBase
Definition: MeasurementBase.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MuonSegmentFilterAlg::initialize
virtual StatusCode initialize() override
Definition: MuonSegmentFilterAlg.cxx:9
MuonSegmentFilterAlg::m_inKey
SG::ReadHandleKey< Trk::SegmentCollection > m_inKey
Definition: MuonSegmentFilterAlg.h:41
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
MuonSegmentFilterAlg::m_thin_chamber_idx
Gaudi::Property< std::vector< int > > m_thin_chamber_idx
Definition: MuonSegmentFilterAlg.h:56
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
Muon::MuonStationIndex::ChIndex
ChIndex
enum to classify the different chamber layers in the muon spectrometer
Definition: MuonStationIndex.h:15
Muon::MuonStationIndex::StIndex
StIndex
enum to classify the different station layers in the muon spectrometer
Definition: MuonStationIndex.h:23
Muon::MuonStationIndex::TechnologyIndex
TechnologyIndex
enum to classify the different layers in the muon spectrometer
Definition: MuonStationIndex.h:54
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5
MuonSegmentFilterAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MuonSegmentFilterAlg.h:29