54 #include <boost/regex.hpp>
109 minimumHits_(iConfig.getParameter<uint32_t>(
"minimumHits")),
110 replaceWithInactiveHits_(iConfig.getParameter<bool>(
"replaceWithInactiveHits")),
111 stripFrontInvalidHits_(iConfig.getParameter<bool>(
"stripFrontInvalidHits")),
112 stripBackInvalidHits_( iConfig.getParameter<bool>(
"stripBackInvalidHits") ),
113 stripAllInvalidHits_( iConfig.getParameter<bool>(
"stripAllInvalidHits") ),
114 excludePixelHits_( iConfig.getParameter<bool>(
"excludePixelHits") ),
115 dZcut_(iConfig.getParameter<double>(
"dzCut") ),
116 dXYcut_(iConfig.getParameter<double>(
"dxyCut") ),
117 detsToIgnore_( iConfig.getParameter<std::vector<uint32_t> >(
"detsToIgnore") )
121 throw cms::Exception(
"Configuration") <<
"Inconsistent Configuration: you can't set both 'stripAllInvalidHits' and 'replaceWithInactiveHits' to true\n";
126 LogDebug(
"CosmicTrackSplitter") <<
"sanity check";
134 produces<TrackCandidateCollection>();
140 LogDebug(
"CosmicTrackSplitter") <<
"IN THE SPLITTER!!!!!";
158 output->reserve(tracks->size());
161 std::vector<TrackingRecHit *> hits;
165 LogDebug(
"CosmicTrackSplitter") <<
"size of map: " << m_TrajTracksMap->size();
166 int HITTOSPLITFROM = 0;
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;
190 LogDebug(
"CosmicTrackSplitter") <<
"number of rechits: " << numberOfHits;
227 idToDetUnit( fdetid )->surface().toGlobal(fHit->
localPosition());
228 GlobalPoint bPosState = measurements[0].updatedState().globalPosition();
229 GlobalPoint fPosState = measurements[measurements.size()-1].
230 updatedState().globalPosition();
231 bool trajReversedFlag =
false;
241 if (( (bPosHit - bPosState).
mag() > (bPosHit - fPosState).
mag() ) && ( (fPosHit - fPosState).
mag() > (fPosHit - bPosState).
mag() ) ){
242 trajReversedFlag =
true;
244 if (trajReversedFlag){
int temp = HITTOSPLITFROM; HITTOSPLITFROM = totalNumberOfHits -
temp; }
249 for (std::vector<reco::Track>::const_iterator itt = tracks->begin(), edt = tracks->end(); itt != edt; ++itt) {
252 LogDebug(
"CosmicTrackSplitter") <<
"ntracks: " << tracks->size();
258 bool continueWithTrack =
true;
259 if (fabs(
v.z()) >
dZcut_) continueWithTrack =
false;
260 if (
v.perp() >
dXYcut_) continueWithTrack =
false;
261 if (continueWithTrack ==
false)
return;
264 for (
int i = 0;
i < 2; ++
i){
266 LogDebug(
"CosmicTrackSplitter") <<
" loop on hits of track #" << (itt - tracks->begin());
272 LogDebug(
"CosmicTrackSplitter") <<
" hit number " << (ith - itt->recHitsBegin());
279 LogDebug(
"CosmicTrackSplitter") <<
" valid, tracker ";
280 bool verdict =
false;
286 LogDebug(
"CosmicTrackSplitter") <<
"hit pos: " << pos <<
", dca pos: " <<
v;
289 if ((
i == 0)&&(hitCtr < HITTOSPLITFROM)){
291 LogDebug(
"CosmicTrackSplitter") <<
"tophalf";
294 if ((
i == 1)&&(hitCtr >= HITTOSPLITFROM)){
296 LogDebug(
"CosmicTrackSplitter") <<
"bottomhalf";
311 LogDebug(
"CosmicTrackSplitter") <<
" verdict after module list: " << (verdict ?
"ok" :
"no");
312 if (verdict ==
true) {
314 hits.push_back(hit->
clone());
325 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 ) ) ++
begin;
347 LogDebug(
"CosmicTrackSplitter") <<
" after front stripping we have " << (
end -
begin) <<
" hits ";
352 while ( (begin !=
end) && ( (*end)->isValid() ==
false ) ) --
end;
356 LogDebug(
"CosmicTrackSplitter") <<
" after back stripping we have " << (
end -
begin) <<
" hits ";
362 LogDebug(
"CosmicTrackSplitter") <<
"we made a candidate of " << hits.size() <<
" hits!";
365 for (begin = hits.begin(),
end = hits.end(); begin !=
end; ++
begin) {
366 if (*begin)
delete *
begin;
368 LogDebug(
"CosmicTrackSplitter") <<
"loop: " <<
i <<
" has " << usedHitCtr <<
" active hits and " << hits.size() <<
" total hits...";
379 LogDebug(
"CosmicTrackSplitter") <<
"Making a candidate!";
384 if ( pdir ==
anyDirection )
throw cms::Exception(
"UnimplementedFeature") <<
"Cannot work with tracks that have 'anyDirecton' \n";
399 ownHits.
reserve(hitsEnd - hitsBegin);
400 for ( ; hitsBegin != hitsEnd; ++hitsBegin) { ownHits.
push_back( *hitsBegin ); }
405 LogDebug(
"CosmicTrackSplitter") <<
" dumping the hits now: ";
407 LogTrace(
"CosmicTrackSplitter") <<
" hit detid = " << hitR.first->geographicalId().rawId() <<
408 ", type = " <<
typeid(*hitR.first).
name();
T getParameter(std::string const &) const
TrackCandidate makeCandidate(const reco::Track &tk, std::vector< TrackingRecHit * >::iterator hitsBegin, std::vector< TrackingRecHit * >::iterator hitsEnd)
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
std::vector< TrackCandidate > TrackCandidateCollection
edm::EDGetTokenT< reco::TrackCollection > tokenTracks
edm::ESHandle< TrackerGeometry > theGeometry
std::pair< const_iterator, const_iterator > range
const Vector & momentum() const
track momentum vector
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.
const GeomDet * det() const
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 replaceWithInactiveHits_
edm::EDGetTokenT< TrajTrackAssociationCollection > tokenTrajTrack
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)
DetId geographicalId() const
volatile std::atomic< bool > shutdown_flag false
Detector det() const
get the detector field from this detid
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_
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.