63 #include <boost/regex.hpp>
86 namespace reco {
namespace modules {
118 tracks_(iConfig.getParameter<edm::InputTag>(
"tracks")),
119 tjTag_(iConfig.getParameter<edm::InputTag>(
"tjTkAssociationMapTag") ),
120 minimumHits_(iConfig.getParameter<uint32_t>(
"minimumHits")),
121 replaceWithInactiveHits_(iConfig.getParameter<bool>(
"replaceWithInactiveHits")),
122 stripFrontInvalidHits_(iConfig.getParameter<bool>(
"stripFrontInvalidHits")),
123 stripBackInvalidHits_( iConfig.getParameter<bool>(
"stripBackInvalidHits") ),
124 stripAllInvalidHits_( iConfig.getParameter<bool>(
"stripAllInvalidHits") ),
125 excludePixelHits_( iConfig.getParameter<bool>(
"excludePixelHits") ),
126 dZcut_(iConfig.getParameter<double>(
"dzCut") ),
127 dXYcut_(iConfig.getParameter<double>(
"dxyCut") ),
128 detsToIgnore_( iConfig.getParameter<std::vector<uint32_t> >(
"detsToIgnore") )
132 throw cms::Exception(
"Configuration") <<
"Inconsistent Configuration: you can't set both 'stripAllInvalidHits' and 'replaceWithInactiveHits' to true\n";
135 LogDebug(
"CosmicTrackSplitter") <<
"sanity check";
143 produces<TrackCandidateCollection>();
149 LogDebug(
"CosmicTrackSplitter") <<
"IN THE SPLITTER!!!!!";
167 output->reserve(tracks->size());
170 std::vector<TrackingRecHit *> hits;
174 LogDebug(
"CosmicTrackSplitter") <<
"size of map: " << m_TrajTracksMap->size();
175 int HITTOSPLITFROM = 0;
177 const Trajectory* trajFromMap = &(*(*iPair).key);
178 const reco::Track* trackFromMap = &(*(*iPair).val);
181 std::vector<TrajectoryMeasurement> measurements = trajFromMap->
measurements();
182 int totalNumberOfHits = measurements.size();
183 int numberOfHits = 0;
184 double previousDotProduct = 0;
187 GlobalVector stateMomentum = measurements[numberOfHits].forwardPredictedState().globalMomentum();
188 GlobalPoint statePosition = measurements[numberOfHits].forwardPredictedState().globalPosition();
189 double dotProduct = stateMomentum.x()*statePosition.x() + stateMomentum.y()*statePosition.y();
190 if ( dotProduct*previousDotProduct < 0 ){
192 HITTOSPLITFROM = numberOfHits;
195 previousDotProduct = dotProduct;
199 LogDebug(
"CosmicTrackSplitter") <<
"number of rechits: " << numberOfHits;
236 idToDetUnit( fdetid )->surface().toGlobal(fHit->
localPosition());
237 GlobalPoint bPosState = measurements[0].updatedState().globalPosition();
238 GlobalPoint fPosState = measurements[measurements.size()-1].
239 updatedState().globalPosition();
240 bool trajReversedFlag =
false;
250 if (( (bPosHit - bPosState).
mag() > (bPosHit - fPosState).
mag() ) && ( (fPosHit - fPosState).
mag() > (fPosHit - bPosState).
mag() ) ){
251 trajReversedFlag =
true;
253 if (trajReversedFlag){
int temp = HITTOSPLITFROM; HITTOSPLITFROM = totalNumberOfHits -
temp; }
258 for (std::vector<reco::Track>::const_iterator itt = tracks->begin(), edt = tracks->end(); itt != edt; ++itt) {
261 LogDebug(
"CosmicTrackSplitter") <<
"ntracks: " << tracks->size();
268 bool continueWithTrack =
true;
269 if (fabs(
v.z()) >
dZcut_) continueWithTrack =
false;
270 if (
v.perp() >
dXYcut_) continueWithTrack =
false;
271 if (continueWithTrack ==
false)
return;
274 for (
int i = 0;
i < 2; ++
i){
276 LogDebug(
"CosmicTrackSplitter") <<
" loop on hits of track #" << (itt - tracks->begin());
282 LogDebug(
"CosmicTrackSplitter") <<
" hit number " << (ith - itt->recHitsBegin());
289 LogDebug(
"CosmicTrackSplitter") <<
" valid, tracker ";
290 bool verdict =
false;
296 LogDebug(
"CosmicTrackSplitter") <<
"hit pos: " << pos <<
", dca pos: " <<
v;
299 if ((
i == 0)&&(hitCtr < HITTOSPLITFROM)){
301 LogDebug(
"CosmicTrackSplitter") <<
"tophalf";
304 if ((
i == 1)&&(hitCtr >= HITTOSPLITFROM)){
306 LogDebug(
"CosmicTrackSplitter") <<
"bottomhalf";
321 LogDebug(
"CosmicTrackSplitter") <<
" verdict after module list: " << (verdict ?
"ok" :
"no");
322 if (verdict ==
true) {
324 hits.push_back(hit->
clone());
335 hits.push_back(hit->
clone());
340 hits.push_back(hit->
clone());
343 LogDebug(
"CosmicTrackSplitter") <<
" end of hit " << (ith - itt->recHitsBegin());
346 LogDebug(
"CosmicTrackSplitter") <<
" end of loop on hits of track #" << (itt - tracks->begin());
348 std::vector<TrackingRecHit *>::iterator
begin = hits.begin(),
end = hits.end();
350 LogDebug(
"CosmicTrackSplitter") <<
" selected " << hits.size() <<
" hits ";
354 while ( (begin !=
end) && ( (*begin)->isValid() ==
false ) ) ++
begin;
357 LogDebug(
"CosmicTrackSplitter") <<
" after front stripping we have " << (
end -
begin) <<
" hits ";
362 while ( (begin !=
end) && ( (*end)->isValid() ==
false ) ) --
end;
366 LogDebug(
"CosmicTrackSplitter") <<
" after back stripping we have " << (
end -
begin) <<
" hits ";
372 LogDebug(
"CosmicTrackSplitter") <<
"we made a candidate of " << hits.size() <<
" hits!";
375 for (begin = hits.begin(),
end = hits.end(); begin !=
end; ++
begin) {
376 if (*begin)
delete *
begin;
378 LogDebug(
"CosmicTrackSplitter") <<
"loop: " <<
i <<
" has " << usedHitCtr <<
" active hits and " << hits.size() <<
" total hits...";
389 LogDebug(
"CosmicTrackSplitter") <<
"Making a candidate!";
394 if ( pdir ==
anyDirection )
throw cms::Exception(
"UnimplementedFeature") <<
"Cannot work with tracks that have 'anyDirecton' \n";
409 ownHits.
reserve(hitsEnd - hitsBegin);
410 for ( ; hitsBegin != hitsEnd; ++hitsBegin) { ownHits.
push_back( *hitsBegin ); }
415 LogDebug(
"CosmicTrackSplitter") <<
" dumping the hits now: ";
417 LogTrace(
"CosmicTrackSplitter") <<
" hit detid = " << hitR.first->geographicalId().rawId() <<
418 ", type = " <<
typeid(*hitR.first).
name();
const Vector & momentum() const
track momentum vector
TrackCandidate makeCandidate(const reco::Track &tk, std::vector< TrackingRecHit * >::iterator hitsBegin, std::vector< TrackingRecHit * >::iterator hitsEnd)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define DEFINE_FWK_MODULE(type)
std::vector< TrackCandidate > TrackCandidateCollection
edm::ESHandle< TrackerGeometry > theGeometry
std::pair< const_iterator, const_iterator > range
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.
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 getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool replaceWithInactiveHits_
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
XYZPointD XYZPoint
point in space with cartesian internal representation
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)
const reco::PFCandidateRefVector & tracks_
DetId geographicalId() const
Detector det() const
get the detector field from this detid
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
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_
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.