17 numOfMaxSeedsParam_(iConfig.getParameter<uint32_t>(
"maxSeeds")),
18 numOfLayersToTry_(iConfig.getParameter<int32_t>(
"layersToTry")),
19 numOfHitsToTry_(iConfig.getParameter<int32_t>(
"hitsToTry")),
20 fixedErrorRescalingForHits_(iConfig.getParameter<double>(
"fixedErrorRescaleFactorForHits")),
21 fixedErrorRescalingForHitless_(iConfig.getParameter<double>(
"fixedErrorRescaleFactorForHitless")),
22 adjustErrorsDynamicallyForHits_(iConfig.getParameter<
bool>(
"adjustErrorsDynamicallyForHits")),
23 adjustErrorsDynamicallyForHitless_(iConfig.getParameter<
bool>(
"adjustErrorsDynamicallyForHitless")),
24 estimatorName_(iConfig.getParameter<
std::
string>(
"estimator")),
25 minEtaForTEC_(iConfig.getParameter<double>(
"minEtaForTEC")),
26 maxEtaForTOB_(iConfig.getParameter<double>(
"maxEtaForTOB")),
27 useHitLessSeeds_(iConfig.getParameter<
bool>(
"UseHitLessSeeds")),
28 useStereoLayersInTEC_(iConfig.getParameter<
bool>(
"UseStereoLayersInTEC")),
31 pT1_(iConfig.getParameter<double>(
"pT1")),
32 pT2_(iConfig.getParameter<double>(
"pT2")),
33 pT3_(iConfig.getParameter<double>(
"pT3")),
34 eta1_(iConfig.getParameter<double>(
"eta1")),
35 eta2_(iConfig.getParameter<double>(
"eta2")),
36 SF1_(iConfig.getParameter<double>(
"SF1")),
37 SF2_(iConfig.getParameter<double>(
"SF2")),
38 SF3_(iConfig.getParameter<double>(
"SF3")),
39 SF4_(iConfig.getParameter<double>(
"SF4")),
40 SF5_(iConfig.getParameter<double>(
"SF5")),
41 tsosDiff_(iConfig.getParameter<double>(
"tsosDiff")),
42 propagatorName_(iConfig.getParameter<
std::
string>(
"propagatorName")),
43 theCategory(
string(
"Muon|RecoMuon|TSGForOI"))
45 produces<std::vector<TrajectorySeed> >();
56 unsigned int numSeedsMade=0;
57 bool analysedL2 =
false;
58 unsigned int layerCount = 0;
86 std::unique_ptr<std::vector<TrajectorySeed> >
result(
new std::vector<TrajectorySeed>());
89 std::vector<BarrelDetLayer const*>
const& tob = measurementTrackerH->geometricSearchTracker()->tobLayers();
91 measurementTrackerH->geometricSearchTracker()->posTidLayers() :
92 measurementTrackerH->geometricSearchTracker()->posTecLayers();
94 measurementTrackerH->geometricSearchTracker()->negTidLayers() :
95 measurementTrackerH->geometricSearchTracker()->negTecLayers();
111 for (
unsigned int l2TrackColIndex(0);l2TrackColIndex!=l2TrackCol->size();++l2TrackColIndex){
113 std::unique_ptr<std::vector<TrajectorySeed> >
out(
new std::vector<TrajectorySeed>());
114 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: L2 muon pT, eta, phi --> " << l2->pt() <<
" , " << l2->eta() <<
" , " << l2->phi() << endl;
117 dummyPlane->move(fts.
position() - dummyPlane->position());
119 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: Created TSOSatIP: " << tsosAtIP << std::endl;
123 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: Created TSOSatMuonSystem: " << tsosAtMuonSystem <<endl;
125 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: Check the error of the L2 parameter and use hit seeds if big errors" << endl;
135 bool useBoth =
false;
136 if (outerTkStateInside.isValid() && outerTkStateOutside.
isValid()){
137 dist =
match_Chi2(outerTkStateInside,outerTkStateOutside);
151 for (
auto it=tob.rbegin(); it!=tob.rend(); ++it) {
152 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TOB layer " << layerCount << endl;
153 findSeedsOnLayer(tTopo, **it, tsosAtIP, *(propagatorAlong.get()), *(propagatorOpposite.get()), l2,
154 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, analysedL2, out);
158 for (
auto it=tob.rbegin(); it!=tob.rend(); ++it) {
159 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TOB layer " << layerCount << endl;
160 findSeedsOnLayer(tTopo, **it, tsosAtMuonSystem, *(propagatorOpposite.get()), *(propagatorOpposite.get()), l2,
161 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, analysedL2, out);
174 for (
auto it=tecPositive.rbegin(); it!=tecPositive.rend(); ++it) {
175 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TEC+ layer " << layerCount << endl;
176 findSeedsOnLayer(tTopo, **it, tsosAtIP, *(propagatorAlong.get()), *(propagatorOpposite.get()), l2,
177 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, analysedL2, out);
181 for (
auto it=tecPositive.rbegin(); it!=tecPositive.rend(); ++it) {
182 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TEC+ layer " << layerCount << endl;
183 findSeedsOnLayer(tTopo, **it, tsosAtMuonSystem, *(propagatorOpposite.get()), *(propagatorOpposite.get()), l2,
184 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, analysedL2, out);
192 for (
auto it=tecNegative.rbegin(); it!=tecNegative.rend(); ++it) {
193 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TEC- layer " << layerCount << endl;
194 findSeedsOnLayer(tTopo, **it, tsosAtIP, *(propagatorAlong.get()), *(propagatorOpposite.get()), l2,
195 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, analysedL2, out);
199 for (
auto it=tecNegative.rbegin(); it!=tecNegative.rend(); ++it) {
200 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TEC- layer " << layerCount << endl;
201 findSeedsOnLayer(tTopo, **it, tsosAtMuonSystem, *(propagatorOpposite.get()), *(propagatorOpposite.get()), l2,
202 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, analysedL2, out);
209 for (std::vector<TrajectorySeed>::iterator it=out->begin(); it!=out->end(); ++it){
210 result->push_back(*it);
227 unsigned int& numSeedsMade,
228 unsigned int& numOfMaxSeeds,
229 unsigned int& layerCount,
231 std::unique_ptr<std::vector<TrajectorySeed> >&
out)
const{
233 if (numSeedsMade>numOfMaxSeeds)
return;
234 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: numSeedsMade = " << numSeedsMade <<
" , layerCount = " << layerCount << endl;
236 double errorSFHits=1.0;
237 double errorSFHitless=1.0;
244 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: Start hitless" << endl;
245 std::vector< GeometricSearchDet::DetWithState > dets;
248 auto const& detOnLayer = dets.front().first;
249 auto const& tsosOnLayer = dets.front().second;
250 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: tsosOnLayer " << tsosOnLayer << endl;
251 if (!tsosOnLayer.isValid()){
261 dets.front().second.rescaleError(errorSFHitless);
265 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: TSOD (Hitless) done " << endl;
273 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: Start Hits" <<endl;
274 if (
makeSeedsFromHits(tTopo, layer, tsosAtIP, *
out, propagatorAlong, *measurementTrackerH, estimatorH, numSeedsMade, errorSFHits, l2->eta())) ++layerCount;
283 double abseta =
std::abs(track->eta());
285 if (track->pt()>
pT1_ && track->pt()<=
pT2_){
290 if (track->pt()>
pT2_ && track->pt()<=
pT3_){
297 LogTrace(
theCategory) <<
"TSGForOI::calculateSFFromL2: SF has been calculated as: " << theSF;
306 std::vector<TrajectorySeed> &
out,
310 unsigned int& numSeedsMade,
311 const double errorSF,
312 const double l2Eta)
const{
318 std::vector< GeometricSearchDet::DetWithState > dets;
322 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: find measurements on each detWithState " << dets.size() << endl;
323 std::vector<TrajectoryMeasurement> meas;
324 for (std::vector<GeometricSearchDet::DetWithState>::iterator it=dets.begin(); it!=dets.end(); ++it) {
329 if (!it->second.isValid())
continue;
331 std::vector < TrajectoryMeasurement > mymeas = det.
fastMeasurements(it->second, onLayer, propagatorAlong, *estimatorH);
332 for (std::vector<TrajectoryMeasurement>::const_iterator it2 = mymeas.begin(), ed2 = mymeas.end(); it2 != ed2; ++it2) {
333 if (it2->recHit()->isValid()) meas.push_back(*it2);
339 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: Update TSOS using TMs after sorting, then create Trajectory Seed, number of TM = " << meas.size() << endl;
340 unsigned int found = 0;
342 for (std::vector<TrajectoryMeasurement>::const_iterator it=meas.begin(); it!=meas.end(); ++it) {
344 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: TSOS for TM " << found << endl;
345 if (not updatedTSOS.
isValid())
continue;
349 DetId detid = ((*it).recHit()->hit())->geographicalId();
356 seedHits.
push_back(*it->recHit()->hit());
359 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: number of seedHits: " << seedHits.
size() << endl;
379 bool ierr = !
m.Invert();
382 edm::LogInfo(
"TSGForOI") <<
"Error inverting covariance matrix";
386 double est = ROOT::Math::Similarity(
v,
m);
396 desc.
add<
int>(
"layersToTry",1);
397 desc.
add<
double>(
"fixedErrorRescaleFactorForHitless",2.0);
398 desc.
add<
int>(
"hitsToTry",1);
399 desc.
add<
bool>(
"adjustErrorsDynamicallyForHits",
false);
400 desc.
add<
bool>(
"adjustErrorsDynamicallyForHitless",
false);
402 desc.
add<
bool>(
"UseHitLessSeeds",
true);
403 desc.
add<
bool>(
"UseStereoLayersInTEC",
false);
404 desc.
add<
std::string>(
"estimator",
"hltESPChi2MeasurementEstimator100");
405 desc.
add<
double>(
"maxEtaForTOB",1.2);
406 desc.
add<
double>(
"minEtaForTEC",0.8);
408 desc.
add<
double>(
"fixedErrorRescaleFactorForHits",2.0);
409 desc.
add<
unsigned int>(
"maxSeeds",1);
410 desc.
add<
double>(
"pT1",13.0);
411 desc.
add<
double>(
"pT2",30.0);
412 desc.
add<
double>(
"pT3",70.0);
413 desc.
add<
double>(
"eta1",1.0);
414 desc.
add<
double>(
"eta2",1.4);
415 desc.
add<
double>(
"SF1",3.0);
416 desc.
add<
double>(
"SF2",4.0);
417 desc.
add<
double>(
"SF3",5.0);
418 desc.
add<
double>(
"SF4",7.0);
419 desc.
add<
double>(
"SF5",10.0);
420 desc.
add<
double>(
"tsosDiff",0.03);
422 descriptions.
add(
"TSGForOI",desc);
const std::string estimatorName_
Estimator used to find dets and TrajectoryMeasurements.
void rescaleError(double factor)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void produce(edm::StreamID sid, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
const LocalTrajectoryParameters & localParameters() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const double tsosDiff_
Distance of TSOSs to trigger using hits or not.
void findSeedsOnLayer(const TrackerTopology *tTopo, const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsosAtIP, const Propagator &propagatorAlong, const Propagator &propagatorOpposite, const reco::TrackRef l2, edm::ESHandle< Chi2MeasurementEstimatorBase > &estimator_, edm::Handle< MeasurementTrackerEvent > &measurementTrackerH, unsigned int &numSeedsMade, unsigned int &numOfMaxSeeds, unsigned int &layerCount, bool &analysedL2, std::unique_ptr< std::vector< TrajectorySeed > > &out) const
Function to find seeds on a given layer.
constexpr uint32_t rawId() const
get the raw id
std::vector< Track > TrackCollection
collection of Tracks
const std::string propagatorName_
Counters and flags for the implementation.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
const double maxEtaForTOB_
Maximum eta value to activate searching in the TOB.
bool isThere(GeomDetEnumerators::SubDetector subdet) const
AlgebraicVector5 vector() const
bool tecIsStereo(const DetId &id) const
std::unique_ptr< Propagator > SetPropagationDirection(Propagator const &iprop, PropagationDirection dir)
const double minEtaForTEC_
Minimum eta value to activate searching in the TEC.
#define DEFINE_FWK_MODULE(type)
double match_Chi2(const TrajectoryStateOnSurface &tsos1, const TrajectoryStateOnSurface &tsos2) const
const double fixedErrorRescalingForHits_
How much to rescale errors from the L2 (fixed error vs pT, eta)
const std::unique_ptr< TrajectoryStateUpdator > updator_
KFUpdator defined in constructor.
std::vector< TrajectoryMeasurement > fastMeasurements(const TrajectoryStateOnSurface &stateOnThisDet, const TrajectoryStateOnSurface &tsos2, const Propagator &prop, const MeasurementEstimator &est) const
static PlanePointer build(Args &&...args)
const bool useHitLessSeeds_
const unsigned int numOfLayersToTry_
How many layers to try.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
double calculateSFFromL2(const reco::TrackRef track) const
Function used to calculate the dynamic error SF by analysing the L2.
const bool useStereoLayersInTEC_
Switch ON to use Stereo layers instead of using every layer in TEC.
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Create L3MuonTrajectorySeeds from L2 Muons updated at vertex in an outside in manner.
const bool adjustErrorsDynamicallyForHitless_
const double pT1_
pT, eta ranges and scale factor values
GlobalPoint position() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
int makeSeedsFromHits(const TrackerTopology *tTopo, const GeometricSearchDet &layer, const TrajectoryStateOnSurface &tsosAtIP, std::vector< TrajectorySeed > &out, const Propagator &propagatorAlong, const MeasurementTrackerEvent &measurementTracker, edm::ESHandle< Chi2MeasurementEstimatorBase > &estimator_, unsigned int &numSeedsMade, const double errorSF, const double l2Eta) const
Function to find hits on layers and create seeds from updated TSOS.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< reco::TrackCollection > src_
Labels for input collections.
const bool adjustErrorsDynamicallyForHits_
Whether or not to use an automatically calculated scale-factor value.
TSGForOI(const edm::ParameterSet &iConfig)
const edm::EDGetTokenT< MeasurementTrackerEvent > measurementTrackerTag_
const unsigned int numOfMaxSeedsParam_
Maximum number of seeds for each L2.
const std::string theCategory
T const * product() const
virtual void compatibleDetsV(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, std::vector< DetWithState > &result) const
const unsigned int numOfHitsToTry_
How many hits to try per layer.
const double fixedErrorRescalingForHitless_