CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
GEMDigiToRawModule Class Reference
Inheritance diagram for GEMDigiToRawModule:
edm::global::EDProducer< edm::RunCache< GEMChMap > > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GEMDigiToRawModule (const edm::ParameterSet &pset)
 Constructor. More...
 
std::shared_ptr< GEMChMapglobalBeginRun (edm::Run const &, edm::EventSetup const &) const override
 
void globalEndRun (edm::Run const &, edm::EventSetup const &) const override
 
void produce (edm::StreamID, edm::Event &, edm::EventSetup const &) const override
 
- Public Member Functions inherited from edm::global::EDProducer< edm::RunCache< GEMChMap > >
 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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

const edm::EDGetTokenT< GEMDigiCollectiondigiToken_
 
const int event_type_
 
edm::ESGetToken< GEMChMap, GEMChMapRcdgemChMapToken_
 
const int maxBunch_
 
const int minBunch_
 
const bool simulatePulseStretching_
 
const bool useDBEMap_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

for gem on CSCDigiToRawModule

Author
J. Lee - UoS

Definition at line 28 of file GEMDigiToRawModule.cc.

Constructor & Destructor Documentation

◆ GEMDigiToRawModule()

GEMDigiToRawModule::GEMDigiToRawModule ( const edm::ParameterSet pset)

Constructor.

Definition at line 54 of file GEMDigiToRawModule.cc.

References gemChMapToken_, and useDBEMap_.

55  : event_type_(pset.getParameter<int>("eventType")),
56  minBunch_(pset.getParameter<int>("minBunch")),
57  maxBunch_(pset.getParameter<int>("maxBunch")),
58  digiToken_(consumes<GEMDigiCollection>(pset.getParameter<edm::InputTag>("gemDigi"))),
59  useDBEMap_(pset.getParameter<bool>("useDBEMap")),
60  simulatePulseStretching_(pset.getParameter<bool>("simulatePulseStretching")) {
61  produces<FEDRawDataCollection>();
62  if (useDBEMap_) {
63  gemChMapToken_ = esConsumes<GEMChMap, GEMChMapRcd, edm::Transition::BeginRun>();
64  }
65 }
edm::ESGetToken< GEMChMap, GEMChMapRcd > gemChMapToken_
const bool simulatePulseStretching_
const edm::EDGetTokenT< GEMDigiCollection > digiToken_

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 67 of file GEMDigiToRawModule.cc.

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

67  {
69  desc.add<edm::InputTag>("gemDigi", edm::InputTag("simMuonGEMDigis"));
70  desc.add<int>("eventType", 0);
71 
72  // time window for pulse stretching simulation
73  desc.add<int>("minBunch", -3);
74  desc.add<int>("maxBunch", 4);
75 
76  desc.add<bool>("useDBEMap", false);
77  desc.add<bool>("simulatePulseStretching", false);
78  descriptions.add("gemPackerDefault", desc);
79 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ globalBeginRun()

std::shared_ptr< GEMChMap > GEMDigiToRawModule::globalBeginRun ( edm::Run const &  ,
edm::EventSetup const &  iSetup 
) const
override

Definition at line 81 of file GEMDigiToRawModule.cc.

References gemChMapToken_, edm::EventSetup::getData(), and useDBEMap_.

81  {
82  if (useDBEMap_) {
83  const auto& eMap = iSetup.getData(gemChMapToken_);
84  auto gemChMap = std::make_shared<GEMChMap>(eMap);
85  return gemChMap;
86  } else {
87  // no EMap in DB, using dummy
88  auto gemChMap = std::make_shared<GEMChMap>();
89  gemChMap->setDummy();
90  return gemChMap;
91  }
92 }
edm::ESGetToken< GEMChMap, GEMChMapRcd > gemChMapToken_

◆ globalEndRun()

void GEMDigiToRawModule::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 36 of file GEMDigiToRawModule.cc.

36 {};

◆ produce()

void GEMDigiToRawModule::produce ( edm::StreamID  iID,
edm::Event iEvent,
edm::EventSetup const &   
) const
overridevirtual

<channels from 1to64

<channels from 65to128

Implements edm::global::EDProducerBase.

Definition at line 94 of file GEMDigiToRawModule.cc.

References GEMDigi::bx(), nano_mu_digi_cff::bx, GEMDetId::chamber(), nano_mu_digi_cff::chamberType, digiToken_, event_type_, l1tstage2_dqm_sourceclient-live_cfg::fedId, l1t_dqm_sourceclient-live_cfg::fedRawData, l1tPhase2CaloJetEmulator_cfi::iEta, iEvent, createfilelist::int, GEMDetId::layer(), LogDebug, GEMChMap::maxAMCs_, maxBunch_, GEMChMap::maxGEBs_, FEDNumbering::MAXGEMFEDID, FEDNumbering::MINGEMFEDID, eostools::move(), FastTimerService_cff::range, GEMDetId::region(), GEMDetId::ring(), cond::persistency::search(), simulatePulseStretching_, GEMDetId::station(), GEMDigi::strip(), nano_mu_digi_cff::strip, and w().

94  {
95  auto fedRawDataCol = std::make_unique<FEDRawDataCollection>();
96 
98  iEvent.getByToken(digiToken_, gemDigis);
99  if (!gemDigis.isValid()) {
100  iEvent.put(std::move(fedRawDataCol));
101  return;
102  }
103 
104  auto gemChMap = runCache(iEvent.getRun().index());
105 
106  std::vector<std::unique_ptr<GEMAMC13>> amc13s;
108 
109  int LV1_id = iEvent.id().event();
110  uint8_t BX_id(iEvent.bunchCrossing());
111  int OrN = iEvent.orbitNumber();
112 
113  // making map of bx GEMDigiCollection
114  // each bx will be saved as new GEMAMC13, so GEMDigiCollection needs to be split into bx
115  std::map<int, GEMDigiCollection> gemBxMap;
116  for (auto const& etaPart : *gemDigis) {
117  GEMDetId gemId = etaPart.first;
118  const GEMDigiCollection::Range& digis = etaPart.second;
119  for (auto digi = digis.first; digi != digis.second; ++digi) {
120  int bx = digi->bx();
122  if (bx < minBunch_ or bx > maxBunch_)
123  continue;
124  else
125  bx = 0;
126  }
127  auto search = gemBxMap.find(bx);
128  if (search != gemBxMap.end()) {
129  search->second.insertDigi(gemId, *digi);
130  } else {
131  GEMDigiCollection newGDC;
132  newGDC.insertDigi(gemId, *digi);
133  gemBxMap.insert(std::pair<int, GEMDigiCollection>(bx, newGDC));
134  }
135  }
136  }
137 
139  uint32_t amc13EvtLength = 0;
140  std::unique_ptr<GEMAMC13> amc13 = std::make_unique<GEMAMC13>();
141 
142  for (uint8_t amcNum = 0; amcNum <= GEMChMap::maxAMCs_; ++amcNum) {
143  uint32_t amcSize = 0;
144  std::unique_ptr<GEMAMC> amc = std::make_unique<GEMAMC>();
145 
146  for (uint8_t gebId = 0; gebId <= GEMChMap::maxGEBs_; ++gebId) {
147  std::unique_ptr<GEMOptoHybrid> optoH = std::make_unique<GEMOptoHybrid>();
148 
149  if (!gemChMap->isValidChamber(fedId, amcNum, gebId))
150  continue;
151 
152  auto geb_dc = gemChMap->chamberPos(fedId, amcNum, gebId);
153  GEMDetId cid = geb_dc.detId;
154  int chamberType = geb_dc.chamberType;
155 
156  auto vfats = gemChMap->getVfats(chamberType);
157 
158  for (auto vfatId : vfats) {
159  auto iEtas = gemChMap->getIEtas(chamberType, vfatId);
160  for (auto iEta : iEtas) {
161  GEMDetId gemId(cid.region(), cid.ring(), cid.station(), cid.layer(), cid.chamber(), iEta);
162 
163  for (auto const& gemBx : gemBxMap) {
164  int bc = BX_id + gemBx.first;
165 
166  bool hasDigi = false;
167  uint64_t lsData = 0;
168  uint64_t msData = 0;
169 
170  GEMDigiCollection inBxGemDigis = gemBx.second;
171  const GEMDigiCollection::Range& range = inBxGemDigis.get(gemId);
172 
173  for (GEMDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
174  const GEMDigi& digi = (*digiIt);
175 
176  int strip = digi.strip();
177 
178  hasDigi = true;
179 
180  if (!gemChMap->isValidStrip(chamberType, iEta, strip))
181  continue;
182  auto chMap = gemChMap->getChannel(chamberType, iEta, strip);
183 
184  if (chMap.vfatAdd != vfatId)
185  continue;
186 
187  if (chMap.chNum < 64)
188  lsData |= 1UL << chMap.chNum;
189  else
190  msData |= 1UL << (chMap.chNum - 64);
191 
192  LogDebug("GEMDigiToRawModule")
193  << "fed: " << fedId << " amc:" << int(amcNum) << " geb:" << int(gebId) << " vfat id:" << int(vfatId)
194  << ",type:" << chamberType << " id:" << gemId << " ch:" << chMap.chNum << " st:" << digi.strip()
195  << " bx:" << digi.bx();
196  }
197 
198  if (!hasDigi)
199  continue;
200  // only make vfat with hits
201  amcSize += 3;
202  int vfatVersion = (chamberType < 10) ? 2 : 3;
203  auto vfat = std::make_unique<GEMVFAT>(vfatVersion, bc, LV1_id, vfatId, lsData, msData);
204  optoH->addVFAT(*vfat);
205  }
206  }
207  } // end of vfats in GEB
208 
209  if (!optoH->vFATs()->empty()) {
210  amcSize += 2;
211  optoH->setChamberHeader(optoH->vFATs()->size() * 3, gebId);
212  optoH->setChamberTrailer(LV1_id, BX_id, optoH->vFATs()->size() * 3);
213  amc->addGEB(*optoH);
214  }
215  } // end of GEB loop
216 
217  if (!amc->gebs()->empty()) {
218  amcSize += 5;
219  amc->setAMCheader1(amcSize, BX_id, LV1_id, amcNum);
220  amc->setAMCheader2(amcNum, OrN, 1);
221  amc->setGEMeventHeader(amc->gebs()->size(), 0);
222  amc13->addAMCpayload(*amc);
223  // AMC header in GEMAMC13
224  amc13->addAMCheader(amcSize, 0, amcNum, 0);
225  amc13EvtLength += amcSize + 1; // AMC data size + AMC header size
226  }
227  } // end of AMC loop
228 
229  if (!amc13->getAMCpayloads()->empty()) {
230  // CDFHeader
231  amc13->setCDFHeader(event_type_, LV1_id, BX_id, fedId);
232  // AMC13header
233  uint8_t nAMC = amc13->getAMCpayloads()->size();
234  amc13->setAMC13Header(1, nAMC, OrN);
235  amc13->setAMC13Trailer(BX_id, LV1_id, BX_id);
236  //CDF trailer
237  uint32_t EvtLength = amc13EvtLength + 4; // 2 header and 2 trailer
238  amc13->setCDFTrailer(EvtLength);
239  amc13s.emplace_back(std::move(amc13));
240  } // finished making amc13 data
241  } // end of FED loop
242 
243  // read out amc13s into fedRawData
244  for (const auto& amc13e : amc13s) {
245  std::vector<uint64_t> words;
246  words.emplace_back(amc13e->getCDFHeader());
247  words.emplace_back(amc13e->getAMC13Header());
248 
249  for (const auto& w : *amc13e->getAMCheaders())
250  words.emplace_back(w);
251 
252  for (const auto& amc : *amc13e->getAMCpayloads()) {
253  words.emplace_back(amc.getAMCheader1());
254  words.emplace_back(amc.getAMCheader2());
255  words.emplace_back(amc.getGEMeventHeader());
256 
257  for (const auto& geb : *amc.gebs()) {
258  words.emplace_back(geb.getChamberHeader());
259 
260  for (const auto& vfat : *geb.vFATs()) {
261  words.emplace_back(vfat.get_fw());
262  words.emplace_back(vfat.get_sw());
263  words.emplace_back(vfat.get_tw());
264  }
265 
266  words.emplace_back(geb.getChamberTrailer());
267  }
268 
269  words.emplace_back(amc.getGEMeventTrailer());
270  words.emplace_back(amc.getAMCTrailer());
271  }
272 
273  words.emplace_back(amc13e->getAMC13Trailer());
274  words.emplace_back(amc13e->getCDFTrailer());
275 
276  FEDRawData& fedRawData = fedRawDataCol->FEDData(amc13e->sourceId());
277 
278  int dataSize = (words.size()) * sizeof(uint64_t);
279  fedRawData.resize(dataSize);
280 
281  uint64_t* w = reinterpret_cast<uint64_t*>(fedRawData.data());
282  for (const auto& word : words) {
283  *(w++) = word;
284  }
285  LogDebug("GEMDigiToRawModule") << "fedId:" << amc13e->sourceId() << " words:" << words.size();
286  }
287 
288  iEvent.put(std::move(fedRawDataCol));
289 }
constexpr int station() const
Definition: GEMDetId.h:179
constexpr int region() const
Definition: GEMDetId.h:171
T w() const
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:21
constexpr int layer() const
Definition: GEMDetId.h:190
constexpr int chamber() const
Definition: GEMDetId.h:183
uint64_t word
int iEvent
Definition: GenABIO.cc:224
constexpr int ring() const
Definition: GEMDetId.h:176
static const int maxGEBs_
Definition: GEMChMap.h:189
const bool simulatePulseStretching_
const edm::EDGetTokenT< GEMDigiCollection > digiToken_
uint16_t strip() const
Definition: GEMDigi.h:26
unsigned long long uint64_t
Definition: Time.h:13
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
int16_t bx() const
Definition: GEMDigi.h:27
static const int maxAMCs_
Definition: GEMChMap.h:192
Definition: AMCSpec.h:8
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ digiToken_

const edm::EDGetTokenT<GEMDigiCollection> GEMDigiToRawModule::digiToken_
private

Definition at line 45 of file GEMDigiToRawModule.cc.

Referenced by produce().

◆ event_type_

const int GEMDigiToRawModule::event_type_
private

Definition at line 42 of file GEMDigiToRawModule.cc.

Referenced by produce().

◆ gemChMapToken_

edm::ESGetToken<GEMChMap, GEMChMapRcd> GEMDigiToRawModule::gemChMapToken_
private

Definition at line 46 of file GEMDigiToRawModule.cc.

Referenced by GEMDigiToRawModule(), and globalBeginRun().

◆ maxBunch_

const int GEMDigiToRawModule::maxBunch_
private

Definition at line 44 of file GEMDigiToRawModule.cc.

Referenced by produce().

◆ minBunch_

const int GEMDigiToRawModule::minBunch_
private

Definition at line 43 of file GEMDigiToRawModule.cc.

◆ simulatePulseStretching_

const bool GEMDigiToRawModule::simulatePulseStretching_
private

Definition at line 48 of file GEMDigiToRawModule.cc.

Referenced by produce().

◆ useDBEMap_

const bool GEMDigiToRawModule::useDBEMap_
private

Definition at line 47 of file GEMDigiToRawModule.cc.

Referenced by GEMDigiToRawModule(), and globalBeginRun().