CMS 3D CMS Logo

Public Types | Public Member Functions | Private Types | Private Member Functions

DTGeometryParsFromDD Class Reference

#include <DTGeometryParsFromDD.h>

List of all members.

Public Types

enum  DTDetTag { DTChamberTag, DTSuperLayerTag, DTLayerTag }

Public Member Functions

void build (const DDCompactView *cview, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig)
 DTGeometryParsFromDD ()
 Constructor.
virtual ~DTGeometryParsFromDD ()
 Destructor.

Private Types

typedef std::pair< std::vector
< double >, std::vector
< double > > 
PosRotPair

Private Member Functions

void buildGeometry (DDFilteredView &fv, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
std::vector< double > extractParameters (DDFilteredView &fv) const
 get parameter also for boolean solid.
void insertChamber (DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
 create the chamber
void insertLayer (DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
 create the layer
void insertSuperLayer (DDFilteredView &fv, const std::string &type, const MuonDDDConstants &muonConstants, RecoIdealGeometry &rig) const
 create the SL
PosRotPair plane (const DDFilteredView &fv) const

Detailed Description

Build the DTGeometry from the DDD description.

Date:
2009/01/16 11:11:47
Revision:
1.1
Author:
Stefano Lacaprara <lacaprara@pd.infn.it> INFN LNL

Definition at line 27 of file DTGeometryParsFromDD.h.


Member Typedef Documentation

typedef std::pair<std::vector<double>, std::vector<double> > DTGeometryParsFromDD::PosRotPair [private]

Definition at line 63 of file DTGeometryParsFromDD.h.


Member Enumeration Documentation

Enumerator:
DTChamberTag 
DTSuperLayerTag 
DTLayerTag 

Definition at line 40 of file DTGeometryParsFromDD.h.


Constructor & Destructor Documentation

DTGeometryParsFromDD::DTGeometryParsFromDD ( )

Constructor.

Definition at line 34 of file DTGeometryParsFromDD.cc.

{}
DTGeometryParsFromDD::~DTGeometryParsFromDD ( ) [virtual]

Destructor.

Definition at line 36 of file DTGeometryParsFromDD.cc.

{}

Member Function Documentation

void DTGeometryParsFromDD::build ( const DDCompactView cview,
const MuonDDDConstants muonConstants,
RecoIdealGeometry rig 
)

Definition at line 39 of file DTGeometryParsFromDD.cc.

References DDFilteredView::addFilter(), DDSpecificsFilter::AND, align_tpl::filter, DDSpecificsFilter::matches, DDSpecificsFilter::setCriteria(), and relativeConstraints::value.

Referenced by DTRecoIdealDBLoader::beginRun().

                                                         {
  //  cout << "DTGeometryParsFromDD::build" << endl;
  //   static const string t0 = "DTGeometryParsFromDD::build";
  //   TimeMe timer(t0,true);

  std::string attribute = "MuStructure"; 
  std::string value     = "MuonBarrelDT";
  DDValue val(attribute, value, 0.0);

  // Asking only for the Muon DTs
  DDSpecificsFilter filter;
  filter.setCriteria(val,  // name & value of a variable 
                     DDSpecificsFilter::matches,
                     DDSpecificsFilter::AND, 
                     true, // compare strings otherwise doubles
                     true  // use merged-specifics or simple-specifics
                     );
  DDFilteredView fview(*cview);
  fview.addFilter(filter);
  buildGeometry(fview, muonConstants, rig);
  //cout << "RecoIdealGeometry " << rig.size() << endl;
}
void DTGeometryParsFromDD::buildGeometry ( DDFilteredView fv,
const MuonDDDConstants muonConstants,
RecoIdealGeometry rig 
) const [private]

Definition at line 65 of file DTGeometryParsFromDD.cc.

References DDfetch(), DDFilteredView::firstChild(), DDFilteredView::mergedSpecifics(), DDFilteredView::nextSibling(), DDFilteredView::parent(), and DDValue::strings().

                                                                       {
  // static const string t0 = "DTGeometryParsFromDD::buildGeometry";
  // TimeMe timer(t0,true);

  bool doChamber = fv.firstChild();

  // Loop on chambers
  int ChamCounter=0;
  while (doChamber){
    ChamCounter++;
    DDValue val("Type");
    const DDsvalues_type params(fv.mergedSpecifics());
    string type;
    if (DDfetch(&params,val)) type = val.strings()[0];
    // FIXME
    val=DDValue("FEPos");
    string FEPos;
    if (DDfetch(&params,val)) FEPos = val.strings()[0];
    insertChamber(fv,type, muonConstants,rig);

    // Loop on SLs
    bool doSL = fv.firstChild();
    int SLCounter=0;
    while (doSL) {
      SLCounter++;
      insertSuperLayer(fv, type, muonConstants,rig);

      bool doL = fv.firstChild();
      int LCounter=0;
      // Loop on SLs
      while (doL) {
        LCounter++;
        insertLayer(fv, type, muonConstants, rig);

        // fv.parent();
        doL = fv.nextSibling(); // go to next layer
      } // layers

      fv.parent();
      doSL = fv.nextSibling(); // go to next SL
    } // sls

    fv.parent();
    doChamber = fv.nextSibling(); // go to next chamber
  } // chambers
}
vector< double > DTGeometryParsFromDD::extractParameters ( DDFilteredView fv) const [private]

get parameter also for boolean solid.

Definition at line 203 of file DTGeometryParsFromDD.cc.

References funct::A, ddbox, DDFilteredView::logicalPart(), DDSolid::parameters(), DDSolid::shape(), DDLogicalPart::solid(), and DDBooleanSolid::solidA().

                                                                {
  vector<double> par;
  if (fv.logicalPart().solid().shape() != ddbox) {
    DDBooleanSolid bs(fv.logicalPart().solid());
    DDSolid A = bs.solidA();
    while (A.shape() != ddbox) {
      DDBooleanSolid bs(A);
      A = bs.solidA();
    }
    par=A.parameters();
  } else {
    par = fv.logicalPart().solid().parameters();
  }
  return par;
}
void DTGeometryParsFromDD::insertChamber ( DDFilteredView fv,
const std::string &  type,
const MuonDDDConstants muonConstants,
RecoIdealGeometry rig 
) const [private]

create the chamber

SL the definition of length, width, thickness depends on the local reference frame of the Det

Definition at line 114 of file DTGeometryParsFromDD.cc.

References stor::soaputils::extractParameters(), DDFilteredView::geoHistory(), MuonDDDNumbering::geoHistoryToBaseNumber(), DTNumberingScheme::getDetId(), RecoIdealGeometry::insert(), and findQualityFiles::size.

                                                                       {
  MuonDDDNumbering mdddnum (muonConstants);
  DTNumberingScheme dtnum (muonConstants);
  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
  DTChamberId detId(rawid);
  //cout << "inserting Chamber " << detId << endl;

  // Chamber specific parameter (size) 
  vector<double> par;
  par.push_back(DTChamberTag);
  vector<double> size= extractParameters(fv);
  par.insert(par.end(), size.begin(), size.end());

  // width is along local X
  // length is along local Y
  // thickness is long local Z

  PosRotPair posRot(plane(fv));

  rig.insert(rawid, posRot.first, posRot.second, par);
}
void DTGeometryParsFromDD::insertLayer ( DDFilteredView fv,
const std::string &  type,
const MuonDDDConstants muonConstants,
RecoIdealGeometry rig 
) const [private]

create the layer

Definition at line 163 of file DTGeometryParsFromDD.cc.

References DDFilteredView::copyno(), stor::soaputils::extractParameters(), DDFilteredView::firstChild(), DDFilteredView::geoHistory(), MuonDDDNumbering::geoHistoryToBaseNumber(), DTNumberingScheme::getDetId(), RecoIdealGeometry::insert(), DDFilteredView::nextSibling(), DDFilteredView::parent(), and findQualityFiles::size.

                                                                     {

  MuonDDDNumbering mdddnum(muonConstants);
  DTNumberingScheme dtnum(muonConstants);
  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
  DTLayerId layId(rawid);
  //cout << "inserting Layer " << layId << endl;

  // Layer specific parameter (size)
  vector<double> par;
  par.push_back(DTLayerTag);
  vector<double> size= extractParameters(fv);
  par.insert(par.end(), size.begin(), size.end());

  // Loop on wires
  bool doWire = fv.firstChild();
  int WCounter=0;
  int firstWire=fv.copyno();
  //float wireLength = par[1]/cm;
  while (doWire) {
    WCounter++;
    doWire = fv.nextSibling(); // next wire
  }
  vector<double> sensSize= extractParameters(fv);
  //int lastWire=fv.copyno();
  par.push_back(firstWire);
  par.push_back(WCounter);
  par.push_back(sensSize[1]);
  fv.parent();

  PosRotPair posRot(plane(fv));

  rig.insert(layId, posRot.first, posRot.second, par);

}
void DTGeometryParsFromDD::insertSuperLayer ( DDFilteredView fv,
const std::string &  type,
const MuonDDDConstants muonConstants,
RecoIdealGeometry rig 
) const [private]

create the SL

Definition at line 140 of file DTGeometryParsFromDD.cc.

References stor::soaputils::extractParameters(), DDFilteredView::geoHistory(), MuonDDDNumbering::geoHistoryToBaseNumber(), DTNumberingScheme::getDetId(), RecoIdealGeometry::insert(), and findQualityFiles::size.

                                                                          {

  MuonDDDNumbering mdddnum(muonConstants);
  DTNumberingScheme dtnum(muonConstants);
  int rawid = dtnum.getDetId(mdddnum.geoHistoryToBaseNumber(fv.geoHistory()));
  DTSuperLayerId slId(rawid);
  //cout << "inserting SuperLayer " << slId << endl;

  // Slayer specific parameter (size)
  vector<double> par;
  par.push_back(DTSuperLayerTag);
  vector<double> size= extractParameters(fv);
  par.insert(par.end(), size.begin(), size.end());

  // Ok this is the slayer position...
  PosRotPair posRot(plane(fv));

  rig.insert(slId, posRot.first, posRot.second, par);
}
DTGeometryParsFromDD::PosRotPair DTGeometryParsFromDD::plane ( const DDFilteredView fv) const [private]

Definition at line 220 of file DTGeometryParsFromDD.cc.

References DDFilteredView::rotation(), DDFilteredView::translation(), x, detailsBasic3DVector::y, and z.

                                                          {
  // extract the position
  const DDTranslation & trans(fv.translation());

  std::vector<double> gtran( 3 );
  gtran[0] = (float) 1.0 * (trans.x() / cm);
  gtran[1] = (float) 1.0 * (trans.y() / cm);
  gtran[2] = (float) 1.0 * (trans.z() / cm);

  // now the rotation
  //  DDRotationMatrix tmp = fv.rotation();
  // === DDD uses 'active' rotations - see CLHEP user guide ===
  //     ORCA uses 'passive' rotation. 
  //     'active' and 'passive' rotations are inverse to each other
  //  DDRotationMatrix tmp = fv.rotation();
  DDRotationMatrix rotation = fv.rotation();//REMOVED .Inverse();
  DD3Vector x, y, z;
  rotation.GetComponents(x,y,z);
//   std::cout << "INVERSE rotation by its own operator: "<< fv.rotation() << std::endl;
//   std::cout << "INVERSE rotation manually: "
//          << x.X() << ", " << x.Y() << ", " << x.Z() << std::endl
//          << y.X() << ", " << y.Y() << ", " << y.Z() << std::endl
//          << z.X() << ", " << z.Y() << ", " << z.Z() << std::endl;

  std::vector<double> grmat( 9 );
  grmat[0] = (float) 1.0 * x.X();
  grmat[1] = (float) 1.0 * x.Y();
  grmat[2] = (float) 1.0 * x.Z();

  grmat[3] = (float) 1.0 * y.X();
  grmat[4] = (float) 1.0 * y.Y();
  grmat[5] = (float) 1.0 * y.Z();

  grmat[6] = (float) 1.0 * z.X();
  grmat[7] = (float) 1.0 * z.Y();
  grmat[8] = (float) 1.0 * z.Z();

//   std::cout << "rotation by its own operator: "<< tmp << std::endl;
//   DD3Vector tx, ty,tz;
//   tmp.GetComponents(tx, ty, tz);
//   std::cout << "rotation manually: "
//          << tx.X() << ", " << tx.Y() << ", " << tx.Z() << std::endl
//          << ty.X() << ", " << ty.Y() << ", " << ty.Z() << std::endl
//          << tz.X() << ", " << tz.Y() << ", " << tz.Z() << std::endl;

  return pair<std::vector<double>, std::vector<double> >(gtran, grmat);
}