CMS 3D CMS Logo

OMTFConfiguration.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 
6 
11 
13 
16 RefHitDef::RefHitDef(unsigned int aInput, int aPhiMin, int aPhiMax, unsigned int aRegion, unsigned int aRefLayer)
17  : iInput(aInput), iRegion(aRegion), iRefLayer(aRefLayer), range(std::pair<int, int>(aPhiMin, aPhiMax)) {}
20 bool RefHitDef::fitsRange(int iPhi) const { return iPhi >= range.first && iPhi <= range.second; }
23 std::ostream &operator<<(std::ostream &out, const RefHitDef &aRefHitDef) {
24  out << "iRefLayer: " << aRefHitDef.iRefLayer << " iInput: " << aRefHitDef.iInput << " iRegion: " << aRefHitDef.iRegion
25  << " range: (" << aRefHitDef.range.first << ", " << aRefHitDef.range.second << std::endl;
26 
27  return out;
28 }
33  std::vector<int> aLayer1D(nInputs(), 0);
34 
36  vector2D aLayer2D;
37  aLayer2D.assign(nLayers(), aLayer1D);
38 
40  vector3D aLayer3D;
41  aLayer3D.assign(nLogicRegions(), aLayer2D);
42 
44  measurements4D.assign(nProcessors(), aLayer3D);
45  measurements4Dref.assign(nProcessors(), aLayer3D);
46 }
51 
53  barrelMin.resize(nProcessors());
54  endcap10DegMin.resize(nProcessors());
55  endcap20DegMin.resize(nProcessors());
56 
57  barrelMax.resize(nProcessors());
58  endcap10DegMax.resize(nProcessors());
59  endcap20DegMax.resize(nProcessors());
60 
61  const std::vector<int> *connectedSectorsStartVec = omtfParams->connectedSectorsStart();
62  const std::vector<int> *connectedSectorsEndVec = omtfParams->connectedSectorsEnd();
63 
64  std::copy(connectedSectorsStartVec->begin(), connectedSectorsStartVec->begin() + 6, barrelMin.begin());
65  std::copy(connectedSectorsStartVec->begin() + 6, connectedSectorsStartVec->begin() + 12, endcap10DegMin.begin());
66  std::copy(connectedSectorsStartVec->begin() + 12, connectedSectorsStartVec->end(), endcap20DegMin.begin());
67 
68  std::copy(connectedSectorsEndVec->begin(), connectedSectorsEndVec->begin() + 6, barrelMax.begin());
69  std::copy(connectedSectorsEndVec->begin() + 6, connectedSectorsEndVec->begin() + 12, endcap10DegMax.begin());
70  std::copy(connectedSectorsEndVec->begin() + 12, connectedSectorsEndVec->end(), endcap20DegMax.begin());
71 
73  const std::vector<L1TMuonOverlapParams::LayerMapNode> *layerMap = omtfParams->layerMap();
74 
75  for (unsigned int iLayer = 0; iLayer < nLayers(); ++iLayer) {
76  L1TMuonOverlapParams::LayerMapNode aNode = layerMap->at(iLayer);
77  hwToLogicLayer[aNode.hwNumber] = aNode.logicNumber;
78  logicToHwLayer[aNode.logicNumber] = aNode.hwNumber;
80  if (aNode.bendingLayer)
81  bendingLayers.insert(aNode.logicNumber);
82  }
84  refToLogicNumber.resize(nRefLayers());
85 
86  const std::vector<L1TMuonOverlapParams::RefLayerMapNode> *refLayerMap = omtfParams->refLayerMap();
87  for (unsigned int iRefLayer = 0; iRefLayer < nRefLayers(); ++iRefLayer) {
88  L1TMuonOverlapParams::RefLayerMapNode aNode = refLayerMap->at(iRefLayer);
89  refToLogicNumber[aNode.refLayer] = aNode.logicNumber;
90  }
92  std::vector<int> vector1D(nRefLayers(), nPhiBins());
94 
97  vector1D_pair aLayer1D(nLayers());
99  vector2D_pair aLayer2D;
100  aLayer2D.assign(nLogicRegions(), aLayer1D);
102  connections.assign(nProcessors(), aLayer2D);
103 
106  std::vector<std::pair<int, int> > aRefHit1D(nLogicRegions(), std::pair<int, int>(9999, 9999));
108  std::vector<std::vector<std::pair<int, int> > > aRefHit2D;
109  aRefHit2D.assign(nRefLayers(), aRefHit1D);
111  regionPhisVsRefLayerVsInput.assign(nInputs(), aRefHit2D);
112 
113  //Vector of ref hit definitions
114  std::vector<RefHitDef> aRefHitsDefs(nRefHits());
116  refHitsDefs.assign(nProcessors(), aRefHitsDefs);
117 
118  const std::vector<int> *phiStartMap = omtfParams->globalPhiStartMap();
119  const std::vector<L1TMuonOverlapParams::RefHitNode> *refHitMap = omtfParams->refHitMap();
120  const std::vector<L1TMuonOverlapParams::LayerInputNode> *layerInputMap = omtfParams->layerInputMap();
121  unsigned int tmpIndex = 0;
122  for (unsigned int iProcessor = 0; iProcessor < nProcessors(); ++iProcessor) {
123  for (unsigned int iRefLayer = 0; iRefLayer < nRefLayers(); ++iRefLayer) {
124  int iPhiStart = phiStartMap->at(iRefLayer + iProcessor * nRefLayers());
125  processorPhiVsRefLayer[iProcessor][iRefLayer] = iPhiStart;
126  }
127  for (unsigned int iRefHit = 0; iRefHit < nRefHits(); ++iRefHit) {
128  int iPhiMin = refHitMap->at(iRefHit + iProcessor * nRefHits()).iPhiMin;
129  int iPhiMax = refHitMap->at(iRefHit + iProcessor * nRefHits()).iPhiMax;
130  unsigned int iInput = refHitMap->at(iRefHit + iProcessor * nRefHits()).iInput;
131  unsigned int iRegion = refHitMap->at(iRefHit + iProcessor * nRefHits()).iRegion;
132  unsigned int iRefLayer = refHitMap->at(iRefHit + iProcessor * nRefHits()).iRefLayer;
133  regionPhisVsRefLayerVsInput[iInput][iRefLayer][iRegion] = std::pair<int, int>(iPhiMin, iPhiMax);
134  refHitsDefs[iProcessor][iRefHit] = RefHitDef(iInput, iPhiMin, iPhiMax, iRegion, iRefLayer);
135  }
136  for (unsigned int iLogicRegion = 0; iLogicRegion < nLogicRegions(); ++iLogicRegion) {
137  for (unsigned int iLayer = 0; iLayer < nLayers(); ++iLayer) {
138  tmpIndex = iLayer + iLogicRegion * nLayers() + iProcessor * nLogicRegions() * nLayers();
139  unsigned int iFirstInput = layerInputMap->at(tmpIndex).iFirstInput;
140  unsigned int nInputsInRegion = layerInputMap->at(tmpIndex).nInputs;
141  connections[iProcessor][iLogicRegion][iLayer] =
142  std::pair<unsigned int, unsigned int>(iFirstInput, nInputsInRegion);
144  if (iProcessor != 0)
145  connections[iProcessor][iLogicRegion][iLayer] = connections[0][iLogicRegion][iLayer];
146  }
147  }
148  }
149 
151 }
154 std::ostream &operator<<(std::ostream &out, const OMTFConfiguration &aConfig) {
155  out << "nLayers(): " << aConfig.nLayers() << " nHitsPerLayer(): " << aConfig.nHitsPerLayer()
156  << " nRefLayers(): " << aConfig.nRefLayers() << " nPdfAddrBits: " << aConfig.nPdfAddrBits()
157  << " nPdfValBits: " << aConfig.nPdfValBits() << std::endl;
158 
159  for (unsigned int iProcessor = 0; iProcessor < aConfig.nProcessors(); ++iProcessor) {
160  out << "Processor: " << iProcessor;
161  for (unsigned int iRefLayer = 0; iRefLayer < aConfig.nRefLayers(); ++iRefLayer) {
162  out << " " << aConfig.processorPhiVsRefLayer[iProcessor][iRefLayer];
163  }
164  out << std::endl;
165  }
166 
167  return out;
168 }
171 bool OMTFConfiguration::isInRegionRange(int iPhiStart, unsigned int coneSize, int iPhi) const {
172  if (iPhi < 0)
173  iPhi += nPhiBins();
174  if (iPhiStart < 0)
175  iPhiStart += nPhiBins();
176 
177  if (iPhiStart + (int)coneSize < (int)nPhiBins()) {
178  return iPhiStart <= iPhi && iPhiStart + (int)coneSize > iPhi;
179  } else if (iPhi > (int)nPhiBins() / 2) {
180  return iPhiStart <= iPhi;
181  } else if (iPhi < (int)nPhiBins() / 2) {
182  return iPhi < iPhiStart + (int)coneSize - (int)nPhiBins();
183  }
184  return false;
185 }
188 unsigned int OMTFConfiguration::getRegionNumberFromMap(unsigned int iInput, unsigned int iRefLayer, int iPhi) const {
189  for (unsigned int iRegion = 0; iRegion < nLogicRegions(); ++iRegion) {
190  if (iPhi >= regionPhisVsRefLayerVsInput[iInput][iRefLayer][iRegion].first &&
191  iPhi <= regionPhisVsRefLayerVsInput[iInput][iRefLayer][iRegion].second)
192  return iRegion;
193  }
194 
195  return 99;
196 }
199 int OMTFConfiguration::globalPhiStart(unsigned int iProcessor) const {
200  return *std::min_element(processorPhiVsRefLayer[iProcessor].begin(), processorPhiVsRefLayer[iProcessor].end());
201 }
204 uint32_t OMTFConfiguration::getLayerNumber(uint32_t rawId) const {
205  uint32_t aLayer = 0;
206 
207  DetId detId(rawId);
208  if (detId.det() != DetId::Muon) {
209  std::cout << "PROBLEM: hit in unknown Det, detID: " << detId.det() << std::endl;
210  return rawId;
211  }
212 
213  switch (detId.subdetId()) {
214  case MuonSubdetId::RPC: {
215  RPCDetId aId(rawId);
216  bool isBarrel = (aId.region() == 0);
217  if (isBarrel)
218  aLayer = aId.station() <= 2 ? 2 * (aId.station() - 1) + aId.layer() : aId.station() + 2;
219  else
220  aLayer = aId.station();
221  aLayer += 10 * (!isBarrel);
222  break;
223  }
224  case MuonSubdetId::DT: {
225  DTChamberId dt(rawId);
226  aLayer = dt.station();
227  break;
228  }
229  case MuonSubdetId::CSC: {
230  CSCDetId csc(rawId);
231  aLayer = csc.station();
232  if (csc.ring() == 2 && csc.station() == 1)
233  aLayer = 1811; //1811 = 2011 - 200, as we want to get 2011 for this chamber.
234  if (csc.station() == 4)
235  aLayer = 4;
236  break;
237  }
238  }
239 
240  int hwNumber = aLayer + 100 * detId.subdetId();
241 
242  return hwNumber;
243 }
RefHitDef::RefHitDef
RefHitDef(unsigned int aInput=15, int aPhiMin=5760, int aPhiMax=5760, unsigned int aRegion=99, unsigned int aRefLayer=99)
Definition: OMTFConfiguration.cc:16
L1TMuonOverlapParams::LayerMapNode::connectedToLayer
unsigned int connectedToLayer
Definition: L1TMuonOverlapParams.h:45
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
fakeOmtfParams_cff.omtfParams
omtfParams
OMTF ESProducer.
Definition: fakeOmtfParams_cff.py:11
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
OMTFConfiguration::getLayerNumber
uint32_t getLayerNumber(uint32_t rawId) const
Definition: OMTFConfiguration.cc:204
RefHitDef
Definition: OMTFConfiguration.h:16
OMTFConfiguration::endcap10DegMin
std::vector< unsigned int > endcap10DegMin
Definition: OMTFConfiguration.h:144
OMTFConfiguration::vector2D_pair
std::vector< vector1D_pair > vector2D_pair
Definition: OMTFConfiguration.h:47
OMTFConfiguration::nPdfValBits
unsigned int nPdfValBits() const
Definition: OMTFConfiguration.h:92
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
RPCDetId
Definition: RPCDetId.h:16
RefHitDef::fitsRange
bool fitsRange(int iPhi) const
Definition: OMTFConfiguration.cc:20
gather_cfg.cout
cout
Definition: gather_cfg.py:144
OMTFConfiguration::vector1D_pair
std::vector< std::pair< unsigned int, unsigned int > > vector1D_pair
Definition: OMTFConfiguration.h:46
OMTFConfiguration::regionPhisVsRefLayerVsInput
std::vector< std::vector< std::vector< std::pair< int, int > > > > regionPhisVsRefLayerVsInput
Definition: OMTFConfiguration.h:161
OMTFConfiguration::nRefHits
unsigned int nRefHits() const
Definition: OMTFConfiguration.h:94
omtf::DataWord64::csc
Definition: OmtfDataWord64.h:16
OMTFConfiguration::refToLogicNumber
std::vector< int > refToLogicNumber
Definition: OMTFConfiguration.h:137
OMTFConfiguration::endcap10DegMax
std::vector< unsigned int > endcap10DegMax
Definition: OMTFConfiguration.h:145
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
OMTFConfiguration
Definition: OMTFConfiguration.h:44
OMTFConfiguration::nPhiBins
unsigned int nPhiBins() const
Definition: OMTFConfiguration.h:93
dqmdumpme.first
first
Definition: dqmdumpme.py:55
RefHitDef::iInput
unsigned int iInput
Hit input number within a cone.
Definition: OMTFConfiguration.h:29
end
#define end
Definition: vmac.h:39
CSCDetId.h
FileInPath.h
OMTFConfiguration::initCounterMatrices
void initCounterMatrices()
Definition: OMTFConfiguration.cc:31
OMTFConfiguration::measurements4D
vector4D measurements4D
4D matrices used during creation of the connections tables.
Definition: OMTFConfiguration.h:174
dt
float dt
Definition: AMPTWrapper.h:136
RefHitDef::range
std::pair< int, int > range
Definition: OMTFConfiguration.h:39
DetId
Definition: DetId.h:17
L1TMuonOverlapParams::RefLayerMapNode
Definition: L1TMuonOverlapParams.h:52
OMTFConfiguration::vector2D
std::vector< vector1D > vector2D
Definition: OMTFConfiguration.h:51
csc
Definition: L1Track.h:19
OMTFConfiguration.h
HLT_2018_cff.coneSize
coneSize
Definition: HLT_2018_cff.py:49353
OMTFConfiguration::nHitsPerLayer
unsigned int nHitsPerLayer() const
Definition: OMTFConfiguration.h:88
OMTFConfiguration::nPdfAddrBits
unsigned int nPdfAddrBits() const
Definition: OMTFConfiguration.h:91
OMTFConfiguration::processorPhiVsRefLayer
std::vector< std::vector< int > > processorPhiVsRefLayer
Definition: OMTFConfiguration.h:153
L1TMuonOverlapParams
Definition: L1TMuonOverlapParams.h:14
OMTFConfiguration::globalPhiStart
int globalPhiStart(unsigned int iProcessor) const
Definition: OMTFConfiguration.cc:199
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
DTChamberId.h
OMTFConfiguration::endcap20DegMin
std::vector< unsigned int > endcap20DegMin
Definition: OMTFConfiguration.h:146
OMTFConfiguration::vector1D
std::vector< int > vector1D
Definition: OMTFConfiguration.h:50
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
RPCDetId.h
OMTFConfiguration::getRegionNumberFromMap
unsigned int getRegionNumberFromMap(unsigned int iInput, unsigned int iRefLayer, int iPhi) const
Definition: OMTFConfiguration.cc:188
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
OMTFConfiguration::measurements4Dref
vector4D measurements4Dref
Definition: OMTFConfiguration.h:175
OMTFConfiguration::configure
void configure(const L1TMuonOverlapParams *omtfParams)
Definition: OMTFConfiguration.cc:49
OMTFConfiguration::nLayers
unsigned int nLayers() const
Definition: OMTFConfiguration.h:87
OMTFConfiguration::connections
vector3D_pair connections
Map of connections.
Definition: OMTFConfiguration.h:171
CSCDetId
Definition: CSCDetId.h:26
createfilelist.int
int
Definition: createfilelist.py:10
RefHitDef::iRefLayer
unsigned int iRefLayer
Reference layer logic number (0-7)
Definition: OMTFConfiguration.h:35
OMTFConfiguration::isInRegionRange
bool isInRegionRange(int iPhiStart, unsigned int coneSize, int iPhi) const
Definition: OMTFConfiguration.cc:171
OMTFConfiguration::refHitsDefs
std::vector< std::vector< RefHitDef > > refHitsDefs
Definition: OMTFConfiguration.h:168
MuonSubdetId.h
OMTFConfiguration::logicToHwLayer
std::map< int, int > logicToHwLayer
Definition: OMTFConfiguration.h:134
OMTFConfiguration::barrelMin
std::vector< unsigned int > barrelMin
Definition: OMTFConfiguration.h:142
OMTFConfiguration::logicToLogic
std::map< int, int > logicToLogic
Definition: OMTFConfiguration.h:135
OMTFConfiguration::nProcessors
unsigned int nProcessors() const
Definition: OMTFConfiguration.h:96
std
Definition: JetResolutionObject.h:76
MuonSubdetId::RPC
static constexpr int RPC
Definition: MuonSubdetId.h:13
OMTFConfiguration::vector3D
std::vector< vector2D > vector3D
Definition: OMTFConfiguration.h:52
OMTFConfiguration::nRefLayers
unsigned int nRefLayers() const
Definition: OMTFConfiguration.h:89
OMTFConfiguration::hwToLogicLayer
std::map< int, int > hwToLogicLayer
Definition: OMTFConfiguration.h:133
L1TMuonOverlapParams::LayerMapNode::hwNumber
unsigned int hwNumber
short layer number used within OMTF emulator
Definition: L1TMuonOverlapParams.h:35
OMTFConfiguration::rawParams
L1TMuonOverlapParams rawParams
Definition: OMTFConfiguration.h:131
L1TMuonOverlapParams::RefLayerMapNode::refLayer
unsigned int refLayer
Reference layer number.
Definition: L1TMuonOverlapParams.h:55
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
DetId::Muon
Definition: DetId.h:26
DTChamberId
Definition: DTChamberId.h:14
L1TMuonOverlapParams::LayerMapNode::logicNumber
unsigned int logicNumber
logic numer of the layer
Definition: L1TMuonOverlapParams.h:38
L1TMuonOverlapParams::LayerMapNode
Definition: L1TMuonOverlapParams.h:32
OMTFConfiguration::bendingLayers
std::set< int > bendingLayers
Definition: OMTFConfiguration.h:136
ParameterSet.h
OMTFConfiguration::nLogicRegions
unsigned int nLogicRegions() const
Definition: OMTFConfiguration.h:97
OMTFConfiguration::nInputs
unsigned int nInputs() const
Definition: OMTFConfiguration.h:98
RPCDetId::layer
int layer() const
Definition: RPCDetId.h:85
OMTFConfiguration::barrelMax
std::vector< unsigned int > barrelMax
Definition: OMTFConfiguration.h:143
L1TMuonOverlapParams::LayerMapNode::bendingLayer
bool bendingLayer
Is this a bending layers?
Definition: L1TMuonOverlapParams.h:41
RefHitDef::iRegion
unsigned int iRegion
Region number assigned to this referecne hit.
Definition: OMTFConfiguration.h:32
begin
#define begin
Definition: vmac.h:32
OMTFConfiguration::endcap20DegMax
std::vector< unsigned int > endcap20DegMax
Definition: OMTFConfiguration.h:147
L1TMuonOverlapParams::RefLayerMapNode::logicNumber
unsigned int logicNumber
Corresponding logical layer number.
Definition: L1TMuonOverlapParams.h:58
operator<<
std::ostream & operator<<(std::ostream &out, const RefHitDef &aRefHitDef)
Definition: OMTFConfiguration.cc:23