143 LogDebug(
"CosmicTrackSplitter") <<
"IN THE SPLITTER!!!!!";
160 auto output = std::make_unique<TrackCandidateCollection>();
164 std::vector<TrackingRecHit *>
hits;
168 LogDebug(
"CosmicTrackSplitter") <<
"size of map: " << m_TrajTracksMap->
size();
169 int HITTOSPLITFROM = 0;
171 iPair != m_TrajTracksMap->
end();
173 const Trajectory *trajFromMap = &(*(*iPair).key);
174 const reco::Track *trackFromMap = &(*(*iPair).val);
177 std::vector<TrajectoryMeasurement> measurements = trajFromMap->
measurements();
178 int totalNumberOfHits = measurements.size();
179 int numberOfHits = 0;
180 double previousDotProduct = 0;
183 GlobalVector stateMomentum = measurements[numberOfHits].forwardPredictedState().globalMomentum();
184 GlobalPoint statePosition = measurements[numberOfHits].forwardPredictedState().globalPosition();
185 double dotProduct = stateMomentum.
x() * statePosition.
x() + stateMomentum.
y() * statePosition.
y();
186 if (dotProduct * previousDotProduct < 0) {
188 HITTOSPLITFROM = numberOfHits;
191 previousDotProduct = dotProduct;
194 LogDebug(
"CosmicTrackSplitter") <<
"number of rechits: " << numberOfHits;
228 GlobalPoint bPosState = measurements[0].updatedState().globalPosition();
229 GlobalPoint fPosState = measurements[measurements.size() - 1].updatedState().globalPosition();
230 bool trajReversedFlag =
false;
240 if (((bPosHit - bPosState).
mag() > (bPosHit - fPosState).
mag()) &&
241 ((fPosHit - fPosState).
mag() > (fPosHit - bPosState).
mag())) {
242 trajReversedFlag =
true;
244 if (trajReversedFlag) {
245 int temp = HITTOSPLITFROM;
246 HITTOSPLITFROM = totalNumberOfHits -
temp;
252 for (std::vector<reco::Track>::const_iterator itt =
tracks->begin(), edt =
tracks->end(); itt != edt; ++itt) {
261 bool continueWithTrack =
true;
263 continueWithTrack =
false;
265 continueWithTrack =
false;
266 if (continueWithTrack ==
false)
270 for (
int i = 0;
i < 2; ++
i) {
272 LogDebug(
"CosmicTrackSplitter") <<
" loop on hits of track #" << (itt -
tracks->begin());
278 LogDebug(
"CosmicTrackSplitter") <<
" hit number " << (ith - itt->recHitsBegin());
280 if (
hit->isValid()) {
281 LogDebug(
"CosmicTrackSplitter") <<
" valid, detid = " <<
hit->geographicalId().rawId();
282 DetId detid =
hit->geographicalId();
285 LogDebug(
"CosmicTrackSplitter") <<
" valid, tracker ";
286 bool verdict =
false;
292 LogDebug(
"CosmicTrackSplitter") <<
"hit pos: " <<
pos <<
", dca pos: " <<
v;
295 if ((
i == 0) && (hitCtr < HITTOSPLITFROM)) {
297 LogDebug(
"CosmicTrackSplitter") <<
"tophalf";
300 if ((
i == 1) && (hitCtr >= HITTOSPLITFROM)) {
302 LogDebug(
"CosmicTrackSplitter") <<
"bottomhalf";
319 <<
" verdict after module list: " << (verdict ?
"ok" :
"no");
320 if (verdict ==
true) {
338 LogDebug(
"CosmicTrackSplitter") <<
" end of hit " << (ith - itt->recHitsBegin());
341 LogDebug(
"CosmicTrackSplitter") <<
" end of loop on hits of track #" << (itt -
tracks->begin());
343 std::vector<TrackingRecHit *>::iterator
begin =
hits.begin(),
end =
hits.end();
345 LogDebug(
"CosmicTrackSplitter") <<
" selected " <<
hits.size() <<
" hits ";
349 while ((begin !=
end) && ((*begin)->isValid() ==
false))
353 LogDebug(
"CosmicTrackSplitter") <<
" after front stripping we have " << (
end -
begin) <<
" hits ";
358 while ((begin !=
end) && ((*end)->isValid() ==
false))
363 LogDebug(
"CosmicTrackSplitter") <<
" after back stripping we have " << (
end -
begin) <<
" hits ";
369 LogDebug(
"CosmicTrackSplitter") <<
"we made a candidate of " <<
hits.size() <<
" hits!";
377 <<
"loop: " <<
i <<
" has " << usedHitCtr <<
" active hits and " <<
hits.size() <<
" total hits...";
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tokenGeometry
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tokenMagField
edm::EDGetTokenT< reco::TrackCollection > tokenTracks
TrackCandidate makeCandidate(const reco::Track &tk, std::vector< TrackingRecHit *>::iterator hitsBegin, std::vector< TrackingRecHit *>::iterator hitsEnd)
edm::ESHandle< TrackerGeometry > theGeometry
constexpr Detector det() const
get the detector field from this detid
bool stripBackInvalidHits_
DataContainer const & measurements() const
const_iterator end() const
last iterator over the map (read only)
size_type size() const
map size
bool stripAllInvalidHits_
edm::ESHandle< MagneticField > theMagField
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
bool replaceWithInactiveHits_
edm::EDGetTokenT< TrajTrackAssociationCollection > tokenTrajTrack
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const Plane & surface() const
The nominal surface of the GeomDet.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
DetId geographicalId() const
constexpr uint32_t rawId() const
get the raw id
bool stripFrontInvalidHits_
const_iterator begin() const
first iterator over the map (read only)
virtual LocalPoint localPosition() const =0
std::vector< uint32_t > detsToIgnore_