Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
StripTdsOfflineTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GaudiKernel/ConcurrencyFlags.h"
6 
8 
9 namespace NSWL1 {
10 
11  class StripHits {
12  public:
17  : t_id (id),
18  t_strip (p),
20  { }
21  };
22 
23  using STRIP_MAP=std::map < Identifier,std::vector<StripHits> >;
24  using STRIP_MAP_IT=std::map < Identifier,std::vector<StripHits> >::iterator;
25  using STRIP_MAP_ITEM=std::pair< Identifier,std::vector<StripHits> >;
26 
27  StripTdsOfflineTool::StripTdsOfflineTool( const std::string& type, const std::string& name, const IInterface* parent) :
29  {
30  declareInterface<NSWL1::IStripTdsTool>(this);
31  }
32 
34  ATH_MSG_DEBUG( "initializing " << name() );
35 
36  ATH_MSG_DEBUG( name() << " configuration:");
37 
40 
42  ATH_CHECK(m_idHelperSvc.retrieve());
43  return StatusCode::SUCCESS;
44  }
45 
46  StatusCode StripTdsOfflineTool::gather_strip_data(std::vector<std::unique_ptr<StripData>>& strips, const std::vector<std::unique_ptr<PadTrigger>>& padTriggers) const {
47  ATH_MSG_DEBUG( "gather_strip_data: start gathering all strip htis");
48 
49  std::vector<std::unique_ptr<StripData>> strip_cache;
50  ATH_CHECK(fill_strip_cache(padTriggers, strip_cache));
51 
52  // delivering the required collection
53  for (unsigned int i=0; i< strip_cache.size(); i++) {
54  // Check if a stip should be read according to pad triggers
55  strips.push_back(std::move(strip_cache.at(i)));
56  }
57  strip_cache.clear();
58  ATH_MSG_DEBUG( "Delivered n. " << strips.size() << " STRIP hits." );
59  return StatusCode::SUCCESS;
60  }
61 
62 
63  StatusCode StripTdsOfflineTool::fill_strip_cache( const std::vector<std::unique_ptr<PadTrigger>>& padTriggers, std::vector<std::unique_ptr<StripData>> &strip_cache) const {
64  SG::ReadCondHandle<MuonGM::MuonDetectorManager> detManager{m_detManagerKey, Gaudi::Hive::currentContext()};
65  ATH_MSG_DEBUG( "fill_strip_cache: start filling the cache for STRIP hits" );
66 
67  if(m_isMC){
69  if(!sdo_container.isValid()){
70  ATH_MSG_WARNING("could not retrieve the sTGC SDO container: it will not be possible to associate the MC truth");
71  }
72  }
73 
75  if(!digit_container.isValid()){
76  ATH_MSG_ERROR("could not retrieve the sTGC Digit container: cannot return the STRIP hits");
77  }
78 
79  sTgcDigitContainer::const_iterator it = digit_container->begin();
80  sTgcDigitContainer::const_iterator it_e = digit_container->end();
81 
82  ATH_MSG_DEBUG( "retrieved sTGC Digit Container with " << digit_container->digit_size() << " collection" );
83  int strip_hit_number = 0;
84  for(; it!=it_e; ++it) {
85  const sTgcDigitCollection* coll = *it;
86 
87  ATH_MSG_DEBUG( "processing collection with size " << coll->size() );
88 
89  for (unsigned int item=0; item<coll->size(); item++) {
90  const sTgcDigit* digit = coll->at(item);
91  Identifier Id = digit->identify();
92  const MuonGM::sTgcReadoutElement* rdoEl = detManager->getsTgcReadoutElement(Id);
93  int channel_type = m_idHelperSvc->stgcIdHelper().channelType(Id);
94  // process only Strip data
95  if (channel_type!=1) continue;
96 
97  Amg::Vector2D strip_lpos;
98  Amg::Vector3D strip_gpos;
99  rdoEl->stripPosition(Id,strip_lpos);
100  const auto& stripSurface=rdoEl->surface(Id);
101  stripSurface.localToGlobal(strip_lpos, strip_gpos, strip_gpos);
102 
103  std::string stName = m_idHelperSvc->stgcIdHelper().stationNameString(m_idHelperSvc->stgcIdHelper().stationName(Id));
104  int stationEta = m_idHelperSvc->stgcIdHelper().stationEta(Id);
105  int stationPhi = m_idHelperSvc->stgcIdHelper().stationPhi(Id);
106  int wedge = m_idHelperSvc->stgcIdHelper().multilayer(Id);
107  int layer = m_idHelperSvc->stgcIdHelper().gasGap(Id);
108  int channel = m_idHelperSvc->stgcIdHelper().channel(Id);
109  int bctag = digit->bcTag();
110 
111  strip_hit_number++;
112  int strip_eta = 0;
113  int strip_phi = 0;
114 
115  ATH_MSG_DEBUG("sTGC Strip hit " << strip_hit_number << ": Station Name [" << stName << "]"
116  << " Station Eta [" << stationEta << "]"
117  << " Station Phi [" << stationPhi << "]"
118  << " Wedge [" << wedge << "]"
119  << " Layer [" << layer << "]"
120  << " Type [" << channel_type << "]"
121  << " ChNr [" << channel << "]"
122  << " Strip Eta [" << strip_eta << "]"
123  << " Strip Phi [" << strip_phi << "]"
124  << " Strip bcTAg [" << bctag << "]");
125 
126  bool isSmall = m_idHelperSvc->stgcIdHelper().isSmall(Id);
127  int trigger_sector = (isSmall)? stationPhi*2 : stationPhi*2-1;//
128  int cache_index = (stationEta>0)? trigger_sector + 16 : trigger_sector;
129  ATH_MSG_DEBUG("sTGC Strip hit " << strip_hit_number << ": Trigger Sector [" << trigger_sector << "]" << " Cache Index [" << cache_index << "]" );
130 
131  // process STRIP hit time: apply the time delay, set the BC tag for the hit according to the trigger capture window
132  auto strip=std::make_unique<StripOfflineData>(Id,&m_idHelperSvc->stgcIdHelper(),digit);
133  strip->set_locX(strip_lpos.x());
134  strip->set_locY(strip_lpos.y());
135  int sideid= (stationEta>0) ? 1 : 0;
136  int sectortype= (isSmall==1) ? 0 : 1;
137  int sectorid=stationPhi;
138  int moduleid=std::abs(stationEta);
139  int wedgeid=wedge;
140  int layerid=layer;
141  strip->setSideId(sideid);
142  strip->setSectorType(sectortype);
143  strip->setSectorId(sectorid);
144  strip->setModuleId(moduleid);
145  strip->setWedgeId(wedgeid);
146  strip->setLayerId(layerid);
147  strip->set_globX(strip_gpos.x());
148  strip->set_globY(strip_gpos.y());
149  strip->set_globZ(strip_gpos.z());
150  strip->set_locZ(0);
151 
152  bool read_strip=readStrip(strip.get(),padTriggers);
153  if (read_strip && (strip->bandId() ==-1 || strip->phiId()==-1 ) ) {
154  ATH_MSG_FATAL("StripTdsOfflineTool:NO MATCH ALL " << "\n"
155  << "wedge:" << strip->wedge() << "\n"
156  << "layer:"<< strip->layer() << "\n"
157  << "loc_x:"<< strip->locX()<< "\n");
158  }
159 
160  //set coordinates above ! readStrip needs that variables !
161  strip->set_readStrip(read_strip);
162  strip_cache.push_back(std::move(strip));
163  }//collections
164  }//items
165  ATH_MSG_DEBUG( "fill_strip_cache: end of processing" );
166  return StatusCode::SUCCESS;
167  }
168 
169 
170  bool StripTdsOfflineTool::readStrip(StripData* strip,const std::vector<std::unique_ptr<PadTrigger>>& padTriggers) const {
171 
172  if (strip->bandId() !=-1) {
173  ATH_MSG_DEBUG("StripTdsOfflineTool:ReadStrip: BandId already set\n" << "moduleID:" << strip->moduleId() +1 << "\n"
174  << "sectiorID:" << strip->sectorId() + 1 << "\n" << "layer:" << strip->wedge() << "\n");
175  }
176  if (strip->phiId() !=-1) {
177  ATH_MSG_DEBUG("StripTdsOfflineTool:ReadStrip: PhiId already set\n" << "moduleID:"<< strip->moduleId() +1 << "\n"
178  << "sectiorID:" << strip->sectorId() + 1 << "\n" << "layer:" << strip->wedge() << "\n");
179  }
180  for(const std::unique_ptr<PadTrigger>& trig :padTriggers){
181  //std::shared_ptr<PadData> padIn=trig->firstPadInner();
182  for(const std::shared_ptr<PadData>& pad : trig->m_pads){
183  if (strip->sideId()!=pad->sideId() ||
184  strip->isSmall()==pad->sectorType() || //strip returns 1 pad returns 0
185  strip->sectorId()!=pad->sectorId() ||
186  std::abs(strip->etaCenter() )> trig->etaMax() || //use abs / sideC
187  std::abs(strip->etaCenter() ) < trig->etaMin() ||
188  strip->layer()!=pad->gasGapId()
189  ) continue;
190  else {
191  strip->setBandId(trig->bandId());
192  strip->setPhiId(trig->phiId());
193  return true;
194  }
195  }//pad loop
196  }//padtrigger loop
197  return false;
198  }
199 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
NSWL1::StripTdsOfflineTool::StripTdsOfflineTool
StripTdsOfflineTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: StripTdsOfflineTool.cxx:27
NSWL1::StripTdsOfflineTool::m_sTgcSdoContainer
SG::ReadHandleKey< MuonSimDataCollection > m_sTgcSdoContainer
Definition: StripTdsOfflineTool.h:99
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
NSWL1::StripHits::t_id
Identifier t_id
Definition: StripTdsOfflineTool.cxx:13
NSWL1::StripOfflineData
class modeling the strip hit fragment for the NSW L1 offline simulation
Definition: StripOfflineData.h:34
StripTdsOfflineTool.h
NSWL1::StripHits::t_strip
StripOfflineData * t_strip
Definition: StripTdsOfflineTool.cxx:14
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
skel.it
it
Definition: skel.GENtoEVGEN.py:407
NSWL1::StripTdsOfflineTool::initialize
virtual StatusCode initialize() override
Definition: StripTdsOfflineTool.cxx:33
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
MuonGM::MuonClusterReadoutElement::surface
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
Definition: MuonClusterReadoutElement.h:123
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
NSWL1::StripData
abstract class to interface the data hit fragment output from the Strip TDS
Definition: TrigT1NSWSimTools/TrigT1NSWSimTools/StripData.h:30
MuonGM::sTgcReadoutElement::stripPosition
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position - should be renamed to channel position If the strip number is outside the range of va...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:321
sTgcDigit
Definition: sTgcDigit.h:20
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
sTgcDigitCollection
Definition: sTgcDigitCollection.h:18
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
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
MuonGM::sTgcReadoutElement
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:30
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:239
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:79
sTgcDigitContainer::digit_size
size_type digit_size() const
Definition: sTgcDigitContainer.cxx:55
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:233
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
NSWL1::StripTdsOfflineTool::fill_strip_cache
StatusCode fill_strip_cache(const std::vector< std::unique_ptr< PadTrigger >> &padTriggers, std::vector< std::unique_ptr< StripData >> &strip_cache) const
Definition: StripTdsOfflineTool.cxx:63
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
NSWL1::StripHits::StripHits
StripHits(Identifier id, StripOfflineData *p, int c)
Definition: StripTdsOfflineTool.cxx:16
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
item
Definition: ItemListSvc.h:43
NSWL1::STRIP_MAP_IT
std::map< Identifier, std::vector< StripHits > >::iterator STRIP_MAP_IT
Definition: StripTdsOfflineTool.cxx:24
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
NSWL1::StripHits
Definition: StripTdsOfflineTool.cxx:11
Muon::nsw::channel_type
channel_type
Definition: NSWDecodeHelper.h:21
NSWL1::STRIP_MAP
std::map< Identifier, std::vector< StripHits > > STRIP_MAP
Definition: StripTdsOfflineTool.cxx:23
NSWL1::StripTdsOfflineTool::m_sTgcDigitContainer
SG::ReadHandleKey< sTgcDigitContainer > m_sTgcDigitContainer
Definition: StripTdsOfflineTool.h:98
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
NSWL1::StripTdsOfflineTool::readStrip
bool readStrip(StripData *, const std::vector< std::unique_ptr< PadTrigger >> &) const
Definition: StripTdsOfflineTool.cxx:170
NSWL1::StripHits::t_cache_index
int t_cache_index
Definition: StripTdsOfflineTool.cxx:15
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
NSWL1::STRIP_MAP_ITEM
std::pair< Identifier, std::vector< StripHits > > STRIP_MAP_ITEM
Definition: StripTdsOfflineTool.cxx:25
AthAlgTool
Definition: AthAlgTool.h:26
Trk::PlaneSurface::localToGlobal
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
Definition: PlaneSurface.cxx:204
NSWL1::StripTdsOfflineTool::gather_strip_data
virtual StatusCode gather_strip_data(std::vector< std::unique_ptr< StripData >> &strips, const std::vector< std::unique_ptr< PadTrigger >> &padTriggers) const override
Definition: StripTdsOfflineTool.cxx:46
NSWL1
A trigger trigger candidate for a stgc sector.
Definition: NSWL1Simulation.cxx:7
NSWL1::StripTdsOfflineTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: StripTdsOfflineTool.h:93
python.compressB64.c
def c
Definition: compressB64.py:93
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
NSWL1::StripTdsOfflineTool::m_isMC
Gaudi::Property< bool > m_isMC
Definition: StripTdsOfflineTool.h:96
NSWL1::StripTdsOfflineTool::m_detManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detManagerKey
Definition: StripTdsOfflineTool.h:92
Identifier
Definition: IdentifierFieldParser.cxx:14