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