CMS 3D CMS Logo

L1TMuonLegacyConverter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1TMuonLegacyConverter
4 // Class: L1TMuonLegacyConverter
5 //
8 //
9 // Original Author: Bortignon Pierluigi
10 // Created: Sun March 6 EDT 2016
11 //
12 //
13 
14 // system include files
15 #include <memory>
16 
17 // user include files
19 
22 
26 
29 
37 
42 
44 
45 // #include "FWCore/Utilities/interface/EDMException.h"
46 
47 //
48 // class decleration
49 //
50 
51 //
52 // constants, enums and typedefs
53 //
54 using namespace l1t;
55 
56 //
57 // static data member definitions
58 //
59 
60 double const L1TMuonLegacyConverter::muonMassGeV_ = 0.105658369; // PDG06
61 
62 //
63 // constructors and destructor
64 //
66  using namespace l1extra;
67 
68  // moving inputTag here
69  muonSource_InputTag = iConfig.getParameter<edm::InputTag>("muonSource");
70  produceMuonParticles_ = iConfig.getUntrackedParameter<bool>("produceMuonParticles");
71  centralBxOnly_ = iConfig.getUntrackedParameter<bool>("centralBxOnly");
72 
73  produces<MuonBxCollection>("imdMuonsLegacy");
74  muonSource_InputToken = consumes<L1MuGMTReadoutCollection>(muonSource_InputTag);
75 }
76 
78  // do anything here that needs to be done at desctruction time
79  // (e.g. close files, deallocate resources etc.)
80 }
81 
82 //
83 // member functions
84 //
85 
86 // ------------ method called to produce the data ------------
88  using namespace edm;
89  using namespace l1extra;
90  using namespace std;
91 
92  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93  // ~~~~~~~~~~~~~~~~~~~~ Muons ~~~~~~~~~~~~~~~~~~~~
94  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95 
96  std::unique_ptr<MuonBxCollection> imdMuonsLegacy(new MuonBxCollection());
97 
98  LogDebug("L1TMuonLegacyConverter") << "\nWarning: L1MuGMTReadoutCollection with " << muonSource_InputTag
99  << "\nrequested in configuration, but not found in the event." << std::endl;
100 
101  if (produceMuonParticles_) {
103  iSetup.get<L1MuTriggerScalesRcd>().get(muScales);
104 
106  iSetup.get<L1MuTriggerPtScaleRcd>().get(muPtScale);
107 
108  Handle<L1MuGMTReadoutCollection> simMuCollection;
109  iEvent.getByToken(muonSource_InputToken, simMuCollection);
110 
111  vector<L1MuGMTExtendedCand> simMuCands;
112 
113  if (!simMuCollection.isValid()) {
114  LogDebug("L1TMuonLegacyConverter") << "\nWarning: L1MuGMTReadoutCollection with " << muonSource_InputTag
115  << "\nrequested in configuration, but not found in the event." << std::endl;
116  } else {
117  if (centralBxOnly_) {
118  // Get GMT candidates from central bunch crossing only
119  simMuCands = simMuCollection->getRecord().getGMTCands();
120  } else {
121  // Get GMT candidates from all bunch crossings
122  vector<L1MuGMTReadoutRecord> records = simMuCollection->getRecords();
123  vector<L1MuGMTReadoutRecord>::const_iterator rItr = records.begin();
124  vector<L1MuGMTReadoutRecord>::const_iterator rEnd = records.end();
125 
126  for (; rItr != rEnd; ++rItr) {
127  vector<L1MuGMTExtendedCand> tmpCands = rItr->getGMTCands();
128 
129  simMuCands.insert(simMuCands.end(), tmpCands.begin(), tmpCands.end());
130  }
131  }
132 
133  vector<L1MuGMTExtendedCand>::const_iterator muItr = simMuCands.begin();
134  vector<L1MuGMTExtendedCand>::const_iterator muEnd = simMuCands.end();
135  for (int i = 0; muItr != muEnd; ++muItr, ++i) {
136  if (!muItr->empty()) {
137  // keep x and y components non-zero and protect against roundoff.
138  double pt = muPtScale->getPtScale()->getLowEdge(muItr->ptIndex()) + 1.e-6;
139  std::cout << "pt from muPtScale = " << pt << std::endl;
140  double eta = muScales->getGMTEtaScale()->getCenter(muItr->etaIndex());
141  double phi = muScales->getPhiScale()->getLowEdge(muItr->phiIndex());
142 
143  math::PtEtaPhiMLorentzVector p4(pt, eta, phi, muonMassGeV_);
144 
145  Muon outMu{p4,
146  (int)0,
147  (int)0,
148  (int)0,
149  (int)muItr->quality(),
150  (int)muItr->charge(),
151  (int)muItr->charge_valid(),
152  (int)muItr->isol(),
153  (int)0,
154  (int)0,
155  true,
156  (int)0,
157  (int)0,
158  (int)0,
159  (int)muItr->rank()};
160  imdMuonsLegacy->push_back(muItr->bx(), outMu);
161  }
162  }
163  }
164  }
165 
166  iEvent.put(std::move(imdMuonsLegacy), "imdMuonsLegacy");
167 
168 } // closing produce
169 
170 //define this as a plug-in
L1EmEtScaleRcd.h
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
L1MuTriggerScales::getGMTEtaScale
const L1MuScale * getGMTEtaScale() const
get the GMT eta scale
Definition: L1MuTriggerScales.h:169
ESHandle.h
L1GctJetFinderParamsRcd.h
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
L1MuTriggerPtScaleRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
l1t::MuonBxCollection
BXVector< Muon > MuonBxCollection
Definition: Muon.h:11
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1TMuonLegacyConverter::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: L1TMuonLegacyConverter.cc:87
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
L1MuTriggerScalesRcd.h
L1GctJetFinderParams.h
edm::Handle
Definition: AssociativeIterator.h:50
L1TMuonLegacyConverter
Definition: L1TMuonLegacyConverter.h:45
Muon
Definition: Muon.py:1
L1TMuonLegacyConverter::L1TMuonLegacyConverter
L1TMuonLegacyConverter(const edm::ParameterSet &)
Definition: L1TMuonLegacyConverter.cc:65
L1HtMissScaleRcd.h
L1MuTriggerScales::getPhiScale
const L1MuScale * getPhiScale() const
get the phi scale
Definition: L1MuTriggerScales.h:175
MakerMacros.h
L1TMuonLegacyConverter::~L1TMuonLegacyConverter
~L1TMuonLegacyConverter() override
Definition: L1TMuonLegacyConverter.cc:77
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PVValHelper::eta
Definition: PVValidationHelpers.h:70
OrphanHandle.h
edm::ESHandle
Definition: DTSurvey.h:22
L1TMuonLegacyConverter.h
L1MuScale::getLowEdge
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
L1MuGMTReadoutCollection::getRecords
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
Definition: L1MuGMTReadoutCollection.h:52
l1t
delete x;
Definition: CaloConfig.h:22
L1MuTriggerPtScale::getPtScale
const L1MuScale * getPtScale() const
get the Pt scale
Definition: L1MuTriggerPtScale.h:59
L1CaloGeometryRecord.h
L1MuTriggerPtScale.h
L1MuGMTReadoutCollection::getRecord
L1MuGMTReadoutRecord const & getRecord(int bx=0) const
Definition: L1MuGMTReadoutCollection.h:55
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
L1MuTriggerScales.h
p4
double p4[4]
Definition: TauolaWrapper.h:92
L1HfRingEtScaleRcd.h
L1MuGMTReadoutRecord::getGMTCands
std::vector< L1MuGMTExtendedCand > getGMTCands() const
get GMT candidates vector
Definition: L1MuGMTReadoutRecord.cc:93
edm::EventSetup
Definition: EventSetup.h:58
L1MuTriggerPtScaleRcd
Definition: L1MuTriggerPtScaleRcd.h:12
get
#define get
L1MuTriggerScalesRcd
Definition: L1MuTriggerScalesRcd.h:12
L1TMuonLegacyConverter::muonMassGeV_
static const double muonMassGeV_
Definition: L1TMuonLegacyConverter.h:78
L1CaloEtScale.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
math::PtEtaPhiMLorentzVector
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
l1extra
Definition: L1EmParticle.h:26
L1JetEtScaleRcd.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
L1CaloGeometry.h
edm::InputTag
Definition: InputTag.h:15
L1MuScale::getCenter
virtual float getCenter(unsigned packed) const =0
get the center of bin represented by packed
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37