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