CMS 3D CMS Logo

MTDTopology.h
Go to the documentation of this file.
1 #ifndef MTDTOPOLOGY_H
2 #define MTDTOPOLOGY_H
3 
7 
8 #include <vector>
9 #include <string>
10 
11 //knower of all things tracker geometry
12 //flexible replacement for PXBDetId and friends
13 //to implement
14 // endcap pixel
15 
16 class MTDTopology {
17 public:
18  struct BTLValues {
19  unsigned int sideStartBit_;
20  unsigned int layerStartBit_;
21  unsigned int trayStartBit_;
22  unsigned int moduleStartBit_;
23  unsigned int sideMask_;
24  unsigned int layerMask_;
25  unsigned int trayMask_;
26  unsigned int moduleMask_;
27  };
28 
29  struct ETLValues {
30  unsigned int sideStartBit_;
31  unsigned int layerStartBit_;
32  unsigned int ringStartBit_;
33  unsigned int moduleStartBit_;
34  unsigned int sideMask_;
35  unsigned int layerMask_;
36  unsigned int ringMask_;
37  unsigned int moduleMask_;
38  };
39 
40  enum DetIdFields {
49  /* TODO: this can be extended for all subdetectors */
51  };
52 
54  public:
55  explicit SameLayerComparator(const MTDTopology *topo) : topo_(topo) {}
56 
57  bool operator()(DetId i1, DetId i2) const {
58  if (i1.det() == i2.det() && i1.subdetId() == i2.subdetId() && topo_->side(i1) == topo_->side(i2) &&
59  topo_->layer(i1) == topo_->layer(i2)) {
60  return false;
61  }
62  return i1 < i2;
63  }
64 
65  bool operator()(uint32_t i1, uint32_t i2) const { return operator()(DetId(i1), DetId(i2)); }
66 
67  private:
69  };
70 
71  MTDTopology(const int &topologyMode, const BTLValues &btl, const ETLValues &etl);
72 
73  int getMTDTopologyMode() const { return mtdTopologyMode_; }
74 
75  unsigned int side(const DetId &id) const;
76  unsigned int layer(const DetId &id) const;
77  unsigned int module(const DetId &id) const;
78  unsigned int tray(const DetId &id) const;
79  unsigned int ring(const DetId &id) const;
80 
81  //module
82  unsigned int btlModule(const DetId &id) const {
83  return ((id.rawId() >> btlVals_.moduleStartBit_) & btlVals_.moduleMask_);
84  }
85  unsigned int etlModule(const DetId &id) const {
86  return int((id.rawId() >> btlVals_.moduleStartBit_) & btlVals_.moduleMask_);
87  }
88 
89  //tray
90  unsigned int btlTray(const DetId &id) const { return ((id.rawId() >> btlVals_.trayStartBit_) & btlVals_.trayMask_); }
91 
92  // ring id
93  unsigned int etlRing(const DetId &id) const { return ((id.rawId() >> etlVals_.ringStartBit_) & etlVals_.ringMask_); }
94 
95  // layer numbers
96  unsigned int btlLayer(const DetId &id) const {
97  return int((id.rawId() >> btlVals_.layerStartBit_) & btlVals_.layerMask_);
98  }
99  unsigned int etlLayer(const DetId &id) const {
100  return int((id.rawId() >> etlVals_.layerStartBit_) & etlVals_.layerMask_);
101  }
102 
103  //side
104  unsigned int btlSide(const DetId &id) const { return ((id.rawId() >> btlVals_.sideStartBit_) & btlVals_.sideMask_); }
105 
106  unsigned int etlSide(const DetId &id) const { return ((id.rawId() >> etlVals_.sideStartBit_) & etlVals_.sideMask_); }
107 
108  // which disc is this ring on the forward or backward one?
109  unsigned int etlDisc(const DetId &id) const {
110  return int((id.rawId() >> etlVals_.ringStartBit_) & etlVals_.ringMask_) % 2;
111  }
112 
113  //old constructors, now return DetId
114  DetId btlDetId(uint32_t side, uint32_t layer, uint32_t tray, uint32_t module) const {
115  //uply
117  uint32_t rawid = id.rawId();
122  return DetId(rawid);
123  }
124 
125  DetId etlDetId(uint32_t side, uint32_t layer, uint32_t ring, uint32_t module) const {
127  uint32_t rawid = id.rawId();
132  return DetId(rawid);
133  }
134 
135  std::pair<DetId, SameLayerComparator> btlDetIdLayerComparator(uint32_t side, uint32_t layer) const {
136  return std::make_pair(btlDetId(side, layer, 1, 1), SameLayerComparator(this));
137  }
138 
139  std::pair<DetId, SameLayerComparator> etlDetIdDiskComparator(uint32_t side, uint32_t layer) const {
140  return std::make_pair(etlDetId(side, layer, 1, 1), SameLayerComparator(this));
141  }
142 
143  std::string print(DetId detid) const;
144 
145  int getMTDLayerNumber(const DetId &id) const;
146 
147  // Extract the raw bit value for a given field type.
148  // E.g. getField(id, PBLadder) == pxbLadder(id)
149  unsigned int getField(const DetId &id, DetIdFields idx) const {
150  return ((id.rawId() >> bits_per_field[idx].startBit) & bits_per_field[idx].mask);
151  }
152  // checks whether a given field can be extracted from a given DetId.
153  // This boils down to checking whether it is the correct subdetector.
154  bool hasField(const DetId &id, DetIdFields idx) const { return id.subdetId() == bits_per_field[idx].subdet; }
155 
156 private:
157  const int mtdTopologyMode_;
158 
161 
163  unsigned int startBit;
164  unsigned int mask;
165  int subdet;
166  };
168 };
169 
170 #endif
MTDTopology::ETLValues::moduleStartBit_
unsigned int moduleStartBit_
Definition: MTDTopology.h:33
MTDTopology::BTLModule
Definition: MTDTopology.h:41
MTDTopology::etlVals_
const ETLValues etlVals_
Definition: MTDTopology.h:160
MTDTopology::side
unsigned int side(const DetId &id) const
Definition: MTDTopology.cc:24
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
MTDTopology::etlModule
unsigned int etlModule(const DetId &id) const
Definition: MTDTopology.h:85
MTDTopology::etlDetIdDiskComparator
std::pair< DetId, SameLayerComparator > etlDetIdDiskComparator(uint32_t side, uint32_t layer) const
Definition: MTDTopology.h:139
MTDTopology::tray
unsigned int tray(const DetId &id) const
Definition: MTDTopology.cc:63
MTDTopology::ETLModule
Definition: MTDTopology.h:45
MTDTopology::BTLLayer
Definition: MTDTopology.h:43
MTDTopology::etlDetId
DetId etlDetId(uint32_t side, uint32_t layer, uint32_t ring, uint32_t module) const
Definition: MTDTopology.h:125
MTDTopology::getMTDLayerNumber
int getMTDLayerNumber(const DetId &id) const
Definition: MTDTopology.cc:122
MTDTopology::BTLValues::trayStartBit_
unsigned int trayStartBit_
Definition: MTDTopology.h:21
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
MTDTopology::btlModule
unsigned int btlModule(const DetId &id) const
Definition: MTDTopology.h:82
MTDTopology::ETLValues::ringStartBit_
unsigned int ringStartBit_
Definition: MTDTopology.h:32
MTDTopology::bits_per_field
const BitmaskAndSubdet bits_per_field[DETID_FIELDS_MAX]
Definition: MTDTopology.h:167
MTDTopology::ring
unsigned int ring(const DetId &id) const
Definition: MTDTopology.cc:76
MTDTopology::SameLayerComparator::operator()
bool operator()(DetId i1, DetId i2) const
Definition: MTDTopology.h:57
MTDTopology::MTDTopology
MTDTopology(const int &topologyMode, const BTLValues &btl, const ETLValues &etl)
Definition: MTDTopology.cc:11
MTDTopology::SameLayerComparator::operator()
bool operator()(uint32_t i1, uint32_t i2) const
Definition: MTDTopology.h:65
MTDTopology::BTLValues::layerMask_
unsigned int layerMask_
Definition: MTDTopology.h:24
MTDTopology::BTLValues::moduleMask_
unsigned int moduleMask_
Definition: MTDTopology.h:26
MTDTopology::getMTDTopologyMode
int getMTDTopologyMode() const
Definition: MTDTopology.h:73
MTDTopology::BitmaskAndSubdet::mask
unsigned int mask
Definition: MTDTopology.h:164
ForwardSubdetector.h
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
MTDTopology::SameLayerComparator::topo_
const MTDTopology * topo_
Definition: MTDTopology.h:68
DetId
Definition: DetId.h:17
MTDTopology::btlTray
unsigned int btlTray(const DetId &id) const
Definition: MTDTopology.h:90
MTDTopology::btlLayer
unsigned int btlLayer(const DetId &id) const
Definition: MTDTopology.h:96
MTDTopology::btlSide
unsigned int btlSide(const DetId &id) const
Definition: MTDTopology.h:104
MTDTopology::BTLValues
Definition: MTDTopology.h:18
MTDTopology::ETLValues
Definition: MTDTopology.h:29
MTDTopology::SameLayerComparator
Definition: MTDTopology.h:53
MTDTopology::btlDetIdLayerComparator
std::pair< DetId, SameLayerComparator > btlDetIdLayerComparator(uint32_t side, uint32_t layer) const
Definition: MTDTopology.h:135
MTDTopology::btlDetId
DetId btlDetId(uint32_t side, uint32_t layer, uint32_t tray, uint32_t module) const
Definition: MTDTopology.h:114
MTDTopology::etlLayer
unsigned int etlLayer(const DetId &id) const
Definition: MTDTopology.h:99
MTDTopology::ETLValues::ringMask_
unsigned int ringMask_
Definition: MTDTopology.h:36
MTDTopology::hasField
bool hasField(const DetId &id, DetIdFields idx) const
Definition: MTDTopology.h:154
MTDTopology::getField
unsigned int getField(const DetId &id, DetIdFields idx) const
Definition: MTDTopology.h:149
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MTDTopology::ETLValues::sideStartBit_
unsigned int sideStartBit_
Definition: MTDTopology.h:30
MTDTopology
Definition: MTDTopology.h:16
MTDTopology::etlSide
unsigned int etlSide(const DetId &id) const
Definition: MTDTopology.h:106
MTDDetId.h
MTDTopology::etlDisc
unsigned int etlDisc(const DetId &id) const
Definition: MTDTopology.h:109
MTDTopology::BTLValues::sideStartBit_
unsigned int sideStartBit_
Definition: MTDTopology.h:19
FastTime
Definition: ForwardSubdetector.h:6
createfilelist.int
int
Definition: createfilelist.py:10
MTDTopology::BTLValues::sideMask_
unsigned int sideMask_
Definition: MTDTopology.h:23
MTDTopology::print
std::string print(DetId detid) const
Definition: MTDTopology.cc:89
MTDTopology::BTLTray
Definition: MTDTopology.h:42
MTDTopology::btlVals_
const BTLValues btlVals_
Definition: MTDTopology.h:159
MTDDetId::kMTDsubdOffset
static const uint32_t kMTDsubdOffset
Definition: MTDDetId.h:29
MTDTopology::ETLValues::sideMask_
unsigned int sideMask_
Definition: MTDTopology.h:34
MTDTopology::DetIdFields
DetIdFields
Definition: MTDTopology.h:40
MTDDetId::BTL
Definition: MTDDetId.h:27
MTDTopology::BitmaskAndSubdet::subdet
int subdet
Definition: MTDTopology.h:165
DetId.h
MTDTopology::mtdTopologyMode_
const int mtdTopologyMode_
Definition: MTDTopology.h:157
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
MTDDetId::ETL
Definition: MTDDetId.h:27
MTDTopology::DETID_FIELDS_MAX
Definition: MTDTopology.h:50
MTDTopology::BitmaskAndSubdet::startBit
unsigned int startBit
Definition: MTDTopology.h:163
MTDTopology::BTLSide
Definition: MTDTopology.h:44
MTDTopology::ETLRing
Definition: MTDTopology.h:46
MTDTopology::BTLValues::trayMask_
unsigned int trayMask_
Definition: MTDTopology.h:25
MTDTopology::ETLValues::moduleMask_
unsigned int moduleMask_
Definition: MTDTopology.h:37
MTDTopology::SameLayerComparator::SameLayerComparator
SameLayerComparator(const MTDTopology *topo)
Definition: MTDTopology.h:55
MTDTopology::ETLValues::layerStartBit_
unsigned int layerStartBit_
Definition: MTDTopology.h:31
MTDTopology::module
unsigned int module(const DetId &id) const
Definition: MTDTopology.cc:50
MTDTopology::etlRing
unsigned int etlRing(const DetId &id) const
Definition: MTDTopology.h:93
DetId::Forward
Definition: DetId.h:30
MTDTopology::BTLValues::layerStartBit_
unsigned int layerStartBit_
Definition: MTDTopology.h:20
MTDTopology::ETLValues::layerMask_
unsigned int layerMask_
Definition: MTDTopology.h:35
MTDTopology::ETLSide
Definition: MTDTopology.h:48
MTDTopology::ETLLayer
Definition: MTDTopology.h:47
MTDTopology::BTLValues::moduleStartBit_
unsigned int moduleStartBit_
Definition: MTDTopology.h:22
MTDTopology::BitmaskAndSubdet
Definition: MTDTopology.h:162
MTDTopology::layer
unsigned int layer(const DetId &id) const
Definition: MTDTopology.cc:37