CMS 3D CMS Logo

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

#include <GEMDigiToRawModule.h>

Inheritance diagram for GEMDigiToRawModule:
edm::global::EDProducer< edm::RunCache< GEMROMapping > > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GEMDigiToRawModule (const edm::ParameterSet &pset)
 Constructor. More...
 
std::shared_ptr< GEMROMappingglobalBeginRun (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< GEMROMapping > >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices 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_
 
bool useDBEMap_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

\based on CSCDigiToRawModule

Author
J. Lee - UoS

Definition at line 27 of file GEMDigiToRawModule.h.

Constructor & Destructor Documentation

◆ GEMDigiToRawModule()

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

Constructor.

Definition at line 23 of file GEMDigiToRawModule.cc.

24  : event_type_(pset.getParameter<int>("eventType")),
25  digi_token(consumes<GEMDigiCollection>(pset.getParameter<edm::InputTag>("gemDigi"))),
26  useDBEMap_(pset.getParameter<bool>("useDBEMap")) {
27  produces<FEDRawDataCollection>();
28 }

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 30 of file GEMDigiToRawModule.cc.

30  {
32  desc.add<edm::InputTag>("gemDigi", edm::InputTag("simMuonGEMDigis"));
33  desc.add<int>("eventType", 0);
34  desc.add<bool>("useDBEMap", false);
35  descriptions.add("gemPackerDefault", desc);
36 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and HLT_2018_cff::InputTag.

◆ globalBeginRun()

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

Definition at line 38 of file GEMDigiToRawModule.cc.

38  {
39  auto gemROmap = std::make_shared<GEMROMapping>();
40  if (useDBEMap_) {
41  edm::ESHandle<GEMeMap> gemEMapRcd;
42  iSetup.get<GEMeMapRcd>().get(gemEMapRcd);
43  auto gemEMap = std::make_unique<GEMeMap>(*(gemEMapRcd.product()));
44  gemEMap->convert(*gemROmap);
45  gemEMap.reset();
46  } else {
47  // no EMap in DB, using dummy
48  auto gemEMap = std::make_unique<GEMeMap>();
49  gemEMap->convertDummy(*gemROmap);
50  gemEMap.reset();
51  }
52  return gemROmap;
53 }

References edm::EventSetup::get(), get, edm::ESHandle< T >::product(), and useDBEMap_.

◆ globalEndRun()

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

Definition at line 35 of file GEMDigiToRawModule.h.

35 {};

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

55  {
56  auto fedRawDataCol = std::make_unique<FEDRawDataCollection>();
57 
59  iEvent.getByToken(digi_token, gemDigis);
60  if (!gemDigis.isValid()) {
61  iEvent.put(std::move(fedRawDataCol));
62  return;
63  }
64 
65  auto gemROMap = runCache(iEvent.getRun().index());
66 
67  std::vector<std::unique_ptr<AMC13Event>> amc13Events;
68  amc13Events.reserve(FEDNumbering::MAXGEMFEDID - FEDNumbering::MINGEMFEDID + 1);
69 
71  std::unique_ptr<AMC13Event> amc13Event = std::make_unique<AMC13Event>();
72 
73  for (uint8_t amcNum = 0; amcNum < GEMeMap::maxAMCs_; ++amcNum) {
74  std::unique_ptr<AMCdata> amcData = std::make_unique<AMCdata>();
75 
76  for (uint8_t gebId = 0; gebId < GEMeMap::maxGEBs_; ++gebId) {
77  std::unique_ptr<GEBdata> gebData = std::make_unique<GEBdata>();
78  GEMROMapping::chamEC geb_ec{fedId, amcNum, gebId};
79 
80  if (!gemROMap->isValidChamber(geb_ec))
81  continue;
82  GEMROMapping::chamDC geb_dc = gemROMap->chamberPos(geb_ec);
83 
84  auto vfats = gemROMap->getVfats(geb_dc.detId);
85  for (auto vfat_ec : vfats) {
86  GEMROMapping::vfatDC vfat_dc = gemROMap->vfatPos(vfat_ec);
87  GEMDetId gemId = vfat_dc.detId;
88  uint16_t vfatId = vfat_ec.vfatAdd;
89 
90  for (uint16_t bc = 0; bc < 2 * GEMeMap::amcBX_; ++bc) {
91  bool hasDigi = false;
92 
93  uint64_t lsData = 0;
94  uint64_t msData = 0;
95 
96  GEMDigiCollection::Range range = gemDigis->get(gemId);
97  for (GEMDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
98  const GEMDigi& digi = (*digiIt);
99  if (digi.bx() != bc - GEMeMap::amcBX_)
100  continue;
101 
102  int localStrip = digi.strip() - vfat_dc.localPhi * GEMeMap::maxChan_;
103 
104  // skip strips not in current vFat
105  if (localStrip < 0 || localStrip > GEMeMap::maxChan_ - 1)
106  continue;
107 
108  hasDigi = true;
109  GEMROMapping::stripNum stMap = {vfat_dc.vfatType, localStrip};
110  GEMROMapping::channelNum chMap = gemROMap->hitPos(stMap);
111 
112  if (chMap.chNum < 64)
113  lsData |= 1UL << chMap.chNum;
114  else
115  msData |= 1UL << (chMap.chNum - 64);
116 
117  LogDebug("GEMDigiToRawModule")
118  << " fed: " << fedId << " amc:" << int(amcNum) << " geb:" << int(gebId)
119  << " vfat:" << vfat_dc.localPhi << ",type: " << vfat_dc.vfatType << " id:" << gemId
120  << " ch:" << chMap.chNum << " st:" << digi.strip() << " bx:" << digi.bx();
121  }
122 
123  if (!hasDigi)
124  continue;
125  // only make vfat with hits
126  auto vfatData = std::make_unique<VFATdata>(geb_dc.vfatVer, bc, 0, vfatId, lsData, msData);
127  gebData->addVFAT(*vfatData);
128  }
129 
130  } // end of vfats in GEB
131 
132  if (!gebData->vFATs()->empty()) {
133  gebData->setChamberHeader(gebData->vFATs()->size() * 3, gebId);
134  gebData->setChamberTrailer(0, 0, gebData->vFATs()->size() * 3);
135  amcData->addGEB(*gebData);
136  }
137 
138  } // end of GEB loop
139 
140  if (!amcData->gebs()->empty()) {
141  amcData->setAMCheader1(0, GEMeMap::amcBX_, 0, amcNum);
142  amcData->setAMCheader2(amcNum, 0, 1);
143  amcData->setGEMeventHeader(amcData->gebs()->size(), 0);
144  amc13Event->addAMCpayload(*amcData);
145  }
146 
147  } // end of AMC loop
148 
149  if (!amc13Event->getAMCpayloads()->empty()) {
150  // CDFHeader
151  uint32_t LV1_id = iEvent.id().event();
152  uint16_t BX_id = iEvent.bunchCrossing();
153  amc13Event->setCDFHeader(event_type_, LV1_id, BX_id, fedId);
154 
155  // AMC13header
156  uint8_t CalTyp = 1;
157  uint8_t nAMC = amc13Event->getAMCpayloads()->size();
158  uint32_t OrN = 2;
159  amc13Event->setAMC13Header(CalTyp, nAMC, OrN);
160 
161  for (unsigned short i = 0; i < amc13Event->nAMC(); ++i) {
162  uint32_t AMC_size = 0;
163  uint8_t Blk_No = 0;
164  uint8_t AMC_No = 0;
165  uint16_t BoardID = 0;
166  amc13Event->addAMCheader(AMC_size, Blk_No, AMC_No, BoardID);
167  }
168 
169  //AMC13 trailer
170  uint8_t Blk_NoT = 0;
171  uint8_t LV1_idT = 0;
172  uint16_t BX_idT = BX_id;
173  amc13Event->setAMC13Trailer(Blk_NoT, LV1_idT, BX_idT);
174  //CDF trailer
175  uint32_t EvtLength = 0;
176  amc13Event->setCDFTrailer(EvtLength);
177  amc13Events.emplace_back(std::move(amc13Event));
178  } // finished making amc13Event data
179 
180  } // end of FED loop
181 
182  // read out amc13Events into fedRawData
183  for (const auto& amc13e : amc13Events) {
184  std::vector<uint64_t> words;
185  words.emplace_back(amc13e->getCDFHeader());
186  words.emplace_back(amc13e->getAMC13Header());
187 
188  for (const auto& w : *amc13e->getAMCheaders())
189  words.emplace_back(w);
190 
191  for (const auto& amc : *amc13e->getAMCpayloads()) {
192  words.emplace_back(amc.getAMCheader1());
193  words.emplace_back(amc.getAMCheader2());
194  words.emplace_back(amc.getGEMeventHeader());
195 
196  for (const auto& geb : *amc.gebs()) {
197  words.emplace_back(geb.getChamberHeader());
198 
199  for (const auto& vfat : *geb.vFATs()) {
200  words.emplace_back(vfat.get_fw());
201  words.emplace_back(vfat.get_sw());
202  words.emplace_back(vfat.get_tw());
203  }
204 
205  words.emplace_back(geb.getChamberTrailer());
206  }
207 
208  words.emplace_back(amc.getGEMeventTrailer());
209  words.emplace_back(amc.getAMCTrailer());
210  }
211 
212  words.emplace_back(amc13e->getAMC13Trailer());
213  words.emplace_back(amc13e->getCDFTrailer());
214 
215  FEDRawData& fedRawData = fedRawDataCol->FEDData(amc13e->sourceId());
216 
217  int dataSize = (words.size()) * sizeof(uint64_t);
218  fedRawData.resize(dataSize);
219 
220  uint64_t* w = reinterpret_cast<uint64_t*>(fedRawData.data());
221  for (const auto& word : words)
222  *(w++) = word;
223 
224  LogDebug("GEMDigiToRawModule") << " words " << words.size();
225  }
226 
227  iEvent.put(std::move(fedRawDataCol));
228 }

References GEMeMap::amcBX_, GEMDigi::bx(), GEMROMapping::channelNum::chNum, GEMROMapping::chamDC::detId, GEMROMapping::vfatDC::detId, digi_token, event_type_, l1tstage2_dqm_sourceclient-live_cfg::fedId, l1t_dqm_sourceclient-live_cfg::fedRawData, mps_fire::i, iEvent, createfilelist::int, edm::HandleBase::isValid(), GEMROMapping::vfatDC::localPhi, LogDebug, GEMeMap::maxAMCs_, GEMeMap::maxChan_, GEMeMap::maxGEBs_, FEDNumbering::MAXGEMFEDID, FEDNumbering::MINGEMFEDID, eostools::move(), FastTimerService_cff::range, GEMDigi::strip(), GEMROMapping::vfatDC::vfatType, GEMROMapping::chamDC::vfatVer, and w.

Member Data Documentation

◆ digi_token

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

Definition at line 42 of file GEMDigiToRawModule.h.

Referenced by produce().

◆ event_type_

int GEMDigiToRawModule::event_type_
private

Definition at line 41 of file GEMDigiToRawModule.h.

Referenced by produce().

◆ useDBEMap_

bool GEMDigiToRawModule::useDBEMap_
private

Definition at line 43 of file GEMDigiToRawModule.h.

Referenced by globalBeginRun().

edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
mps_fire.i
i
Definition: mps_fire.py:355
GEMROMapping::vfatDC::vfatType
int vfatType
Definition: GEMROMapping.h:45
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
GEMROMapping::chamDC
Definition: GEMROMapping.h:26
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
GEMROMapping::stripNum
Definition: GEMROMapping.h:72
edm::Handle< GEMDigiCollection >
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
FEDRawData
Definition: FEDRawData.h:19
FEDNumbering::MINGEMFEDID
Definition: FEDNumbering.h:123
GEMROMapping::chamDC::vfatVer
int vfatVer
Definition: GEMROMapping.h:28
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
GEMDigi::bx
int bx() const
Definition: GEMDigi.h:27
GEMROMapping::vfatDC::detId
GEMDetId detId
Definition: GEMROMapping.h:46
GEMROMapping::vfatDC::localPhi
int localPhi
Definition: GEMROMapping.h:47
GEMDigi::strip
int strip() const
Definition: GEMDigi.h:26
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:188
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GEMeMap::maxGEBs_
static const int maxGEBs_
Definition: GEMeMap.h:64
w
const double w
Definition: UKUtility.cc:23
edm::ESHandle
Definition: DTSurvey.h:22
GEMROMapping::vfatDC
Definition: GEMROMapping.h:44
GEMROMapping::channelNum::chNum
int chNum
Definition: GEMROMapping.h:63
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
GEMeMap::amcBX_
static const int amcBX_
Definition: GEMeMap.h:70
GEMDetId
Definition: GEMDetId.h:17
GEMROMapping::chamEC
Definition: GEMROMapping.h:9
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
GEMDigi
Definition: GEMDigi.h:15
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:88
get
#define get
GEMeMap::maxAMCs_
static const int maxAMCs_
Definition: GEMeMap.h:65
eostools.move
def move(src, dest)
Definition: eostools.py:511
GEMDigiToRawModule::useDBEMap_
bool useDBEMap_
Definition: GEMDigiToRawModule.h:43
GEMROMapping::channelNum
Definition: GEMROMapping.h:61
FEDNumbering::MAXGEMFEDID
Definition: FEDNumbering.h:124
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
amc
Definition: AMCSpec.h:8
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
GEMROMapping::chamDC::detId
GEMDetId detId
Definition: GEMROMapping.h:27
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
GEMDigiToRawModule::digi_token
edm::EDGetTokenT< GEMDigiCollection > digi_token
Definition: GEMDigiToRawModule.h:42
GEMeMap::maxChan_
static const int maxChan_
Definition: GEMeMap.h:69
GEMeMapRcd
Definition: GEMeMapRcd.h:23
GEMDigiToRawModule::event_type_
int event_type_
Definition: GEMDigiToRawModule.h:41
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27