CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ScGMTRawToDigi Class Reference

#include <ScGMTRawToDigi.h>

Inheritance diagram for ScGMTRawToDigi:
edm::stream::EDProducer<>

Public Member Functions

 ScGMTRawToDigi (const edm::ParameterSet &)
 
 ~ScGMTRawToDigi () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
void unpackOrbit (const unsigned char *buf, size_t len)
 

Private Attributes

bool debug_ = false
 
int nMuonsOrbit_
 
std::vector< std::vector< l1ScoutingRun3::Muon > > orbitBuffer_
 
edm::EDGetToken rawToken
 
bool skipInterm_ = true
 
edm::InputTag srcInputTag
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 24 of file ScGMTRawToDigi.h.

Constructor & Destructor Documentation

◆ ScGMTRawToDigi()

ScGMTRawToDigi::ScGMTRawToDigi ( const edm::ParameterSet iConfig)
explicit

Definition at line 3 of file ScGMTRawToDigi.cc.

References debug_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), nMuonsOrbit_, orbitBuffer_, rawToken, skipInterm_, and srcInputTag.

3  {
4  using namespace edm;
5  srcInputTag = iConfig.getParameter<InputTag>("srcInputTag");
6  skipInterm_ = iConfig.getParameter<bool>("skipInterm");
7  debug_ = iConfig.getUntrackedParameter<bool>("debug", false);
8 
9  // initialize orbit buffer for BX 1->3564;
10  orbitBuffer_ = std::vector<std::vector<l1ScoutingRun3::Muon>>(3565);
11  for (auto& bxVec : orbitBuffer_) {
12  bxVec.reserve(8);
13  }
14  nMuonsOrbit_ = 0;
15 
16  produces<l1ScoutingRun3::MuonOrbitCollection>("Muon").setBranchAlias("MuonOrbitCollection");
17  rawToken = consumes<SDSRawDataCollection>(srcInputTag);
18 }
edm::EDGetToken rawToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::InputTag srcInputTag
std::vector< std::vector< l1ScoutingRun3::Muon > > orbitBuffer_
T getUntrackedParameter(std::string const &, T const &) const
HLT enums.

◆ ~ScGMTRawToDigi()

ScGMTRawToDigi::~ScGMTRawToDigi ( )
override

Definition at line 20 of file ScGMTRawToDigi.cc.

20 {};

Member Function Documentation

◆ fillDescriptions()

void ScGMTRawToDigi::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 159 of file ScGMTRawToDigi.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

159  {
161  desc.add<edm::InputTag>("srcInputTag", edm::InputTag("rawDataCollector"));
162  desc.add<bool>("skipInterm", true);
163  desc.addUntracked<bool>("debug", false);
164  descriptions.add("ScGMTRawToDigi", desc);
165 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void ScGMTRawToDigi::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 22 of file ScGMTRawToDigi.cc.

References gather_cfg::cout, FEDRawData::data(), debug_, SDSRawDataCollection::FEDData(), SDSNumbering::GmtSDSID, iEvent, eostools::move(), nMuonsOrbit_, orbitBuffer_, rawToken, FEDRawData::size(), and unpackOrbit().

22  {
23  using namespace edm;
24 
25  Handle<SDSRawDataCollection> ScoutingRawDataCollection;
26  iEvent.getByToken(rawToken, ScoutingRawDataCollection);
27 
28  const FEDRawData& sourceRawData = ScoutingRawDataCollection->FEDData(SDSNumbering::GmtSDSID);
29  size_t orbitSize = sourceRawData.size();
30 
31  std::unique_ptr<l1ScoutingRun3::MuonOrbitCollection> unpackedMuons(new l1ScoutingRun3::MuonOrbitCollection);
32 
33  if ((sourceRawData.size() == 0) && debug_) {
34  std::cout << "No raw data for GMT FED\n";
35  }
36 
37  // unpack current orbit and store data into the orbitBufferr
38  unpackOrbit(sourceRawData.data(), orbitSize);
39 
40  // fill orbit collection and clear the Bx buffer vector
41  unpackedMuons->fillAndClear(orbitBuffer_, nMuonsOrbit_);
42 
43  // store collection in the event
44  iEvent.put(std::move(unpackedMuons), "Muon");
45 }
edm::EDGetToken rawToken
void unpackOrbit(const unsigned char *buf, size_t len)
const FEDRawData & FEDData(int sourceId) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
std::vector< std::vector< l1ScoutingRun3::Muon > > orbitBuffer_
int iEvent
Definition: GenABIO.cc:224
static constexpr int GmtSDSID
Definition: SDSNumbering.h:17
HLT enums.
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

◆ unpackOrbit()

void ScGMTRawToDigi::unpackOrbit ( const unsigned char *  buf,
size_t  len 
)
private

Definition at line 47 of file ScGMTRawToDigi.cc.

References cms::cuda::assert(), visDQMUpload::buf, l1ScoutingRun3::ugmt::block::bx, nano_mu_digi_cff::bx, gather_cfg::cout, debug_, TauDecayModes::dec, PVValHelper::dxy, PVValHelper::eta, HLT_2024v12_cff::eta1, HLT_2024v12_cff::eta2, l1ScoutingRun3::ugmt::muon::extra, l1ScoutingRun3::ugmt::muon::f, RecoTauValidation_cfi::header, mps_fire::i, hcalRecHitTable_cff::ieta, hcaltpdigi_cfi::ieta1, hcaltpdigi_cfi::ieta2, hcalRecHitTable_cff::iphi, genparticles_cff::iso, l1ScoutingRun3::ugmt::block::mu, HLT_2024v12_cff::muon, nMuonsOrbit_, l1ScoutingRun3::ugmt::block::orbit, orbitBuffer_, PVValHelper::phi, l1ScoutingRun3::printMuon(), DiDispStaMuonMonitor_cfi::pt, l1tGTMenu_lepSeeds_cff::qual, l1ScoutingRun3::ugmt::muon::s, skipInterm_, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by produce().

47  {
48  using namespace l1ScoutingRun3;
49 
50  // reset counters
51  nMuonsOrbit_ = 0;
52 
53  size_t pos = 0;
54 
55  while (pos < len) {
56  assert(pos + 4 <= len);
57 
58  // get BX header
59  uint32_t header = *((uint32_t*)(buf + pos));
60  pos += 4;
61  // count mA and mB
62  uint32_t mAcount = (header & header_masks::mAcount) >> header_shifts::mAcount;
63  uint32_t mBcount = (header & header_masks::mBcount) >> header_shifts::mBcount;
64 
65  // declare block to read
66  ugmt::block* bl = (ugmt::block*)(buf + pos);
67  pos += 4 + 4 + (mAcount + mBcount) * 12;
68  assert(pos <= len);
69 
70  uint32_t orbit = bl->orbit & 0x7FFFFFFF;
71  uint32_t bx = bl->bx;
72 
73  if (debug_) {
74  std::cout << "GMT Orbit " << orbit << ", BX -> " << bx << ", nMuons -> " << mAcount + mBcount << std::endl;
75  }
76 
77  // Unpack muons for this BX
78  orbitBuffer_[bx].reserve(mAcount + mBcount);
79 
80  for (unsigned int i = 0; i < mAcount + mBcount; i++) {
81  uint32_t interm = (bl->mu[i].extra >> ugmt::shiftsMuon::interm) & ugmt::masksMuon::interm;
82  if ((interm == 1) && (skipInterm_)) {
83  if (debug_) {
84  std::cout << " -> Excluding intermediate muon\n";
85  }
86  continue;
87  }
88 
90  uint32_t ietaextu = (bl->mu[i].f >> ugmt::shiftsMuon::etaext) & ugmt::masksMuon::etaextv;
91  int32_t ietaext;
92  if (((bl->mu[i].f >> ugmt::shiftsMuon::etaext) & ugmt::masksMuon::etaexts) != 0) {
93  ietaext = ietaextu -= 256;
94  } else {
95  ietaext = ietaextu;
96  }
97 
98  // extract pt and quality and apply cut if required
99  int32_t iptuncon = (bl->mu[i].s >> ugmt::shiftsMuon::ptuncon) & ugmt::masksMuon::ptuncon;
100  int32_t ipt = (bl->mu[i].f >> ugmt::shiftsMuon::pt) & ugmt::masksMuon::pt;
101  if ((ipt - 1) < 0) {
102  continue;
103  }
104  uint32_t qual = (bl->mu[i].f >> ugmt::shiftsMuon::qual) & ugmt::masksMuon::qual;
105 
106  // extract integer value for extrapolated phi
107  int32_t iphiext = ((bl->mu[i].f >> ugmt::shiftsMuon::phiext) & ugmt::masksMuon::phiext);
108 
109  // extract integer value for extrapolated phi
110  int32_t idxy = ((bl->mu[i].s >> ugmt::shiftsMuon::dxy) & ugmt::masksMuon::dxy);
111 
112  // extract iso bits and charge
113  uint32_t iso = (bl->mu[i].s >> ugmt::shiftsMuon::iso) & ugmt::masksMuon::iso;
114  int32_t chrg = 0;
115  if (((bl->mu[i].s >> ugmt::shiftsMuon::chrgv) & ugmt::masksMuon::chrgv) == 1)
116  chrg = ((bl->mu[i].s >> ugmt::shiftsMuon::chrg) & ugmt::masksMuon::chrg) == 1 ? -1 : 1;
117 
118  // extract eta and phi at muon station
119  int32_t iphi = (bl->mu[i].s >> ugmt::shiftsMuon::phi) & ugmt::masksMuon::phi;
122 
123  uint32_t ieta_u;
124  int32_t ieta;
125  // checking if raw eta should be taken from muon 1 or muon 2
126  if ((bl->mu[i].extra & 0x1) == 0) {
127  ieta_u = ieta1;
128  } else {
129  ieta_u = ieta2;
130  }
131 
132  // two's complement
133  if (ieta_u > 256) {
134  ieta = ieta_u - 512;
135  } else {
136  ieta = ieta_u;
137  }
138 
139  // increment muon counter
140  nMuonsOrbit_++;
141 
142  l1ScoutingRun3::Muon muon(ipt, ieta, iphi, qual, chrg, chrg != 0, iso, index, ietaext, iphiext, iptuncon, idxy);
143 
144  orbitBuffer_[bx].push_back(muon);
145 
146  if (debug_) {
147  std::cout << "--- Muon " << i << " ---\n";
148  std::cout << " Raw f: 0x" << std::hex << bl->mu[i].f << std::dec << "\n";
149  std::cout << " Raw s: 0x" << std::hex << bl->mu[i].s << std::dec << "\n";
150  std::cout << " Raw extra: 0x" << std::hex << bl->mu[i].extra << std::dec << "\n";
151  printMuon(muon);
152  }
153 
154  } // end of bx
155 
156  } // end orbit while loop
157 }
void printMuon(const Muon &muon, std::ostream &outs=std::cout)
assert(be >=bs)
std::vector< std::vector< l1ScoutingRun3::Muon > > orbitBuffer_

Member Data Documentation

◆ debug_

bool ScGMTRawToDigi::debug_ = false
private

Definition at line 41 of file ScGMTRawToDigi.h.

Referenced by produce(), ScGMTRawToDigi(), and unpackOrbit().

◆ nMuonsOrbit_

int ScGMTRawToDigi::nMuonsOrbit_
private

Definition at line 39 of file ScGMTRawToDigi.h.

Referenced by produce(), ScGMTRawToDigi(), and unpackOrbit().

◆ orbitBuffer_

std::vector<std::vector<l1ScoutingRun3::Muon> > ScGMTRawToDigi::orbitBuffer_
private

Definition at line 38 of file ScGMTRawToDigi.h.

Referenced by produce(), ScGMTRawToDigi(), and unpackOrbit().

◆ rawToken

edm::EDGetToken ScGMTRawToDigi::rawToken
private

Definition at line 44 of file ScGMTRawToDigi.h.

Referenced by produce(), and ScGMTRawToDigi().

◆ skipInterm_

bool ScGMTRawToDigi::skipInterm_ = true
private

Definition at line 42 of file ScGMTRawToDigi.h.

Referenced by ScGMTRawToDigi(), and unpackOrbit().

◆ srcInputTag

edm::InputTag ScGMTRawToDigi::srcInputTag
private

Definition at line 43 of file ScGMTRawToDigi.h.

Referenced by ScGMTRawToDigi().