CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h"
00002 
00003 #include "PixelBarrelLayerBuilder.h"
00004 #include "PixelForwardLayerBuilder.h"
00005 #include "TIBLayerBuilder.h"
00006 #include "TOBLayerBuilder.h"
00007 #include "TIDLayerBuilder.h"
00008 #include "TECLayerBuilder.h"
00009 
00010 #include "Geometry/TrackerGeometryBuilder/interface/trackerHierarchy.h"
00011 
00012 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00013 
00014 
00015 #include "DataFormats/Common/interface/Trie.h"
00016 #include <boost/function.hpp>
00017 #include <boost/bind.hpp>
00018 
00019 using namespace std;
00020 
00021 GeometricSearchTracker*
00022 GeometricSearchTrackerBuilder::build(const GeometricDet* theGeometricTracker,
00023                                      const TrackerGeometry* theGeomDetGeometry)
00024 {
00025   PixelBarrelLayerBuilder aPixelBarrelLayerBuilder;
00026   PixelForwardLayerBuilder aPixelForwardLayerBuilder;
00027   TIBLayerBuilder aTIBLayerBuilder;
00028   TOBLayerBuilder aTOBLayerBuilder;
00029   TIDLayerBuilder aTIDLayerBuilder;
00030   TECLayerBuilder aTECLayerBuilder;
00031 
00032   vector<BarrelDetLayer*>  thePxlBarLayers;
00033   vector<BarrelDetLayer*>  theTIBLayers;
00034   vector<BarrelDetLayer*>  theTOBLayers;
00035   vector<ForwardDetLayer*> theNegPxlFwdLayers;
00036   vector<ForwardDetLayer*> thePosPxlFwdLayers;
00037   vector<ForwardDetLayer*> theNegTIDLayers;
00038   vector<ForwardDetLayer*> thePosTIDLayers;
00039   vector<ForwardDetLayer*> theNegTECLayers;
00040   vector<ForwardDetLayer*> thePosTECLayers;
00041   
00042   using namespace trackerTrie;
00043 
00044   //-- future code
00045   // create a Trie
00046   DetTrie trie(0);
00047 
00048   // to be moved elsewhere
00049   {
00050     const TrackingGeometry::DetUnitContainer&  modules = theGeomDetGeometry->detUnits(); 
00051     typedef TrackingGeometry::DetUnitContainer::const_iterator Iter;
00052     Iter b=modules.begin();
00053     Iter e=modules.end();
00054     Iter last;
00055     try {
00056       for(;b!=e; ++b) {
00057         last = b;
00058         unsigned int rawid = (*b)->geographicalId().rawId();
00059         trie.insert(trackerHierarchy(rawid), *b); 
00060       }
00061     }
00062     catch(edm::Exception const & e) {
00063       std::cout << "in filling " << e.what() << std::endl;
00064       unsigned int rawid = (*last)->geographicalId().rawId();
00065       int subdetid = (*last)->geographicalId().subdetId();
00066       std::cout << rawid << " " << subdetid << std::endl;
00067     }  
00068   }
00069 
00070   // layers "ids"
00071   unsigned int layerId[] = {1,3,5,21,22,41,42,61,62};
00072   //  boost::function<void(trackerTrie::Node const &)> fun[9]; 
00073   /*
00074         thePxlBarLayers.push_back( aPixelBarrelLayerBuilder.build(*p) );
00075         theTIBLayers.push_back( aTIBLayerBuilder.build(*p) );
00076         theTOBLayers.push_back( aTOBLayerBuilder.build(*p) );
00077         theNegPxlFwdLayers.push_back( aPixelForwardLayerBuilder.build(*p) );
00078         thePosPxlFwdLayers.push_back( aPixelForwardLayerBuilder.build(*p) );
00079         theNegTIDLayers.push_back( aTIDLayerBuilder.build(*p) );
00080         thePosTIDLayers.push_back( aTIDLayerBuilder.build(*p) );
00081         theNegTECLayers.push_back( aTECLayerBuilder.build(*p) );
00082         thePosTECLayers.push_back( aTECLayerBuilder.build(*p) );
00083   */
00084    
00085 
00086   for (int i=0;i<9;i++) {
00087     std::string s;
00088     if (layerId[i]>9) s+=char(layerId[i]/10); 
00089     s+=char(layerId[i]%10);
00090     node_iterator e;    
00091     node_iterator p(trie.node(s));
00092     for (;p!=e;++p) {
00093       //    fun[i](*p);
00094     }
00095   }    
00096 
00097 
00098   // current code
00099   vector<const GeometricDet*> theGeometricDetLayers = theGeometricTracker->components();
00100   for(vector<const GeometricDet*>::const_iterator it=theGeometricDetLayers.begin();
00101       it!=theGeometricDetLayers.end(); it++){
00102 
00103     if( (*it)->type() == GeometricDet::PixelBarrel) {
00104       vector<const GeometricDet*> thePxlBarGeometricDetLayers = (*it)->components();
00105       for(vector<const GeometricDet*>::const_iterator it2=thePxlBarGeometricDetLayers.begin();
00106           it2!=thePxlBarGeometricDetLayers.end(); it2++){
00107         thePxlBarLayers.push_back( aPixelBarrelLayerBuilder.build(*it2,theGeomDetGeometry) );
00108       }
00109     }
00110     
00111     if( (*it)->type() == GeometricDet::TIB) {
00112       vector<const GeometricDet*> theTIBGeometricDetLayers = (*it)->components();
00113       for(vector<const GeometricDet*>::const_iterator it2=theTIBGeometricDetLayers.begin();
00114           it2!=theTIBGeometricDetLayers.end(); it2++){
00115         theTIBLayers.push_back( aTIBLayerBuilder.build(*it2,theGeomDetGeometry) );
00116       }
00117     }
00118 
00119     if( (*it)->type() == GeometricDet::TOB) {
00120       vector<const GeometricDet*> theTOBGeometricDetLayers = (*it)->components();
00121       for(vector<const GeometricDet*>::const_iterator it2=theTOBGeometricDetLayers.begin();       
00122       it2!=theTOBGeometricDetLayers.end(); it2++){
00123         theTOBLayers.push_back( aTOBLayerBuilder.build(*it2,theGeomDetGeometry) );
00124       }
00125     }
00126 
00127     
00128     if( (*it)->type() == GeometricDet::PixelEndCap || (*it)->type() == GeometricDet::PixelEndCapPhase1 ){
00129       vector<const GeometricDet*> thePxlFwdGeometricDetLayers = (*it)->components();
00130       for(vector<const GeometricDet*>::const_iterator it2=thePxlFwdGeometricDetLayers.begin();
00131           it2!=thePxlFwdGeometricDetLayers.end(); it2++){
00132         if((*it2)->positionBounds().z() < 0)
00133           theNegPxlFwdLayers.push_back( aPixelForwardLayerBuilder.build(*it2,theGeomDetGeometry) );
00134         if((*it2)->positionBounds().z() > 0)
00135           thePosPxlFwdLayers.push_back( aPixelForwardLayerBuilder.build(*it2,theGeomDetGeometry) );
00136       }
00137     }
00138     
00139 
00140 
00141     if( (*it)->type() == GeometricDet::TID){
00142       vector<const GeometricDet*> theTIDGeometricDetLayers = (*it)->components();
00143       for(vector<const GeometricDet*>::const_iterator it2=theTIDGeometricDetLayers.begin();
00144       it2!=theTIDGeometricDetLayers.end(); it2++){
00145         if((*it2)->positionBounds().z() < 0)
00146           theNegTIDLayers.push_back( aTIDLayerBuilder.build(*it2,theGeomDetGeometry) );
00147         if((*it2)->positionBounds().z() > 0)
00148           thePosTIDLayers.push_back( aTIDLayerBuilder.build(*it2,theGeomDetGeometry) );
00149       }
00150     }
00151 
00152     if( (*it)->type() == GeometricDet::TEC) {
00153       vector<const GeometricDet*> theTECGeometricDetLayers = (*it)->components();
00154       for(vector<const GeometricDet*>::const_iterator it2=theTECGeometricDetLayers.begin();
00155       it2!=theTECGeometricDetLayers.end(); it2++){
00156         if((*it2)->positionBounds().z() < 0)
00157           theNegTECLayers.push_back( aTECLayerBuilder.build(*it2,theGeomDetGeometry) );
00158         if((*it2)->positionBounds().z() > 0)
00159           thePosTECLayers.push_back( aTECLayerBuilder.build(*it2,theGeomDetGeometry) );
00160       }
00161     }
00162 
00163 
00164   }
00165   
00166 
00167   return new GeometricSearchTracker(thePxlBarLayers,theTIBLayers,theTOBLayers,
00168                                     theNegPxlFwdLayers,theNegTIDLayers,theNegTECLayers,
00169                                     thePosPxlFwdLayers,thePosTIDLayers,thePosTECLayers);
00170 }