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
 
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, and srcInputTag.

3  {
4  using namespace edm;
5  srcInputTag = iConfig.getParameter<InputTag>("srcInputTag");
6  debug_ = iConfig.getUntrackedParameter<bool>("debug", false);
7 
8  // initialize orbit buffer for BX 1->3564;
9  orbitBuffer_ = std::vector<std::vector<l1ScoutingRun3::Muon>>(3565);
10  for (auto& bxVec : orbitBuffer_) {
11  bxVec.reserve(8);
12  }
13  nMuonsOrbit_ = 0;
14 
15  produces<l1ScoutingRun3::MuonOrbitCollection>().setBranchAlias("MuonOrbitCollection");
16  rawToken = consumes<SDSRawDataCollection>(srcInputTag);
17 }
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 19 of file ScGMTRawToDigi.cc.

19 {};

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 163 of file ScGMTRawToDigi.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

163  {
165  desc.setUnknown();
166  descriptions.addDefault(desc);
167 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 21 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().

21  {
22  using namespace edm;
23 
24  Handle<SDSRawDataCollection> ScoutingRawDataCollection;
25  iEvent.getByToken(rawToken, ScoutingRawDataCollection);
26 
27  const FEDRawData& sourceRawData = ScoutingRawDataCollection->FEDData(SDSNumbering::GmtSDSID);
28  size_t orbitSize = sourceRawData.size();
29 
30  std::unique_ptr<l1ScoutingRun3::MuonOrbitCollection> unpackedMuons(new l1ScoutingRun3::MuonOrbitCollection);
31 
32  if ((sourceRawData.size() == 0) && debug_) {
33  std::cout << "No raw data for GMT FED\n";
34  }
35 
36  // unpack current orbit and store data into the orbitBufferr
37  unpackOrbit(sourceRawData.data(), orbitSize);
38 
39  // fill orbit collection and clear the Bx buffer vector
40  unpackedMuons->fillAndClear(orbitBuffer_, nMuonsOrbit_);
41 
42  // store collection in the event
43  iEvent.put(std::move(unpackedMuons));
44 }
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 46 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_2023v12_cff::eta1, HLT_2023v12_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, l1ScoutingRun3::ugmt::block::mu, HLT_2023v12_cff::muon, nMuonsOrbit_, l1ScoutingRun3::ugmt::block::orbit, orbitBuffer_, PVValHelper::phi, l1ScoutingRun3::printMuon(), DiDispStaMuonMonitor_cfi::pt, l1tGTMenu_lepSeeds_cff::qual, l1ScoutingRun3::ugmt::muon::s, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by produce().

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

Referenced by produce(), and ScGMTRawToDigi().

◆ srcInputTag

edm::InputTag ScGMTRawToDigi::srcInputTag
private

Definition at line 42 of file ScGMTRawToDigi.h.

Referenced by ScGMTRawToDigi().