CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoTracker/TkDetLayers/src/TIBLayerBuilder.cc

Go to the documentation of this file.
00001 #include "TIBLayerBuilder.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 #include "TIBRingBuilder.h"
00006 
00007 using namespace edm;
00008 using namespace std;
00009 
00010 TIBLayer* TIBLayerBuilder::build(const GeometricDet* aTIBLayer,
00011                                  const TrackerGeometry* theGeomDetGeometry)
00012 {
00013   vector<const GeometricDet*> theGeometricRods = aTIBLayer->components();
00014   
00015   vector<vector<const GeometricDet*> > innerGeometricDetRings; 
00016   vector<vector<const GeometricDet*> > outerGeometricDetRings;
00017   
00018   constructRings(theGeometricRods,innerGeometricDetRings,outerGeometricDetRings);
00019 
00020   TIBRingBuilder myRingBuilder;
00021 
00022   vector<const TIBRing*> innerRings;
00023   vector<const TIBRing*> outerRings;
00024 
00025   for(unsigned int i=0; i<innerGeometricDetRings.size(); i++){
00026     innerRings.push_back(myRingBuilder.build(innerGeometricDetRings[i],theGeomDetGeometry));
00027     outerRings.push_back(myRingBuilder.build(outerGeometricDetRings[i],theGeomDetGeometry));
00028   }
00029     
00030   return new TIBLayer(innerRings,outerRings);
00031 }
00032 
00033 
00034 
00035 
00036 void 
00037 TIBLayerBuilder::constructRings(vector<const GeometricDet*>& theGeometricRods,
00038                                 vector<vector<const GeometricDet*> >& innerGeometricDetRings,
00039                                 vector<vector<const GeometricDet*> >& outerGeometricDetRings)
00040 {
00041   double meanPerp=0;
00042   for(vector<const GeometricDet*>::const_iterator it=theGeometricRods.begin(); 
00043       it!= theGeometricRods.end();it++){
00044     meanPerp = meanPerp + (*it)->positionBounds().perp();
00045   }
00046   meanPerp = meanPerp/theGeometricRods.size();
00047   
00048   vector<const GeometricDet*> theInnerGeometricRods;
00049   vector<const GeometricDet*> theOuterGeometricRods;
00050 
00051   for(vector<const GeometricDet*>::const_iterator it=theGeometricRods.begin(); 
00052       it!= theGeometricRods.end();it++){
00053     if( (*it)->positionBounds().perp() < meanPerp) theInnerGeometricRods.push_back(*it);
00054     if( (*it)->positionBounds().perp() > meanPerp) theOuterGeometricRods.push_back(*it);
00055   }
00056 
00057   size_t innerLeftRodMaxSize  = 0;
00058   size_t innerRightRodMaxSize = 0;
00059   size_t outerLeftRodMaxSize  = 0;
00060   size_t outerRightRodMaxSize = 0;
00061 
00062   for(vector<const GeometricDet*>::const_iterator it=theInnerGeometricRods.begin(); 
00063       it!= theInnerGeometricRods.end();it++){
00064     if( (*it)->positionBounds().z() < 0) 
00065       innerLeftRodMaxSize  = max(innerLeftRodMaxSize,  (**it).components().size());
00066     if( (*it)->positionBounds().z() > 0) 
00067       innerRightRodMaxSize = max(innerRightRodMaxSize, (**it).components().size());
00068   }
00069 
00070   for(vector<const GeometricDet*>::const_iterator it=theOuterGeometricRods.begin(); 
00071       it!= theOuterGeometricRods.end();it++){
00072     if( (*it)->positionBounds().z() < 0) 
00073       outerLeftRodMaxSize  = max(outerLeftRodMaxSize,  (**it).components().size());
00074     if( (*it)->positionBounds().z() > 0) 
00075       outerRightRodMaxSize = max(outerRightRodMaxSize, (**it).components().size());
00076   }
00077 
00078   LogDebug("TkDetLayers") << "innerLeftRodMaxSize: " << innerLeftRodMaxSize ;
00079   LogDebug("TkDetLayers") << "innerRightRodMaxSize: " << innerRightRodMaxSize ;
00080 
00081   LogDebug("TkDetLayers") << "outerLeftRodMaxSize: " << outerLeftRodMaxSize ;
00082   LogDebug("TkDetLayers") << "outerRightRodMaxSize: " << outerRightRodMaxSize ;
00083 
00084   for(unsigned int i=0;i< (innerLeftRodMaxSize+innerRightRodMaxSize);i++){
00085     innerGeometricDetRings.push_back(vector<const GeometricDet*>());
00086   }
00087 
00088   for(unsigned int i=0;i< (outerLeftRodMaxSize+outerRightRodMaxSize);i++){
00089     outerGeometricDetRings.push_back(vector<const GeometricDet*>());
00090   }
00091   
00092   for(unsigned int ringN = 0; ringN < innerLeftRodMaxSize; ringN++){
00093     for(vector<const GeometricDet*>::const_iterator it=theInnerGeometricRods.begin(); 
00094         it!= theInnerGeometricRods.end();it++){
00095       if( (*it)->positionBounds().z() < 0){
00096         if( (**it).components().size()>ringN)
00097           innerGeometricDetRings[ringN].push_back( (**it).components()[ringN] );
00098       }
00099     }
00100   }
00101   
00102   for(unsigned int ringN = 0; ringN < innerRightRodMaxSize; ringN++){
00103     for(vector<const GeometricDet*>::const_iterator it=theInnerGeometricRods.begin(); 
00104         it!= theInnerGeometricRods.end();it++){
00105       if( (*it)->positionBounds().z() > 0){
00106         if( (**it).components().size()>ringN)
00107           innerGeometricDetRings[innerLeftRodMaxSize+ringN].push_back( (**it).components()[ringN] );
00108       }
00109     }
00110   }
00111 
00112 
00113   for(unsigned int ringN = 0; ringN < outerLeftRodMaxSize; ringN++){
00114     for(vector<const GeometricDet*>::const_iterator it=theOuterGeometricRods.begin(); 
00115         it!= theOuterGeometricRods.end();it++){
00116       if( (*it)->positionBounds().z() < 0){
00117         if( (**it).components().size()>ringN)
00118           outerGeometricDetRings[ringN].push_back( (**it).components()[ringN] );
00119       }
00120     }
00121   }
00122   
00123   for(unsigned int ringN = 0; ringN < outerRightRodMaxSize; ringN++){
00124     for(vector<const GeometricDet*>::const_iterator it=theOuterGeometricRods.begin(); 
00125         it!= theOuterGeometricRods.end();it++){
00126       if( (*it)->positionBounds().z() > 0){
00127         if( (**it).components().size()>ringN)
00128           outerGeometricDetRings[outerLeftRodMaxSize+ringN].push_back( (**it).components()[ringN] );
00129       }
00130     }
00131   }
00132   
00133 }
00134 
00135 
00136