ATLAS Offline Software
FPGATrackSimDetectorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
11 
12 
13 
14 FPGATrackSimDetectorTool::FPGATrackSimDetectorTool(const std::string& algname, const std::string &name, const IInterface *ifc) :
16  {}
17 
18 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
20  ATH_CHECK( detStore()->retrieve(m_PIX_mgr, "Pixel"));
21  ATH_CHECK( detStore()->retrieve(m_pixelId, "PixelID") );
22  ATH_CHECK( detStore()->retrieve(m_sctId, "SCT_ID") );
23  ATH_CHECK( m_FPGATrackSimMapping.retrieve() ) ;
24  return StatusCode::SUCCESS;
25 }
26 
27 
28 /* this method loops over all the ID modules, pixel and SCT, with the goal
29  * to create the online and offline map used to describe the modules within
30  * the FPGATrackSim system. In particular can create the list of the modules in FPGATrackSim
31  * towers, organized by layer, as used to calcualte the SS
32  */
34  /* All the modules are collected as FPGATrackSimHit, allowing to interact efficiently
35  * with FPGATrackSim elements as PMAP or RMAP
36  */
37  std::list<FPGATrackSimHit> CompleteIDModuleList;
38 
39  // To save the SRAM lookup into an output file
40  std::ofstream fout_pix(m_sram_path_pix);
41  std::ofstream fout_sct(m_sram_path_sct);
42  Int_t countForSRAM(0);
43 
44  for( InDetDD::SiDetectorElementCollection::const_iterator i=m_PIX_mgr->getDetectorElementBegin(), f=m_PIX_mgr->getDetectorElementEnd() ; i!=f; ++i ) {
45  const InDetDD::SiDetectorElement* sielement( *i );
46  Identifier id = sielement->identify();
47  IdentifierHash idhash = sielement->identifyHash();
48 
49  FPGATrackSimHit tmpmodraw;
50 
51  tmpmodraw.setHitType(HitType::unmapped);
52  tmpmodraw.setDetType(SiliconTech::pixel);
53  tmpmodraw.setDetectorZone(static_cast<DetectorZone>(m_pixelId->barrel_ec(id)));
54  tmpmodraw.setLayerDisk(m_pixelId->layer_disk(id));
55  tmpmodraw.setPhiModule(m_pixelId->phi_module(id));
56  tmpmodraw.setEtaModule(m_pixelId->eta_module(id));
57  tmpmodraw.setPhiIndex(m_pixelId->phi_index(id));
58  tmpmodraw.setEtaIndex(m_pixelId->eta_index(id));
59  tmpmodraw.setIdentifierHash(idhash);
60 
61  fout_pix << m_pixelId->barrel_ec(id) << "\t" << m_pixelId->layer_disk(id) << "\t" << m_pixelId->phi_module(id) << "\t" << m_pixelId->eta_module(id) << "\t" << countForSRAM << std::endl;
62  countForSRAM++;
63 
64  CompleteIDModuleList.push_back(tmpmodraw);
65  }
66 
67  countForSRAM = 0;
68 
71  for (; wafer_it!=wafer_end; ++wafer_it) {
72  const Identifier id = *wafer_it;
73  const IdentifierHash idhash = m_sctId->wafer_hash(id);
74 
75  FPGATrackSimHit tmpmodraw;
76 
77  tmpmodraw.setHitType(HitType::unmapped);
78  tmpmodraw.setDetType(SiliconTech::strip);
79  tmpmodraw.setDetectorZone(static_cast<DetectorZone>(m_sctId->barrel_ec(id)));
80  tmpmodraw.setLayerDisk(m_sctId->layer_disk(id));
81  tmpmodraw.setPhiModule(m_sctId->phi_module(id));
82  tmpmodraw.setEtaModule(m_sctId->eta_module(id));
83  tmpmodraw.setPhiIndex(m_sctId->side(id));
84  tmpmodraw.setEtaIndex(m_sctId->strip(id));
85  tmpmodraw.setIdentifierHash(idhash);
86 
87  fout_sct << m_sctId->barrel_ec(id) << "\t" << m_sctId->layer_disk(id) << "\t" << m_sctId->phi_module(id) << "\t" << m_sctId->eta_module(id) << "\t" << countForSRAM << std::endl;
88  countForSRAM++;
89 
90  CompleteIDModuleList.push_back(tmpmodraw);
91  }
92 
93 
94 
95  /* The modules are store by tower and by logical layer */
96  unsigned int nregions(m_FPGATrackSimMapping->RegionMap_2nd()->getNRegions()); // get the number of towers
97  unsigned int nplanes(m_FPGATrackSimMapping->PlaneMap_2nd(0)->getNLogiLayers());
98  std::set<unsigned int> **grouped_modules = new std::set<unsigned int>*[nregions];
99  for (unsigned int ireg=0;ireg!=nregions;++ireg) grouped_modules[ireg] = new std::set<unsigned int>[nplanes];
100 
101  for (auto& curmodrawhit: CompleteIDModuleList) { // loop over the modules, represente as raw hits
102  // verify if accoring the current pmap this is module that has to be mapped
103 
104  // convert the FPGATrackSimHit representation in FPGATrackSimHit to interact with the PMAP
105  m_FPGATrackSimMapping->PlaneMap_2nd(0)->map(curmodrawhit);
106 
107  bool hasOneRegion(false); // it will become true if at least 1 tower is associated with the module
108  for (unsigned int ireg=0;ireg!=nregions;++ireg) { // loop over the regions
109  if (m_FPGATrackSimMapping->RegionMap_2nd()->isInRegion(ireg,curmodrawhit)) {
110  hasOneRegion = true;
111  // the module is compatible with the current
112  grouped_modules[ireg][curmodrawhit.getLayer()].insert(curmodrawhit.getIdentifierHash());
113  }
114  } // end loop over the regions
115 
116  if (!hasOneRegion) ATH_MSG_WARNING ( "The module with hash " << curmodrawhit.getIdentifierHash() << " and FPGATrackSim ID (" << curmodrawhit.getLayer() << "," << curmodrawhit.getSection() << ") is not associated to a tower");
117  } // end loop over the modules
118 
119  // Save the map into the output file and print at screen a small message
120  std::ofstream fout(m_global2local_path.value().c_str());
121  for (unsigned int ireg=0;ireg!=nregions;++ireg) { // loop over the regions
122  for (unsigned int ip=0;ip!=nplanes;++ip) { // loop over the regions
123  ATH_MSG_DEBUG ( "Region " << ireg << ", layer" << ip << " has " << grouped_modules[ireg][ip].size() << " modules");
124  unsigned int modnumber(0);
125  for (const auto &curhash: grouped_modules[ireg][ip]) {
126  fout << ireg << '\t' << ip << '\t' << curhash << '\t' << modnumber++ << std::endl;
127  }
128  }
129  }
130  fout.close();
131 
132  // Close SRAM lookup tables
133  fout_pix.close();
134  fout_sct.close();
135 
136  // clear the memory
137  for (unsigned int ireg=0;ireg!=nregions;++ireg) delete [] grouped_modules[ireg];
138  delete [] grouped_modules;
139 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
getMenu.algname
algname
Definition: getMenu.py:54
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:658
FPGATrackSimDetectorTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimDetectorTool.cxx:19
SiliconTech::strip
@ strip
FPGATrackSimHit::setEtaIndex
void setEtaIndex(unsigned v)
Definition: FPGATrackSimHit.h:103
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
FPGATrackSimHit::setIdentifierHash
void setIdentifierHash(unsigned v)
Definition: FPGATrackSimHit.h:72
SCT_ID::wafer_begin
const_id_iterator wafer_begin(void) const
Iterators over full set of ids. Wafer iterator is sorted.
Definition: SCT_ID.cxx:654
FPGATrackSimDetectorTool::m_sram_path_sct
Gaudi::Property< std::string > m_sram_path_sct
Definition: FPGATrackSimDetectorTool.h:45
FPGATrackSimDetectorTool::m_PIX_mgr
const InDetDD::SiDetectorManager * m_PIX_mgr
Definition: FPGATrackSimDetectorTool.h:49
SCT_ID::const_id_iterator
std::vector< Identifier >::const_iterator const_id_iterator
Definition: SCT_ID.h:73
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
FPGATrackSimDetectorTool::m_sctId
const SCT_ID * m_sctId
Definition: FPGATrackSimDetectorTool.h:51
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
FPGATrackSimHit::setDetectorZone
void setDetectorZone(DetectorZone detZone)
Definition: FPGATrackSimHit.h:56
InDetDD::SolidStateDetectorElementBase::identifyHash
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimRegionMap.h
Maps ITK module indices to FPGATrackSim regions.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
FPGATrackSimHit::setDetType
void setDetType(SiliconTech detType)
Definition: FPGATrackSimHit.h:55
FPGATrackSimHit::setPhiIndex
void setPhiIndex(unsigned v)
Definition: FPGATrackSimHit.h:102
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimDetectorTool::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimDetectorTool.h:42
dqt_zlumi_alleff_HIST.fout
fout
Definition: dqt_zlumi_alleff_HIST.py:59
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
FPGATrackSimHit::setEtaModule
void setEtaModule(int v)
Definition: FPGATrackSimHit.h:76
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
PixelID::eta_index
int eta_index(const Identifier &id) const
Definition: PixelID.h:664
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
hist_file_dump.f
f
Definition: hist_file_dump.py:135
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
FPGATrackSimHit::setPhiModule
void setPhiModule(unsigned v)
Definition: FPGATrackSimHit.h:77
FPGATrackSimDetectorTool::m_sram_path_pix
Gaudi::Property< std::string > m_sram_path_pix
Definition: FPGATrackSimDetectorTool.h:44
FPGATrackSimDetectorTool.h
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
FPGATrackSimHit::setLayerDisk
void setLayerDisk(unsigned v)
Definition: FPGATrackSimHit.h:73
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
FPGATrackSimDetectorTool::FPGATrackSimDetectorTool
FPGATrackSimDetectorTool(const std::string &, const std::string &, const IInterface *)
Definition: FPGATrackSimDetectorTool.cxx:14
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SiDetectorElement.h
DetectorZone
DetectorZone
Definition: FPGATrackSimTypes.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
SCT_ID::strip
int strip(const Identifier &id) const
Definition: SCT_ID.h:764
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
FPGATrackSimDetectorTool::m_pixelId
const PixelID * m_pixelId
Definition: FPGATrackSimDetectorTool.h:50
FPGATrackSimDetectorTool::m_global2local_path
Gaudi::Property< std::string > m_global2local_path
Definition: FPGATrackSimDetectorTool.h:43
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
SCT_ID::wafer_end
const_id_iterator wafer_end(void) const
Definition: SCT_ID.cxx:658
InDetDD::SiDetectorManager::getDetectorElementEnd
virtual SiDetectorElementCollection::const_iterator getDetectorElementEnd() const =0
FPGATrackSimDetectorTool::dumpGlobalToLocalModuleMap
void dumpGlobalToLocalModuleMap()
Definition: FPGATrackSimDetectorTool.cxx:33
AthAlgTool
Definition: AthAlgTool.h:26
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
InDetDD::SiDetectorManager::getDetectorElementBegin
virtual SiDetectorElementCollection::const_iterator getDetectorElementBegin() const =0
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
InDetDD::SolidStateDetectorElementBase::identify
virtual Identifier identify() const override final
identifier of this detector element (inline)
SiliconTech::pixel
@ pixel
HitType::unmapped
@ unmapped
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54
Identifier
Definition: IdentifierFieldParser.cxx:14