51 #include <boost/regex.hpp>
102 std::vector<TrackingRecHit *>::iterator hitsBegin,
103 std::vector<TrackingRecHit *>::iterator hitsEnd);
108 : minimumHits_(iConfig.getParameter<uint32_t>(
"minimumHits")),
109 replaceWithInactiveHits_(iConfig.getParameter<
bool>(
"replaceWithInactiveHits")),
110 stripFrontInvalidHits_(iConfig.getParameter<
bool>(
"stripFrontInvalidHits")),
111 stripBackInvalidHits_(iConfig.getParameter<
bool>(
"stripBackInvalidHits")),
112 stripAllInvalidHits_(iConfig.getParameter<
bool>(
"stripAllInvalidHits")),
113 excludePixelHits_(iConfig.getParameter<
bool>(
"excludePixelHits")),
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>();
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) {
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());
275 if (
hit->isValid()) {
276 LogDebug(
"CosmicTrackSplitter") <<
" valid, detid = " <<
hit->geographicalId().rawId();
277 DetId detid =
hit->geographicalId();
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) {
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!";
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();