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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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
 
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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

on CSCDigiToRawModule

Author
J. Lee - UoS

Definition at line 27 of file GEMDigiToRawModule.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 23 of file GEMDigiToRawModule.cc.

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

Member Function Documentation

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

Definition at line 31 of file GEMDigiToRawModule.cc.

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

32 {
34  desc.add<edm::InputTag>("gemDigi", edm::InputTag("simMuonGEMDigis"));
35  desc.add<int>("eventType", 0);
36  desc.add<bool>("useDBEMap", false);
37  descriptions.add("gemPackerDefault", desc);
38 }
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 40 of file GEMDigiToRawModule.cc.

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

41 {
42  auto gemROmap = std::make_shared<GEMROMapping>();
43  if (useDBEMap_) {
44  edm::ESHandle<GEMeMap> gemEMapRcd;
45  iSetup.get<GEMeMapRcd>().get(gemEMapRcd);
46  auto gemEMap = std::make_unique<GEMeMap>(*(gemEMapRcd.product()));
47  gemEMap->convert(*gemROmap);
48  gemEMap.reset();
49  }
50  else {
51  // no EMap in DB, using dummy
52  auto gemEMap = std::make_unique<GEMeMap>();
53  gemEMap->convertDummy(*gemROmap);
54  gemEMap.reset();
55  }
56  return gemROmap;
57 }
T const * product() const
Definition: ESHandle.h:86
void GEMDigiToRawModule::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 35 of file GEMDigiToRawModule.h.

References fillDescriptions().

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

References GEMeMap::amcBX_, edm::EventBase::bunchCrossing(), GEMDigi::bx(), GEMROMapping::channelNum::chNum, FEDRawData::data(), GEMROMapping::chamDC::detId, GEMROMapping::vfatDC::detId, digi_token, edm::EventID::event(), event_type_, l1t::stage2::layer2::fedId, edm::Event::getByToken(), edm::Event::getRun(), mps_fire::i, edm::EventBase::id(), edm::Run::index(), createfilelist::int, GEMROMapping::vfatDC::localPhi, LogDebug, GEMeMap::maxAMCs_, GEMeMap::maxChan_, GEMeMap::maxGEBs_, FEDNumbering::MAXGEMFEDID, FEDNumbering::MINGEMFEDID, eostools::move(), edm::Event::put(), FEDRawData::resize(), GEMDigi::strip(), GEMROMapping::vfatDC::vfatType, GEMROMapping::chamDC::vfatVer, and w.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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

Member Data Documentation

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

Definition at line 43 of file GEMDigiToRawModule.h.

Referenced by produce().

int GEMDigiToRawModule::event_type_
private

Definition at line 42 of file GEMDigiToRawModule.h.

Referenced by produce().

bool GEMDigiToRawModule::useDBEMap_
private

Definition at line 44 of file GEMDigiToRawModule.h.

Referenced by globalBeginRun().