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