Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:56

0001 /******* \class DTGeometryBuilderFromCondDB *******
0002  *
0003  * Description:
0004  *  
0005  *  detailed description
0006  *
0007  * \author : Stefano Lacaprara - INFN LNL <stefano.lacaprara@pd.infn.it>
0008  *
0009  * Modification:
0010  *
0011  *********************************/
0012 
0013 /* This Class Header */
0014 #include "Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromCondDB.h"
0015 
0016 /* Collaborating Class Header */
0017 #include <CondFormats/GeometryObjects/interface/RecoIdealGeometry.h>
0018 #include <Geometry/DTGeometry/interface/DTGeometry.h>
0019 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
0020 #include <DataFormats/MuonDetId/interface/DTSuperLayerId.h>
0021 #include <DataFormats/MuonDetId/interface/DTLayerId.h>
0022 #include "DataFormats/Math/interface/GeantUnits.h"
0023 #include <FWCore/MessageLogger/interface/MessageLogger.h>
0024 
0025 /* C++ Headers */
0026 #include <iostream>
0027 using namespace std;
0028 
0029 using namespace geant_units;
0030 using namespace geant_units::operators;
0031 
0032 /* ====================================================================== */
0033 
0034 /* Constructor */
0035 DTGeometryBuilderFromCondDB::DTGeometryBuilderFromCondDB() {}
0036 
0037 /* Destructor */
0038 DTGeometryBuilderFromCondDB::~DTGeometryBuilderFromCondDB() {}
0039 
0040 /* Operations */
0041 void DTGeometryBuilderFromCondDB::build(const std::shared_ptr<DTGeometry>& theGeometry, const RecoIdealGeometry& rig) {
0042   //  cout << "DTGeometryBuilderFromCondDB " << endl;
0043   const std::vector<DetId>& detids(rig.detIds());
0044   //  cout << "size " << detids.size() << endl;
0045 
0046   size_t idt = 0;
0047   DTChamber* chamber(nullptr);
0048   DTSuperLayer* sl(nullptr);
0049   while (idt < detids.size()) {
0050     //copy(par.begin(), par.end(), ostream_iterator<double>(std::cout," "));
0051     if (int(*(rig.shapeStart(idt))) == 0) {  // a Chamber
0052       // add the provious chamber which by now has been updated with SL and
0053       // layers
0054       if (chamber)
0055         theGeometry->add(chamber);
0056       // go for the actual one
0057       DTChamberId chid(detids[idt]);
0058       //cout << "CH: " <<  chid << endl;
0059       chamber = buildChamber(chid, rig, idt);
0060     } else if (int(*(rig.shapeStart(idt))) == 1) {  // a SL
0061       DTSuperLayerId slid(detids[idt]);
0062       //cout << "  SL: " <<  slid << endl;
0063       sl = buildSuperLayer(chamber, slid, rig, idt);
0064       theGeometry->add(sl);
0065     } else if (int(*(rig.shapeStart(idt))) == 2) {  // a Layer
0066       DTLayerId lid(detids[idt]);
0067       //cout << "    LAY: " <<  lid << endl;
0068       DTLayer* lay = buildLayer(sl, lid, rig, idt);
0069       theGeometry->add(lay);
0070     } else {
0071       cout << "What is this?" << endl;
0072     }
0073     ++idt;
0074   }
0075   if (chamber)
0076     theGeometry->add(chamber);  // add the last chamber
0077 }
0078 
0079 // Calling function has the responsibility to delete the allocated RectangularPlaneBounds object
0080 RectangularPlaneBounds* dtGeometryBuilder::getRecPlaneBounds(const std::vector<double>::const_iterator& shapeStart) {
0081   float width = convertMmToCm(*(shapeStart));          // r-phi  dimension - different in different chambers
0082   float length = convertMmToCm(*(shapeStart + 1));     // z      dimension - constant
0083   float thickness = convertMmToCm(*(shapeStart + 2));  // radial thickness - almost constant
0084   return new RectangularPlaneBounds(width, length, thickness);
0085 }
0086 
0087 DTChamber* DTGeometryBuilderFromCondDB::buildChamber(const DetId& id, const RecoIdealGeometry& rig, size_t idt) const {
0088   DTChamberId detId(id);
0089 
0090   ///SL the definition of length, width, thickness depends on the local reference frame of the Det
0091   // width is along local X
0092   // length is along local Y
0093   // length z      dimension - constant 125.55 cm
0094   // thickness is along local Z
0095   // radial thickness - almost constant about 18 cm
0096   RCPPlane surf(
0097       plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds(++rig.shapeStart(idt))));
0098 
0099   DTChamber* chamber = new DTChamber(detId, surf);
0100 
0101   return chamber;
0102 }
0103 
0104 DTSuperLayer* DTGeometryBuilderFromCondDB::buildSuperLayer(DTChamber* chamber,
0105                                                            const DetId& id,
0106                                                            const RecoIdealGeometry& rig,
0107                                                            size_t idt) const {
0108   DTSuperLayerId slId(id);
0109 
0110   // r-phi  dimension - different in different chambers
0111   // z      dimension - constant 126.8 cm
0112   // radial thickness - almost constant about 5 cm
0113 
0114   // Ok this is the slayer position...
0115   RCPPlane surf(
0116       plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds(++rig.shapeStart(idt))));
0117 
0118   DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
0119 
0120   // cout << "adding slayer " << slayer->id() << " to chamber "<<  chamber->id() << endl;
0121   assert(chamber);
0122   chamber->add(slayer);
0123   return slayer;
0124 }
0125 
0126 DTLayer* DTGeometryBuilderFromCondDB::buildLayer(DTSuperLayer* sl,
0127                                                  const DetId& id,
0128                                                  const RecoIdealGeometry& rig,
0129                                                  size_t idt) const {
0130   DTLayerId layId(id);
0131 
0132   // Layer specific parameter (size)
0133   // r-phi  dimension - different in different chambers
0134   // z      dimension - constant 126.8 cm
0135   // radial thickness - almost constant about 20 cm
0136 
0137   auto shapeStartPtr = rig.shapeStart(idt);
0138   RCPPlane surf(
0139       plane(rig.tranStart(idt), rig.rotStart(idt), dtGeometryBuilder::getRecPlaneBounds((shapeStartPtr + 1))));
0140 
0141   // Loop on wires
0142   int firstWire = static_cast<int>(*(shapeStartPtr + 4));       //par[4]);
0143   int WCounter = static_cast<int>(*(shapeStartPtr + 5));        //par[5]);
0144   double sensibleLength = convertMmToCm(*(shapeStartPtr + 6));  //par[6] in cm;
0145   DTTopology topology(firstWire, WCounter, sensibleLength);
0146 
0147   DTLayerType layerType;
0148 
0149   DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
0150   // cout << "adding layer " << layer->id() << " to sl "<<  sl->id() << endl;
0151 
0152   assert(sl);
0153   sl->add(layer);
0154   return layer;
0155 }
0156 
0157 DTGeometryBuilderFromCondDB::RCPPlane DTGeometryBuilderFromCondDB::plane(const vector<double>::const_iterator tranStart,
0158                                                                          const vector<double>::const_iterator rotStart,
0159                                                                          Bounds* bounds) const {
0160   // extract the position
0161   const Surface::PositionType posResult(*(tranStart), *(tranStart + 1), *(tranStart + 2));
0162   // now the rotation
0163   Surface::RotationType rotResult(*(rotStart + 0),
0164                                   *(rotStart + 1),
0165                                   *(rotStart + 2),
0166                                   *(rotStart + 3),
0167                                   *(rotStart + 4),
0168                                   *(rotStart + 5),
0169                                   *(rotStart + 6),
0170                                   *(rotStart + 7),
0171                                   *(rotStart + 8));
0172 
0173   return RCPPlane(new Plane(posResult, rotResult, bounds));
0174 }