CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1TTwinMuxRawToDigi Class Reference
Inheritance diagram for L1TTwinMuxRawToDigi:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool fillRawData (edm::Event &e, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTChambPhContainer::Phi_Container &phi_out_data) const
 Generate and fill FED raw data for a full event. More...
 
 L1TTwinMuxRawToDigi (const edm::ParameterSet &pset)
 Constructor. More...
 
void processFed (int twinmuxfed, int wheel, std::array< short, 12 > const &twinMuxAmcSec, edm::Handle< FEDRawDataCollection > data, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTChambPhContainer::Phi_Container &phi_out_data) const
 
void produce (edm::StreamID, edm::Event &e, const edm::EventSetup &c) const override
 Produce digis out of raw data. More...
 
 ~L1TTwinMuxRawToDigi () override
 Destructor. More...
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

int benAngConversion (int benAng_) const
 
edm::InputTag getDTTM7InputTag () const
 
int normBx (int bx_, int bxCnt_) const
 
int radAngConversion (int radAng_) const
 
unsigned char * readline (unsigned char *lineFED, int &lines, long &dataWord) const
 

Private Attributes

std::vector< std::array< short, 12 > > amcsec_
 
std::vector< long long int > amcsecmap_
 
bool debug_
 
edm::InputTag DTTM7InputTag_
 
std::vector< int > feds_
 
size_t nfeds_
 
edm::EDGetTokenT< FEDRawDataCollectionRaw_token
 
std::vector< int > wheels_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 42 of file L1TTwinMuxRawToDigi.cc.

Constructor & Destructor Documentation

◆ L1TTwinMuxRawToDigi()

L1TTwinMuxRawToDigi::L1TTwinMuxRawToDigi ( const edm::ParameterSet pset)

Constructor.

Definition at line 93 of file L1TTwinMuxRawToDigi.cc.

References amcsec_, amcsecmap_, DTTM7InputTag_, feds_, nfeds_, Raw_token, edm::shift, and wheels_.

94  :
95 
96  debug_(pset.getUntrackedParameter<bool>("debug", false)),
97  nfeds_(0),
98  DTTM7InputTag_(pset.getParameter<edm::InputTag>("DTTM7_FED_Source")),
99  feds_(pset.getUntrackedParameter<std::vector<int> >("feds", std::vector<int>())),
100  wheels_(pset.getUntrackedParameter<std::vector<int> >("wheels", std::vector<int>())),
101  amcsecmap_(pset.getUntrackedParameter<std::vector<long long int> >("amcsecmap", std::vector<long long int>()))
102 
103 {
104  produces<L1MuDTChambPhContainer>("PhIn").setBranchAlias("PhIn");
105  produces<L1MuDTChambThContainer>("ThIn").setBranchAlias("ThIn");
106  produces<L1MuDTChambPhContainer>("PhOut").setBranchAlias("PhOut");
107 
108  Raw_token = consumes<FEDRawDataCollection>(DTTM7InputTag_);
109 
110  nfeds_ = feds_.size();
111 
112  if (nfeds_ != wheels_.size())
113  throw cms::Exception("TwinMux_unpacker") << "Configuration file error. Size of \'wheels\' and \'feds\' differs.\n";
114 
115  if (amcsecmap_.size() != wheels_.size())
116  throw cms::Exception("TwinMux_unpacker")
117  << "Configuration file error. Size of \'wheels\' and \'amcsecmap\' differs.\n";
118 
119  for (size_t wh_i = 0; wh_i < amcsecmap_.size(); ++wh_i) {
120  std::array<short, 12> whmap;
121  for (size_t amc_i = 1; amc_i < 13; ++amc_i) {
122  short shift = (12 - amc_i) * 4;
123  whmap[amc_i - 1] = (amcsecmap_[wh_i] >> shift) & 0xF;
124  }
125  amcsec_.push_back(whmap);
126  }
127 }
std::vector< long long int > amcsecmap_
std::vector< std::array< short, 12 > > amcsec_
std::vector< int > feds_
std::vector< int > wheels_
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
edm::InputTag DTTM7InputTag_
static unsigned int const shift

◆ ~L1TTwinMuxRawToDigi()

L1TTwinMuxRawToDigi::~L1TTwinMuxRawToDigi ( )
override

Destructor.

Definition at line 129 of file L1TTwinMuxRawToDigi.cc.

129 {}

Member Function Documentation

◆ benAngConversion()

int L1TTwinMuxRawToDigi::benAngConversion ( int  benAng_) const
private

Definition at line 186 of file L1TTwinMuxRawToDigi.cc.

Referenced by processFed().

186  {
187  if (benAng_ > 511)
188  return benAng_ - 1024;
189 
190  return benAng_;
191 }

◆ fillRawData()

bool L1TTwinMuxRawToDigi::fillRawData ( edm::Event e,
L1MuDTChambPhContainer::Phi_Container phi_data,
L1MuDTChambThContainer::The_Container the_data,
L1MuDTChambPhContainer::Phi_Container phi_out_data 
) const

Generate and fill FED raw data for a full event.

Definition at line 152 of file L1TTwinMuxRawToDigi.cc.

References amcsec_, data, MillePedeFileConverter_cfg::e, feds_, nfeds_, processFed(), Raw_token, and wheels_.

Referenced by produce().

155  {
157  e.getByToken(Raw_token, data);
158 
159  for (size_t w_i = 0; w_i < nfeds_; ++w_i) {
160  processFed(feds_[w_i], wheels_[w_i], amcsec_[w_i], data, phi_data, the_data, phi_out_data);
161  }
162 
163  return true;
164 }
std::vector< std::array< short, 12 > > amcsec_
std::vector< int > feds_
std::vector< int > wheels_
edm::EDGetTokenT< FEDRawDataCollection > Raw_token
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void processFed(int twinmuxfed, int wheel, std::array< short, 12 > const &twinMuxAmcSec, edm::Handle< FEDRawDataCollection > data, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTChambPhContainer::Phi_Container &phi_out_data) const

◆ getDTTM7InputTag()

edm::InputTag L1TTwinMuxRawToDigi::getDTTM7InputTag ( ) const
inlineprivate

Definition at line 84 of file L1TTwinMuxRawToDigi.cc.

References DTTM7InputTag_.

84 { return DTTM7InputTag_; }
edm::InputTag DTTM7InputTag_

◆ normBx()

int L1TTwinMuxRawToDigi::normBx ( int  bx_,
int  bxCnt_ 
) const
private

Definition at line 166 of file L1TTwinMuxRawToDigi.cc.

References funct::abs().

Referenced by processFed().

166  {
167  int bxNorm_ = bx_ - bxCnt_;
168  if (abs(bxNorm_) < 3000)
169  return bxNorm_;
170 
171  if (bxNorm_ > 0)
172  return bxNorm_ - 3564;
173  if (bxNorm_ < 0)
174  return bxNorm_ + 3564;
175 
176  return -99;
177 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ processFed()

void L1TTwinMuxRawToDigi::processFed ( int  twinmuxfed,
int  wheel,
std::array< short, 12 > const &  twinMuxAmcSec,
edm::Handle< FEDRawDataCollection data,
L1MuDTChambPhContainer::Phi_Container phi_data,
L1MuDTChambThContainer::The_Container the_data,
L1MuDTChambPhContainer::Phi_Container phi_out_data 
) const

Container

Debug

Header

Variables

–> Header - line 1 [must start with 0x5]

–> Header - line 2

–> AMC - line 3 to 3+nAMC

–> Store payloads

–> Trailer - line 1

–> Trailer - line 2 [must start with 0xA]

–> AMC trailer - line 2

do not consider the trailer

2 words already read, last removed because trailer with CRC

==>> increment 3

BX info + theta info word

Two's complement conversion Important: here value 0x20 has been treated as -32 when in fact it is an error code denoting incorrect readout window configuration, but the case should really not happen




BX info + theta info word

Phi info word. MBx determined by selector 0x01 - 0x04

Phi info word.

bx normalized to the bxcounter

Trailer of payload with CRC

Definition at line 193 of file L1TTwinMuxRawToDigi.cc.

References benAngConversion(), L1DTConfig_cfi::bxOffset, dt_crc::calcCRC(), RawDataTask_cfi::CRC, FEDRawData::data(), data, debug_, TauDecayModes::dec, alignmentValidation::fname, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, LogDebug, dqmPostProcessing_online::logfile, normBx(), or, radAngConversion(), readline(), hgcalTBTopologyTester_cfi::sector, FEDRawData::size(), makeMuonMisalignmentScenario::wheel, testProducerWithPsetDescEmpty_cfi::x1, and testProducerWithPsetDescEmpty_cfi::x2.

Referenced by fillRawData().

199  {
200  const unsigned int fw_rev_with_zerosupression =
201  93; // put the correct Firmware Revision of the first version with zerosuppression
202  int previous_selector = -100;
204  std::vector<long> DTTM7WordContainer;
205 
207  std::ofstream logfile;
208  if (debug_) {
209  std::ostringstream fname;
210  fname << "eventDump_" << twinMuxFed << ".txt";
211  logfile.open(fname.str());
212  }
213 
215  FEDRawData TM7data = data->FEDData(twinMuxFed);
216  if (TM7data.size() == 0)
217  return;
218 
220  unsigned char* lineFED = TM7data.data();
221  int nline = 0; // counting already include header
222  long dataWord = 0;
223  int newCRC = 0xFFFF;
224 
226  lineFED = readline(lineFED, nline, dataWord);
227  dt_crc::calcCRC(dataWord, newCRC);
228 
229  int TM7fedId = (dataWord >> 8) & 0xFFF; // positions 8 -> 19
230  /*** NOT UNPACKED
231  int bunchCnt = ( dataWord >> 20 ) & 0xFFF; // positions 20 -> 31
232  int eventCnt = ( dataWord >> 32 ) & 0xFFFFFF; // positions 32 -> 55
233  ***/
234  int BOEevTy = (dataWord >> 60) & 0xF; // positions 60 -> 63
235 
236  int linecounter = 0;
237  if (debug_)
238  logfile << '[' << ++linecounter << "]\t" << std::hex << dataWord << std::dec << "\t|\t"
239  << "BOEevTy " << BOEevTy << '\t' << "TM7fedId " << TM7fedId << '\n';
240 
241  if ((BOEevTy != 0x5) || (TM7fedId != twinMuxFed)) {
242  edm::LogWarning("TwinMux_unpacker") << "Not a TM7 of FED " << twinMuxFed << " header " << std::hex << dataWord;
243  return;
244  }
245 
247  lineFED = readline(lineFED, nline, dataWord);
248  dt_crc::calcCRC(dataWord, newCRC);
249 
250  std::map<int, int> AMCsizes;
251  /*** NOT UNPACKED
252  int orbit = ( dataWord >> 4 ) & 0xFFFFFFFF; // positions 4 -> 35
253  ***/
254  int nAMC = (dataWord >> 52) & 0xF; // positions 52 -> 55
255 
256  if (debug_)
257  logfile << '[' << ++linecounter << "]\t" << std::hex << dataWord << std::dec << "\t|\t"
258  << "nAMC " << nAMC << '\n';
259 
261  for (int j = 0; j < nAMC; ++j) {
262  lineFED = readline(lineFED, nline, dataWord);
263  dt_crc::calcCRC(dataWord, newCRC);
264 
265  int AMCno = (dataWord >> 16) & 0xF; // positions 16 -> 19
266  /*** NOT UNPACKED
267  int TM7boardID = dataWord & 0xFFFF; // positions 0 -> 15
268  int bulkno = (dataWord >> 20 ) & 0xFF; // positions 20 -> 27
269  ***/
270  if ((AMCno < 1) || (AMCno > 12)) {
271  edm::LogWarning("TwinMux_unpacker") << "AMCnumber " << std::dec << AMCno << " out of range (1-12)";
272  return;
273  }
274 
275  AMCsizes[AMCno] = (dataWord >> 32) & 0xFFFFFF; // positions 32 -> 55
276 
277  if (debug_)
278  logfile << '[' << ++linecounter << "]\t" << std::hex << dataWord << std::dec << "\t|\t"
279  << "AMCsizes[" << AMCno << "] " << AMCsizes[AMCno] << std::dec << '\n';
280  }
281 
283  std::map<int, int>::iterator AMCiterator = AMCsizes.begin();
284  std::map<int, int>::iterator AMCitend = AMCsizes.end();
285  for (; AMCiterator != AMCitend; ++AMCiterator) {
286  for (int k = 0; k < AMCiterator->second; ++k) {
287  lineFED = readline(lineFED, nline, dataWord);
288  dt_crc::calcCRC(dataWord, newCRC);
289 
290  DTTM7WordContainer.push_back(dataWord);
291  }
292  }
293 
295  lineFED = readline(lineFED, nline, dataWord);
296  dt_crc::calcCRC(dataWord, newCRC);
297 
299 
300  lineFED = readline(lineFED, nline, dataWord);
301  dt_crc::calcCRC(dataWord & 0xFFFFFFFF0000FFFF, newCRC);
302 
304  int chkEOE = (dataWord >> 60) & 0xF; // positions 60 -> 63
305  int CRC = (dataWord >> 16) & 0xFFFF; // positions 17 ->32
306  int evtLgth = (dataWord >> 32) & 0xFFFFFF; // positions 33 ->56
307 
308  if (chkEOE != 0xA) {
309  edm::LogWarning("TwinMux_unpacker") << "AMC block closing line " << std::hex << dataWord << std::dec
310  << " does not start with 0xA";
311  return;
312  }
313 
314  if (debug_)
315  logfile << "\tevtLgth " << std::hex << evtLgth << "\tCRC " << CRC << std::dec << '\n';
316 
317  if (nline != evtLgth) {
318  edm::LogWarning("TwinMux_unpacker") << "Number of words read " << std::dec << nline << " and event length "
319  << std::dec << evtLgth << " differ ";
320  return;
321  }
322 
323  if (newCRC != CRC) {
324  edm::LogWarning("TwinMux_unpacker") << "Calculated CRC " << std::hex << newCRC << " differs from CRC in trailer "
325  << std::hex << CRC;
326  return;
327  }
328 
329  // --> Analyze event
330  std::vector<long>::iterator DTTM7iterator = DTTM7WordContainer.begin();
331  std::vector<long>::iterator DTTM7itend = DTTM7WordContainer.end();
332 
333  int lcounter = 0;
334  for (; DTTM7iterator != DTTM7itend; ++DTTM7iterator) {
335  dataWord = (*DTTM7iterator);
336  int dataLenght = (dataWord & 0xFFFFF); // positions 0 -> 19
337  int bxCounter = (dataWord >> 20) & 0xFFF; // positions 20 -> 31
338  int event = (dataWord >> 32) & 0xFFFFFF; // positions 32 -> 55
339  int AMC_ID = (dataWord >> 56) & 0xF; // positions 56 -> 59
340  int control = (dataWord >> 60) & 0xF; // positions 59 -> 63
341  int wheel = twinMuxWheel;
342 
343  if ((AMC_ID < 1) or (AMC_ID > 12)) {
344  edm::LogWarning("TwinMux_unpacker") << "%%%%%% AMC_ID OUT OF RANGE \n"
345  << " TM7fedId " << TM7fedId << " AMC_ID " << AMC_ID;
346  break;
347  }
348 
349  int sector = twinMuxAmcSec[AMC_ID - 1];
350 
351  if ((sector < 1) or (sector > 12)) {
352  if (sector != 15)
353  edm::LogWarning("TwinMux_unpacker")
354  << "%%%%%% VALID AMC_ID POINTS TO SECTOR OUT OF RANGE \n"
355  << " TM7fedId " << TM7fedId << " AMC_ID " << AMC_ID << " wheel " << wheel << " sector " << sector;
356  break;
357  }
358 
359  if (debug_)
360  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWord << std::dec << "\t|\t"
361  << "AMC_ID " << AMC_ID << '\t' << "control " << control << '\t' << "event " << event << '\t'
362  << "bxCounter " << bxCounter << '\t' << "dataLenght " << dataLenght << '\n';
363 
364  ++DTTM7iterator; // User word empty /// ==>> increment 2
365  if (DTTM7iterator == DTTM7itend) {
366  LogDebug("TwinMux_unpacker") << "TRAILING WORD AS A PAYLOAD END in FED " << std::hex << TM7fedId << std::hex
367  << dataWord << std::dec << " [it pos " << int(DTTM7iterator - DTTM7itend) << " ]";
368  break;
369  }
370 
371  dataWord = (*DTTM7iterator);
372  unsigned int firmware_rev = (dataWord >> 7) & 0x1FF;
373  int boardID = (dataWord & 0xFFFF); // positions 0 -> 15
374  int orbit = (dataWord >> 16) & 0xFFFF; // positions 15 -> 32
375 
376  if (DTTM7iterator == DTTM7itend) {
377  edm::LogWarning("TwinMux_unpacker")
378  << "%%%%%% AMC_ID " << AMC_ID << " control " << control << " event " << event << " bxCounter " << bxCounter
379  << " size " << dataLenght << " orbit " << orbit << " board " << boardID << " AMCsizes " << AMCsizes[AMC_ID]
380  << " it pos " << int(DTTM7iterator - DTTM7itend);
381  break;
382  }
383 
384  if (debug_)
385  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWord << std::dec << "\t|\t"
386  << " orbit " << orbit << " board " << boardID << '\n';
387 
388  int AMCsize = AMCsizes[AMC_ID] - 1;
389  int bxID = 99;
390  int bc0 = -99;
391  int bxNr = -99;
392 
394  for (int tm7eventsize = 2; tm7eventsize < AMCsize; ++tm7eventsize) {
395  ++DTTM7iterator;
396  if (DTTM7iterator == DTTM7itend) {
397  edm::LogWarning("TwinMux_unpacker") << "UNEXPECTED END OF PAYLOAD INSIDE CHAMBER DESCRIPTION"
398  << " [it pos " << int(DTTM7iterator - DTTM7itend) << " ]";
399  break;
400  }
401 
402  long dataWordSub = (*DTTM7iterator);
403  int selector = (dataWordSub >> 60) & 0xF; // positions 60 -> 63
404 
405  if (firmware_rev >= fw_rev_with_zerosupression) { // zerosuppressed data unpacking
406  if (selector == 0xC) {
407 
408  bc0 = (dataWordSub >> 59) & 0x1; // position 59
409  /*** NOT UNPACKED
410  int L1A = ( dataWordSub >> 58) & 0x1; // position 58
411  ***/
412  int bxOffset = (dataWordSub >> 48) & 0x3F; // positions 48 -> 53
416  bxNr = bxOffset < 32 ? bxOffset : bxOffset - 64;
417 
418  //eta info
419 
420  int posBTI[7], qualBTI[7];
421 
422  int mb3_eta = (dataWordSub & 0xFF); // positions 0 -> 7
423  int mb3_eta_HQ = (dataWordSub >> 8) & 0xFF; // positions 8 -> 15
424  int mb2_eta = (dataWordSub >> 16) & 0xFF; // positions 16 -> 23
425  int mb2_eta_HQ = (dataWordSub >> 24) & 0xFF; // positions 24 -> 31
426  int mb1_eta = (dataWordSub >> 32) & 0xFF; // positions 32 -> 39
427  int mb1_eta_HQ = (dataWordSub >> 40) & 0xFF; // positions 40 -> 47
428 
429  //MB1
430  for (int i = 0; i <= 5; i++) {
431  posBTI[i] = (mb1_eta >> i) & 0x01;
432  qualBTI[i] = (mb1_eta_HQ >> i) & 0x01;
433  }
434  posBTI[6] = (((mb1_eta >> 6) & 0x01) || ((mb1_eta >> 7) & 0x01));
435  qualBTI[6] = (((mb1_eta_HQ >> 6) & 0x01) || ((mb1_eta_HQ >> 7) & 0x01));
436 
437  theSegments.push_back(L1MuDTChambThDigi(bxNr, wheel, sector - 1, 1, posBTI, qualBTI));
438 
439  // posBTI and qualBTI are reused!
440 
441  //MB2
442  for (int i = 0; i <= 5; i++) {
443  posBTI[i] = (mb2_eta >> i) & 0x01;
444  qualBTI[i] = (mb2_eta_HQ >> i) & 0x01;
445  }
446  posBTI[6] = ((mb2_eta >> 6) & 0x01) || ((mb2_eta >> 7) & 0x01);
447  qualBTI[6] = ((mb2_eta_HQ >> 6) & 0x01) || ((mb2_eta_HQ >> 7) & 0x01);
448 
449  theSegments.push_back(L1MuDTChambThDigi(bxNr, wheel, sector - 1, 2, posBTI, qualBTI));
450 
451  //MB3
452  for (int i = 0; i <= 5; i++) {
453  posBTI[i] = (mb3_eta >> i) & 0x01;
454  qualBTI[i] = (mb3_eta_HQ >> i) & 0x01;
455  }
456  posBTI[6] = ((mb3_eta >> 6) & 0x01) || ((mb3_eta >> 7) & 0x01);
457  qualBTI[6] = ((mb3_eta_HQ >> 6) & 0x01) || ((mb3_eta_HQ >> 7) & 0x01);
458 
459  theSegments.push_back(L1MuDTChambThDigi(bxNr, wheel, sector - 1, 3, posBTI, qualBTI));
460 
461  if (debug_)
462  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t bx info word\t"
463  << "bxOffset " << bxOffset << '\t' << "bc0 " << bc0 << '\t' << "mb1_eta " << mb1_eta << '\t'
464  << "mb2_eta " << mb2_eta << '\t' << "mb3_eta " << mb3_eta << '\t' << "mb1_eta_HQ " << mb1_eta_HQ
465  << '\t' << "mb2_eta_HQ " << mb2_eta_HQ << '\t' << "mb3_eta_HQ " << mb3_eta_HQ << '\n';
466 
467  }
468 
469  else if (selector >= 1 && selector <= 4) {
470 
471  int out_phi = (dataWordSub >> 0) & 0xFFF; // positions 0 -> 11
472  int out_phib = (dataWordSub >> 12) & 0x3FF; // positions 12 -> 21
473  int out_qual = (dataWordSub >> 22) & 0x7; // positions 22 -> 24
474  int out_q3 = (dataWordSub >> 25) & 0x1; // positions 25
475  int out_q4 = (dataWordSub >> 26) & 0x1; // positions 26
476  int out_updown = (dataWordSub >> 27) & 0x1; // positions 27
477  int out_ts2tag = (dataWordSub >> 28) & 0x1; // positions 28
478  /*** NOT UNPACKED
479  int out_parity = ( dataWordSub >> 29) & 0x1; // positions 29
480  ***/
481  int in_phi = (dataWordSub >> 30) & 0xFFF; // positions 30 -> 41
482  int in_phib = (dataWordSub >> 42) & 0x3FF; // positions 42 -> 51
483  int in_qual = (dataWordSub >> 52) & 0x7; // positions 52 -> 54
484  int in_updown = (dataWordSub >> 57) & 0x1; // positions 57
485  int in_ts2tag = (dataWordSub >> 58) & 0x1; // positions 58
486  /*** NOT UNPACKED
487  int in_parity = ( dataWordSub >> 59) & 0x1; // positions 59
488  ***/
489 
490  int in_phi_conv = radAngConversion(in_phi);
491  int in_phib_conv = benAngConversion(in_phib);
492  int out_phi_conv = radAngConversion(out_phi);
493  int out_phib_conv = benAngConversion(out_phib);
494 
495  if (previous_selector != selector) { // first track
496  if (in_qual != 7) {
497  phiSegments.push_back(L1MuDTChambPhDigi(bxNr,
498  wheel,
499  sector - 1,
500  selector,
501  in_phi_conv,
502  in_phib_conv,
503  in_qual,
504  in_ts2tag + in_updown * 2,
505  bxCounter));
506  }
507  if (out_qual != 7) {
508  phioutSegments.push_back(L1MuDTChambPhDigi(bxNr,
509  wheel,
510  sector - 1,
511  selector,
512  out_phi_conv,
513  out_phib_conv,
514  out_qual,
515  out_ts2tag + out_updown * 2,
516  bxCounter,
517  out_q3 + 2 * out_q4));
518  }
519  } else { // currently no seperation between first/second in data, keep it for possible later fix
520  // second track
521  if (in_qual != 7) {
522  phiSegments.push_back(L1MuDTChambPhDigi(bxNr,
523  wheel,
524  sector - 1,
525  selector,
526  in_phi_conv,
527  in_phib_conv,
528  in_qual,
529  in_ts2tag + in_updown * 2,
530  bxCounter));
531  }
532 
533  if (out_qual != 7) {
534  phioutSegments.push_back(L1MuDTChambPhDigi(bxNr,
535  wheel,
536  sector - 1,
537  selector,
538  out_phi_conv,
539  out_phib_conv,
540  out_qual,
541  out_ts2tag + out_updown * 2,
542  bxCounter,
543  out_q3 + 2 * out_q4));
544  }
545  }
546  if (debug_)
547  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t|\t"
548  << "in_ts2tag " << in_ts2tag << '\t' << "in_updown " << in_updown << '\t' << "in_qual " << in_qual
549  << '\t' << "in_phib " << in_phib_conv << '\t' << "in_phi " << in_phi_conv << '\t' << "out_ts2tag "
550  << out_ts2tag << '\t' << "out_updown " << out_updown << '\t' << "out_qual " << out_qual << '\t'
551  << "out_q3_out " << out_q3 << '\t' << "out_q4_out " << out_q4 << '\t' << "out_phib "
552  << out_phib_conv << '\t' << "out_phi " << out_phi_conv << '\t' << "2nd track "
553  << ((previous_selector == selector) ? 1 : 0) << '\n';
554  }
555 
556  else if (selector == 0x9 || selector == 0xE) { //RPC word
557 
558  LogDebug("TwinMux_unpacker") << "RPC WORD [" << std::dec << tm7eventsize << "] : " << std::hex << dataWordSub
559  << std::dec << " it pos " << int(DTTM7iterator - DTTM7itend);
560 
561  if (debug_)
562  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t RPC WORD\n";
563 
564  } //RPC word
565 
566  else if (selector == 0x6) { //HO word
567 
568  LogDebug("TwinMux_unpacker") << "HO WORD [" << std::dec << tm7eventsize << "] : " << std::hex << dataWordSub
569  << std::dec << " it pos " << int(DTTM7iterator - DTTM7itend);
570 
571  if (debug_)
572  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t HO WORD\n";
573 
574  } //HO word
575 
576  else if (selector == 0xF) { //ERROR word
577 
578  LogDebug("TwinMux_unpacker") << "ERROR WORD [" << std::dec << tm7eventsize << "] : " << std::hex
579  << dataWordSub << std::dec << " it pos " << int(DTTM7iterator - DTTM7itend);
580 
581  if (debug_)
582  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t ERROR WORD\n";
583  } //ERROR word
584 
585  else { //unkown word
586 
587  LogDebug("TwinMux_unpacker") << "UNKNOWN WORD received " << std::hex << dataWordSub << " in FED " << std::hex
588  << TM7fedId;
589 
590  if (debug_)
591  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t UNKNOWN WORD\n";
592  }
593  previous_selector = selector; // store selector to identify 2nd track
594  } else {
595  // normal data unpacking below
596  if (selector == 0x4) { //TSC word
597 
598  bxID = (dataWordSub >> 48) & 0xFFF; // positions 48 -> 60
599  bc0 = (dataWordSub >> 22) & 0x1; // positions 22 -> 23
600  bxNr = normBx(bxID, bxCounter);
601 
602  if (debug_)
603  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t TSC WORD\t"
604  << "bxID " << bxID << '\t' << "bc0 " << bc0 << '\n';
605 
606  } //TSC WORD
607 
608  else if (selector == 0x1) { //MB1/2 word
609 
610  int mb2_phi = (dataWordSub & 0xFFF); // positions 0 -> 11
611  int mb2_phib = (dataWordSub >> 12) & 0x3FF; // positions 12 -> 21
612  int mb2_qual = (dataWordSub >> 22) & 0x7; // positions 22 -> 24
613  int mb2_ts2tag = (dataWordSub >> 28) & 0x1; // positions 28
614  /*** NOT UNPACKED
615  int mb2_parity = ( dataWordSub >> 29) & 0x1; // positions 29
616  ***/
617 
618  int mb1_phi = (dataWordSub >> 30) & 0xFFF; // positions 30 -> 41
619  int mb1_phib = (dataWordSub >> 42) & 0x3FF; // positions 42 -> 51
620  int mb1_qual = (dataWordSub >> 52) & 0x7; // positions 52 -> 54
621  int mb1_ts2tag = (dataWordSub >> 58) & 0x1; // positions 58
622  /*** NOT UNPACKED
623  int mb1_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
624  ***/
625 
626  int mb1_phi_conv = radAngConversion(mb1_phi);
627  int mb1_phib_conv = benAngConversion(mb1_phib);
628 
629  int mb2_phi_conv = radAngConversion(mb2_phi);
630  int mb2_phib_conv = benAngConversion(mb2_phib);
631 
632  phiSegments.push_back(L1MuDTChambPhDigi(
633  bxNr, wheel, sector - 1, 1, mb1_phi_conv, mb1_phib_conv, mb1_qual, mb1_ts2tag, bxCounter, -1));
634  phiSegments.push_back(L1MuDTChambPhDigi(
635  bxNr, wheel, sector - 1, 2, mb2_phi_conv, mb2_phib_conv, mb2_qual, mb2_ts2tag, bxCounter, -1));
636 
637  if (debug_)
638  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t|\t"
639  << "mb1_ts2tag " << mb1_ts2tag << '\t' << "mb1_qual " << mb1_qual << '\t' << "mb1_phib "
640  << mb1_phib_conv << '\t' << "mb1_phi " << mb1_phi_conv << '\t' << "mb2_ts2tag " << mb2_ts2tag
641  << '\t' << "mb2_qual " << mb2_qual << '\t' << "mb2_phib " << mb2_phib_conv << '\t' << "mb2_phi "
642  << mb2_phi_conv << '\n';
643  } //MB1/2 word
644 
645  else if (selector == 0x2) {
646  int mb4_phi = (dataWordSub & 0xFFF); // positions 0 -> 11
647  int mb4_phib = (dataWordSub >> 12) & 0x3FF; // positions 12 -> 21
648  int mb4_qual = (dataWordSub >> 22) & 0x7; // positions 22 -> 24
649  int mb4_ts2tag = (dataWordSub >> 28) & 0x1; // positions 28
650  /*** NOT UNPACKED
651  int mb4_parity = ( dataWordSub >> 29) & 0x1; // positions 29
652  ***/
653 
654  int mb3_phi = (dataWordSub >> 30) & 0xFFF; // positions 30 -> 41
655  int mb3_phib = (dataWordSub >> 42) & 0x3FF; // positions 42 -> 51
656  int mb3_qual = (dataWordSub >> 52) & 0x7; // positions 52 -> 54
657  int mb3_ts2tag = (dataWordSub >> 58) & 0x1; // positions 58
658  /*** NOT UNPACKED
659  int mb3_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
660  ***/
661 
662  int mb3_phi_conv = radAngConversion(mb3_phi);
663  int mb3_phib_conv = benAngConversion(mb3_phib);
664 
665  int mb4_phi_conv = radAngConversion(mb4_phi);
666  int mb4_phib_conv = benAngConversion(mb4_phib);
667 
668  phiSegments.push_back(L1MuDTChambPhDigi(
669  bxNr, wheel, sector - 1, 3, mb3_phi_conv, mb3_phib_conv, mb3_qual, mb3_ts2tag, bxCounter, -1));
670  phiSegments.push_back(L1MuDTChambPhDigi(
671  bxNr, wheel, sector - 1, 4, mb4_phi_conv, mb4_phib_conv, mb4_qual, mb4_ts2tag, bxCounter, -1));
672 
673  if (debug_)
674  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t|\t"
675  << "mb3_ts2tag " << mb3_ts2tag << '\t' << "mb3_qual " << mb3_qual << '\t' << "mb3_phib "
676  << mb3_phib_conv << '\t' << "mb3_phi " << mb3_phi_conv << '\t' << "mb4_ts2tag " << mb4_ts2tag
677  << '\t' << "mb4_qual " << mb4_qual << '\t' << "mb4_phib " << mb4_phib_conv << '\t' << "mb4_phi "
678  << mb4_phi_conv << '\n';
679 
680  } //MB3/4 word
681 
682  else if (selector == 0x3) { //etha word
683 
684  int posBTI[7], qualBTI[7];
685 
686  int mb3_eta = (dataWordSub & 0xFF); // positions 0 -> 7
687  int mb2_eta = (dataWordSub >> 16) & 0xFF; // positions 16 -> 23
688  int mb1_eta = (dataWordSub >> 40) & 0xFF; // positions 40 -> 47
689 
690  int mb3_eta_HQ = (dataWordSub >> 8) & 0xFF; // positions 8 -> 15
691  int mb2_eta_HQ = (dataWordSub >> 32) & 0xFF; // positions 32 -> 39
692  int mb1_eta_HQ = (dataWordSub >> 48) & 0xFF; // positions 48 -> 55
693 
694  if (debug_)
695  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t|\t"
696  << "mb1_eta " << mb1_eta << '\t' << "mb2_eta " << mb2_eta << '\t' << "mb3_eta " << mb3_eta << '\t'
697  << "mb1_eta_HQ " << mb1_eta_HQ << '\t' << "mb2_eta_HQ " << mb2_eta_HQ << '\t' << "mb3_eta_HQ "
698  << mb3_eta_HQ << '\n';
699 
700  //MB1
701  posBTI[0] = (mb1_eta & 0x01);
702  posBTI[1] = ((mb1_eta & 0x02) >> 1);
703  posBTI[2] = ((mb1_eta & 0x04) >> 2);
704  posBTI[3] = ((mb1_eta & 0x08) >> 3);
705  posBTI[4] = ((mb1_eta & 0x10) >> 4);
706  posBTI[5] = ((mb1_eta & 0x20) >> 5);
707  posBTI[6] = (((mb1_eta & 0x40) >> 6) || ((mb1_eta & 0x80) >> 7));
708 
709  qualBTI[0] = (mb1_eta_HQ & 0x01);
710  qualBTI[1] = ((mb1_eta_HQ & 0x02) >> 1);
711  qualBTI[2] = ((mb1_eta_HQ & 0x04) >> 2);
712  qualBTI[3] = ((mb1_eta_HQ & 0x08) >> 3);
713  qualBTI[4] = ((mb1_eta_HQ & 0x10) >> 4);
714  qualBTI[5] = ((mb1_eta_HQ & 0x20) >> 5);
715  qualBTI[6] = (((mb1_eta_HQ & 0x40) >> 6) || ((mb1_eta_HQ & 0x80) >> 7));
716 
717  theSegments.push_back(L1MuDTChambThDigi(bxNr, wheel, sector - 1, 1, posBTI, qualBTI));
718 
719  //MB2
720  posBTI[0] = (mb2_eta & 0x01);
721  posBTI[1] = ((mb2_eta & 0x02) >> 1);
722  posBTI[2] = ((mb2_eta & 0x04) >> 2);
723  posBTI[3] = ((mb2_eta & 0x08) >> 3);
724  posBTI[4] = ((mb2_eta & 0x10) >> 4);
725  posBTI[5] = ((mb2_eta & 0x20) >> 5);
726  posBTI[6] = (((mb2_eta & 0x40) >> 6) || ((mb2_eta & 0x80) >> 7));
727 
728  qualBTI[0] = (mb2_eta_HQ & 0x01);
729  qualBTI[1] = ((mb2_eta_HQ & 0x02) >> 1);
730  qualBTI[2] = ((mb2_eta_HQ & 0x04) >> 2);
731  qualBTI[3] = ((mb2_eta_HQ & 0x08) >> 3);
732  qualBTI[4] = ((mb2_eta_HQ & 0x10) >> 4);
733  qualBTI[5] = ((mb2_eta_HQ & 0x20) >> 5);
734  qualBTI[6] = (((mb2_eta_HQ & 0x40) >> 6) || ((mb2_eta_HQ & 0x80) >> 7));
735 
736  theSegments.push_back(L1MuDTChambThDigi(bxNr, wheel, sector - 1, 2, posBTI, qualBTI));
737 
738  //MB3
739  posBTI[0] = (mb3_eta & 0x01);
740  posBTI[1] = ((mb3_eta & 0x02) >> 1);
741  posBTI[2] = ((mb3_eta & 0x04) >> 2);
742  posBTI[3] = ((mb3_eta & 0x08) >> 3);
743  posBTI[4] = ((mb3_eta & 0x10) >> 4);
744  posBTI[5] = ((mb3_eta & 0x20) >> 5);
745  posBTI[6] = (((mb3_eta & 0x40) >> 6) || ((mb3_eta & 0x80) >> 7));
746 
747  qualBTI[0] = (mb3_eta_HQ & 0x01);
748  qualBTI[1] = ((mb3_eta_HQ & 0x02) >> 1);
749  qualBTI[2] = ((mb3_eta_HQ & 0x04) >> 2);
750  qualBTI[3] = ((mb3_eta_HQ & 0x08) >> 3);
751  qualBTI[4] = ((mb3_eta_HQ & 0x10) >> 4);
752  qualBTI[5] = ((mb3_eta_HQ & 0x20) >> 5);
753  qualBTI[6] = (((mb3_eta_HQ & 0x40) >> 6) || ((mb3_eta_HQ & 0x80) >> 7));
754 
755  theSegments.push_back(L1MuDTChambThDigi(bxNr, wheel, sector - 1, 3, posBTI, qualBTI));
756 
757  } //etha word
758 
759  else if (selector == 0xB) { //MB1/2 output word
760 
761  int mb2_phi = (dataWordSub & 0xFFF); // positions 0 -> 11
762  int mb2_phib = (dataWordSub >> 12) & 0x3FF; // positions 12 -> 21
763  int mb2_qual = (dataWordSub >> 22) & 0x7; // positions 22 -> 24
764  int mb2_q3 = (dataWordSub >> 25) & 0x1; // positions 25
765  int mb2_q4 = (dataWordSub >> 26) & 0x1; // positions 26
766  int mb2_ts2tag = (dataWordSub >> 28) & 0x1; // positions 28
767  /*** NOT UNPACKED
768  int mb2_parity = ( dataWordSub >> 29) & 0x1; // positions 29
769  ***/
770 
771  int mb1_phi = (dataWordSub >> 30) & 0xFFF; // positions 30 -> 41
772  int mb1_phib = (dataWordSub >> 42) & 0x3FF; // positions 42 -> 51
773  int mb1_qual = (dataWordSub >> 52) & 0x7; // positions 52 -> 54
774  int mb1_q3 = (dataWordSub >> 55) & 0x1; // positions 55
775  int mb1_q4 = (dataWordSub >> 56) & 0x1; // positions 56
776  int mb1_ts2tag = (dataWordSub >> 58) & 0x1; // positions 58
777  /*** NOT UNPACKED
778  int mb1_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
779  ***/
780 
781  int mb1_phi_conv = radAngConversion(mb1_phi);
782  int mb1_phib_conv = benAngConversion(mb1_phib);
783 
784  int mb2_phi_conv = radAngConversion(mb2_phi);
785  int mb2_phib_conv = benAngConversion(mb2_phib);
786 
787  phioutSegments.push_back(L1MuDTChambPhDigi(bxNr,
788  wheel,
789  sector - 1,
790  1,
791  mb1_phi_conv,
792  mb1_phib_conv,
793  mb1_qual,
794  mb1_ts2tag,
795  bxCounter,
796  mb1_q3 + 2 * mb1_q4));
797  phioutSegments.push_back(L1MuDTChambPhDigi(bxNr,
798  wheel,
799  sector - 1,
800  2,
801  mb2_phi_conv,
802  mb2_phib_conv,
803  mb2_qual,
804  mb2_ts2tag,
805  bxCounter,
806  mb2_q3 + 2 * mb2_q4));
807 
808  if (debug_)
809  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t|\t"
810  << "mb1_ts2tag_out " << mb1_ts2tag << '\t' << "mb1_qual_out " << mb1_qual << '\t' << "mb1_q3_out "
811  << mb1_q3 << '\t' << "mb1_q4_out " << mb1_q4 << '\t' << "mb1_phib_out " << mb1_phib_conv << '\t'
812  << "mb1_phi_out " << mb1_phi_conv << '\t' << "mb2_ts2tag_out " << mb2_ts2tag << '\t'
813  << "mb2_qual_out " << mb2_qual << '\t' << "mb2_q3_out " << mb2_q3 << '\t' << "mb2_q4_out " << mb2_q4
814  << '\t' << "mb2_phib_out " << mb2_phib_conv << '\t' << "mb2_phi_out " << mb2_phi_conv << '\n';
815 
816  } //MB1/2 output word
817 
818  else if (selector == 0xC) { //MB3/4 output word
819 
820  int mb4_phi = (dataWordSub & 0xFFF); // positions 0 -> 11
821  int mb4_phib = (dataWordSub >> 12) & 0x3FF; // positions 12 -> 21
822  int mb4_qual = (dataWordSub >> 22) & 0x7; // positions 22 -> 24
823  int mb4_q3 = (dataWordSub >> 25) & 0x1; // positions 25
824  int mb4_q4 = (dataWordSub >> 26) & 0x1; // positions 26
825  int mb4_ts2tag = (dataWordSub >> 28) & 0x1; // positions 28
826  /*** NOT UNPACKED
827  int mb4_parity = ( dataWordSub >> 29) & 0x1; // positions 29
828  ***/
829 
830  int mb3_phi = (dataWordSub >> 30) & 0xFFF; // positions 30 -> 41
831  int mb3_phib = (dataWordSub >> 42) & 0x3FF; // positions 42 -> 51
832  int mb3_qual = (dataWordSub >> 52) & 0x7; // positions 52 -> 54
833  int mb3_q3 = (dataWordSub >> 55) & 0x1; // positions 55
834  int mb3_q4 = (dataWordSub >> 56) & 0x1; // positions 56
835  int mb3_ts2tag = (dataWordSub >> 58) & 0x1; // positions 58
836  /*** NOT UNPACKED
837  int mb3_parity = ( dataWordSub >> 59 ) &0x1; // positions 59
838  ***/
839 
840  int mb3_phi_conv = radAngConversion(mb3_phi);
841  int mb3_phib_conv = benAngConversion(mb3_phib);
842 
843  int mb4_phi_conv = radAngConversion(mb4_phi);
844  int mb4_phib_conv = benAngConversion(mb4_phib);
845 
846  phioutSegments.push_back(L1MuDTChambPhDigi(bxNr,
847  wheel,
848  sector - 1,
849  3,
850  mb3_phi_conv,
851  mb3_phib_conv,
852  mb3_qual,
853  mb3_ts2tag,
854  bxCounter,
855  mb3_q3 + 2 * mb3_q4));
856  phioutSegments.push_back(L1MuDTChambPhDigi(bxNr,
857  wheel,
858  sector - 1,
859  4,
860  mb4_phi_conv,
861  mb4_phib_conv,
862  mb4_qual,
863  mb4_ts2tag,
864  bxCounter,
865  mb4_q3 + 2 * mb4_q4));
866 
867  if (debug_)
868  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t|\t"
869  << "mb3_ts2tag_out " << mb3_ts2tag << '\t' << "mb3_qual_out " << mb3_qual << '\t' << "mb3_q3_out "
870  << mb3_q3 << '\t' << "mb3_q4_out " << mb3_q4 << '\t' << "mb3_phib_out " << mb3_phib_conv << '\t'
871  << "mb3_phi_out " << mb3_phi_conv << '\t' << "mb4_ts2tag_out " << mb4_ts2tag << '\t'
872  << "mb4_qual_out " << mb4_qual << '\t' << "mb4_q3_out " << mb4_q3 << '\t' << "mb4_q4_out " << mb4_q4
873  << '\t' << "mb4_phib_out " << mb4_phib_conv << '\t' << "mb4_phi_out " << mb4_phi_conv << '\n';
874 
875  } //MB3/4 output word
876 
877  else if (selector == 0xD) { //etha output word
878 
879  if (debug_)
880  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t ETHA OUTPUT WORD\n";
881 
882  } //etha output word
883 
884  else if (selector == 0x9 || selector == 0xE) { //RPC word
885 
886  LogDebug("TwinMux_unpacker") << "RPC WORD [" << std::dec << tm7eventsize << "] : " << std::hex << dataWordSub
887  << std::dec << " it pos " << int(DTTM7iterator - DTTM7itend);
888 
889  if (debug_)
890  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t RPC WORD\n";
891 
892  } //RPC word
893 
894  else if (selector == 0x6) { //HO word
895 
896  LogDebug("TwinMux_unpacker") << "HO WORD [" << std::dec << tm7eventsize << "] : " << std::hex << dataWordSub
897  << std::dec << " it pos " << int(DTTM7iterator - DTTM7itend);
898 
899  if (debug_)
900  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t HO WORD\n";
901 
902  } //HO word
903 
904  else if (selector == 0xF) { //ERROR word
905 
906  LogDebug("TwinMux_unpacker") << "ERROR WORD [" << std::dec << tm7eventsize << "] : " << std::hex
907  << dataWordSub << std::dec << " it pos " << int(DTTM7iterator - DTTM7itend);
908 
909  if (debug_)
910  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t ERROR WORD\n";
911  } //ERROR word
912 
913  else { //unkown word
914 
915  LogDebug("TwinMux_unpacker") << "UNKNOWN WORD received " << std::hex << dataWordSub << " in FED " << std::hex
916  << TM7fedId;
917 
918  if (debug_)
919  logfile << '[' << ++lcounter << "]\t" << std::hex << dataWordSub << std::dec << "\t UNKNOWN WORD\n";
920  }
921 
922  if (DTTM7iterator == DTTM7itend)
923  break;
924  }
925  } //end of loop over AMCsize
926 
928  ++DTTM7iterator;
929 
930  if (DTTM7iterator == DTTM7itend)
931  break;
932 
933  } // end for-loop container content
934 
935  return;
936 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
unsigned char * readline(unsigned char *lineFED, int &lines, long &dataWord) const
int benAngConversion(int benAng_) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
int normBx(int bx_, int bxCnt_) const
int radAngConversion(int radAng_) const
string fname
main script
void calcCRC(long, int &)
Definition: DTCRC.cc:3
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
Log< level::Warning, false > LogWarning
#define LogDebug(id)

◆ produce()

void L1TTwinMuxRawToDigi::produce ( edm::StreamID  ,
edm::Event e,
const edm::EventSetup c 
) const
overridevirtual

Produce digis out of raw data.

Implements edm::global::EDProducerBase.

Definition at line 131 of file L1TTwinMuxRawToDigi.cc.

References MillePedeFileConverter_cfg::e, fillRawData(), and eostools::move().

131  {
132  std::unique_ptr<L1MuDTChambPhContainer> TM7phi_product(new L1MuDTChambPhContainer);
133  std::unique_ptr<L1MuDTChambThContainer> TM7the_product(new L1MuDTChambThContainer);
134  std::unique_ptr<L1MuDTChambPhContainer> TM7phi_out_product(new L1MuDTChambPhContainer);
135 
139 
140  if (!fillRawData(e, phi_data, the_data, phi_out_data))
141  return;
142 
143  TM7phi_product->setContainer(phi_data);
144  TM7the_product->setContainer(the_data);
145  TM7phi_out_product->setContainer(phi_out_data);
146 
147  e.put(std::move(TM7phi_product), "PhIn");
148  e.put(std::move(TM7the_product), "ThIn");
149  e.put(std::move(TM7phi_out_product), "PhOut");
150 }
bool fillRawData(edm::Event &e, L1MuDTChambPhContainer::Phi_Container &phi_data, L1MuDTChambThContainer::The_Container &the_data, L1MuDTChambPhContainer::Phi_Container &phi_out_data) const
Generate and fill FED raw data for a full event.
std::vector< L1MuDTChambPhDigi > Phi_Container
std::vector< L1MuDTChambThDigi > The_Container
def move(src, dest)
Definition: eostools.py:511

◆ radAngConversion()

int L1TTwinMuxRawToDigi::radAngConversion ( int  radAng_) const
private

Definition at line 179 of file L1TTwinMuxRawToDigi.cc.

Referenced by processFed().

179  {
180  if (radAng_ > 2047)
181  return radAng_ - 4096;
182 
183  return radAng_;
184 }

◆ readline()

unsigned char* L1TTwinMuxRawToDigi::readline ( unsigned char *  lineFED,
int &  lines,
long &  dataWord 
) const
inlineprivate

Definition at line 77 of file L1TTwinMuxRawToDigi.cc.

References groupFilesInBlocks::lines.

Referenced by processFed().

77  {
78  dataWord = *((long*)lineFED);
79  lineFED += 8;
80  ++lines;
81  return lineFED;
82  }

Member Data Documentation

◆ amcsec_

std::vector<std::array<short, 12> > L1TTwinMuxRawToDigi::amcsec_
private

Definition at line 74 of file L1TTwinMuxRawToDigi.cc.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().

◆ amcsecmap_

std::vector<long long int> L1TTwinMuxRawToDigi::amcsecmap_
private

Definition at line 73 of file L1TTwinMuxRawToDigi.cc.

Referenced by L1TTwinMuxRawToDigi().

◆ debug_

bool L1TTwinMuxRawToDigi::debug_
private

Definition at line 68 of file L1TTwinMuxRawToDigi.cc.

Referenced by processFed().

◆ DTTM7InputTag_

edm::InputTag L1TTwinMuxRawToDigi::DTTM7InputTag_
private

Definition at line 70 of file L1TTwinMuxRawToDigi.cc.

Referenced by getDTTM7InputTag(), and L1TTwinMuxRawToDigi().

◆ feds_

std::vector<int> L1TTwinMuxRawToDigi::feds_
private

Definition at line 71 of file L1TTwinMuxRawToDigi.cc.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().

◆ nfeds_

size_t L1TTwinMuxRawToDigi::nfeds_
private

Definition at line 69 of file L1TTwinMuxRawToDigi.cc.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().

◆ Raw_token

edm::EDGetTokenT<FEDRawDataCollection> L1TTwinMuxRawToDigi::Raw_token
private

Definition at line 86 of file L1TTwinMuxRawToDigi.cc.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().

◆ wheels_

std::vector<int> L1TTwinMuxRawToDigi::wheels_
private

Definition at line 72 of file L1TTwinMuxRawToDigi.cc.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().