File indexing completed on 2025-01-31 09:20:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "Detector/DeVeloSensor.h"
0018 #include "DD4hep/ConditionsData.h"
0019 #include "DD4hep/Primitives.h"
0020 #include "DD4hep/Printout.h"
0021
0022 namespace gaudi {
0023 const DeVeloSensorElement::itemkey_type DeVeloSensorElement::key_info = dd4hep::ConditionKey::itemCode("StripInfo");
0024 const DeVeloSensorElement::itemkey_type DeVeloSensorElement::key_noise = dd4hep::ConditionKey::itemCode("StripNoise");
0025 const DeVeloSensorElement::itemkey_type DeVeloSensorElement::key_readout = dd4hep::ConditionKey::itemCode("StripReadout");
0026 }
0027
0028
0029 void gaudi::detail::DeVeloSensorStaticObject::print(int indent, int flg) const {
0030 this->DeStaticObject::print(indent, flg);
0031 if ( flg & DePrint::SPECIFIC ) {
0032 printout(INFO,"DeVeloSensor", "%s+ >> %s:%d [%s] Class:%d Sens:%d Side:%c %s R:%s Phi:%s Veto:%s Thick:%g Rmin:%g Rmax:%g",
0033 DE::indent(indent).c_str(),
0034 moduleName.c_str(), moduleId, fullType.c_str(), clsID, sensorNumber,
0035 (de_user&DeVeloFlags::LEFT) == 0 ? 'R' : 'L',
0036 (de_user&DeVeloFlags::DOWNSTREAM) == 0 ? "UpStrm" : "DnStrm",
0037 yes_no((de_user&DeVeloFlags::R_TYPE) != 0),
0038 yes_no((de_user&DeVeloFlags::PHI_TYPE) != 0),
0039 yes_no((de_user&DeVeloFlags::PU_TYPE) != 0),
0040 siliconThickness, innerRadius, outerRadius);
0041 }
0042 }
0043
0044
0045 void gaudi::detail::DeVeloSensorStaticObject::initialize() {
0046 de_user |= DeVeloFlags::READOUT;
0047 moduleName = param<std::string>("Module");
0048 typeName = param<std::string>("Type");
0049 sensorNumber = param<int>("SensorNumber");
0050 siliconThickness = param<double>("SiThick");
0051 innerRadius = param<double>("InnerRadius");
0052 outerRadius = param<double>("OuterRadius");
0053
0054 if ( typeName.find("R") == 0 ) de_user |= DeVeloFlags::R_TYPE;
0055 if ( typeName.find("Phi") == 0 ) de_user |= DeVeloFlags::PHI_TYPE;
0056 if ( typeName.find("Veto") == 0 ) de_user |= DeVeloFlags::PU_TYPE;
0057 if ( typeName == "R" || typeName == "Phi" || typeName == "Veto" ) {
0058 if ( 0 != param<int>("Left") ) de_user |= DeVeloFlags::LEFT;
0059 if ( 0 != param<int>("Downstream") ) de_user |= DeVeloFlags::DOWNSTREAM;
0060 fullType = typeName
0061 + ( (de_user&DeVeloFlags::DOWNSTREAM) ? "DnStrm" : "UpStrm" )
0062 + ( (de_user&DeVeloFlags::LEFT) ? "Left" : "Right");
0063 } else {
0064 if ( (typeName == "PhiDL" || typeName == "PhiUL" ||
0065 typeName == "RLeft" || typeName == "VetoL") ) de_user |= DeVeloFlags::LEFT;
0066 if (typeName == "PhiDL" || typeName == "PhiDR") de_user |= DeVeloFlags::DOWNSTREAM;
0067 fullType = typeName;
0068 }
0069
0070 if ( de_user&DeVeloFlags::R_TYPE ) {
0071 (0 != param<int>("DownstreamR")) ? de_user|=DeVeloFlags::DOWNSTREAM : de_user &= ~DeVeloFlags::DOWNSTREAM;
0072 } else if ( de_user&DeVeloFlags::PHI_TYPE ) {
0073 (0 != param<int>("DownstreamPhi")) ? de_user|=DeVeloFlags::DOWNSTREAM : de_user &= ~DeVeloFlags::DOWNSTREAM;
0074 }
0075 }
0076
0077
0078 void gaudi::detail::DeVeloSensorObject::print(int indent, int flg) const {
0079 DeIOVObject::print(indent, flg);
0080 printout(INFO,"DeIOVVeloSensor", "%s+ Z:%g Info(%s): %s [%ld entries] Noise(%s): %s [%ld entries] "
0081 "Readout(%s): %s [READOUT:%s Tell1-no-Sensor:%s]",
0082 DE::indent(indent).c_str(),
0083 z,
0084
0085 info.isValid() ? info.name() : "--",
0086 yes_no(info.isValid()),
0087 stripInfos.size(),
0088
0089 noise.isValid() ? noise.name() : "--",
0090 yes_no(noise.isValid()),
0091 stripNoise.size(),
0092
0093 readout.isValid() ? readout.name() : "--",
0094 yes_no(readout.isValid()),
0095 yes_no((de_user&DeVeloFlags::READOUT)!=0),
0096 yes_no((de_user&DeVeloFlags::T1NOSENS)!=0));
0097 }
0098
0099
0100 void gaudi::detail::DeVeloSensorObject::initialize() {
0101 DeIOVObject::initialize();
0102
0103 sensor_static = de_static;
0104
0105 checkAlignment();
0106 z = DetectorElement<DeVeloSensor>(this).toGlobal(XYZPoint(0,0,0)).z();
0107 for(const auto& c : conditions) {
0108 if ( c.first == DeVeloSensor::key_info ) info = c.second;
0109 else if ( c.first == DeVeloSensor::key_noise ) noise = c.second;
0110 else if ( c.first == DeVeloSensor::key_readout ) readout = c.second;
0111 }
0112
0113
0114 if ( !info.isValid() ) {
0115 except("DeIOVVeloSensor", "Invalid IOV dependent sensor info!");
0116 }
0117 else {
0118 const dd4hep::cond::AbstractMap& m = info.get<dd4hep::cond::AbstractMap>();
0119 stripInfos = m.get<std::vector<int> >("StripInfo");
0120 #if 0
0121 if(m_verbose){
0122 msg() << MSG::VERBOSE << "Sensor " << m_sensorNumber << " has stripInfoConditions "<< endmsg;
0123 for( int row = 0 ; row < 64 ; ++row ){
0124 msg() << MSG::VERBOSE << format("%4i-%4i",(32*row),(32*row+31));
0125 for( int col = 0 ; col < 32 ; ++col ){
0126 msg() << MSG::VERBOSE << format("%2i ",m_stripInfos[32*row+col].asInt());
0127 }
0128 msg() << MSG::VERBOSE << endmsg;
0129 }
0130 }
0131 #endif
0132 if (stripInfos.size() != DeVeloSensorStaticObject::numberOfStrips) {
0133 except("DeIOVVeloSensor","Strip info condition size does not match number of strips!");
0134 }
0135 }
0136 if ( !noise.isValid() ) {
0137 except("DeIOVVeloSensor", "Invalid IOV dependent sensor noise!");
0138 }
0139 else {
0140 const dd4hep::cond::AbstractMap& m = noise.get<dd4hep::cond::AbstractMap>();
0141 stripNoise = m.get<std::vector<double> >("StripNoise");
0142 if ( stripNoise.size() != DeVeloSensorStaticObject::numberOfStrips ) {
0143 except("IOVDeVeloSensor","Strip noise condition size does not match number of strips!");
0144 }
0145 }
0146 if ( !readout.isValid() ) {
0147
0148 }
0149 else {
0150 const dd4hep::cond::AbstractMap& m = noise.get<dd4hep::cond::AbstractMap>();
0151 (0 != m.get<int>("ReadoutFlag")) ? de_user |= DeVeloFlags::READOUT : de_user &= ~DeVeloFlags::READOUT;
0152 (0 != m.get<int>("Tell1WithoutSensor")) ? de_user |= DeVeloFlags::T1NOSENS : de_user &= ~DeVeloFlags::T1NOSENS;
0153 }
0154 }