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

edm::EDGetTokenT< GEMDigiCollectiondigi_token
 
int event_type_
 
edm::ESGetToken< GEMChMap, GEMChMapRcdgemChMapToken_
 
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 51 of file GEMDigiToRawModule.cc.

References gemChMapToken_, and useDBEMap_.

52  : event_type_(pset.getParameter<int>("eventType")),
53  digi_token(consumes<GEMDigiCollection>(pset.getParameter<edm::InputTag>("gemDigi"))),
54  useDBEMap_(pset.getParameter<bool>("useDBEMap")) {
55  produces<FEDRawDataCollection>();
56  if (useDBEMap_) {
57  gemChMapToken_ = esConsumes<GEMChMap, GEMChMapRcd, edm::Transition::BeginRun>();
58  }
59 }
edm::EDGetTokenT< GEMDigiCollection > digi_token
edm::ESGetToken< GEMChMap, GEMChMapRcd > gemChMapToken_

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 61 of file GEMDigiToRawModule.cc.

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

61  {
63  desc.add<edm::InputTag>("gemDigi", edm::InputTag("simMuonGEMDigis"));
64  desc.add<int>("eventType", 0);
65  desc.add<bool>("useDBEMap", false);
66  descriptions.add("gemPackerDefault", desc);
67 }
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 69 of file GEMDigiToRawModule.cc.

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

69  {
70  if (useDBEMap_) {
71  const auto& eMap = iSetup.getData(gemChMapToken_);
72  auto gemChMap = std::make_shared<GEMChMap>(eMap);
73  return gemChMap;
74  } else {
75  // no EMap in DB, using dummy
76  auto gemChMap = std::make_shared<GEMChMap>();
77  gemChMap->setDummy();
78  return gemChMap;
79  }
80 }
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 82 of file GEMDigiToRawModule.cc.

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

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

Member Data Documentation

◆ digi_token

edm::EDGetTokenT<GEMDigiCollection> GEMDigiToRawModule::digi_token
private

Definition at line 43 of file GEMDigiToRawModule.cc.

Referenced by produce().

◆ event_type_

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 44 of file GEMDigiToRawModule.cc.

Referenced by GEMDigiToRawModule(), and globalBeginRun().

◆ useDBEMap_

bool GEMDigiToRawModule::useDBEMap_
private

Definition at line 45 of file GEMDigiToRawModule.cc.

Referenced by GEMDigiToRawModule(), and globalBeginRun().