ATLAS Offline Software
Loading...
Searching...
No Matches
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
14FPGATrackSimDetectorTool::FPGATrackSimDetectorTool(const std::string& algname, const std::string &name, const IInterface *ifc) :
15 AthAlgTool(algname,name,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
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
69 SCT_ID::const_id_iterator wafer_it = m_sctId->wafer_begin();
70 SCT_ID::const_id_iterator wafer_end = m_sctId->wafer_end();
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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Maps ITK module indices to FPGATrackSim regions.
DetectorZone
This is an Identifier helper class for the Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
Gaudi::Property< std::string > m_sram_path_pix
Gaudi::Property< std::string > m_sram_path_sct
virtual StatusCode initialize() override
const InDetDD::SiDetectorManager * m_PIX_mgr
Gaudi::Property< std::string > m_global2local_path
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
FPGATrackSimDetectorTool(const std::string &, const std::string &, const IInterface *)
void setPhiModule(unsigned v)
void setIdentifierHash(unsigned v)
void setEtaIndex(unsigned v)
void setPhiIndex(unsigned v)
void setHitType(HitType type)
void setLayerDisk(unsigned v)
void setEtaModule(int v)
void setDetectorZone(DetectorZone detZone)
void setDetType(SiliconTech detType)
This is a "hash" representation of an Identifier.
Class to hold geometrical description of a silicon detector element.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
virtual Identifier identify() const override final
identifier of this detector element (inline)
std::vector< Identifier >::const_iterator const_id_iterator
Definition SCT_ID.h:73
static TFile * fout
Definition listroot.cxx:40