CMS 3D CMS Logo

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

#include <GEMRawToDigiModule.h>

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

Public Member Functions

 GEMRawToDigiModule (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< FEDRawDataCollectionfed_token
 
bool unPackStatusDigis_
 
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 33 of file GEMRawToDigiModule.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 19 of file GEMRawToDigiModule.cc.

References unPackStatusDigis_.

19  :
20  fed_token(consumes<FEDRawDataCollection>( pset.getParameter<edm::InputTag>("InputLabel") )),
21  useDBEMap_(pset.getParameter<bool>("useDBEMap")),
22  unPackStatusDigis_(pset.getParameter<bool>("unPackStatusDigis"))
23 {
24  produces<GEMDigiCollection>();
25  if (unPackStatusDigis_) {
26  produces<GEMVfatStatusDigiCollection>("vfatStatus");
27  produces<GEMGEBdataCollection>("gebStatus");
28  produces<GEMAMCdataCollection>("AMCdata");
29  produces<GEMAMC13EventCollection>("AMC13Event");
30  }
31 }
T getParameter(std::string const &) const
edm::EDGetTokenT< FEDRawDataCollection > fed_token

Member Function Documentation

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

Definition at line 33 of file GEMRawToDigiModule.cc.

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

34 {
36  desc.add<edm::InputTag>("InputLabel", edm::InputTag("rawDataCollector"));
37  desc.add<bool>("useDBEMap", false);
38  desc.add<bool>("unPackStatusDigis", false);
39  descriptions.add("muonGEMDigisDefault", desc);
40 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< GEMROMapping > GEMRawToDigiModule::globalBeginRun ( edm::Run const &  ,
edm::EventSetup const &  iSetup 
) const
override

Definition at line 42 of file GEMRawToDigiModule.cc.

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

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

Definition at line 41 of file GEMRawToDigiModule.h.

References fillDescriptions().

41 {};
void GEMRawToDigiModule::produce ( edm::StreamID  iID,
edm::Event iEvent,
edm::EventSetup const &   
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 61 of file GEMRawToDigiModule.cc.

References GEMDigi::bx(), GEMDetId::chamberId(), officialStyle::chan, GEMROMapping::channelNum::chNum, FEDRawData::data(), data, GEMROMapping::chamDC::detId, GEMROMapping::vfatDC::detId, fed_token, l1t::stage2::layer2::fedId, edm::Event::getByToken(), edm::Event::getRun(), mps_fire::i, edm::Run::index(), createfilelist::int, gen::k, GEMROMapping::vfatDC::localPhi, LogDebug, GEMeMap::maxChan_, FEDNumbering::MAXGEMFEDID, FEDNumbering::MINGEMFEDID, eostools::move(), ecaldqm::nChannels, edm::Event::put(), FEDRawData::size(), GEMROMapping::stripNum::stNum, GEMDigi::strip(), unPackStatusDigis_, GEMROMapping::vfatDC::vfatType, GEMROMapping::chamDC::vfatVer, and globals_cff::x1.

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

62 {
63  auto outGEMDigis = std::make_unique<GEMDigiCollection>();
64  auto outVFATStatus = std::make_unique<GEMVfatStatusDigiCollection>();
65  auto outGEBStatus = std::make_unique<GEMGEBdataCollection>();
66  auto outAMCdata = std::make_unique<GEMAMCdataCollection>();
67  auto outAMC13Event = std::make_unique<GEMAMC13EventCollection>();
68 
69  // Take raw from the event
71  iEvent.getByToken( fed_token, fed_buffers );
72 
73  auto gemROMap = runCache(iEvent.getRun().index());
74 
76  const FEDRawData& fedData = fed_buffers->FEDData(fedId);
77 
78  int nWords = fedData.size()/sizeof(uint64_t);
79  LogDebug("GEMRawToDigiModule") <<" words " << nWords;
80 
81  if (nWords<5) continue;
82  const unsigned char * data = fedData.data();
83 
84  auto amc13Event = std::make_unique<AMC13Event>();
85 
86  const uint64_t* word = reinterpret_cast<const uint64_t* >(data);
87 
88  amc13Event->setCDFHeader(*word);
89  amc13Event->setAMC13Header(*(++word));
90 
91  // Readout out AMC headers
92  for (uint8_t i = 0; i < amc13Event->nAMC(); ++i)
93  amc13Event->addAMCheader(*(++word));
94 
95  // Readout out AMC payloads
96  for (uint8_t i = 0; i < amc13Event->nAMC(); ++i) {
97  auto amcData = std::make_unique<AMCdata>();
98  amcData->setAMCheader1(*(++word));
99  amcData->setAMCheader2(*(++word));
100  amcData->setGEMeventHeader(*(++word));
101  uint16_t amcBx = amcData->bx();
102  uint8_t amcNum = amcData->amcNum();
103 
104  // Fill GEB
105  for (uint8_t j = 0; j < amcData->davCnt(); ++j) {
106  auto gebData = std::make_unique<GEBdata>();
107  gebData->setChamberHeader(*(++word));
108 
109  uint8_t gebId = gebData->inputID();
110  GEMROMapping::chamEC geb_ec = {fedId, amcNum, gebId};
111  GEMROMapping::chamDC geb_dc = gemROMap->chamberPos(geb_ec);
112  GEMDetId gemChId = geb_dc.detId;
113 
114  for (uint16_t k = 0; k < gebData->vfatWordCnt()/3; k++) {
115  auto vfatData = std::make_unique<VFATdata>();
116  vfatData->read_fw(*(++word));
117  vfatData->read_sw(*(++word));
118  vfatData->read_tw(*(++word));
119 
120  vfatData->setVersion(geb_dc.vfatVer);
121  uint16_t vfatId = vfatData->vfatId();
122  GEMROMapping::vfatEC vfat_ec = {vfatId, gemChId};
123 
124  // check if ChipID exists.
125  if (!gemROMap->isValidChipID(vfat_ec)) {
126  edm::LogWarning("GEMRawToDigiModule") << "InValid: amcNum "<< int(amcNum)
127  << " gebId "<< int(gebId)
128  << " vfatId "<< int(vfatId)
129  << " vfat Pos "<< int(vfatData->position());
130  continue;
131  }
132  // check vfat data
133  if (vfatData->quality()) {
134  edm::LogWarning("GEMRawToDigiModule") << "Quality "<< int(vfatData->quality())
135  << " b1010 "<< int(vfatData->b1010())
136  << " b1100 "<< int(vfatData->b1100())
137  << " b1110 "<< int(vfatData->b1110());
138  if (vfatData->crc() != vfatData->checkCRC() ) {
139  edm::LogWarning("GEMRawToDigiModule") << "DIFFERENT CRC :"
140  <<vfatData->crc()<<" "<<vfatData->checkCRC();
141  }
142  }
143 
144  GEMROMapping::vfatDC vfat_dc = gemROMap->vfatPos(vfat_ec);
145 
146  vfatData->setPhi(vfat_dc.localPhi);
147  GEMDetId gemId = vfat_dc.detId;
148  uint16_t bc=vfatData->bc();
149  // strip bx = vfat bx - amc bx
150  int bx = bc-amcBx;
151 
152  for (int chan = 0; chan < VFATdata::nChannels; ++chan) {
153  uint8_t chan0xf = 0;
154  if (chan < 64) chan0xf = ((vfatData->lsData() >> chan) & 0x1);
155  else chan0xf = ((vfatData->msData() >> (chan-64)) & 0x1);
156 
157  // no hits
158  if (chan0xf==0) continue;
159 
160  GEMROMapping::channelNum chMap = {vfat_dc.vfatType, chan};
161  GEMROMapping::stripNum stMap = gemROMap->hitPos(chMap);
162 
163  int stripId = stMap.stNum + vfatData->phi()*GEMeMap::maxChan_;
164 
165  GEMDigi digi(stripId,bx);
166 
167  LogDebug("GEMRawToDigiModule")
168  << " fed: " << fedId
169  << " amc:" << int(amcNum)
170  << " geb:" << int(gebId)
171  << " vfat:"<< vfat_dc.localPhi
172  << ",type: "<< vfat_dc.vfatType
173  << " id:"<< gemId
174  << " ch:"<< chMap.chNum
175  << " st:"<< digi.strip()
176  << " bx:"<< digi.bx();
177 
178  outGEMDigis.get()->insertDigi(gemId,digi);
179 
180  }// end of channel loop
181 
182  if (unPackStatusDigis_) {
183  outVFATStatus.get()->insertDigi(gemId, GEMVfatStatusDigi(*vfatData));
184  }
185 
186  } // end of vfat loop
187 
188  gebData->setChamberTrailer(*(++word));
189 
190  if (unPackStatusDigis_) {
191  outGEBStatus.get()->insertDigi(gemChId.chamberId(), (*gebData));
192  }
193 
194  } // end of geb loop
195 
196  amcData->setGEMeventTrailer(*(++word));
197  amcData->setAMCTrailer(*(++word));
198 
199  if (unPackStatusDigis_) {
200  outAMCdata.get()->insertDigi(amcData->boardId(), (*amcData));
201  }
202 
203  } // end of amc loop
204 
205  amc13Event->setAMC13Trailer(*(++word));
206  amc13Event->setCDFTrailer(*(++word));
207 
208  if (unPackStatusDigis_) {
209  outAMC13Event.get()->insertDigi(amc13Event->bxId(), AMC13Event(*amc13Event));
210  }
211 
212  } // end of amc13Event
213 
214  iEvent.put(std::move(outGEMDigis));
215 
216  if (unPackStatusDigis_) {
217  iEvent.put(std::move(outVFATStatus), "vfatStatus");
218  iEvent.put(std::move(outGEBStatus), "gebStatus");
219  iEvent.put(std::move(outAMCdata), "AMCdata");
220  iEvent.put(std::move(outAMC13Event), "AMC13Event");
221  }
222 
223 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Run const & getRun() const
Definition: Event.cc:99
static const int maxChan_
Definition: GEMeMap.h:69
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
edm::EDGetTokenT< FEDRawDataCollection > fed_token
RunIndex index() const
Definition: Run.cc:21
int k[5][pyjets_maxn]
unsigned long long uint64_t
Definition: Time.h:15
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 48 of file GEMRawToDigiModule.h.

Referenced by produce().

bool GEMRawToDigiModule::unPackStatusDigis_
private

Definition at line 50 of file GEMRawToDigiModule.h.

Referenced by GEMRawToDigiModule(), and produce().

bool GEMRawToDigiModule::useDBEMap_
private

Definition at line 49 of file GEMRawToDigiModule.h.

Referenced by globalBeginRun().