CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/TkDetLayers/src/TOBLayerBuilder.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkDetLayers/interface/TOBLayerBuilder.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 #include "RecoTracker/TkDetLayers/interface/TOBRodBuilder.h"
00006 
00007 using namespace edm;
00008 using namespace std;
00009 
00010 TOBLayer* TOBLayerBuilder::build(const GeometricDet* aTOBLayer,
00011                                  const TrackerGeometry* theGeomDetGeometry){
00012 
00013   vector<const GeometricDet*>  theGeometricDetRods = aTOBLayer->components();
00014   vector<const GeometricDet*> negativeZrods;
00015   vector<const GeometricDet*> positiveZrods;
00016 
00017   for(vector<const GeometricDet*>::const_iterator it=theGeometricDetRods.begin();
00018       it!=theGeometricDetRods.end(); it++){
00019     if( (*it)->positionBounds().z() < 0) negativeZrods.push_back(*it);
00020     if( (*it)->positionBounds().z() >= 0) positiveZrods.push_back(*it);
00021   }
00022 
00023   TOBRodBuilder myTOBRodBuilder;
00024 
00025   vector<const TOBRod*> theInnerRods;
00026   vector<const TOBRod*> theOuterRods;
00027   
00028   //LogDebug("TkDetLayers") << "positiveZrods[0]->positionBounds().perp(): " 
00029   //                      << positiveZrods[0]->positionBounds().perp() ;
00030   //LogDebug("TkDetLayers") << "positiveZrods[1]->positionBounds().perp(): " 
00031   //                      << positiveZrods[1]->positionBounds().perp() ;
00032 
00033   double positiveMeanR = 0;
00034   if(positiveZrods.size()>0){
00035     for(unsigned int index=0; index!=positiveZrods.size(); index++){
00036       positiveMeanR += positiveZrods[index]->positionBounds().perp();
00037     }
00038     positiveMeanR = positiveMeanR/positiveZrods.size();
00039   }
00040 
00041 
00042   double negativeMeanR = 0;
00043   if(negativeZrods.size()>0){
00044     for(unsigned int index=0; index!=negativeZrods.size(); index++){
00045       negativeMeanR += negativeZrods[index]->positionBounds().perp();
00046     }
00047     negativeMeanR = negativeMeanR/negativeZrods.size();
00048   }
00049 
00050   if(positiveZrods.size()>0 && negativeZrods.size()>0){
00051     for(unsigned int index=0; index!=positiveZrods.size(); index++){
00052       if( positiveZrods[index]->positionBounds().phi() != negativeZrods[index]->positionBounds().phi()){
00053         edm::LogError("TkDetLayers") << "ERROR:rods don't have the same phi. exit!";
00054         break;      
00055       }
00056 
00057       if(positiveZrods[index]->positionBounds().perp() < positiveMeanR)
00058         theInnerRods.push_back(myTOBRodBuilder.build(negativeZrods[index],
00059                                                      positiveZrods[index],
00060                                                      theGeomDetGeometry)    );       
00061       if(positiveZrods[index]->positionBounds().perp() >= positiveMeanR)
00062         theOuterRods.push_back(myTOBRodBuilder.build(negativeZrods[index],
00063                                                      positiveZrods[index],
00064                                                      theGeomDetGeometry)    );
00065     }
00066   } else{
00067     if(positiveZrods.size()>0){
00068       for(unsigned int index=0; index!=positiveZrods.size(); index++){
00069         if(positiveZrods[index]->positionBounds().perp() < positiveMeanR)
00070           theInnerRods.push_back(myTOBRodBuilder.build(0,
00071                                                        positiveZrods[index],
00072                                                        theGeomDetGeometry)    );       
00073         if(positiveZrods[index]->positionBounds().perp() >= positiveMeanR)
00074           theOuterRods.push_back(myTOBRodBuilder.build(0,
00075                                                        positiveZrods[index],
00076                                                        theGeomDetGeometry)    );       
00077       }
00078     }
00079     if(negativeZrods.size()>0){
00080       for(unsigned int index=0; index!=negativeZrods.size(); index++){
00081         if(negativeZrods[index]->positionBounds().perp() < negativeMeanR)
00082           theInnerRods.push_back(myTOBRodBuilder.build(negativeZrods[index],
00083                                                        0,
00084                                                        theGeomDetGeometry)    );       
00085         if(negativeZrods[index]->positionBounds().perp() >= negativeMeanR)
00086           theOuterRods.push_back(myTOBRodBuilder.build(negativeZrods[index],
00087                                                        0,
00088                                                        theGeomDetGeometry)    );
00089       }
00090     }
00091   }
00092   
00093   //LogDebug("TkDetLayers") << "theInnerRods.size(): " << theInnerRods.size() ;
00094   //LogDebug("TkDetLayers") << "theOuterRods.size(): " << theOuterRods.size() ;
00095   
00096 
00097   return new TOBLayer(theInnerRods,theOuterRods);
00098 }