CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::ESGetToken< RPCAMCLinkMap,
RPCOMTFLinkMapRcd
theAmcMappingToken
 
edm::ParameterSet theConfig
 
CscPacker theCscPacker
 
edm::EDGetTokenT
< CSCCorrelatedLCTDigiCollection
theCscToken
 
DtPacker theDtPacker
 
edm::EDGetTokenT
< L1MuDTChambPhContainer
theDtPhToken
 
edm::EDGetTokenT
< L1MuDTChambThContainer
theDtThToken
 
unsigned long theEventCounter
 
std::string theOutputTag
 
edm::ESGetToken< RPCEMap,
RPCEMapRcd
theRPCEMapToken
 
RpcPacker theRpcPacker
 
edm::EDGetTokenT
< RPCDigiCollection
theRpcToken
 
bool theSkipCsc
 
bool theSkipDt
 
bool theSkipRpc
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 50 of file OmtfPacker.cc.

Constructor & Destructor Documentation

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

Definition at line 83 of file OmtfPacker.cc.

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

83  : theConfig(pset), theEventCounter(0) {
84  theOutputTag = pset.getParameter<std::string>("outputTag");
85 
86  produces<FEDRawDataCollection>(theOutputTag);
87 
88  theRpcToken = consumes<RPCDigiCollection>(pset.getParameter<edm::InputTag>("rpcInputLabel"));
89  theCscToken = consumes<CSCCorrelatedLCTDigiCollection>(pset.getParameter<edm::InputTag>("cscInputLabel"));
90  theDtPhToken = consumes<L1MuDTChambPhContainer>(pset.getParameter<edm::InputTag>("dtPhInputLabel"));
91  theDtThToken = consumes<L1MuDTChambThContainer>(pset.getParameter<edm::InputTag>("dtThInputLabel"));
92 
93  theSkipDt = pset.getParameter<bool>("skipDt");
94  theSkipRpc = pset.getParameter<bool>("skipRpc");
95  theSkipCsc = pset.getParameter<bool>("skipCsc");
96 
97  if (!theSkipRpc) {
98  theRPCEMapToken = esConsumes<edm::Transition::BeginRun>();
99  if (not theConfig.getParameter<bool>("useRpcConnectionFile")) {
100  theAmcMappingToken = esConsumes<edm::Transition::BeginRun>();
101  }
102  }
103  }
edm::ESGetToken< RPCAMCLinkMap, RPCOMTFLinkMapRcd > theAmcMappingToken
Definition: OmtfPacker.cc:76
edm::ParameterSet theConfig
Definition: OmtfPacker.cc:63
edm::ESGetToken< RPCEMap, RPCEMapRcd > theRPCEMapToken
Definition: OmtfPacker.cc:75
edm::EDGetTokenT< RPCDigiCollection > theRpcToken
Definition: OmtfPacker.cc:70
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > theCscToken
Definition: OmtfPacker.cc:71
edm::EDGetTokenT< L1MuDTChambThContainer > theDtThToken
Definition: OmtfPacker.cc:72
unsigned long theEventCounter
Definition: OmtfPacker.cc:64
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< L1MuDTChambPhContainer > theDtPhToken
Definition: OmtfPacker.cc:73
std::string theOutputTag
Definition: OmtfPacker.cc:66
omtf::OmtfPacker::~OmtfPacker ( )
inlineoverride

Definition at line 54 of file OmtfPacker.cc.

54 {}

Member Function Documentation

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

Definition at line 120 of file OmtfPacker.cc.

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

120  {
121  //
122  // initialise RPC packer
123  //
124  if (!theSkipRpc) {
126  if (theConfig.getParameter<bool>("useRpcConnectionFile")) {
127  theRpcPacker.init(*readoutMapping,
128  edm::FileInPath(theConfig.getParameter<std::string>("rpcConnectionFile")).fullPath());
129  } else {
130  auto const& amcMapping = es.getData(theAmcMappingToken);
131  theRpcPacker.init(*readoutMapping, amcMapping);
132  }
133  }
134 
135  //
136  // init CSC Link map
137  //
138  if (!theSkipCsc)
139  theCscPacker.init();
140  }
edm::ESGetToken< RPCAMCLinkMap, RPCOMTFLinkMapRcd > theAmcMappingToken
Definition: OmtfPacker.cc:76
edm::ParameterSet theConfig
Definition: OmtfPacker.cc:63
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::ESGetToken< RPCEMap, RPCEMapRcd > theRPCEMapToken
Definition: OmtfPacker.cc:75
void init(const RPCEMap &readoutMapping, const RPCAMCLinkMap &linkMap)
RpcPacker theRpcPacker
Definition: OmtfPacker.cc:79
CscPacker theCscPacker
Definition: OmtfPacker.cc:78
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ESTransientHandle< T > getTransientHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:168
std::string fullPath() const
Definition: FileInPath.cc:161
void omtf::OmtfPacker::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 105 of file OmtfPacker.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

105  {
107  desc.add<edm::InputTag>("rpcInputLabel", edm::InputTag(""));
108  desc.add<edm::InputTag>("cscInputLabel", edm::InputTag(""));
109  desc.add<edm::InputTag>("dtPhInputLabel", edm::InputTag(""));
110  desc.add<edm::InputTag>("dtThInputLabel", edm::InputTag(""));
111  desc.add<bool>("skipRpc", false);
112  desc.add<bool>("skipCsc", false);
113  desc.add<bool>("skipDt", false);
114  desc.add<bool>("useRpcConnectionFile", false);
115  desc.add<std::string>("rpcConnectionFile", "");
116  desc.add<std::string>("outputTag", "");
117  descriptions.add("omtfPacker", desc);
118  }
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 142 of file OmtfPacker.cc.

References amc13::Packet::add(), edm::EventBase::bunchCrossing(), evf::compute_crc(), omtf::DataWord64::csc, FEDRawData::data(), omtf::DataWord64::dt, edm::EventID::event(), edm::Event::eventAuxiliary(), l1tstage2_dqm_sourceclient-live_cfg::fedId, edm::Event::getByToken(), edm::EventBase::id(), LogDebug, LogTrace, eostools::move(), omtf::DataWord64::omtf, edm::EventAuxiliary::orbitNumber(), omtf::DtPacker::pack(), omtf::CscPacker::pack(), omtf::RpcPacker::pack(), jetCorrFactors_cfi::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().

142  {
143  LogDebug("OmtfPacker::produce") << "Beginning To Pack Event: " << ++theEventCounter;
144 
145  //
146  // prepare FedAmcRawsMap structure to collect Word64 raws from digi packers
147  //
148  FedAmcRawsMap raws;
149  std::list<unsigned int> amcIds = {1, 3, 5, 7, 9, 11};
150  std::list<unsigned int> fedIds = {1380, 1381};
151  for (auto& fedId : fedIds) {
152  for (auto& amcId : amcIds) {
153  raws[std::make_pair(fedId, amcId)];
154  }
155  }
156 
157  //
158  // DT raws
159  //
160  if (!theSkipDt) {
161  edm::Handle<L1MuDTChambPhContainer> digiCollectionDTPh;
162  ev.getByToken(theDtPhToken, digiCollectionDTPh);
163  edm::Handle<L1MuDTChambThContainer> digiCollectionDTTh;
164  ev.getByToken(theDtThToken, digiCollectionDTTh);
165  theDtPacker.pack(digiCollectionDTPh.product(), digiCollectionDTTh.product(), raws);
166  }
167 
168  //
169  // csc raws
170  //
171  if (!theSkipCsc) {
173  ev.getByToken(theCscToken, digiCollectionCSC);
174  theCscPacker.pack(digiCollectionCSC.product(), raws);
175  }
176 
177  //
178  // rpc raws
179  //
180  if (!theSkipRpc) {
181  edm::Handle<RPCDigiCollection> digiCollectionRPC;
182  ev.getByToken(theRpcToken, digiCollectionRPC);
183  theRpcPacker.pack(digiCollectionRPC.product(), raws);
184  }
185 
186  auto bxId = ev.bunchCrossing();
187  auto evtId = ev.id().event();
188  auto orbit = ev.eventAuxiliary().orbitNumber();
189  std::unique_ptr<FEDRawDataCollection> raw_coll(new FEDRawDataCollection());
190  for (auto& fedId : fedIds) {
191  //
192  // assign formatted raws to feds
193  //
194  amc13::Packet amc13;
195  for (const auto& it : raws) {
196  if (fedId != it.first.first)
197  continue;
198  const std::vector<Word64>& amcData = it.second;
199  unsigned int amcId = it.first.second;
200  for (const auto& raw : amcData) {
201  std::ostringstream dataStr;
202  if (DataWord64::csc == DataWord64::type(raw))
203  dataStr << CscDataWord64(raw);
204  if (DataWord64::dt == DataWord64::type(raw))
205  dataStr << DtDataWord64(raw);
206  if (DataWord64::rpc == DataWord64::type(raw))
207  dataStr << RpcDataWord64(raw);
209  dataStr << MuonDataWord64(raw);
210  LogTrace("") << " fed: " << fedId << " amcId: " << amcId << " RAW DATA: " << dataStr.str() << std::endl;
211  }
212  amc13.add(amcId, 43981, evtId, orbit, bxId, amcData);
213  }
214 
215  FEDRawData& fed_data = raw_coll->FEDData(fedId);
216 
217  const unsigned int slinkHeaderSize = 8;
218  const unsigned int slinkTrailerSize = 8;
219  unsigned int size = (amc13.size()) * sizeof(Word64) + slinkHeaderSize + slinkTrailerSize;
220  fed_data.resize(size);
221  unsigned char* payload = fed_data.data();
222  unsigned char* payload_start = payload;
223 
224  FEDHeader header(payload);
225  const unsigned int evtType = 1;
226  header.set(payload, evtType, evtId, bxId, fedId);
227 
228  amc13.write(ev, payload, slinkHeaderSize, size - slinkHeaderSize - slinkTrailerSize);
229 
230  payload += slinkHeaderSize;
231  payload += amc13.size() * 8;
232 
233  FEDTrailer trailer(payload);
234  trailer.set(payload, size / 8, evf::compute_crc(payload_start, size), 0, 0);
235  }
236  ev.put(std::move(raw_coll), theOutputTag);
237  }
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::map< std::pair< unsigned int, unsigned int >, std::vector< Word64 > > FedAmcRawsMap
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:95
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:80
#define LogTrace(id)
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
def move
Definition: eostools.py:511
edm::EDGetTokenT< RPCDigiCollection > theRpcToken
Definition: OmtfPacker.cc:70
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:79
Type type(const T &)
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > theCscToken
Definition: OmtfPacker.cc:71
uint64_t Word64
CscPacker theCscPacker
Definition: OmtfPacker.cc:78
edm::EDGetTokenT< L1MuDTChambThContainer > theDtThToken
Definition: OmtfPacker.cc:72
T const * product() const
Definition: Handle.h:70
unsigned long theEventCounter
Definition: OmtfPacker.cc:64
edm::EDGetTokenT< L1MuDTChambPhContainer > theDtPhToken
Definition: OmtfPacker.cc:73
std::string theOutputTag
Definition: OmtfPacker.cc:66
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
tuple size
Write out results.
#define LogDebug(id)

Member Data Documentation

edm::ESGetToken<RPCAMCLinkMap, RPCOMTFLinkMapRcd> omtf::OmtfPacker::theAmcMappingToken
private

Definition at line 76 of file OmtfPacker.cc.

Referenced by beginRun(), and OmtfPacker().

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

Definition at line 63 of file OmtfPacker.cc.

Referenced by beginRun(), and OmtfPacker().

CscPacker omtf::OmtfPacker::theCscPacker
private

Definition at line 78 of file OmtfPacker.cc.

Referenced by beginRun(), and produce().

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

Definition at line 71 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

DtPacker omtf::OmtfPacker::theDtPacker
private

Definition at line 80 of file OmtfPacker.cc.

Referenced by produce().

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

Definition at line 73 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

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

Definition at line 72 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

unsigned long omtf::OmtfPacker::theEventCounter
private

Definition at line 64 of file OmtfPacker.cc.

Referenced by produce().

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

Definition at line 66 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

edm::ESGetToken<RPCEMap, RPCEMapRcd> omtf::OmtfPacker::theRPCEMapToken
private

Definition at line 75 of file OmtfPacker.cc.

Referenced by beginRun(), and OmtfPacker().

RpcPacker omtf::OmtfPacker::theRpcPacker
private

Definition at line 79 of file OmtfPacker.cc.

Referenced by beginRun(), and produce().

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

Definition at line 70 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

bool omtf::OmtfPacker::theSkipCsc
private

Definition at line 68 of file OmtfPacker.cc.

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

bool omtf::OmtfPacker::theSkipDt
private

Definition at line 68 of file OmtfPacker.cc.

Referenced by OmtfPacker(), and produce().

bool omtf::OmtfPacker::theSkipRpc
private

Definition at line 68 of file OmtfPacker.cc.

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