CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
omtf::OmtfUnpacker Class Reference
Inheritance diagram for omtf::OmtfUnpacker:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (const edm::Run &run, const edm::EventSetup &es) override
 
 OmtfUnpacker (const edm::ParameterSet &pset)
 
void produce (edm::Event &ev, const edm::EventSetup &es) override
 
 ~OmtfUnpacker () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::ParameterSet theConfig
 
CscUnpacker theCscUnpacker
 
DtUnpacker theDtUnpacker
 
unsigned long theEventCounter
 
edm::EDGetTokenT< FEDRawDataCollectiontheFedDataToken
 
MuonUnpacker theMuonUnpacker
 
std::string theOutputTag
 
RpcUnpacker theRpcUnpacker
 
bool theSkipCsc
 
bool theSkipDt
 
bool theSkipMuon
 
bool theSkipRpc
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 48 of file OmtfUnpacker.cc.

Constructor & Destructor Documentation

omtf::OmtfUnpacker::OmtfUnpacker ( const edm::ParameterSet pset)

Definition at line 76 of file OmtfUnpacker.cc.

References edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theFedDataToken, theOutputTag, theSkipCsc, theSkipDt, theSkipMuon, and theSkipRpc.

76  : theConfig(pset) {
77  theOutputTag = pset.getParameter<std::string>("outputTag");
78 
79  produces<RPCDigiCollection>(theOutputTag);
80  produces<CSCCorrelatedLCTDigiCollection>(theOutputTag);
81  produces<l1t::RegionalMuonCandBxCollection>(theOutputTag);
82  produces<L1MuDTChambPhContainer>(theOutputTag);
83  produces<L1MuDTChambThContainer>(theOutputTag);
84 
85  theSkipDt = pset.getParameter<bool>("skipDt");
86  theSkipRpc = pset.getParameter<bool>("skipRpc");
87  theSkipCsc = pset.getParameter<bool>("skipCsc");
88  theSkipMuon = pset.getParameter<bool>("skipMuon");
89 
90  theFedDataToken = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("inputLabel"));
91  }
T getParameter(std::string const &) const
edm::EDGetTokenT< FEDRawDataCollection > theFedDataToken
Definition: OmtfUnpacker.cc:63
std::string theOutputTag
Definition: OmtfUnpacker.cc:71
edm::ParameterSet theConfig
Definition: OmtfUnpacker.cc:70
omtf::OmtfUnpacker::~OmtfUnpacker ( )
inlineoverride

Definition at line 52 of file OmtfUnpacker.cc.

References beginRun(), ev, fillDescriptions(), produce(), and writedatasetfile::run.

52 {}

Member Function Documentation

void omtf::OmtfUnpacker::beginRun ( const edm::Run run,
const edm::EventSetup es 
)
override

Definition at line 106 of file OmtfUnpacker.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), omtf::CscUnpacker::init(), omtf::RpcUnpacker::init(), AlCaHLTBitMon_QueryRunRegistry::string, theConfig, theCscUnpacker, theRpcUnpacker, theSkipCsc, and theSkipRpc.

Referenced by ~OmtfUnpacker().

106  {
107  //
108  // rpc unpacker
109  //
110  if (!theSkipRpc) {
111  if (theConfig.getParameter<bool>("useRpcConnectionFile")) {
113  } else {
114  theRpcUnpacker.init(es);
115  }
116  }
117 
118  //
119  // csc unpacker
120  //
121  if (!theSkipCsc)
123  }
T getParameter(std::string const &) const
void init(const edm::EventSetup &es)
RpcUnpacker theRpcUnpacker
Definition: OmtfUnpacker.cc:65
std::string fullPath() const
Definition: FileInPath.cc:163
edm::ParameterSet theConfig
Definition: OmtfUnpacker.cc:70
CscUnpacker theCscUnpacker
Definition: OmtfUnpacker.cc:66
void omtf::OmtfUnpacker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 93 of file OmtfUnpacker.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), HLT_2018_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ~OmtfUnpacker().

93  {
95  desc.add<edm::InputTag>("inputLabel", edm::InputTag("rawDataCollector"));
96  desc.add<bool>("skipRpc", false);
97  desc.add<bool>("skipCsc", false);
98  desc.add<bool>("skipDt", false);
99  desc.add<bool>("skipMuon", false);
100  desc.add<bool>("useRpcConnectionFile", false);
101  desc.add<std::string>("rpcConnectionFile", "");
102  desc.add<std::string>("outputTag", "");
103  descriptions.add("omtfUnpacker", desc);
104  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void omtf::OmtfUnpacker::produce ( edm::Event ev,
const edm::EventSetup es 
)
override

Definition at line 125 of file OmtfUnpacker.cc.

References FEDHeader::bxID(), amc13::Header::check(), FEDHeader::check(), FEDTrailer::check(), FEDTrailer::crc(), omtf::DataWord64::csc, FEDRawData::data(), debug, edm::MessageDrop::debugEnabled, DEFINE_FWK_MODULE, omtf::DataWord64::dt, FEDTrailer::evtStatus(), FEDRawDataCollection::FEDData(), l1tstage2_dqm_sourceclient-live_cfg::fedId, FEDTrailer::fragmentLength(), amc::BlockHeader::getAMCNumber(), amc::Header::getAMCNumber(), amc13::Trailer::getBlock(), amc::BlockHeader::getBoardID(), amc13::Trailer::getBX(), amc13::Trailer::getCRC(), amc13::Header::getFormatVersion(), amc13::Trailer::getLV1ID(), amc13::Header::getNumberOfAMCs(), amc13::Header::getOrbitNumber(), amc::BlockHeader::getSize(), RecoTauValidation_cfi::header, edm::MessageDrop::instance(), LogDebug, LogTrace, FEDHeader::lvl1ID(), FEDHeader::moreHeaders(), FEDTrailer::moreTrailers(), eostools::move(), omtf::DataWord64::omtf, amc13::Packet::parse(), amc13::Packet::payload(), amc::BlockHeader::raw(), amc::Header::raw(), l1tstage2_dqm_sourceclient-live_cfg::rawData, omtf::DataWord64::rpc, FEDRawData::size(), FEDHeader::sourceID(), str, theCscUnpacker, theDtUnpacker, theEventCounter, theFedDataToken, theMuonUnpacker, theOutputTag, theRpcUnpacker, theSkipCsc, theSkipDt, theSkipMuon, theSkipRpc, FEDHeader::triggerType(), FEDTrailer::ttsBits(), omtf::DataWord64::type(), omtf::DtUnpacker::unpack(), omtf::MuonUnpacker::unpack(), omtf::CscUnpacker::unpack(), omtf::RpcUnpacker::unpack(), and FEDHeader::version().

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

125  {
127  theEventCounter++;
128  if (debug)
129  LogDebug("OmtfUnpacker::produce") << "Beginning To Unpack Event: " << theEventCounter;
130 
131  edm::Handle<FEDRawDataCollection> allFEDRawData;
132  event.getByToken(theFedDataToken, allFEDRawData);
133 
134  auto producedRPCDigis = std::make_unique<RPCDigiCollection>();
135  auto producedCscLctDigis = std::make_unique<CSCCorrelatedLCTDigiCollection>();
136  auto producedMuonDigis = std::make_unique<l1t::RegionalMuonCandBxCollection>();
137  producedMuonDigis->setBXRange(-3, 4);
138  auto producedDTPhDigis = std::make_unique<L1MuDTChambPhContainer>();
139  auto producedDTThDigis = std::make_unique<L1MuDTChambThContainer>();
140  std::vector<L1MuDTChambPhDigi> phi_Container;
141  std::vector<L1MuDTChambThDigi> the_Container;
142 
143  for (int fedId = 1380; fedId <= 1381; ++fedId) {
144  const FEDRawData& rawData = allFEDRawData->FEDData(fedId);
145  unsigned int nWords = rawData.size() / sizeof(Word64);
146  LogTrace("") << "FED : " << fedId << " words: " << nWords;
147  if (nWords == 0)
148  continue;
149 
150  //
151  // FED header
152  //
153  const Word64* header = reinterpret_cast<const Word64*>(rawData.data());
154  FEDHeader fedHeader(reinterpret_cast<const unsigned char*>(header));
155  if (!fedHeader.check()) {
156  LogTrace("") << " ** PROBLEM **, header.check() failed, break";
157  break;
158  }
159  if (fedHeader.sourceID() != fedId) {
160  LogTrace("") << " ** PROBLEM **, fedHeader.sourceID() != fedId"
161  << "fedId = " << fedId << " sourceID=" << fedHeader.sourceID();
162  }
163  int triggerBX = fedHeader.bxID();
164  if (debug) {
165  std::ostringstream str;
166  str << " header: " << *reinterpret_cast<const std::bitset<64>*>(header) << std::endl;
167  str << " header triggerType: " << fedHeader.triggerType() << std::endl;
168  str << " header lvl1ID: " << fedHeader.lvl1ID() << std::endl;
169  str << " header bxID: " << fedHeader.bxID() << std::endl;
170  str << " header sourceID: " << fedHeader.sourceID() << std::endl;
171  str << " header version: " << fedHeader.version() << std::endl;
172  str << " header more : " << fedHeader.moreHeaders() << std::endl;
173  str << " triggerBx " << triggerBX << std::endl;
174  LogTrace("") << str.str();
175  }
176 
177  //
178  // FED trailer
179  //
180  const Word64* trailer = reinterpret_cast<const Word64*>(rawData.data()) + (nWords - 1);
181  trailer++;
182  bool moreTrailers = true;
183  while (moreTrailers) {
184  trailer--;
185  FEDTrailer fedTrailer(reinterpret_cast<const unsigned char*>(trailer));
186  if (!fedTrailer.check()) {
187  if (debug)
188  LogTrace("") << " ** PROBLEM **, trailer.check() failed, break";
189  break;
190  }
191  if (fedTrailer.fragmentLength() != nWords) {
192  if (debug)
193  LogTrace("") << " ** PROBLEM **, fedTrailer.fragmentLength()!= nWords, break";
194  break;
195  }
196  moreTrailers = fedTrailer.moreTrailers();
197  if (debug) {
198  std::ostringstream str;
199  str << " trailer: " << *reinterpret_cast<const std::bitset<64>*>(trailer) << std::endl;
200  str << " trailer lenght: " << fedTrailer.fragmentLength() << std::endl;
201  str << " trailer crc: " << fedTrailer.crc() << std::endl;
202  str << " trailer evtStatus: " << fedTrailer.evtStatus() << std::endl;
203  str << " trailer ttsBits: " << fedTrailer.ttsBits() << std::endl;
204  LogTrace("") << str.str();
205  }
206  }
207 
208  //
209  // dump all FED data for debug
210  //
211  if (debug) {
212  std::ostringstream str;
213  for (const Word64* word = header + 1; word != trailer; word++) {
214  str << " data: " << *reinterpret_cast<const std::bitset<64>*>(word) << std::endl;
215  }
216  LogTrace("") << str.str();
217  }
218 
219  //
220  // AMC13 header
221  //
222  const Word64* headerAmc13raw = header + 1;
223  amc13::Header headerAmc13(headerAmc13raw);
224  if (debug) {
225  std::ostringstream str;
226  str << " headerAMC13: " << *reinterpret_cast<const std::bitset<64>*>(headerAmc13raw) << std::endl;
227  str << " amc13 check: " << headerAmc13.check() << std::endl;
228  str << " amc13 format: " << headerAmc13.getFormatVersion() << std::endl;
229  str << " amc13 nAMCs: " << headerAmc13.getNumberOfAMCs() << std::endl;
230  str << " amc13 orbit: " << headerAmc13.getOrbitNumber() << std::endl;
231  LogTrace("") << str.str();
232  }
233  //unsigned int nAMCs = headerAmc13.getNumberOfAMCs();
234  //for (unsigned int iAMC = 0; iAMC <nAMCs; iAMC++) {
235  // const Word64* raw = header+1 +(iAMC+1);
236  //}
237 
238  //
239  // AMC13 trailer
240  //
241  const Word64* trailerAmc13raw = trailer - 1;
242  amc13::Trailer trailerAmc13(trailerAmc13raw);
243  if (debug) {
244  std::ostringstream str;
245  str << " trailerAMC13: " << *reinterpret_cast<const std::bitset<64>*>(trailerAmc13raw) << std::endl;
246  str << " crc: " << trailerAmc13.getCRC() << std::endl;
247  str << " block: " << trailerAmc13.getBlock() << std::endl;
248  str << " LV1ID: " << trailerAmc13.getLV1ID() << std::endl;
249  str << " BX: " << trailerAmc13.getBX() << std::endl;
250  LogTrace("") << str.str();
251  }
252 
253  //
254  // get AMC13 payload (-> AMC's data)
255  //
256  amc13::Packet packetAmc13;
257  if (!packetAmc13.parse(header, header + 1, nWords - 2, fedHeader.lvl1ID(), fedHeader.bxID(), true, false)) {
258  edm::LogError("OMTF") << "Could not extract AMC13 Packet.";
259  return;
260  }
261  //LogTrace("") <<"AMC13 Packet: "<< packetAmc13.blocks() << " size "<<packetAmc13.size() << std::endl;
262 
263  //
264  // loop over AMC's
265  //
266  unsigned int blockNum = 0;
267  for (auto amc : packetAmc13.payload()) {
268  amc::BlockHeader bh = amc.blockHeader();
269  if (debug) {
270  std::ostringstream str;
271  str << " ----------- #" << blockNum++ << std::endl;
272  str << " blockheader: " << std::bitset<64>(bh.raw()) << std::endl;
273  str << " boardID: " << bh.getBoardID() << std::endl;
274  str << " amcNumber: " << bh.getAMCNumber() << std::endl;
275  str << " size: " << bh.getSize(); // << std::endl;
276  LogTrace("") << str.str();
277  }
278 
279  //
280  // AMC header
281  //
282  amc::Header headerAmc = amc.header();
283  if (debug) {
284  std::ostringstream str;
285  str << " AMC header[0]: " << std::bitset<64>(headerAmc.raw()[0]) << std::endl;
286  str << " AMC header[1]: " << std::bitset<64>(headerAmc.raw()[1]) << std::endl;
287  str << " AMC number: " << headerAmc.getAMCNumber(); // << std::endl;
288  LogTrace("") << str.str();
289  }
290 
291  //
292  // AMC trailer
293  //
294  //amc::Trailer trailerAmc = amc.trailer(); //this is the expected way but does not work
295  amc::Trailer trailerAmc(amc.data().get() + amc.size() -
296  1); //FIXME: the above is prefered but this works (CMSSW900)
297  if (debug) {
298  std::ostringstream str;
299  str << " AMC trailer: " << std::bitset<64>(trailerAmc.raw()) << std::endl;
300  str << " getLV1ID: " << trailerAmc.getLV1ID() << std::endl;
301  str << " size: " << trailerAmc.getSize() << std::endl;
302  LogTrace("") << str.str();
303  }
304 
305  //
306  // AMC payload
307  //
308  const auto& payload64 = amc.data();
309  const Word64* word = payload64.get();
310  for (unsigned int iWord = 1; iWord <= amc.size(); iWord++, word++) {
311  if (iWord <= 2)
312  continue; // two header words for each AMC
313  if (iWord == amc.size())
314  continue; // trailer for each AMC
315 
316  LogTrace("") << " payload: " << *reinterpret_cast<const std::bitset<64>*>(word);
317  DataWord64::Type recordType = DataWord64::type(*word);
318 
319  unsigned int fedId = fedHeader.sourceID();
320  unsigned int amcId = bh.getAMCNumber() / 2 + 1; // in OMTF convertsion 1-6
321  //
322  // RPC data
323  //
324  if (DataWord64::rpc == recordType && !theSkipRpc) {
325  theRpcUnpacker.unpack(triggerBX, fedId, amcId, RpcDataWord64(*word), producedRPCDigis.get());
326  }
327 
328  //
329  // CSC data
330  //
331  if (DataWord64::csc == recordType && !theSkipCsc) {
332  theCscUnpacker.unpack(fedId, amcId, CscDataWord64(*word), producedCscLctDigis.get());
333  }
334 
335  //
336  // DT data
337  //
338  if (DataWord64::dt == recordType && !theSkipDt) {
339  theDtUnpacker.unpack(fedId, amcId, DtDataWord64(*word), phi_Container, the_Container);
340  }
341 
342  //
343  // OMTF (muon) data
344  //
345  if (DataWord64::omtf == recordType && !theSkipMuon) {
346  theMuonUnpacker.unpack(fedId, amcId, MuonDataWord64(*word), producedMuonDigis.get());
347  }
348  }
349  }
350  }
351  event.put(std::move(producedRPCDigis), theOutputTag);
352  event.put(std::move(producedCscLctDigis), theOutputTag);
353  event.put(std::move(producedMuonDigis), theOutputTag);
354  producedDTPhDigis->setContainer(phi_Container);
355  event.put(std::move(producedDTPhDigis), theOutputTag);
356  producedDTThDigis->setContainer(the_Container);
357  event.put(std::move(producedDTThDigis), theOutputTag);
358  }
#define LogDebug(id)
std::vector< amc::Packet > payload() const
Definition: AMC13Spec.h:92
uint64_t raw() const
Definition: AMCSpec.h:23
unsigned int getAMCNumber() const
Definition: AMCSpec.h:71
void unpack(unsigned int fed, unsigned int amc, const CscDataWord64 &raw, CSCCorrelatedLCTDigiCollection *prod)
static MessageDrop * instance()
Definition: MessageDrop.cc:59
unsigned int getAMCNumber() const
Definition: AMCSpec.h:28
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
void unpack(int triggerBX, unsigned int fed, unsigned int amc, const RpcDataWord64 &raw, RPCDigiCollection *prod)
MuonUnpacker theMuonUnpacker
Definition: OmtfUnpacker.cc:68
uint64_t word
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< uint64_t > raw() const
Definition: AMCSpec.h:79
RpcUnpacker theRpcUnpacker
Definition: OmtfUnpacker.cc:65
Type type(const T &)
#define LogTrace(id)
uint64_t Word64
#define debug
Definition: HDRShower.cc:19
unsigned long theEventCounter
Definition: OmtfUnpacker.cc:61
unsigned int getSize() const
Definition: AMCSpec.h:30
DtUnpacker theDtUnpacker
Definition: OmtfUnpacker.cc:67
edm::EDGetTokenT< FEDRawDataCollection > theFedDataToken
Definition: OmtfUnpacker.cc:63
bool parse(const uint64_t *start, const uint64_t *data, unsigned int size, unsigned int lv1, unsigned int bx, bool legacy_mc=false, bool mtf7_mode=false)
Definition: AMC13Spec.cc:60
unsigned int getBoardID() const
Definition: AMCSpec.h:29
std::string theOutputTag
Definition: OmtfUnpacker.cc:71
void unpack(unsigned int fed, unsigned int amc, const DtDataWord64 &raw, std::vector< L1MuDTChambPhDigi > &phi_Container, std::vector< L1MuDTChambThDigi > &the_Container)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
Definition: AMCSpec.h:8
void unpack(unsigned int fed, unsigned int amc, const MuonDataWord64 &raw, l1t::RegionalMuonCandBxCollection *muColl)
#define str(s)
def move(src, dest)
Definition: eostools.py:511
CscUnpacker theCscUnpacker
Definition: OmtfUnpacker.cc:66

Member Data Documentation

edm::ParameterSet omtf::OmtfUnpacker::theConfig
private

Definition at line 70 of file OmtfUnpacker.cc.

Referenced by beginRun().

CscUnpacker omtf::OmtfUnpacker::theCscUnpacker
private

Definition at line 66 of file OmtfUnpacker.cc.

Referenced by beginRun(), and produce().

DtUnpacker omtf::OmtfUnpacker::theDtUnpacker
private

Definition at line 67 of file OmtfUnpacker.cc.

Referenced by produce().

unsigned long omtf::OmtfUnpacker::theEventCounter
private

Definition at line 61 of file OmtfUnpacker.cc.

Referenced by produce().

edm::EDGetTokenT<FEDRawDataCollection> omtf::OmtfUnpacker::theFedDataToken
private

Definition at line 63 of file OmtfUnpacker.cc.

Referenced by OmtfUnpacker(), and produce().

MuonUnpacker omtf::OmtfUnpacker::theMuonUnpacker
private

Definition at line 68 of file OmtfUnpacker.cc.

Referenced by produce().

std::string omtf::OmtfUnpacker::theOutputTag
private

Definition at line 71 of file OmtfUnpacker.cc.

Referenced by OmtfUnpacker(), and produce().

RpcUnpacker omtf::OmtfUnpacker::theRpcUnpacker
private

Definition at line 65 of file OmtfUnpacker.cc.

Referenced by beginRun(), and produce().

bool omtf::OmtfUnpacker::theSkipCsc
private

Definition at line 73 of file OmtfUnpacker.cc.

Referenced by beginRun(), OmtfUnpacker(), and produce().

bool omtf::OmtfUnpacker::theSkipDt
private

Definition at line 73 of file OmtfUnpacker.cc.

Referenced by OmtfUnpacker(), and produce().

bool omtf::OmtfUnpacker::theSkipMuon
private

Definition at line 73 of file OmtfUnpacker.cc.

Referenced by OmtfUnpacker(), and produce().

bool omtf::OmtfUnpacker::theSkipRpc
private

Definition at line 73 of file OmtfUnpacker.cc.

Referenced by beginRun(), OmtfUnpacker(), and produce().