Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:17

0001 #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSGeometryESCommon.h"
0002 #include "Geometry/VeryForwardGeometryBuilder/interface/CTPPSDDDNames.h"
0003 
0004 namespace CTPPSGeometryESCommon {
0005 
0006   std::unique_ptr<DetGeomDesc> applyAlignments(const DetGeomDesc& idealDetRoot,
0007                                                const CTPPSRPAlignmentCorrectionsData* alignments) {
0008     std::deque<const DetGeomDesc*> bufferIdealGeo;
0009     bufferIdealGeo.emplace_back(&idealDetRoot);
0010 
0011     std::deque<DetGeomDesc*> bufferAlignedGeo;
0012     DetGeomDesc* alignedDetRoot = new DetGeomDesc(idealDetRoot, DetGeomDesc::cmWithoutChildren);
0013     bufferAlignedGeo.emplace_back(alignedDetRoot);
0014 
0015     while (!bufferIdealGeo.empty()) {
0016       const DetGeomDesc* idealDet = bufferIdealGeo.front();
0017       DetGeomDesc* alignedDet = bufferAlignedGeo.front();
0018       bufferIdealGeo.pop_front();
0019       bufferAlignedGeo.pop_front();
0020 
0021       const std::string name = alignedDet->name();
0022 
0023       // Is it sensor? If yes, apply full sensor alignments
0024       if (name == DDD_TOTEM_RP_SENSOR_NAME || name == DDD_CTPPS_DIAMONDS_SEGMENT_NAME ||
0025           name == DDD_CTPPS_UFSD_SEGMENT_NAME || name == DDD_CTPPS_PIXELS_SENSOR_NAME ||
0026           name == DDD_CTPPS_PIXELS_SENSOR_NAME_2x2 ||
0027           std::regex_match(name, std::regex(DDD_TOTEM_TIMING_SENSOR_TMPL))) {
0028         unsigned int plId = alignedDet->geographicalID();
0029 
0030         if (alignments) {
0031           const auto& ac = alignments->getFullSensorCorrection(plId);
0032           alignedDet->applyAlignment(ac);
0033         }
0034       }
0035 
0036       // Is it RP box? If yes, apply RP alignments
0037       if (name == DDD_TOTEM_RP_RP_NAME || name == DDD_CTPPS_DIAMONDS_RP_NAME || name == DDD_CTPPS_PIXELS_RP_NAME ||
0038           name == DDD_TOTEM_TIMING_RP_NAME) {
0039         unsigned int rpId = alignedDet->geographicalID();
0040 
0041         if (alignments) {
0042           const auto& ac = alignments->getRPCorrection(rpId);
0043           alignedDet->applyAlignment(ac);
0044         }
0045       }
0046 
0047       // create and add children
0048       const auto& idealDetChildren = idealDet->components();
0049       for (unsigned int i = 0; i < idealDetChildren.size(); i++) {
0050         const DetGeomDesc* idealDetChild = idealDetChildren[i];
0051         bufferIdealGeo.emplace_back(idealDetChild);
0052 
0053         // create new node with the same information as in idealDetChild and add it as a child of alignedDet
0054         DetGeomDesc* alignedDetChild = new DetGeomDesc(*idealDetChild, DetGeomDesc::cmWithoutChildren);
0055         alignedDet->addComponent(alignedDetChild);
0056 
0057         bufferAlignedGeo.emplace_back(alignedDetChild);
0058       }
0059     }
0060     return std::unique_ptr<DetGeomDesc>(alignedDetRoot);
0061   }
0062 
0063 }  // namespace CTPPSGeometryESCommon