CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/FastSimulation/TrackerSetup/src/TrackerInteractionGeometry.cc

Go to the documentation of this file.
00001 //Framework Headers
00002 #include "FWCore/Utilities/interface/Exception.h"
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 
00005 //CMSSW Headers
00006 #include "DataFormats/GeometrySurface/interface/Surface.h"
00007 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
00008 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
00009 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
00010 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
00011 
00012 // Tracker/Tracking Headers
00013 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
00014 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00015 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
00016 
00017 //FAMOS Headers
00018 #include "FastSimulation/TrackerSetup/interface/TrackerInteractionGeometry.h"
00019 
00020 #include<iostream>
00021 
00022 TrackerInteractionGeometry::TrackerInteractionGeometry(const edm::ParameterSet& trackerMaterial,
00023                                                        const GeometricSearchTracker* theGeomSearchTracker)
00024 {
00025  
00026   // Fraction of radiation length : had oc values to account 
00027   // for detectors, cables, support, ...
00028   // Note : the second argument is not used in FAMOS
00029   // Note : the first argument is tuned to reproduce the CMSIM material
00030   //        in terms or radiation length.
00031 
00032 
00033   // Thickness of all layers
00034   // Version of the material description
00035   version = trackerMaterial.getParameter<unsigned int>("TrackerMaterialVersion");
00036   // Beam Pipe
00037   beamPipeThickness = trackerMaterial.getParameter<std::vector<double> >("BeamPipeThickness");
00038   // Pixel Barrel Layers 1-3
00039   pxbThickness = trackerMaterial.getParameter<std::vector<double> >("PXBThickness");
00040   // Pixel Barrel services at the end of layers 1-3
00041   pxb1CablesThickness = trackerMaterial.getParameter<std::vector<double> >("PXB1CablesThickness");
00042   pxb2CablesThickness = trackerMaterial.getParameter<std::vector<double> >("PXB2CablesThickness");
00043   pxb3CablesThickness = trackerMaterial.getParameter<std::vector<double> >("PXB3CablesThickness");
00044   // Pixel Barrel outside cables
00045   pxbOutCables1Thickness = trackerMaterial.getParameter<std::vector<double> >("PXBOutCables1Thickness");
00046   pxbOutCables2Thickness = trackerMaterial.getParameter<std::vector<double> >("PXBOutCables2Thickness");
00047   // Pixel Disks 1-2
00048   pxdThickness = trackerMaterial.getParameter<std::vector<double> >("PXDThickness");
00049   // Pixel Endcap outside cables
00050   pxdOutCables1Thickness = trackerMaterial.getParameter<std::vector<double> >("PXDOutCables1Thickness");
00051   pxdOutCables2Thickness = trackerMaterial.getParameter<std::vector<double> >("PXDOutCables2Thickness");
00052   // Tracker Inner barrel layers 1-4
00053   tibLayer1Thickness = trackerMaterial.getParameter<std::vector<double> >("TIBLayer1Thickness");
00054   tibLayer2Thickness = trackerMaterial.getParameter<std::vector<double> >("TIBLayer2Thickness");
00055   tibLayer3Thickness = trackerMaterial.getParameter<std::vector<double> >("TIBLayer3Thickness");
00056   tibLayer4Thickness = trackerMaterial.getParameter<std::vector<double> >("TIBLayer4Thickness");
00057   // TIB outside services (endcap)
00058   tibOutCables1Thickness = trackerMaterial.getParameter<std::vector<double> >("TIBOutCables1Thickness");
00059   tibOutCables2Thickness = trackerMaterial.getParameter<std::vector<double> >("TIBOutCables2Thickness");
00060   // Tracker Inner disks layers 1-3
00061   tidLayer1Thickness = trackerMaterial.getParameter<std::vector<double> >("TIDLayer1Thickness");
00062   tidLayer2Thickness = trackerMaterial.getParameter<std::vector<double> >("TIDLayer2Thickness");
00063   tidLayer3Thickness = trackerMaterial.getParameter<std::vector<double> >("TIDLayer3Thickness");
00064   // TID outside wall (endcap)
00065   tidOutsideThickness = trackerMaterial.getParameter<std::vector<double> >("TIDOutsideThickness");
00066   // TOB inside wall (barrel)
00067   tobInsideThickness = trackerMaterial.getParameter<std::vector<double> >("TOBInsideThickness");
00068   // Tracker Outer barrel layers 1-6
00069   tobLayer1Thickness = trackerMaterial.getParameter<std::vector<double> >("TOBLayer1Thickness");
00070   tobLayer2Thickness = trackerMaterial.getParameter<std::vector<double> >("TOBLayer2Thickness");
00071   tobLayer3Thickness = trackerMaterial.getParameter<std::vector<double> >("TOBLayer3Thickness");
00072   tobLayer4Thickness = trackerMaterial.getParameter<std::vector<double> >("TOBLayer4Thickness");
00073   tobLayer5Thickness = trackerMaterial.getParameter<std::vector<double> >("TOBLayer5Thickness");
00074   tobLayer6Thickness = trackerMaterial.getParameter<std::vector<double> >("TOBLayer6Thickness");
00075   // TOB services (endcap)
00076   tobOutsideThickness = trackerMaterial.getParameter<std::vector<double> >("TOBOutsideThickness");
00077   // Tracker EndCap disks layers 1-9
00078   tecLayerThickness = trackerMaterial.getParameter<std::vector<double> >("TECLayerThickness");
00079   // TOB outside wall (barrel)
00080   barrelCablesThickness = trackerMaterial.getParameter<std::vector<double> >("BarrelCablesThickness");
00081   // TEC outside wall (endcap)
00082   endcapCables1Thickness = trackerMaterial.getParameter<std::vector<double> >("EndcapCables1Thickness");
00083   endcapCables2Thickness = trackerMaterial.getParameter<std::vector<double> >("EndcapCables2Thickness");
00084 
00085   // Position of dead material layers (cables, services, etc.)
00086   // Beam pipe
00087   beamPipeRadius = trackerMaterial.getParameter<std::vector<double> >("BeamPipeRadius");
00088   beamPipeLength = trackerMaterial.getParameter<std::vector<double> >("BeamPipeLength");
00089   // Cables and Services at the end of PIXB1,2,3 ("disk")
00090   pxb1CablesInnerRadius = trackerMaterial.getParameter<std::vector<double> >("PXB1CablesInnerRadius");
00091   pxb2CablesInnerRadius = trackerMaterial.getParameter<std::vector<double> >("PXB2CablesInnerRadius");
00092   pxb3CablesInnerRadius = trackerMaterial.getParameter<std::vector<double> >("PXB3CablesInnerRadius");
00093   // Pixel Barrel Outside walls and cables
00094   pxbOutCables1InnerRadius = trackerMaterial.getParameter<std::vector<double> >("PXBOutCables1InnerRadius");
00095   pxbOutCables1OuterRadius = trackerMaterial.getParameter<std::vector<double> >("PXBOutCables1OuterRadius");
00096   pxbOutCables1ZPosition = trackerMaterial.getParameter<std::vector<double> >("PXBOutCables1ZPosition");
00097   pxbOutCables2InnerRadius = trackerMaterial.getParameter<std::vector<double> >("PXBOutCables2InnerRadius");
00098   pxbOutCables2OuterRadius = trackerMaterial.getParameter<std::vector<double> >("PXBOutCables2OuterRadius");
00099   pxbOutCables2ZPosition = trackerMaterial.getParameter<std::vector<double> >("PXBOutCables2ZPosition");
00100   // Pixel Outside walls and cables (barrel and endcaps)
00101   pixelOutCablesRadius = trackerMaterial.getParameter<std::vector<double> >("PixelOutCablesRadius");
00102   pixelOutCablesLength = trackerMaterial.getParameter<std::vector<double> >("PixelOutCablesLength");
00103   pixelOutCablesInnerRadius = trackerMaterial.getParameter<std::vector<double> >("PixelOutCablesInnerRadius");
00104   pixelOutCablesOuterRadius = trackerMaterial.getParameter<std::vector<double> >("PixelOutCablesOuterRadius");
00105   pixelOutCablesZPosition = trackerMaterial.getParameter<std::vector<double> >("PixelOutCablesZPosition");
00106   // Tracker Inner Barrel Outside Cables and walls (endcap) 
00107   tibOutCables1InnerRadius = trackerMaterial.getParameter<std::vector<double> >("TIBOutCables1InnerRadius");
00108   tibOutCables1OuterRadius = trackerMaterial.getParameter<std::vector<double> >("TIBOutCables1OuterRadius");
00109   tibOutCables1ZPosition = trackerMaterial.getParameter<std::vector<double> >("TIBOutCables1ZPosition");
00110   tibOutCables2InnerRadius = trackerMaterial.getParameter<std::vector<double> >("TIBOutCables2InnerRadius");
00111   tibOutCables2OuterRadius = trackerMaterial.getParameter<std::vector<double> >("TIBOutCables2OuterRadius");
00112   tibOutCables2ZPosition = trackerMaterial.getParameter<std::vector<double> >("TIBOutCables2ZPosition");
00113   // Tracker outer barrel Inside wall (barrel)
00114   tobInCablesRadius = trackerMaterial.getParameter<std::vector<double> >("TOBInCablesRadius");
00115   tobInCablesLength = trackerMaterial.getParameter<std::vector<double> >("TOBInCablesLength");
00116   // Tracker Inner Disks Outside Cables and walls
00117   tidOutCablesInnerRadius = trackerMaterial.getParameter<std::vector<double> >("TIDOutCablesInnerRadius");
00118   tidOutCablesZPosition = trackerMaterial.getParameter<std::vector<double> >("TIDOutCablesZPosition");
00119   // Tracker Outer Barrel Outside Cables and walls (barrel and endcaps)
00120   tobOutCablesInnerRadius = trackerMaterial.getParameter<std::vector<double> >("TOBOutCablesInnerRadius");
00121   tobOutCablesOuterRadius = trackerMaterial.getParameter<std::vector<double> >("TOBOutCablesOuterRadius");
00122   tobOutCablesZPosition = trackerMaterial.getParameter<std::vector<double> >("TOBOutCablesZPosition");
00123   tobOutCablesRadius = trackerMaterial.getParameter<std::vector<double> >("TOBOutCablesRadius");
00124   tobOutCablesLength = trackerMaterial.getParameter<std::vector<double> >("TOBOutCablesLength");
00125   // Tracker Endcaps Outside Cables and walls
00126   tecOutCables1InnerRadius = trackerMaterial.getParameter<std::vector<double> >("TECOutCables1InnerRadius");
00127   tecOutCables1OuterRadius = trackerMaterial.getParameter<std::vector<double> >("TECOutCables1OuterRadius");
00128   tecOutCables1ZPosition = trackerMaterial.getParameter<std::vector<double> >("TECOutCables1ZPosition");
00129   tecOutCables2InnerRadius = trackerMaterial.getParameter<std::vector<double> >("TECOutCables2InnerRadius");
00130   tecOutCables2OuterRadius = trackerMaterial.getParameter<std::vector<double> >("TECOutCables2OuterRadius");
00131   tecOutCables2ZPosition = trackerMaterial.getParameter<std::vector<double> >("TECOutCables2ZPosition");
00132 
00133   // Fudge factors for tracker layer material inhomogeneities
00134   fudgeLayer = trackerMaterial.getParameter<std::vector<unsigned int> >("FudgeLayer");
00135   fudgeMin = trackerMaterial.getParameter<std::vector<double> >("FudgeMin");
00136   fudgeMax = trackerMaterial.getParameter<std::vector<double> >("FudgeMax");
00137   fudgeFactor = trackerMaterial.getParameter<std::vector<double> >("FudgeFactor");
00138 
00139   // The previous std::vector must have the same size!
00140   if ( fudgeLayer.size() != fudgeMin.size() ||  
00141        fudgeLayer.size() != fudgeMax.size() ||  
00142        fudgeLayer.size() != fudgeFactor.size() ) {
00143     throw cms::Exception("FastSimulation/TrackerInteractionGeometry ") 
00144       << " WARNING with fudge factors !  You have " << fudgeLayer.size() 
00145       << " layers, but " 
00146       << fudgeMin.size() << " min values, "
00147       << fudgeMax.size() << " max values and "
00148       << fudgeFactor.size() << " fudge factor values!"
00149       << std::endl
00150       << "Please make enter the same number of inputs " 
00151       << "in FastSimulation/TrackerInteractionGeometry/data/TrackerMaterial.cfi"
00152       << std::endl;
00153   }
00154 
00155   // The Beam pipe
00156   _theMPBeamPipe = new MediumProperties(beamPipeThickness[version],0.0001);  
00157   // The pixel barrel layers
00158   _theMPPixelBarrel = new MediumProperties(pxbThickness[version],0.0001);  
00159     // Pixel Barrel services at the end of layers 1-3
00160   _theMPPixelOutside1 = new MediumProperties(pxb1CablesThickness[version],0.0001);  
00161   _theMPPixelOutside2 = new MediumProperties(pxb2CablesThickness[version],0.0001);  
00162   _theMPPixelOutside3 = new MediumProperties(pxb3CablesThickness[version],0.0001);  
00163   // Pixel Barrel outside cables
00164   _theMPPixelOutside4 = new MediumProperties(pxbOutCables1Thickness[version],0.0001);  
00165   _theMPPixelOutside  = new MediumProperties(pxbOutCables2Thickness[version],0.0001);  
00166   // The pixel endcap disks
00167   _theMPPixelEndcap = new MediumProperties(pxdThickness[version],0.0001);  
00168   // Pixel Endcap outside cables
00169   _theMPPixelOutside5 = new MediumProperties(pxdOutCables1Thickness[version],0.0001);  
00170   _theMPPixelOutside6 = new MediumProperties(pxdOutCables2Thickness[version],0.0001);  
00171   // The tracker inner barrel layers 1-4
00172   _theMPTIB1 = new MediumProperties(tibLayer1Thickness[version],0.0001);  
00173   _theMPTIB2 = new MediumProperties(tibLayer2Thickness[version],0.0001);  
00174   _theMPTIB3 = new MediumProperties(tibLayer3Thickness[version],0.0001);  
00175   _theMPTIB4 = new MediumProperties(tibLayer4Thickness[version],0.0001);  
00176   // TIB outside services (endcap)
00177   _theMPTIBEOutside1 = new MediumProperties(tibOutCables1Thickness[version],0.0001);  
00178   _theMPTIBEOutside2 = new MediumProperties(tibOutCables2Thickness[version],0.0001);  
00179   // The tracker inner disks 1-3
00180   _theMPInner1 = new MediumProperties(tidLayer1Thickness[version],0.0001);  
00181   _theMPInner2 = new MediumProperties(tidLayer2Thickness[version],0.0001);  
00182   _theMPInner3 = new MediumProperties(tidLayer3Thickness[version],0.0001);  
00183   // TID outside wall (endcap)
00184   _theMPTIDEOutside = new MediumProperties(tidOutsideThickness[version],0.0001);  
00185   // TOB inside wall (barrel)
00186   _theMPTOBBInside = new MediumProperties(tobInsideThickness[version],0.0001);  
00187   // The tracker outer barrel layers 1-6
00188   _theMPTOB1 = new MediumProperties(tobLayer1Thickness[version],0.0001);  
00189   _theMPTOB2 = new MediumProperties(tobLayer2Thickness[version],0.0001);  
00190   _theMPTOB3 = new MediumProperties(tobLayer3Thickness[version],0.0001);  
00191   _theMPTOB4 = new MediumProperties(tobLayer4Thickness[version],0.0001);  
00192   _theMPTOB5 = new MediumProperties(tobLayer5Thickness[version],0.0001);  
00193   _theMPTOB6 = new MediumProperties(tobLayer6Thickness[version],0.0001);  
00194   // TOB services (endcap)
00195   _theMPTOBEOutside = new MediumProperties(tobOutsideThickness[version],0.0001);  
00196   // The tracker endcap disks 1-9
00197   _theMPEndcap = new MediumProperties(tecLayerThickness[version],0.0001);  
00198   // TOB outside wall (barrel)
00199   _theMPBarrelOutside = new MediumProperties(barrelCablesThickness[version],0.0001);  
00200   // TEC outside wall (endcap)
00201   _theMPEndcapOutside = new MediumProperties(endcapCables1Thickness[version],0.0001);  
00202   _theMPEndcapOutside2 = new MediumProperties(endcapCables2Thickness[version],0.0001);  
00203 
00204   // Check that the Reco Tracker Geometry has been loaded
00205   if ( !theGeomSearchTracker ) 
00206     throw cms::Exception("FastSimulation/TrackerInteractionGeometry") 
00207       << "The pointer to the GeometricSearchTracker was not set"; 
00208 
00209   // The vector of Barrel Tracker Layers 
00210   std::vector< BarrelDetLayer*> barrelLayers = 
00211     theGeomSearchTracker->barrelLayers();
00212 
00213   // The vector of Forward Tracker Layers (positive z)
00214   std::vector< ForwardDetLayer*>  posForwardLayers = 
00215     theGeomSearchTracker->posForwardLayers();
00216 
00217   // Local pointers
00218   BoundCylinder* theCylinder;
00219   BoundDisk* theDisk;
00220 
00221   // Create the nest of cylinders
00222   const Surface::PositionType thePosition(0.,0.,0.);
00223   const Surface::RotationType theRotation(1.,0.,0.,0.,1.,0.,0.,0.,1.);
00224   // Beam Pipe
00225   //  const SimpleCylinderBounds  PIPE( 0.997,   1.003,  -300., 300.);
00226   const SimpleCylinderBounds  PIPE( beamPipeRadius[version]-0.003, beamPipeRadius[version]+0.003,  
00227                                    -beamPipeLength[version],       beamPipeLength[version]);
00228 
00229   // Take the active layer position from the Tracker Reco Geometry
00230   // Pixel barrel
00231   std::vector< BarrelDetLayer*>::const_iterator bl = barrelLayers.begin();
00232   double maxLength = (**bl).specificSurface().bounds().length()/2.+1.7;
00233   double maxRadius = (**bl).specificSurface().radius()+0.01;
00234   // First pixel barrel layer: r=4.41058, l=53.38
00235   const SimpleCylinderBounds  PIXB1( maxRadius-0.005, maxRadius+0.005, -maxLength, +maxLength);
00236   // "Cables" 
00237   const SimpleDiskBounds PIXBOut1(pxb1CablesInnerRadius[version],maxRadius+0.01,-0.5,0.5);
00238   const Surface::PositionType PPIXBOut1(0.0,0.0,maxLength);
00239 
00240   // Second pixel barrel layer: r=7.30732, l=53.38
00241   ++bl;
00242   maxLength = std::max( (**bl).specificSurface().bounds().length()/2.+1.7, maxLength+0.000 );
00243   maxRadius = (**bl).specificSurface().radius();
00244   const SimpleCylinderBounds  PIXB2( maxRadius-0.005, maxRadius+0.005, -maxLength, +maxLength);
00245 
00246   // "Cables"
00247   const SimpleDiskBounds PIXBOut2(pxb2CablesInnerRadius[version],maxRadius+0.005,-0.5,0.5);
00248   const Surface::PositionType PPIXBOut2(0.0,0.0,maxLength);
00249 
00250   // More cables
00251   ++bl;
00252   maxRadius = (**bl).specificSurface().radius();
00253   const SimpleDiskBounds PIXBOut3(pxb3CablesInnerRadius[version],maxRadius,-0.5,0.5);
00254   const Surface::PositionType PPIXBOut3(0.0,0.0,maxLength);
00255 
00256   // Third pixel barrel layer: r=10.1726, l=53.38
00257   maxLength = std::max( (**bl).specificSurface().bounds().length()/2.+1.7, maxLength+0.000 );
00258   const SimpleCylinderBounds  PIXB3( maxRadius-0.005, maxRadius+0.005, -maxLength, +maxLength);
00259 
00260   // Pixel Barrel Outside walls and cables
00261   const SimpleDiskBounds PIXBOut4( pxbOutCables1InnerRadius[version],pxbOutCables1OuterRadius[version],-0.5,0.5);
00262   const Surface::PositionType PPIXBOut4(0.0,0.0,pxbOutCables1ZPosition[version]);
00263 
00264   const SimpleDiskBounds PIXBOut(pxbOutCables2InnerRadius[version],pxbOutCables2OuterRadius[version],-0.5,0.5);
00265   const Surface::PositionType PPIXBOut(0.0,0.0,pxbOutCables2ZPosition[version]);
00266 
00267   const SimpleCylinderBounds  PIXBOut5( pixelOutCablesRadius[version]-0.1, pixelOutCablesRadius[version]+0.1, 
00268                                        -pixelOutCablesLength[version],     pixelOutCablesLength[version]);
00269 
00270   const SimpleDiskBounds PIXBOut6(pixelOutCablesInnerRadius[version],pixelOutCablesOuterRadius[version],-0.5,0.5);
00271   const Surface::PositionType PPIXBOut6(0.0,0.0,pixelOutCablesZPosition[version]);
00272 
00273 
00274   // Tracker Inner Barrel : thin detectors (300 microns)
00275   // First TIB layer: r=25.6786, l=130.04
00276   ++bl;
00277   maxRadius = (**bl).specificSurface().radius();
00278   maxLength = (**bl).specificSurface().bounds().length()/2.;
00279   const SimpleCylinderBounds  TIB1( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00280   // Second TIB layer: r=34.0341, l=131.999
00281   ++bl;
00282   maxRadius = (**bl).specificSurface().radius();
00283   maxLength = std::max( (**bl).specificSurface().bounds().length()/2., maxLength+0.000 );
00284   const SimpleCylinderBounds  TIB2( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00285   // Third TIB layer: r=41.9599, l=131.628  !!!! Needs to be larger than TIB2
00286   ++bl;
00287   maxRadius = (**bl).specificSurface().radius();
00288   maxLength = std::max( (**bl).specificSurface().bounds().length()/2., maxLength+0.000 );
00289   const SimpleCylinderBounds  TIB3( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00290   // Fourth TIB layer: r=49.8924, l=132.78
00291   ++bl;
00292   maxRadius = (**bl).specificSurface().radius();
00293   maxLength = std::max( (**bl).specificSurface().bounds().length()/2., maxLength+0.000 );
00294   const SimpleCylinderBounds  TIB4( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00295 
00296   // Inner Barrel Cylinder & Ends : Cables and walls
00297   const SimpleDiskBounds TIBEOut(tibOutCables1InnerRadius[version],tibOutCables1OuterRadius[version],-0.05,0.05);
00298   const Surface::PositionType PTIBEOut(0.0,0.0,tibOutCables1ZPosition[version]);
00299 
00300   const SimpleDiskBounds TIBEOut2(tibOutCables2InnerRadius[version],tibOutCables2OuterRadius[version],-0.05,0.05);
00301   const Surface::PositionType PTIBEOut2(0.0,0.0,tibOutCables2ZPosition[version]);
00302 
00303   // Inner Tracker / Outer Barrel Wall
00304   const SimpleCylinderBounds  TOBCIn ( tobInCablesRadius[version]-0.5, tobInCablesRadius[version]+0.5,
00305                                       -tobInCablesLength[version],     tobInCablesLength[version]);
00306 
00307   // First TOB layer: r=60.7671, l=216.576
00308   ++bl;
00309   maxRadius = (**bl).specificSurface().radius();
00310   maxLength = (**bl).specificSurface().bounds().length()/2.+0.0;
00311   const SimpleCylinderBounds  TOB1( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00312   // Second TOB layer: r=69.3966, l=216.576
00313   ++bl;
00314   maxRadius = (**bl).specificSurface().radius();
00315   maxLength = std::max( (**bl).specificSurface().bounds().length()/2.+0.0, maxLength+0.000 );
00316   const SimpleCylinderBounds  TOB2( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00317   // Third TOB layer: r=78.0686, l=216.576
00318   ++bl;
00319   maxRadius = (**bl).specificSurface().radius();
00320   maxLength = std::max( (**bl).specificSurface().bounds().length()/2.+0.0, maxLength+0.000 );
00321   const SimpleCylinderBounds  TOB3( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00322   // Fourth TOB layer: r=86.8618, l=216.576
00323   ++bl;
00324   maxRadius = (**bl).specificSurface().radius();
00325   maxLength = std::max( (**bl).specificSurface().bounds().length()/2.+0.0, maxLength+0.000 );
00326   const SimpleCylinderBounds  TOB4( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00327   // Fifth TOB layer: r=96.5557, l=216.576
00328   ++bl;
00329   maxRadius = (**bl).specificSurface().radius();
00330   maxLength = std::max( (**bl).specificSurface().bounds().length()/2.+0.0, maxLength+0.000 );
00331   const SimpleCylinderBounds  TOB5( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00332   // Sixth TOB layer: r=108.05, l=216.576
00333   ++bl;
00334   maxRadius = (**bl).specificSurface().radius();
00335   maxLength = std::max( (**bl).specificSurface().bounds().length()/2.+0.0, maxLength+0.000 );
00336   const SimpleCylinderBounds  TOB6( maxRadius-0.0150, maxRadius+0.0150, -maxLength, +maxLength);
00337 
00338   const SimpleDiskBounds TOBEOut(tobOutCablesInnerRadius[version],tobOutCablesOuterRadius[version],-0.5,0.5);
00339   const Surface::PositionType PTOBEOut(0.0,0.0,tobOutCablesZPosition[version]);
00340 
00341   const Surface::RotationType theRotation2(1.,0.,0.,0.,1.,0.,0.,0.,1.);
00342 
00343   // Outside : Barrel
00344   const SimpleCylinderBounds  TBOut ( tobOutCablesRadius[version]-0.5, tobOutCablesRadius[version]+0.5,
00345                                      -tobOutCablesLength[version],     tobOutCablesLength[version]);
00346 
00347   // And now the disks...
00348   std::vector< ForwardDetLayer*>::const_iterator fl = posForwardLayers.begin();
00349 
00350   // Pixel disks 
00351   // First Pixel disk: Z pos 35.5 radii 5.42078, 16.0756
00352   double innerRadius = (**fl).specificSurface().innerRadius()-1.0;
00353   double outerRadius = (**fl).specificSurface().outerRadius()+2.0;
00354   const SimpleDiskBounds PIXD1(innerRadius, outerRadius,-0.0150,+0.0150);
00355   const Surface::PositionType PPIXD1(0.0,0.0,(**fl).surface().position().z()); 
00356   // Second Pixel disk: Z pos 48.5 radii 5.42078, 16.0756
00357   ++fl;
00358   innerRadius = (**fl).specificSurface().innerRadius()-1.0;
00359   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00360   const SimpleDiskBounds PIXD2(innerRadius, outerRadius,-0.0150,+0.0150);
00361   const Surface::PositionType PPIXD2(0.0,0.0,(**fl).surface().position().z()); 
00362 
00363   // Tracker Inner disks (add 3 cm for the outer radius to simulate cables, 
00364   // and remove 1cm to inner radius to allow for some extrapolation margin)
00365   // First TID : Z pos 78.445 radii 23.14, 50.4337
00366   ++fl;
00367   innerRadius = (**fl).specificSurface().innerRadius()-0.5;
00368   outerRadius = (**fl).specificSurface().outerRadius()+3.5;
00369   const SimpleDiskBounds TID1(innerRadius,outerRadius,-0.0150,+0.0150);
00370   const Surface::PositionType PTID1(0.,0.,(**fl).surface().position().z()); 
00371   // Second TID : Z pos 90.445 radii 23.14, 50.4337
00372   ++fl;
00373   innerRadius = (**fl).specificSurface().innerRadius()-0.5;
00374   outerRadius = std::max( (**fl).specificSurface().outerRadius()+3.5, outerRadius+0.000);
00375   const SimpleDiskBounds TID2(innerRadius,outerRadius,-0.0150,+0.0150);
00376   const Surface::PositionType PTID2(0.,0.,(**fl).surface().position().z()); 
00377   // Third TID : Z pos 105.445 radii 23.14, 50.4337
00378   ++fl;
00379   innerRadius = (**fl).specificSurface().innerRadius()-0.5;
00380   outerRadius = std::max( (**fl).specificSurface().outerRadius()+3.5, outerRadius+0.000);
00381   const SimpleDiskBounds TID3(innerRadius,outerRadius,-0.0150,+0.0150);
00382   const Surface::PositionType PTID3(0.,0.,(**fl).surface().position().z()); 
00383 
00384   // TID Wall and cables
00385   const SimpleDiskBounds TIDEOut(tidOutCablesInnerRadius[version],outerRadius+1.0,-0.5,0.5);
00386   const Surface::PositionType PTIDEOut(0.0,0.0,tidOutCablesZPosition[version]);
00387 
00388 
00389   // Tracker Endcaps : Add 11 cm to outer radius to correct for a bug, remove
00390   // 5cm to the inner radius (TEC7,8,9) to correct for a simular bug, and
00391   // remove other 2cm to inner radius to allow for some extrapolation margin
00392   // First TEC: Z pos 131.892 radii 23.3749, 99.1967
00393   ++fl;
00394   innerRadius = (**fl).specificSurface().innerRadius()-1.5;
00395   outerRadius = (**fl).specificSurface().outerRadius()+2.0;
00396   const SimpleDiskBounds TEC1(innerRadius,outerRadius,-0.0150,+0.0150);
00397   const Surface::PositionType PTEC1(0.,0,(**fl).surface().position().z()); 
00398   // Second TEC: Z pos 145.892 radii 23.3749, 99.1967
00399   ++fl;
00400   innerRadius = (**fl).specificSurface().innerRadius()-1.5;
00401   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00402   const SimpleDiskBounds TEC2(innerRadius,outerRadius,-0.0150,+0.0150);
00403   const Surface::PositionType PTEC2(0.,0.,(**fl).surface().position().z());
00404   // Third TEC: Z pos 159.892 radii 23.3749, 99.1967
00405   ++fl;
00406   innerRadius = (**fl).specificSurface().innerRadius()-1.5;
00407   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00408   const SimpleDiskBounds TEC3(innerRadius,outerRadius,-0.0150,+0.0150);
00409   const Surface::PositionType PTEC3(0.,0.,(**fl).surface().position().z());
00410   // Fourth TEC: Z pos 173.892 radii 32.1263, 99.1967
00411   ++fl;
00412   innerRadius = (**fl).specificSurface().innerRadius()-2.5;
00413   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00414   const SimpleDiskBounds TEC4(innerRadius,outerRadius,-0.0150,+0.0150);
00415   const Surface::PositionType PTEC4(0.,0.,(**fl).surface().position().z());
00416   // Fifth TEC: Z pos 187.892 radii 32.1263, 99.1967
00417   ++fl;
00418   innerRadius = (**fl).specificSurface().innerRadius()-2.5;
00419   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00420   const SimpleDiskBounds TEC5(innerRadius,outerRadius,-0.0150,+0.0150);
00421   const Surface::PositionType PTEC5(0.,0.,(**fl).surface().position().z());
00422   // Sixth TEC: Z pos 205.392 radii 32.1263, 99.1967
00423   ++fl;
00424   innerRadius = (**fl).specificSurface().innerRadius()-2.5;
00425   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00426   const SimpleDiskBounds TEC6(innerRadius,outerRadius,-0.0150,+0.0150);
00427   const Surface::PositionType PTEC6(0.,0.,(**fl).surface().position().z());
00428   // Seventh TEC: Z pos 224.121 radii 44.7432, 99.1967
00429   ++fl;
00430   innerRadius = (**fl).specificSurface().innerRadius()-9.5;
00431   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00432   const SimpleDiskBounds TEC7(innerRadius,outerRadius,-0.0150,+0.0150);
00433   const Surface::PositionType PTEC7(0.,0.,(**fl).surface().position().z());
00434   // Eighth TEC: Z pos 244.621 radii 44.7432, 99.1967
00435   ++fl;
00436   innerRadius = (**fl).specificSurface().innerRadius()-9.5;
00437   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00438   const SimpleDiskBounds TEC8(innerRadius,outerRadius,-0.0150,+0.0150);
00439   const Surface::PositionType PTEC8(0.,0.,(**fl).surface().position().z());
00440   // Nineth TEC: Z pos 266.121 radii 56.1781, 99.1967
00441   ++fl;
00442   innerRadius = (**fl).specificSurface().innerRadius()-20.5;
00443   outerRadius = std::max( (**fl).specificSurface().outerRadius()+2.0, outerRadius+0.000 );
00444   const SimpleDiskBounds TEC9(innerRadius,outerRadius,-0.0150,+0.0150);
00445   const Surface::PositionType PTEC9(0.,0.,(**fl).surface().position().z());
00446 
00447   // Outside : Endcap
00448   const SimpleDiskBounds TEOut(tecOutCables1InnerRadius[version],tecOutCables1OuterRadius[version],-0.5,0.5);
00449   const Surface::PositionType PTEOut(0.0,0.0,tecOutCables1ZPosition[version]);
00450 
00451   const SimpleDiskBounds TEOut2(tecOutCables2InnerRadius[version],tecOutCables2OuterRadius[version],-0.5,0.5);
00452   const Surface::PositionType PTEOut2(0.0,0.0,tecOutCables2ZPosition[version]);
00453 
00454   // The ordering of disks and cylinders is essential here
00455   // (from inside to outside)
00456   // Do not change it thoughtlessly.
00457 
00458 
00459   // Beam Pipe
00460 
00461   unsigned layerNr = 100;
00462   theCylinder = new BoundCylinder(thePosition,theRotation,PIPE);
00463   theCylinder->setMediumProperties(_theMPBeamPipe);
00464   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00465     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00466                                          minDim(layerNr),maxDim(layerNr),
00467                                          fudgeFactors(layerNr)));
00468   else
00469     delete theCylinder;
00470   
00471   // Pixels 
00472 
00473   layerNr = TrackerInteractionGeometry::PXB+1;
00474   theCylinder = new BoundCylinder(thePosition,theRotation,PIXB1);
00475   theCylinder->setMediumProperties(_theMPPixelBarrel);
00476   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00477     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00478                                          minDim(layerNr),maxDim(layerNr),
00479                                          fudgeFactors(layerNr)));
00480   else
00481     delete theCylinder;
00482 
00483   layerNr = 101;
00484   theDisk = new BoundDisk(PPIXBOut1,theRotation2,PIXBOut1);
00485   theDisk->setMediumProperties(_theMPPixelOutside1);
00486   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00487     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00488                                          minDim(layerNr),maxDim(layerNr),
00489                                          fudgeFactors(layerNr)));
00490   else
00491     delete theDisk;
00492 
00493   layerNr = TrackerInteractionGeometry::PXB+2;
00494   theCylinder = new BoundCylinder(thePosition,theRotation,PIXB2);
00495   theCylinder->setMediumProperties(_theMPPixelBarrel);
00496   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00497     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00498                                          minDim(layerNr),maxDim(layerNr),
00499                                          fudgeFactors(layerNr)));
00500   else
00501     delete theCylinder;
00502 
00503   layerNr = 102;
00504   theDisk = new BoundDisk(PPIXBOut2,theRotation2,PIXBOut2);
00505   theDisk->setMediumProperties(_theMPPixelOutside2);
00506   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00507     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00508                                          minDim(layerNr),maxDim(layerNr),
00509                                          fudgeFactors(layerNr)));
00510   else
00511     delete theDisk;
00512 
00513   layerNr = 103;
00514   theDisk = new BoundDisk(PPIXBOut3,theRotation2,PIXBOut3);
00515   theDisk->setMediumProperties(_theMPPixelOutside3);
00516   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00517     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00518                                          minDim(layerNr),maxDim(layerNr),
00519                                          fudgeFactors(layerNr)));
00520   else
00521     delete theDisk;
00522 
00523   layerNr = TrackerInteractionGeometry::PXB+3;
00524   theCylinder = new BoundCylinder(thePosition,theRotation,PIXB3);
00525   theCylinder->setMediumProperties(_theMPPixelBarrel);
00526   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00527     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00528                                          minDim(layerNr),maxDim(layerNr),
00529                                          fudgeFactors(layerNr)));
00530   else
00531     delete theCylinder;
00532 
00533   layerNr = 104;
00534   theDisk = new BoundDisk(PPIXBOut4,theRotation2,PIXBOut4);
00535   theDisk->setMediumProperties(_theMPPixelOutside4);
00536   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00537     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00538                                          minDim(layerNr),maxDim(layerNr),
00539                                          fudgeFactors(layerNr)));
00540   else
00541     delete theDisk;
00542 
00543   layerNr = 105;
00544   theDisk = new BoundDisk(PPIXBOut,theRotation2,PIXBOut);
00545   theDisk->setMediumProperties(_theMPPixelOutside);
00546   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00547     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00548                                          minDim(layerNr),maxDim(layerNr),
00549                                          fudgeFactors(layerNr)));
00550   else
00551     delete theDisk;
00552 
00553   layerNr = TrackerInteractionGeometry::PXD+1;
00554   theDisk = new BoundDisk(PPIXD1,theRotation2,PIXD1);
00555   theDisk->setMediumProperties(_theMPPixelEndcap);
00556   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00557     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00558                                          minDim(layerNr),maxDim(layerNr),
00559                                          fudgeFactors(layerNr)));
00560   else
00561     delete theDisk;
00562 
00563   layerNr = TrackerInteractionGeometry::PXD+2;
00564   theDisk = new BoundDisk(PPIXD2,theRotation2,PIXD2);
00565   theDisk->setMediumProperties(_theMPPixelEndcap);
00566   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00567     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00568                                          minDim(layerNr),maxDim(layerNr),
00569                                          fudgeFactors(layerNr)));
00570   else
00571     delete theDisk;
00572 
00573   layerNr = 106;
00574   theCylinder = new BoundCylinder(thePosition,theRotation,PIXBOut5);
00575   theCylinder->setMediumProperties(_theMPPixelOutside5);
00576   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00577     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00578                                          minDim(layerNr),maxDim(layerNr),
00579                                          fudgeFactors(layerNr)));
00580   else
00581     delete theCylinder;
00582 
00583   layerNr = 107;
00584   theDisk = new BoundDisk(PPIXBOut6,theRotation2,PIXBOut6);
00585   theDisk->setMediumProperties(_theMPPixelOutside6);
00586   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00587     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00588                                          minDim(layerNr),maxDim(layerNr),
00589                                          fudgeFactors(layerNr)));
00590   else
00591     delete theDisk;
00592 
00593   // Inner Barrel 
00594 
00595   layerNr = TrackerInteractionGeometry::TIB+1;
00596   theCylinder = new BoundCylinder(thePosition,theRotation,TIB1);
00597   theCylinder->setMediumProperties(_theMPTIB1);
00598   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00599     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00600                                          minDim(layerNr),maxDim(layerNr),
00601                                          fudgeFactors(layerNr)));
00602   else
00603     delete theCylinder;
00604 
00605   layerNr = TrackerInteractionGeometry::TIB+2;
00606   theCylinder = new BoundCylinder(thePosition,theRotation,TIB2);
00607   theCylinder->setMediumProperties(_theMPTIB2);
00608   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00609     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00610                                          minDim(layerNr),maxDim(layerNr),
00611                                          fudgeFactors(layerNr)));
00612   else
00613     delete theCylinder;
00614 
00615   layerNr = TrackerInteractionGeometry::TIB+3;
00616   theCylinder = new BoundCylinder(thePosition,theRotation,TIB3);
00617   theCylinder->setMediumProperties(_theMPTIB3);
00618   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00619     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00620                                          minDim(layerNr),maxDim(layerNr),
00621                                          fudgeFactors(layerNr)));
00622   else
00623     delete theCylinder;
00624 
00625   layerNr = TrackerInteractionGeometry::TIB+4;
00626   theCylinder = new BoundCylinder(thePosition,theRotation,TIB4);
00627   theCylinder->setMediumProperties(_theMPTIB4);
00628   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00629     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00630                                          minDim(layerNr),maxDim(layerNr),
00631                                          fudgeFactors(layerNr)));
00632   else
00633     delete theCylinder;
00634 
00635   layerNr = 108;
00636   theDisk = new BoundDisk(PTIBEOut,theRotation2,TIBEOut);
00637   theDisk->setMediumProperties(_theMPTIBEOutside1);
00638   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00639     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00640                                          minDim(layerNr),maxDim(layerNr),
00641                                          fudgeFactors(layerNr)));
00642   else
00643     delete theDisk;
00644 
00645   layerNr = 109;
00646   theDisk = new BoundDisk(PTIBEOut2,theRotation2,TIBEOut2);
00647   theDisk->setMediumProperties(_theMPTIBEOutside2);
00648   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00649     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00650                                          minDim(layerNr),maxDim(layerNr),
00651                                          fudgeFactors(layerNr)));
00652   else
00653     delete theDisk;
00654   
00655   // Inner Endcaps
00656 
00657   layerNr = TrackerInteractionGeometry::TID+1;
00658   theDisk = new BoundDisk(PTID1,theRotation2,TID1);
00659   theDisk->setMediumProperties(_theMPInner1);
00660   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00661     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00662                                          minDim(layerNr),maxDim(layerNr),
00663                                          fudgeFactors(layerNr)));
00664   else
00665     delete theDisk;
00666 
00667   layerNr = TrackerInteractionGeometry::TID+2;
00668   theDisk = new BoundDisk(PTID2,theRotation2,TID2);
00669   theDisk->setMediumProperties(_theMPInner2);
00670   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00671     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00672                                          minDim(layerNr),maxDim(layerNr),
00673                                          fudgeFactors(layerNr)));
00674 
00675   else
00676     delete theDisk;
00677 
00678   layerNr = TrackerInteractionGeometry::TID+3;
00679   theDisk = new BoundDisk(PTID3,theRotation2,TID3);
00680   theDisk->setMediumProperties(_theMPInner3);
00681   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00682     _theCylinders.push_back(TrackerLayer(theDisk,12,layerNr,
00683                                          minDim(layerNr),maxDim(layerNr),
00684                                          fudgeFactors(layerNr)));
00685   else
00686     delete theDisk;
00687 
00688   layerNr = 110;
00689   theDisk = new BoundDisk(PTIDEOut,theRotation2,TIDEOut);
00690   theDisk->setMediumProperties(_theMPTIDEOutside);
00691   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00692     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00693                                          minDim(layerNr),maxDim(layerNr),
00694                                          fudgeFactors(layerNr)));
00695   else
00696     delete theDisk;
00697 
00698 
00699   // Outer Barrel 
00700 
00701   layerNr = 111;
00702   theCylinder = new BoundCylinder(thePosition,theRotation,TOBCIn);
00703   theCylinder->setMediumProperties(_theMPTOBBInside);
00704   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00705     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00706                                          minDim(layerNr),maxDim(layerNr),
00707                                          fudgeFactors(layerNr)));
00708   else
00709     delete theCylinder;
00710 
00711   layerNr = TrackerInteractionGeometry::TOB+1;
00712   theCylinder = new BoundCylinder(thePosition,theRotation,TOB1);
00713   theCylinder->setMediumProperties(_theMPTOB1);
00714   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00715     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00716                                          minDim(layerNr),maxDim(layerNr),
00717                                          fudgeFactors(layerNr)));
00718   else
00719     delete theCylinder;
00720 
00721   layerNr = TrackerInteractionGeometry::TOB+2;
00722   theCylinder = new BoundCylinder(thePosition,theRotation,TOB2);
00723   theCylinder->setMediumProperties(_theMPTOB2);
00724   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00725     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00726                                          minDim(layerNr),maxDim(layerNr),
00727                                          fudgeFactors(layerNr)));
00728   else
00729     delete theCylinder;
00730 
00731   layerNr = TrackerInteractionGeometry::TOB+3;
00732   theCylinder = new BoundCylinder(thePosition,theRotation,TOB3);
00733   theCylinder->setMediumProperties(_theMPTOB3);
00734   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00735     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00736                                          minDim(layerNr),maxDim(layerNr),
00737                                          fudgeFactors(layerNr)));
00738   else
00739     delete theCylinder;
00740 
00741   layerNr = TrackerInteractionGeometry::TOB+4;
00742   theCylinder = new BoundCylinder(thePosition,theRotation,TOB4);
00743   theCylinder->setMediumProperties(_theMPTOB4);
00744   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00745     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00746                                          minDim(layerNr),maxDim(layerNr),
00747                                          fudgeFactors(layerNr)));
00748   else
00749     delete theCylinder;
00750 
00751   layerNr = TrackerInteractionGeometry::TOB+5;
00752   theCylinder = new BoundCylinder(thePosition,theRotation,TOB5);
00753   theCylinder->setMediumProperties(_theMPTOB5);
00754   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00755     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00756                                          minDim(layerNr),maxDim(layerNr),
00757                                          fudgeFactors(layerNr)));
00758   else
00759     delete theCylinder;
00760 
00761   layerNr = TrackerInteractionGeometry::TOB+6;
00762   theCylinder = new BoundCylinder(thePosition,theRotation,TOB6);
00763   theCylinder->setMediumProperties(_theMPTOB6);
00764   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00765     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00766                                          minDim(layerNr),maxDim(layerNr),
00767                                          fudgeFactors(layerNr)));
00768   else
00769     delete theCylinder;
00770 
00771   layerNr = 112;
00772   theDisk = new BoundDisk(PTOBEOut,theRotation2,TOBEOut);
00773   theDisk->setMediumProperties(_theMPTOBEOutside);
00774   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00775     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00776                                          minDim(layerNr),maxDim(layerNr),
00777                                          fudgeFactors(layerNr)));
00778   else
00779     delete theDisk;
00780 
00781   // Outer Endcaps
00782  
00783   layerNr = TrackerInteractionGeometry::TEC+1;
00784   theDisk = new BoundDisk(PTEC1,theRotation2,TEC1);
00785   theDisk->setMediumProperties(_theMPEndcap);
00786   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00787     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00788                                          minDim(layerNr),maxDim(layerNr),
00789                                          fudgeFactors(layerNr)));
00790   else
00791     delete theDisk;
00792 
00793   layerNr = TrackerInteractionGeometry::TEC+2;
00794   theDisk = new BoundDisk(PTEC2,theRotation2,TEC2);
00795   theDisk->setMediumProperties(_theMPEndcap);
00796   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00797     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00798                                          minDim(layerNr),maxDim(layerNr),
00799                                          fudgeFactors(layerNr)));
00800   else
00801     delete theDisk;
00802 
00803   layerNr = TrackerInteractionGeometry::TEC+3;
00804   theDisk = new BoundDisk(PTEC3,theRotation2,TEC3);
00805   theDisk->setMediumProperties(_theMPEndcap);
00806   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00807     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00808                                          minDim(layerNr),maxDim(layerNr),
00809                                          fudgeFactors(layerNr)));
00810   else
00811     delete theDisk;
00812 
00813   layerNr = TrackerInteractionGeometry::TEC+4;
00814   theDisk = new BoundDisk(PTEC4,theRotation2,TEC4);
00815   theDisk->setMediumProperties(_theMPEndcap);
00816   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00817     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00818                                          minDim(layerNr),maxDim(layerNr),
00819                                          fudgeFactors(layerNr)));
00820   else
00821     delete theDisk;
00822 
00823   layerNr = TrackerInteractionGeometry::TEC+5;
00824   theDisk = new BoundDisk(PTEC5,theRotation2,TEC5);
00825   theDisk->setMediumProperties(_theMPEndcap);
00826   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00827     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00828                                          minDim(layerNr),maxDim(layerNr),
00829                                          fudgeFactors(layerNr)));
00830   else
00831     delete theDisk;
00832 
00833   layerNr = TrackerInteractionGeometry::TEC+6;
00834   theDisk = new BoundDisk(PTEC6,theRotation2,TEC6);
00835   theDisk->setMediumProperties(_theMPEndcap);
00836   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00837     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00838                                          minDim(layerNr),maxDim(layerNr),
00839                                          fudgeFactors(layerNr)));
00840   else
00841     delete theDisk;
00842 
00843   layerNr = TrackerInteractionGeometry::TEC+7;
00844   theDisk = new BoundDisk(PTEC7,theRotation2,TEC7);
00845   theDisk->setMediumProperties(_theMPEndcap);
00846   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00847     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00848                                          minDim(layerNr),maxDim(layerNr),
00849                                          fudgeFactors(layerNr)));
00850   else
00851     delete theDisk;
00852 
00853   layerNr = TrackerInteractionGeometry::TEC+8;
00854   theDisk = new BoundDisk(PTEC8,theRotation2,TEC8);
00855   theDisk->setMediumProperties(_theMPEndcap);
00856   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00857     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00858                                          minDim(layerNr),maxDim(layerNr),
00859                                          fudgeFactors(layerNr)));
00860   else
00861     delete theDisk;
00862 
00863   layerNr = TrackerInteractionGeometry::TEC+9;
00864   theDisk = new BoundDisk(PTEC9,theRotation2,TEC9);
00865   theDisk->setMediumProperties(_theMPEndcap);
00866   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00867     _theCylinders.push_back(TrackerLayer(theDisk,layerNr,
00868                                          minDim(layerNr),maxDim(layerNr),
00869                                          fudgeFactors(layerNr)));
00870   else
00871     delete theDisk;
00872 
00873 
00874   // Tracker Outside
00875 
00876   layerNr = 113;
00877   theCylinder = new BoundCylinder(thePosition,theRotation,TBOut);
00878   theCylinder->setMediumProperties(_theMPBarrelOutside);
00879   if ( theCylinder->mediumProperties()->radLen() > 0. ) 
00880     _theCylinders.push_back(TrackerLayer(theCylinder,false,layerNr,
00881                                          minDim(layerNr),maxDim(layerNr),
00882                                          fudgeFactors(layerNr)));
00883   else
00884     delete theCylinder;
00885 
00886   layerNr = 114;
00887   theDisk = new BoundDisk(PTEOut,theRotation2,TEOut);
00888   theDisk->setMediumProperties(_theMPEndcapOutside);
00889   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00890     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00891                                          minDim(layerNr),maxDim(layerNr),
00892                                          fudgeFactors(layerNr)));
00893   else
00894     delete theDisk;
00895 
00896   layerNr = 115;
00897   theDisk = new BoundDisk(PTEOut2,theRotation2,TEOut2);
00898   theDisk->setMediumProperties(_theMPEndcapOutside2);
00899   if ( theDisk->mediumProperties()->radLen() > 0. ) 
00900     _theCylinders.push_back(TrackerLayer(theDisk,true,layerNr,
00901                                          minDim(layerNr),maxDim(layerNr),
00902                                          fudgeFactors(layerNr)));
00903   else
00904     delete theDisk;
00905 
00906   // Check overall compatibility of cylinder dimensions
00907   // (must be nested cylinders)
00908   // Throw an exception if the test fails
00909   double zin, rin;
00910   double zout, rout;
00911   unsigned nCyl=0;
00912   std::list<TrackerLayer>::const_iterator cyliterOut=cylinderBegin();
00913   // Inner cylinder dimensions
00914   if ( cyliterOut->forward() ) {
00915     zin = cyliterOut->disk()->position().z();
00916     rin = cyliterOut->disk()->outerRadius();
00917   } else {
00918     zin = cyliterOut->cylinder()->bounds().length()/2.;
00919     rin = cyliterOut->cylinder()->bounds().width()/2.;
00920   }
00921   // Go to the next cylinder
00922   ++cyliterOut;
00923   // And loop over all cylinders
00924   while ( cyliterOut != cylinderEnd() ) {
00925     // Outer cylinder dimensions
00926     if ( cyliterOut->forward() ) {
00927       zout = cyliterOut->disk()->position().z();
00928       rout = cyliterOut->disk()->outerRadius();
00929     } else {
00930       zout = cyliterOut->cylinder()->bounds().length()/2.;
00931       rout = cyliterOut->cylinder()->bounds().width()/2.;
00932     }
00933 
00934     nCyl++;
00935     if ( zout < zin || rout < rin ) { 
00936       throw cms::Exception("FastSimulation/TrackerInteractionGeometry ") 
00937         << " WARNING with cylinder number " << nCyl 
00938         << " (Active Layer Number = " <<  cyliterOut->layerNumber() 
00939         << " Forward ? " <<  cyliterOut->forward() << " ) "
00940         << " has dimensions smaller than previous cylinder : " << std::endl
00941         << " zout/zin = " << zout << " " << zin << std::endl
00942         << " rout/rin = " << rout << " " << rin << std::endl;
00943     } else {
00944       /*
00945       std::cout << " Cylinder number " << nCyl 
00946                 << " (Active Layer Number = " <<  cyliterOut->layerNumber() 
00947                 << " Forward ? " <<  cyliterOut->forward() << " ) "
00948                 << " has dimensions of : " 
00949                 << " zout = " << zout << "; " 
00950                 << " rout = " << rout << std::endl;
00951       */
00952     }
00953     // Go to the next cylinder
00954     cyliterOut++;
00955     // Inner cylinder becomes outer cylinder
00956     zin = zout;
00957     rin = rout;
00958     // End test
00959   } 
00960     
00961 }
00962 
00963 std::vector<double>
00964 TrackerInteractionGeometry::minDim(unsigned layerNr) { 
00965   std::vector<double> min;
00966   for ( unsigned iLayer=0; iLayer<fudgeFactor.size(); ++iLayer ) {   
00967     if ( layerNr != fudgeLayer[iLayer] ) continue;
00968     min.push_back(fudgeMin[iLayer]);
00969   }
00970   return min;
00971 }
00972 
00973 std::vector<double>
00974 TrackerInteractionGeometry::maxDim(unsigned layerNr) { 
00975   std::vector<double> max;
00976   for ( unsigned iLayer=0; iLayer<fudgeFactor.size(); ++iLayer ) {   
00977     if ( layerNr != fudgeLayer[iLayer] ) continue;
00978     max.push_back(fudgeMax[iLayer]);
00979   }
00980   return max;
00981 }
00982 
00983 std::vector<double>
00984 TrackerInteractionGeometry::fudgeFactors(unsigned layerNr) { 
00985   std::vector<double> fudge;
00986   for ( unsigned iLayer=0; iLayer<fudgeFactor.size(); ++iLayer ) {   
00987     if ( layerNr != fudgeLayer[iLayer] ) continue;
00988     fudge.push_back(fudgeFactor[iLayer]);
00989   }
00990   return fudge;
00991 }
00992 
00993 TrackerInteractionGeometry::~TrackerInteractionGeometry()
00994 {
00995   _theCylinders.clear();
00996   //  _theRings.clear();
00997 
00998   // The Beam pipe
00999   delete _theMPBeamPipe;
01000   // The pixel barrel layers
01001   delete _theMPPixelBarrel;
01002   // The pixel endcap disks
01003   delete _theMPPixelEndcap;
01004   // The various cables thicnesses for each layer / disks
01005   delete _theMPPixelOutside1;
01006   delete _theMPPixelOutside2;
01007   delete _theMPPixelOutside3;
01008   delete _theMPPixelOutside4;
01009   delete _theMPPixelOutside;
01010   delete _theMPPixelOutside5;
01011   delete _theMPPixelOutside6;
01012   // The tracker inner barrel layers
01013   delete _theMPTIB1;
01014   delete _theMPTIB2;
01015   delete _theMPTIB3;
01016   delete _theMPTIB4;
01017   // The tracker outer barrel layers
01018   delete _theMPTOB1;
01019   delete _theMPTOB2;
01020   delete _theMPTOB3;
01021   delete _theMPTOB4;
01022   delete _theMPTOB5;
01023   delete _theMPTOB6;
01024   // The tracker inner disks
01025   delete _theMPInner1;
01026   delete _theMPInner2;
01027   delete _theMPInner3;
01028   // The tracker endcap disks
01029   delete _theMPEndcap;
01030   // Various cable thicknesses 
01031   delete _theMPTOBBInside;
01032   delete _theMPTIBEOutside1;
01033   delete _theMPTIBEOutside2;
01034   delete _theMPTIDEOutside;
01035   delete _theMPTOBEOutside;
01036   delete _theMPBarrelOutside;
01037   delete _theMPEndcapOutside;
01038   delete _theMPEndcapOutside2;
01039 }