CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L2MuonSeedGeneratorFromL1T Class Reference

#include <L2MuonSeedGeneratorFromL1T.h>

Inheritance diagram for L2MuonSeedGeneratorFromL1T:
edm::stream::EDProducer<>

Public Member Functions

 L2MuonSeedGeneratorFromL1T (const edm::ParameterSet &)
 Constructor. More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~L2MuonSeedGeneratorFromL1T () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

const TrajectorySeedassociateOfflineSeedToL1 (edm::Handle< edm::View< TrajectorySeed > > &, std::vector< int > &, TrajectoryStateOnSurface &, double)
 
bool isAssociateOfflineSeedToL1 (edm::Handle< edm::View< TrajectorySeed > > &, std::vector< std::vector< double > > &, TrajectoryStateOnSurface &, unsigned int, std::vector< std::vector< const TrajectorySeed * > > &, double)
 

Private Attributes

bool centralBxOnly_
 use central bx only muons More...
 
std::vector< double > etaBins
 
std::vector< double > matchingDR
 
const unsigned matchType
 
edm::EDGetTokenT< l1t::MuonBxCollectionmuCollToken_
 
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
 
const unsigned sortType
 
MeasurementEstimatortheEstimator
 
edm::InputTag theL1GMTReadoutCollection
 
const double theL1MaxEta
 
const double theL1MinPt
 
const unsigned theL1MinQuality
 
const double theMinPtBarrel
 
const double theMinPtEndcap
 
edm::InputTag theOfflineSeedLabel
 
std::string thePropagatorName
 
MuonServiceProxytheService
 the event setup proxy, it takes care the services update More...
 
edm::InputTag theSource
 
const bool useOfflineSeed
 
const bool useUnassociatedL1
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

L2 muon seed generator: Transform the L1 informations in seeds for the L2 muon reconstruction

Author
A.Everett, R.Bellan, J. Alcaraz

ORCA's author: N. Neumeister

Modified by M.Oh

L2 muon seed generator: Transform the L1 informations in seeds for the L2 muon reconstruction

Author
A.Everett, R.Bellan

ORCA's author: N. Neumeister

Modified by M.Oh

Definition at line 48 of file L2MuonSeedGeneratorFromL1T.h.

Constructor & Destructor Documentation

L2MuonSeedGeneratorFromL1T::L2MuonSeedGeneratorFromL1T ( const edm::ParameterSet iConfig)
explicit

Constructor.

Definition at line 66 of file L2MuonSeedGeneratorFromL1T.cc.

References Chi2MeasurementEstimator_cfi::Chi2MeasurementEstimator, etaBins, Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), matchingDR, matchType, muCollToken_, MuonServiceProxy_cff::MuonServiceProxy, offlineSeedToken_, sortType, theEstimator, theOfflineSeedLabel, theService, theSource, and useOfflineSeed.

66  :
67  theSource(iConfig.getParameter<InputTag>("InputObjects")),
68  theL1GMTReadoutCollection(iConfig.getParameter<InputTag>("GMTReadoutCollection")), // to be removed
69  thePropagatorName(iConfig.getParameter<string>("Propagator")),
70  theL1MinPt(iConfig.getParameter<double>("L1MinPt")),
71  theL1MaxEta(iConfig.getParameter<double>("L1MaxEta")),
72  theL1MinQuality(iConfig.getParameter<unsigned int>("L1MinQuality")),
73  theMinPtBarrel(iConfig.getParameter<double>("SetMinPtBarrelTo")),
74  theMinPtEndcap(iConfig.getParameter<double>("SetMinPtEndcapTo")),
75  useOfflineSeed(iConfig.getUntrackedParameter<bool>("UseOfflineSeed", false)),
76  useUnassociatedL1(iConfig.getParameter<bool>("UseUnassociatedL1")),
77  matchingDR(iConfig.getParameter<std::vector<double> >("MatchDR")),
78  etaBins(iConfig.getParameter<std::vector<double> >("EtaMatchingBins")),
79  centralBxOnly_( iConfig.getParameter<bool>("CentralBxOnly") ),
80  matchType( iConfig.getParameter<unsigned int>("MatchType") ),
81  sortType( iConfig.getParameter<unsigned int>("SortType") )
82  {
83 
84  muCollToken_ = consumes<MuonBxCollection>(theSource);
85 
86  if(useOfflineSeed) {
87  theOfflineSeedLabel = iConfig.getUntrackedParameter<InputTag>("OfflineSeedLabel");
88  offlineSeedToken_ = consumes<edm::View<TrajectorySeed> >(theOfflineSeedLabel);
89 
90  // check that number of eta bins -1 matches number of dR cones
91  if( matchingDR.size()!=etaBins.size() - 1 ) {
92  throw cms::Exception("Configuration") << "Size of MatchDR "
93  << "does not match number of eta bins." << endl;
94  }
95 
96 
97  }
98 
99  if(matchType>4 || sortType>3) {
100  throw cms::Exception("Configuration") << "Wrong MatchType or SortType" << endl;
101  }
102 
103  // service parameters
104  ParameterSet serviceParameters = iConfig.getParameter<ParameterSet>("ServiceParameters");
105 
106  // the services
107  theService = new MuonServiceProxy(serviceParameters);
108 
109  // the estimator
111 
112 
113  produces<L2MuonTrajectorySeedCollection>();
114 }
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool centralBxOnly_
use central bx only muons
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
edm::EDGetTokenT< l1t::MuonBxCollection > muCollToken_
L2MuonSeedGeneratorFromL1T::~L2MuonSeedGeneratorFromL1T ( )
override

Destructor.

Definition at line 117 of file L2MuonSeedGeneratorFromL1T.cc.

References theEstimator, and theService.

117  {
118  if (theService) delete theService;
119  if (theEstimator) delete theEstimator;
120 }
MuonServiceProxy * theService
the event setup proxy, it takes care the services update

Member Function Documentation

const TrajectorySeed * L2MuonSeedGeneratorFromL1T::associateOfflineSeedToL1 ( edm::Handle< edm::View< TrajectorySeed > > &  offseeds,
std::vector< int > &  offseedMap,
TrajectoryStateOnSurface newTsos,
double  dRcone 
)
private

Definition at line 885 of file L2MuonSeedGeneratorFromL1T.cc.

References edm::View< T >::begin(), boostedElectronIsolation_cff::deltaR, MuonPatternRecoDumper::dumpMuonId(), PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::globalPosition(), LogDebug, PV3DBase< T, PVType, FrameType >::phi(), AlCaHLTBitMon_QueryRunRegistry::string, TrajectoryStateOnSurface::surface(), thePropagatorName, and theService.

Referenced by produce().

888  {
889 
890  const std::string metlabel = "Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
891  MuonPatternRecoDumper debugtmp;
892 
893  edm::View<TrajectorySeed>::const_iterator offseed, endOffseed = offseeds->end();
894  const TrajectorySeed *selOffseed = nullptr;
895  double bestDr = 99999.;
896  unsigned int nOffseed(0);
897  int lastOffseed(-1);
898 
899  for(offseed=offseeds->begin(); offseed!=endOffseed; ++offseed, ++nOffseed) {
900  if(offseedMap[nOffseed]!=0) continue;
901  GlobalPoint glbPos = theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().position());
902  GlobalVector glbMom = theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().momentum());
903 
904  // Preliminary check
905  double preDr = deltaR( newTsos.globalPosition().eta(), newTsos.globalPosition().phi(), glbPos.eta(), glbPos.phi() );
906  if(preDr > 1.0) continue;
907 
908  const FreeTrajectoryState offseedFTS(glbPos, glbMom, offseed->startingState().parameters().charge(), &*theService->magneticField());
909  TrajectoryStateOnSurface offseedTsos = theService->propagator(thePropagatorName)->propagate(offseedFTS, newTsos.surface());
910  LogDebug(metlabel) << "Offline seed info: Det and State" << std::endl;
911  LogDebug(metlabel) << debugtmp.dumpMuonId(offseed->startingState().detId()) << std::endl;
912  LogDebug(metlabel) << "pos: (r=" << offseedFTS.position().mag() << ", phi="
913  << offseedFTS.position().phi() << ", eta=" << offseedFTS.position().eta() << ")" << std::endl;
914  LogDebug(metlabel) << "mom: (q*pt=" << offseedFTS.charge()*offseedFTS.momentum().perp() << ", phi="
915  << offseedFTS.momentum().phi() << ", eta=" << offseedFTS.momentum().eta() << ")" << std::endl << std::endl;
916 
917  if(offseedTsos.isValid()) {
918  LogDebug(metlabel) << "Offline seed info after propagation to L1 layer:" << std::endl;
919  LogDebug(metlabel) << "pos: (r=" << offseedTsos.globalPosition().mag() << ", phi="
920  << offseedTsos.globalPosition().phi() << ", eta=" << offseedTsos.globalPosition().eta() << ")" << std::endl;
921  LogDebug(metlabel) << "mom: (q*pt=" << offseedTsos.charge()*offseedTsos.globalMomentum().perp() << ", phi="
922  << offseedTsos.globalMomentum().phi() << ", eta=" << offseedTsos.globalMomentum().eta() << ")" << std::endl << std::endl;
923  double newDr = deltaR( newTsos.globalPosition().eta(), newTsos.globalPosition().phi(),
924  offseedTsos.globalPosition().eta(), offseedTsos.globalPosition().phi() );
925  LogDebug(metlabel) << " -- DR = " << newDr << std::endl;
926  if( newDr < dRcone && newDr<bestDr ) {
927  LogDebug(metlabel) << " --> OK! " << newDr << std::endl << std::endl;
928  selOffseed = &*offseed;
929  bestDr = newDr;
930  offseedMap[nOffseed] = 1;
931  if(lastOffseed>-1) offseedMap[lastOffseed] = 0;
932  lastOffseed = nOffseed;
933  }
934  else {
935  LogDebug(metlabel) << " --> Rejected. " << newDr << std::endl << std::endl;
936  }
937  }
938  else {
939  LogDebug(metlabel) << "Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
940  }
941  }
942 
943  return selOffseed;
944 }
#define LogDebug(id)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalPoint globalPosition() const
std::string dumpMuonId(const DetId &id) const
const SurfaceType & surface() const
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
T eta() const
Definition: PV3DBase.h:76
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void L2MuonSeedGeneratorFromL1T::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 123 of file L2MuonSeedGeneratorFromL1T.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and edm::ParameterSetDescription::addUntracked().

123  {
125  desc.add<edm::InputTag>("GMTReadoutCollection", edm::InputTag("")); // to be removed
126  desc.add<edm::InputTag>("InputObjects",edm::InputTag("hltGmtStage2Digis"));
127  desc.add<string>("Propagator", "");
128  desc.add<double>("L1MinPt",-1.);
129  desc.add<double>("L1MaxEta",5.0);
130  desc.add<unsigned int>("L1MinQuality",0);
131  desc.add<double>("SetMinPtBarrelTo",3.5);
132  desc.add<double>("SetMinPtEndcapTo",1.0);
133  desc.addUntracked<bool>("UseOfflineSeed",false);
134  desc.add<bool>("UseUnassociatedL1", true);
135  desc.add<std::vector<double>>("MatchDR", {0.3});
136  desc.add<std::vector<double>>("EtaMatchingBins", {0., 2.5});
137  desc.add<bool>("CentralBxOnly", true);
138  desc.add<unsigned int>("MatchType", 0)->setComment("MatchType : 0 Old matching, 1 L1 Order(1to1), 2 Min dR(1to1), 3 Higher Q(1to1), 4 All matched L1");
139  desc.add<unsigned int>("SortType", 0)->setComment("SortType : 0 not sort, 1 Pt, 2 Q and Pt");
140  desc.addUntracked<edm::InputTag>("OfflineSeedLabel", edm::InputTag(""));
141 
143  psd0.addUntracked<std::vector<std::string>>("Propagators", {
144  "SteppingHelixPropagatorAny"
145  });
146  psd0.add<bool>("RPCLayers", true);
147  psd0.addUntracked<bool>("UseMuonNavigation", true);
148  desc.add<edm::ParameterSetDescription>("ServiceParameters", psd0);
149  descriptions.add("L2MuonSeedGeneratorFromL1T",desc);
150 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool L2MuonSeedGeneratorFromL1T::isAssociateOfflineSeedToL1 ( edm::Handle< edm::View< TrajectorySeed > > &  offseeds,
std::vector< std::vector< double > > &  dRmtx,
TrajectoryStateOnSurface newTsos,
unsigned int  imu,
std::vector< std::vector< const TrajectorySeed * > > &  selOffseeds,
double  dRcone 
)
private

Definition at line 947 of file L2MuonSeedGeneratorFromL1T.cc.

References edm::View< T >::begin(), boostedElectronIsolation_cff::deltaR, MuonPatternRecoDumper::dumpMuonId(), PV3DBase< T, PVType, FrameType >::eta(), TrajectoryStateOnSurface::globalPosition(), LogDebug, PV3DBase< T, PVType, FrameType >::phi(), AlCaHLTBitMon_QueryRunRegistry::string, TrajectoryStateOnSurface::surface(), thePropagatorName, and theService.

Referenced by produce().

952  {
953 
954  const std::string metlabel = "Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
955  bool isAssociated = false;
956  MuonPatternRecoDumper debugtmp;
957 
958  edm::View<TrajectorySeed>::const_iterator offseed, endOffseed = offseeds->end();
959  unsigned int nOffseed(0);
960 
961  for(offseed=offseeds->begin(); offseed!=endOffseed; ++offseed, ++nOffseed) {
962  GlobalPoint glbPos = theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().position());
963  GlobalVector glbMom = theService->trackingGeometry()->idToDet(offseed->startingState().detId())->surface().toGlobal(offseed->startingState().parameters().momentum());
964 
965  // Preliminary check
966  double preDr = deltaR( newTsos.globalPosition().eta(), newTsos.globalPosition().phi(), glbPos.eta(), glbPos.phi() );
967  if(preDr > 1.0) continue;
968 
969  const FreeTrajectoryState offseedFTS(glbPos, glbMom, offseed->startingState().parameters().charge(), &*theService->magneticField());
970  TrajectoryStateOnSurface offseedTsos = theService->propagator(thePropagatorName)->propagate(offseedFTS, newTsos.surface());
971  LogDebug(metlabel) << "Offline seed info: Det and State" << std::endl;
972  LogDebug(metlabel) << debugtmp.dumpMuonId(offseed->startingState().detId()) << std::endl;
973  LogDebug(metlabel) << "pos: (r=" << offseedFTS.position().mag() <<
974  ", phi=" << offseedFTS.position().phi() <<
975  ", eta=" << offseedFTS.position().eta() << ")" << std::endl;
976  LogDebug(metlabel) << "mom: (q*pt=" << offseedFTS.charge()*offseedFTS.momentum().perp() <<
977  ", phi=" << offseedFTS.momentum().phi() <<
978  ", eta=" << offseedFTS.momentum().eta() << ")" << std::endl << std::endl;
979 
980  if(offseedTsos.isValid()) {
981  LogDebug(metlabel) << "Offline seed info after propagation to L1 layer:" << std::endl;
982  LogDebug(metlabel) << "pos: (r=" << offseedTsos.globalPosition().mag() <<
983  ", phi=" << offseedTsos.globalPosition().phi() <<
984  ", eta=" << offseedTsos.globalPosition().eta() << ")" << std::endl;
985  LogDebug(metlabel) << "mom: (q*pt=" << offseedTsos.charge()*offseedTsos.globalMomentum().perp() <<
986  ", phi=" << offseedTsos.globalMomentum().phi() <<
987  ", eta=" << offseedTsos.globalMomentum().eta() << ")" << std::endl << std::endl;
988  double newDr = deltaR( newTsos.globalPosition().eta(), newTsos.globalPosition().phi(),
989  offseedTsos.globalPosition().eta(), offseedTsos.globalPosition().phi() );
990 
991 
992  LogDebug(metlabel) << " -- DR = " << newDr << std::endl;
993  if( newDr < dRcone ) {
994  LogDebug(metlabel) << " --> OK! " << newDr << std::endl << std::endl;
995 
996  dRmtx[imu][nOffseed] = newDr;
997  selOffseeds[imu][nOffseed] = &*offseed;
998 
999  isAssociated = true;
1000  }
1001  else {
1002  LogDebug(metlabel) << " --> Rejected. " << newDr << std::endl << std::endl;
1003  }
1004  }
1005  else {
1006  LogDebug(metlabel) << "Invalid offline seed TSOS after propagation!" << std::endl << std::endl;
1007  }
1008  }
1009 
1010  return isAssociated;
1011 }
#define LogDebug(id)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
GlobalPoint globalPosition() const
std::string dumpMuonId(const DetId &id) const
const SurfaceType & surface() const
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
T eta() const
Definition: PV3DBase.h:76
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
void L2MuonSeedGeneratorFromL1T::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 152 of file L2MuonSeedGeneratorFromL1T.cc.

References alongMomentum, associateOfflineSeedToL1(), Reference_intrackfit_cff::barrel, centralBxOnly_, ALCARECOTkAlJpsiMuMu_cff::charge, TrajectoryStateOnSurface::charge(), GeometricSearchDet::compatibleDets(), funct::cos(), debug, SoftLeptonByDistance_cfi::distance, PFRecoTauChargedHadronBuilderPlugins_cfi::dRcone, MuonPatternRecoDumper::dumpFTS(), MuonPatternRecoDumper::dumpLayer(), MuonPatternRecoDumper::dumpMuonId(), MuonPatternRecoDumper::dumpTSOS(), relativeConstraints::error, PVValHelper::eta, PV3DBase< T, PVType, FrameType >::eta(), etaBins, JetChargeProducer_cfi::exp, GeomDet::geographicalId(), edm::Event::getByToken(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), mps_fire::i, createfilelist::int, isAssociateOfflineSeedToL1(), TrajectoryStateOnSurface::isValid(), LogDebug, PV3DBase< T, PVType, FrameType >::mag(), matchingDR, matchType, metname, eostools::move(), muCollToken_, offlineSeedToken_, convertSQLitetoXML_cfg::output, PV3DBase< T, PVType, FrameType >::perp(), trajectoryStateTransform::persistentState(), phi, PV3DBase< T, PVType, FrameType >::phi(), Geom::pi(), GeometricSearchDet::position(), EnergyCorrector::pt, edm::OwnVector< T, P >::push_back(), edm::Event::put(), jets_cff::quality, TCMET_cfi::radius, DetId::rawId(), TrajectorySeed::recHits(), funct::sin(), jetUpdater_cfi::sort, sortByL1Pt(), sortByL1QandPt(), sortType, TrajectorySeed::startingState(), AlCaHLTBitMon_QueryRunRegistry::string, GeometricSearchDet::surface(), theEstimator, theL1MaxEta, theL1MinPt, theL1MinQuality, theMinPtBarrel, theMinPtEndcap, thePropagatorName, theService, theta(), pfDeepBoostedJetPreprocessParams_cfi::upper_bound, useOfflineSeed, useUnassociatedL1, and PV3DBase< T, PVType, FrameType >::z().

153 {
154  const std::string metname = "Muon|RecoMuon|L2MuonSeedGeneratorFromL1T";
156 
157  auto output = std::make_unique<L2MuonTrajectorySeedCollection>();
158 
160  iEvent.getByToken(muCollToken_, muColl);
161  LogDebug(metname) << "Number of muons " << muColl->size() << endl;
162 
163 
164  //--- matchType 0 : Old logic
165  if(matchType == 0) {
166 
167  edm::Handle<edm::View<TrajectorySeed> > offlineSeedHandle;
168  vector<int> offlineSeedMap;
169  if(useOfflineSeed) {
170  iEvent.getByToken(offlineSeedToken_, offlineSeedHandle);
171  LogDebug(metname) << "Number of offline seeds " << offlineSeedHandle->size() << endl;
172  offlineSeedMap = vector<int>(offlineSeedHandle->size(), 0);
173  }
174 
175  for (int ibx = muColl->getFirstBX(); ibx <= muColl->getLastBX(); ++ibx) {
176  if (centralBxOnly_ && (ibx != 0)) continue;
177  for (auto it = muColl->begin(ibx); it != muColl->end(ibx); it++){
178 
179  unsigned int quality = it->hwQual();
180  int valid_charge = it->hwChargeValid();
181 
182  float pt = it->pt();
183  float eta = it->eta();
184  float theta = 2*atan(exp(-eta));
185  float phi = it->phi();
186  int charge = it->charge();
187  // Set charge=0 for the time being if the valid charge bit is zero
188  if (!valid_charge) charge = 0;
189 
190  // link number indices of the optical fibres that connect the uGMT with the track finders
191  //EMTF+ : 36-41, OMTF+ : 42-47, BMTF : 48-59, OMTF- : 60-65, EMTF- : 66-71
192  int link = 36 + (int)(it -> tfMuonIndex() / 3.);
193  bool barrel = true;
194  if ( (link >= 36 && link <= 41) || (link >= 66 && link <= 71)) barrel = false;
195 
196  if ( pt < theL1MinPt || fabs(eta) > theL1MaxEta ) continue;
197 
198  LogDebug(metname) << "New L2 Muon Seed" ;
199  LogDebug(metname) << "Pt = " << pt << " GeV/c";
200  LogDebug(metname) << "eta = " << eta;
201  LogDebug(metname) << "theta = " << theta << " rad";
202  LogDebug(metname) << "phi = " << phi << " rad";
203  LogDebug(metname) << "charge = " << charge;
204  LogDebug(metname) << "In Barrel? = " << barrel;
205 
206  if ( quality <= theL1MinQuality ) continue;
207  LogDebug(metname) << "quality = "<< quality;
208 
209  // Update the services
210  theService->update(iSetup);
211 
212  const DetLayer *detLayer = nullptr;
213  float radius = 0.;
214 
215  CLHEP::Hep3Vector vec(0.,1.,0.);
216  vec.setTheta(theta);
217  vec.setPhi(phi);
218 
219  DetId theid;
220  // Get the det layer on which the state should be put
221  if ( barrel ){
222  LogDebug(metname) << "The seed is in the barrel";
223 
224  // MB2
225  theid = DTChamberId(0,2,0);
226  detLayer = theService->detLayerGeometry()->idToLayer(theid);
227  LogDebug(metname) << "L2 Layer: " << debug.dumpLayer(detLayer);
228 
229  const BoundSurface* sur = &(detLayer->surface());
230  const BoundCylinder* bc = dynamic_cast<const BoundCylinder*>(sur);
231 
232  radius = fabs(bc->radius()/sin(theta));
233 
234  LogDebug(metname) << "radius "<<radius;
235 
236  if ( pt < theMinPtBarrel ) pt = theMinPtBarrel;
237  }
238  else {
239  LogDebug(metname) << "The seed is in the endcap";
240 
241  // ME2
242  theid = theta < Geom::pi()/2. ? CSCDetId(1,2,0,0,0) : CSCDetId(2,2,0,0,0);
243 
244  detLayer = theService->detLayerGeometry()->idToLayer(theid);
245  LogDebug(metname) << "L2 Layer: " << debug.dumpLayer(detLayer);
246 
247  radius = fabs(detLayer->position().z()/cos(theta));
248 
249  if( pt < theMinPtEndcap) pt = theMinPtEndcap;
250  }
251 
252  vec.setMag(radius);
253 
254  GlobalPoint pos(vec.x(),vec.y(),vec.z());
255 
256  GlobalVector mom(pt*cos(phi), pt*sin(phi), pt*cos(theta)/sin(theta));
257 
258  GlobalTrajectoryParameters param(pos,mom,charge,&*theService->magneticField());
260 
261  mat[0][0] = (0.25/pt)*(0.25/pt); // sigma^2(charge/abs_momentum)
262  if ( !barrel ) mat[0][0] = (0.4/pt)*(0.4/pt);
263 
264  //Assign q/pt = 0 +- 1/pt if charge has been declared invalid
265  if (!valid_charge) mat[0][0] = (1./pt)*(1./pt);
266 
267  mat[1][1] = 0.05*0.05; // sigma^2(lambda)
268  mat[2][2] = 0.2*0.2; // sigma^2(phi)
269  mat[3][3] = 20.*20.; // sigma^2(x_transverse))
270  mat[4][4] = 20.*20.; // sigma^2(y_transverse))
271 
273 
274  const FreeTrajectoryState state(param,error);
275 
276  LogDebug(metname) << "Free trajectory State from the parameters";
277  LogDebug(metname) << debug.dumpFTS(state);
278 
279  // Propagate the state on the MB2/ME2 surface
280  TrajectoryStateOnSurface tsos = theService->propagator(thePropagatorName)->propagate(state, detLayer->surface());
281 
282  LogDebug(metname) << "State after the propagation on the layer";
283  LogDebug(metname) << debug.dumpLayer(detLayer);
284  LogDebug(metname) << debug.dumpTSOS(tsos);
285 
286  double dRcone = matchingDR[0];
287  if ( fabs(eta) < etaBins.back() ){
288  std::vector<double>::iterator lowEdge = std::upper_bound (etaBins.begin(), etaBins.end(), fabs(eta));
289  dRcone = matchingDR.at( lowEdge - etaBins.begin() - 1);
290  }
291 
292  if (tsos.isValid()) {
293 
295 
296  if(useOfflineSeed && ( !valid_charge || charge == 0) ) {
297 
298  const TrajectorySeed *assoOffseed =
299  associateOfflineSeedToL1(offlineSeedHandle, offlineSeedMap, tsos, dRcone );
300 
301  if(assoOffseed!=nullptr) {
302  PTrajectoryStateOnDet const & seedTSOS = assoOffseed->startingState();
304  tsci = assoOffseed->recHits().first,
305  tscie = assoOffseed->recHits().second;
306  for(; tsci!=tscie; ++tsci) {
307  container.push_back(*tsci);
308  }
309  output->push_back(L2MuonTrajectorySeed(seedTSOS,container,alongMomentum,
310  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
311  }
312  else {
313  if(useUnassociatedL1) {
314  // convert the TSOS into a PTSOD
315  PTrajectoryStateOnDet const & seedTSOS = trajectoryStateTransform::persistentState( tsos, theid.rawId());
316  output->push_back(L2MuonTrajectorySeed(seedTSOS,container,alongMomentum,
317  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
318  }
319  }
320  }
321  else if (useOfflineSeed && valid_charge){
322  // Get the compatible dets on the layer
323  std::vector< pair<const GeomDet*,TrajectoryStateOnSurface> >
324  detsWithStates = detLayer->compatibleDets(tsos,
325  *theService->propagator(thePropagatorName),
326  *theEstimator);
327 
328  if (detsWithStates.empty() && barrel ) {
329  // Fallback solution using ME2, try again to propagate but using ME2 as reference
330  DetId fallback_id;
331  theta < Geom::pi()/2. ? fallback_id = CSCDetId(1,2,0,0,0) : fallback_id = CSCDetId(2,2,0,0,0);
332  const DetLayer* ME2DetLayer = theService->detLayerGeometry()->idToLayer(fallback_id);
333 
334  tsos = theService->propagator(thePropagatorName)->propagate(state, ME2DetLayer->surface());
335  detsWithStates = ME2DetLayer->compatibleDets(tsos,
336  *theService->propagator(thePropagatorName),
337  *theEstimator);
338  }
339 
340  if (!detsWithStates.empty()){
341 
342  TrajectoryStateOnSurface newTSOS = detsWithStates.front().second;
343  const GeomDet *newTSOSDet = detsWithStates.front().first;
344 
345  LogDebug(metname) << "Most compatible det";
346  LogDebug(metname) << debug.dumpMuonId(newTSOSDet->geographicalId());
347 
348  if (newTSOS.isValid()){
349 
350  LogDebug(metname) << "pos: (r=" << newTSOS.globalPosition().mag() << ", phi="
351  << newTSOS.globalPosition().phi() << ", eta=" << newTSOS.globalPosition().eta() << ")";
352  LogDebug(metname) << "mom: (q*pt=" << newTSOS.charge()*newTSOS.globalMomentum().perp() << ", phi="
353  << newTSOS.globalMomentum().phi() << ", eta=" << newTSOS.globalMomentum().eta() << ")";
354 
355  const TrajectorySeed *assoOffseed =
356  associateOfflineSeedToL1(offlineSeedHandle, offlineSeedMap, newTSOS, dRcone);
357 
358  if(assoOffseed!=nullptr) {
359  PTrajectoryStateOnDet const & seedTSOS = assoOffseed->startingState();
361  tsci = assoOffseed->recHits().first,
362  tscie = assoOffseed->recHits().second;
363  for(; tsci!=tscie; ++tsci) {
364  container.push_back(*tsci);
365  }
366  output->push_back(L2MuonTrajectorySeed(seedTSOS,container,alongMomentum,
367  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
368  }
369  else {
370  if(useUnassociatedL1) {
371  // convert the TSOS into a PTSOD
372  PTrajectoryStateOnDet const & seedTSOS = trajectoryStateTransform::persistentState( newTSOS,newTSOSDet->geographicalId().rawId());
373  output->push_back(L2MuonTrajectorySeed(seedTSOS,container,alongMomentum,
374  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
375  }
376  }
377  }
378  }
379  }
380  else {
381  // convert the TSOS into a PTSOD
382  PTrajectoryStateOnDet const & seedTSOS = trajectoryStateTransform::persistentState( tsos, theid.rawId());
383  output->push_back(L2MuonTrajectorySeed(seedTSOS,container,alongMomentum,
384  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
385  }
386  }
387  }
388  }
389 
390  } // End of matchType 0
391 
392  //--- matchType > 0 : Updated logics
393  else if(matchType > 0) {
394 
395  unsigned int nMuColl = muColl->size();
396 
397  vector< vector<double> > dRmtx;
398  vector< vector<const TrajectorySeed *> > selOffseeds;
399 
400  edm::Handle<edm::View<TrajectorySeed> > offlineSeedHandle;
401  if(useOfflineSeed) {
402  iEvent.getByToken(offlineSeedToken_, offlineSeedHandle);
403  unsigned int nOfflineSeed = offlineSeedHandle->size();
404  LogDebug(metname) << "Number of offline seeds " << nOfflineSeed << endl;
405 
406  // Initialize dRmtx and selOffseeds
407  dRmtx = vector< vector<double> >(nMuColl, vector<double>(nOfflineSeed, 999.0));
408  selOffseeds = vector< vector <const TrajectorySeed *> >(nMuColl, vector<const TrajectorySeed *>(nOfflineSeed, nullptr));
409  }
410 
411  // At least one L1 muons are associated with offSeed
412  bool isAsso = false;
413 
414  //--- Fill dR matrix
415  for (int ibx = muColl->getFirstBX(); ibx <= muColl->getLastBX(); ++ibx) {
416  if (centralBxOnly_ && (ibx != 0)) continue;
417  for (auto it = muColl->begin(ibx); it != muColl->end(ibx); it++){
418 
419  //Position of given L1mu
420  unsigned int imu = distance(muColl->begin(muColl->getFirstBX()),it);
421 
422  unsigned int quality = it->hwQual();
423  int valid_charge = it->hwChargeValid();
424 
425  float pt = it->pt();
426  float eta = it->eta();
427  float theta = 2*atan(exp(-eta));
428  float phi = it->phi();
429  int charge = it->charge();
430  // Set charge=0 for the time being if the valid charge bit is zero
431  if (!valid_charge) charge = 0;
432 
433  // link number indices of the optical fibres that connect the uGMT with the track finders
434  //EMTF+ : 36-41, OMTF+ : 42-47, BMTF : 48-59, OMTF- : 60-65, EMTF- : 66-71
435  int link = 36 + (int)(it -> tfMuonIndex() / 3.);
436  bool barrel = true;
437  if ( (link >= 36 && link <= 41) || (link >= 66 && link <= 71)) barrel = false;
438 
439  if ( pt < theL1MinPt || fabs(eta) > theL1MaxEta ) continue;
440 
441  LogDebug(metname) << "New L2 Muon Seed" ;
442  LogDebug(metname) << "Pt = " << pt << " GeV/c";
443  LogDebug(metname) << "eta = " << eta;
444  LogDebug(metname) << "theta = " << theta << " rad";
445  LogDebug(metname) << "phi = " << phi << " rad";
446  LogDebug(metname) << "charge = " << charge;
447  LogDebug(metname) << "In Barrel? = " << barrel;
448 
449  if ( quality <= theL1MinQuality ) continue;
450  LogDebug(metname) << "quality = "<< quality;
451 
452  // Update the services
453  theService->update(iSetup);
454 
455  const DetLayer *detLayer = nullptr;
456  float radius = 0.;
457 
458  CLHEP::Hep3Vector vec(0.,1.,0.);
459  vec.setTheta(theta);
460  vec.setPhi(phi);
461 
462  DetId theid;
463  // Get the det layer on which the state should be put
464  if ( barrel ){
465  LogDebug(metname) << "The seed is in the barrel";
466 
467  // MB2
468  theid = DTChamberId(0,2,0);
469  detLayer = theService->detLayerGeometry()->idToLayer(theid);
470  LogDebug(metname) << "L2 Layer: " << debug.dumpLayer(detLayer);
471 
472  const BoundSurface* sur = &(detLayer->surface());
473  const BoundCylinder* bc = dynamic_cast<const BoundCylinder*>(sur);
474 
475  radius = fabs(bc->radius()/sin(theta));
476 
477  LogDebug(metname) << "radius "<<radius;
478 
479  if ( pt < theMinPtBarrel ) pt = theMinPtBarrel;
480  }
481  else {
482  LogDebug(metname) << "The seed is in the endcap";
483 
484  // ME2
485  theid = theta < Geom::pi()/2. ? CSCDetId(1,2,0,0,0) : CSCDetId(2,2,0,0,0);
486 
487  detLayer = theService->detLayerGeometry()->idToLayer(theid);
488  LogDebug(metname) << "L2 Layer: " << debug.dumpLayer(detLayer);
489 
490  radius = fabs(detLayer->position().z()/cos(theta));
491 
492  if( pt < theMinPtEndcap) pt = theMinPtEndcap;
493  }
494 
495  vec.setMag(radius);
496 
497  GlobalPoint pos(vec.x(),vec.y(),vec.z());
498 
499  GlobalVector mom(pt*cos(phi), pt*sin(phi), pt*cos(theta)/sin(theta));
500 
501  GlobalTrajectoryParameters param(pos,mom,charge,&*theService->magneticField());
503 
504  mat[0][0] = (0.25/pt)*(0.25/pt); // sigma^2(charge/abs_momentum)
505  if ( !barrel ) mat[0][0] = (0.4/pt)*(0.4/pt);
506 
507  //Assign q/pt = 0 +- 1/pt if charge has been declared invalid
508  if (!valid_charge) mat[0][0] = (1./pt)*(1./pt);
509 
510  mat[1][1] = 0.05*0.05; // sigma^2(lambda)
511  mat[2][2] = 0.2*0.2; // sigma^2(phi)
512  mat[3][3] = 20.*20.; // sigma^2(x_transverse))
513  mat[4][4] = 20.*20.; // sigma^2(y_transverse))
514 
516 
517  const FreeTrajectoryState state(param,error);
518 
519  LogDebug(metname) << "Free trajectory State from the parameters";
520  LogDebug(metname) << debug.dumpFTS(state);
521 
522  // Propagate the state on the MB2/ME2 surface
523  TrajectoryStateOnSurface tsos = theService->propagator(thePropagatorName)->propagate(state, detLayer->surface());
524 
525  LogDebug(metname) << "State after the propagation on the layer";
526  LogDebug(metname) << debug.dumpLayer(detLayer);
527  LogDebug(metname) << debug.dumpTSOS(tsos);
528 
529  double dRcone = matchingDR[0];
530  if ( fabs(eta) < etaBins.back() ){
531  std::vector<double>::iterator lowEdge = std::upper_bound (etaBins.begin(), etaBins.end(), fabs(eta));
532  dRcone = matchingDR.at( lowEdge - etaBins.begin() - 1);
533  }
534 
535  if (tsos.isValid()) {
536 
538 
539  if(useOfflineSeed) {
540 
541  if( ( !valid_charge || charge == 0 ) ) {
542 
543  bool isAssoOffseed = isAssociateOfflineSeedToL1(offlineSeedHandle, dRmtx, tsos, imu, selOffseeds, dRcone );
544 
545  if(isAssoOffseed) {
546  isAsso = true;
547  }
548 
549  // Using old way
550  else {
551  if(useUnassociatedL1) {
552  // convert the TSOS into a PTSOD
553  PTrajectoryStateOnDet const & seedTSOS = trajectoryStateTransform::persistentState( tsos, theid.rawId());
554  output->push_back(L2MuonTrajectorySeed(seedTSOS,container,alongMomentum,
555  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
556  }
557  }
558 
559  }
560 
561  else if( valid_charge ) {
562 
563  // Get the compatible dets on the layer
564  std::vector< pair<const GeomDet*,TrajectoryStateOnSurface> >
565  detsWithStates = detLayer->compatibleDets(tsos,
566  *theService->propagator(thePropagatorName),
567  *theEstimator);
568 
569  if (detsWithStates.empty() && barrel ) {
570  // Fallback solution using ME2, try again to propagate but using ME2 as reference
571  DetId fallback_id;
572  theta < Geom::pi()/2. ? fallback_id = CSCDetId(1,2,0,0,0) : fallback_id = CSCDetId(2,2,0,0,0);
573  const DetLayer* ME2DetLayer = theService->detLayerGeometry()->idToLayer(fallback_id);
574 
575  tsos = theService->propagator(thePropagatorName)->propagate(state, ME2DetLayer->surface());
576  detsWithStates = ME2DetLayer->compatibleDets(tsos,
577  *theService->propagator(thePropagatorName),
578  *theEstimator);
579  }
580 
581  if (!detsWithStates.empty()){
582 
583  TrajectoryStateOnSurface newTSOS = detsWithStates.front().second;
584  const GeomDet *newTSOSDet = detsWithStates.front().first;
585 
586  LogDebug(metname) << "Most compatible det";
587  LogDebug(metname) << debug.dumpMuonId(newTSOSDet->geographicalId());
588 
589  if (newTSOS.isValid()){
590 
591  LogDebug(metname) << "pos: (r=" << newTSOS.globalPosition().mag() << ", phi="
592  << newTSOS.globalPosition().phi() << ", eta=" << newTSOS.globalPosition().eta() << ")";
593  LogDebug(metname) << "mom: (q*pt=" << newTSOS.charge()*newTSOS.globalMomentum().perp() << ", phi="
594  << newTSOS.globalMomentum().phi() << ", eta=" << newTSOS.globalMomentum().eta() << ")";
595 
596  bool isAssoOffseed = isAssociateOfflineSeedToL1(offlineSeedHandle, dRmtx, newTSOS, imu, selOffseeds, dRcone );
597 
598  if(isAssoOffseed) {
599  isAsso = true;
600  }
601 
602  // Using old way
603  else {
604  if(useUnassociatedL1) {
605  // convert the TSOS into a PTSOD
606  PTrajectoryStateOnDet const & seedTSOS = trajectoryStateTransform::persistentState( newTSOS,newTSOSDet->geographicalId().rawId());
607  output->push_back(L2MuonTrajectorySeed(seedTSOS,container,alongMomentum,
608  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
609  }
610  }
611 
612  }
613  }
614  }
615  } // useOfflineSeed
616 
617  else {
618  // convert the TSOS into a PTSOD
619  PTrajectoryStateOnDet const & seedTSOS = trajectoryStateTransform::persistentState( tsos, theid.rawId());
620  output->push_back(L2MuonTrajectorySeed(seedTSOS,container,alongMomentum,
621  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
622  }
623 
624  }
625  }
626  }
627 
628  // MatchType : 0 Old matching, 1 L1 Order(1to1), 2 Min dR(1to1), 3 Higher Q(1to1), 4 All matched L1
629  if(useOfflineSeed && isAsso) {
630  unsigned int nOfflineSeed1 = offlineSeedHandle->size();
631  unsigned int nL1;
632  unsigned int i, j; // for the matrix element
633 
634  if(matchType==1) {
635  vector<bool> removed_col = vector<bool>(nOfflineSeed1, false);
636 
637  for(nL1=0; nL1 < nMuColl; ++nL1) {
638  double tempDR = 99.;
639  unsigned int theOffs = 0;
640 
641  for(j=0; j<nOfflineSeed1; ++j) {
642  if(removed_col[j]) continue;
643  if( tempDR > dRmtx[nL1][j] ) {
644  tempDR = dRmtx[nL1][j];
645  theOffs = j;
646  }
647  }
648 
649  auto it = muColl->begin(muColl->getFirstBX()) + nL1;
650 
651  double newDRcone = matchingDR[0];
652  if ( fabs(it->eta()) < etaBins.back() ){
653  std::vector<double>::iterator lowEdge = std::upper_bound (etaBins.begin(), etaBins.end(), fabs(it->eta()));
654  newDRcone = matchingDR.at( lowEdge - etaBins.begin() - 1);
655  }
656 
657  if( !(tempDR < newDRcone) ) continue;
658 
659  // Remove column for given offSeed
660  removed_col[theOffs] = true;
661 
662  if( selOffseeds[nL1][theOffs] != nullptr ) {
663  //put given L1mu and offSeed to output
664  edm::OwnVector<TrackingRecHit> newContainer;
665 
666  PTrajectoryStateOnDet const & seedTSOS = selOffseeds[nL1][theOffs] ->startingState();
668  tsci = selOffseeds[nL1][theOffs]->recHits().first,
669  tscie = selOffseeds[nL1][theOffs]->recHits().second;
670  for(; tsci!=tscie; ++tsci) {
671  newContainer.push_back(*tsci);
672  }
673  output->push_back(L2MuonTrajectorySeed(seedTSOS,newContainer,alongMomentum,
674  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
675  }
676  }
677  }
678 
679  else if(matchType==2) {
680  vector<bool> removed_row = vector<bool>(nMuColl, false);
681  vector<bool> removed_col = vector<bool>(nOfflineSeed1, false);
682 
683  for(nL1=0; nL1 < nMuColl; ++nL1) {
684  double tempDR = 99.;
685  unsigned int theL1 = 0;
686  unsigned int theOffs = 0;
687 
688  for(i=0; i<nMuColl; ++i) {
689  if(removed_row[i]) continue;
690  for(j=0; j<nOfflineSeed1; ++j) {
691  if(removed_col[j]) continue;
692  if(tempDR > dRmtx[i][j]) {
693  tempDR = dRmtx[i][j];
694  theL1 = i;
695  theOffs = j;
696  }
697  }
698  }
699 
700  auto it = muColl->begin(muColl->getFirstBX()) + theL1;
701 
702  double newDRcone = matchingDR[0];
703  if ( fabs(it->eta()) < etaBins.back() ){
704  std::vector<double>::iterator lowEdge = std::upper_bound (etaBins.begin(), etaBins.end(), fabs(it->eta()));
705  newDRcone = matchingDR.at( lowEdge - etaBins.begin() - 1);
706  }
707 
708  if( !(tempDR < newDRcone) ) continue;
709 
710  // Remove row and column for given (L1mu, offSeed)
711  removed_col[theOffs] = true;
712  removed_row[theL1] = true;
713 
714  if( selOffseeds[theL1][theOffs] != nullptr ) {
715  //put given L1mu and offSeed to output
716  edm::OwnVector<TrackingRecHit> newContainer;
717 
718  PTrajectoryStateOnDet const & seedTSOS = selOffseeds[theL1][theOffs] ->startingState();
720  tsci = selOffseeds[theL1][theOffs]->recHits().first,
721  tscie = selOffseeds[theL1][theOffs]->recHits().second;
722  for(; tsci!=tscie; ++tsci) {
723  newContainer.push_back(*tsci);
724  }
725  output->push_back(L2MuonTrajectorySeed(seedTSOS,newContainer,alongMomentum,
726  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
727  }
728  }
729  }
730 
731  else if(matchType==3) {
732  vector<bool> removed_row = vector<bool>(nMuColl, false);
733  vector<bool> removed_col = vector<bool>(nOfflineSeed1, false);
734 
735  for(nL1=0; nL1 < nMuColl; ++nL1) {
736  double tempDR = 99.;
737  unsigned int theL1 = 0;
738  unsigned int theOffs = 0;
739  auto theit = muColl->begin(muColl->getFirstBX());
740 
741  // L1Q > 10 (L1Q = 12)
742  for(i=0; i<nMuColl; ++i) {
743  if(removed_row[i]) continue;
744  theit = muColl->begin(muColl->getFirstBX()) + i;
745  if (theit->hwQual() > 10) {
746  for(j=0; j<nOfflineSeed1; ++j) {
747  if(removed_col[j]) continue;
748  if(tempDR > dRmtx[i][j]) {
749  tempDR = dRmtx[i][j];
750  theL1 = i;
751  theOffs = j;
752  }
753  }
754  }
755  }
756 
757  // 6 < L1Q <= 10 (L1Q = 8)
758  if (tempDR == 99.) {
759  for(i=0; i<nMuColl; ++i) {
760  if(removed_row[i]) continue;
761  theit = muColl->begin(muColl->getFirstBX()) + i;
762  if ( (theit->hwQual() <= 10) && (theit->hwQual() > 6) ) {
763  for(j=0; j<nOfflineSeed1; ++j) {
764  if(removed_col[j]) continue;
765  if(tempDR > dRmtx[i][j]) {
766  tempDR = dRmtx[i][j];
767  theL1 = i;
768  theOffs = j;
769  }
770  }
771  }
772  }
773  }
774 
775  // L1Q <= 6 (L1Q = 4)
776  if (tempDR == 99.) {
777  for(i=0; i<nMuColl; ++i) {
778  if(removed_row[i]) continue;
779  theit = muColl->begin(muColl->getFirstBX()) + i;
780  if (theit->hwQual() <= 6) {
781  for(j=0; j<nOfflineSeed1; ++j) {
782  if(removed_col[j]) continue;
783  if(tempDR > dRmtx[i][j]) {
784  tempDR = dRmtx[i][j];
785  theL1 = i;
786  theOffs = j;
787  }
788  }
789  }
790  }
791  }
792 
793  auto it = muColl->begin(muColl->getFirstBX()) + theL1;
794 
795  double newDRcone = matchingDR[0];
796  if ( fabs(it->eta()) < etaBins.back() ){
797  std::vector<double>::iterator lowEdge = std::upper_bound (etaBins.begin(), etaBins.end(), fabs(it->eta()));
798  newDRcone = matchingDR.at( lowEdge - etaBins.begin() - 1);
799  }
800 
801  if( !(tempDR < newDRcone) ) continue;
802 
803  // Remove row and column for given (L1mu, offSeed)
804  removed_col[theOffs] = true;
805  removed_row[theL1] = true;
806 
807  if( selOffseeds[theL1][theOffs] != nullptr ) {
808  //put given L1mu and offSeed to output
809  edm::OwnVector<TrackingRecHit> newContainer;
810 
811  PTrajectoryStateOnDet const & seedTSOS = selOffseeds[theL1][theOffs] ->startingState();
813  tsci = selOffseeds[theL1][theOffs]->recHits().first,
814  tscie = selOffseeds[theL1][theOffs]->recHits().second;
815  for(; tsci!=tscie; ++tsci) {
816  newContainer.push_back(*tsci);
817  }
818  output->push_back(L2MuonTrajectorySeed(seedTSOS,newContainer,alongMomentum,
819  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
820  }
821  }
822  }
823 
824  else if(matchType==4) {
825 
826  for(i=0; i<nMuColl; ++i) {
827 
828  auto it = muColl->begin(muColl->getFirstBX()) + i;
829 
830  double tempDR = 99.;
831  unsigned int theOffs = 0;
832 
833  double newDRcone = matchingDR[0];
834  if ( fabs(it->eta()) < etaBins.back() ){
835  std::vector<double>::iterator lowEdge = std::upper_bound (etaBins.begin(), etaBins.end(), fabs(it->eta()));
836  newDRcone = matchingDR.at( lowEdge - etaBins.begin() - 1);
837  }
838 
839  for(j=0; j<nOfflineSeed1; ++j) {
840  if( tempDR > dRmtx[i][j] ) {
841  tempDR = dRmtx[i][j];
842  theOffs = j;
843  }
844  }
845 
846  if( !(tempDR < newDRcone) ) continue;
847 
848  if( selOffseeds[i][theOffs] != nullptr ) {
849  //put given L1mu and offSeed to output
850  edm::OwnVector<TrackingRecHit> newContainer;
851 
852  PTrajectoryStateOnDet const & seedTSOS = selOffseeds[i][theOffs] ->startingState();
854  tsci = selOffseeds[i][theOffs]->recHits().first,
855  tscie = selOffseeds[i][theOffs]->recHits().second;
856  for(; tsci!=tscie; ++tsci) {
857  newContainer.push_back(*tsci);
858  }
859  output->push_back(L2MuonTrajectorySeed(seedTSOS,newContainer,alongMomentum,
860  MuonRef(muColl, distance(muColl->begin(muColl->getFirstBX()),it) )));
861  }
862  }
863  }
864 
865  } // useOfflineSeed && isAsso
866 
867  } // matchType > 0
868 
869  //--- SortType 1 : by L1 pT
870  if(sortType == 1) {
871  sort(output->begin(),output->end(),sortByL1Pt);
872  }
873 
874  //--- SortType 2 : by L1 quality and pT
875  else if(sortType == 2) {
876  sort(output->begin(),output->end(),sortByL1QandPt);
877  }
878 
879 
880  iEvent.put(std::move(output));
881 }
#define LogDebug(id)
edm::EDGetTokenT< edm::View< TrajectorySeed > > offlineSeedToken_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
T perp() const
Definition: PV3DBase.h:72
bool centralBxOnly_
use central bx only muons
std::string dumpLayer(const DetLayer *layer) const
const TrajectorySeed * associateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed > > &, std::vector< int > &, TrajectoryStateOnSurface &, double)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
bool sortByL1Pt(L2MuonTrajectorySeed &A, L2MuonTrajectorySeed &B)
const std::string metname
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Geom::Theta< T > theta() const
GlobalPoint globalPosition() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
edm::Ref< MuonBxCollection > MuonRef
Definition: Muon.h:13
std::string dumpMuonId(const DetId &id) const
std::string dumpFTS(const FreeTrajectoryState &fts) const
std::string dumpTSOS(const TrajectoryStateOnSurface &tsos) const
void push_back(D *&d)
Definition: OwnVector.h:290
T mag() const
Definition: PV3DBase.h:67
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
recHitContainer::const_iterator const_iterator
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool isAssociateOfflineSeedToL1(edm::Handle< edm::View< TrajectorySeed > > &, std::vector< std::vector< double > > &, TrajectoryStateOnSurface &, unsigned int, std::vector< std::vector< const TrajectorySeed * > > &, double)
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
bool sortByL1QandPt(L2MuonTrajectorySeed &A, L2MuonTrajectorySeed &B)
Definition: DetId.h:18
PTrajectoryStateOnDet const & startingState() const
#define debug
Definition: HDRShower.cc:19
virtual const Surface::PositionType & position() const
Returns position of the surface.
range recHits() const
edm::EDGetTokenT< l1t::MuonBxCollection > muCollToken_
T eta() const
Definition: PV3DBase.h:76
GlobalVector globalMomentum() const
constexpr double pi()
Definition: Pi.h:31
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool L2MuonSeedGeneratorFromL1T::centralBxOnly_
private

use central bx only muons

Definition at line 82 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

std::vector<double> L2MuonSeedGeneratorFromL1T::etaBins
private

Definition at line 79 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

std::vector<double> L2MuonSeedGeneratorFromL1T::matchingDR
private

Definition at line 78 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

const unsigned L2MuonSeedGeneratorFromL1T::matchType
private

Definition at line 83 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

edm::EDGetTokenT<l1t::MuonBxCollection> L2MuonSeedGeneratorFromL1T::muCollToken_
private

Definition at line 68 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

edm::EDGetTokenT<edm::View<TrajectorySeed> > L2MuonSeedGeneratorFromL1T::offlineSeedToken_
private

Definition at line 69 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

const unsigned L2MuonSeedGeneratorFromL1T::sortType
private

Definition at line 84 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

MeasurementEstimator* L2MuonSeedGeneratorFromL1T::theEstimator
private
edm::InputTag L2MuonSeedGeneratorFromL1T::theL1GMTReadoutCollection
private

Definition at line 64 of file L2MuonSeedGeneratorFromL1T.h.

const double L2MuonSeedGeneratorFromL1T::theL1MaxEta
private

Definition at line 72 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

const double L2MuonSeedGeneratorFromL1T::theL1MinPt
private

Definition at line 71 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

const unsigned L2MuonSeedGeneratorFromL1T::theL1MinQuality
private

Definition at line 73 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

const double L2MuonSeedGeneratorFromL1T::theMinPtBarrel
private

Definition at line 74 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

const double L2MuonSeedGeneratorFromL1T::theMinPtEndcap
private

Definition at line 75 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().

edm::InputTag L2MuonSeedGeneratorFromL1T::theOfflineSeedLabel
private

Definition at line 65 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T().

std::string L2MuonSeedGeneratorFromL1T::thePropagatorName
private
MuonServiceProxy* L2MuonSeedGeneratorFromL1T::theService
private

the event setup proxy, it takes care the services update

Definition at line 87 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by associateOfflineSeedToL1(), isAssociateOfflineSeedToL1(), L2MuonSeedGeneratorFromL1T(), produce(), and ~L2MuonSeedGeneratorFromL1T().

edm::InputTag L2MuonSeedGeneratorFromL1T::theSource
private

Definition at line 63 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T().

const bool L2MuonSeedGeneratorFromL1T::useOfflineSeed
private

Definition at line 76 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by L2MuonSeedGeneratorFromL1T(), and produce().

const bool L2MuonSeedGeneratorFromL1T::useUnassociatedL1
private

Definition at line 77 of file L2MuonSeedGeneratorFromL1T.h.

Referenced by produce().