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
CSCGeometryBuilder Class Reference

#include <CSCGeometryBuilder.h>

Public Member Functions

void build (boost::shared_ptr< CSCGeometry > theGeometry, const RecoIdealGeometry &rig, const CSCRecoDigiParameters &cscpars)
 Build the geometry. More...
 
 CSCGeometryBuilder ()
 Constructor. More...
 
virtual ~CSCGeometryBuilder ()
 Destructor. More...
 

Private Member Functions

void buildChamber (boost::shared_ptr< CSCGeometry > theGeometry, CSCDetId chamberId, const std::vector< float > &fpar, const std::vector< float > &fupar, const std::vector< float > &gtran, const std::vector< float > &grmat, const CSCWireGroupPackage &wg)
 Build one CSC chamber, and its component layers, and add them to the geometry. More...
 

Private Attributes

const std::string myName
 

Detailed Description

Build the CSCGeometry from the DDD description.

Author
Tim Cox

Definition at line 22 of file CSCGeometryBuilder.h.

Constructor & Destructor Documentation

CSCGeometryBuilder::CSCGeometryBuilder ( )

Constructor.

Definition at line 18 of file CSCGeometryBuilder.cc.

18 : myName("CSCGeometryBuilder"){}
const std::string myName
CSCGeometryBuilder::~CSCGeometryBuilder ( )
virtual

Destructor.

Definition at line 21 of file CSCGeometryBuilder.cc.

21 {}

Member Function Documentation

void CSCGeometryBuilder::build ( boost::shared_ptr< CSCGeometry theGeometry,
const RecoIdealGeometry rig,
const CSCRecoDigiParameters cscpars 
)

Build the geometry.

Definition at line 24 of file CSCGeometryBuilder.cc.

References CSCWireGroupPackage::alignmentPinToFirstWire, buildChamber(), CSCWireGroupPackage::consecutiveGroups, fwrapper::cs, CSCDetId, cond::rpcobgas::detid, RecoIdealGeometry::detIds(), i, CSCWireGroupPackage::lengthOfWirePlane, LogTrace, myName, CSCWireGroupPackage::narrowWidthOfWirePlane, CSCWireGroupPackage::numberOfGroups, CSCRecoDigiParameters::pChamberType, CSCRecoDigiParameters::pfupars, CSCRecoDigiParameters::pUserParOffset, CSCRecoDigiParameters::pUserParSize, CSCDetId::ring(), RecoIdealGeometry::rotEnd(), RecoIdealGeometry::rotStart(), RecoIdealGeometry::shapeEnd(), RecoIdealGeometry::shapeStart(), CSCDetId::station(), RecoIdealGeometry::tranEnd(), RecoIdealGeometry::tranStart(), CSCChamberSpecs::whatChamberType(), CSCWireGroupPackage::wideWidthOfWirePlane, CSCWireGroupPackage::wiresInEachGroup, and CSCWireGroupPackage::wireSpacing.

Referenced by CSCGeometryBuilderFromDDD::build(), and CSCGeometryESModule::initCSCGeometry_().

26  {
27 
28  // CSCGeometry* theGeometry = new CSCGeometry;
29 
30  std::vector<float> fpar;
31  std::vector<float> gtran;
32  std::vector<float> grmat;
33  std::vector<float> fupar;
34  std::vector<double>::const_iterator it, endIt;
35  const std::vector<DetId>& detids(rig.detIds());
36 
37  for ( size_t idt = 0; idt < detids.size(); ++idt) {
38  CSCDetId detid = CSCDetId( detids[idt] );
39  // int jendcap = detid.endcap();
40  int jstation = detid.station();
41  int jring = detid.ring();
42  // int jchamber = detid.chamber();
43 
44  endIt = rig.shapeEnd(idt);
45  fpar.clear();
46  for ( it = rig.shapeStart(idt); it != endIt; ++it) {
47  fpar.push_back( (float)(*it) );
48  }
49 
50  gtran.clear();
51  endIt = rig.tranEnd(idt);
52  for ( it = rig.tranStart(idt); it != endIt; ++it ) {
53  gtran.push_back((float)(*it));
54  }
55  grmat.clear();
56  endIt = rig.rotEnd(idt);
57  for ( it = rig.rotStart(idt) ; it != endIt; ++it ) {
58  grmat.push_back((float)(*it));
59  }
60 
61  // get the chamber type from existing info
62  int chamberType = CSCChamberSpecs::whatChamberType( jstation, jring );
63  // std::cout << "Chamber type = " << chamberType << std::endl;
64  size_t cs = 0;
65  // assert ( cscpars.pCSCDetIds.size() != 0 );
66  assert ( cscpars.pChamberType.size() != 0 );
67  // while (cs < cscpars.pCSCDetIds.size() && detid != cscpars.pCSCDetIds[cs]) {
68  while (cs < cscpars.pChamberType.size() && chamberType != cscpars.pChamberType[cs]) {
69  ++cs;
70  }
71  // assert ( cs != cscpars.pCSCDetIds.size() );
72  assert ( cs != cscpars.pChamberType.size() );
73 
74  // check the existence of the specs for this type WHY? Remove it...
75  // const CSCChamberSpecs* aSpecs = theGeometry->findSpecs( chamberType );
76  size_t fu, numfuPars;
78  fu = cscpars.pUserParOffset[cs];
79  numfuPars = fu + 1 + size_t(cscpars.pfupars[fu]);
80 
81  // upars from db are now uparvals + wg info so we need to unwrap only part here first...
82  LogTrace(myName) << myName << ": I think I have " << cscpars.pUserParSize[cs] << " values in pfupars (uparvals)." << std::endl;
83  LogTrace(myName) << myName << ": For fupar I will start at " << cscpars.pUserParOffset[cs] + 1
84  << " in pfupars and go to " << numfuPars << "." << std::endl;
85  // if ( aSpecs == 0 ) {
86  for ( ++fu; fu < numfuPars; ++fu ) {
87  LogTrace(myName) << myName << ": pfupars[" << fu << "]=" << cscpars.pfupars[fu] << std::endl;
88  fupar.push_back(cscpars.pfupars[fu]);
89  }
90 // } else {
91 // fu = fu + numfuPars + 1;
92 // }
93  // now, we need to start from "here" at fu to go on and build wg...
94  wg.wireSpacing = cscpars.pfupars[fu++];
95  wg.alignmentPinToFirstWire = cscpars.pfupars[fu++];
96  wg.numberOfGroups = int(cscpars.pfupars[fu++]);
97  wg.narrowWidthOfWirePlane = cscpars.pfupars[fu++];
98  wg.wideWidthOfWirePlane = cscpars.pfupars[fu++];
99  wg.lengthOfWirePlane = cscpars.pfupars[fu++];
100  size_t numgrp = static_cast<size_t>(cscpars.pfupars[fu]);
101  size_t maxFu = fu + 1 + numgrp;
102  fu++;
103  for ( ;fu < maxFu; ++fu ) {
104  wg.wiresInEachGroup.push_back(int(cscpars.pfupars[fu]));
105  }
106  maxFu = fu + numgrp;
107  //stupid comment // MEC: 2008-04-30: decided I need to have wg every time unless whole wg idea is re-worked.
108  // std::cout << " fu = " << fu << " going to maxFu = " << maxFu << std::endl;
109  for ( ;fu < maxFu; ++fu ) {
110  wg.consecutiveGroups.push_back(int(cscpars.pfupars[fu]));
111  }
112 
113  if ( wg.numberOfGroups != 0 ) {
114  LogTrace(myName) << myName << ": TotNumWireGroups = " << wg.numberOfGroups ;
115  LogTrace(myName) << myName << ": WireSpacing = " << wg.wireSpacing ;
116  LogTrace(myName) << myName << ": AlignmentPinToFirstWire = " << wg.alignmentPinToFirstWire ;
117  LogTrace(myName) << myName << ": Narrow width of wire plane = " << wg.narrowWidthOfWirePlane ;
118  LogTrace(myName) << myName << ": Wide width of wire plane = " << wg.wideWidthOfWirePlane ;
119  LogTrace(myName) << myName << ": Length in y of wire plane = " << wg.lengthOfWirePlane ;
120  LogTrace(myName) << myName << ": wg.consecutiveGroups.size() = " << wg.consecutiveGroups.size() ;
121  LogTrace(myName) << myName << ": wg.wiresInEachGroup.size() = " << wg.wiresInEachGroup.size() ;
122  LogTrace(myName) << myName << ": \tNumGroups\tWiresInGroup" ;
123  for (size_t i = 0; i < wg.consecutiveGroups.size(); i++) {
124  LogTrace(myName) << myName << " \t" << wg.consecutiveGroups[i] << "\t\t" << wg.wiresInEachGroup[i] ;
125  }
126  } else {
127  LogTrace(myName) << myName << ": DDD is MISSING SpecPars for wire groups" ;
128  }
129  LogTrace(myName) << myName << ": end of wire group info. " ;
130 
131  // CSCWireGroupPackage wg = cscpars.pWGPs[cs];
132  // Are we going to apply centre-to-intersection offsets, even if values exist in the specs file?
133  if ( !theGeometry->centreTIOffsets() ) fupar[30] = 0.; // reset to zero if flagged 'off'
134 
135  buildChamber (theGeometry, detid, fpar, fupar, gtran, grmat, wg ); //, cscpars.pWGPs[cs] );
136  fupar.clear();
137  }
138  // return theGeometry;
139 }
int i
Definition: DBlmapReader.cc:9
auto_ptr< ClusterSequence > cs
std::vector< double >::const_iterator rotEnd(size_t ind) const
static int whatChamberType(int istation, int iring)
std::vector< double >::const_iterator rotStart(size_t ind) const
void buildChamber(boost::shared_ptr< CSCGeometry > theGeometry, CSCDetId chamberId, const std::vector< float > &fpar, const std::vector< float > &fupar, const std::vector< float > &gtran, const std::vector< float > &grmat, const CSCWireGroupPackage &wg)
Build one CSC chamber, and its component layers, and add them to the geometry.
std::vector< float > pfupars
std::vector< double >::const_iterator tranEnd(size_t ind) const
std::vector< int > pChamberType
std::vector< double >::const_iterator tranStart(size_t ind) const
std::vector< int > pUserParOffset
const std::string myName
#define LogTrace(id)
const std::vector< DetId > & detIds() const
int ring() const
Definition: CSCDetId.h:77
std::vector< int > pUserParSize
std::vector< double >::const_iterator shapeEnd(size_t ind) const
std::vector< double >::const_iterator shapeStart(size_t ind) const
int station() const
Definition: CSCDetId.h:88
void CSCGeometryBuilder::buildChamber ( boost::shared_ptr< CSCGeometry theGeometry,
CSCDetId  chamberId,
const std::vector< float > &  fpar,
const std::vector< float > &  fupar,
const std::vector< float > &  gtran,
const std::vector< float > &  grmat,
const CSCWireGroupPackage wg 
)
private

Build one CSC chamber, and its component layers, and add them to the geometry.

Definition at line 141 of file CSCGeometryBuilder.cc.

References Surface::bounds(), Plane::build(), CSCDetId::chamber(), gather_cfg::cout, CSCDetId, CSCDetId::endcap(), CSCChamberSpecs::evenLayerGeometry(), relativeConstraints::geom, j, CSCDetId::layer(), LogTrace, myName, CSCChamberSpecs::oddLayerGeometry(), TrapezoidalPlaneBounds::parameters(), CSCDetId::ring(), TkRotation< T >::rotateAxes(), CSCDetId::station(), GeomDet::surface(), Bounds::thickness(), and CSCChamberSpecs::whatChamberType().

Referenced by build().

149  {
150 
151  LogTrace(myName) << myName << ": entering buildChamber" ;
152 
153  int jend = chamberId.endcap();
154  int jstat = chamberId.station();
155  int jring = chamberId.ring();
156  int jch = chamberId.chamber();
157  int jlay = chamberId.layer();
158 
159  if (jlay != 0 ) edm::LogWarning(myName) << "Error! CSCGeometryBuilderFromDDD was fed layer id = " << jlay << "\n";
160 
161  const size_t kNpar = 4;
162  if ( fpar.size() != kNpar )
163  edm::LogError(myName) << "Error, expected npar="
164  << kNpar << ", found npar=" << fpar.size() << std::endl;
165 
166  LogTrace(myName) << myName << ": E" << jend << " S" << jstat << " R" << jring <<
167  " C" << jch << " L" << jlay ;
168  LogTrace(myName) << myName << ": npar=" << fpar.size() << " hB=" << fpar[0]
169  << " hT=" << fpar[1] << " hD=" << fpar[2] << " hH=" << fpar[3] ;
170  LogTrace(myName) << myName << ": gtran[0,1,2]=" << gtran[0] << " " << gtran[1] << " " << gtran[2] ;
171  LogTrace(myName) << myName << ": grmat[0-8]=" << grmat[0] << " " << grmat[1] << " " << grmat[2] << " "
172  << grmat[3] << " " << grmat[4] << " " << grmat[5] << " "
173  << grmat[6] << " " << grmat[7] << " " << grmat[8] ;
174  LogTrace(myName) << myName << ": nupar=" << fupar.size() << " upar[0]=" << fupar[0]
175  << " upar[" << fupar.size()-1 << "]=" << fupar[fupar.size()-1];
176 
177 
178  const CSCChamber* chamber = theGeometry->chamber( chamberId );
179  if ( chamber ){
180  }
181  else { // this chamber not yet built/stored
182 
183  LogTrace(myName) << myName <<": CSCChamberSpecs::build requested for ME" << jstat << jring ;
184  int chamberType = CSCChamberSpecs::whatChamberType( jstat, jring );
185  const CSCChamberSpecs* aSpecs = theGeometry->findSpecs( chamberType );
186 // // CSCChamberSpecs* aSpecs = CSCChamberSpecs::specs( chamberType );
187 // if ( aSpecs == 0 ) aSpecs = theGeometry->buildSpecs( chamberType, fpar, fupar, wg );
188  // aSpecs = CSCChamberSpecs::build( chamberType, fpar, fupar, wg );
189  if ( fupar.size() != 0 && aSpecs == 0 ) {
190  // make new one:
191  aSpecs = theGeometry->buildSpecs (chamberType, fpar, fupar, wg);
192  } else if ( fupar.size() == 0 && aSpecs == 0 ) {
193  std::cout << "SHOULD BE THROW? Error, wg and/or fupar size are 0 BUT this Chamber Spec has not been built!" << std::endl;
194  }
195 // else if (fupar.size() != 0 && aSpecs != 0 ) {
196 // std::cout << "SHOULD BE THROW? Error, a Chamber Specs was found AND still the fupar and/or wg were/was non-zero! " << std::endl;
197 // }
198 
199 
200  // Build a Transformation out of GEANT gtran and grmat...
201  // These are used to transform a point in the local reference frame
202  // of a subdetector to the global frame of CMS by
203  // (grmat)^(-1)*local + (gtran)
204  // The corresponding transformation from global to local is
205  // (grmat)*(global - gtran)
206 
207  Surface::RotationType aRot( grmat[0], grmat[1], grmat[2],
208  grmat[3], grmat[4], grmat[5],
209  grmat[6], grmat[7], grmat[8] );
210 
211  // This rotation from GEANT considers the detector face as the x-z plane.
212  // We want this to be the local x-y plane.
213  // Furthermore, the -z_global endcap has LH local coordinates, since it is built
214  // in GEANT as a *reflection* of the +z_global endcap.
215  // So we need to rotate, and in -z flip local x.
216 
217  // aRot.rotateAxes will transform aRot in place so that it becomes
218  // applicable to the new local coordinates: detector face in x-y plane
219  // looking out along z, in either endcap.
220 
221  // The interface for rotateAxes specifies 'new' X,Y,Z but the
222  // implementation deals with them as the 'old'.
223 
224  Basic3DVector<float> oldX( 1., 0., 0. );
225  Basic3DVector<float> oldY( 0., 0., -1. );
226  Basic3DVector<float> oldZ( 0., 1., 0. );
227 
228  if ( gtran[2]<0. ) oldX *= -1;
229 
230  aRot.rotateAxes( oldX, oldY, oldZ );
231 
232  // Need to know z of layers w.r.t to z of centre of chamber.
233 
234  float frameThickness = fupar[31]/10.; // mm -> cm
235  float gapThickness = fupar[32]/10.; // mm -> cm
236  float panelThickness = fupar[33]/10.; // mm -> cm
237  float zAverageAGVtoAF = fupar[34]/10.; // mm -> cm
238 
239  float layerThickness = gapThickness; // consider the layer to be the gas gap
240  float layerSeparation = gapThickness + panelThickness; // centre-to-centre of neighbouring layers
241 
242  float chamberThickness = 7.*panelThickness + 6.*gapThickness + 2.*frameThickness ; // chamber frame thickness
243  float hChamberThickness = chamberThickness/2.; // @@ should match value returned from DDD directly
244 
245  // distAverageAGVtoAF is offset between centre of chamber (AF) and (L1+L6)/2 (average AGVs)
246  // where AF = AluminumFrame and AGV=ActiveGasVolume (volume names in DDD).
247  // It is signed based on global z values: zc - (zl1+zl6)/2
248 
249  // Local z values w.r.t. AF...
250  // z of wires in layer 1 = z_w1 = +/- zAverageAGVtoAF + 2.5*layerSeparation; // layer 1 is at most +ve local z
251  // The sign in '+/-' depends on relative directions of local and global z.
252  // It is '-' if they are the same direction, and '+' if opposite directions.
253  // z of wires in layer N = z_wN = z_w1 - (N-1)*layerSeparation;
254  // z of strips in layer N = z_sN = z_wN + gapThickness/2.; @@ BEWARE: need to check if it should be '-gapThickness/2' !
255 
256  // Set dimensions of trapezoidal chamber volume
257  // N.B. apothem is 4th in fpar but 3rd in ctor
258 
259  // hChamberThickness and fpar[2] should be the same - but using the above value at least shows
260  // how chamber structure works
261 
262  // TrapezoidalPlaneBounds* bounds = new TrapezoidalPlaneBounds( fpar[0], fpar[1], fpar[3], fpar[2] );
263  TrapezoidalPlaneBounds* bounds = new TrapezoidalPlaneBounds( fpar[0], fpar[1], fpar[3], hChamberThickness );
264 
265  // Centre of chamber in z is specified in DDD
266  Surface::PositionType aVec( gtran[0], gtran[1], gtran[2] );
267 
268  Plane::PlanePointer plane = Plane::build(aVec, aRot, bounds);
269 
270  CSCChamber* chamber = new CSCChamber( plane, chamberId, aSpecs );
271  theGeometry->addChamber( chamber );
272 
273  LogTrace(myName) << myName << ": Create chamber E" << jend << " S" << jstat
274  << " R" << jring << " C" << jch
275  << " z=" << gtran[2]
276  << " t/2=" << fpar[2] << " (DDD) or " << hChamberThickness
277  << " (specs) adr=" << chamber ;
278 
279  // Create the component layers of this chamber
280  // We're taking the z as the z of the wire plane within the layer (middle of gas gap)
281 
282  // Specify global z of layer by offsetting from centre of chamber: since layer 1
283  // is nearest to IP in stations 1/2 but layer 6 is nearest in stations 3/4,
284  // we need to adjust sign of offset appropriately...
285  int localZwrtGlobalZ = +1;
286  if ( (jend==1 && jstat<3 ) || ( jend==2 && jstat>2 ) ) localZwrtGlobalZ = -1;
287  int globalZ = +1;
288  if ( jend == 2 ) globalZ = -1;
289 // int localZwrtGlobalZ = +1;
290 // if ( (jend==1 && jstat<3 ) || ( jend==2 && jstat>2 ) ) localZwrtGlobalZ = -1;
291 
292 
293  LogTrace(myName) << myName << ": layerSeparation=" << layerSeparation
294  << ", zAF-zAverageAGV=" << zAverageAGVtoAF
295  << ", localZwrtGlobalZ=" << localZwrtGlobalZ
296  << ", gtran[2]=" << gtran[2] ;
297 
298  for ( short j = 1; j <= 6; ++j ) {
299 
300  CSCDetId layerId = CSCDetId( jend, jstat, jring, jch, j );
301 
302  // extra-careful check that we haven't already built this layer
303  const CSCLayer* cLayer = dynamic_cast<const CSCLayer*> (theGeometry->idToDet( layerId ) );
304 
305  if ( cLayer == 0 ) {
306 
307  // build the layer - need the chamber's specs and an appropriate layer-geometry
308  const CSCChamberSpecs* aSpecs = chamber->specs();
309  const CSCLayerGeometry* geom =
310  (j%2 != 0) ? aSpecs->oddLayerGeometry( jend ) :
311  aSpecs->evenLayerGeometry( jend );
312 
313  // Build appropriate BoundPlane, based on parent chamber, with gas gap as thickness
314 
315  // centre of chamber is at global z = gtran[2]
316  float zlayer = gtran[2] - globalZ*zAverageAGVtoAF + localZwrtGlobalZ*(3.5-j)*layerSeparation;
317 
318  Surface::RotationType chamberRotation = chamber->surface().rotation();
319  Surface::PositionType layerPosition( gtran[0], gtran[1], zlayer );
320  std::array<const float, 4> const & dims = geom->parameters(); // returns hb, ht, d, a
321  // dims[2] = layerThickness/2.; // half-thickness required and note it is 3rd value in vector
322  TrapezoidalPlaneBounds* bounds = new TrapezoidalPlaneBounds( dims[0], dims[1], dims[3], layerThickness/2. );
323  Plane::PlanePointer plane = Plane::build(layerPosition, chamberRotation, bounds);
324 
325  CSCLayer* layer = new CSCLayer( plane, layerId, chamber, geom );
326 
327  LogTrace(myName) << myName << ": Create layer E" << jend << " S" << jstat
328  << " R" << jring << " C" << jch << " L" << j
329  << " z=" << zlayer
330  << " t=" << layerThickness << " or " << layer->surface().bounds().thickness()
331  << " adr=" << layer << " layerGeom adr=" << geom ;
332 
333  chamber->addComponent(j, layer);
334  theGeometry->addLayer( layer );
335  }
336  else {
337  edm::LogError(myName) << ": ERROR, layer " << j <<
338  " for chamber = " << ( chamber->id() ) <<
339  " already exists: layer address=" << cLayer <<
340  " chamber address=" << chamber << "\n";
341  }
342 
343  } // layer construction within chamber
344  } // chamber construction
345 }
int chamber() const
Definition: CSCDetId.h:70
virtual const std::array< const float, 4 > parameters() const
static int whatChamberType(int istation, int iring)
const Bounds & bounds() const
Definition: Surface.h:128
int layer() const
Definition: CSCDetId.h:63
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
int endcap() const
Definition: CSCDetId.h:95
virtual float thickness() const =0
static PlanePointer build(Args &&...args)
Definition: Plane.h:36
const CSCLayerGeometry * evenLayerGeometry(int iendcap) const
int j
Definition: DBlmapReader.cc:9
const std::string myName
#define LogTrace(id)
int ring() const
Definition: CSCDetId.h:77
const CSCLayerGeometry * oddLayerGeometry(int iendcap) const
Accessors for LayerGeometry&#39;s.
int station() const
Definition: CSCDetId.h:88
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

const std::string CSCGeometryBuilder::myName
private

Definition at line 49 of file CSCGeometryBuilder.h.

Referenced by build(), and buildChamber().