CMS 3D CMS Logo

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