CMS 3D CMS Logo

L1UpgradeTfMuonTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1Ntuples
4 // Class: L1UpgradeTfMuonTreeProducer
5 //
11 //
12 // Original Author:
13 // Created:
14 // $Id: L1UpgradeTfMuonTreeProducer.cc,v 1.8 2012/08/29 12:44:03 jbrooke Exp $
15 //
16 //
17 
18 // system include files
19 #include <memory>
20 
21 // framework
28 
29 // data formats
32 
33 // Needed to get BMTF firmware version
37 
38 // ROOT output stuff
41 #include "TTree.h"
42 
45 
46 //
47 // class declaration
48 //
49 
51 public:
54 
55 private:
56  void beginJob(void) override;
57  void analyze(const edm::Event&, const edm::EventSetup&) override;
58  void endJob() override;
59 
60 public:
71 
72 private:
74  bool isEMU_;
75 
76  // output file
78 
79  // tree
80  TTree* tree_;
81 
82  // EDM input tags
88 
91 
92  // EDM handles
94 
95  unsigned getAlgoFwVersion();
96 };
97 
99  isEMU_ = iConfig.getParameter<bool>("isEMU");
100  fedToken_ = consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("feds"));
102  consumes<l1t::RegionalMuonCandBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("bmtfMuonToken"));
104  consumes<l1t::RegionalMuonCandBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("bmtf2MuonToken"));
106  consumes<l1t::RegionalMuonCandBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("omtfMuonToken"));
108  consumes<l1t::RegionalMuonCandBxCollection>(iConfig.getUntrackedParameter<edm::InputTag>("emtfMuonToken"));
110  consumes<L1MuDTChambPhContainer>(iConfig.getUntrackedParameter<edm::InputTag>("bmtfInputPhMuonToken"));
112  consumes<L1MuDTChambThContainer>(iConfig.getUntrackedParameter<edm::InputTag>("bmtfInputThMuonToken"));
113 
114  maxL1UpgradeTfMuon_ = iConfig.getParameter<unsigned int>("maxL1UpgradeTfMuon");
115 
121 
122  // set up output
123  tree_ = fs_->make<TTree>("L1UpgradeTfMuonTree", "L1UpgradeTfMuonTree");
124  tree_->Branch("L1UpgradeBmtfMuon", "L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat", &l1UpgradeBmtfData, 32000, 3);
125  tree_->Branch("L1UpgradeKBmtfMuon", "L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat", &l1UpgradeKBmtfData, 32000, 3);
126  tree_->Branch("L1UpgradeOmtfMuon", "L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat", &l1UpgradeOmtfData, 32000, 3);
127  tree_->Branch("L1UpgradeEmtfMuon", "L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat", &l1UpgradeEmtfData, 32000, 3);
128 
129  tree_->Branch(
130  "L1UpgradeBmtfInputs", "L1Analysis::L1AnalysisBMTFInputsDataFormat", &l1UpgradeBmtfInputsData, 32000, 3);
131 }
132 
134 
135 //
136 // member functions
137 //
138 
139 // ------------ method called to for each event ------------
143  if (isEMU_) {
144  legacybmtfMuonToken = bmtfMuonToken_;
145  kbmtfMuonToken = bmtf2MuonToken_;
146  } else {
147  iEvent.getByToken(fedToken_, feds_);
148  // Get fw version
149  unsigned algoFwVersion{getAlgoFwVersion()};
150  if (algoFwVersion < 2499805536) { //95000160(hex)
151  // Legacy was triggering (and therefore in the main collection)
152  legacybmtfMuonToken = bmtfMuonToken_;
153  kbmtfMuonToken = bmtf2MuonToken_;
154  } else {
155  // kBMTF was triggering
156  legacybmtfMuonToken = bmtf2MuonToken_;
157  kbmtfMuonToken = bmtfMuonToken_;
158  }
159  }
160 
167 
174 
175  iEvent.getByToken(legacybmtfMuonToken, bmtfMuon);
176  iEvent.getByToken(kbmtfMuonToken, kbmtfMuon);
177  iEvent.getByToken(omtfMuonToken_, omtfMuon);
178  iEvent.getByToken(emtfMuonToken_, emtfMuon);
179  iEvent.getByToken(bmtfPhInputToken_, bmtfPhInputs);
180  iEvent.getByToken(bmtfThInputToken_, bmtfThInputs);
181 
182  if (bmtfMuon.isValid()) {
184  } else {
185  edm::LogWarning("MissingProduct") << "L1Upgrade BMTF muons not found. Branch will not be filled" << std::endl;
186  }
187 
188  if (kbmtfMuon.isValid()) {
190  } else {
191  edm::LogWarning("MissingProduct") << "L1Upgrade kBMTF muons not found. Branch will not be filled" << std::endl;
192  }
193 
194  if (omtfMuon.isValid()) {
196  } else {
197  edm::LogWarning("MissingProduct") << "L1Upgrade OMTF muons not found. Branch will not be filled" << std::endl;
198  }
199 
200  if (emtfMuon.isValid()) {
202  } else {
203  edm::LogWarning("MissingProduct") << "L1Upgrade EMTF muons not found. Branch will not be filled" << std::endl;
204  }
205 
206  int max_inputs = maxL1UpgradeTfMuon_ * 4;
207 
208  if (!bmtfPhInputs.isValid()) {
209  edm::LogWarning("MissingProduct") << "L1Upgrade BMTF Ph Inputs not found. Branch will not be filled" << std::endl;
210  } else
211  l1UpgradeBmtfInputs.SetBMPH(bmtfPhInputs, max_inputs);
212 
213  if (!bmtfThInputs.isValid()) {
214  edm::LogWarning("MissingProduct") << "L1Upgrade BMTF Th Inputs not found. Branch will not be filled" << std::endl;
215  } else
216  l1UpgradeBmtfInputs.SetBMTH(bmtfThInputs, max_inputs);
217 
218  tree_->Fill();
219 }
220 
221 // ------------ method called once each job just before starting event loop ------------
223 
224 // ------------ method called once each job just after ending the event loop ------------
226 
228  int nonEmptyFed = 0;
229  if (feds_->FEDData(1376).size() > 0)
230  nonEmptyFed = 1376;
231  else if (feds_->FEDData(1377).size() > 0)
232  nonEmptyFed = 1377;
233  else {
234  edm::LogError("L1UpgradeTfMuonTreeProducer")
235  << "Both BMTF feds (1376, 1377) seem empty, will lead to unexpected results in tree from data.";
236  return 0;
237  }
238 
239  const FEDRawData& l1tRcd = feds_->FEDData(nonEmptyFed);
240  edm::LogInfo("L1UpgradeTfMuonTreeProducer") << "L1T Rcd taken from the FEDData.";
241  edm::LogInfo("L1UpgradeTfMuonTreeProducer") << "l1tRcd.size=" << l1tRcd.size() << " for fed:" << nonEmptyFed;
242 
243  const unsigned char* data = l1tRcd.data();
245 
246  amc13::Packet packet;
247  if (!packet.parse((const uint64_t*)data,
248  (const uint64_t*)(data + 8),
249  (l1tRcd.size()) / 8,
250  header.lvl1ID(),
251  header.bxID(),
252  false,
253  false)) {
254  edm::LogError("L1UpgradeTfMuonTreeProducer") << "Could not extract AMC13 Packet.";
255  return 0;
256  }
257 
258  if (!packet.payload().empty()) {
259  auto payload64 = (packet.payload().at(0)).data();
260  const uint32_t* start = (const uint32_t*)payload64.get();
261  const uint32_t* end = start + (packet.payload().at(0).size() * 2);
262 
263  l1t::MP7Payload payload(start, end, false);
264  return payload.getAlgorithmFWVersion();
265 
266  } else {
267  edm::LogError("L1UpgradeTfMuonTreeProducer") << "AMC13 payload is empty, cannot extract AMC13 Packet.";
268  return 0;
269  }
270 }
271 
272 //define this as a plug-in
Block.h
L1UpgradeTfMuonTreeProducer::fs_
edm::Service< TFileService > fs_
Definition: L1UpgradeTfMuonTreeProducer.cc:77
L1UpgradeTfMuonTreeProducer::bmtf2MuonToken_
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > bmtf2MuonToken_
Definition: L1UpgradeTfMuonTreeProducer.cc:85
start
Definition: start.py:1
amc13::Packet::parse
bool parse(const uint64_t *start, const uint64_t *data, unsigned int size, unsigned int lv1, unsigned int bx, bool legacy_mc=false, bool mtf7_mode=false)
Definition: AMC13Spec.cc:60
MessageLogger.h
L1UpgradeTfMuonTreeProducer::bmtfPhInputToken_
edm::EDGetTokenT< L1MuDTChambPhContainer > bmtfPhInputToken_
Definition: L1UpgradeTfMuonTreeProducer.cc:89
L1Analysis::L1AnalysisL1UpgradeTfMuon::SetTfMuon
void SetTfMuon(const l1t::RegionalMuonCandBxCollection &muon, unsigned maxL1UpgradeTfMuon)
Definition: L1AnalysisL1UpgradeTfMuon.cc:7
L1UpgradeTfMuonTreeProducer::l1UpgradeEmtfData
L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat * l1UpgradeEmtfData
Definition: L1UpgradeTfMuonTreeProducer.cc:69
L1Analysis::L1AnalysisL1UpgradeTfMuon::getData
L1AnalysisL1UpgradeTfMuonDataFormat * getData()
Definition: L1AnalysisL1UpgradeTfMuon.h:20
L1UpgradeTfMuonTreeProducer::emtfMuonToken_
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > emtfMuonToken_
Definition: L1UpgradeTfMuonTreeProducer.cc:87
edm::EDGetTokenT< FEDRawDataCollection >
L1Analysis::L1AnalysisBMTFInputs::SetBMTH
void SetBMTH(const edm::Handle< L1MuDTChambThContainer > L1MuDTChambThContainer, unsigned int maxDTTH)
Definition: L1AnalysisBMTFInputs.cc:37
L1Analysis::L1AnalysisBMTFInputs::SetBMPH
void SetBMPH(const edm::Handle< L1MuDTChambPhContainer > L1MuDTChambPhContainer, unsigned int maxDTPH)
Definition: L1AnalysisBMTFInputs.cc:13
L1UpgradeTfMuonTreeProducer::l1UpgradeOmtfData
L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat * l1UpgradeOmtfData
Definition: L1UpgradeTfMuonTreeProducer.cc:68
L1UpgradeTfMuonTreeProducer::L1UpgradeTfMuonTreeProducer
L1UpgradeTfMuonTreeProducer(const edm::ParameterSet &)
Definition: L1UpgradeTfMuonTreeProducer.cc:98
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EDAnalyzer.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< FEDRawDataCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
L1UpgradeTfMuonTreeProducer::l1UpgradeBmtf
L1Analysis::L1AnalysisL1UpgradeTfMuon l1UpgradeBmtf
Definition: L1UpgradeTfMuonTreeProducer.cc:62
amc13::Packet::payload
std::vector< amc::Packet > payload() const
Definition: AMC13Spec.h:92
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
AMC13Spec.h
L1Analysis::L1AnalysisL1UpgradeTfMuon::Reset
void Reset()
Definition: L1AnalysisL1UpgradeTfMuon.h:14
L1UpgradeTfMuonTreeProducer
Definition: L1UpgradeTfMuonTreeProducer.cc:50
MakerMacros.h
L1UpgradeTfMuonTreeProducer::~L1UpgradeTfMuonTreeProducer
~L1UpgradeTfMuonTreeProducer() override
Definition: L1UpgradeTfMuonTreeProducer.cc:133
L1UpgradeTfMuonTreeProducer::l1UpgradeBmtfData
L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat * l1UpgradeBmtfData
Definition: L1UpgradeTfMuonTreeProducer.cc:66
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1Analysis::L1AnalysisBMTFInputs
Definition: L1AnalysisBMTFInputs.h:19
L1UpgradeTfMuonTreeProducer::feds_
edm::Handle< FEDRawDataCollection > feds_
Definition: L1UpgradeTfMuonTreeProducer.cc:93
Service.h
amc13::Packet
Definition: AMC13Spec.h:69
L1Analysis::L1AnalysisBMTFInputs::getData
L1AnalysisBMTFInputsDataFormat * getData()
Definition: L1AnalysisBMTFInputs.h:28
mps_fire.end
end
Definition: mps_fire.py:242
L1Analysis::L1AnalysisBMTFInputs::Reset
void Reset()
Definition: L1AnalysisBMTFInputs.h:27
jets_cff.payload
payload
Definition: jets_cff.py:32
L1UpgradeTfMuonTreeProducer::endJob
void endJob() override
Definition: L1UpgradeTfMuonTreeProducer.cc:225
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
L1UpgradeTfMuonTreeProducer::tree_
TTree * tree_
Definition: L1UpgradeTfMuonTreeProducer.cc:80
l1t::MP7Payload
Definition: Block.h:122
L1Analysis::L1AnalysisL1UpgradeTfMuon::SetKalmanMuon
void SetKalmanMuon()
Definition: L1AnalysisL1UpgradeTfMuon.h:18
TFileService.h
L1UpgradeTfMuonTreeProducer::bmtfThInputToken_
edm::EDGetTokenT< L1MuDTChambThContainer > bmtfThInputToken_
Definition: L1UpgradeTfMuonTreeProducer.cc:90
edm::ParameterSet
Definition: ParameterSet.h:47
L1UpgradeTfMuonTreeProducer::beginJob
void beginJob(void) override
Definition: L1UpgradeTfMuonTreeProducer.cc:222
Event.h
L1UpgradeTfMuonTreeProducer::l1UpgradeBmtfInputs
L1Analysis::L1AnalysisBMTFInputs l1UpgradeBmtfInputs
Definition: L1UpgradeTfMuonTreeProducer.cc:65
L1UpgradeTfMuonTreeProducer::l1UpgradeOmtf
L1Analysis::L1AnalysisL1UpgradeTfMuon l1UpgradeOmtf
Definition: L1UpgradeTfMuonTreeProducer.cc:63
L1UpgradeTfMuonTreeProducer::l1UpgradeKBmtf
L1Analysis::L1AnalysisL1UpgradeTfMuon l1UpgradeKBmtf
Definition: L1UpgradeTfMuonTreeProducer.cc:61
L1UpgradeTfMuonTreeProducer::isEMU_
bool isEMU_
Definition: L1UpgradeTfMuonTreeProducer.cc:74
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
FEDRawDataCollection.h
L1AnalysisBMTFInputs.h
edm::EventSetup
Definition: EventSetup.h:58
L1UpgradeTfMuonTreeProducer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1UpgradeTfMuonTreeProducer.cc:140
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat
Definition: L1AnalysisL1UpgradeTfMuonDataFormat.h:9
L1UpgradeTfMuonTreeProducer::l1UpgradeKBmtfData
L1Analysis::L1AnalysisL1UpgradeTfMuonDataFormat * l1UpgradeKBmtfData
Definition: L1UpgradeTfMuonTreeProducer.cc:67
TFileService::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
L1UpgradeTfMuonTreeProducer::fedToken_
edm::EDGetTokenT< FEDRawDataCollection > fedToken_
Definition: L1UpgradeTfMuonTreeProducer.cc:83
L1UpgradeTfMuonTreeProducer::maxL1UpgradeTfMuon_
unsigned maxL1UpgradeTfMuon_
Definition: L1UpgradeTfMuonTreeProducer.cc:73
L1UpgradeTfMuonTreeProducer::l1UpgradeEmtf
L1Analysis::L1AnalysisL1UpgradeTfMuon l1UpgradeEmtf
Definition: L1UpgradeTfMuonTreeProducer.cc:64
Frameworkfwd.h
L1UpgradeTfMuonTreeProducer::omtfMuonToken_
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > omtfMuonToken_
Definition: L1UpgradeTfMuonTreeProducer.cc:86
L1UpgradeTfMuonTreeProducer::l1UpgradeBmtfInputsData
L1Analysis::L1AnalysisBMTFInputsDataFormat * l1UpgradeBmtfInputsData
Definition: L1UpgradeTfMuonTreeProducer.cc:70
RegionalMuonCand.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:291
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
L1UpgradeTfMuonTreeProducer::getAlgoFwVersion
unsigned getAlgoFwVersion()
Definition: L1UpgradeTfMuonTreeProducer.cc:227
ParameterSet.h
L1AnalysisL1UpgradeTfMuon.h
L1Analysis::L1AnalysisBMTFInputsDataFormat
Definition: L1AnalysisBMTFInputsDataFormat.h:7
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
FEDHeader
Definition: FEDHeader.h:14
edm::Event
Definition: Event.h:73
FEDHeader.h
edm::InputTag
Definition: InputTag.h:15
L1UpgradeTfMuonTreeProducer::bmtfMuonToken_
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > bmtfMuonToken_
Definition: L1UpgradeTfMuonTreeProducer.cc:84
L1Analysis::L1AnalysisL1UpgradeTfMuon
Definition: L1AnalysisL1UpgradeTfMuon.h:9