CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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< 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
 
 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
 
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)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::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
< GEMDigiCollection
digi_token
 
int event_type_
 
edm::ESGetToken< GEMeMap,
GEMeMapRcd
gemEMapToken_
 
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
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 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)
 
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 29 of file GEMDigiToRawModule.cc.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 52 of file GEMDigiToRawModule.cc.

References gemEMapToken_, and useDBEMap_.

53  : event_type_(pset.getParameter<int>("eventType")),
54  digi_token(consumes<GEMDigiCollection>(pset.getParameter<edm::InputTag>("gemDigi"))),
55  useDBEMap_(pset.getParameter<bool>("useDBEMap")) {
56  produces<FEDRawDataCollection>();
57  if (useDBEMap_) {
58  gemEMapToken_ = esConsumes<GEMeMap, GEMeMapRcd, edm::Transition::BeginRun>();
59  }
60 }
edm::ESGetToken< GEMeMap, GEMeMapRcd > gemEMapToken_
edm::EDGetTokenT< GEMDigiCollection > digi_token
T getParameter(std::string const &) const
Definition: ParameterSet.h:303

Member Function Documentation

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

Definition at line 62 of file GEMDigiToRawModule.cc.

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

62  {
64  desc.add<edm::InputTag>("gemDigi", edm::InputTag("simMuonGEMDigis"));
65  desc.add<int>("eventType", 0);
66  desc.add<bool>("useDBEMap", false);
67  descriptions.add("gemPackerDefault", desc);
68 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< GEMROMapping > GEMDigiToRawModule::globalBeginRun ( edm::Run const &  ,
edm::EventSetup const &  iSetup 
) const
override

Definition at line 70 of file GEMDigiToRawModule.cc.

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

70  {
71  auto gemROmap = std::make_shared<GEMROMapping>();
72  if (useDBEMap_) {
73  const auto& eMap = iSetup.getData(gemEMapToken_);
74  auto gemEMap = std::make_unique<GEMeMap>(eMap);
75  gemEMap->convert(*gemROmap);
76  gemEMap.reset();
77  } else {
78  // no EMap in DB, using dummy
79  auto gemEMap = std::make_unique<GEMeMap>();
80  gemEMap->convertDummy(*gemROmap);
81  gemEMap.reset();
82  }
83  return gemROmap;
84 }
edm::ESGetToken< GEMeMap, GEMeMapRcd > gemEMapToken_
void GEMDigiToRawModule::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 37 of file GEMDigiToRawModule.cc.

37 {};
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 86 of file GEMDigiToRawModule.cc.

References amc, edm::EventBase::bunchCrossing(), GEMDigi::bx(), makePileupJSON::bx, GEMROMapping::channelNum::chNum, FEDRawData::data(), GEMROMapping::chamDC::detId, GEMROMapping::vfatDC::detId, digi_token, edm::EventID::event(), event_type_, l1tstage2_dqm_sourceclient-live_cfg::fedId, edm::Event::getByToken(), edm::Event::getRun(), edm::EventBase::id(), edm::Run::index(), GEMROMapping::vfatDC::localPhi, LogDebug, GEMeMap::maxAMCs_, GEMeMap::maxChan_, GEMeMap::maxGEBs_, FEDNumbering::MAXGEMFEDID, FEDNumbering::MINGEMFEDID, eostools::move(), edm::EventBase::orbitNumber(), edm::Event::put(), sistrip::SpyUtilities::range(), FEDRawData::resize(), cond::persistency::search(), GEMDigi::strip(), GEMROMapping::vfatDC::vfatType, GEMROMapping::chamDC::vfatVer, and w().

86  {
87  auto fedRawDataCol = std::make_unique<FEDRawDataCollection>();
88 
90  iEvent.getByToken(digi_token, gemDigis);
91  if (!gemDigis.isValid()) {
92  iEvent.put(std::move(fedRawDataCol));
93  return;
94  }
95 
96  auto gemROMap = runCache(iEvent.getRun().index());
97 
98  std::vector<std::unique_ptr<GEMAMC13>> amc13s;
100 
101  int LV1_id = iEvent.id().event();
102  uint8_t BX_id(iEvent.bunchCrossing());
103  int OrN = iEvent.orbitNumber();
104 
105  // making map of bx GEMDigiCollection
106  // each bx will be saved as new GEMAMC13, so GEMDigiCollection needs to be split into bx
107  std::map<int, GEMDigiCollection> gemBxMap;
108  for (auto const& etaPart : *gemDigis) {
109  GEMDetId gemId = etaPart.first;
110  const GEMDigiCollection::Range& digis = etaPart.second;
111  for (auto digi = digis.first; digi != digis.second; ++digi) {
112  int bx = digi->bx();
113  auto search = gemBxMap.find(bx);
114  if (search != gemBxMap.end()) {
115  search->second.insertDigi(gemId, *digi);
116  } else {
117  GEMDigiCollection newGDC;
118  newGDC.insertDigi(gemId, *digi);
119  gemBxMap.insert(std::pair<int, GEMDigiCollection>(bx, newGDC));
120  }
121  }
122  }
123 
125  uint32_t amc13EvtLength = 0;
126  std::unique_ptr<GEMAMC13> amc13 = std::make_unique<GEMAMC13>();
127 
128  for (uint8_t amcNum = 0; amcNum <= GEMeMap::maxAMCs_; ++amcNum) {
129  uint32_t amcSize = 0;
130  std::unique_ptr<GEMAMC> amc = std::make_unique<GEMAMC>();
131 
132  for (uint8_t gebId = 0; gebId <= GEMeMap::maxGEBs_; ++gebId) {
133  std::unique_ptr<GEMOptoHybrid> optoH = std::make_unique<GEMOptoHybrid>();
134  GEMROMapping::chamEC geb_ec{fedId, amcNum, gebId};
135 
136  if (!gemROMap->isValidChamber(geb_ec))
137  continue;
138  GEMROMapping::chamDC geb_dc = gemROMap->chamberPos(geb_ec);
139 
140  auto vfats = gemROMap->getVfats(geb_dc.detId);
141  for (auto const& vfat_ec : vfats) {
142  GEMROMapping::vfatDC vfat_dc = gemROMap->vfatPos(vfat_ec);
143  GEMDetId gemId = vfat_dc.detId;
144  uint16_t vfatId = vfat_ec.vfatAdd;
145 
146  for (auto const& gemBx : gemBxMap) {
147  int bc = BX_id + gemBx.first;
148 
149  bool hasDigi = false;
150  uint64_t lsData = 0;
151  uint64_t msData = 0;
152 
153  GEMDigiCollection inBxGemDigis = gemBx.second;
154  const GEMDigiCollection::Range& range = inBxGemDigis.get(gemId);
155  for (GEMDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
156  const GEMDigi& digi = (*digiIt);
157 
158  int localStrip = digi.strip() - vfat_dc.localPhi * GEMeMap::maxChan_;
159 
160  // skip strips not in current vFat
161  if (localStrip < 0 || localStrip > GEMeMap::maxChan_ - 1)
162  continue;
163 
164  hasDigi = true;
165  GEMROMapping::stripNum stMap = {vfat_dc.vfatType, localStrip};
166  GEMROMapping::channelNum chMap = gemROMap->hitPos(stMap);
167 
168  if (chMap.chNum < 64)
169  lsData |= 1UL << chMap.chNum;
170  else
171  msData |= 1UL << (chMap.chNum - 64);
172 
173  LogDebug("GEMDigiToRawModule")
174  << "fed: " << fedId << " amc:" << int(amcNum) << " geb:" << int(gebId) << " vfat id:" << int(vfatId)
175  << ",type:" << vfat_dc.vfatType << " id:" << gemId << " ch:" << chMap.chNum << " st:" << digi.strip()
176  << " bx:" << digi.bx();
177  }
178 
179  if (!hasDigi)
180  continue;
181  // only make vfat with hits
182  amcSize += 3;
183  auto vfat = std::make_unique<GEMVFAT>(geb_dc.vfatVer, bc, LV1_id, vfatId, lsData, msData);
184  optoH->addVFAT(*vfat);
185  }
186  } // end of vfats in GEB
187 
188  if (!optoH->vFATs()->empty()) {
189  amcSize += 2;
190  optoH->setChamberHeader(optoH->vFATs()->size() * 3, gebId);
191  optoH->setChamberTrailer(LV1_id, BX_id, optoH->vFATs()->size() * 3);
192  amc->addGEB(*optoH);
193  }
194  } // end of GEB loop
195 
196  if (!amc->gebs()->empty()) {
197  amcSize += 5;
198  amc->setAMCheader1(amcSize, BX_id, LV1_id, amcNum);
199  amc->setAMCheader2(amcNum, OrN, 1);
200  amc->setGEMeventHeader(amc->gebs()->size(), 0);
201  amc13->addAMCpayload(*amc);
202  // AMC header in GEMAMC13
203  amc13->addAMCheader(amcSize, 0, amcNum, 0);
204  amc13EvtLength += amcSize + 1; // AMC data size + AMC header size
205  }
206  } // end of AMC loop
207 
208  if (!amc13->getAMCpayloads()->empty()) {
209  // CDFHeader
210  amc13->setCDFHeader(event_type_, LV1_id, BX_id, fedId);
211  // AMC13header
212  uint8_t nAMC = amc13->getAMCpayloads()->size();
213  amc13->setAMC13Header(1, nAMC, OrN);
214  amc13->setAMC13Trailer(BX_id, LV1_id, BX_id);
215  //CDF trailer
216  uint32_t EvtLength = amc13EvtLength + 4; // 2 header and 2 trailer
217  amc13->setCDFTrailer(EvtLength);
218  amc13s.emplace_back(std::move(amc13));
219  } // finished making amc13 data
220  } // end of FED loop
221 
222  // read out amc13s into fedRawData
223  for (const auto& amc13e : amc13s) {
224  std::vector<uint64_t> words;
225  words.emplace_back(amc13e->getCDFHeader());
226  words.emplace_back(amc13e->getAMC13Header());
227 
228  for (const auto& w : *amc13e->getAMCheaders())
229  words.emplace_back(w);
230 
231  for (const auto& amc : *amc13e->getAMCpayloads()) {
232  words.emplace_back(amc.getAMCheader1());
233  words.emplace_back(amc.getAMCheader2());
234  words.emplace_back(amc.getGEMeventHeader());
235 
236  for (const auto& geb : *amc.gebs()) {
237  words.emplace_back(geb.getChamberHeader());
238 
239  for (const auto& vfat : *geb.vFATs()) {
240  words.emplace_back(vfat.get_fw());
241  words.emplace_back(vfat.get_sw());
242  words.emplace_back(vfat.get_tw());
243  }
244 
245  words.emplace_back(geb.getChamberTrailer());
246  }
247 
248  words.emplace_back(amc.getGEMeventTrailer());
249  words.emplace_back(amc.getAMCTrailer());
250  }
251 
252  words.emplace_back(amc13e->getAMC13Trailer());
253  words.emplace_back(amc13e->getCDFTrailer());
254 
255  FEDRawData& fedRawData = fedRawDataCol->FEDData(amc13e->sourceId());
256 
257  int dataSize = (words.size()) * sizeof(uint64_t);
258  fedRawData.resize(dataSize);
259 
260  uint64_t* w = reinterpret_cast<uint64_t*>(fedRawData.data());
261  for (const auto& word : words) {
262  *(w++) = word;
263  }
264  LogDebug("GEMDigiToRawModule") << "fedId:" << amc13e->sourceId() << " words:" << words.size();
265  }
266 
267  iEvent.put(std::move(fedRawDataCol));
268 }
EventNumber_t event() const
Definition: EventID.h:40
edm::EDGetTokenT< GEMDigiCollection > digi_token
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:21
int16_t bx() const
Definition: GEMDigi.h:27
int bunchCrossing() const
Definition: EventBase.h:64
Run const & getRun() const
Definition: Event.cc:112
static const int maxChan_
Definition: GEMeMap.h:72
const uint16_t range(const Frame &aFrame)
uint64_t word
double amc
Definition: hdecay.h:20
uint16_t strip() const
Definition: GEMDigi.h:26
void resize(size_t newsize)
Definition: FEDRawData.cc:28
def move
Definition: eostools.py:511
RunIndex index() const
Definition: Run.cc:26
int orbitNumber() const
Definition: EventBase.h:65
static const int maxAMCs_
Definition: GEMeMap.h:65
static const int maxGEBs_
Definition: GEMeMap.h:62
unsigned long long uint64_t
Definition: Time.h:13
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
edm::EventID id() const
Definition: EventBase.h:59
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
T w() const
#define LogDebug(id)

Member Data Documentation

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

Definition at line 44 of file GEMDigiToRawModule.cc.

Referenced by produce().

int GEMDigiToRawModule::event_type_
private

Definition at line 43 of file GEMDigiToRawModule.cc.

Referenced by produce().

edm::ESGetToken<GEMeMap, GEMeMapRcd> GEMDigiToRawModule::gemEMapToken_
private

Definition at line 45 of file GEMDigiToRawModule.cc.

Referenced by GEMDigiToRawModule(), and globalBeginRun().

bool GEMDigiToRawModule::useDBEMap_
private

Definition at line 46 of file GEMDigiToRawModule.cc.

Referenced by GEMDigiToRawModule(), and globalBeginRun().