Go to the documentation of this file.00001 #include "RecoTracker/SpecialSeedGenerators/interface/CosmicSeedCreator.h"
00002 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
00003 #include "RecoTracker/TkSeedingLayers/interface/SeedingHitSet.h"
00004 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
00005 #include "RecoTracker/TkSeedGenerator/interface/FastHelix.h"
00006 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00007 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "MagneticField/Engine/interface/MagneticField.h"
00010 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00011 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00012 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
00013 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include "TrackingTools/GeomPropagators/interface/PropagationExceptions.h"
00016 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00017 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00018 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00019 #include "TrackingTools/TrackAssociator/interface/DetIdInfo.h"
00020
00021 template <class T> T sqr( T t) {return t*t;}
00022
00023 const TrajectorySeed * CosmicSeedCreator::trajectorySeed(TrajectorySeedCollection & seedCollection,
00024 const SeedingHitSet & ordered,
00025 const TrackingRegion & region,
00026 const edm::EventSetup& es)
00027 {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 const SeedingHitSet & hits = ordered;
00038 if ( hits.size() < 2) return 0;
00039
00040
00041
00042
00043 TransientTrackingRecHit::ConstRecHitPointer tth1 = hits[0];
00044 TransientTrackingRecHit::ConstRecHitPointer tth2 = hits[1];
00045
00046 TransientTrackingRecHit::ConstRecHitPointer usedHit;
00047
00048
00049
00050 GlobalVector initialMomentum(region.direction());
00051
00052
00053
00054 LogDebug("CosmicSeedCreator") << "initial momentum = " << initialMomentum;
00055
00056
00057
00058
00059 edm::ESHandle<MagneticField> bfield;
00060 es.get<IdealMagneticFieldRecord>().get(bfield);
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 bool reverseAll = false;
00072 if ( fabs(tth1->globalPosition().perp()) < fabs(tth2->globalPosition().perp()) )
00073
00074 {
00075 usedHit=tth1;
00076 reverseAll = true;
00077 }
00078
00079 else usedHit=tth2;
00080
00081
00082
00083
00084
00085 bool bottomSeed = (usedHit->globalPosition().y()<0);
00086
00087
00088
00089
00090 edm::OwnVector<TrackingRecHit> seedHits;
00091
00092 if (reverseAll){
00093 LogDebug("CosmicSeedCreator") <<"Reverse all applied";
00094
00095 seedHits.push_back(tth2->hit()->clone());
00096 seedHits.push_back(tth1->hit()->clone());
00097 }
00098
00099 else {
00100 seedHits.push_back(tth1->hit()->clone());
00101 seedHits.push_back(tth2->hit()->clone());
00102 }
00103
00104
00105
00106
00107
00108 PropagationDirection seedDirection = alongMomentum;
00109
00110
00111 if (reverseAll) initialMomentum *=-1;
00112
00113 if (bottomSeed){
00114
00115
00116 initialMomentum *=-1;
00117
00118 seedDirection = oppositeToMomentum;
00119 }
00120
00121
00122 for (int charge=-1;charge<=1;charge+=2){
00123
00124
00125 FreeTrajectoryState freeState(GlobalTrajectoryParameters(usedHit->globalPosition(),
00126 initialMomentum, charge, &*bfield),
00127 CurvilinearTrajectoryError(AlgebraicSymMatrix(5,1))
00128 );
00129
00130 LogDebug("CosmicSeedCreator")<<"Position freeState: " << usedHit->globalPosition()
00131 <<"\nCharge: "<< charge
00132 <<"\nInitial momentum :" << initialMomentum ;
00133
00134 TrajectoryStateOnSurface tsos(freeState, *usedHit->surface());
00135
00136 TrajectoryStateTransform transformer;
00137 boost::shared_ptr<PTrajectoryStateOnDet> PTraj(transformer.persistentState(tsos, usedHit->hit()->geographicalId().rawId()));
00138 seedCollection.push_back( TrajectorySeed(*PTraj,seedHits,seedDirection));
00139
00140 }
00141
00142
00143
00144
00145
00146
00147
00148
00149 LogDebug("CosmicSeedCreator")
00150 << "Using SeedCreator---------->\n"
00151 << "seedCollections size = " << seedCollection.size();
00152
00153 if ( seedCollection.size() > maxseeds_ ) {
00154 edm::LogError("TooManySeeds") << "Found too many seeds (" << seedCollection.size() << " > " << maxseeds_ << "), bailing out.\n";
00155 seedCollection.clear();
00156 return &seedCollection.back();
00157 }
00158 else {
00159 return &seedCollection.back();
00160 }
00161
00162 }