File indexing completed on 2025-01-18 09:14:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef DETECTOR_DEVELOSENSOR_H
0016 #define DETECTOR_DEVELOSENSOR_H 1
0017
0018
0019 #include <array>
0020
0021
0022 #include "Detector/DetectorElement.h"
0023 #include "Detector/DeStatic.h"
0024 #include "Detector/DeIOV.h"
0025 #include "DD4hep/DD4hepUnits.h"
0026
0027
0028 namespace gaudi {
0029
0030 namespace DeVeloConst {
0031 }
0032 namespace DeVeloFlags {
0033 enum {
0034
0035 ALL = 2,
0036
0037
0038 RIGHT = 0,
0039 LEFT = 1<<0,
0040 MAIN = 1<<2,
0041 SIDE = 1<<3,
0042 SUPPORT = 1<<4,
0043 MODULE = 1<<5,
0044 LADDER = 1<<6,
0045 SENSOR = 1<<7,
0046
0047
0048 TOP = 1<<8,
0049 DOWNSTREAM = 1<<9,
0050 R_TYPE = 1<<10,
0051 PHI_TYPE = 1<<11,
0052 PU_TYPE = 1<<12,
0053
0054
0055 READOUT = 1<<7,
0056 T1NOSENS = 1<<8
0057 };
0058 }
0059
0060
0061 namespace detail {
0062
0063
0064
0065
0066
0067
0068
0069
0070 class DeVeloSensorStaticObject : public detail::DeStaticObject {
0071 public:
0072
0073 enum { classID = 1008101 };
0074
0075 static const unsigned int minRoutingLine = 1;
0076 static const unsigned int maxRoutingLine = 2048;
0077 static const unsigned int numberOfStrips = 2048;
0078
0079 std::string moduleName;
0080 std::string typeName;
0081 std::string fullType;
0082 int moduleId;
0083 unsigned int sensorNumber;
0084 double siliconThickness;
0085 double innerRadius;
0086 double outerRadius;
0087
0088
0089 unsigned int numberOfZones;
0090 std::map< unsigned int, unsigned int > mapRoutingLineToStrip;
0091 std::map< unsigned int, unsigned int > mapStripToRoutingLine;
0092 std::vector< std::pair< XYZPoint, XYZPoint > > stripLimits;
0093
0094 public:
0095
0096 DE_CTORS_DEFAULT(DeVeloSensorStaticObject);
0097
0098
0099 virtual void initialize() override;
0100
0101 virtual void print(int indent, int flags) const override;
0102 };
0103 }
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 class DeVeloSensorStaticElement : public dd4hep::Handle<detail::DeVeloSensorStaticObject> {
0125 DE_CONDITIONS_TYPEDEFS;
0126
0127 typedef Object static_t;
0128 public:
0129
0130 DE_CTORS_HANDLE(DeVeloSensorStaticElement,Base);
0131 };
0132
0133
0134 typedef DetectorStaticElement<DeVeloSensorStaticElement> DeVeloSensorStatic;
0135
0136
0137
0138 namespace detail {
0139
0140
0141
0142
0143
0144
0145
0146
0147 class DeVeloSensorObject : public DeIOVObject {
0148 DE_CONDITIONS_TYPEDEFS;
0149 typedef DeVeloSensorStatic::Object static_t;
0150
0151
0152 DeVeloSensorStatic sensor_static;
0153
0154
0155
0156 Condition info;
0157
0158 Condition noise;
0159
0160 Condition readout;
0161
0162 DeIOV halfBoxGeom;
0163 Condition stripNoiseCondition;
0164 Condition stripInfoCondition;
0165 Condition readoutCondition;
0166
0167 std::vector< double > stripNoise;
0168 std::vector< int > stripInfos;
0169
0170 double z = 0.0;
0171
0172 public:
0173
0174 DE_CTORS_DEFAULT(DeVeloSensorObject);
0175
0176
0177 virtual void initialize() override;
0178
0179 virtual void print(int indent, int flags) const override;
0180 };
0181 }
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200 class DeVeloSensorElement : public dd4hep::Handle<detail::DeVeloSensorObject> {
0201 DE_CONDITIONS_TYPEDEFS;
0202
0203 typedef Object::static_t static_t;
0204 typedef Object iov_t;
0205
0206 public:
0207
0208 static const itemkey_type key_info;
0209 static const itemkey_type key_noise;
0210 static const itemkey_type key_readout;
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221 class StripInfo
0222 {
0223 public:
0224 StripInfo() : m_info(0) { ; }
0225 StripInfo(int i) : m_info(i) { ; }
0226
0227 private:
0228 enum {
0229 LOWGAIN= 2,
0230 NOISY= 1,
0231 STRIPOK = 0,
0232 DEAD= -1,
0233 OPEN= -2,
0234 PINHOLE= -3,
0235 SHORT= -4
0236 };
0237
0238 public:
0239
0240 bool stripIsOK() const { return m_info==STRIPOK; }
0241
0242 bool stripIsLowGain() const { return m_info==LOWGAIN; }
0243
0244 bool stripIsNoisy() const { return m_info==NOISY; }
0245
0246 bool stripIsDead() const { return m_info==DEAD; }
0247
0248 bool stripIsOpen() const { return m_info==OPEN; }
0249
0250 bool stripIsPinhole() const { return m_info==PINHOLE; }
0251
0252 bool stripIsShort() const { return m_info==SHORT; }
0253
0254 int asInt() const{ return m_info; }
0255
0256 private:
0257 int m_info;
0258 };
0259
0260
0261 DE_CTORS_HANDLE(DeVeloSensorElement,Base);
0262
0263 static_t& staticData() const
0264 { return access()->sensor_static; }
0265
0266 const iov_t& iovData() const
0267 { return *access(); }
0268
0269
0270 unsigned int station () const
0271 { return (staticData().sensorNumber&0x3E) >> 1; }
0272
0273 unsigned int sensorNumber () const
0274 { return staticData().sensorNumber; }
0275
0276 unsigned int moduleId () const
0277 { return staticData().moduleId; }
0278
0279 unsigned int numberOfStrips () const
0280 { return staticData().numberOfStrips; }
0281
0282 StripInfo stripInfo(size_t which) const
0283 { return iovData().stripInfos[which]; }
0284
0285 unsigned int numberOfZones () const
0286 { return staticData().numberOfZones; }
0287
0288 double z () const
0289 { return iovData().z; }
0290
0291 double innerRadius () const
0292 { return staticData().innerRadius; }
0293
0294 double outerRadius () const
0295 { return staticData().outerRadius; }
0296
0297 double siliconThickness () const
0298 { return staticData().siliconThickness; }
0299
0300 bool isRight () const
0301 { return 0 == (staticData().de_user&DeVeloFlags::LEFT); }
0302
0303 bool isLeft () const
0304 { return 0 != (staticData().de_user&DeVeloFlags::LEFT); }
0305
0306 bool isDownstream () const
0307 { return 0 != (staticData().de_user&DeVeloFlags::DOWNSTREAM); }
0308
0309 bool isPileUp () const
0310 { return 0 != (staticData().de_user&DeVeloFlags::PU_TYPE); }
0311
0312 bool isR () const
0313 { return 0 != (staticData().de_user&DeVeloFlags::R_TYPE); }
0314
0315 bool isPhi () const
0316 { return 0 != (staticData().de_user&DeVeloFlags::PHI_TYPE); }
0317
0318 bool isTop () const
0319 { return 0 != (staticData().de_user&DeVeloFlags::TOP); }
0320
0321 bool isBottom () const
0322 { return 0 == (staticData().de_user&DeVeloFlags::TOP); }
0323
0324
0325
0326
0327 bool isReadOut() const
0328 { return 0 != (staticData().de_user&DeVeloFlags::READOUT); }
0329
0330
0331
0332
0333 bool tell1WithoutSensor() const
0334 { return 0 != (staticData().de_user&DeVeloFlags::T1NOSENS); }
0335
0336
0337 unsigned int globalZoneOfStrip(const unsigned int strip) const {
0338 int flg = staticData().de_user;
0339 return (flg&DeVeloFlags::PHI_TYPE)
0340 ? static_cast<unsigned int>(strip>682)
0341 : ((flg&DeVeloFlags::DOWNSTREAM) ? 3-strip/512 : strip/512);
0342 }
0343
0344
0345
0346
0347 double stripNoise(unsigned int strip) const { return iovData().stripNoise[strip]; }
0348
0349
0350
0351
0352
0353
0354 StripInfo stripInfo(unsigned int strip) const { return iovData().stripInfos[strip]; }
0355
0356
0357
0358 XYZPoint veloHalfBoxToLocal(const XYZPoint& boxPos) const {
0359 XYZPoint globalPos = iovData().halfBoxGeom.toGlobal(boxPos);
0360 return DeIOV(ptr()).toLocal(globalPos);
0361 }
0362
0363 XYZPoint veloHalfBoxToGlobal(const XYZPoint& boxPos) const {
0364 return iovData().halfBoxGeom.toGlobal(boxPos);
0365 }
0366
0367 XYZPoint globalToVeloHalfBox(const XYZPoint& globalPos) const {
0368 return iovData().halfBoxGeom.toLocal(globalPos);
0369 }
0370
0371
0372 std::pair<XYZPoint,XYZPoint> localStripLimits(unsigned int strip) const {
0373 return staticData().stripLimits[strip];
0374 }
0375
0376
0377 std::pair<XYZPoint,XYZPoint> globalStripLimits(unsigned int strip) const {
0378 const DeIOV iov(ptr());
0379 const static_t& s = staticData();
0380 XYZPoint begin = iov.toGlobal(s.stripLimits[strip].first);
0381 XYZPoint end = iov.toGlobal(s.stripLimits[strip].second);
0382 return std::pair<XYZPoint,XYZPoint>(begin,end);
0383 }
0384
0385 double localPhiToGlobal(double phiLocal) const {
0386 int flg = staticData().de_user;
0387 if( flg&DeVeloFlags::DOWNSTREAM ) phiLocal = -phiLocal;
0388 if( 0 == (flg&DeVeloFlags::LEFT) ) phiLocal += dd4hep::pi;
0389 return phiLocal;
0390 }
0391
0392 unsigned int RoutingLineToChipChannel(unsigned int routLine) const {
0393 routLine = detail::DeVeloSensorStaticObject::maxRoutingLine-routLine;
0394 if(1 == routLine%4){
0395 routLine++;
0396 }else if(2 == routLine%4){
0397 routLine--;
0398 }
0399 return routLine;
0400 }
0401
0402 unsigned int ChipChannelToRoutingLine(unsigned int chipChan) const {
0403 if(1 == chipChan%4){
0404 chipChan++;
0405 } else if(2 == chipChan%4) {
0406 chipChan--;
0407 }
0408 return (detail::DeVeloSensorStaticObject::numberOfStrips-chipChan);
0409 }
0410
0411 unsigned int ChipChannelToStrip(unsigned int chipChan) const {
0412 return RoutingLineToStrip(ChipChannelToRoutingLine(chipChan));
0413 }
0414
0415 unsigned int StripToChipChannel(unsigned int strip) const {
0416 return RoutingLineToChipChannel(StripToRoutingLine(strip));
0417 }
0418
0419 unsigned int RoutingLineToStrip(unsigned int routLine) const {
0420 return staticData().mapRoutingLineToStrip.at(routLine);
0421 }
0422
0423 unsigned int StripToRoutingLine(unsigned int strip) const {
0424 return staticData().mapStripToRoutingLine.at(strip);
0425 }
0426
0427 unsigned int ChipFromRoutingLine(unsigned int routLine) const {
0428 return ChipFromChipChannel(RoutingLineToChipChannel(routLine));
0429 }
0430
0431 unsigned int ChipFromChipChannel(unsigned int chipChan) const {
0432 return static_cast<int>(chipChan/128);
0433 }
0434
0435 unsigned int ChipFromStrip(unsigned int strip) const {
0436 return ChipFromChipChannel(StripToChipChannel(strip));
0437 }
0438
0439
0440
0441
0442 bool OKStrip(unsigned int strip) const {
0443 return (strip<staticData().numberOfStrips && stripInfo(strip).stripIsOK());
0444 }
0445
0446 bool OKChipChannel(unsigned int chipChan) const {
0447 return (chipChan<staticData().numberOfStrips && OKStrip(ChipChannelToStrip(chipChan)));
0448 }
0449 };
0450
0451
0452 typedef DetectorElement<DeVeloSensorElement> DeVeloSensor;
0453
0454
0455
0456
0457
0458
0459
0460
0461
0462
0463 class DeVeloRSensor : public DeVeloSensorElement {
0464 enum { classID = 1008101 };
0465
0466 public:
0467
0468 DE_CTORS_HANDLE(DeVeloRSensor,DeVeloSensorElement);
0469 };
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480 class DeVeloPhiSensor : public DeVeloSensorElement {
0481 enum { classID = 1008101 };
0482
0483 public:
0484
0485 DE_CTORS_HANDLE(DeVeloPhiSensor,DeVeloSensorElement);
0486 };
0487
0488 }
0489 #endif