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 
88  l1t::MP7Payload payload(start, end, false);
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;
Definition: start.py:1
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
BXVector< RegionalMuonCand > RegionalMuonCandBxCollection
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
Log< level::Error, false > LogError
L1TBMTFAlgoSelector(const edm::ParameterSet &ps)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::Event &, const edm::EventSetup &) override
Log< level::Info, false > LogInfo
unsigned long long uint64_t
Definition: Time.h:13
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
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
std::vector< amc::Packet > payload() const
Definition: AMC13Spec.h:92
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
def move(src, dest)
Definition: eostools.py:511