CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoEgamma/EgammaPhotonAlgos/src/ConversionSeedFinder.cc

Go to the documentation of this file.
00001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00002 #include "RecoEgamma/EgammaPhotonAlgos/interface/ConversionSeedFinder.h"
00003 // Field
00004 // Geometry
00005 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00006 //
00007 #include "RecoTracker/TkNavigation/interface/StartingLayerFinder.h"
00008 #include "RecoTracker/TkNavigation/interface/LayerCollector.h"
00009 //
00010 
00011 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00012 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
00013 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"
00014 
00015 ConversionSeedFinder::ConversionSeedFinder(const edm::ParameterSet& config ): 
00016   conf_(config),
00017   theUpdator_()
00018 {
00019 
00020   LogDebug("ConversionSeedFinder")  << " CTOR " << "\n";
00021 
00022   theMeasurementTrackerName_=config.getParameter<std::string>("MeasurementTrackerName");
00023 }
00024 
00025 
00026 
00027 void ConversionSeedFinder::setEvent(const edm::Event& evt  )  {
00028  
00029   theMeasurementTracker_->update(evt);
00030   theTrackerGeom_= this->getMeasurementTracker()->geomTracker();
00031 
00032   //get the BeamSpot
00033   edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00034   evt.getByLabel("offlineBeamSpot",recoBeamSpotHandle);
00035   theBeamSpot_ = *recoBeamSpotHandle;
00036 
00037 
00038 
00039 }
00040 
00041 void ConversionSeedFinder::setEventSetup(const edm::EventSetup& es  )  {
00042   es.get<TrackerRecoGeometryRecord>().get( theGeomSearchTracker_);
00043   es.get<IdealMagneticFieldRecord>().get( theMF_ );
00044 
00045 
00046   edm::ESHandle<MeasurementTracker> measurementTrackerHandle;
00047   es.get<CkfComponentsRecord>().get(theMeasurementTrackerName_,measurementTrackerHandle);
00048   theMeasurementTracker_ = measurementTrackerHandle.product();
00049   
00050   edm::ESHandle<Propagator>  propagatorAlongMomHandle;
00051   es.get<TrackingComponentsRecord>().get("alongMomElePropagator",propagatorAlongMomHandle);
00052   thePropagatorAlongMomentum_ = &(*propagatorAlongMomHandle);
00053  
00054 
00055   edm::ESHandle<Propagator>  propagatorOppoToMomHandle;
00056   es.get<TrackingComponentsRecord>().get("oppositeToMomElePropagator",propagatorOppoToMomHandle);
00057   thePropagatorOppositeToMomentum_ = &(*propagatorOppoToMomHandle);
00058 
00059 
00060 
00061 
00062 }
00063 
00064 
00065 void ConversionSeedFinder::findLayers() const {
00066   
00067 
00068   int charge;
00069   //List the DetLayers crossed by a straight line from the centre of the 
00070   //detector to the supercluster position
00071   //  GlobalPoint  vertex(0.,0.,0.);
00072   GlobalPoint  vertex(theBeamSpot_.position().x(),theBeamSpot_.position().y(),theBeamSpot_.position().z()); 
00073   charge=-1;  
00074   FreeTrajectoryState theStraightLineFTS = trackStateFromClusters(charge, vertex, alongMomentum, 1.);
00075   
00076   findLayers( theStraightLineFTS  );
00077   
00078   
00079 }
00080 
00081 FreeTrajectoryState ConversionSeedFinder::trackStateFromClusters( int charge, const GlobalPoint  & theOrigin, 
00082                                                                   PropagationDirection dir, float scaleFactor) const {
00083   
00084   
00085 
00086   double caloEnergy = theSCenergy_ * scaleFactor ;
00087   
00088   GlobalVector radiusCalo = theSCPosition_ - theOrigin ;
00089   
00090   GlobalVector momentumWithoutCurvature = radiusCalo.unit() * caloEnergy;
00091   
00092   
00093   GlobalTrajectoryParameters gtp;
00094   if(dir == alongMomentum) {
00095     gtp = GlobalTrajectoryParameters(theOrigin, momentumWithoutCurvature, charge, &(*theMF_) ) ;
00096   } else {
00097     gtp = GlobalTrajectoryParameters(theSCPosition_, momentumWithoutCurvature, charge, &(*theMF_) ) ;
00098   }
00099 
00100 
00101 
00102   
00103   // now create error matrix
00104   // dpos = 4mm/sqrt(E), dtheta = move vertex by 1sigma
00105   float dpos = 0.4/sqrt(theSCenergy_);
00106   dpos *= 2.;
00107   float dphi = dpos/theSCPosition_.perp();
00108   //  float dp = 0.03 * sqrt(theCaloEnergy);
00109   //  float dp = theCaloEnergy / sqrt(12.); // for fun
00110   float theta1 = theSCPosition_.theta();
00111   float theta2 = atan2(double(theSCPosition_.perp()), theSCPosition_.z()-5.5);
00112   float dtheta = theta1 - theta2;
00113   AlgebraicSymMatrix55  m;
00114   m[0][0] = 1.; m[1][1] = dpos*dpos ; m[2][2] = dpos*dpos ;
00115   m[3][3] = dphi*dphi ; m[4][4] = dtheta * dtheta ;
00116 
00117   FreeTrajectoryState fts(gtp, CurvilinearTrajectoryError(m)) ;
00118 
00119   return fts ;
00120 
00121 
00122 }
00123 
00124 void ConversionSeedFinder::findLayers(const FreeTrajectoryState & traj) const {
00125 
00126 
00127 
00128   theLayerList_.clear();
00129 
00130 
00131   StraightLinePropagator prop( &(*theMF_), alongMomentum);
00132 
00133   StartingLayerFinder starter(&prop, this->getMeasurementTracker() );
00134  
00135   LayerCollector collector(&prop, &starter, 5., 5.);
00136 
00137   theLayerList_ = collector.allLayers(traj);
00138 
00139   
00140   for(unsigned int i = 0; i < theLayerList_.size(); ++i) {
00141     printLayer(i);
00142   }
00143   
00144 
00145 }
00146 
00147 
00148 void ConversionSeedFinder::printLayer(int i) const {
00149   const DetLayer * layer = theLayerList_[i];
00150   if (layer->location() == GeomDetEnumerators::barrel ) {
00151     //    const BarrelDetLayer * barrelLayer = dynamic_cast<const BarrelDetLayer*>(layer);
00152     //float r = barrelLayer->specificSurface().radius();
00153     //    std::cout   <<  " barrel layer radius " << r << " " << barrelLayer->specificSurface().bounds().length()/2. << "\n";
00154 
00155   } else {
00156     //    const ForwardDetLayer * forwardLayer = dynamic_cast<const ForwardDetLayer*>(layer);
00157     // float z =  fabs(forwardLayer->surface().position().z());
00158     //    std::cout   << " forward layer position " << z << " " << forwardLayer->specificSurface().innerRadius() << " " << forwardLayer->specificSurface().outerRadius() << "\n";
00159   }
00160 }
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171