Go to the documentation of this file.00001 #include "RecoEgamma/EgammaPhotonAlgos/interface/OutInConversionTrackFinder.h"
00002
00003 #include "RecoTracker/Record/interface/CkfComponentsRecord.h"
00004 #include "RecoTracker/CkfPattern/interface/GroupedTrajCandLess.h"
00005 #include "RecoTracker/CkfPattern/interface/SeedCleanerByHitPosition.h"
00006 #include "RecoTracker/CkfPattern/interface/CachingSeedCleanerByHitPosition.h"
00007 #include "RecoTracker/CkfPattern/interface/CachingSeedCleanerBySharedInput.h"
00008 #include "RecoTracker/CkfPattern/interface/TransientInitialStateEstimator.h"
00009
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011
00012
00013 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
00014 #include "TrackingTools/TrajectoryCleaning/interface/TrajectoryCleanerBySharedHits.h"
00015 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00016
00017 #include "DataFormats/Common/interface/OwnVector.h"
00018 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
00019
00020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00021
00022 #include "Utilities/General/interface/precomputed_value_sort.h"
00023
00024
00025
00026 OutInConversionTrackFinder::OutInConversionTrackFinder(const edm::EventSetup& es,
00027 const edm::ParameterSet& conf ) : ConversionTrackFinder( es, conf )
00028 {
00029
00030
00031 theTrajectoryCleaner_ = new TrajectoryCleanerBySharedHits(conf);
00032
00033
00034 std::string cleaner = conf_.getParameter<std::string>("OutInRedundantSeedCleaner");
00035 if (cleaner == "SeedCleanerByHitPosition") {
00036 theSeedCleaner_ = new SeedCleanerByHitPosition();
00037 } else if (cleaner == "CachingSeedCleanerByHitPosition") {
00038 theSeedCleaner_ = new CachingSeedCleanerByHitPosition();
00039 } else if (cleaner == "CachingSeedCleanerBySharedInput") {
00040 theSeedCleaner_ = new CachingSeedCleanerBySharedInput();
00041 } else if (cleaner == "none") {
00042 theSeedCleaner_ = 0;
00043 } else {
00044 throw cms::Exception("OutInRedundantSeedCleaner not found", cleaner);
00045 }
00046
00047
00048
00049
00050
00051 }
00052
00053
00054
00055
00056 OutInConversionTrackFinder::~OutInConversionTrackFinder() {
00057
00058 delete theTrajectoryCleaner_;
00059 if (theSeedCleaner_) delete theSeedCleaner_;
00060
00061 }
00062
00063
00064 std::vector<Trajectory> OutInConversionTrackFinder::tracks(const TrajectorySeedCollection outInSeeds,
00065 TrackCandidateCollection &output_p ) const {
00066
00067
00068
00069
00070 std::vector<Trajectory> tmpO;
00071 tmpO.erase(tmpO.begin(), tmpO.end() ) ;
00072
00073 std::vector<Trajectory> result;
00074 result.erase(result.begin(), result.end() ) ;
00075
00076
00077 std::vector<Trajectory> rawResult;
00078 if (theSeedCleaner_) theSeedCleaner_->init( &rawResult );
00079
00080
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 int goodSeed=0;
00109 std::vector<Trajectory> theTmpTrajectories;
00110 for(TrajectorySeedCollection::const_iterator iSeed=outInSeeds.begin(); iSeed!=outInSeeds.end();iSeed++){
00111
00112 theTmpTrajectories.clear();
00113
00114 if (!theSeedCleaner_ || theSeedCleaner_->good(&(*iSeed))) {
00115 goodSeed++;
00116
00117
00118 DetId tmpId = DetId( iSeed->startingState().detId());
00119 const GeomDet* tmpDet = theMeasurementTracker_->geomTracker()->idToDet( tmpId );
00120 GlobalVector gv = tmpDet->surface().toGlobal( iSeed->startingState().parameters().momentum() );
00121
00122
00123 LogDebug("OutInConversionTrackFinder") << " OutInConversionTrackFinder::tracks seed starting state position " << iSeed->startingState().parameters().position() << " momentum " << iSeed->startingState().parameters().momentum() << " charge " << iSeed->startingState().parameters().charge() << " R " << gv.perp() << " eta " << gv.eta() << " phi " << gv.phi() << "\n";
00124
00125
00126 theCkfTrajectoryBuilder_->trajectories(*iSeed, theTmpTrajectories);
00127
00128 LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder::track returned " << theTmpTrajectories.size() << " trajectories" << "\n";
00129
00130 theTrajectoryCleaner_->clean(theTmpTrajectories);
00131
00132 for(std::vector<Trajectory>::const_iterator it=theTmpTrajectories.begin();
00133 it!=theTmpTrajectories.end(); it++){
00134 if( it->isValid() ) {
00135 rawResult.push_back(*it);
00136 if (theSeedCleaner_) theSeedCleaner_->add( & (*it) );
00137 }
00138 }
00139
00140
00141 }
00142 }
00143 LogDebug("OutInConversionTrackFinder") << " OutInConversionTrackFinder::track Good seeds " << goodSeed << "\n";
00144 LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder::track rawResult size after cleaning " << rawResult.size() << "\n";
00145
00146 if (theSeedCleaner_) theSeedCleaner_->done();
00147
00148 std::vector<Trajectory> unsmoothedResult;
00149 theTrajectoryCleaner_->clean(rawResult);
00150
00151 for (std::vector<Trajectory>::const_iterator itraw = rawResult.begin(); itraw != rawResult.end(); itraw++) {
00152 if((*itraw).isValid()) {
00153 tmpO.push_back( *itraw );
00154 LogDebug("OutInConversionTrackFinder") << " rawResult num hits " << (*itraw).foundHits() << "\n";
00155 }
00156 }
00157
00158
00159
00160 LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size() << " before sorting " << "\n";
00161
00162
00163
00164
00165 precomputed_value_sort( tmpO.begin(), tmpO.end(), ExtractNumOfHits() );
00166
00167
00168 LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO after sorting " << "\n";
00169
00170
00171
00172
00173 for (int i=tmpO.size()-1; i>=0; i--) {
00174 unsmoothedResult.push_back( tmpO[i] );
00175 }
00176 LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder unsmoothedResult size " << unsmoothedResult.size() << "\n";
00177
00178
00179
00180
00181
00182
00183
00184
00185 tmpO.clear();
00186 LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size() << " after clearing " << "\n";
00187 for (std::vector<Trajectory>::const_iterator it = unsmoothedResult.begin(); it != unsmoothedResult.end(); it++) {
00188 if( !it->isValid() ) continue;
00189
00190 std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = theInitialState_->innerState( *it);
00191
00192
00193
00194 if (! initState.first.isValid() || initState.second == 0) {
00195 LogDebug("OutInConversionTrackFinder") << "invalid innerState, will not make TrackCandidate" << "\n";;
00196 continue;
00197 }
00198 tmpO.push_back(*it);
00199 }
00200
00201
00202 LogDebug("OutInConversionTrackFinder") << "OutInConversionTrackFinder tmpO size " << tmpO.size() << " after filling " << "\n";
00203 if ( tmpO.size() ) {
00204 std::vector<Trajectory>::iterator it=tmpO.begin();
00205
00206
00207 result.push_back(*it);
00208 if ( tmpO.size() > 1) result.push_back(*(++it));
00209 }
00210
00211
00212
00213
00214
00215
00216
00217 for (std::vector<Trajectory>::const_iterator it = result.begin(); it != result.end(); it++) {
00218
00219
00220 edm::OwnVector<TrackingRecHit> recHits;
00221 Trajectory::RecHitContainer thits;
00222 it->recHitsV(thits,useSplitHits_);
00223 recHits.reserve(thits.size());
00224 for (Trajectory::RecHitContainer::const_iterator hitIt = thits.begin(); hitIt != thits.end(); hitIt++) {
00225 recHits.push_back( (**hitIt).hit()->clone());
00226 }
00227
00228
00229 std::pair<TrajectoryStateOnSurface, const GeomDet*> initState = theInitialState_->innerState( *it);
00230
00231 if (! initState.first.isValid() || initState.second == 0) {
00232
00233 continue;
00234 }
00235
00236 PTrajectoryStateOnDet* state = 0;
00237 if(useSplitHits_ && (initState.second != thits.front()->det()) && thits.front()->det() ){
00238 TrajectoryStateOnSurface propagated = thePropagator_->propagate(initState.first,thits.front()->det()->surface());
00239 if (!propagated.isValid()) continue;
00240 state = TrajectoryStateTransform().persistentState(propagated,
00241 thits.front()->det()->geographicalId().rawId());
00242 }
00243 if(!state) state = TrajectoryStateTransform().persistentState( initState.first,
00244 initState.second->geographicalId().rawId());
00245
00246 LogDebug("OutInConversionTrackFinder")<< "OutInConversionTrackFinder Number of hits for the track candidate " << recHits.size() << " TSOS charge " << initState.first.charge() << "\n";
00247 output_p.push_back(TrackCandidate(recHits, it->seed(),*state ) );
00248 delete state;
00249 }
00250
00251
00252
00253
00254
00255 return result;
00256
00257
00258
00259 }