5 #include <Math/DistFunc.h>
11 src_( cfg.getParameter<edm::InputTag>(
"src" ) ),
12 beamspot_( cfg.getParameter<edm::InputTag>(
"beamspot" ) ),
13 useVertices_( cfg.getParameter<bool>(
"useVertices" ) ),
14 useVtxError_( cfg.getParameter<bool>(
"useVtxError" ) ),
15 vertices_( useVertices_ ? cfg.getParameter<edm::InputTag>(
"vertices" ) : edm::InputTag(
"NONE"))
19 std::vector<edm::ParameterSet> trkSelectors( cfg.
getParameter<std::vector< edm::ParameterSet> >(
"trackSelectors") );
23 res_par_.reserve(trkSelectors.size());
26 d0_par1_.reserve(trkSelectors.size());
27 dz_par1_.reserve(trkSelectors.size());
28 d0_par2_.reserve(trkSelectors.size());
29 dz_par2_.reserve(trkSelectors.size());
31 max_d0_.reserve(trkSelectors.size());
32 max_z0_.reserve(trkSelectors.size());
33 nSigmaZ_.reserve(trkSelectors.size());
45 for (
unsigned int i=0;
i<trkSelectors.size();
i++) {
52 res_par_.push_back(trkSelectors[
i].getParameter< std::vector<double> >(
"res_par") );
53 chi2n_par_.push_back( trkSelectors[
i].getParameter<double>(
"chi2n_par") );
55 d0_par1_.push_back(trkSelectors[
i].getParameter< std::vector<double> >(
"d0_par1"));
56 dz_par1_.push_back(trkSelectors[
i].getParameter< std::vector<double> >(
"dz_par1"));
57 d0_par2_.push_back(trkSelectors[
i].getParameter< std::vector<double> >(
"d0_par2"));
58 dz_par2_.push_back(trkSelectors[
i].getParameter< std::vector<double> >(
"dz_par2"));
62 max_d0_.push_back(trkSelectors[
i].getParameter<double>(
"max_d0"));
63 max_z0_.push_back(trkSelectors[
i].getParameter<double>(
"max_z0"));
64 nSigmaZ_.push_back(trkSelectors[
i].getParameter<double>(
"nSigmaZ"));
66 min_layers_.push_back(trkSelectors[
i].getParameter<uint32_t>(
"minNumberLayers") );
67 min_3Dlayers_.push_back(trkSelectors[
i].getParameter<uint32_t>(
"minNumber3DLayers") );
68 max_lostLayers_.push_back(trkSelectors[
i].getParameter<uint32_t>(
"maxNumberLostLayers"));
69 min_hits_bypass_.push_back(trkSelectors[
i].getParameter<uint32_t>(
"minHitsToBypassChecks"));
72 keepAllTracks_.push_back( trkSelectors[
i].getParameter<bool>(
"keepAllTracks"));
73 max_relpterr_.push_back(trkSelectors[
i].getParameter<double>(
"max_relpterr"));
74 min_nhits_.push_back(trkSelectors[
i].getParameter<uint32_t>(
"min_nhits"));
78 std::string qualityStr = trkSelectors[
i].getParameter<std::string>(
"qualityBit");
79 if (qualityStr !=
"") {
85 "You can't set the quality bit " << trkSelectors[
i].getParameter<std::string>(
"qualityBit") <<
" as it is 'undefQuality' or unknown.\n";
88 max_d0NoPV_.push_back(trkSelectors[i].getParameter<double>(
"max_d0NoPV"));
89 max_z0NoPV_.push_back(trkSelectors[i].getParameter<double>(
"max_z0NoPV"));
96 name_.push_back( trkSelectors[i].getParameter<std::string>(
"name") );
100 std::string pfName=trkSelectors[
i].getParameter<std::string>(
"preFilterName");
103 for (
unsigned int j=0;
j<
i;
j++)
109 throw cms::Exception(
"Configuration") <<
"Invalid prefilter name in MultiTrackSelector "
110 << trkSelectors[
i].getParameter<std::string>(
"preFilterName");
115 produces<edm::ValueMap<int> >(
name_[
i]).setBranchAlias(
name_[i] +
"TrackQuals");
126 using namespace reco;
136 vertexBeamSpot = *hBsp;
142 unsigned int trkSize=hSrcTrack->size();
143 std::vector<int> selTracksSave(
qualityToSet_.size()*trkSize,0);
147 std::vector<int> selTracks(trkSize,0);
148 auto_ptr<edm::ValueMap<int> > selTracksValueMap = auto_ptr<edm::ValueMap<int> >(
new edm::ValueMap<int>);
151 std::vector<Point> points;
152 std::vector<double> vterr;
153 std::vector<double> vzerr;
158 for (TrackCollection::const_iterator it = hSrcTrack->begin(), ed = hSrcTrack->end(); it != ed; ++it, ++
current) {
159 const Track & trk = * it;
162 LogTrace(
"TrackSelection") <<
"ready to check track with pt="<< trk.
pt() ;
167 selTracks.at(current)=-1;
173 ok =
select(
i,vertexBeamSpot, trk, points, vterr, vzerr);
175 LogTrace(
"TrackSelection") <<
"track with pt="<< trk.
pt() <<
" NOT selected";
177 selTracks.at(current)=-1;
182 LogTrace(
"TrackSelection") <<
"track with pt="<< trk.
pt() <<
" selected";
192 selTracks.at(current)= (selTracks.at(current) | (1<<
qualityToSet_[
i]));
193 if (!points.empty()) {
203 for (
unsigned int j=0;
j< trkSize;
j++ ) selTracksSave[
j+
i*trkSize]=selTracks.at(
j);
204 filler.insert(hSrcTrack, selTracks.begin(),selTracks.end());
216 const std::vector<Point> &points,
217 std::vector<double> &vterr,
218 std::vector<double> &vzerr) {
224 if ( tk.
ndof() < 1E-5 )
return false;
231 LogDebug(
"TrackSelection") <<
"cuts on nlayers: " << nlayers <<
" " << nlayers3D <<
" " << nlayersLost <<
" vs "
236 LogTrace(
"TrackSelection") <<
"cuts on nlayers passed";
239 double chi2n_no1Dmod = chi2n;
245 if (
typeid(*hit) ==
typeid(SiStripRecHit1D)) ++count1dhits;
248 if (count1dhits > 0) {
249 double chi2 = tk.
chi2();
250 double ndof = tk.
ndof();
251 chi2n = (chi2+count1dhits)/
double(ndof+count1dhits);
255 if (chi2n >
chi2n_par_[tsNum]*nlayers)
return false;
260 double pt = tk.
pt(),
eta = tk.
eta();
276 double nomdzE = nomd0E*(std::cosh(
eta));
285 bool primaryVertexZCompatibility(
false);
286 bool primaryVertexD0Compatibility(
false);
288 if (points.empty()) {
290 if (
abs(dz) < hypot(vertexBeamSpot.
sigmaZ()*
nSigmaZ_[tsNum],dzCut) ) primaryVertexZCompatibility =
true;
292 if (
abs(d0) < d0Cut) primaryVertexD0Compatibility =
true;
296 for (std::vector<Point>::const_iterator
point = points.begin(),
end = points.end();
point !=
end; ++
point) {
297 LogTrace(
"TrackSelection") <<
"Test track w.r.t. vertex with z position " <<
point->z();
298 if(primaryVertexZCompatibility && primaryVertexD0Compatibility)
break;
302 double dzErrPV =
sqrt(dzE*dzE+vzerr[iv]*vzerr[iv]);
303 double d0ErrPV =
sqrt(d0E*d0E+vterr[iv]*vterr[iv]);
307 abs(dzPV) <
max_z0_[tsNum]) primaryVertexZCompatibility =
true;
310 abs(d0PV) <
max_d0_[tsNum]) primaryVertexD0Compatibility =
true;
312 if (
abs(dzPV) < dzCut) primaryVertexZCompatibility =
true;
313 if (
abs(d0PV) < d0Cut) primaryVertexD0Compatibility =
true;
315 LogTrace(
"TrackSelection") <<
"distances " << dzPV <<
" " << d0PV <<
" vs " << dzCut <<
" " << d0Cut;
323 if (
abs(d0) >
max_d0_[tsNum] && !primaryVertexD0Compatibility)
return false;
324 LogTrace(
"TrackSelection") <<
"absolute cuts on d0 passed";
325 if (
abs(dz) >
max_z0_[tsNum] && !primaryVertexZCompatibility)
return false;
326 LogTrace(
"TrackSelection") <<
"absolute cuts on dz passed";
330 <<
" d0 compatibility? " << primaryVertexD0Compatibility
331 <<
" z compatibility? " << primaryVertexZCompatibility ;
334 return (primaryVertexD0Compatibility && primaryVertexZCompatibility);
343 std::vector<Point> &points,
344 std::vector<double> &vterr,
345 std::vector<double> &vzerr) {
347 using namespace reco;
349 for (VertexCollection::const_iterator it = vtxs.begin(), ed = vtxs.end(); it != ed; ++it) {
351 LogDebug(
"SelectVertex") <<
" select vertex with z position " << it->z() <<
" "
352 << it->chi2() <<
" " << it->ndof() <<
" " << TMath::Prob(it->chi2(),
static_cast<int32_t
>(it->ndof()));
356 points.push_back(it->position());
357 vterr.push_back(
sqrt(it->yError()*it->xError()));
358 vzerr.push_back(it->zError());
359 LogTrace(
"SelectVertex") <<
" SELECTED vertex with z position " << it->z();
360 toTake--;
if (toTake == 0)
break;
std::vector< double > chi2n_par_
T getParameter(std::string const &) const
std::vector< double > max_d0NoPV_
std::vector< double > max_d0_
Impact parameter absolute cuts.
void selectVertices(unsigned int tsNum, const reco::VertexCollection &vtxs, std::vector< Point > &points, std::vector< double > &vterr, std::vector< double > &vzerr)
double d0Error() const
error on d0
std::vector< std::vector< double > > dz_par1_
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
std::vector< std::vector< double > > d0_par1_
std::vector< std::vector< double > > d0_par2_
std::vector< bool > applyAbsCutsIfNoPV_
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
process one event
std::vector< double > max_z0NoPV_
int pixelLayersWithMeasurement() const
int trackerLayersWithoutMeasurement() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
std::vector< uint32_t > min_3Dlayers_
int numberOfValidStripLayersWithMonoAndStereo() const
std::vector< int32_t > vtxNumber_
vertex cuts
std::vector< double > nSigmaZ_
std::vector< std::string > name_
double eta() const
pseudorapidity of momentum vector
std::vector< bool > keepAllTracks_
const T & max(const T &a, const T &b)
double chi2() const
chi-squared of the fit
std::vector< std::vector< double > > res_par_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
double ndof() const
number of degrees of freedom of the fit
int trackerLayersWithMeasurement() const
virtual ~MultiTrackSelector()
destructor
double pt() const
track transverse momentum
std::vector< uint32_t > min_nhits_
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
std::vector< unsigned int > preFilter_
unsigned short numberOfValidHits() const
number of valid hits found
bool select(unsigned tsNum, const reco::BeamSpot &vertexBeamSpot, const reco::Track &tk, const std::vector< Point > &points, std::vector< double > &vterr, std::vector< double > &vzerr)
return class, or -1 if rejected
std::vector< double > max_relpterr_
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::vector< uint32_t > min_hits_bypass_
edm::InputTag src_
source collection label
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
double dzError() const
error on dz
static TrackQuality qualityByName(const std::string &name)
std::vector< double > chi2n_no1Dmod_par_
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_
double sigmaZ() const
sigma z
std::vector< TrackBase::TrackQuality > qualityToSet_
std::vector< bool > setQualityBit_
do I have to set a quality bit?
std::vector< uint32_t > min_layers_
Cuts on numbers of layers with hits/3D hits/lost hits.
std::vector< double > max_z0_
unsigned short found() const
Number of valid hits on track.
const Point & position() const
position
std::vector< uint32_t > max_lostLayers_
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
std::vector< std::vector< double > > dz_par2_
std::vector< bool > applyAdaptedPVCuts_
Power< A, B >::type pow(const A &a, const B &b)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.