62 #include <boost/regex.hpp>
85 namespace reco {
namespace modules {
117 tracks_(iConfig.getParameter<edm::InputTag>(
"tracks")),
118 tjTag_(iConfig.getParameter<edm::InputTag>(
"tjTkAssociationMapTag") ),
119 minimumHits_(iConfig.getParameter<uint32_t>(
"minimumHits")),
120 replaceWithInactiveHits_(iConfig.getParameter<bool>(
"replaceWithInactiveHits")),
121 stripFrontInvalidHits_(iConfig.getParameter<bool>(
"stripFrontInvalidHits")),
122 stripBackInvalidHits_( iConfig.getParameter<bool>(
"stripBackInvalidHits") ),
123 stripAllInvalidHits_( iConfig.getParameter<bool>(
"stripAllInvalidHits") ),
124 excludePixelHits_( iConfig.getParameter<bool>(
"excludePixelHits") ),
125 dZcut_(iConfig.getParameter<double>(
"dzCut") ),
126 dXYcut_(iConfig.getParameter<double>(
"dxyCut") ),
127 detsToIgnore_( iConfig.getParameter<std::vector<uint32_t> >(
"detsToIgnore") )
131 throw cms::Exception(
"Configuration") <<
"Inconsistent Configuration: you can't set both 'stripAllInvalidHits' and 'replaceWithInactiveHits' to true\n";
134 LogDebug(
"CosmicTrackSplitter") <<
"sanity check";
142 produces<TrackCandidateCollection>();
148 LogDebug(
"CosmicTrackSplitter") <<
"IN THE SPLITTER!!!!!";
166 output->reserve(tracks->size());
169 std::vector<TrackingRecHit *> hits;
173 LogDebug(
"CosmicTrackSplitter") <<
"size of map: " << m_TrajTracksMap->size();
174 int HITTOSPLITFROM = 0;
176 const Trajectory* trajFromMap = &(*(*iPair).key);
177 const reco::Track* trackFromMap = &(*(*iPair).val);
180 std::vector<TrajectoryMeasurement> measurements = trajFromMap->
measurements();
181 int totalNumberOfHits = measurements.size();
182 int numberOfHits = 0;
183 double previousDotProduct = 0;
186 GlobalVector stateMomentum = measurements[numberOfHits].forwardPredictedState().globalMomentum();
187 GlobalPoint statePosition = measurements[numberOfHits].forwardPredictedState().globalPosition();
188 double dotProduct = stateMomentum.x()*statePosition.x() + stateMomentum.y()*statePosition.y();
189 if ( dotProduct*previousDotProduct < 0 ){
191 HITTOSPLITFROM = numberOfHits;
194 previousDotProduct = dotProduct;
198 LogDebug(
"CosmicTrackSplitter") <<
"number of rechits: " << numberOfHits;
235 idToDetUnit( fdetid )->surface().toGlobal(fHit->
localPosition());
236 GlobalPoint bPosState = measurements[0].updatedState().globalPosition();
237 GlobalPoint fPosState = measurements[measurements.size()-1].
238 updatedState().globalPosition();
239 bool trajReversedFlag =
false;
249 if (( (bPosHit - bPosState).
mag() > (bPosHit - fPosState).
mag() ) && ( (fPosHit - fPosState).
mag() > (fPosHit - bPosState).
mag() ) ){
250 trajReversedFlag =
true;
252 if (trajReversedFlag){
int temp = HITTOSPLITFROM; HITTOSPLITFROM = totalNumberOfHits -
temp; }
257 for (std::vector<reco::Track>::const_iterator itt = tracks->begin(), edt = tracks->end(); itt != edt; ++itt) {
260 LogDebug(
"CosmicTrackSplitter") <<
"ntracks: " << tracks->size();
266 bool continueWithTrack =
true;
267 if (fabs(
v.z()) >
dZcut_) continueWithTrack =
false;
268 if (
v.perp() >
dXYcut_) continueWithTrack =
false;
269 if (continueWithTrack ==
false)
return;
272 for (
int i = 0;
i < 2; ++
i){
274 LogDebug(
"CosmicTrackSplitter") <<
" loop on hits of track #" << (itt - tracks->begin());
280 LogDebug(
"CosmicTrackSplitter") <<
" hit number " << (ith - itt->recHitsBegin());
287 LogDebug(
"CosmicTrackSplitter") <<
" valid, tracker ";
288 bool verdict =
false;
294 LogDebug(
"CosmicTrackSplitter") <<
"hit pos: " << pos <<
", dca pos: " <<
v;
297 if ((
i == 0)&&(hitCtr < HITTOSPLITFROM)){
299 LogDebug(
"CosmicTrackSplitter") <<
"tophalf";
302 if ((
i == 1)&&(hitCtr >= HITTOSPLITFROM)){
304 LogDebug(
"CosmicTrackSplitter") <<
"bottomhalf";
319 LogDebug(
"CosmicTrackSplitter") <<
" verdict after module list: " << (verdict ?
"ok" :
"no");
320 if (verdict ==
true) {
322 hits.push_back(hit->
clone());
333 hits.push_back(hit->
clone());
338 hits.push_back(hit->
clone());
341 LogDebug(
"CosmicTrackSplitter") <<
" end of hit " << (ith - itt->recHitsBegin());
344 LogDebug(
"CosmicTrackSplitter") <<
" end of loop on hits of track #" << (itt - tracks->begin());
346 std::vector<TrackingRecHit *>::iterator
begin = hits.begin(),
end = hits.end();
348 LogDebug(
"CosmicTrackSplitter") <<
" selected " << hits.size() <<
" hits ";
352 while ( (begin !=
end) && ( (*begin)->isValid() ==
false ) ) ++
begin;
355 LogDebug(
"CosmicTrackSplitter") <<
" after front stripping we have " << (
end -
begin) <<
" hits ";
360 while ( (begin !=
end) && ( (*end)->isValid() ==
false ) ) --
end;
364 LogDebug(
"CosmicTrackSplitter") <<
" after back stripping we have " << (
end -
begin) <<
" hits ";
370 LogDebug(
"CosmicTrackSplitter") <<
"we made a candidate of " << hits.size() <<
" hits!";
373 for (begin = hits.begin(),
end = hits.end(); begin !=
end; ++
begin) {
374 if (*begin)
delete *
begin;
376 LogDebug(
"CosmicTrackSplitter") <<
"loop: " <<
i <<
" has " << usedHitCtr <<
" active hits and " << hits.size() <<
" total hits...";
387 LogDebug(
"CosmicTrackSplitter") <<
"Making a candidate!";
392 if ( pdir ==
anyDirection )
throw cms::Exception(
"UnimplementedFeature") <<
"Cannot work with tracks that have 'anyDirecton' \n";
407 ownHits.
reserve(hitsEnd - hitsBegin);
408 for ( ; hitsBegin != hitsEnd; ++hitsBegin) { ownHits.
push_back( *hitsBegin ); }
413 LogDebug(
"CosmicTrackSplitter") <<
" dumping the hits now: ";
415 LogTrace(
"CosmicTrackSplitter") <<
" hit detid = " << hitR.first->geographicalId().rawId() <<
416 ", type = " <<
typeid(*hitR.first).
name();
const Vector & momentum() const
track momentum vector
TrackCandidate makeCandidate(const reco::Track &tk, std::vector< TrackingRecHit * >::iterator hitsBegin, std::vector< TrackingRecHit * >::iterator hitsEnd)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
std::vector< TrackCandidate > TrackCandidateCollection
edm::ESHandle< TrackerGeometry > theGeometry
std::pair< const_iterator, const_iterator > range
const math::XYZPoint & outerPosition() const
position of the outermost hit
bool stripBackInvalidHits_
const math::XYZPoint & innerPosition() const
position of the innermost hit
uint32_t rawId() const
get the raw id
DataContainer const & measurements() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool stripAllInvalidHits_
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
edm::ESHandle< MagneticField > theMagField
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool replaceWithInactiveHits_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalVector
vector in glovbal coordinate system
virtual TrackingRecHit * clone() const =0
edm::RefToBase< TrajectorySeed > seedRef() const
bool stripFrontInvalidHits_
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
PropagationDirection seedDirection() const
direction of how the hits were sorted in the original seed
CosmicTrackSplitter(const edm::ParameterSet &iConfig)
const reco::PFCandidateRefVector & tracks_
DetId geographicalId() const
Detector det() const
get the detector field from this detid
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
virtual LocalPoint localPosition() const =0
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
std::vector< uint32_t > detsToIgnore_
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.