CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoEgamma/EgammaElectronAlgos/src/PixelMatchNextLayers.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    EgammaElectronAlgos
00004 // Class:      PixelMatchNextLayers
00005 // 
00013 //
00014 // Original Author:  Ursula Berthon, Claude Charlot
00015 //         Created:  Mon Mar 27 13:22:06 CEST 2006
00016 // $Id: PixelMatchNextLayers.cc,v 1.17 2011/04/08 08:54:09 innocent Exp $
00017 //
00018 //
00019 
00020 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00021 #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" 
00022 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00023 #include "RecoEgamma/EgammaElectronAlgos/interface/PixelMatchNextLayers.h"
00024 
00025 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00026 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00027 
00028 #include <iostream> 
00029 #include <algorithm>
00030 
00031  
00032 PixelMatchNextLayers::PixelMatchNextLayers(const LayerMeasurements * theLayerMeasurements,const DetLayer* ilayer, 
00033                                            FreeTrajectoryState & aFTS,
00034                                            const PropagatorWithMaterial *aProp,  
00035                                            const BarrelMeasurementEstimator *aBarrelMeas,
00036                                            const ForwardMeasurementEstimator *aForwardMeas,
00037                                            bool searchInTIDTEC)
00038  {
00039 
00040   typedef std::vector<TrajectoryMeasurement>::const_iterator aMeas;
00041   std::vector<const DetLayer*> allayers;
00042   std::vector<const DetLayer*> nl = ilayer->nextLayers( aFTS, alongMomentum);
00043   for (std::vector<const DetLayer*>::const_iterator il = nl.begin(); il != nl.end(); il++) {
00044     allayers.push_back(*il);
00045     std::vector<const DetLayer*> n2l = (*il)->nextLayers( aFTS, alongMomentum);
00046     for (std::vector<const DetLayer*>::const_iterator i2l = n2l.begin(); i2l != n2l.end(); i2l++) {
00047       allayers.push_back(*i2l);
00048     }
00049   }
00050 
00051   const TrajectoryStateOnSurface tsos(aFTS,ilayer->surface());
00052   
00053   if (tsos.isValid()) 
00054     {    
00055       for (std::vector<const DetLayer*>::const_iterator il = allayers.begin(); il != allayers.end(); il++) 
00056         {
00057           if ( (*il)->subDetector()==GeomDetEnumerators::PixelBarrel || (*il)->subDetector()==GeomDetEnumerators::PixelEndcap ) {
00058             
00059             std::vector<TrajectoryMeasurement> pixelMeasurements;
00060             if ((*il)->subDetector()==GeomDetEnumerators::PixelBarrel) {
00061               pixelMeasurements = theLayerMeasurements->measurements( **il, tsos , *aProp, *aBarrelMeas); 
00062             } else {
00063               pixelMeasurements = theLayerMeasurements->measurements( **il, tsos, *aProp, *aForwardMeas);
00064             }
00065             for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++){
00066               if (m == pixelMeasurements.begin()){
00067                 CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
00068                                       m->forwardPredictedState().globalPosition().y(),
00069                                       m->forwardPredictedState().globalPosition().z());
00070                 predictionHere.push_back( prediction);
00071               }
00072               if (m->recHit()->isValid()) {
00073                 measurementsHere.push_back( *m);
00074                 hitsHere.push_back( m->recHit());
00075 
00076                 //std::cout<<"\n SH B-D "<<std::endl;
00077 
00078               } else {
00079                 badMeasurementsHere.push_back( *m);
00080               }
00081             }
00082           }
00083           if (searchInTIDTEC) {   
00084           //additional search in the TID layers
00085           if ( ((*il)->subDetector())==GeomDetEnumerators::TID && (ilayer->location()) == GeomDetEnumerators::endcap)
00086             {
00087               std::vector<TrajectoryMeasurement> pixelMeasurements;
00088               pixelMeasurements = theLayerMeasurements->measurements( (**il), tsos , *aProp, *aForwardMeas); 
00089               
00090               for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++)
00091                 {
00092                   // limit search in first ring
00093                   if (TIDDetId(m->recHit()->geographicalId()).ring() > 1) continue;
00094                   if (m == pixelMeasurements.begin())
00095                     {
00096                       CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
00097                                             m->forwardPredictedState().globalPosition().y(),
00098                                             m->forwardPredictedState().globalPosition().z());
00099                       predictionHere.push_back( prediction);
00100                     }
00101                   if (m->recHit()->isValid()) 
00102                     {
00103                       measurementsHere.push_back( *m);
00104                       hitsHere.push_back(m->recHit());
00105                     }
00106                   // else{ std::cout<<" 2H not valid "<<std::endl;}
00107                 }
00108             } //end of TID search
00109           
00110           //additional search in the TEC layers
00111           if ( ((*il)->subDetector())==GeomDetEnumerators::TEC && (ilayer->location()) == GeomDetEnumerators::endcap)
00112             {
00113               std::vector<TrajectoryMeasurement> pixelMeasurements;
00114               pixelMeasurements = theLayerMeasurements->measurements( (**il), tsos , *aProp, *aForwardMeas); 
00115                       
00116               for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++)
00117                 {
00118                   // limit search in first ring and first third wheels
00119                   if (TECDetId(m->recHit()->geographicalId()).ring() > 1) continue;
00120                   if (TECDetId(m->recHit()->geographicalId()).wheel() > 3) continue;
00121                   if (m == pixelMeasurements.begin())
00122                     {
00123                       CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
00124                                             m->forwardPredictedState().globalPosition().y(),
00125                                             m->forwardPredictedState().globalPosition().z());
00126                       predictionHere.push_back( prediction);
00127                     }
00128                   if (m->recHit()->isValid()) 
00129                     {
00130                       measurementsHere.push_back( *m);
00131                       hitsHere.push_back(m->recHit());
00132 
00133                       //std::cout<<"\n SH TEC "<<std::endl;
00134 
00135                     }
00136                   // else{ std::cout<<" 2H not valid "<<std::endl;}
00137                 }
00138             } //end of TEC search
00139           }
00140         }
00141     } 
00142 }
00143 
00144   
00145 std::vector<TrajectoryMeasurement> PixelMatchNextLayers::measurementsInNextLayers() const {
00146 
00147   return measurementsHere;
00148 }
00149 
00150 std::vector<TrajectoryMeasurement> PixelMatchNextLayers::badMeasurementsInNextLayers() const {
00151 
00152   return badMeasurementsHere;
00153 }
00154 
00155 TransientTrackingRecHit::RecHitContainer PixelMatchNextLayers::hitsInNextLayers() const {
00156 
00157   return hitsHere;
00158 }
00159 
00160 std::vector<CLHEP::Hep3Vector> PixelMatchNextLayers::predictionInNextLayers() const {
00161 
00162   return predictionHere;
00163 }
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173