51 #include <boost/regex.hpp> 102 std::vector<TrackingRecHit *>::iterator hitsBegin,
103 std::vector<TrackingRecHit *>::iterator hitsEnd);
108 :
minimumHits_(iConfig.getParameter<uint32_t>(
"minimumHits")),
114 dZcut_(iConfig.getParameter<double>(
"dzCut")),
115 dXYcut_(iConfig.getParameter<double>(
"dxyCut")),
116 detsToIgnore_(iConfig.getParameter<
std::vector<uint32_t> >(
"detsToIgnore")) {
119 throw cms::Exception(
"Configuration") <<
"Inconsistent Configuration: you can't set both 'stripAllInvalidHits' " 120 "and 'replaceWithInactiveHits' to true\n";
126 LogDebug(
"CosmicTrackSplitter") <<
"sanity check";
134 produces<TrackCandidateCollection>();
138 LogDebug(
"CosmicTrackSplitter") <<
"IN THE SPLITTER!!!!!";
155 auto output = std::make_unique<TrackCandidateCollection>();
156 output->reserve(tracks->size());
159 std::vector<TrackingRecHit *>
hits;
163 LogDebug(
"CosmicTrackSplitter") <<
"size of map: " << m_TrajTracksMap->
size();
164 int HITTOSPLITFROM = 0;
166 iPair != m_TrajTracksMap->
end();
168 const Trajectory *trajFromMap = &(*(*iPair).key);
169 const reco::Track *trackFromMap = &(*(*iPair).val);
172 std::vector<TrajectoryMeasurement> measurements = trajFromMap->
measurements();
173 int totalNumberOfHits = measurements.size();
174 int numberOfHits = 0;
175 double previousDotProduct = 0;
178 GlobalVector stateMomentum = measurements[numberOfHits].forwardPredictedState().globalMomentum();
179 GlobalPoint statePosition = measurements[numberOfHits].forwardPredictedState().globalPosition();
180 double dotProduct = stateMomentum.x() * statePosition.x() + stateMomentum.y() * statePosition.y();
181 if (dotProduct * previousDotProduct < 0) {
183 HITTOSPLITFROM = numberOfHits;
186 previousDotProduct = dotProduct;
189 LogDebug(
"CosmicTrackSplitter") <<
"number of rechits: " << numberOfHits;
223 GlobalPoint bPosState = measurements[0].updatedState().globalPosition();
224 GlobalPoint fPosState = measurements[measurements.size() - 1].updatedState().globalPosition();
225 bool trajReversedFlag =
false;
235 if (((bPosHit - bPosState).
mag() > (bPosHit - fPosState).
mag()) &&
236 ((fPosHit - fPosState).
mag() > (fPosHit - bPosState).
mag())) {
237 trajReversedFlag =
true;
239 if (trajReversedFlag) {
240 int temp = HITTOSPLITFROM;
241 HITTOSPLITFROM = totalNumberOfHits -
temp;
247 for (std::vector<reco::Track>::const_iterator itt = tracks->begin(), edt = tracks->end(); itt != edt; ++itt) {
250 LogDebug(
"CosmicTrackSplitter") <<
"ntracks: " << tracks->size();
256 bool continueWithTrack =
true;
258 continueWithTrack =
false;
260 continueWithTrack =
false;
261 if (continueWithTrack ==
false)
265 for (
int i = 0;
i < 2; ++
i) {
267 LogDebug(
"CosmicTrackSplitter") <<
" loop on hits of track #" << (itt - tracks->begin());
273 LogDebug(
"CosmicTrackSplitter") <<
" hit number " << (ith - itt->recHitsBegin());
280 LogDebug(
"CosmicTrackSplitter") <<
" valid, tracker ";
281 bool verdict =
false;
287 LogDebug(
"CosmicTrackSplitter") <<
"hit pos: " << pos <<
", dca pos: " <<
v;
290 if ((
i == 0) && (hitCtr < HITTOSPLITFROM)) {
292 LogDebug(
"CosmicTrackSplitter") <<
"tophalf";
295 if ((
i == 1) && (hitCtr >= HITTOSPLITFROM)) {
297 LogDebug(
"CosmicTrackSplitter") <<
"bottomhalf";
314 <<
" verdict after module list: " << (verdict ?
"ok" :
"no");
315 if (verdict ==
true) {
317 hits.push_back(hit->
clone());
326 hits.push_back(hit->
clone());
330 hits.push_back(hit->
clone());
333 LogDebug(
"CosmicTrackSplitter") <<
" end of hit " << (ith - itt->recHitsBegin());
336 LogDebug(
"CosmicTrackSplitter") <<
" end of loop on hits of track #" << (itt - tracks->begin());
338 std::vector<TrackingRecHit *>::iterator
begin = hits.begin(),
end = hits.end();
340 LogDebug(
"CosmicTrackSplitter") <<
" selected " << hits.size() <<
" hits ";
344 while ((begin !=
end) && ((*begin)->isValid() ==
false))
348 LogDebug(
"CosmicTrackSplitter") <<
" after front stripping we have " << (
end -
begin) <<
" hits ";
353 while ((begin !=
end) && ((*end)->isValid() ==
false))
358 LogDebug(
"CosmicTrackSplitter") <<
" after back stripping we have " << (
end -
begin) <<
" hits ";
364 LogDebug(
"CosmicTrackSplitter") <<
"we made a candidate of " << hits.size() <<
" hits!";
367 for (begin = hits.begin(),
end = hits.end(); begin !=
end; ++
begin) {
372 <<
"loop: " <<
i <<
" has " << usedHitCtr <<
" active hits and " << hits.size() <<
" total hits...";
381 std::vector<TrackingRecHit *>::iterator hitsBegin,
382 std::vector<TrackingRecHit *>::iterator hitsEnd) {
383 LogDebug(
"CosmicTrackSplitter") <<
"Making a candidate!";
388 throw cms::Exception(
"UnimplementedFeature") <<
"Cannot work with tracks that have 'anyDirecton' \n";
405 ownHits.
reserve(hitsEnd - hitsBegin);
406 for (; hitsBegin != hitsEnd; ++hitsBegin) {
413 LogDebug(
"CosmicTrackSplitter") <<
" dumping the hits now: ";
415 auto const &
tmp = *hitR.first;
416 LogTrace(
"CosmicTrackSplitter") <<
" hit detid = " << hitR.first->geographicalId().rawId()
417 <<
", type = " <<
typeid(
tmp).
name();
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
const edm::RefToBase< TrajectorySeed > & seedRef() const
T getParameter(std::string const &) 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())
constexpr uint32_t rawId() const
get the raw id
edm::EDGetTokenT< reco::TrackCollection > tokenTracks
edm::ESHandle< TrackerGeometry > theGeometry
const Vector & momentum() const
track momentum vector
const math::XYZPoint & outerPosition() const
position of the outermost hit
const Plane & surface() const
The nominal surface of the GeomDet.
bool stripBackInvalidHits_
const math::XYZPoint & innerPosition() const
position of the innermost hit
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
DataContainer const & measurements() const
#define DEFINE_FWK_MODULE(type)
const GeomDet * det() const
virtual TrackingRecHit * clone() const =0
bool stripAllInvalidHits_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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.
virtual LocalPoint localPosition() const =0
bool replaceWithInactiveHits_
edm::EDGetTokenT< TrajTrackAssociationCollection > tokenTrajTrack
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalVector
vector in glovbal coordinate system
size_type size() const
map size
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
bool stripFrontInvalidHits_
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalPoint
point in global coordinate system
CosmicTrackSplitter(const edm::ParameterSet &iConfig)
const_iterator begin() const
first iterator over the map (read only)
DetId geographicalId() const
std::pair< const_iterator, const_iterator > range
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
std::vector< uint32_t > detsToIgnore_
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
constexpr Detector det() const
get the detector field from this detid
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.