CMS 3D CMS Logo

L1TBMTFAlgoSelector.cc
Go to the documentation of this file.
1 /*
2 /P.Katsoulis
3 /G.Karathanasis
4 */
5 
6 #include "L1TBMTFAlgoSelector.h"
7 
8 //The Constructor defines what to be consumed and produced
10  bmtfKalmanToken = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("bmtfKalman"));
11  bmtfLegacyToken = consumes<l1t::RegionalMuonCandBxCollection>(ps.getParameter<edm::InputTag>("bmtfLegacy"));
12  fedToken = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("feds"));
13 
14  produces<l1t::RegionalMuonCandBxCollection>("BMTF");
15  produces<l1t::RegionalMuonCandBxCollection>("BMTF2");
16 }
17 
19 
21  //Declare the Handlers
23  eve.getByToken(fedToken, feds);
25  eve.getByToken(bmtfKalmanToken, bmtfKalman);
27  eve.getByToken(bmtfLegacyToken, bmtfLegacy);
28 
29  //----> Make RegMuonCand Copies
30  auto *bmtfKalman_copy = new l1t::RegionalMuonCandBxCollection(*bmtfKalman);
31  auto *bmtfLegacy_copy = new l1t::RegionalMuonCandBxCollection(*bmtfLegacy);
32  edm::LogInfo("L1TDQM") << "copy RegionalMuonCandBxCollections created";
33  edm::LogInfo("L1TDQM") << "bmtfKalman_copy address: " << bmtfKalman_copy;
34  edm::LogInfo("L1TDQM") << "bmtfLegacy_copy address: " << bmtfLegacy_copy;
35 
36  //-----> Get the fw-ver
37  int nonEmptyFed = 0;
38  if (feds->FEDData(1376).size() > 0)
39  nonEmptyFed = 1376;
40  else if (feds->FEDData(1377).size() > 0)
41  nonEmptyFed = 1377;
42  else {
43  edm::LogError("L1TDQM") << "[L1TBMTFAlgoSelector] Both BMTF feds (1376, 1377) seem empty."
44  << "Using Default Configuration."
45  << "Will be wrong if this is Kalman triggering and ZS is enabled";
46  //Define the default configuration
47  std::unique_ptr<l1t::RegionalMuonCandBxCollection> bmtfTriggering, bmtfSecondary;
48  bmtfTriggering.reset(bmtfLegacy_copy);
49  bmtfSecondary.reset(bmtfKalman_copy);
50  //Print in log the addresses
51  edm::LogInfo("L1TDQM") << "Triggering and Secondary pointers filled:";
52  edm::LogInfo("L1TDQM") << "bmtfTriggering address: " << bmtfTriggering.get();
53  edm::LogInfo("L1TDQM") << "bmtfSecondary address: " << bmtfSecondary.get();
54  //Produce the products
55  eve.put(std::move(bmtfTriggering), "BMTF");
56  eve.put(std::move(bmtfSecondary), "BMTF2");
57  return;
58  }
59 
60  const FEDRawData &l1tRcd = feds->FEDData(nonEmptyFed);
61  ;
62  edm::LogInfo("L1TDQM") << "L1T Rcd taken from the FEDData.";
63  edm::LogInfo("L1TDQM") << "l1tRcd.size=" << l1tRcd.size() << " for fed:" << nonEmptyFed;
64 
65  const unsigned char *data = l1tRcd.data();
67  edm::LogInfo("L1TDQM") << "header and data extracted from the Rcd.";
68 
69  amc13::Packet packet;
70  if (!packet.parse((const uint64_t *)data,
71  (const uint64_t *)(data + 8),
72  (l1tRcd.size()) / 8,
73  header.lvl1ID(),
74  header.bxID(),
75  false,
76  false)) {
77  edm::LogError("L1TDQM") << "Could not extract AMC13 Packet.";
78  return;
79  }
80 
81  edm::LogInfo("L1TDQM") << "AMC13-packet-payload size = " << packet.payload().size();
82  unsigned algo_ver;
83  if (!packet.payload().empty()) {
84  auto payload64 = (packet.payload().at(0)).data();
85  const uint32_t *start = (const uint32_t *)payload64.get();
86  const uint32_t *end = start + (packet.payload().at(0).size() * 2);
87 
89  algo_ver = payload.getAlgorithmFWVersion();
90 
91  edm::LogInfo("L1TDQM") << "algo-ver = " << algo_ver << std::endl;
92  } else {
93  edm::LogError("L1TDQM") << "amc13 payload is empty, cannot extract AMC13 Packet...";
94  return;
95  }
96 
97  //----->Make the Decision which Algo Triggers
98  std::unique_ptr<l1t::RegionalMuonCandBxCollection> bmtfTriggering, bmtfSecondary;
99  if (algo_ver >= 2499805536) { //95000160(hex)
100  // kalman triggers
101  bmtfTriggering.reset(bmtfKalman_copy);
102  bmtfSecondary.reset(bmtfLegacy_copy);
103  } else {
104  // legacy triggers
105  bmtfTriggering.reset(bmtfLegacy_copy);
106  bmtfSecondary.reset(bmtfKalman_copy);
107  }
108 
109  edm::LogInfo("L1TDQM") << "Triggering and Secondary pointers filled:";
110  edm::LogInfo("L1TDQM") << "bmtfTriggering address: " << bmtfTriggering.get();
111  edm::LogInfo("L1TDQM") << "bmtfSecondary address: " << bmtfSecondary.get();
112 
113  eve.put(std::move(bmtfTriggering), "BMTF");
114  eve.put(std::move(bmtfSecondary), "BMTF2");
115 
116  return;
117 }
118 
119 using namespace dqmBmtfAlgoSelector;
l1tstage2emulator_dqm_sourceclient-live_cfg.feds
feds
Definition: l1tstage2emulator_dqm_sourceclient-live_cfg.py:146
dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::L1TBMTFAlgoSelector
L1TBMTFAlgoSelector(const edm::ParameterSet &ps)
Definition: L1TBMTFAlgoSelector.cc:9
start
Definition: start.py:1
L1TBMTFAlgoSelector_cfi.bmtfKalman
bmtfKalman
Definition: L1TBMTFAlgoSelector_cfi.py:6
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
dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::bmtfKalmanToken
edm::EDGetToken bmtfKalmanToken
Definition: L1TBMTFAlgoSelector.h:51
edm::LogInfo
Definition: MessageLogger.h:254
edm::Handle
Definition: AssociativeIterator.h:50
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
end
#define end
Definition: vmac.h:39
FEDRawData
Definition: FEDRawData.h:19
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
amc13::Packet
Definition: AMC13Spec.h:69
dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: L1TBMTFAlgoSelector.cc:20
jets_cff.payload
payload
Definition: jets_cff.py:34
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
l1t::MP7Payload
Definition: Block.h:106
L1TBMTFAlgoSelector.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
l1t::RegionalMuonCandBxCollection
BXVector< RegionalMuonCand > RegionalMuonCandBxCollection
Definition: RegionalMuonCandFwd.h:9
edm::EventSetup
Definition: EventSetup.h:57
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::fedToken
edm::EDGetToken fedToken
Definition: L1TBMTFAlgoSelector.h:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
dqmBmtfAlgoSelector
Definition: L1TBMTFAlgoSelector.h:37
eostools.move
def move(src, dest)
Definition: eostools.py:511
dqmBmtfAlgoSelector::L1TBMTFAlgoSelector
Definition: L1TBMTFAlgoSelector.h:39
dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::~L1TBMTFAlgoSelector
~L1TBMTFAlgoSelector() override
Definition: L1TBMTFAlgoSelector.cc:18
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
L1TBMTFAlgoSelector_cfi.bmtfLegacy
bmtfLegacy
Definition: L1TBMTFAlgoSelector_cfi.py:7
FEDHeader
Definition: FEDHeader.h:14
edm::Event
Definition: Event.h:73
dqmBmtfAlgoSelector::L1TBMTFAlgoSelector::bmtfLegacyToken
edm::EDGetToken bmtfLegacyToken
Definition: L1TBMTFAlgoSelector.h:52
edm::InputTag
Definition: InputTag.h:15