ATLAS Offline Software
TGCDatabaseManager.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
13 #include "TrigT1TGC/TGCGoodMF.h"
17 
19 
20 namespace LVL1TGCTrigger {
21 
23 {
24  if(!patchPanel) return 0;
25 
26  PatchPanelIDs patchPanelIDs(5, -1);
27  patchPanelIDs.at(0) = (patchPanel->getRegion() == TGCRegionType::FORWARD ? 0 : 1);
28  patchPanelIDs.at(1) = patchPanel->getType();
29  patchPanelIDs.at(2) = patchPanel->getId();
30  patchPanelIDs.at(3) = (patchPanel->getAdjacentPP(0) ? patchPanel->getAdjacentPP(0)->getId() : -1);
31  patchPanelIDs.at(4) = (patchPanel->getAdjacentPP(1) ? patchPanel->getAdjacentPP(1)->getId() : -1);
32 
33  std::map<PatchPanelIDs, std::pair<const TGCConnectionInPP, PatchPanelPointers> >::const_iterator cit
34  = m_patchPanelToConnectionInPP.find(patchPanelIDs);
35  // If this PatchPanel is already registered, create a clone connectionInPP
36  if(cit!=m_patchPanelToConnectionInPP.end()) {
37  TGCConnectionInPP* newConnectionInPP = new TGCConnectionInPP(((*cit).second).first);
38  PatchPanelPointers oldPatchPanelPointers = ((*cit).second).second;
39  // Need to replace PatchPanel pointers of newConnectionInPP by ones of patchPanel
40  bool isReplaced = newConnectionInPP->replacePatchPanelPointers(patchPanel, oldPatchPanelPointers);
41  if(!isReplaced) {
42  delete newConnectionInPP;
43  newConnectionInPP = 0;
44  }
45  return newConnectionInPP;
46  }
47 
48  return 0;
49 }
50 
52  const TGCConnectionInPP* connectionInPP)
53 {
54  if(!patchPanel || !connectionInPP) return;
55 
56  PatchPanelIDs patchPanelIDs(5, -1);
57  patchPanelIDs.at(0) = (patchPanel->getRegion() == TGCRegionType::FORWARD ? 0 : 1);
58  patchPanelIDs.at(1) = patchPanel->getType();
59  patchPanelIDs.at(2) = patchPanel->getId();
60  patchPanelIDs.at(3) = (patchPanel->getAdjacentPP(0) ? patchPanel->getAdjacentPP(0)->getId() : -1);
61  patchPanelIDs.at(4) = (patchPanel->getAdjacentPP(1) ? patchPanel->getAdjacentPP(1)->getId() : -1);
62 
63  PatchPanelPointers patchPanelPointers;
64  patchPanelPointers.push_back(patchPanel);
65  patchPanelPointers.push_back(patchPanel->getAdjacentPP(0));
66  patchPanelPointers.push_back(patchPanel->getAdjacentPP(1));
67 
68  TGCConnectionInPP newConnectionInPP(*connectionInPP);
69  std::pair<const TGCConnectionInPP, PatchPanelPointers> cInPP_PPPs(newConnectionInPP, patchPanelPointers);
70 
71  m_patchPanelToConnectionInPP.insert(std::pair<PatchPanelIDs, std::pair<const TGCConnectionInPP, PatchPanelPointers> >
72  (patchPanelIDs, cInPP_PPPs));
73 }
74 
76  : AthMessaging("LVL1TGC::TGCDatabaseManager"),
77  m_tgcArgs(nullptr)
78 {
79  for(int j=0; j<NumberOfRegionType; j+=1){
80  for(int i=0; i<TGCSector::NumberOfPatchPanelType; i+=1){
81  for(int k=0; k<TotalNumForwardBackwardType; k+=1){
82  m_ASDToPP[j][i][k] = 0;
83  }
84  }
85  }
86  for(int i=0; i<NumberOfRegionType; i+=1){
87  m_PPToSL[i] = 0;
88  }
89  for (int side=0; side < LVL1TGC::kNSide; side++) {
90  m_mapEIFI[side] = 0;
91  }
92 }
93 
95  const SG::ReadCondHandleKey<TGCTriggerData>& readCondKey,
96  const SG::ReadCondHandleKey<TGCTriggerLUTs>& readLUTsCondKey)
97  : AthMessaging("LVL1TGC::TGCDatabaseManager"),
98  m_tgcArgs(tgcargs)
99 {
100  setLevel(tgcArgs()->MSGLEVEL());
101 
102  bool status = true;
103 
104  ATH_MSG_DEBUG("Read database for connection from ASD to PP.");
105 
106  for(int i=0; i<TGCSector::NumberOfPatchPanelType; i+=1){
107  for(int k=0; k<TotalNumForwardBackwardType; k+=1){
108  m_ASDToPP[0][i][k] = new TGCConnectionASDToPP;
109  m_ASDToPP[1][i][k] = new TGCConnectionASDToPP;
110  status = status
113  }
114  }
115  for(int i=0; i<NumberOfRegionType; i+=1){
117  }
120 
121  // Temporary solution for Run 3 simulation (to be migrated to CONDDB
122  tgcArgs()->set_USE_CONDDB(false);
123 
124  // CW for SL (ONLY available for Run-3 development phase)
125  std::string ver_BW = "v05";
126  std::string ver_EIFI = "v07";
127  std::string ver_TILE = "v01";
128  std::string ver_NSW = "v01";
129  std::string ver_BIS78 = "v01"; // OK?
130  std::string ver_HotRoI = "v2";
131 
132  // EIFI Coincidence Map
133  ATH_MSG_DEBUG("start to create EIFI coincidence map.");
134  for (int side=0; side < LVL1TGC::kNSide; side++) {
135  m_mapEIFI[side] = new LVL1TGC::TGCEIFICoincidenceMap(tgcArgs(), readCondKey, ver_EIFI, side);
136  }
137 
138  // Big Wheel Coincidence LUT
139  m_bigWheelLUT.reset(new LVL1TGC::BigWheelCoincidenceLUT(tgcArgs(), readLUTsCondKey, ver_BW));
140 
141  // Tile-Muon LUT
142  m_tileMuLUT.reset(new LVL1TGC::TGCTileMuCoincidenceLUT(tgcArgs(), readCondKey, ver_TILE));
143 
144  // NSW coincidence Map
145  if(tgcArgs()->USE_NSW()){
146  for (int side=0; side < LVL1TGC::kNSide; side++) {
147  for (int oct=0; oct<NumberOfOctant; oct++) {
148  for(int mod=0; mod<NumberOfModuleInBW; mod++){
149  // NSW Coincidence Map
150  m_mapNSW[side][oct][mod].reset(new TGCNSWCoincidenceMap(tgcArgs(),ver_NSW,side,oct,mod));
151  }
152  }
153  }
154  }
155 
156  // BIS78 coincidence Map
157  if(tgcArgs()->USE_BIS78()){
158  m_mapBIS78.reset(new LVL1TGC::TGCBIS78CoincidenceMap(tgcArgs(),ver_BIS78));
159  }
160 
161  //Hot RoI LUT
162  m_mapGoodMF.reset(new LVL1TGC::TGCGoodMF(tgcArgs(),ver_HotRoI));
163 }
164 
166 {
167  for(int i=0; i<NumberOfRegionType; i+=1){
168  delete m_PPToSL[i];
169  m_PPToSL[i]=0;
170  }
171 }
172 
174 {
175  int i,j,k;
176  for( j=0; j<NumberOfRegionType; j+=1){
177  for( i=0; i<TGCSector::NumberOfPatchPanelType; i+=1){
178  for( k=0; k<TotalNumForwardBackwardType; k+=1){
179  if(m_ASDToPP[j][i][k]!=0) delete m_ASDToPP[j][i][k];
180  m_ASDToPP[j][i][k]=0;
181  }
182  }
183  if(m_PPToSL[j]!=0) delete m_PPToSL[j];
184  m_PPToSL[j]=0;
185  }
186 
187  for (int side=0; side < LVL1TGC::kNSide; side++) {
188  delete m_mapEIFI[side];
189  }
190 }
191 
193  : AthMessaging("LVL1TGC::TGCDatabaseManager")
194 {
195  for(int j=0; j<NumberOfRegionType; j+=1){
196  for(int i=0; i<TGCSector::NumberOfPatchPanelType; i+=1){
197  for(int k=0; k<TotalNumForwardBackwardType; k+=1){
198  m_ASDToPP[j][i][k] = 0;
199  }
200  }
201  }
202  for( int i=0; i<NumberOfRegionType; i+=1) m_PPToSL[i] = 0;
203  for (int side=0; side < LVL1TGC::kNSide; side++) {
204  m_mapEIFI[side] = 0;
205  }
206 
207  *this = right;
208 }
209 
212 {
213  if(this!=&right){
214  m_tgcArgs = right.m_tgcArgs;
215  for( int j=0; j<NumberOfRegionType; j+=1){
216  for( int i=0; i<TGCSector::NumberOfPatchPanelType; i+=1){
217  for( int k=0; k<TotalNumForwardBackwardType; k+=1){
218  if(m_ASDToPP[j][i][k]!=0) delete m_ASDToPP[j][i][k];
219  m_ASDToPP[j][i][k] = new TGCConnectionASDToPP;
220  *m_ASDToPP[j][i][k] = *right.m_ASDToPP[j][i][k];
221  }
222  }
223  }
224  for(int i=0; i<NumberOfRegionType; i+=1){
225  if(m_PPToSL[i]!=0) delete m_PPToSL[i];
226  m_PPToSL[i] = new TGCConnectionPPToSL( *right.m_PPToSL[i] );
227  }
228 
229  for (int side=0; side<LVL1TGC::kNSide; side++) {
230  if (m_mapEIFI[side]!=0) delete m_mapEIFI[side];
232  }
233 
235  }
236  return *this;
237 }
238 
240 {
241  switch (type) {
242  case 0: //ASD2PP
243  return "MuonTGC_Cabling_ASD2PP.db";
244  case 1: //PP
245  return "MuonTGC_Cabling_PP.db";
246  case 2: //PP2SL
247  return "MuonTGC_Cabling_PP2SL.db";
248  }
249  return "";
250 }
251 
252 const std::vector<std::string> TGCDatabaseManager::splitCW(const std::string& input, char delimiter)
253 {
254  std::istringstream stream(input);
255 
256  std::string field;
257  std::vector<std::string> result;
258  while (std::getline(stream, field, delimiter)) {
259  result.push_back(field);
260  }
261  return result;
262 }
263 
264 } //end of namespace bracket
LVL1TGCTrigger::TGCRegionType::ENDCAP
@ ENDCAP
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
LVL1TGCTrigger::TGCDatabaseManager::NumberOfModuleInBW
@ NumberOfModuleInBW
Definition: TGCDatabaseManager.h:74
LVL1TGCTrigger::TGCDatabaseManager::operator=
TGCDatabaseManager & operator=(const TGCDatabaseManager &right)
Definition: TGCDatabaseManager.cxx:211
LVL1TGCTrigger::TGCPatchPanel::getId
int getId() const
Definition: TGCPatchPanel.cxx:399
get_generator_info.result
result
Definition: get_generator_info.py:21
LVL1TGCTrigger::TGCArguments::set_USE_CONDDB
void set_USE_CONDDB(bool v)
Definition: TGCArguments.cxx:33
TGCNSWCoincidenceMap.h
AthMsgStreamMacros.h
LVL1TGCTrigger::TGCDatabaseManager::m_tileMuLUT
std::shared_ptr< LVL1TGC::TGCTileMuCoincidenceLUT > m_tileMuLUT
Definition: TGCDatabaseManager.h:78
LVL1TGCTrigger::NumberOfRegionType
const int NumberOfRegionType
Definition: TGCNumbering.h:55
TGCBIS78CoincidenceMap.h
LVL1TGCTrigger::TGCDatabaseManager::splitCW
static const std::vector< std::string > splitCW(const std::string &input, char delimiter)
Definition: TGCDatabaseManager.cxx:252
LVL1TGCTrigger::TGCPatchPanel::getAdjacentPP
TGCPatchPanel * getAdjacentPP(int side)
Definition: TGCPatchPanel.h:49
LVL1TGCTrigger::TGCNSWCoincidenceMap
Definition: TGCNSWCoincidenceMap.h:26
BigWheelCoincidenceLUT.h
LVL1TGC::TGCTileMuCoincidenceLUT
This class stores the LUT for Tile-Muon coincidence of the Run-3 L1Muon Endcap trigger.
Definition: TGCTileMuCoincidenceLUT.h:62
LVL1TGCTrigger::TGCDatabaseManager::m_bigWheelLUT
std::shared_ptr< LVL1TGC::BigWheelCoincidenceLUT > m_bigWheelLUT
Definition: TGCDatabaseManager.h:76
LVL1TGCTrigger::TGCDatabaseManager::PatchPanelIDs
std::vector< int > PatchPanelIDs
Definition: TGCDatabaseManager.h:40
LVL1TGCTrigger::TGCRegionType::FORWARD
@ FORWARD
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
LVL1TGCTrigger::TGCConnectionInPP
Definition: TGCConnectionInPP.h:15
LVL1TGCTrigger::TGCDatabaseManager::m_mapNSW
std::array< std::array< std::array< std::shared_ptr< TGCNSWCoincidenceMap >, NumberOfModuleInBW >, NumberOfOctant >, LVL1TGC::kNSide > m_mapNSW
Definition: TGCDatabaseManager.h:79
LVL1TGCTrigger::TGCDatabaseManager::m_tgcArgs
TGCArguments * m_tgcArgs
Definition: TGCDatabaseManager.h:87
TGCDatabaseManager.h
LVL1TGC::TGCEIFICoincidenceMap
Definition: TGCEIFICoincidenceMap.h:23
LVL1TGCTrigger::TGCForwardBackwardType
TGCForwardBackwardType
Definition: TGCNumbering.h:59
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
LVL1TGCTrigger::TotalNumForwardBackwardType
@ TotalNumForwardBackwardType
Definition: TGCNumbering.h:59
LVL1TGCTrigger::TGCConnectionPPToSL
Definition: TGCConnectionPPToSL.h:16
LVL1TGCTrigger::TGCDatabaseManager::~TGCDatabaseManager
virtual ~TGCDatabaseManager()
Definition: TGCDatabaseManager.cxx:173
TRT::Hit::side
@ side
Definition: HitInfo.h:83
TGCEIFICoincidenceMap.h
LVL1TGCTrigger::TGCConnectionASDToPP::readData
bool readData(TGCRegionType region, int type, TGCForwardBackwardType forward)
Definition: TGCConnectionASDToPP.cxx:52
LVL1TGCTrigger::TGCDatabaseManager::m_patchPanelToConnectionInPP
std::map< PatchPanelIDs, std::pair< const TGCConnectionInPP, PatchPanelPointers > > m_patchPanelToConnectionInPP
Definition: TGCDatabaseManager.h:85
AthMessaging::setLevel
void setLevel(MSG::Level lvl)
Change the current logging level.
Definition: AthMessaging.cxx:28
LVL1TGCTrigger::NumberOfOctant
const int NumberOfOctant
Definition: TGCElectronicsSystem.h:19
LVL1TGCTrigger::TGCDatabaseManager::getFilename
static std::string getFilename(int type)
Definition: TGCDatabaseManager.cxx:239
python.AthDsoLogger.delimiter
delimiter
Definition: AthDsoLogger.py:71
LVL1TGC::TGCBIS78CoincidenceMap
Definition: TGCBIS78CoincidenceMap.h:24
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
LVL1TGCTrigger::TGCConnectionInPP::replacePatchPanelPointers
bool replacePatchPanelPointers(TGCPatchPanel *newPatchPanel, const std::vector< const TGCPatchPanel * > &oldPatchPanels)
Definition: TGCConnectionInPP.cxx:354
LVL1TGCTrigger::TGCDatabaseManager::m_PPToSL
TGCConnectionPPToSL * m_PPToSL[NumberOfRegionType]
Definition: TGCDatabaseManager.h:81
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
LVL1TGCTrigger::TGCDatabaseManager::getConnectionInPP
TGCConnectionInPP * getConnectionInPP(TGCPatchPanel *patchPanel) const
Definition: TGCDatabaseManager.cxx:22
LVL1TGCTrigger::TGCDatabaseManager::tgcArgs
TGCArguments * tgcArgs()
Definition: TGCDatabaseManager.h:70
LVL1TGCTrigger
Definition: LVL1TGCTrigger.cxx:47
LVL1TGCTrigger::TGCDatabaseManager::m_mapBIS78
std::shared_ptr< LVL1TGC::TGCBIS78CoincidenceMap > m_mapBIS78
Definition: TGCDatabaseManager.h:80
LVL1TGCTrigger::TGCDatabaseManager
Definition: TGCDatabaseManager.h:39
LVL1TGCTrigger::TGCDatabaseManager::deleteConnectionPPToSL
void deleteConnectionPPToSL()
Definition: TGCDatabaseManager.cxx:165
LVL1TGCTrigger::TGCDatabaseManager::TGCDatabaseManager
TGCDatabaseManager()
Definition: TGCDatabaseManager.cxx:75
LVL1TGCTrigger::TGCPatchPanel::getType
int getType() const
Definition: TGCPatchPanel.h:64
TGCConnectionInPP.h
LVL1TGC::TGCGoodMF
Definition: TGCGoodMF.h:20
TGCGoodMF.h
LVL1TGCTrigger::TGCPatchPanel
Definition: TGCPatchPanel.h:38
LVL1TGCTrigger::TGCArguments
Definition: TGCArguments.h:12
SG::ReadCondHandleKey< TGCTriggerData >
LVL1TGCTrigger::TGCDatabaseManager::m_mapGoodMF
std::shared_ptr< LVL1TGC::TGCGoodMF > m_mapGoodMF
Definition: TGCDatabaseManager.h:83
TGCConnectionASDToPP.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TGCConnectionPPToSL.h
LVL1TGCTrigger::TGCDatabaseManager::m_ASDToPP
TGCConnectionASDToPP * m_ASDToPP[NumberOfRegionType][TGCSector::NumberOfPatchPanelType][TotalNumForwardBackwardType]
Definition: TGCDatabaseManager.h:82
LVL1TGC::kNSide
@ kNSide
Definition: TGCNumbering.h:16
TGCTileMuCoincidenceLUT.h
merge.status
status
Definition: merge.py:17
TGCArguments.h
LVL1TGCTrigger::TGCPatchPanel::getRegion
TGCRegionType getRegion() const
Definition: TGCPatchPanel.h:66
LVL1TGCTrigger::TGCDatabaseManager::PatchPanelPointers
std::vector< const TGCPatchPanel * > PatchPanelPointers
Definition: TGCDatabaseManager.h:41
LVL1TGCTrigger::TGCConnectionPPToSL::readData
bool readData(TGCRegionType type)
Definition: TGCConnectionPPToSL.cxx:40
LVL1TGCTrigger::TGCDatabaseManager::m_mapEIFI
LVL1TGC::TGCEIFICoincidenceMap * m_mapEIFI[LVL1TGC::kNSide]
Definition: TGCDatabaseManager.h:77
LVL1TGC::BigWheelCoincidenceLUT
Definition: BigWheelCoincidenceLUT.h:35
LVL1TGCTrigger::TGCConnectionASDToPP
Definition: TGCConnectionASDToPP.h:13
TGCPatchPanel.h
LVL1TGCTrigger::TGCDatabaseManager::addConnectionInPP
void addConnectionInPP(const TGCPatchPanel *patchPanel, const TGCConnectionInPP *connectionInPP)
Definition: TGCDatabaseManager.cxx:51
fitman.k
k
Definition: fitman.py:528
LVL1TGCTrigger::TGCSector::NumberOfPatchPanelType
@ NumberOfPatchPanelType
Definition: TGCSector.h:37