CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/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.14 2009/05/27 14:08:23 fabiocos Exp $
00017 //
00018 //
00019 
00020 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00021 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
00022 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
00023 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h" 
00024 #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" 
00025 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00026 #include "RecoEgamma/EgammaElectronAlgos/interface/BarrelMeasurementEstimator.h"
00027 #include "RecoEgamma/EgammaElectronAlgos/interface/ForwardMeasurementEstimator.h"
00028 #include "RecoEgamma/EgammaElectronAlgos/interface/PixelMatchNextLayers.h"
00029 
00030 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00031 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
00032 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00033 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00034 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00035 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00036 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00037 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00038 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00039 
00040 #include <iostream> 
00041 #include <algorithm>
00042 
00043  
00044 PixelMatchNextLayers::PixelMatchNextLayers(const LayerMeasurements * theLayerMeasurements,const DetLayer* ilayer, 
00045                                            FreeTrajectoryState & aFTS,
00046                                            const PropagatorWithMaterial *aProp,  
00047                                            const BarrelMeasurementEstimator *aBarrelMeas,
00048                                            const ForwardMeasurementEstimator *aForwardMeas,
00049                                            bool searchInTIDTEC)
00050  {
00051 
00052   typedef std::vector<TrajectoryMeasurement>::const_iterator aMeas;
00053   std::vector<const DetLayer*> allayers;
00054   std::vector<const DetLayer*> nl = ilayer->nextLayers( aFTS, alongMomentum);
00055   for (std::vector<const DetLayer*>::const_iterator il = nl.begin(); il != nl.end(); il++) {
00056     allayers.push_back(*il);
00057     std::vector<const DetLayer*> n2l = (*il)->nextLayers( aFTS, alongMomentum);
00058     for (std::vector<const DetLayer*>::const_iterator i2l = n2l.begin(); i2l != n2l.end(); i2l++) {
00059       allayers.push_back(*i2l);
00060     }
00061   }
00062 
00063   const TrajectoryStateOnSurface tsos(aFTS,ilayer->surface());
00064   
00065   if (tsos.isValid()) 
00066     {    
00067       for (std::vector<const DetLayer*>::const_iterator il = allayers.begin(); il != allayers.end(); il++) 
00068         {
00069           if ( (*il)->subDetector()==GeomDetEnumerators::PixelBarrel || (*il)->subDetector()==GeomDetEnumerators::PixelEndcap ) {
00070             
00071             std::vector<TrajectoryMeasurement> pixelMeasurements;
00072             if ((*il)->subDetector()==GeomDetEnumerators::PixelBarrel) {
00073               pixelMeasurements = theLayerMeasurements->measurements( **il, tsos , *aProp, *aBarrelMeas); 
00074             } else {
00075               pixelMeasurements = theLayerMeasurements->measurements( **il, tsos, *aProp, *aForwardMeas);
00076             }
00077             for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++){
00078               if (m == pixelMeasurements.begin()){
00079                 CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
00080                                       m->forwardPredictedState().globalPosition().y(),
00081                                       m->forwardPredictedState().globalPosition().z());
00082                 predictionHere.push_back( prediction);
00083               }
00084               if (m->recHit()->isValid()) {
00085                 measurementsHere.push_back( *m);
00086                 hitsHere.push_back( m->recHit());
00087 
00088                 //std::cout<<"\n SH B-D "<<std::endl;
00089 
00090               } else {
00091                 badMeasurementsHere.push_back( *m);
00092               }
00093             }
00094           }
00095           if (searchInTIDTEC) {   
00096           //additional search in the TID layers
00097           if ( ((*il)->subDetector())==GeomDetEnumerators::TID && (ilayer->location()) == GeomDetEnumerators::endcap)
00098             {
00099               std::vector<TrajectoryMeasurement> pixelMeasurements;
00100               pixelMeasurements = theLayerMeasurements->measurements( (**il), tsos , *aProp, *aForwardMeas); 
00101               
00102               for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++)
00103                 {
00104                   // limit search in first ring
00105                   if (TIDDetId(m->recHit()->geographicalId()).ring() > 1) continue;
00106                   if (m == pixelMeasurements.begin())
00107                     {
00108                       CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
00109                                             m->forwardPredictedState().globalPosition().y(),
00110                                             m->forwardPredictedState().globalPosition().z());
00111                       predictionHere.push_back( prediction);
00112                     }
00113                   if (m->recHit()->isValid()) 
00114                     {
00115                       measurementsHere.push_back( *m);
00116                       hitsHere.push_back(m->recHit());
00117                     }
00118                   // else{ std::cout<<" 2H not valid "<<std::endl;}
00119                 }
00120             } //end of TID search
00121           
00122           //additional search in the TEC layers
00123           if ( ((*il)->subDetector())==GeomDetEnumerators::TEC && (ilayer->location()) == GeomDetEnumerators::endcap)
00124             {
00125               std::vector<TrajectoryMeasurement> pixelMeasurements;
00126               pixelMeasurements = theLayerMeasurements->measurements( (**il), tsos , *aProp, *aForwardMeas); 
00127                       
00128               for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++)
00129                 {
00130                   // limit search in first ring and first third wheels
00131                   if (TECDetId(m->recHit()->geographicalId()).ring() > 1) continue;
00132                   if (TECDetId(m->recHit()->geographicalId()).wheel() > 3) continue;
00133                   if (m == pixelMeasurements.begin())
00134                     {
00135                       CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
00136                                             m->forwardPredictedState().globalPosition().y(),
00137                                             m->forwardPredictedState().globalPosition().z());
00138                       predictionHere.push_back( prediction);
00139                     }
00140                   if (m->recHit()->isValid()) 
00141                     {
00142                       measurementsHere.push_back( *m);
00143                       hitsHere.push_back(m->recHit());
00144 
00145                       //std::cout<<"\n SH TEC "<<std::endl;
00146 
00147                     }
00148                   // else{ std::cout<<" 2H not valid "<<std::endl;}
00149                 }
00150             } //end of TEC search
00151           }
00152         }
00153     } 
00154 }
00155 
00156   
00157 std::vector<TrajectoryMeasurement> PixelMatchNextLayers::measurementsInNextLayers() const {
00158 
00159   return measurementsHere;
00160 }
00161 
00162 std::vector<TrajectoryMeasurement> PixelMatchNextLayers::badMeasurementsInNextLayers() const {
00163 
00164   return badMeasurementsHere;
00165 }
00166 
00167 TransientTrackingRecHit::RecHitContainer PixelMatchNextLayers::hitsInNextLayers() const {
00168 
00169   return hitsHere;
00170 }
00171 
00172 std::vector<CLHEP::Hep3Vector> PixelMatchNextLayers::predictionInNextLayers() const {
00173 
00174   return predictionHere;
00175 }
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185