CMS 3D CMS Logo

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

Public Member Functions

void beginRun (const edm::Run &run, const edm::EventSetup &es) override
 
 OmtfPacker (const edm::ParameterSet &pset)
 
void produce (edm::Event &ev, const edm::EventSetup &es) override
 
 ~OmtfPacker () 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
 
CscPacker theCscPacker
 
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollectiontheCscToken
 
DtPacker theDtPacker
 
edm::EDGetTokenT< L1MuDTChambPhContainertheDtPhToken
 
edm::EDGetTokenT< L1MuDTChambThContainertheDtThToken
 
unsigned long theEventCounter
 
std::string theOutputTag
 
RpcPacker theRpcPacker
 
edm::EDGetTokenT< RPCDigiCollectiontheRpcToken
 
bool theSkipCsc
 
bool theSkipDt
 
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 46 of file OmtfPacker.cc.

Constructor & Destructor Documentation

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

Definition at line 76 of file OmtfPacker.cc.

References edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, theCscToken, theDtPhToken, theDtThToken, theOutputTag, theRpcToken, theSkipCsc, theSkipDt, and theSkipRpc.

76  : theConfig(pset), theEventCounter(0) {
77  theOutputTag = pset.getParameter<std::string>("outputTag");
78 
79  produces<FEDRawDataCollection>(theOutputTag);
80 
81  theRpcToken = consumes<RPCDigiCollection>(pset.getParameter<edm::InputTag>("rpcInputLabel"));
82  theCscToken = consumes<CSCCorrelatedLCTDigiCollection>(pset.getParameter<edm::InputTag>("cscInputLabel"));
83  theDtPhToken = consumes<L1MuDTChambPhContainer>(pset.getParameter<edm::InputTag>("dtPhInputLabel"));
84  theDtThToken = consumes<L1MuDTChambThContainer>(pset.getParameter<edm::InputTag>("dtThInputLabel"));
85 
86  theSkipDt = pset.getParameter<bool>("skipDt");
87  theSkipRpc = pset.getParameter<bool>("skipRpc");
88  theSkipCsc = pset.getParameter<bool>("skipCsc");
89  }
T getParameter(std::string const &) const
edm::ParameterSet theConfig
Definition: OmtfPacker.cc:59
edm::EDGetTokenT< RPCDigiCollection > theRpcToken
Definition: OmtfPacker.cc:66
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > theCscToken
Definition: OmtfPacker.cc:67
edm::EDGetTokenT< L1MuDTChambThContainer > theDtThToken
Definition: OmtfPacker.cc:68
unsigned long theEventCounter
Definition: OmtfPacker.cc:60
edm::EDGetTokenT< L1MuDTChambPhContainer > theDtPhToken
Definition: OmtfPacker.cc:69
std::string theOutputTag
Definition: OmtfPacker.cc:62
omtf::OmtfPacker::~OmtfPacker ( )
inlineoverride

Definition at line 50 of file OmtfPacker.cc.

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

50 {}

Member Function Documentation

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

Definition at line 106 of file OmtfPacker.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), omtf::CscPacker::init(), omtf::RpcPacker::init(), AlCaHLTBitMon_QueryRunRegistry::string, theConfig, theCscPacker, theRpcPacker, theSkipCsc, and theSkipRpc.

Referenced by ~OmtfPacker().

106  {
107  //
108  // initialise RPC packer
109  //
110  if (!theSkipRpc) {
111  if (theConfig.getParameter<bool>("useRpcConnectionFile")) {
113  } else {
114  theRpcPacker.init(es);
115  }
116  }
117 
118  //
119  // init CSC Link map
120  //
121  if (!theSkipCsc)
122  theCscPacker.init();
123  }
T getParameter(std::string const &) const
edm::ParameterSet theConfig
Definition: OmtfPacker.cc:59
RpcPacker theRpcPacker
Definition: OmtfPacker.cc:72
CscPacker theCscPacker
Definition: OmtfPacker.cc:71
std::string fullPath() const
Definition: FileInPath.cc:163
void init(const edm::EventSetup &es)
void omtf::OmtfPacker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 91 of file OmtfPacker.cc.

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

Referenced by ~OmtfPacker().

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

Definition at line 125 of file OmtfPacker.cc.

References amc13::Packet::add(), edm::EventBase::bunchCrossing(), evf::compute_crc(), omtf::DataWord64::csc, FEDRawData::data(), DEFINE_FWK_MODULE, omtf::DataWord64::dt, edm::EventID::event(), edm::Event::eventAuxiliary(), l1tstage2_dqm_sourceclient-live_cfg::fedId, L1TStage2BMTF_cff::fedIds, EcalFEDMonitor_cfi::FEDRawDataCollection, edm::Event::getByToken(), RecoTauValidation_cfi::header, edm::EventBase::id(), LogDebug, LogTrace, eostools::move(), omtf::DataWord64::omtf, edm::EventAuxiliary::orbitNumber(), omtf::DtPacker::pack(), omtf::CscPacker::pack(), omtf::RpcPacker::pack(), jets_cff::payload, edm::Handle< T >::product(), edm::Event::put(), FEDRawData::resize(), omtf::DataWord64::rpc, FEDHeader::set(), FEDTrailer::set(), amc13::Packet::size(), findQualityFiles::size, theCscPacker, theCscToken, theDtPacker, theDtPhToken, theDtThToken, theEventCounter, theOutputTag, theRpcPacker, theRpcToken, theSkipCsc, theSkipDt, theSkipRpc, omtf::DataWord64::type(), and amc13::Packet::write().

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

125  {
126  LogDebug("OmtfPacker::produce") << "Beginning To Pack Event: " << ++theEventCounter;
127 
128  //
129  // prepare FedAmcRawsMap structure to collect Word64 raws from digi packers
130  //
131  FedAmcRawsMap raws;
132  std::list<unsigned int> amcIds = {1, 3, 5, 7, 9, 11};
133  std::list<unsigned int> fedIds = {1380, 1381};
134  for (auto& fedId : fedIds) {
135  for (auto& amcId : amcIds) {
136  raws[std::make_pair(fedId, amcId)];
137  }
138  }
139 
140  //
141  // DT raws
142  //
143  if (!theSkipDt) {
144  edm::Handle<L1MuDTChambPhContainer> digiCollectionDTPh;
145  ev.getByToken(theDtPhToken, digiCollectionDTPh);
146  edm::Handle<L1MuDTChambThContainer> digiCollectionDTTh;
147  ev.getByToken(theDtThToken, digiCollectionDTTh);
148  theDtPacker.pack(digiCollectionDTPh.product(), digiCollectionDTTh.product(), raws);
149  }
150 
151  //
152  // csc raws
153  //
154  if (!theSkipCsc) {
156  ev.getByToken(theCscToken, digiCollectionCSC);
157  theCscPacker.pack(digiCollectionCSC.product(), raws);
158  }
159 
160  //
161  // rpc raws
162  //
163  if (!theSkipRpc) {
164  edm::Handle<RPCDigiCollection> digiCollectionRPC;
165  ev.getByToken(theRpcToken, digiCollectionRPC);
166  theRpcPacker.pack(digiCollectionRPC.product(), raws);
167  }
168 
169  auto bxId = ev.bunchCrossing();
170  auto evtId = ev.id().event();
171  auto orbit = ev.eventAuxiliary().orbitNumber();
172  std::unique_ptr<FEDRawDataCollection> raw_coll(new FEDRawDataCollection());
173  for (auto& fedId : fedIds) {
174  //
175  // assign formatted raws to feds
176  //
178  for (const auto& it : raws) {
179  if (fedId != it.first.first)
180  continue;
181  const std::vector<Word64>& amcData = it.second;
182  unsigned int amcId = it.first.second;
183  for (const auto& raw : amcData) {
184  std::ostringstream dataStr;
185  if (DataWord64::csc == DataWord64::type(raw))
186  dataStr << CscDataWord64(raw);
187  if (DataWord64::dt == DataWord64::type(raw))
188  dataStr << DtDataWord64(raw);
189  if (DataWord64::rpc == DataWord64::type(raw))
190  dataStr << RpcDataWord64(raw);
192  dataStr << MuonDataWord64(raw);
193  LogTrace("") << " fed: " << fedId << " amcId: " << amcId << " RAW DATA: " << dataStr.str() << std::endl;
194  }
195  amc13.add(amcId, 43981, evtId, orbit, bxId, amcData);
196  }
197 
198  FEDRawData& fed_data = raw_coll->FEDData(fedId);
199 
200  const unsigned int slinkHeaderSize = 8;
201  const unsigned int slinkTrailerSize = 8;
202  unsigned int size = (amc13.size()) * sizeof(Word64) + slinkHeaderSize + slinkTrailerSize;
203  fed_data.resize(size);
204  unsigned char* payload = fed_data.data();
205  unsigned char* payload_start = payload;
206 
207  FEDHeader header(payload);
208  const unsigned int evtType = 1;
209  header.set(payload, evtType, evtId, bxId, fedId);
210 
211  amc13.write(ev, payload, slinkHeaderSize, size - slinkHeaderSize - slinkTrailerSize);
212 
213  payload += slinkHeaderSize;
214  payload += amc13.size() * 8;
215 
216  FEDTrailer trailer(payload);
217  trailer.set(payload, size / 8, evf::compute_crc(payload_start, size), 0, 0);
218  }
219  ev.put(std::move(raw_coll), theOutputTag);
220  }
#define LogDebug(id)
size
Write out results.
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
std::map< std::pair< unsigned int, unsigned int >, std::vector< Word64 > > FedAmcRawsMap
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:93
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
unsigned int size() const
Definition: AMC13Spec.cc:186
int bunchCrossing() const
Definition: EventBase.h:64
void add(unsigned int amc_no, unsigned int board, unsigned int lv1id, unsigned int orbit, unsigned int bx, const std::vector< uint64_t > &load, unsigned int user=0)
Definition: AMC13Spec.cc:47
bool write(const edm::Event &ev, unsigned char *ptr, unsigned int skip, unsigned int size) const
Definition: AMC13Spec.cc:202
DtPacker theDtPacker
Definition: OmtfPacker.cc:73
void pack(const RPCDigiCollection *prod, FedAmcRawsMap &raws)
void resize(size_t newsize)
Definition: FEDRawData.cc:28
int orbitNumber() const
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:46
edm::EDGetTokenT< RPCDigiCollection > theRpcToken
Definition: OmtfPacker.cc:66
void pack(const CSCCorrelatedLCTDigiCollection *prod, FedAmcRawsMap &raws)
void pack(const L1MuDTChambPhContainer *phCont, const L1MuDTChambThContainer *thCont, FedAmcRawsMap &raws)
Definition: OmtfDtPacker.cc:8
RpcPacker theRpcPacker
Definition: OmtfPacker.cc:72
Type type(const T &)
#define LogTrace(id)
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > theCscToken
Definition: OmtfPacker.cc:67
uint64_t Word64
CscPacker theCscPacker
Definition: OmtfPacker.cc:71
edm::EDGetTokenT< L1MuDTChambThContainer > theDtThToken
Definition: OmtfPacker.cc:68
T const * product() const
Definition: Handle.h:69
unsigned long theEventCounter
Definition: OmtfPacker.cc:60
edm::EDGetTokenT< L1MuDTChambPhContainer > theDtPhToken
Definition: OmtfPacker.cc:69
std::string theOutputTag
Definition: OmtfPacker.cc:62
edm::EventID id() const
Definition: EventBase.h:59
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::ParameterSet omtf::OmtfPacker::theConfig
private

Definition at line 59 of file OmtfPacker.cc.

Referenced by beginRun().

CscPacker omtf::OmtfPacker::theCscPacker
private

Definition at line 71 of file OmtfPacker.cc.

Referenced by beginRun(), and produce().

edm::EDGetTokenT<CSCCorrelatedLCTDigiCollection> omtf::OmtfPacker::theCscToken
private

Definition at line 67 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

DtPacker omtf::OmtfPacker::theDtPacker
private

Definition at line 73 of file OmtfPacker.cc.

Referenced by produce().

edm::EDGetTokenT<L1MuDTChambPhContainer> omtf::OmtfPacker::theDtPhToken
private

Definition at line 69 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

edm::EDGetTokenT<L1MuDTChambThContainer> omtf::OmtfPacker::theDtThToken
private

Definition at line 68 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

unsigned long omtf::OmtfPacker::theEventCounter
private

Definition at line 60 of file OmtfPacker.cc.

Referenced by produce().

std::string omtf::OmtfPacker::theOutputTag
private

Definition at line 62 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

RpcPacker omtf::OmtfPacker::theRpcPacker
private

Definition at line 72 of file OmtfPacker.cc.

Referenced by beginRun(), and produce().

edm::EDGetTokenT<RPCDigiCollection> omtf::OmtfPacker::theRpcToken
private

Definition at line 66 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

bool omtf::OmtfPacker::theSkipCsc
private

Definition at line 64 of file OmtfPacker.cc.

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

bool omtf::OmtfPacker::theSkipDt
private

Definition at line 64 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

bool omtf::OmtfPacker::theSkipRpc
private

Definition at line 64 of file OmtfPacker.cc.

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