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")),
64 produces<GEMDigiCollection>();
66 produces<GEMAMC13StatusCollection>(
"AMC13Status");
67 produces<GEMAMCStatusCollection>(
"AMCStatus");
68 produces<GEMOHStatusCollection>(
"OHStatus");
69 produces<GEMVFATStatusCollection>(
"VFATStatus");
72 gemChMapToken_ = esConsumes<GEMChMap, GEMChMapRcd, edm::Transition::BeginRun>();
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.";
85 desc.add<
bool>(
"useDBEMap",
false);
86 desc.add<
bool>(
"keepDAQStatus",
true);
87 desc.add<
bool>(
"readMultiBX",
false);
88 desc.add<
bool>(
"ge21Off",
false);
91 descriptions.
add(
"muonGEMDigisDefault",
desc);
97 auto gemChMap = std::make_shared<GEMChMap>(eMap);
101 auto gemChMap = std::make_shared<GEMChMap>();
102 gemChMap->setDummy();
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>();
118 auto gemChMap = runCache(
iEvent.getRun().index());
126 if (st_amc13.
isBad()) {
127 LogDebug(
"GEMRawToDigiModule") << st_amc13;
129 outAMC13Status.get()->insertDigi(
fedId, st_amc13);
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();
142 for (
const auto&
amc : *(
amc13->getAMCpayloads())) {
143 uint8_t amcNum =
amc.amcNum();
144 if (!gemChMap->isValidAMC(
fedId, amcNum)) {
150 if (st_amc.isBad()) {
151 LogDebug(
"GEMRawToDigiModule") << st_amc;
153 outAMCStatus.get()->insertDigi(
fedId, st_amc);
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());
163 for (
const auto& optoHybrid : *
amc.gebs()) {
164 uint8_t gebId = optoHybrid.inputID();
166 bool isValidChamber = gemChMap->isValidChamber(
fedId, amcNum, gebId);
167 if (!isValidChamber) {
171 auto geb_dc = gemChMap->chamberPos(
fedId, amcNum, gebId);
173 int chamberType = geb_dc.chamberType;
177 LogDebug(
"GEMRawToDigiModule") << st_oh;
179 outOHStatus.get()->insertDigi(cId, st_oh);
185 for (
auto vfat : *optoHybrid.vFATs()) {
187 if (chamberType < 10)
191 uint16_t vfatId = vfat.vfatId();
193 if (!gemChMap->isValidVFAT(chamberType, vfatId)) {
199 if (st_vfat.
isBad()) {
200 LogDebug(
"GEMRawToDigiModule") << st_vfat;
202 outVFATStatus.get()->insertDigi(cId, st_vfat);
207 int bx(vfat.bc() - amcBx);
212 chan0xf = ((vfat.lsData() >>
chan) & 0
x1);
214 chan0xf = ((vfat.msData() >> (
chan - 64)) & 0x1);
220 auto stMap = gemChMap->getStrip(chamberType, vfatId,
chan);
222 int stripId = stMap.stNum;
223 int ieta = stMap.iEta;
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();
233 outGEMDigis.get()->insertDigi(gemId, digi);
238 outVFATStatus.get()->insertDigi(cId, st_vfat);
244 outOHStatus.get()->insertDigi(cId, st_oh);
250 outAMCStatus.get()->insertDigi(
fedId, st_amc);
256 outAMC13Status.get()->insertDigi(
fedId, st_amc13);
constexpr int station() const
constexpr int region() const
size_t size() const
Lenght of the data buffer in bytes.
Log< level::Error, false > LogError
constexpr int layer() const
std::shared_ptr< GEMChMap > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
constexpr int chamber() const
static const int nChannels
edm::EDGetTokenT< FEDRawDataCollection > fed_token
void globalEndRun(edm::Run const &, edm::EventSetup const &) const override
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
edm::ESGetToken< GEMChMap, GEMChMapRcd > gemChMapToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
constexpr int ring() const
#define DEFINE_FWK_MODULE(type)
bool getData(T &iHolder) const
GEMRawToDigiModule(const edm::ParameterSet &pset)
Constructor.
unsigned long long uint64_t
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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.