CMS 3D CMS Logo

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

#include <ScBMTFRawToDigi.h>

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

Public Member Functions

 ScBMTFRawToDigi (const edm::ParameterSet &)
 
 ~ScBMTFRawToDigi () 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, int sdsId)
 

Private Attributes

bool debug_ = false
 
int nStubsOrbit_
 
std::vector< std::vector< l1ScoutingRun3::BMTFStub > > orbitBuffer_
 
edm::EDGetToken rawToken_
 
std::vector< int > sourceIdList_
 
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 ScBMTFRawToDigi.h.

Constructor & Destructor Documentation

◆ ScBMTFRawToDigi()

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

Definition at line 3 of file ScBMTFRawToDigi.cc.

References debug_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), nStubsOrbit_, orbitBuffer_, rawToken_, sourceIdList_, and srcInputTag_.

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

◆ ~ScBMTFRawToDigi()

ScBMTFRawToDigi::~ScBMTFRawToDigi ( )
override

Definition at line 20 of file ScBMTFRawToDigi.cc.

20 {}

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 131 of file ScBMTFRawToDigi.cc.

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

131  {
133  desc.setUnknown();
134  descriptions.addDefault(desc);
135 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

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

Definition at line 22 of file ScBMTFRawToDigi.cc.

References SDSNumbering::BmtfMaxSDSID, SDSNumbering::BmtfMinSDSID, gather_cfg::cout, FEDRawData::data(), debug_, SDSRawDataCollection::FEDData(), iEvent, eostools::move(), nStubsOrbit_, orbitBuffer_, rawToken_, FEDRawData::size(), sourceIdList_, and unpackOrbit().

22  {
23  using namespace edm;
24 
25  Handle<SDSRawDataCollection> ScoutingRawDataCollection;
26  iEvent.getByToken(rawToken_, ScoutingRawDataCollection);
27 
28  std::unique_ptr<l1ScoutingRun3::BMTFStubOrbitCollection> unpackedStubs(new l1ScoutingRun3::BMTFStubOrbitCollection);
29 
30  for (const auto& sdsId : sourceIdList_) {
31  if ((sdsId < SDSNumbering::BmtfMinSDSID) || (sdsId > SDSNumbering::BmtfMaxSDSID))
32  edm::LogError("ScBMTFRawToDigi::produce")
33  << "Provided a source ID outside the expected range: " << sdsId << ", expected range ["
35  const FEDRawData& sourceRawData = ScoutingRawDataCollection->FEDData(sdsId);
36  size_t orbitSize = sourceRawData.size();
37 
38  if ((sourceRawData.size() == 0) && debug_) {
39  std::cout << "No raw data for BMTF FED " << sdsId << std::endl;
40  }
41 
42  // unpack current orbit and store data into the orbitBufferr
43  unpackOrbit(sourceRawData.data(), orbitSize, sdsId);
44  }
45 
46  // fill orbit collection and clear the Bx buffer vector
47  unpackedStubs->fillAndClear(orbitBuffer_, nStubsOrbit_);
48 
49  // store collection in the event
50  iEvent.put(std::move(unpackedStubs), "BMTFStub");
51 }
static constexpr int BmtfMinSDSID
Definition: SDSNumbering.h:20
const FEDRawData & FEDData(int sourceId) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
void unpackOrbit(const unsigned char *buf, size_t len, int sdsId)
Log< level::Error, false > LogError
std::vector< std::vector< l1ScoutingRun3::BMTFStub > > orbitBuffer_
static constexpr int BmtfMaxSDSID
Definition: SDSNumbering.h:21
int iEvent
Definition: GenABIO.cc:224
edm::EDGetToken rawToken_
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
std::vector< int > sourceIdList_
def move(src, dest)
Definition: eostools.py:511

◆ unpackOrbit()

void ScBMTFRawToDigi::unpackOrbit ( const unsigned char *  buf,
size_t  len,
int  sdsId 
)
private

Definition at line 53 of file ScBMTFRawToDigi.cc.

References cms::cuda::assert(), SDSNumbering::BmtfMinSDSID, visDQMUpload::buf, nano_mu_digi_cff::bx, l1ScoutingRun3::bmtf::block::bx, gather_cfg::cout, debug_, TauDecayModes::dec, PVValHelper::eta, l1ScoutingRun3::bmtf::block::header, mps_fire::i, nStubsOrbit_, l1ScoutingRun3::bmtf::block::orbit, orbitBuffer_, phi, PVValHelper::phi, nano_mu_digi_cff::sector, relativeConstraints::station, makeGlobalPositionRcd_cfg::tag, and makeMuonMisalignmentScenario::wheel.

Referenced by produce().

53  {
54  using namespace l1ScoutingRun3;
55 
56  // reset counters
57  nStubsOrbit_ = 0;
58 
59  size_t pos = 0;
60 
61  while (pos < len) {
62  assert(pos + 4 <= len);
63 
64  bmtf::block* bl = (bmtf::block*)(buf + pos);
65 
66  unsigned bx = bl->bx;
67  unsigned orbit = (bl->orbit) & 0x7FFFFFFF;
68  unsigned sCount = (bl->header) & 0xff;
69 
70  size_t pos_increment = 12 + sCount * 8;
71 
72  assert(pos_increment <= len);
73 
74  pos += 12; // header
75 
76  if (debug_) {
77  std::cout << " BMTF #" << sdsId << " Orbit " << orbit << ", BX -> " << bx << ", nStubs -> " << sCount
78  << std::endl;
79  }
80 
81  // Unpack stubs for the current pair (BX, sector)
82  int32_t phi, phiB, tag, qual, eta, qeta, station, wheel, sector;
83 
84  // map for station and wheel, to find chambers with 2 stubs
85  std::vector<std::vector<bool>> stwh_matrix(4, std::vector<bool>(5, false));
86  for (unsigned int i = 0; i < sCount; i++) {
87  uint64_t stub_raw = *(uint64_t*)(buf + pos);
88  pos += 8;
89 
91  phiB = ((stub_raw >> bmtf::shiftsStubs::phiB) & bmtf::masksStubs::phiB);
92  qual = ((stub_raw >> bmtf::shiftsStubs::qual) & bmtf::masksStubs::qual);
94  qeta = ((stub_raw >> bmtf::shiftsStubs::qeta) & bmtf::masksStubs::qeta);
98 
99  if (stwh_matrix[station - 1][wheel + 2] == false) {
100  tag = 1;
101  } else {
102  tag = 0;
103  }
104  stwh_matrix[station - 1][wheel + 2] = true;
105 
106  phi = phi >= 2048 ? phi - 4096 : phi;
107  phiB = phiB >= 512 ? phiB - 1024 : phiB;
108  wheel = wheel >= 4 ? wheel - 8 : wheel;
109 
110  BMTFStub stub(phi, phiB, qual, eta, qeta, station, wheel, sector, tag);
111  orbitBuffer_[bx].push_back(stub);
112  nStubsOrbit_++;
113 
114  if (debug_) {
115  std::cout << "Stub " << i << ", raw: 0x" << std::hex << stub_raw << std::dec << std::endl;
116  std::cout << "\tPhi: " << phi << std::endl;
117  std::cout << "\tPhiB: " << phiB << std::endl;
118  std::cout << "\tQuality: " << qual << std::endl;
119  std::cout << "\tEta: " << eta << std::endl;
120  std::cout << "\tQEta: " << qeta << std::endl;
121  std::cout << "\tStation: " << station << std::endl;
122  std::cout << "\tWheel: " << wheel << std::endl;
123  std::cout << "\tSector: " << sector << std::endl;
124  std::cout << "\tTag: " << tag << std::endl;
125  }
126  }
127 
128  } // end orbit while loop
129 }
static constexpr int BmtfMinSDSID
Definition: SDSNumbering.h:20
assert(be >=bs)
std::vector< std::vector< l1ScoutingRun3::BMTFStub > > orbitBuffer_
unsigned long long uint64_t
Definition: Time.h:13

Member Data Documentation

◆ debug_

bool ScBMTFRawToDigi::debug_ = false
private

Definition at line 41 of file ScBMTFRawToDigi.h.

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

◆ nStubsOrbit_

int ScBMTFRawToDigi::nStubsOrbit_
private

Definition at line 39 of file ScBMTFRawToDigi.h.

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

◆ orbitBuffer_

std::vector<std::vector<l1ScoutingRun3::BMTFStub> > ScBMTFRawToDigi::orbitBuffer_
private

Definition at line 38 of file ScBMTFRawToDigi.h.

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

◆ rawToken_

edm::EDGetToken ScBMTFRawToDigi::rawToken_
private

Definition at line 44 of file ScBMTFRawToDigi.h.

Referenced by produce(), and ScBMTFRawToDigi().

◆ sourceIdList_

std::vector<int> ScBMTFRawToDigi::sourceIdList_
private

Definition at line 42 of file ScBMTFRawToDigi.h.

Referenced by produce(), and ScBMTFRawToDigi().

◆ srcInputTag_

edm::InputTag ScBMTFRawToDigi::srcInputTag_
private

Definition at line 43 of file ScBMTFRawToDigi.h.

Referenced by ScBMTFRawToDigi().