139 LogDebug(
"CosmicTrackSplitter") <<
"IN THE SPLITTER!!!!!";
156 auto output = std::make_unique<TrackCandidateCollection>();
157 output->reserve(tracks->size());
160 std::vector<TrackingRecHit *>
hits;
164 LogDebug(
"CosmicTrackSplitter") <<
"size of map: " << m_TrajTracksMap->
size();
165 int HITTOSPLITFROM = 0;
167 const Trajectory* trajFromMap = &(*(*iPair).key);
168 const reco::Track* trackFromMap = &(*(*iPair).val);
171 std::vector<TrajectoryMeasurement> measurements = trajFromMap->
measurements();
172 int totalNumberOfHits = measurements.size();
173 int numberOfHits = 0;
174 double previousDotProduct = 0;
177 GlobalVector stateMomentum = measurements[numberOfHits].forwardPredictedState().globalMomentum();
178 GlobalPoint statePosition = measurements[numberOfHits].forwardPredictedState().globalPosition();
179 double dotProduct = stateMomentum.
x()*statePosition.
x() + stateMomentum.
y()*statePosition.
y();
180 if ( dotProduct*previousDotProduct < 0 ){
182 HITTOSPLITFROM = numberOfHits;
185 previousDotProduct = dotProduct;
189 LogDebug(
"CosmicTrackSplitter") <<
"number of rechits: " << numberOfHits;
226 idToDetUnit( fdetid )->surface().toGlobal(fHit->
localPosition());
227 GlobalPoint bPosState = measurements[0].updatedState().globalPosition();
228 GlobalPoint fPosState = measurements[measurements.size()-1].
230 bool trajReversedFlag =
false;
240 if (( (bPosHit - bPosState).
mag() > (bPosHit - fPosState).
mag() ) && ( (fPosHit - fPosState).
mag() > (fPosHit - bPosState).
mag() ) ){
241 trajReversedFlag =
true;
243 if (trajReversedFlag){
int temp = HITTOSPLITFROM; HITTOSPLITFROM = totalNumberOfHits -
temp; }
248 for (std::vector<reco::Track>::const_iterator itt = tracks->begin(), edt = tracks->end(); itt != edt; ++itt) {
251 LogDebug(
"CosmicTrackSplitter") <<
"ntracks: " << tracks->size();
257 bool continueWithTrack =
true;
258 if (fabs(
v.z()) >
dZcut_) continueWithTrack =
false;
259 if (
v.perp() >
dXYcut_) continueWithTrack =
false;
260 if (continueWithTrack ==
false)
return;
263 for (
int i = 0;
i < 2; ++
i){
265 LogDebug(
"CosmicTrackSplitter") <<
" loop on hits of track #" << (itt - tracks->begin());
271 LogDebug(
"CosmicTrackSplitter") <<
" hit number " << (ith - itt->recHitsBegin());
278 LogDebug(
"CosmicTrackSplitter") <<
" valid, tracker ";
279 bool verdict =
false;
285 LogDebug(
"CosmicTrackSplitter") <<
"hit pos: " << pos <<
", dca pos: " <<
v;
288 if ((
i == 0)&&(hitCtr < HITTOSPLITFROM)){
290 LogDebug(
"CosmicTrackSplitter") <<
"tophalf";
293 if ((
i == 1)&&(hitCtr >= HITTOSPLITFROM)){
295 LogDebug(
"CosmicTrackSplitter") <<
"bottomhalf";
310 LogDebug(
"CosmicTrackSplitter") <<
" verdict after module list: " << (verdict ?
"ok" :
"no");
311 if (verdict ==
true) {
313 hits.push_back(hit->
clone());
324 hits.push_back(hit->
clone());
329 hits.push_back(hit->
clone());
332 LogDebug(
"CosmicTrackSplitter") <<
" end of hit " << (ith - itt->recHitsBegin());
335 LogDebug(
"CosmicTrackSplitter") <<
" end of loop on hits of track #" << (itt - tracks->begin());
337 std::vector<TrackingRecHit *>::iterator
begin = hits.begin(),
end = hits.end();
339 LogDebug(
"CosmicTrackSplitter") <<
" selected " << hits.size() <<
" hits ";
343 while ( (begin !=
end) && ( (*begin)->isValid() ==
false ) ) ++
begin;
346 LogDebug(
"CosmicTrackSplitter") <<
" after front stripping we have " << (
end -
begin) <<
" hits ";
351 while ( (begin !=
end) && ( (*end)->isValid() ==
false ) ) --
end;
355 LogDebug(
"CosmicTrackSplitter") <<
" after back stripping we have " << (
end -
begin) <<
" hits ";
361 LogDebug(
"CosmicTrackSplitter") <<
"we made a candidate of " << hits.size() <<
" hits!";
364 for (begin = hits.begin(),
end = hits.end(); begin !=
end; ++
begin) {
365 if (*begin)
delete *
begin;
367 LogDebug(
"CosmicTrackSplitter") <<
"loop: " <<
i <<
" has " << usedHitCtr <<
" active hits and " << hits.size() <<
" total hits...";
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
TrackCandidate makeCandidate(const reco::Track &tk, std::vector< TrackingRecHit * >::iterator hitsBegin, std::vector< TrackingRecHit * >::iterator hitsEnd)
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
edm::EDGetTokenT< reco::TrackCollection > tokenTracks
edm::ESHandle< TrackerGeometry > theGeometry
const Plane & surface() const
The nominal surface of the GeomDet.
bool stripBackInvalidHits_
uint32_t rawId() const
get the raw id
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
DataContainer const & measurements() const
const GeomDet * det() const
virtual TrackingRecHit * clone() const =0
bool stripAllInvalidHits_
edm::ESHandle< MagneticField > theMagField
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
virtual LocalPoint localPosition() const =0
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool replaceWithInactiveHits_
edm::EDGetTokenT< TrajTrackAssociationCollection > tokenTrajTrack
size_type size() const
map size
bool stripFrontInvalidHits_
const_iterator begin() const
first iterator over the map (read only)
DetId geographicalId() const
Detector det() const
get the detector field from this detid
std::vector< uint32_t > detsToIgnore_
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.