test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCGeometryBuilderFromCondDB.cc
Go to the documentation of this file.
1 
8 
12 
16 
19 
21 
22 #include "CLHEP/Units/GlobalSystemOfUnits.h"
23 
24 #include <iostream>
25 #include <algorithm>
26 
28  theComp11Flag(comp11)
29 { }
30 
32 { }
33 
35 {
36  const std::vector<DetId>& detids(rgeo.detIds());
38 
40  std::vector<double>::const_iterator tranStart;
41  std::vector<double>::const_iterator shapeStart;
42  std::vector<double>::const_iterator rotStart;
43  std::vector<std::string>::const_iterator strStart;
44 
45  for (unsigned int id=0; id<detids.size(); id++){
46 
47  RPCDetId rpcid(detids[id]);
48  RPCDetId chid(rpcid.region(),rpcid.ring(),rpcid.station(),
49  rpcid.sector(),rpcid.layer(),rpcid.subsector(),0);
50 
51  tranStart=rgeo.tranStart(id);
52  shapeStart=rgeo.shapeStart(id);
53  rotStart=rgeo.rotStart(id);
54  strStart=rgeo.strStart(id);
55  name=*(strStart);
56 
57  Surface::PositionType pos(*(tranStart)/cm,*(tranStart+1)/cm, *(tranStart+2)/cm);
58  // CLHEP way
59  Surface::RotationType rot(*(rotStart+0),*(rotStart+1),*(rotStart+2),
60  *(rotStart+3),*(rotStart+4),*(rotStart+5),
61  *(rotStart+6),*(rotStart+7),*(rotStart+8));
62 
63  std::vector<float> pars;
64  RPCRollSpecs* rollspecs= 0;
65  Bounds* bounds = 0;
66 
67  // if (dpar.size()==4){
68  if ( rgeo.shapeEnd(id) - shapeStart == 4 ) {
69  float width = *(shapeStart+0)/cm;
70  float length = *(shapeStart+1)/cm;
71  float thickness = *(shapeStart+2)/cm;
72  float nstrip = *(shapeStart+3);
73  //RectangularPlaneBounds*
74  bounds =
75  new RectangularPlaneBounds(width,length,thickness);
76  pars.push_back(width);
77  pars.push_back(length);
78  pars.push_back(nstrip);
79 
80  if (!theComp11Flag) {
81  //Correction of the orientation to get the REAL geometry.
82  //Change of axes for the +z part only.
83  //Including the 0 whell
84  if ( *(tranStart+2) > -1500.) { //tran[2] >-1500. ){
85  Basic3DVector<float> newX(-1.,0.,0.);
86  Basic3DVector<float> newY(0.,-1.,0.);
87  Basic3DVector<float> newZ(0.,0.,1.);
88  rot.rotateAxes (newX, newY,newZ);
89  }
90  }
91 
92 
93  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCBarrel,name,pars);
94 
95 
96  }else{
97  float be = *(shapeStart+0)/cm;
98  float te = *(shapeStart+1)/cm;
99  float ap = *(shapeStart+2)/cm;
100  float ti = *(shapeStart+3)/cm;
101  float nstrip = *(shapeStart+4);
102  // TrapezoidalPlaneBounds*
103  bounds =
104  new TrapezoidalPlaneBounds(be,te,ap,ti);
105  pars.push_back(be); //b/2;
106  pars.push_back(te); //B/2;
107  pars.push_back(ap); //h/2;
108  pars.push_back(nstrip);
109 
110  rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCEndcap,name,pars);
111 
112  //Change of axes for the forward
113  Basic3DVector<float> newX(1.,0.,0.);
114  Basic3DVector<float> newY(0.,0.,1.);
115  // if (tran[2] > 0. )
116  newY *= -1;
117  Basic3DVector<float> newZ(0.,1.,0.);
118  rot.rotateAxes (newX, newY,newZ);
119  }
120 
121  BoundPlane* bp = new BoundPlane(pos,rot,bounds);
123  RPCRoll* r=new RPCRoll(rpcid,surf,rollspecs);
124  geometry->add(r);
125 
126  std::list<RPCRoll *> rls;
127  if (chids.find(chid)!=chids.end()){
128  rls = chids[chid];
129  }
130  rls.push_back(r);
131  chids[chid]=rls;
132  }
133  // Create the RPCChambers and store them on the Geometry
134  for( std::map<RPCDetId, std::list<RPCRoll *> >::iterator ich=chids.begin();
135  ich != chids.end(); ich++){
136  RPCDetId chid = ich->first;
137  std::list<RPCRoll * > rls = ich->second;
138 
139  // compute the overall boundplane. At the moment we use just the last
140  // surface
141  BoundPlane* bp=0;
142  for(std::list<RPCRoll *>::iterator rl=rls.begin();
143  rl!=rls.end(); rl++){
144  const BoundPlane& bps = (*rl)->surface();
145  bp = const_cast<BoundPlane *>(&bps);
146  }
147 
149  // Create the chamber
150  RPCChamber* ch = new RPCChamber (chid, surf);
151  // Add the rolls to rhe chamber
152  for(std::list<RPCRoll *>::iterator rl=rls.begin();
153  rl!=rls.end(); rl++){
154  ch->add(*rl);
155  }
156  // Add the chamber to the geometry
157  geometry->add(ch);
158 
159  }
160  return geometry;
161 }
162 
163 
164 
void add(RPCRoll *rl)
Add Roll to the chamber which takes ownership.
Definition: RPCChamber.cc:48
RPCGeometry * build(const RecoIdealGeometry &rgeo)
std::map< RPCDetId, std::list< RPCRoll * > > chids
Plane BoundPlane
Definition: Plane.h:95
std::vector< double >::const_iterator rotStart(size_t ind) const
TkRotation & rotateAxes(const Basic3DVector< T > &newX, const Basic3DVector< T > &newY, const Basic3DVector< T > &newZ)
std::vector< std::string >::const_iterator strStart(size_t ind) const
int ring() const
Definition: RPCDetId.h:72
std::vector< double >::const_iterator tranStart(size_t ind) const
const std::vector< DetId > & detIds() const
int layer() const
Definition: RPCDetId.h:108
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
std::vector< double >::const_iterator shapeEnd(size_t ind) const
ESHandle< TrackerGeometry > geometry
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:114
std::vector< double >::const_iterator shapeStart(size_t ind) const
Definition: Bounds.h:22
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96