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,
17  int aPhiMin, int aPhiMax,
18  unsigned int aRegion,
19  unsigned int aRefLayer):
20  iInput(aInput),
21  iRegion(aRegion),
22  iRefLayer(aRefLayer),
23  range(std::pair<int,int>(aPhiMin,aPhiMax)){}
26 bool RefHitDef::fitsRange(int iPhi) const{
27 
28  return iPhi>=range.first &&
29  iPhi<=range.second;
30 
31 }
34 std::ostream & operator << (std::ostream &out, const RefHitDef & aRefHitDef){
35 
36 
37  out<<"iRefLayer: "<<aRefHitDef.iRefLayer
38  <<" iInput: "<<aRefHitDef.iInput
39  <<" iRegion: "<<aRefHitDef.iRegion
40  <<" range: ("<<aRefHitDef.range.first
41  <<", "<<aRefHitDef.range.second<<std::endl;
42 
43  return out;
44 }
48 
50  std::vector<int> aLayer1D(nInputs(),0);
51 
53  vector2D aLayer2D;
54  aLayer2D.assign(nLayers(),aLayer1D);
55 
57  vector3D aLayer3D;
58  aLayer3D.assign(nLogicRegions(),aLayer2D);
59 
61  measurements4D.assign(nProcessors(),aLayer3D);
62  measurements4Dref.assign(nProcessors(),aLayer3D);
63 }
67 
68 
69  rawParams = *omtfParams;
70 
72  barrelMin.resize(nProcessors());
73  endcap10DegMin.resize(nProcessors());
74  endcap20DegMin.resize(nProcessors());
75 
76  barrelMax.resize(nProcessors());
77  endcap10DegMax.resize(nProcessors());
78  endcap20DegMax.resize(nProcessors());
79 
80  const std::vector<int> *connectedSectorsStartVec = omtfParams->connectedSectorsStart();
81  const std::vector<int> *connectedSectorsEndVec = omtfParams->connectedSectorsEnd();
82 
83  std::copy(connectedSectorsStartVec->begin(), connectedSectorsStartVec->begin()+6, barrelMin.begin());
84  std::copy(connectedSectorsStartVec->begin()+6, connectedSectorsStartVec->begin()+12, endcap10DegMin.begin());
85  std::copy(connectedSectorsStartVec->begin()+12, connectedSectorsStartVec->end(), endcap20DegMin.begin());
86 
87  std::copy(connectedSectorsEndVec->begin(), connectedSectorsEndVec->begin()+6, barrelMax.begin());
88  std::copy(connectedSectorsEndVec->begin()+6, connectedSectorsEndVec->begin()+12, endcap10DegMax.begin());
89  std::copy(connectedSectorsEndVec->begin()+12, connectedSectorsEndVec->end(), endcap20DegMax.begin());
90 
92  const std::vector<L1TMuonOverlapParams::LayerMapNode> *layerMap = omtfParams->layerMap();
93 
94  for(unsigned int iLayer=0;iLayer<nLayers();++iLayer){
95  L1TMuonOverlapParams::LayerMapNode aNode = layerMap->at(iLayer);
96  hwToLogicLayer[aNode.hwNumber] = aNode.logicNumber;
97  logicToHwLayer[aNode.logicNumber] = aNode.hwNumber;
98  logicToLogic[aNode.logicNumber] = aNode.connectedToLayer;
99  if(aNode.bendingLayer) bendingLayers.insert(aNode.logicNumber);
100  }
102  refToLogicNumber.resize(nRefLayers());
103 
104  const std::vector<L1TMuonOverlapParams::RefLayerMapNode> *refLayerMap = omtfParams->refLayerMap();
105  for(unsigned int iRefLayer=0;iRefLayer<nRefLayers();++iRefLayer){
106  L1TMuonOverlapParams::RefLayerMapNode aNode = refLayerMap->at(iRefLayer);
107  refToLogicNumber[aNode.refLayer] = aNode.logicNumber;
108  }
110  std::vector<int> vector1D(nRefLayers(),nPhiBins());
111  processorPhiVsRefLayer.assign(nProcessors(),vector1D);
112 
115  vector1D_pair aLayer1D(nLayers());
117  vector2D_pair aLayer2D;
118  aLayer2D.assign(nLogicRegions(),aLayer1D);
120  connections.assign(nProcessors(),aLayer2D);
121 
124  std::vector<std::pair<int,int> > aRefHit1D(nLogicRegions(),std::pair<int,int>(9999,9999));
126  std::vector<std::vector<std::pair<int,int> > > aRefHit2D;
127  aRefHit2D.assign(nRefLayers(),aRefHit1D);
129  regionPhisVsRefLayerVsInput.assign(nInputs(),aRefHit2D);
130 
131  //Vector of ref hit definitions
132  std::vector<RefHitDef> aRefHitsDefs(nRefHits());
134  refHitsDefs.assign(nProcessors(),aRefHitsDefs);
135 
136  const std::vector<int> *phiStartMap = omtfParams->globalPhiStartMap();
137  const std::vector<L1TMuonOverlapParams::RefHitNode> *refHitMap = omtfParams->refHitMap();
138  const std::vector<L1TMuonOverlapParams::LayerInputNode> *layerInputMap = omtfParams->layerInputMap();
139  unsigned int tmpIndex = 0;
140  for(unsigned int iProcessor=0;iProcessor<nProcessors();++iProcessor){
141  for(unsigned int iRefLayer=0;iRefLayer<nRefLayers();++iRefLayer){
142  int iPhiStart = phiStartMap->at(iRefLayer+iProcessor*nRefLayers());
143  processorPhiVsRefLayer[iProcessor][iRefLayer] = iPhiStart;
144  }
145  for(unsigned int iRefHit=0;iRefHit<nRefHits();++iRefHit){
146  int iPhiMin = refHitMap->at(iRefHit+iProcessor*nRefHits()).iPhiMin;
147  int iPhiMax = refHitMap->at(iRefHit+iProcessor*nRefHits()).iPhiMax;
148  unsigned int iInput = refHitMap->at(iRefHit+iProcessor*nRefHits()).iInput;
149  unsigned int iRegion = refHitMap->at(iRefHit+iProcessor*nRefHits()).iRegion;
150  unsigned int iRefLayer = refHitMap->at(iRefHit+iProcessor*nRefHits()).iRefLayer;
151  regionPhisVsRefLayerVsInput[iInput][iRefLayer][iRegion] = std::pair<int,int>(iPhiMin,iPhiMax);
152  refHitsDefs[iProcessor][iRefHit] = RefHitDef(iInput,iPhiMin,iPhiMax,iRegion,iRefLayer);
153  }
154  for(unsigned int iLogicRegion=0;iLogicRegion<nLogicRegions();++iLogicRegion){
155  for(unsigned int iLayer=0;iLayer<nLayers();++iLayer){
156  tmpIndex = iLayer+iLogicRegion*nLayers() + iProcessor*nLogicRegions()*nLayers();
157  unsigned int iFirstInput = layerInputMap->at(tmpIndex).iFirstInput;
158  unsigned int nInputsInRegion = layerInputMap->at(tmpIndex).nInputs;
159  connections[iProcessor][iLogicRegion][iLayer] = std::pair<unsigned int, unsigned int>(iFirstInput,nInputsInRegion);
161  if(iProcessor!=0) connections[iProcessor][iLogicRegion][iLayer] = connections[0][iLogicRegion][iLayer];
162  }
163  }
164  }
165 
166  initCounterMatrices();
167 
168 }
171 std::ostream & operator << (std::ostream &out, const OMTFConfiguration & aConfig){
172 
173 
174  out<<"nLayers(): "<<aConfig.nLayers()
175  <<" nHitsPerLayer(): "<<aConfig.nHitsPerLayer()
176  <<" nRefLayers(): "<<aConfig.nRefLayers()
177  <<" nPdfAddrBits: "<<aConfig.nPdfAddrBits()
178  <<" nPdfValBits: "<<aConfig.nPdfValBits()
179  <<std::endl;
180 
181  for(unsigned int iProcessor = 0;iProcessor<aConfig.nProcessors(); ++iProcessor){
182  out<<"Processor: "<<iProcessor;
183  for(unsigned int iRefLayer=0;iRefLayer<aConfig.nRefLayers();++iRefLayer){
184  out<<" "<<aConfig.processorPhiVsRefLayer[iProcessor][iRefLayer];
185  }
186  out<<std::endl;
187  }
188 
189  return out;
190 
191 }
195  unsigned int coneSize,
196  int iPhi) const {
197 
198  if(iPhi<0) iPhi+=nPhiBins();
199  if(iPhiStart<0) iPhiStart+=nPhiBins();
200 
201  if(iPhiStart+(int)coneSize<(int)nPhiBins()){
202  return iPhiStart<=iPhi && iPhiStart+(int)coneSize>iPhi;
203  }
204  else if(iPhi>(int)nPhiBins()/2){
205  return iPhiStart<=iPhi;
206  }
207  else if(iPhi<(int)nPhiBins()/2){
208  return iPhi<iPhiStart+(int)coneSize-(int)nPhiBins();
209  }
210  return false;
211 }
215  unsigned int iRefLayer,
216  int iPhi) const {
217 
218  for(unsigned int iRegion=0;iRegion<nLogicRegions();++iRegion){
219  if(iPhi>=regionPhisVsRefLayerVsInput[iInput][iRefLayer][iRegion].first &&
220  iPhi<=regionPhisVsRefLayerVsInput[iInput][iRefLayer][iRegion].second)
221  return iRegion;
222  }
223 
224  return 99;
225 }
228 int OMTFConfiguration::globalPhiStart(unsigned int iProcessor) const {
229 
230  return *std::min_element(processorPhiVsRefLayer[iProcessor].begin(),
231  processorPhiVsRefLayer[iProcessor].end());
232 
233 }
236 uint32_t OMTFConfiguration::getLayerNumber(uint32_t rawId) const {
237 
238  uint32_t aLayer = 0;
239 
240  DetId detId(rawId);
241  if (detId.det() != DetId::Muon){
242  std::cout << "PROBLEM: hit in unknown Det, detID: "<<detId.det()<<std::endl;
243  return rawId;
244  }
245 
246  switch (detId.subdetId()) {
247  case MuonSubdetId::RPC: {
248  RPCDetId aId(rawId);
249  bool isBarrel = (aId.region()==0);
250  if(isBarrel) aLayer = aId.station() <=2 ?
251  2*( aId.station()-1)+ aId.layer()
252  : aId.station()+2;
253  else aLayer = aId.station();
254  aLayer+= 10*(!isBarrel);
255  break;
256  }
257  case MuonSubdetId::DT: {
258  DTChamberId dt(rawId);
259  aLayer = dt.station();
260  break;
261  }
262  case MuonSubdetId::CSC: {
263  CSCDetId csc(rawId);
264  aLayer = csc.station();
265  if(csc.ring()==2 && csc.station()==1) aLayer = 1811;//1811 = 2011 - 200, as we want to get 2011 for this chamber.
266  if(csc.station()==4) aLayer = 4;
267  break;
268  }
269  }
270 
271  int hwNumber = aLayer+100*detId.subdetId();
272 
273  return hwNumber;
274 }
bool fitsRange(int iPhi) const
std::vector< vector1D_pair > vector2D_pair
float dt
Definition: AMPTWrapper.h:126
const std::vector< LayerMapNode > * layerMap() const
std::vector< std::pair< unsigned int, unsigned int > > vector1D_pair
unsigned int nRefLayers() const
def copy(args, dbName)
unsigned int hwNumber
short layer number used within OMTF emulator
const std::vector< int > * connectedSectorsEnd() const
bool isInRegionRange(int iPhiStart, unsigned int coneSize, int iPhi) const
unsigned int nLayers() const
unsigned int logicNumber
logic numer of the layer
unsigned int nProcessors() const
std::vector< std::vector< int > > processorPhiVsRefLayer
unsigned int iInput
Hit input number within a cone.
std::vector< vector2D > vector3D
U second(std::pair< T, U > const &p)
const std::vector< LayerInputNode > * layerInputMap() const
static const int CSC
Definition: MuonSubdetId.h:13
unsigned int getRegionNumberFromMap(unsigned int iInput, unsigned int iRefLayer, int iPhi) const
unsigned int nPdfAddrBits() const
std::vector< vector1D > vector2D
unsigned int nHitsPerLayer() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
std::vector< int > vector1D
RefHitDef(unsigned int aInput=15, int aPhiMin=5760, int aPhiMax=5760, unsigned int aRegion=99, unsigned int aRefLayer=99)
#define end
Definition: vmac.h:39
bool bendingLayer
Is this a bending layers?
void configure(const L1TMuonOverlapParams *omtfParams)
int ring() const
Definition: CSCDetId.h:75
int layer() const
Definition: RPCDetId.h:108
Definition: DetId.h:18
uint32_t getLayerNumber(uint32_t rawId) const
unsigned int refLayer
Reference layer number.
const std::vector< int > * globalPhiStartMap() const
std::pair< int, int > range
int globalPhiStart(unsigned int iProcessor) const
#define begin
Definition: vmac.h:32
static const int RPC
Definition: MuonSubdetId.h:14
unsigned int iRefLayer
Reference layer logic number (0-7)
unsigned int logicNumber
Corresponding logical layer number.
int station() const
Definition: CSCDetId.h:86
static const int DT
Definition: MuonSubdetId.h:12
unsigned int iRegion
Region number assigned to this referecne hit.
const std::vector< RefLayerMapNode > * refLayerMap() const
int station() const
Return the station number.
Definition: DTChamberId.h:51
unsigned int nPdfValBits() const
friend std::ostream & operator<<(std::ostream &out, const RefHitDef &aRefHitDef)
const std::vector< int > * connectedSectorsStart() const
const std::vector< RefHitNode > * refHitMap() const
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96