CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
GEMGeometryBuilderFromDDD Class Reference

#include <GEMGeometryBuilderFromDDD.h>

Public Member Functions

GEMGeometrybuild (const DDCompactView *cview, const MuonDDDConstants &muonConstants)
 
 GEMGeometryBuilderFromDDD ()
 
 ~GEMGeometryBuilderFromDDD ()
 

Private Member Functions

GEMGeometrybuildGeometry (DDFilteredView &fview, const MuonDDDConstants &muonConstants)
 

Private Attributes

std::map< GEMDetId,
std::vector< GEMDetId > > 
chids
 

Detailed Description

Build the GEMGeometry ftom the DDD description

Author
M. Maggi - INFN Bari

Definition at line 22 of file GEMGeometryBuilderFromDDD.h.

Constructor & Destructor Documentation

GEMGeometryBuilderFromDDD::GEMGeometryBuilderFromDDD ( )

Implementation of the GEM Geometry Builder from DDD

Author
Port of: MuDDDGEMBuilder (ORCA)
M. Maggi - INFN Bari

Definition at line 29 of file GEMGeometryBuilderFromDDD.cc.

30 { }
GEMGeometryBuilderFromDDD::~GEMGeometryBuilderFromDDD ( )

Definition at line 32 of file GEMGeometryBuilderFromDDD.cc.

33 { }

Member Function Documentation

GEMGeometry * GEMGeometryBuilderFromDDD::build ( const DDCompactView cview,
const MuonDDDConstants muonConstants 
)

Definition at line 35 of file GEMGeometryBuilderFromDDD.cc.

References DDFilteredView::addFilter(), AND, buildGeometry(), alcazmumu_cfi::filter, matches, DDSpecificsFilter::setCriteria(), AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

Referenced by GEMGeometryESModule::produce().

36 {
37  std::string attribute = "ReadOutName"; // could come from .orcarc
38  std::string value = "MuonGEMHits"; // could come from .orcarc
39  DDValue val(attribute, value, 0.0);
40 
41  // Asking only for the MuonGEM's
43  filter.setCriteria(val, // name & value of a variable
45  DDLogOp::AND,
46  true, // compare strings otherwise doubles
47  true // use merged-specifics or simple-specifics
48  );
49  DDFilteredView fview(*cview);
50  fview.addFilter(filter);
51 
52  return this->buildGeometry(fview, muonConstants);
53 }
GEMGeometry * buildGeometry(DDFilteredView &fview, const MuonDDDConstants &muonConstants)
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32
GEMGeometry * GEMGeometryBuilderFromDDD::buildGeometry ( DDFilteredView fview,
const MuonDDDConstants muonConstants 
)
private

Definition at line 55 of file GEMGeometryBuilderFromDDD.cc.

References GEMRing::add(), GEMStation::add(), GEMRegion::add(), GEMChamber::add(), GEMSuperChamber::add(), GEMGeometry::add(), GEMNumberingScheme::baseNumberToUnitNumber(), GEMGeometry::chamber(), GEMGeometry::chambers(), chambers, gather_cfg::cout, DDfetch(), DDValue::doubles(), GEMGeometry::etaPartition(), GEMGeometry::etaPartitions(), DDFilteredView::firstChild(), GeomDetEnumerators::GEM, DDFilteredView::geoHistory(), MuonDDDNumbering::geoHistoryToBaseNumber(), geometry, i, LogDebug, DDFilteredView::logicalPart(), CommPDSkim_cfg::maxStation, DDName::name(), mergeVDriftHistosByStation::name, DDBase< N, C >::name(), DDFilteredView::nextSibling(), AlCaHLTBitMon_ParallelJobs::p, DDSolid::parameters(), HLT_25ns14e33_v3_cff::region, relativeConstraints::ring, makeMuonMisalignmentScenario::rot, TkRotation< T >::rotateAxes(), DDFilteredView::rotation(), GEMStation::setName(), jetcorrextractor::sign(), DDLogicalPart::solid(), DDFilteredView::specifics(), relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, GEMGeometry::superChambers(), cond::to_string(), DDFilteredView::translation(), x, y, and z.

Referenced by build().

56 {
57  std::cout << "Building the geometry service" << std::endl;
58  LogDebug("GEMGeometryBuilderFromDDD") <<"Building the geometry service";
60 
61  LogDebug("GEMGeometryBuilderFromDDD") << "About to run through the GEM structure\n"
62  <<" First logical part "
63  <<fview.logicalPart().name().name();
64  bool doSubDets = fview.firstChild();
65  LogDebug("GEMGeometryBuilderFromDDD") << "doSubDets = " << doSubDets;
66 
67  LogDebug("GEMGeometryBuilderFromDDD") <<"start the loop";
68  int nChambers(0);
69  int maxStation(1);
70  while (doSubDets)
71  {
72  // Get the Base Muon Number
73  MuonDDDNumbering mdddnum(muonConstants);
74  LogDebug("GEMGeometryBuilderFromDDD") <<"Getting the Muon base Number";
75  MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
76 
77  LogDebug("GEMGeometryBuilderFromDDD") <<"Start the GEM Numbering Schema";
78  GEMNumberingScheme gemnum(muonConstants);
79 
80  GEMDetId rollDetId(gemnum.baseNumberToUnitNumber(mbn));
81  LogDebug("GEMGeometryBuilderFromDDD") << "GEM eta partition rawId: " << rollDetId.rawId() << ", detId: " << rollDetId;
82 
83  // chamber id for this partition. everything is the same; but partition number is 0.
84  GEMDetId chamberId(rollDetId.chamberId());
85  LogDebug("GEMGeometryBuilderFromDDD") << "GEM chamber rawId: " << chamberId.rawId() << ", detId: " << chamberId;
86  const int stationId(rollDetId.station());
87  if (stationId > maxStation) maxStation = stationId;
88 
89  if (rollDetId.roll()==1) ++nChambers;
90 
91  DDValue numbOfStrips("nStrips");
92  DDValue numbOfPads("nPads");
93 
94  std::vector<const DDsvalues_type* > specs(fview.specifics());
95  std::vector<const DDsvalues_type* >::iterator is = specs.begin();
96  double nStrips = 0., nPads = 0.;
97  for (;is != specs.end(); is++)
98  {
99  if (DDfetch( *is, numbOfStrips)) nStrips = numbOfStrips.doubles()[0];
100  if (DDfetch( *is, numbOfPads)) nPads = numbOfPads.doubles()[0];
101  }
102  LogDebug("GEMGeometryBuilderFromDDD")
103  << ((nStrips == 0. ) ? ("No nStrips found!!") : ("Number of strips: " + boost::lexical_cast<std::string>(nStrips)));
104  LogDebug("GEMGeometryBuilderFromDDD")
105  << ((nPads == 0. ) ? ("No nPads found!!") : ("Number of pads: " + boost::lexical_cast<std::string>(nPads)));
106 
107  std::vector<double> dpar=fview.logicalPart().solid().parameters();
108  std::string name = fview.logicalPart().name().name();
109  DDTranslation tran = fview.translation();
110  //removed .Inverse after comparing to DT...
111  DDRotationMatrix rota = fview.rotation();//.Inverse();
112  Surface::PositionType pos(tran.x()/cm, tran.y()/cm, tran.z()/cm);
113  // CLHEP way
114  // Surface::RotationType rot(rota.xx(),rota.xy(),rota.xz(),
115  // rota.yx(),rota.yy(),rota.yz(),
116  // rota.zx(),rota.zy(),rota.zz());
117 
118  //ROOT::Math way
119  DD3Vector x, y, z;
120  rota.GetComponents(x,y,z);
121  // doesn't this just re-inverse???
122  Surface::RotationType rot(float(x.X()), float(x.Y()), float(x.Z()),
123  float(y.X()), float(y.Y()), float(y.Z()),
124  float(z.X()), float(z.Y()), float(z.Z()));
125 
126  float be = dpar[4]/cm; // half bottom edge
127  float te = dpar[8]/cm; // half top edge
128  float ap = dpar[0]/cm; // half apothem
129  float ti = 0.4/cm; // half thickness
130 
131  // TrapezoidalPlaneBounds*
132  Bounds* bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
133 
134  std::vector<float> pars;
135  pars.push_back(be);
136  pars.push_back(te);
137  pars.push_back(ap);
138  pars.push_back(nStrips);
139  pars.push_back(nPads);
140 
141  LogDebug("GEMGeometryBuilderFromDDD")
142  << "GEM " << name << " par " << be << " " << te << " " << ap << " " << dpar[0];
143 
145 
146  //Change of axes for the forward
147  Basic3DVector<float> newX(1.,0.,0.);
148  Basic3DVector<float> newY(0.,0.,1.);
149  // if (tran.z() > 0. )
150  newY *= -1;
151  Basic3DVector<float> newZ(0.,1.,0.);
152  rot.rotateAxes (newX, newY, newZ);
153 
154  BoundPlane* bp = new BoundPlane(pos, rot, bounds);
156  GEMEtaPartition* gep = new GEMEtaPartition(rollDetId, surf, e_p_specs);
157 
158  // Add the eta partition to the geometry
159  geometry->add(gep);
160  // go to next layer
161  doSubDets = fview.nextSibling();
162  }
163 
164  auto& partitions(geometry->etaPartitions());
165  // build the chambers and add them to the geometry
166  std::vector<GEMDetId> vDetId;
167  vDetId.clear();
168  int oldRollNumber = 1;
169  for (unsigned i=1; i<=partitions.size(); ++i){
170  GEMDetId detId(partitions.at(i-1)->id());
171  const int rollNumber(detId.roll());
172  // new batch of eta partitions --> new chamber
173  if (rollNumber < oldRollNumber || i == partitions.size()) {
174  // don't forget the last partition for the last chamber
175  if (i == partitions.size()) vDetId.push_back(detId);
176 
177  GEMDetId fId(vDetId.front());
178  GEMDetId chamberId(fId.chamberId());
179  // compute the overall boundplane using the first eta partition
180  const GEMEtaPartition* p(geometry->etaPartition(fId));
181  const BoundPlane& bps = p->surface();
182  BoundPlane* bp = const_cast<BoundPlane*>(&bps);
184 
185  GEMChamber* ch = new GEMChamber(chamberId, surf);
186  LogDebug("GEMGeometryBuilderFromDDD") << "Creating chamber " << chamberId << " with " << vDetId.size() << " eta partitions" << std::endl;
187 
188  for(auto id : vDetId){
189  LogDebug("GEMGeometryBuilderFromDDD") << "Adding eta partition " << id << " to GEM chamber" << std::endl;
190  ch->add(const_cast<GEMEtaPartition*>(geometry->etaPartition(id)));
191  }
192 
193  LogDebug("GEMGeometryBuilderFromDDD") << "Adding the chamber to the geometry" << std::endl;
194  geometry->add(ch);
195  vDetId.clear();
196  }
197  vDetId.push_back(detId);
198  oldRollNumber = rollNumber;
199  }
200 
201  auto& chambers(geometry->chambers());
202  // construct super chambers
203  for (unsigned i=0; i<chambers.size(); ++i){
204  const BoundPlane& bps = chambers.at(i)->surface();
205  BoundPlane* bp = const_cast<BoundPlane*>(&bps);
207  GEMDetId detIdL1(chambers.at(i)->id());
208  if (detIdL1.layer()==2) continue;
209  GEMDetId detIdL2(detIdL1.region(),detIdL1.ring(),detIdL1.station(),2,detIdL1.chamber(),0);
210  auto ch2 = geometry->chamber(detIdL2);
211 
212  LogDebug("GEMGeometryBuilderFromDDD") << "First chamber for super chamber: " << detIdL1 << std::endl;
213  LogDebug("GEMGeometryBuilderFromDDD") << "Second chamber for super chamber: " << detIdL2 << std::endl;
214 
215  LogDebug("GEMGeometryBuilderFromDDD") << "Creating new GEM super chamber out of chambers." << std::endl;
216  GEMSuperChamber* sch = new GEMSuperChamber(detIdL1, surf);
217  sch->add(const_cast<GEMChamber*>(chambers.at(i)));
218  sch->add(const_cast<GEMChamber*>(ch2));
219 
220  LogDebug("GEMGeometryBuilderFromDDD") << "Adding the super chamber to the geometry." << std::endl;
221  geometry->add(sch);
222  }
223 
224  auto& superChambers(geometry->superChambers());
225  // construct the regions, stations and rings.
226  for (int re = -1; re <= 1; re = re+2) {
227  GEMRegion* region = new GEMRegion(re);
228  for (int st=1; st<=maxStation; ++st) {
229  GEMStation* station = new GEMStation(re, st);
230  std::string sign( re==-1 ? "-" : "");
231  std::string name("GE" + sign + std::to_string(st) + "/1");
232  // Closest (furthest) super chambers in GE2/1 are called GE2/1s (GE2/1l)
233  if (st==2) name = "GE" + sign + std::to_string(st) + "/1s";
234  if (st==3) name = "GE" + sign + std::to_string(st-1) + "/1l";
235  station->setName(name);
236  for (int ri=1; ri<=1; ++ri) {
237  GEMRing* ring = new GEMRing(re, st, ri);
238  for (unsigned sch=0; sch<superChambers.size(); ++sch){
239  const GEMDetId detId(superChambers.at(sch)->id());
240  if (detId.region() != re || detId.station() != st || detId.ring() != ri) continue;
241  ring->add(const_cast<GEMSuperChamber*>(superChambers.at(sch)));
242  LogDebug("GEMGeometryBuilderFromDDD") << "Adding super chamber " << detId << " to ring: "
243  << "re " << re << " st " << st << " ri " << ri << std::endl;
244  }
245  LogDebug("GEMGeometryBuilderFromDDD") << "Adding ring " << ri << " to station " << "re " << re << " st " << st << std::endl;
246  station->add(const_cast<GEMRing*>(ring));
247  geometry->add(const_cast<GEMRing*>(ring));
248  }
249  LogDebug("GEMGeometryBuilderFromDDD") << "Adding station " << st << " to region " << re << std::endl;
250  region->add(const_cast<GEMStation*>(station));
251  geometry->add(const_cast<GEMStation*>(station));
252  }
253  LogDebug("GEMGeometryBuilderFromDDD") << "Adding region " << re << " to the geometry " << std::endl;
254  geometry->add(const_cast<GEMRegion*>(region));
255  }
256  return geometry;
257 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:150
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
const N & name() const
Definition: DDBase.h:78
bool nextSibling()
set the current node to the next sibling ...
const DDRotationMatrix & rotation() const
The absolute rotation of the current node.
double sign(double x)
void add(GEMChamber *ch)
Add chamber to the super chamber which takes ownership.
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
void add(GEMRing *ring)
Add ring to the station which takes ownership.
Definition: GEMStation.cc:26
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:103
void add(GEMSuperChamber *ch)
Add super chamber to the ring which takes ownership.
Definition: GEMRing.cc:22
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
std::string to_string(const T &t)
Definition: Logger.cc:26
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
A DD Translation is currently implemented with Root Vector3D.
Definition: DDTranslation.h:6
const std::vector< const GEMEtaPartition * > & etaPartitions() const
Return a vector of all GEM eta partitions.
Definition: GEMGeometry.cc:63
void add(GEMEtaPartition *roll)
Add EtaPartition to the chamber which takes ownership.
Definition: GEMChamber.cc:27
void setName(std::string name)
Set the station name.
Definition: GEMStation.cc:75
const std::vector< const GEMSuperChamber * > & superChambers() const
Return a vector of all GEM super chambers.
Definition: GEMGeometry.cc:55
void add(GEMRegion *region)
Add a GEMRegion to the Geometry.
Definition: GEMGeometry.cc:108
const GEMChamber * chamber(GEMDetId id) const
Definition: GEMGeometry.cc:99
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:59
ESHandle< TrackerGeometry > geometry
bool firstChild()
set the current node to the first child ...
void add(GEMStation *st)
Add station to the region which takes ownership.
Definition: GEMRegion.cc:25
tuple cout
Definition: gather_cfg.py:121
Definition: Bounds.h:22
const DDTranslation & translation() const
The absolute translation of the current node.
std::vector< const DDsvalues_type * > specifics() const
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
const std::string & name() const
Returns the name.
Definition: DDName.cc:87

Member Data Documentation

std::map<GEMDetId,std::vector<GEMDetId> > GEMGeometryBuilderFromDDD::chids
private

Definition at line 34 of file GEMGeometryBuilderFromDDD.h.