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