64 _verbosity(iConfig.getUntrackedParameter<
int>(
"Verbosity", 0)),
65 electronicsMapLabel_(iConfig.getParameter<
std::
string>(
"ElectronicsMap")),
68 tok_HBHEDigiCollection_(consumes<
HBHEDigiCollection >(iConfig.getParameter<
edm::InputTag>(
"HBHEqie8"))),
69 tok_HFDigiCollection_(consumes<
HFDigiCollection>(iConfig.getParameter<
edm::InputTag>(
"HFqie8"))),
71 premix_(iConfig.getParameter<
bool>(
"premix"))
73 produces<FEDRawDataCollection>(
"");
103 map<int,unique_ptr<HCalFED> > fedMap;
110 if( qie10DigiCollection.
isValid() ){
112 for (
unsigned int j=0; j < qie10dc.
size(); j++){
116 int crateId =
eid.crateId();
117 int slotId =
eid.slot();
118 int uhtrIndex = ((slotId&0xF)<<8) | (crateId&0xFF);
126 if( ! uhtrs.
exist( uhtrIndex ) ){
127 uhtrs.
newUHTR( uhtrIndex , presamples );
137 if( qie11DigiCollection.
isValid() ){
139 for (
unsigned int j=0; j < qie11dc.
size(); j++){
143 int crateId =
eid.crateId();
144 int slotId =
eid.slot();
145 int uhtrIndex = ((slotId&0xF)<<8) | (crateId&0xFF);
148 if( ! uhtrs.
exist(uhtrIndex) ){
149 uhtrs.
newUHTR( uhtrIndex , presamples );
158 if(hfDigiCollection.
isValid()){
161 DetId detid = qiedf->id();
164 int crateId =
eid.crateId();
165 int slotId =
eid.slot();
166 int uhtrIndex = (crateId&0xFF) | ((slotId&0xF)<<8) ;
169 if( ! uhtrs.
exist(uhtrIndex) ){
170 uhtrs.
newUHTR( uhtrIndex , presamples );
179 if(hbheDigiCollection.
isValid()){
182 DetId detid = qiedf->id();
185 int crateId =
eid.crateId();
186 int slotId =
eid.slot();
187 int uhtrIndex = (crateId&0xFF) | ((slotId&0xF)<<8) ;
190 if( ! uhtrs.
exist(uhtrIndex) ){
191 uhtrs.
newUHTR( uhtrIndex , presamples );
200 if(tpDigiCollection.
isValid()){
203 DetId detid = qiedf->id();
206 int crateId =
eid.crateId();
207 int slotId =
eid.slot();
208 int uhtrIndex = (crateId&0xFF) | ((slotId&0xF)<<8);
209 int ilink =
eid.fiberIndex();
210 int itower =
eid.fiberChanId();
211 int channelid = (itower&0xF) | ((ilink&0xF)<<4);
214 if( ! uhtrs.
exist(uhtrIndex) ){
215 uhtrs.
newUHTR( uhtrIndex , presamples );
227 for( UHTRpacker::UHTRMap::iterator uhtr = uhtrs.
uhtrs.begin() ; uhtr != uhtrs.
uhtrs.end() ; ++uhtr){
231 uint64_t crateId = (uhtr->first)&0xFF;
232 uint64_t slotId = (uhtr->first&0xF00)>>8;
236 if( fedMap.find(fedId) == fedMap.end() ){
240 fedMap[
fedId]->addUHTR(uhtr->second,crateId,slotId);
248 for(
map<
int,unique_ptr<HCalFED> >::iterator fed = fedMap.begin() ; fed != fedMap.end() ; ++fed ){
250 int fedId = fed->first;
252 auto & rawData = fed_buffers->FEDData(fedId);
253 fed->second->formatFEDdata(rawData);
257 FEDTrailer hcalFEDTrailer(rawData.data()+(rawData.size()-8));
258 hcalFEDTrailer.
set(rawData.data()+(rawData.size()-8), rawData.size()/8,
evf::compute_crc(rawData.data(),rawData.size()), 0, 0);
278 desc.
add<
bool>(
"premix",
false);
279 descriptions.
add(
"hcalDigiToRawuHTR",desc);
DetId detid() const
Get the detector id.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
EventNumber_t event() const
edm::EDGetTokenT< HBHEDigiCollection > tok_HBHEDigiCollection_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void finalizeHeadTail(uhtrData *uhtr, bool verbosity)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
int presamples() const
for backward compatibility
uhtrData * newUHTR(int uhtrIndex, int ps=0, int orn=0, int bcn=0, uint64_t evt=0)
std::vector< HFDataFrame >::const_iterator const_iterator
int bunchCrossing() const
static void set(unsigned char *trailer, int evt_lgth, int crc, int evt_stat, int tts, bool T=false)
Set all fields in the trailer.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< HcalDataFrameContainer< QIE10DataFrame > > tok_QIE10DigiCollection_
std::string electronicsMapLabel_
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
edm::EDGetTokenT< HFDigiCollection > tok_HFDigiCollection_
~HcalDigiToRawuHTR() override
DetId detid() const
Get the detector id.
HcalDigiToRawuHTR(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const_iterator end() const
unsigned long long uint64_t
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void addChannel(int uhtrIndex, edm::SortedCollection< HFDataFrame >::const_iterator &qiedf, const HcalElectronicsMap *readoutMap, bool premix, int verbosity=0)
int presamples() const
for backward compatibility
bool exist(int uhtrIndex)
const DetId lookupTrigger(HcalElectronicsId fId) const
brief lookup the trigger logical detid associated with the given electronics id
T const * product() const
Readout chain identification for Hcal.
edm::EDGetTokenT< HcalTrigPrimDigiCollection > tok_TPDigiCollection_
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
const_iterator begin() const
edm::EDGetTokenT< HcalDataFrameContainer< QIE11DataFrame > > tok_QIE11DigiCollection_