Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <vector>
00016 #include <iostream>
00017 #include <cmath>
00018
00019 #include "RecoTracker/RoadSearchHelixMaker/interface/RoadSearchHelixMakerAlgorithm.h"
00020
00021 #include "DataFormats/Common/interface/Handle.h"
00022 #include "FWCore/Framework/interface/ESHandle.h"
00023 #include "FWCore/Framework/interface/EventSetup.h"
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025
00026 #include "DataFormats/TrackCandidate/interface/TrackCandidate.h"
00027 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00028
00029 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00030 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00031 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00032 #include "DataFormats/GeometrySurface/interface/Surface.h"
00033 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00034 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00035
00036 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00037 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00038
00039 #include "Geometry/CommonTopologies/interface/TrapezoidalStripTopology.h"
00040 #include "Geometry/CommonTopologies/interface/RectangularStripTopology.h"
00041 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00042
00043 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHel.hh"
00044 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxFittedHel.hh"
00045 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxHit.hh"
00046 #include "RecoTracker/RoadSearchHelixMaker/interface/DcxTrackCandidatesToTracks.hh"
00047
00048 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00049
00050 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00051 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00052 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00053 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00054
00055 RoadSearchHelixMakerAlgorithm::RoadSearchHelixMakerAlgorithm(const edm::ParameterSet& conf) : conf_(conf) {
00056 }
00057
00058 RoadSearchHelixMakerAlgorithm::~RoadSearchHelixMakerAlgorithm() {
00059 }
00060
00061 void RoadSearchHelixMakerAlgorithm::run(const TrackCandidateCollection* input,
00062 const edm::EventSetup& es,
00063 reco::TrackCollection &output)
00064 {
00065
00066 edm::LogInfo("RoadSearch") << "Input of " << input->size() << " track candidate(s).";
00067
00068
00069
00070
00071 if ( input->empty() ){
00072 edm::LogInfo("RoadSearch") << "Created " << output.size() << " tracks.";
00073 return;
00074 }
00075
00076
00077
00078
00079
00080
00081 edm::ESHandle<TrackerGeometry> tracker;
00082 es.get<TrackerDigiGeometryRecord>().get(tracker);
00083
00084
00085 edm::ESHandle<MagneticField> fieldHandle;
00086 es.get<IdealMagneticFieldRecord>().get(fieldHandle);
00087 const MagneticField *field = fieldHandle.product();
00088
00089 unsigned int trackcandidate_ctr=0;
00090
00091
00092 for ( TrackCandidateCollection::const_iterator trackcandidate = input->begin(); trackcandidate != input->end(); ++trackcandidate ) {
00093 TrackCandidate currentCandidate = *trackcandidate;
00094 ++trackcandidate_ctr;
00095 unsigned int trackcandidate_number_rechits = 0;
00096 TrackCandidate::range recHitRange = currentCandidate.recHits();
00097 for ( TrackCandidate::const_iterator recHit = recHitRange.first; recHit != recHitRange.second; ++recHit ) {
00098 ++trackcandidate_number_rechits;
00099 }
00100
00101 LogDebug("RoadSearch") << "Track candidate number, number of TrackingRecHits = " << trackcandidate_ctr << " "
00102 << trackcandidate_number_rechits;
00103
00104
00105
00106
00107 edm::LogInfo("RoadSearch") << "Beware - Use Simple Helix Fitted Tracks only for Debugging Purposes!!" ;
00108
00109 std::vector<DcxHit*> listohits;
00110
00111 for ( TrackCandidate::const_iterator recHit = recHitRange.first; recHit != recHitRange.second; ++recHit ) {
00112 DetId recHitId = recHit->geographicalId();
00113 const GeomDet *recHitGeomDet = tracker->idToDet(recHitId);
00114 GlobalPoint hit_global_pos = recHitGeomDet->surface().toGlobal(recHit->localPosition());
00115
00116 if ( (unsigned int)recHitId.subdetId() == StripSubdetector::TIB ||
00117 (unsigned int)recHitId.subdetId() == StripSubdetector::TOB ) {
00118 const GeomDetUnit *recHitGeomDetUnit;
00119
00120 const GluedGeomDet *recHitGluedGeomDet = dynamic_cast<const GluedGeomDet*>(recHitGeomDet);
00121 if ( recHitGluedGeomDet != 0 ) {
00122 recHitGeomDetUnit = recHitGluedGeomDet->monoDet();
00123 } else {
00124 recHitGeomDetUnit = tracker->idToDetUnit(recHitId);
00125 }
00126 const StripTopology *recHitTopology = dynamic_cast<const StripTopology*>(&(recHitGeomDetUnit->topology()));
00127 double iLength = recHitTopology->stripLength();
00128 LocalPoint temp_lpos = recHit->localPosition();
00129 LocalPoint temp_lpos_f(temp_lpos.x(),temp_lpos.y()+iLength/2.0,temp_lpos.z());
00130 LocalPoint temp_lpos_b(temp_lpos.x(),temp_lpos.y()-iLength/2.0,temp_lpos.z());
00131 GlobalPoint temp_gpos_f = recHitGeomDet->surface().toGlobal(temp_lpos_f);
00132 GlobalPoint temp_gpos_b = recHitGeomDet->surface().toGlobal(temp_lpos_b);
00133 GlobalVector fir_uvec((temp_gpos_f.x()-temp_gpos_b.x())/iLength,
00134 (temp_gpos_f.y()-temp_gpos_b.y())/iLength,(temp_gpos_f.z()-temp_gpos_b.z())/iLength);
00135 DcxHit* try_me = new DcxHit(hit_global_pos.x(), hit_global_pos.y(), hit_global_pos.z(),
00136 fir_uvec.x(), fir_uvec.y(), fir_uvec.z());
00137 listohits.push_back(try_me);
00138 }
00139 }
00140 DcxTrackCandidatesToTracks make_tracks(listohits,output, field);
00141 }
00142
00143 edm::LogInfo("RoadSearch") << "Created " << output.size() << " tracks.";
00144
00145 }