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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 79 of file OmtfUnpacker.cc.

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

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

Definition at line 53 of file OmtfUnpacker.cc.

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

53 {}

Member Function Documentation

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

Definition at line 110 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().

110  {
111 
112  //
113  // rpc unpacker
114  //
115  if (!theSkipRpc) {
116  if (theConfig.getParameter<bool>("useRpcConnectionFile")) {
118  } else {
119  theRpcUnpacker.init(es);
120  }
121  }
122 
123 
124  //
125  // csc unpacker
126  //
128 
129 }
T getParameter(std::string const &) const
void init(const edm::EventSetup &es)
RpcUnpacker theRpcUnpacker
Definition: OmtfUnpacker.cc:67
std::string fullPath() const
Definition: FileInPath.cc:163
edm::ParameterSet theConfig
Definition: OmtfUnpacker.cc:72
CscUnpacker theCscUnpacker
Definition: OmtfUnpacker.cc:68
void omtf::OmtfUnpacker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 96 of file OmtfUnpacker.cc.

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

Referenced by ~OmtfUnpacker().

96  {
98  desc.add<edm::InputTag>("inputLabel",edm::InputTag("rawDataCollector"));
99  desc.add<bool>("skipRpc",false);
100  desc.add<bool>("skipCsc",false);
101  desc.add<bool>("skipDt",false);
102  desc.add<bool>("skipMuon",false);
103  desc.add<bool>("useRpcConnectionFile",false);
104  desc.add<std::string>("rpcConnectionFile","");
105  desc.add<std::string>("outputTag","");
106  descriptions.add("omtfUnpacker",desc);
107 }
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 132 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(), l1t::stage2::layer2::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(), 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::MuonUnpacker::unpack(), omtf::DtUnpacker::unpack(), omtf::CscUnpacker::unpack(), omtf::RpcUnpacker::unpack(), and FEDHeader::version().

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

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

Member Data Documentation

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

Definition at line 72 of file OmtfUnpacker.cc.

Referenced by beginRun().

CscUnpacker omtf::OmtfUnpacker::theCscUnpacker
private

Definition at line 68 of file OmtfUnpacker.cc.

Referenced by beginRun(), and produce().

DtUnpacker omtf::OmtfUnpacker::theDtUnpacker
private

Definition at line 69 of file OmtfUnpacker.cc.

Referenced by produce().

unsigned long omtf::OmtfUnpacker::theEventCounter
private

Definition at line 63 of file OmtfUnpacker.cc.

Referenced by produce().

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

Definition at line 65 of file OmtfUnpacker.cc.

Referenced by OmtfUnpacker(), and produce().

MuonUnpacker omtf::OmtfUnpacker::theMuonUnpacker
private

Definition at line 70 of file OmtfUnpacker.cc.

Referenced by produce().

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

Definition at line 73 of file OmtfUnpacker.cc.

Referenced by OmtfUnpacker(), and produce().

RpcUnpacker omtf::OmtfUnpacker::theRpcUnpacker
private

Definition at line 67 of file OmtfUnpacker.cc.

Referenced by beginRun(), and produce().

bool omtf::OmtfUnpacker::theSkipCsc
private

Definition at line 75 of file OmtfUnpacker.cc.

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

bool omtf::OmtfUnpacker::theSkipDt
private

Definition at line 75 of file OmtfUnpacker.cc.

Referenced by OmtfUnpacker(), and produce().

bool omtf::OmtfUnpacker::theSkipMuon
private

Definition at line 75 of file OmtfUnpacker.cc.

Referenced by OmtfUnpacker(), and produce().

bool omtf::OmtfUnpacker::theSkipRpc
private

Definition at line 75 of file OmtfUnpacker.cc.

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