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< GEMROmap > > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GEMRawToDigiModule (const edm::ParameterSet &pset)
 Constructor. More...
 
std::shared_ptr< GEMROmapglobalBeginRun (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< GEMROmap > >
 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
 
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)
 
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 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 32 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<GEMGEBStatusDigiCollection>("GEBStatus");
28  produces<GEMAMCStatusDigiCollection>("AMCStatus");
29  }
30 }
T getParameter(std::string const &) const
edm::EDGetTokenT< FEDRawDataCollection > fed_token

Member Function Documentation

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

Definition at line 32 of file GEMRawToDigiModule.cc.

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

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

Definition at line 41 of file GEMRawToDigiModule.cc.

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

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

Definition at line 40 of file GEMRawToDigiModule.h.

References fillDescriptions().

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

Implements edm::global::EDProducerBase.

Definition at line 60 of file GEMRawToDigiModule.cc.

References GEMDigi::bx(), officialStyle::chan, GEMROmap::channelNum::chNum, FEDRawData::data(), data, RecoEcal_EventContent_cff::ec, fed_token, GEMROmap::dCoord::gemDetId, edm::Event::getByToken(), edm::Event::getRun(), mps_fire::i, triggerObjects_cff::id, edm::Run::index(), createfilelist::int, GEMROmap::dCoord::iPhi, gen::k, LogDebug, GEMELMap::maxChan_, FEDNumbering::MAXGEMFEDID, GEMELMap::maxVFatGE11_, GEMELMap::maxVFatGE21_, FEDNumbering::MINGEMFEDID, eostools::move(), ecaldqm::nChannels, edm::Event::put(), FEDRawData::size(), GEMDetId::station(), GEMROmap::stripNum::stNum, unPackStatusDigis_, GEMROmap::eCoord::vfatId, GEMROmap::dCoord::vfatType, and globals_cff::x1.

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

61 {
62  auto outGEMDigis = std::make_unique<GEMDigiCollection>();
63  auto outVfatStatus = std::make_unique<GEMVfatStatusDigiCollection>();
64  auto outGEBStatus = std::make_unique<GEMGEBStatusDigiCollection>();
65  auto outAMCStatus = std::make_unique<GEMAMCStatusDigiCollection>();
66 
67  // Take raw from the event
69  iEvent.getByToken( fed_token, fed_buffers );
70 
71  auto gemROMap = runCache(iEvent.getRun().index());
72 
73  for (unsigned int id=FEDNumbering::MINGEMFEDID; id<=FEDNumbering::MAXGEMFEDID; ++id){
74  const FEDRawData& fedData = fed_buffers->FEDData(id);
75 
76  int nWords = fedData.size()/sizeof(uint64_t);
77  LogDebug("GEMRawToDigiModule") <<" words " << nWords;
78  if (nWords<5) continue;
79  const unsigned char * data = fedData.data();
80 
81  auto amc13Event = std::make_unique<AMC13Event>();
82 
83  const uint64_t* word = reinterpret_cast<const uint64_t* >(data);
84 
85  amc13Event->setCDFHeader(*word);
86  amc13Event->setAMC13header(*(++word));
87 
88  // Readout out AMC headers
89  for (unsigned short i = 0; i < amc13Event->nAMC(); ++i)
90  amc13Event->addAMCheader(*(++word));
91 
92  // Readout out AMC payloads
93  for (unsigned short i = 0; i < amc13Event->nAMC(); ++i){
94  auto amcData = std::make_unique<AMCdata>();
95  amcData->setAMCheader1(*(++word));
96  amcData->setAMCheader2(*(++word));
97  amcData->setGEMeventHeader(*(++word));
98  uint16_t amcId = amcData->boardId();
99  uint16_t amcBx = amcData->bx();
100 
101  // Fill GEB
102  for (unsigned short j = 0; j < amcData->gdCount(); ++j){
103  auto gebData = std::make_unique<GEBdata>();
104  gebData->setChamberHeader(*(++word));
105 
106  unsigned int m_nvb = gebData->vwh() / 3; // number of VFAT2 blocks
107  uint16_t gebId = gebData->inputID();
108  GEMDetId gemId(-1,1,1,1,1,0); // temp ID
109  for (unsigned short k = 0; k < m_nvb; k++){
110  auto vfatData = std::make_unique<VFATdata>();
111  vfatData->read_fw(*(++word));
112  vfatData->read_sw(*(++word));
113  vfatData->read_tw(*(++word));
114  gebData->addVFAT(*vfatData);
115 
116  uint16_t bc=vfatData->bc();
117  uint8_t b1010=vfatData->b1010();
118  uint8_t b1100=vfatData->b1100();
119  uint8_t b1110=vfatData->b1110();
120  uint16_t vfatId=vfatData->chipID();
121  uint16_t crc = vfatData->crc();
122  uint16_t crc_check = vfatData->checkCRC();
123  bool Quality = (b1010==10) && (b1100==12) && (b1110==14) && (crc==crc_check);
124 
125  if (crc!=crc_check) edm::LogWarning("GEMRawToDigiModule") << "DIFFERENT CRC :"<<crc<<" "<<crc_check;
126  if (!Quality) edm::LogWarning("GEMRawToDigiModule") << "Quality "<< Quality
127  << " b1010 "<< int(b1010)
128  << " b1100 "<< int(b1100)
129  << " b1110 "<< int(b1110);
130 
131  //check if ChipID exists.
132  GEMROmap::eCoord ec = {amcId, gebId, vfatId};
133 
134  if (!gemROMap->isValidChipID(ec)){
135  edm::LogWarning("GEMRawToDigiModule") << "InValid ChipID :"<<ec.vfatId;
136  continue;
137  }
138 
139  for (int chan = 0; chan < VFATdata::nChannels; ++chan) {
140  uint8_t chan0xf = 0;
141  if (chan < 64) chan0xf = ((vfatData->lsData() >> chan) & 0x1);
142  else chan0xf = ((vfatData->msData() >> (chan-64)) & 0x1);
143 
144  // no hits
145  if(chan0xf==0) continue;
146  GEMROmap::dCoord dc = gemROMap->hitPosition(ec);
147  // strip bx = vfat bx - amc bx
148  int bx = bc-amcBx;
149  gemId = dc.gemDetId;
150 
151  GEMROmap::channelNum chMap = {dc.vfatType, chan};
152  GEMROmap::stripNum stMap = gemROMap->hitPosition(chMap);
153 
154  int maxVFat = GEMELMap::maxVFatGE11_;
155  if (gemId.station() == 2) maxVFat = GEMELMap::maxVFatGE21_;
156  int stripId = stMap.stNum + (dc.iPhi-1)%maxVFat*GEMELMap::maxChan_;
157 
158  GEMDigi digi(stripId,bx);
159  LogDebug("GEMRawToDigiModule") <<" vfatId "<<ec.vfatId
160  <<" gemDetId "<< gemId
161  <<" chan "<< chMap.chNum
162  <<" strip "<< stripId
163  <<" bx "<< digi.bx();
164 
165  outGEMDigis.get()->insertDigi(gemId,digi);
166  }
167 
168  if (unPackStatusDigis_){
169  GEMVfatStatusDigi vfatStatus(vfatData->lsData(), vfatData->msData(),
170  crc, vfatData->crc_calc(),
171  b1010, b1100, b1110, vfatData->flag(),
172  vfatData->isBlockGood());
173  outVfatStatus.get()->insertDigi(gebData->inputID(),vfatStatus);
174  }
175 
176  }
177 
178  gebData->setChamberTrailer(*(++word));
179  if (unPackStatusDigis_){
180  GEMGEBStatusDigi gebStatus(gebData->zeroSupWordsCnt(),
181  gebData->vwh(),
182  gebData->errorC(),
183  gebData->ohCRC(),
184  gebData->vwt(),
185  gebData->inFu(),
186  gebData->inputID(),
187  gebData->stuckd(),
188  gebData->getGEBflag());
189  outGEBStatus.get()->insertDigi(gebData->inputID(),gebStatus);
190  }
191 
192  amcData->addGEB(*gebData);
193  }
194 
195  amcData->setGEMeventTrailer(*(++word));
196  amcData->setAMCTrailer(*(++word));
197 
198  if (unPackStatusDigis_){
199  GEMAMCStatusDigi amcStatus(amcData->amcNum(),
200  amcData->l1A(),
201  amcData->bx(),
202  amcData->dlength(),
203  amcData->fv(),
204  amcData->runType(),
205  amcData->param1(),
206  amcData->param2(),
207  amcData->param3(),
208  amcData->orbitNum(),
209  amcData->boardId(),
210  amcData->gemDAV(),
211  amcData->bStatus(),
212  amcData->gdCount(),
213  amcData->ttsState(),
214  amcData->chamberTimeOut(),
215  amcData->oosGLIB());
216  outAMCStatus.get()->insertDigi(amcData->boardId(), amcStatus);
217  }
218 
219  amc13Event->addAMCpayload(*amcData);
220  }
221 
222  amc13Event->setAMC13trailer(*(++word));
223  amc13Event->setCDFTrailer(*(++word));
224  }
225 
226  iEvent.put(std::move(outGEMDigis));
227  if (unPackStatusDigis_){
228  iEvent.put(std::move(outVfatStatus), "vfatStatus");
229  iEvent.put(std::move(outGEBStatus), "GEBStatus");
230  iEvent.put(std::move(outAMCStatus), "AMCStatus");
231  }
232 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
Run const & getRun() const
Definition: Event.cc:114
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
static const int maxVFatGE21_
Definition: GEMELMap.h:60
edm::EDGetTokenT< FEDRawDataCollection > fed_token
static const int maxChan_
Definition: GEMELMap.h:61
GEMDetId gemDetId
Definition: GEMROmap.h:30
RunIndex index() const
Definition: Run.cc:24
int k[5][pyjets_maxn]
unsigned long long uint64_t
Definition: Time.h:15
static const int maxVFatGE11_
Definition: GEMELMap.h:59
uint16_t vfatId
Definition: GEMROmap.h:12
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 47 of file GEMRawToDigiModule.h.

Referenced by produce().

bool GEMRawToDigiModule::unPackStatusDigis_
private

Definition at line 49 of file GEMRawToDigiModule.h.

Referenced by GEMRawToDigiModule(), and produce().

bool GEMRawToDigiModule::useDBEMap_
private

Definition at line 48 of file GEMRawToDigiModule.h.

Referenced by globalBeginRun().