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