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 theCategory(
string(
"Muon|RecoMuon|TSGForOI"))
44 produces<std::vector<TrajectorySeed> >();
55 unsigned int numSeedsMade=0;
56 bool analysedL2 =
false;
57 bool foundHitlessSeed =
false;
58 unsigned int layerCount = 0;
84 std::unique_ptr<std::vector<TrajectorySeed> >
result(
new std::vector<TrajectorySeed>());
87 std::vector<BarrelDetLayer const*>
const& tob = measurementTrackerH->geometricSearchTracker()->tobLayers();
88 std::vector<ForwardDetLayer const*>
const& tecPositive = measurementTrackerH->geometricSearchTracker()->posTecLayers();
89 std::vector<ForwardDetLayer const*>
const& tecNegative = measurementTrackerH->geometricSearchTracker()->negTecLayers();
105 for (
unsigned int l2TrackColIndex(0);l2TrackColIndex!=l2TrackCol->size();++l2TrackColIndex){
107 std::unique_ptr<std::vector<TrajectorySeed> >
out(
new std::vector<TrajectorySeed>());
108 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: L2 muon pT, eta, phi --> " << l2->pt() <<
" , " << l2->eta() <<
" , " << l2->phi() << endl;
111 dummyPlane->move(fts.
position() - dummyPlane->position());
113 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: Created TSOSatIP: " << tsosAtIP << std::endl;
117 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: Created TSOSatMuonSystem: " << tsosAtMuonSystem <<endl;
120 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: Check the error of the L2 parameter and use hit seeds if big errors" << endl;
130 if (outerTkStateInside.isValid() && outerTkStateOutside.
isValid()){
131 float deta = outerTkStateInside.globalPosition().eta() - outerTkStateOutside.
globalPosition().
eta();
132 float dphi = outerTkStateInside.globalPosition().phi() - outerTkStateOutside.
globalPosition().
phi();
133 dist =
sqrt(deta*deta+dphi*dphi);
142 foundHitlessSeed =
false;
147 for (
auto it=tob.rbegin(); it!=tob.rend(); ++it) {
148 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TOB layer " << layerCount << endl;
149 findSeedsOnLayer(tTopo, **it, tsosAtIP, *(propagatorAlong.get()), *(propagatorOpposite.get()), l2,
150 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, foundHitlessSeed, analysedL2, out);
162 for (
auto it=tecPositive.rbegin(); it!=tecPositive.rend(); ++it) {
163 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TEC+ layer " << layerCount << endl;
164 findSeedsOnLayer(tTopo, **it, tsosAtIP, *(propagatorAlong.get()), *(propagatorOpposite.get()), l2,
165 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, foundHitlessSeed, analysedL2, out);
172 for (
auto it=tecNegative.rbegin(); it!=tecNegative.rend(); ++it) {
173 LogTrace(
"TSGForOI") <<
"TSGForOI::produce: looping in TEC- layer " << layerCount << endl;
174 findSeedsOnLayer(tTopo, **it, tsosAtIP, *(propagatorAlong.get()), *(propagatorOpposite.get()), l2,
175 estimatorH, measurementTrackerH, numSeedsMade, numOfMaxSeeds, layerCount, foundHitlessSeed, analysedL2, out);
179 for (std::vector<TrajectorySeed>::iterator it=out->begin(); it!=out->end(); ++it){
180 result->push_back(*it);
197 unsigned int& numSeedsMade,
198 unsigned int& numOfMaxSeeds,
199 unsigned int& layerCount,
200 bool& foundHitlessSeed,
202 std::unique_ptr<std::vector<TrajectorySeed> >&
out)
const{
204 if (numSeedsMade>numOfMaxSeeds)
return;
205 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: numSeedsMade = " << numSeedsMade <<
" , layerCount = " << layerCount << endl;
207 double errorSFHits=1.0;
208 double errorSFHitless=1.0;
214 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: Start hitless" << endl;
215 std::vector< GeometricSearchDet::DetWithState > dets;
218 auto const& detOnLayer = dets.front().first;
219 auto const& tsosOnLayer = dets.front().second;
220 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: tsosOnLayer " << tsosOnLayer << endl;
221 if (!tsosOnLayer.isValid()){
231 dets.front().second.rescaleError(errorSFHitless);
235 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: TSOD (Hitless) done " << endl;
236 foundHitlessSeed=
true;
238 numSeedsMade=
out->size();
245 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: Start Hits" <<endl;
246 if (
makeSeedsFromHits(tTopo, layer, tsosAtIP, *
out, propagatorAlong, *measurementTrackerH, estimatorH, errorSFHits)) ++layerCount;
247 numSeedsMade=
out->size();
256 double abseta =
std::abs(track->eta());
258 if (track->pt()>
pT1_ && track->pt()<=
pT2_){
263 if (track->pt()>
pT2_ && track->pt()<=
pT3_){
270 LogTrace(
theCategory) <<
"TSGForOI::calculateSFFromL2: SF has been calculated as: " << theSF;
279 std::vector<TrajectorySeed> &
out,
283 const double errorSF)
const{
289 std::vector< GeometricSearchDet::DetWithState > dets;
293 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: find measurements on each detWithState " << dets.size() << endl;
294 std::vector<TrajectoryMeasurement> meas;
295 for (std::vector<GeometricSearchDet::DetWithState>::iterator it=dets.begin(); it!=dets.end(); ++it) {
300 if (!it->second.isValid())
continue;
302 std::vector < TrajectoryMeasurement > mymeas = det.
fastMeasurements(it->second, onLayer, propagatorAlong, *estimatorH);
303 for (std::vector<TrajectoryMeasurement>::const_iterator it2 = mymeas.begin(), ed2 = mymeas.end(); it2 != ed2; ++it2) {
304 if (it2->recHit()->isValid()) meas.push_back(*it2);
310 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: Update TSOS using TMs after sorting, then create Trajectory Seed, number of TM = " << meas.size() << endl;
311 unsigned int found = 0;
313 for (std::vector<TrajectoryMeasurement>::const_iterator it=meas.begin(); it!=meas.end(); ++it) {
315 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: TSOS for TM " << found << endl;
316 if (not updatedTSOS.
isValid())
continue;
320 DetId detid = ((*it).recHit()->hit())->geographicalId();
327 seedHits.
push_back(*it->recHit()->hit());
330 LogTrace(
"TSGForOI") <<
"TSGForOI::findSeedsOnLayer: number of seedHits: " << seedHits.
size() << endl;
342 desc.
add<
int>(
"layersToTry",1);
343 desc.
add<
double>(
"fixedErrorRescaleFactorForHitless",2.0);
344 desc.
add<
int>(
"hitsToTry",1);
345 desc.
add<
bool>(
"adjustErrorsDynamicallyForHits",
false);
346 desc.
add<
bool>(
"adjustErrorsDynamicallyForHitless",
false);
348 desc.
add<
bool>(
"UseHitLessSeeds",
true);
349 desc.
add<
bool>(
"UseStereoLayersInTEC",
false);
350 desc.
add<
std::string>(
"estimator",
"hltESPChi2MeasurementEstimator100");
351 desc.
add<
double>(
"maxEtaForTOB",1.2);
352 desc.
add<
double>(
"minEtaForTEC",0.8);
354 desc.
add<
double>(
"fixedErrorRescaleFactorForHits",2.0);
355 desc.
add<
unsigned int>(
"maxSeeds",1);
356 desc.
add<
double>(
"pT1",13.0);
357 desc.
add<
double>(
"pT2",30.0);
358 desc.
add<
double>(
"pT3",70.0);
359 desc.
add<
double>(
"eta1",1.0);
360 desc.
add<
double>(
"eta2",1.4);
361 desc.
add<
double>(
"SF1",3.0);
362 desc.
add<
double>(
"SF2",4.0);
363 desc.
add<
double>(
"SF3",5.0);
364 desc.
add<
double>(
"SF4",7.0);
365 desc.
add<
double>(
"SF5",10.0);
366 desc.
add<
double>(
"tsosDiff",0.03);
367 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)
virtual void produce(edm::StreamID sid, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
const double tsosDiff_
Distance of TSOSs to trigger using hits or not.
Geom::Phi< T > phi() const
std::vector< Track > TrackCollection
collection of Tracks
GlobalPoint globalPosition() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const double maxEtaForTOB_
Maximum eta value to activate searching in the TOB.
uint32_t rawId() const
get the raw id
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.
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.
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.
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 &foundHitlessSeed, bool &analysedL2, std::unique_ptr< std::vector< TrajectorySeed > > &out) const
Function to find seeds on a given layer.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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
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_, const double errorSF) 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
Counters and flags for the implementation.
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_