CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
L1TTwinMuxRawToDigi Class Reference

#include <L1TTwinMuxRawToDigi.h>

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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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)
 
 ~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
 
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::vector< ModuleDescription const * > &modules, 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
 
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
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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 30 of file L1TTwinMuxRawToDigi.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 34 of file L1TTwinMuxRawToDigi.cc.

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

34  :
35 
36  debug_( pset.getUntrackedParameter<bool>("debug", false) ),
37  nfeds_(0),
38  DTTM7InputTag_( pset.getParameter<edm::InputTag>("DTTM7_FED_Source") ),
39  feds_( pset.getUntrackedParameter<std::vector<int> >("feds", std::vector<int>()) ),
40  wheels_( pset.getUntrackedParameter<std::vector<int> >("wheels", std::vector<int>())),
41  amcsecmap_( pset.getUntrackedParameter<std::vector<long long int> >("amcsecmap", std::vector<long long int>()))
42 
43 {
44 
45  produces<L1MuDTChambPhContainer>("PhIn").setBranchAlias("PhIn");
46  produces<L1MuDTChambThContainer>("ThIn").setBranchAlias("ThIn");
47  produces<L1MuDTChambPhContainer>("PhOut").setBranchAlias("PhOut");
48 
49  Raw_token = consumes<FEDRawDataCollection> (DTTM7InputTag_);
50 
51  nfeds_ = feds_.size();
52 
53  if ( nfeds_ != wheels_.size() )
54  throw cms::Exception("TwinMux_unpacker") << "Configuration file error. Size of \'wheels\' and \'feds\' differs.\n";
55 
56  if ( amcsecmap_.size() != wheels_.size() )
57  throw cms::Exception("TwinMux_unpacker") << "Configuration file error. Size of \'wheels\' and \'amcsecmap\' differs.\n";
58 
59  for (size_t wh_i = 0; wh_i < amcsecmap_.size(); ++wh_i){
60  std::array<short, 12> whmap;
61  for (size_t amc_i = 1; amc_i < 13; ++amc_i ) {
62  short shift = (12-amc_i)*4;
63  whmap[amc_i-1] = ( amcsecmap_[wh_i] >> shift ) & 0xF;
64  }
65  amcsec_.push_back(whmap);
66  }
67 
68 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
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 ( )
override

Destructor.

Definition at line 70 of file L1TTwinMuxRawToDigi.cc.

70 {}

Member Function Documentation

int L1TTwinMuxRawToDigi::benAngConversion ( int  benAng_) const
private

Definition at line 133 of file L1TTwinMuxRawToDigi.cc.

Referenced by processFed().

133  {
134 
135  if (benAng_>511)
136  return benAng_-1024;
137 
138  return benAng_;
139 
140 }
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 96 of file L1TTwinMuxRawToDigi.cc.

References amcsec_, data, feds_, edm::Event::getByToken(), nfeds_, processFed(), Raw_token, and wheels_.

Referenced by produce().

99  {
100 
102  e.getByToken( Raw_token, data );
103 
104  for ( size_t w_i = 0; w_i < nfeds_; ++w_i ) {
105  processFed( feds_[w_i], wheels_[w_i], amcsec_[w_i], data, phi_data, the_data, phi_out_data);
106  }
107 
108  return true;
109 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
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:82
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
edm::InputTag L1TTwinMuxRawToDigi::getDTTM7InputTag ( ) const
inlineprivate

Definition at line 74 of file L1TTwinMuxRawToDigi.h.

References DTTM7InputTag_.

74 { return DTTM7InputTag_; }
edm::InputTag DTTM7InputTag_
int L1TTwinMuxRawToDigi::normBx ( int  bx_,
int  bxCnt_ 
) const
private

Definition at line 111 of file L1TTwinMuxRawToDigi.cc.

References funct::abs().

Referenced by processFed().

112  {
113 
114  int bxNorm_ = bx_ - bxCnt_;
115  if ( abs( bxNorm_ ) < 3000 ) return bxNorm_;
116 
117  if ( bxNorm_ > 0 ) return bxNorm_ - 3564;
118  if ( bxNorm_ < 0 ) return bxNorm_ + 3564;
119 
120  return -99;
121 
122 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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 142 of file L1TTwinMuxRawToDigi.cc.

References benAngConversion(), dt_crc::calcCRC(), FEDRawData::data(), debug_, TauDecayModes::dec, DEFINE_FWK_MODULE, FEDRawDataCollection::FEDData(), alignmentValidation::fname, mps_fire::i, createfilelist::int, gen::k, LogDebug, normBx(), or, radAngConversion(), readline(), FEDRawData::size(), makeMuonMisalignmentScenario::wheel, globals_cff::x1, and globals_cff::x2.

Referenced by fillRawData().

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

Produce digis out of raw data.

Definition at line 72 of file L1TTwinMuxRawToDigi.cc.

References fillRawData(), eostools::move(), and edm::Event::put().

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

73  {
74 
75  std::unique_ptr<L1MuDTChambPhContainer> TM7phi_product(new L1MuDTChambPhContainer);
76  std::unique_ptr<L1MuDTChambThContainer> TM7the_product(new L1MuDTChambThContainer);
77  std::unique_ptr<L1MuDTChambPhContainer> TM7phi_out_product(new L1MuDTChambPhContainer);
78 
82 
83  if ( !fillRawData(e, phi_data, the_data, phi_out_data) ) return;
84 
85  TM7phi_product->setContainer(phi_data);
86  TM7the_product->setContainer(the_data);
87  TM7phi_out_product->setContainer(phi_out_data);
88 
89  e.put(std::move(TM7phi_product), "PhIn");
90  e.put(std::move(TM7the_product), "ThIn");
91  e.put(std::move(TM7phi_out_product), "PhOut");
92 
93 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
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
int L1TTwinMuxRawToDigi::radAngConversion ( int  radAng_) const
private

Definition at line 124 of file L1TTwinMuxRawToDigi.cc.

Referenced by processFed().

124  {
125 
126  if (radAng_>2047)
127  return radAng_-4096;
128 
129  return radAng_;
130 
131 }
unsigned char* L1TTwinMuxRawToDigi::readline ( unsigned char *  lineFED,
int &  lines,
long &  dataWord 
) const
inlineprivate

Definition at line 66 of file L1TTwinMuxRawToDigi.h.

References groupFilesInBlocks::lines.

Referenced by processFed().

67  {
68  dataWord = *( (long*) lineFED );
69  lineFED += 8;
70  ++lines;
71  return lineFED;
72  }

Member Data Documentation

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

Definition at line 63 of file L1TTwinMuxRawToDigi.h.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().

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

Definition at line 62 of file L1TTwinMuxRawToDigi.h.

Referenced by L1TTwinMuxRawToDigi().

bool L1TTwinMuxRawToDigi::debug_
private

Definition at line 57 of file L1TTwinMuxRawToDigi.h.

Referenced by processFed().

edm::InputTag L1TTwinMuxRawToDigi::DTTM7InputTag_
private

Definition at line 59 of file L1TTwinMuxRawToDigi.h.

Referenced by getDTTM7InputTag(), and L1TTwinMuxRawToDigi().

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

Definition at line 60 of file L1TTwinMuxRawToDigi.h.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().

size_t L1TTwinMuxRawToDigi::nfeds_
private

Definition at line 58 of file L1TTwinMuxRawToDigi.h.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().

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

Definition at line 76 of file L1TTwinMuxRawToDigi.h.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().

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

Definition at line 61 of file L1TTwinMuxRawToDigi.h.

Referenced by fillRawData(), and L1TTwinMuxRawToDigi().