CMS 3D CMS Logo

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

Public Member Functions

 GEMRawToDigiModule (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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept 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< FEDRawDataCollectionfed_token
 
unsigned int fedIdEnd_
 
unsigned int fedIdStart_
 
bool ge21Off_
 
edm::ESGetToken< GEMChMap, GEMChMapRcdgemChMapToken_
 
std::unique_ptr< GEMRawToDigigemRawToDigi_
 
bool keepDAQStatus_
 
bool readMultiBX_
 
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 31 of file GEMRawToDigiModule.cc.

Constructor & Destructor Documentation

◆ GEMRawToDigiModule()

GEMRawToDigiModule::GEMRawToDigiModule ( const edm::ParameterSet pset)

Constructor.

Definition at line 55 of file GEMRawToDigiModule.cc.

References fedIdEnd_, fedIdStart_, ge21Off_, gemChMapToken_, keepDAQStatus_, FEDNumbering::MAXGEMFEDID, FEDNumbering::MINGE21FEDID, FEDNumbering::MINGEMFEDID, and useDBEMap_.

56  : fed_token(consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("InputLabel"))),
57  useDBEMap_(pset.getParameter<bool>("useDBEMap")),
58  keepDAQStatus_(pset.getParameter<bool>("keepDAQStatus")),
59  readMultiBX_(pset.getParameter<bool>("readMultiBX")),
60  ge21Off_(pset.getParameter<bool>("ge21Off")),
61  fedIdStart_(pset.getParameter<unsigned int>("fedIdStart")),
62  fedIdEnd_(pset.getParameter<unsigned int>("fedIdEnd")),
63  gemRawToDigi_(std::make_unique<GEMRawToDigi>()) {
64  produces<GEMDigiCollection>();
65  if (keepDAQStatus_) {
66  produces<GEMAMC13StatusCollection>("AMC13Status");
67  produces<GEMAMCStatusCollection>("AMCStatus");
68  produces<GEMOHStatusCollection>("OHStatus");
69  produces<GEMVFATStatusCollection>("VFATStatus");
70  }
71  if (useDBEMap_) {
72  gemChMapToken_ = esConsumes<GEMChMap, GEMChMapRcd, edm::Transition::BeginRun>();
73  }
76  } else if (ge21Off_) {
77  edm::LogError("InvalidSettings") << "Turning GE2/1 off requires changing the FEDIDs the GEM unpacker looks at. If "
78  "you wish to set the FEDIDs yourself, don't use the ge21Off switch.";
79  }
80 }
Log< level::Error, false > LogError
edm::EDGetTokenT< FEDRawDataCollection > fed_token
edm::ESGetToken< GEMChMap, GEMChMapRcd > gemChMapToken_
std::unique_ptr< GEMRawToDigi > gemRawToDigi_

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 82 of file GEMRawToDigiModule.cc.

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

82  {
84  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
85  desc.add<bool>("useDBEMap", false);
86  desc.add<bool>("keepDAQStatus", true);
87  desc.add<bool>("readMultiBX", false);
88  desc.add<bool>("ge21Off", false);
89  desc.add<unsigned int>("fedIdStart", FEDNumbering::MINGEMFEDID);
90  desc.add<unsigned int>("fedIdEnd", FEDNumbering::MAXGEMFEDID);
91  descriptions.add("muonGEMDigisDefault", desc);
92 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ globalBeginRun()

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

Definition at line 94 of file GEMRawToDigiModule.cc.

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

94  {
95  if (useDBEMap_) {
96  const auto& eMap = iSetup.getData(gemChMapToken_);
97  auto gemChMap = std::make_shared<GEMChMap>(eMap);
98  return gemChMap;
99  } else {
100  // no EMap in DB, using dummy
101  auto gemChMap = std::make_shared<GEMChMap>();
102  gemChMap->setDummy();
103  return gemChMap;
104  }
105 }
edm::ESGetToken< GEMChMap, GEMChMapRcd > gemChMapToken_

◆ globalEndRun()

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

Definition at line 39 of file GEMRawToDigiModule.cc.

39 {};

◆ produce()

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

Implements edm::global::EDProducerBase.

Definition at line 107 of file GEMRawToDigiModule.cc.

References amc, nano_mu_digi_cff::bx, GEMDetId::chamber(), nano_mu_digi_cff::chamberType, officialStyle::chan, FEDRawData::data(), fed_token, l1tstage2_dqm_sourceclient-live_cfg::fedId, fedIdEnd_, fedIdStart_, gemRawToDigi_, hcalRecHitTable_cff::ieta, iEvent, createfilelist::int, GEMAMC13Status::inValidAMC(), GEMOHStatus::inValidVFAT(), GEMAMC13Status::isBad(), GEMVFATStatus::isBad(), GEMOHStatus::isBad(), keepDAQStatus_, GEMDetId::layer(), LogDebug, eostools::move(), GEMVFAT::nChannels, l1ctLayer2EG_cff::nWords, readMultiBX_, GEMDetId::region(), GEMDetId::ring(), FEDRawData::size(), GEMDetId::station(), and testProducerWithPsetDescEmpty_cfi::x1.

107  {
108  auto outGEMDigis = std::make_unique<GEMDigiCollection>();
109  auto outAMC13Status = std::make_unique<GEMAMC13StatusCollection>();
110  auto outAMCStatus = std::make_unique<GEMAMCStatusCollection>();
111  auto outOHStatus = std::make_unique<GEMOHStatusCollection>();
112  auto outVFATStatus = std::make_unique<GEMVFATStatusCollection>();
113 
114  // Take raw from the event
116  iEvent.getByToken(fed_token, fed_buffers);
117 
118  auto gemChMap = runCache(iEvent.getRun().index());
119 
120  for (unsigned int fedId = fedIdStart_; fedId <= fedIdEnd_; ++fedId) {
121  const FEDRawData& fedData = fed_buffers->FEDData(fedId);
122 
123  int nWords = fedData.size() / sizeof(uint64_t);
124  LogDebug("GEMRawToDigiModule") << "fedId:" << fedId << " words: " << nWords;
125  GEMAMC13Status st_amc13(fedData);
126  if (st_amc13.isBad()) {
127  LogDebug("GEMRawToDigiModule") << st_amc13;
128  if (keepDAQStatus_) {
129  outAMC13Status.get()->insertDigi(fedId, st_amc13);
130  }
131  continue;
132  }
133 
134  const uint64_t* word = reinterpret_cast<const uint64_t*>(fedData.data());
135  auto amc13 = gemRawToDigi_->convertWordToGEMAMC13(word);
136  LogDebug("GEMRawToDigiModule") << "Event bx:" << iEvent.bunchCrossing() << " lv1Id:" << iEvent.id().event()
137  << " orbitNumber:" << iEvent.orbitNumber();
138  LogDebug("GEMRawToDigiModule") << "AMC13 bx:" << amc13->bunchCrossing() << " lv1Id:" << int(amc13->lv1Id())
139  << " orbitNumber:" << amc13->orbitNumber();
140 
141  // Read AMC data
142  for (const auto& amc : *(amc13->getAMCpayloads())) {
143  uint8_t amcNum = amc.amcNum();
144  if (!gemChMap->isValidAMC(fedId, amcNum)) {
145  st_amc13.inValidAMC();
146  continue;
147  }
148 
149  GEMAMCStatus st_amc(amc13.get(), amc);
150  if (st_amc.isBad()) {
151  LogDebug("GEMRawToDigiModule") << st_amc;
152  if (keepDAQStatus_) {
153  outAMCStatus.get()->insertDigi(fedId, st_amc);
154  }
155  continue;
156  }
157 
158  uint16_t amcBx = amc.bunchCrossing();
159  LogDebug("GEMRawToDigiModule") << "AMC no.:" << int(amc.amcNum()) << " bx:" << int(amc.bunchCrossing())
160  << " lv1Id:" << int(amc.lv1Id()) << " orbitNumber:" << int(amc.orbitNumber());
161 
162  // Read GEB data
163  for (const auto& optoHybrid : *amc.gebs()) {
164  uint8_t gebId = optoHybrid.inputID();
165 
166  bool isValidChamber = gemChMap->isValidChamber(fedId, amcNum, gebId);
167  if (!isValidChamber) {
168  st_amc.inValidOH();
169  continue;
170  }
171  auto geb_dc = gemChMap->chamberPos(fedId, amcNum, gebId);
172  GEMDetId cId(geb_dc.detId);
173  int chamberType = geb_dc.chamberType;
174 
175  GEMOHStatus st_oh(optoHybrid, chamberType);
176  if (st_oh.isBad()) {
177  LogDebug("GEMRawToDigiModule") << st_oh;
178  if (keepDAQStatus_) {
179  outOHStatus.get()->insertDigi(cId, st_oh);
180  }
181  continue;
182  }
183 
184  //Read vfat data
185  for (auto vfat : *optoHybrid.vFATs()) {
186  // set vfat fw version
187  if (chamberType < 10)
188  vfat.setVersion(2);
189  else
190  vfat.setVersion(3);
191  uint16_t vfatId = vfat.vfatId();
192 
193  if (!gemChMap->isValidVFAT(chamberType, vfatId)) {
194  st_oh.inValidVFAT();
195  continue;
196  }
197 
198  GEMVFATStatus st_vfat(amc, optoHybrid, vfat, chamberType, readMultiBX_);
199  if (st_vfat.isBad()) {
200  LogDebug("GEMRawToDigiModule") << st_vfat;
201  if (keepDAQStatus_) {
202  outVFATStatus.get()->insertDigi(cId, st_vfat);
203  }
204  continue;
205  }
206 
207  int bx(vfat.bc() - amcBx);
208 
209  for (int chan = 0; chan < GEMVFAT::nChannels; ++chan) {
210  uint8_t chan0xf = 0;
211  if (chan < 64)
212  chan0xf = ((vfat.lsData() >> chan) & 0x1);
213  else
214  chan0xf = ((vfat.msData() >> (chan - 64)) & 0x1);
215 
216  // no hits
217  if (chan0xf == 0)
218  continue;
219 
220  auto stMap = gemChMap->getStrip(chamberType, vfatId, chan);
221 
222  int stripId = stMap.stNum;
223  int ieta = stMap.iEta;
224 
225  GEMDetId gemId(cId.region(), cId.ring(), cId.station(), cId.layer(), cId.chamber(), ieta);
226 
227  GEMDigi digi(stripId, bx);
228 
229  LogDebug("GEMRawToDigiModule") << "fed: " << fedId << " amc:" << int(amcNum) << " geb:" << int(gebId)
230  << " vfat id:" << int(vfatId) << ",type:" << chamberType << " id:" << gemId
231  << " ch:" << chan << " st:" << digi.strip() << " bx:" << digi.bx();
232 
233  outGEMDigis.get()->insertDigi(gemId, digi);
234 
235  } // end of channel loop
236 
237  if (keepDAQStatus_) {
238  outVFATStatus.get()->insertDigi(cId, st_vfat);
239  }
240 
241  } // end of vfat loop
242 
243  if (keepDAQStatus_) {
244  outOHStatus.get()->insertDigi(cId, st_oh);
245  }
246 
247  } // end of optohybrid loop
248 
249  if (keepDAQStatus_) {
250  outAMCStatus.get()->insertDigi(fedId, st_amc);
251  }
252 
253  } // end of amc loop
254 
255  if (keepDAQStatus_) {
256  outAMC13Status.get()->insertDigi(fedId, st_amc13);
257  }
258 
259  } // end of amc13
260 
261  iEvent.put(std::move(outGEMDigis));
262 
263  if (keepDAQStatus_) {
264  iEvent.put(std::move(outAMC13Status), "AMC13Status");
265  iEvent.put(std::move(outAMCStatus), "AMCStatus");
266  iEvent.put(std::move(outOHStatus), "OHStatus");
267  iEvent.put(std::move(outVFATStatus), "VFATStatus");
268  }
269 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
static const int nChannels
Definition: GEMVFAT.h:117
edm::EDGetTokenT< FEDRawDataCollection > fed_token
uint64_t word
int iEvent
Definition: GenABIO.cc:224
double amc
Definition: hdecay.h:20
unsigned long long uint64_t
Definition: Time.h:13
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
std::unique_ptr< GEMRawToDigi > gemRawToDigi_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
Definition: AMCSpec.h:8
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ fed_token

edm::EDGetTokenT<FEDRawDataCollection> GEMRawToDigiModule::fed_token
private

Definition at line 45 of file GEMRawToDigiModule.cc.

Referenced by produce().

◆ fedIdEnd_

unsigned int GEMRawToDigiModule::fedIdEnd_
private

Definition at line 48 of file GEMRawToDigiModule.cc.

Referenced by GEMRawToDigiModule(), and produce().

◆ fedIdStart_

unsigned int GEMRawToDigiModule::fedIdStart_
private

Definition at line 48 of file GEMRawToDigiModule.cc.

Referenced by GEMRawToDigiModule(), and produce().

◆ ge21Off_

bool GEMRawToDigiModule::ge21Off_
private

Definition at line 47 of file GEMRawToDigiModule.cc.

Referenced by GEMRawToDigiModule().

◆ gemChMapToken_

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

Definition at line 46 of file GEMRawToDigiModule.cc.

Referenced by GEMRawToDigiModule(), and globalBeginRun().

◆ gemRawToDigi_

std::unique_ptr<GEMRawToDigi> GEMRawToDigiModule::gemRawToDigi_
private

Definition at line 49 of file GEMRawToDigiModule.cc.

Referenced by produce().

◆ keepDAQStatus_

bool GEMRawToDigiModule::keepDAQStatus_
private

Definition at line 47 of file GEMRawToDigiModule.cc.

Referenced by GEMRawToDigiModule(), and produce().

◆ readMultiBX_

bool GEMRawToDigiModule::readMultiBX_
private

Definition at line 47 of file GEMRawToDigiModule.cc.

Referenced by produce().

◆ useDBEMap_

bool GEMRawToDigiModule::useDBEMap_
private

Definition at line 47 of file GEMRawToDigiModule.cc.

Referenced by GEMRawToDigiModule(), and globalBeginRun().