CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OMTFinputMaker.cc
Go to the documentation of this file.
1 #include <cmath>
2 #include <vector>
3 #include <iostream>
4 #include <algorithm>
5 
10 
15 
18 
25 {
27 }
33 bool OMTFinputMaker::acceptDigi(uint32_t rawId,
34  unsigned int iProcessor,
36 
37  unsigned int aMin = OMTFConfiguration::instance()->barrelMin[iProcessor];
38  unsigned int aMax = OMTFConfiguration::instance()->barrelMax[iProcessor];
39  unsigned int aSector = 99;
40 
42  DetId detId(rawId);
43  if (detId.det() != DetId::Muon)
44  edm::LogError("Critical OMTFinputMaker") << "PROBLEM: hit in unknown Det, detID: "<<detId.det()<<std::endl;
45  switch (detId.subdetId()) {
46  case MuonSubdetId::RPC: {
47  RPCDetId aId(rawId);
48 
50  if(type==l1t::tftype::omtf_pos &&
51  (aId.region()<0 ||
52  (aId.region()==0 && aId.ring()!=2) ||
53  (aId.region()==0 && aId.station()==4) ||
54  (aId.region()==0 && aId.station()==2 && aId.layer()==2 && aId.roll()==1) ||
55  (aId.region()==0 && aId.station()==3 && aId.roll()==1) ||
56  (aId.region()==1 && aId.station()==4) ||
58  (aId.region()==1 && aId.station()>0 && aId.ring()<3))
59  ) return false;
60 
61  if(type==l1t::tftype::omtf_neg &&
62  (aId.region()>0 ||
63  (aId.region()==0 && aId.ring()!=-2) ||
64  (aId.region()==0 && aId.station()==4) ||
65  (aId.region()==0 && aId.station()==2 && aId.layer()==2 && aId.roll()==1) ||
66  (aId.region()==0 && aId.station()==3 && aId.roll()==1) ||
67  (aId.region()==-1 && aId.station()==4) ||
68  //RPC RE1/2 temporarily not used (aId.region()==1 && aId.station()==1 && aId.ring()<2) ||
69  (aId.region()==-1 && aId.station()>0 && aId.ring()<3))
70  ) return false;
71 
72  if(type==l1t::tftype::bmtf && aId.region()!=0) return false;
73 
74  if(type==l1t::tftype::emtf_pos &&
75  (aId.region()<=0 ||
76  (aId.station()==1 && aId.ring()==3))) return false;
77  if(type==l1t::tftype::emtf_neg &&
78  (aId.region()>=0 ||
79  (aId.station()==1 && aId.ring()==3))) return false;
81  if(aId.region()==0) aSector = aId.sector();
82  if(aId.region()!=0){
83  aSector = (aId.sector()-1)*6+aId.subsector();
84  aMin = OMTFConfiguration::instance()->endcap10DegMin[iProcessor];
85  aMax = OMTFConfiguration::instance()->endcap10DegMax[iProcessor];
86  }
87 
88  break;
89  }
90  case MuonSubdetId::DT: {
91  DTChamberId dt(rawId);
92 
93  if(type==l1t::tftype::omtf_pos && dt.wheel()!=2) return false;
94  if(type==l1t::tftype::omtf_neg && dt.wheel()!=-2) return false;
95  if(type==l1t::tftype::emtf_pos || type==l1t::tftype::emtf_neg) return false;
96 
97  aSector = dt.sector();
98  break;
99  }
100  case MuonSubdetId::CSC: {
101 
102  CSCDetId csc(rawId);
103  if(type==l1t::tftype::omtf_pos &&
104  (csc.endcap()==2 || csc.ring()==1 || csc.station()==4)) return false;
105  if(type==l1t::tftype::omtf_neg &&
106  (csc.endcap()==1 || csc.ring()==1 || csc.station()==4)) return false;
107 
108  if(type==l1t::tftype::emtf_pos &&
109  (csc.endcap()==2 || (csc.station()==1 && csc.ring()==3))
110  ) return false;
111  if(type==l1t::tftype::emtf_neg &&
112  (csc.endcap()==1 || (csc.station()==1 && csc.ring()==3))
113  ) return false;
114 
115  aSector = csc.chamber();
116 
117  aMin = OMTFConfiguration::instance()->endcap10DegMin[iProcessor];
118  aMax = OMTFConfiguration::instance()->endcap10DegMax[iProcessor];
119 
120  if( (type==l1t::tftype::emtf_pos || type==l1t::tftype::emtf_neg) &&
121  csc.station()>1 && csc.ring()==1){
122  aMin = OMTFConfiguration::instance()->endcap20DegMin[iProcessor];
123  aMax = OMTFConfiguration::instance()->endcap20DegMax[iProcessor];
124  }
125  break;
126  }
127  }
128 
129  if(aMax>aMin && aSector>=aMin && aSector<=aMax) return true;
130  if(aMax<aMin && (aSector>=aMin || aSector<=aMax)) return true;
131 
132  return false;
133 }
136 unsigned int OMTFinputMaker::getInputNumber(unsigned int rawId,
137  unsigned int iProcessor,
138  l1t::tftype type){
139 
140  unsigned int iInput = 99;
141  unsigned int aSector = 99;
142  int aMin = OMTFConfiguration::instance()->barrelMin[iProcessor];
143  int iRoll = 1;
144  int nInputsPerSector = 2;
145 
146  DetId detId(rawId);
147  if (detId.det() != DetId::Muon) edm::LogError("Critical OMTFinputMaker") << "PROBLEM: hit in unknown Det, detID: "<<detId.det()<<std::endl;
148  switch (detId.subdetId()) {
149  case MuonSubdetId::RPC: {
150  RPCDetId rpc(rawId);
151  if(rpc.region()==0){
152  nInputsPerSector = 4;
153  aSector = rpc.sector();
156  if(iProcessor==5 && aSector<3) aMin = -1;
157  //Use division into rolls
158  iRoll = rpc.roll();
161  if(rpc.station()==2 && rpc.layer()==2 && rpc.roll()==2) iRoll = 1;
163  if(rpc.station()==3){
164  iRoll = 1;
165  nInputsPerSector = 2;
166  }
168  if(type==l1t::tftype::bmtf)iRoll = 1;
169  }
170  if(rpc.region()!=0){
171  aSector = (rpc.sector()-1)*6+rpc.subsector();
172  aMin = OMTFConfiguration::instance()->endcap10DegMin[iProcessor];
175  if(iProcessor==5 && aSector<5) aMin = -4;
176  }
177  break;
178  }
179  case MuonSubdetId::DT: {
180  DTChamberId dt(rawId);
181  aSector = dt.sector();
184  if(iProcessor==5 && aSector<3) aMin = -1;
185  break;
186  }
187  case MuonSubdetId::CSC: {
188  CSCDetId csc(rawId);
189  aSector = csc.chamber();
190  aMin = OMTFConfiguration::instance()->endcap10DegMin[iProcessor];
193  if(iProcessor==5 && aSector<5) aMin = -4;
197  if( (type==l1t::tftype::emtf_pos || type==l1t::tftype::emtf_neg) &&
198  csc.station()>1 && csc.ring()==1){
199  aMin = OMTFConfiguration::instance()->endcap20DegMin[iProcessor];
200  if(iProcessor==5 && aSector<3) aMin = -2;
201  }
202  break;
203  }
204  }
205 
207  iInput = (aSector - aMin)*nInputsPerSector;
209  iInput+=iRoll-1;
210 
211  return iInput;
212 }
216  const L1MuDTChambThContainer *dtThDigis,
217  unsigned int iProcessor,
219 {
220 
222  if(!dtPhDigis) return result;
223 
224  for (const auto digiIt: *dtPhDigis->getContainer()) {
225 
226  DTChamberId detid(digiIt.whNum(),digiIt.stNum(),digiIt.scNum()+1);
227 
229  if(!acceptDigi(detid.rawId(), iProcessor, type)) continue;
230 
235  // FIXME (MK): at least Ts2Tag selection is not correct! Check it
236  if (digiIt.bxNum()!= 0 || digiIt.BxCnt()!= 0 || digiIt.Ts2Tag()!= 0 || digiIt.code()<4) continue;
237 
238  unsigned int hwNumber = OMTFConfiguration::instance()->getLayerNumber(detid.rawId());
240 
241  //unsigned int iLayer = OMTFConfiguration::instance()->hwToLogicLayer[hwNumber];
242  auto iter = OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber);
243  unsigned int iLayer = iter->second;
244 
245  int iPhi = myAngleConverter.getProcessorPhi(iProcessor, type, digiIt);
246  int iEta = myAngleConverter.getGlobalEta(detid.rawId(), digiIt, dtThDigis);
247  unsigned int iInput= getInputNumber(detid.rawId(), iProcessor, type);
248  result.addLayerHit(iLayer,iInput,iPhi,iEta);
249  result.addLayerHit(iLayer+1,iInput,digiIt.phiB(),iEta);
250  }
251 
252  return result;
253 
254 }
258  unsigned int iProcessor,
259  l1t::tftype type){
260 
262  if(!cscDigis) return result;
263 
264  auto chamber = cscDigis->begin();
265  auto chend = cscDigis->end();
266  for( ; chamber != chend; ++chamber ) {
267 
268  unsigned int rawid = (*chamber).first;
270  if(!acceptDigi(rawid, iProcessor, type)) continue;
271  auto digi = (*chamber).second.first;
272  auto dend = (*chamber).second.second;
273  for( ; digi != dend; ++digi ) {
274 
277  if (abs(digi->getBX()- 6)>0) continue;
278 
279  unsigned int hwNumber = OMTFConfiguration::instance()->getLayerNumber(rawid);
280  if(OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber)==OMTFConfiguration::instance()->hwToLogicLayer.end()) continue;
281 
282 
283  //unsigned int iLayer = OMTFConfiguration::instance()->hwToLogicLayer[hwNumber];
284  auto iter = OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber);
285  unsigned int iLayer = iter->second;
286 
287  int iPhi = myAngleConverter.getProcessorPhi(iProcessor, type, CSCDetId(rawid), *digi);
288  int iEta = myAngleConverter.getGlobalEta(rawid, *digi);
292  if(abs(iEta)>1.26/2.61*240) continue;
293  unsigned int iInput= getInputNumber(rawid, iProcessor, type);
294  result.addLayerHit(iLayer,iInput,iPhi,iEta);
295  }
296  }
297  return result;
298 }
301 bool rpcPrimitiveCmp(const RPCDigi &a, const RPCDigi &b) { return a.strip() < b.strip(); };
305  unsigned int iProcessor,
306  l1t::tftype type){
307 
308  OMTFinput result;
309  if(!rpcDigis) return result;
310  std::stringstream str;
311 
312  const RPCDigiCollection & rpcDigiCollection = *rpcDigis;
313  for (auto rollDigis : rpcDigiCollection) {
314  RPCDetId roll = rollDigis.first;
315  unsigned int rawid = roll.rawId();
316  if(!acceptDigi(rawid, iProcessor, type)) continue;
320  std::vector<RPCDigi> digisCopy;
321  std::copy_if(rollDigis.second.first, rollDigis.second.second, std::back_inserter(digisCopy), [](const RPCDigi & aDigi){return (aDigi.bx()==0);});
322  std::sort(digisCopy.begin(),digisCopy.end(),rpcPrimitiveCmp);
323  typedef std::pair<unsigned int, unsigned int> Cluster;
324  std::vector<Cluster> clusters;
325  for(auto & digi: digisCopy) {
326  if(clusters.empty()) clusters.push_back(Cluster(digi.strip(),digi.strip()));
327  else if (digi.strip() - clusters.back().second == 1) clusters.back().second = digi.strip();
328  else if (digi.strip() - clusters.back().second > 1) clusters.push_back(Cluster(digi.strip(),digi.strip()));
329  }
330 
331  for (auto & cluster: clusters) {
332  int iPhiHalfStrip1 = myAngleConverter.getProcessorPhi(iProcessor, type, roll, cluster.first);
333  int iPhiHalfStrip2 = myAngleConverter.getProcessorPhi(iProcessor, type, roll, cluster.second);
334  int iPhi = (iPhiHalfStrip1+iPhiHalfStrip2)/2;
335  int iEta = myAngleConverter.getGlobalEta(rawid, cluster.first);
336  unsigned int hwNumber = OMTFConfiguration::instance()->getLayerNumber(rawid);
337  //unsigned int iLayer = OMTFConfiguration::instance()->hwToLogicLayer[hwNumber];
338  auto iter = OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber);
339  unsigned int iLayer = iter->second;
340 
341  unsigned int iInput= getInputNumber(rawid, iProcessor, type);
342  result.addLayerHit(iLayer,iInput,iPhi,iEta);
343 
344  str<<" RPC halfDigi "
345  <<" begin: "<<cluster.first<<" end: "<<cluster.second
346  <<" iPhi: "<<iPhi
347  <<" iEta: "<<iEta
348  <<" hwNumber: "<<hwNumber
349  <<" iInput: "<<iInput
350  <<" iLayer: "<<iLayer
351  <<std::endl;
352  }
353  }
354 
355  edm::LogInfo("OMTFInputMaker")<<str.str();
356  return result;
357 }
361  const L1MuDTChambThContainer *dtThDigis,
362  const CSCCorrelatedLCTDigiCollection *cscDigis,
363  const RPCDigiCollection *rpcDigis,
364  unsigned int iProcessor,
365  l1t::tftype type){
366 
368  result += processDT(dtPhDigis, dtThDigis, iProcessor, type);
369  result += processCSC(cscDigis, iProcessor, type);
370  result += processRPC(rpcDigis, iProcessor, type);
371  return result;
372 }
std::vector< unsigned int > endcap20DegMax
int chamber() const
Definition: CSCDetId.h:68
type
Definition: HCALResponse.h:21
float dt
Definition: AMPTWrapper.h:126
std::vector< unsigned int > endcap10DegMin
OMTFinput processCSC(const CSCCorrelatedLCTDigiCollection *cscDigis, unsigned int iProcessor, l1t::tftype type)
OMTFinput processRPC(const RPCDigiCollection *rpcDigis, unsigned int iProcessor, l1t::tftype type)
int bx() const
Definition: RPCDigi.cc:47
int getGlobalEta(unsigned int rawid, const L1MuDTChambPhDigi &aDigi, const L1MuDTChambThContainer *dtThDigis)
Convert local eta coordinate to global digital microGMT scale.
std::vector< unsigned int > endcap20DegMin
tuple result
Definition: mps_fire.py:95
void initialize(const edm::EventSetup &es)
std::vector< unsigned int > endcap10DegMax
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int endcap() const
Definition: CSCDetId.h:93
int getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const L1MuDTChambPhDigi &digi) const
static const int CSC
Definition: MuonSubdetId.h:13
int strip() const
Definition: RPCDigi.cc:45
int roll() const
Definition: RPCDetId.h:120
int ring() const
Definition: RPCDetId.h:72
OMTFinput processDT(const L1MuDTChambPhContainer *dtPhDigis, const L1MuDTChambThContainer *dtThDigis, unsigned int iProcessor, l1t::tftype type)
AngleConverter myAngleConverter
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
int ring() const
Definition: CSCDetId.h:75
int layer() const
Definition: RPCDetId.h:108
Definition: DetId.h:18
bool acceptDigi(uint32_t rawId, unsigned int iProcessor, l1t::tftype type)
std::vector< unsigned int > barrelMin
uint32_t getLayerNumber(uint32_t rawId) const
unsigned int getInputNumber(unsigned int rawId, unsigned int iProcessor, l1t::tftype type)
double b
Definition: hdecay.h:120
Phi_Container const * getContainer() const
std::map< int, int > hwToLogicLayer
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
return(e1-e2)*(e1-e2)+dp *dp
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:114
bool rpcPrimitiveCmp(const RPCDigi &a, const RPCDigi &b)
static const int RPC
Definition: MuonSubdetId.h:14
int sector() const
Definition: DTChamberId.h:61
double a
Definition: hdecay.h:121
bool addLayerHit(unsigned int iLayer, unsigned int iInput, int iPhi, int iEta)
Definition: OMTFinput.cc:45
OMTFinput buildInputForProcessor(const L1MuDTChambPhContainer *dtPhDigis, const L1MuDTChambThContainer *dtThDigis, const CSCCorrelatedLCTDigiCollection *cscDigis, const RPCDigiCollection *rpcDigis, unsigned int iProcessor, l1t::tftype type=l1t::tftype::omtf_pos)
Method translating trigger digis into input matrix with global phi coordinates.
int station() const
Definition: CSCDetId.h:86
static const int DT
Definition: MuonSubdetId.h:12
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
static const OMTFConfiguration * instance()
std::vector< unsigned int > barrelMax
void checkAndUpdateGeometry(const edm::EventSetup &)
Update the Geometry with current Event Setup.
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96