CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Attributes
GctFormatTranslateMCLegacy Class Reference

Unpacks/packs the MC Legacy data originally produced by the GctBlockPacker class. More...

#include <GctFormatTranslateMCLegacy.h>

Inheritance diagram for GctFormatTranslateMCLegacy:
GctFormatTranslateBase

Public Member Functions

virtual bool convertBlock (const unsigned char *d, const GctBlockHeader &hdr)
 Get digis from the block - will return true if it succeeds, false otherwise. More...
 
 GctFormatTranslateMCLegacy (bool hltMode=false, bool unpackSharedRegions=false)
 Constructor. More...
 
virtual GctBlockHeader generateBlockHeader (const unsigned char *data) const
 Generate a block header from four 8-bit values. More...
 
void writeAllRctCaloRegionBlock (unsigned char *d, const L1CaloRegionCollection *rctCalo)
 Writes the giant hack that is the RCT Calo Regions block. More...
 
void writeGctOutEmAndEnergyBlock (unsigned char *d, const L1GctEmCandCollection *iso, const L1GctEmCandCollection *nonIso, const L1GctEtTotalCollection *etTotal, const L1GctEtHadCollection *etHad, const L1GctEtMissCollection *etMiss)
 Writes GCT output EM and energy sums block into an unsigned char array, starting at the position pointed to by d. More...
 
void writeGctOutJetBlock (unsigned char *d, const L1GctJetCandCollection *cenJets, const L1GctJetCandCollection *forJets, const L1GctJetCandCollection *tauJets, const L1GctHFRingEtSumsCollection *hfRingSums, const L1GctHFBitCountsCollection *hfBitCounts, const L1GctHtMissCollection *htMiss)
 Writes GCT output jet cands and counts into an unsigned char array, starting at the position pointed to by d. More...
 
void writeRctEmCandBlocks (unsigned char *d, const L1CaloEmCollection *rctEm)
 Writes the 4 RCT EM Candidate blocks. More...
 
virtual ~GctFormatTranslateMCLegacy ()
 Destructor. More...
 
- Public Member Functions inherited from GctFormatTranslateBase
 GctFormatTranslateBase (bool hltMode=false, bool unpackSharedRegions=false)
 Constructor. More...
 
const std::string & getBlockDescription (const GctBlockHeader &header) const
 Get block description. More...
 
void setPackingBxId (uint32_t bxId)
 
void setPackingEventId (uint32_t eventId)
 
void setUnpackCollections (GctUnpackCollections *const collections)
 Set the pointer to the unpack collections. More...
 
virtual ~GctFormatTranslateBase ()
 Destructor. More...
 

Protected Member Functions

virtual BlockLengthMapblockLengthMap ()
 get the static block ID to block-length map. More...
 
virtual const BlockLengthMapblockLengthMap () const
 get the static block ID to block-length map. More...
 
virtual BlockNameMapblockNameMap ()
 get the static block ID to block-name map. More...
 
virtual const BlockNameMapblockNameMap () const
 get the static block ID to blockname map. More...
 
virtual uint32_t generateRawHeader (const uint32_t blockId, const uint32_t nSamples, const uint32_t bxId, const uint32_t eventId) const
 Returns a raw 32-bit header word generated from the blockId, number of time samples, bunch-crossing and event IDs. More...
 
virtual
BlockIdToEmCandIsoBoundMap
internEmIsoBounds ()
 get the static intern EM cand isolated boundary map. More...
 
virtual const
BlockIdToEmCandIsoBoundMap
internEmIsoBounds () const
 get the static intern EM cand isolated boundary map. More...
 
virtual BlkToRctCrateMaprctEmCrateMap ()
 get the static block ID to RCT crate map for electrons. More...
 
virtual const BlkToRctCrateMaprctEmCrateMap () const
 get static the block ID to RCT crate map for electrons. More...
 
virtual BlkToRctCrateMaprctJetCrateMap ()
 get the static block ID to RCT crate map for jets More...
 
virtual const BlkToRctCrateMaprctJetCrateMap () const
 get the static block ID to RCT crate map for jets More...
 
- Protected Member Functions inherited from GctFormatTranslateBase
void blockDoNothing (const unsigned char *d, const GctBlockHeader &hdr)
 The null unpack function - obviously common to all formats. More...
 
bool checkBlock (const GctBlockHeader &hdr) const
 Performs checks on the block header to see if the block is possible to unpack or not. More...
 
GctUnpackCollections *const colls () const
 Protected access to the GCT Unpack Collections. More...
 
L1GctJetCandCollection *const gctJets (const unsigned cat) const
 Get a specific jet candandiate collection using the JetCandCategory enumeration. More...
 
bool hltMode () const
 Protected interface to get HLT optimisation mode flag. More...
 
const uint32_t packingBxId () const
 Get the BxId to be used when packing data. More...
 
const uint32_t packingEventId () const
 Get the EventId to be used when packing data. More...
 
const SourceCardRoutingsrcCardRouting () const
 Protected interface to the unpackSharedRegions commissioning option. More...
 
bool unpackSharedRegions () const
 
void writeRawHeader (unsigned char *data, uint32_t blockId, uint32_t nSamples) const
 Writes a raw block header into the raw data array for a given block ID and number of time-samples. More...
 

Private Types

typedef std::map< unsigned int,
PtrToUnpackFn
BlockIdToUnpackFnMap
 Typedef for a block ID to unpack function map. More...
 
typedef void(GctFormatTranslateMCLegacy::* PtrToUnpackFn )(const unsigned char *, const GctBlockHeader &)
 Function pointer typdef to a block unpack function. More...
 

Private Member Functions

void blockToAllRctCaloRegions (const unsigned char *d, const GctBlockHeader &hdr)
 Unpack All RCT Calo Regions ('orrible hack for DigiToRaw use) More...
 
void blockToFibres (const unsigned char *d, const GctBlockHeader &hdr)
 unpack Fibres More...
 
void blockToFibresAndToRctEmCand (const unsigned char *d, const GctBlockHeader &hdr)
 unpack Fibres and RCT EM Candidates More...
 
void blockToGctEmCandsAndEnergySums (const unsigned char *d, const GctBlockHeader &hdr)
 unpack GCT EM Candidates and energy sums. More...
 
void blockToGctJetCandsAndCounts (const unsigned char *d, const GctBlockHeader &hdr)
 Unpack GCT Jet Candidates and jet counts. More...
 
void blockToRctEmCand (const unsigned char *d, const GctBlockHeader &hdr)
 unpack RCT EM Candidates More...
 
template<typename Collection >
bool findBx0OffsetInCollection (unsigned &bx0Offset, const Collection *coll)
 Template function (used in packing) that will find the offset to first item in a collection vector where bx=0. More...
 

Static Private Attributes

static BlockLengthMap m_blockLength = GctFormatTranslateMCLegacy::BlockLengthMap()
 Map to translate block number to fundamental size of a block (i.e. for 1 time-sample). More...
 
static BlockNameMap m_blockName = GctFormatTranslateMCLegacy::BlockNameMap()
 Map to hold a description for each block number. More...
 
static BlockIdToUnpackFnMap m_blockUnpackFn = GctFormatTranslateMCLegacy::BlockIdToUnpackFnMap()
 Block ID to unpack function map. More...
 
static BlockIdToEmCandIsoBoundMap m_internEmIsoBounds = GctFormatTranslateMCLegacy::BlockIdToEmCandIsoBoundMap()
 
static BlkToRctCrateMap m_rctEmCrate = GctFormatTranslateMCLegacy::BlkToRctCrateMap()
 Map to relate capture block ID to the RCT crate the data originated from (for electrons). More...
 
static BlkToRctCrateMap m_rctJetCrate = GctFormatTranslateMCLegacy::BlkToRctCrateMap()
 Map to relate capture block ID to the RCT crate the data originated from (for jets). More...
 

Additional Inherited Members

- Protected Types inherited from GctFormatTranslateBase
typedef std::map< unsigned int,
unsigned int > 
BlkToRctCrateMap
 Typedef for mapping block ID to RCT crate. More...
 
typedef std::map< unsigned int,
IsoBoundaryPair
BlockIdToEmCandIsoBoundMap
 A typdef for mapping Block IDs to IsoBoundaryPairs. More...
 
typedef std::map< unsigned int,
unsigned int > 
BlockLengthMap
 Block ID to Block Length map. More...
 
typedef std::pair< unsigned
int, unsigned int > 
BlockLengthPair
 Block ID/length pair. More...
 
typedef std::map< unsigned int,
std::string > 
BlockNameMap
 Block ID to Block Description map. More...
 
typedef std::pair< unsigned
int, std::string > 
BlockNamePair
 Block ID/Description pair. More...
 
enum  EmCandCatagory { NON_ISO_EM_CANDS, ISO_EM_CANDS, NUM_EM_CAND_CATEGORIES }
 An enum of the EM candidate types. More...
 
typedef std::pair< unsigned
int, unsigned int > 
IsoBoundaryPair
 
enum  JetCandCategory { TAU_JETS, FORWARD_JETS, CENTRAL_JETS, NUM_JET_CATEGORIES }
 Useful enumeration for jet candidate pack/unpack. More...
 

Detailed Description

Unpacks/packs the MC Legacy data originally produced by the GctBlockPacker class.

The data produced by the legacy GctBlockPacker class should have a firmware version header that wasn't set to anything, i.e.: 0x00000000

Author
Robert Frazier
Revision:
1.3
Date:
2009/04/21 15:33:16

Definition at line 22 of file GctFormatTranslateMCLegacy.h.

Member Typedef Documentation

typedef std::map<unsigned int, PtrToUnpackFn> GctFormatTranslateMCLegacy::BlockIdToUnpackFnMap
private

Typedef for a block ID to unpack function map.

Definition at line 108 of file GctFormatTranslateMCLegacy.h.

typedef void(GctFormatTranslateMCLegacy::* GctFormatTranslateMCLegacy::PtrToUnpackFn)(const unsigned char *, const GctBlockHeader &)
private

Function pointer typdef to a block unpack function.

Definition at line 106 of file GctFormatTranslateMCLegacy.h.

Constructor & Destructor Documentation

GctFormatTranslateMCLegacy::GctFormatTranslateMCLegacy ( bool  hltMode = false,
bool  unpackSharedRegions = false 
)
explicit

Constructor.

Parameters
hltMode- set true to unpack only BX zero and GCT output data (i.e. to run as quick as possible).
unpackSharedRegions- this is a commissioning option to unpack the shared RCT calo regions.

Definition at line 28 of file GctFormatTranslateMCLegacy.cc.

References GctFormatTranslateBase::blockDoNothing(), blockToAllRctCaloRegions(), blockToFibresAndToRctEmCand(), blockToGctEmCandsAndEnergySums(), blockToGctJetCandsAndCounts(), m_blockLength, m_blockName, m_blockUnpackFn, and m_rctEmCrate.

28  :
30 {
31  static bool initClass = true;
32 
33  if(initClass)
34  {
35  initClass = false;
36 
37  /*** Setup BlockID to BlockLength Map ***/
38  // Miscellaneous Blocks
39  m_blockLength.insert(make_pair(0x000,0)); // NULL
40  m_blockLength.insert(make_pair(0x0ff,198)); // Temporary hack: All RCT Calo Regions for CMSSW pack/unpack
41  // ConcJet FPGA
42  m_blockLength.insert(make_pair(0x583,8)); // ConcJet: Jet Cands and Counts Output to GT
43  // ConcElec FPGA
44  m_blockLength.insert(make_pair(0x683,6)); // ConcElec: EM Cands and Energy Sums Output to GT
45  // Electron Leaf FPGAs
46  m_blockLength.insert(make_pair(0x804,15)); // Leaf0ElecPosEtaU1: Raw Input
47  m_blockLength.insert(make_pair(0x884,12)); // Leaf0ElecPosEtaU2: Raw Input
48  m_blockLength.insert(make_pair(0xc04,15)); // Leaf0ElecNegEtaU1: Raw Input
49  m_blockLength.insert(make_pair(0xc84,12)); // Leaf0ElecNegEtaU2: Raw Input
50 
51 
52  /*** Setup BlockID to BlockName Map ***/
53  // Miscellaneous Blocks
54  m_blockName.insert(make_pair(0x000,"NULL"));
55  m_blockName.insert(make_pair(0x0ff,"All RCT Calo Regions")); // Temporary hack: All RCT Calo Regions for CMSSW pack/unpack
56  // ConcJet FPGA
57  m_blockName.insert(make_pair(0x583,"ConcJet: Jet Cands and Counts Output to GT"));
58  // ConcElec FPGA
59  m_blockName.insert(make_pair(0x683,"ConcElec: EM Cands and Energy Sums Output to GT"));
60  // Electron Leaf FPGAs
61  m_blockName.insert(make_pair(0x804,"Leaf0ElecPosEtaU1: Raw Input"));
62  m_blockName.insert(make_pair(0x884,"Leaf0ElecPosEtaU2: Raw Input"));
63  m_blockName.insert(make_pair(0xc04,"Leaf0ElecNegEtaU1: Raw Input"));
64  m_blockName.insert(make_pair(0xc84,"Leaf0ElecNegEtaU2: Raw Input"));
65 
66 
67  /*** Setup BlockID to Unpack-Function Map ***/
68  // Miscellaneous Blocks
70  m_blockUnpackFn[0x0ff] = &GctFormatTranslateMCLegacy::blockToAllRctCaloRegions; // Temporary hack: All RCT Calo Regions for CMSSW pack/unpack
71  // ConcJet FPGA
72  m_blockUnpackFn[0x583] = &GctFormatTranslateMCLegacy::blockToGctJetCandsAndCounts; // ConcJet: Jet Cands and Counts Output to GT
73  // ConcElec FPGA
74  m_blockUnpackFn[0x683] = &GctFormatTranslateMCLegacy::blockToGctEmCandsAndEnergySums; // ConcElec: EM Cands and Energy Sums Output to GT
75  // Electron Leaf FPGAs
76  m_blockUnpackFn[0x804] = &GctFormatTranslateMCLegacy::blockToFibresAndToRctEmCand; // Leaf0ElecPosEtaU1: Raw Input
77  m_blockUnpackFn[0x884] = &GctFormatTranslateMCLegacy::blockToFibresAndToRctEmCand; // Leaf0ElecPosEtaU2: Raw Input
78  m_blockUnpackFn[0xc04] = &GctFormatTranslateMCLegacy::blockToFibresAndToRctEmCand; // Leaf0ElecNegEtaU1: Raw Input
79  m_blockUnpackFn[0xc84] = &GctFormatTranslateMCLegacy::blockToFibresAndToRctEmCand; // Leaf0ElecNegEtaU2: Raw Input
80 
81 
82  /*** Setup RCT Em Crate Map ***/
83  m_rctEmCrate[0x804] = 13;
84  m_rctEmCrate[0x884] = 9;
85  m_rctEmCrate[0xc04] = 4;
86  m_rctEmCrate[0xc84] = 0;
87 
88 
89  /*** Setup RCT jet crate map. ***/
90  // No entries required!
91 
92 
93  /*** Setup Block ID map for pipeline payload positions of isolated Internal EM Cands. ***/
94  // No entries required!
95  }
96 }
void blockToFibresAndToRctEmCand(const unsigned char *d, const GctBlockHeader &hdr)
unpack Fibres and RCT EM Candidates
void blockToGctEmCandsAndEnergySums(const unsigned char *d, const GctBlockHeader &hdr)
unpack GCT EM Candidates and energy sums.
GctFormatTranslateBase(bool hltMode=false, bool unpackSharedRegions=false)
Constructor.
static BlockLengthMap m_blockLength
Map to translate block number to fundamental size of a block (i.e. for 1 time-sample).
void blockDoNothing(const unsigned char *d, const GctBlockHeader &hdr)
The null unpack function - obviously common to all formats.
bool hltMode() const
Protected interface to get HLT optimisation mode flag.
static BlkToRctCrateMap m_rctEmCrate
Map to relate capture block ID to the RCT crate the data originated from (for electrons).
void blockToGctJetCandsAndCounts(const unsigned char *d, const GctBlockHeader &hdr)
Unpack GCT Jet Candidates and jet counts.
static BlockNameMap m_blockName
Map to hold a description for each block number.
void blockToAllRctCaloRegions(const unsigned char *d, const GctBlockHeader &hdr)
Unpack All RCT Calo Regions (&#39;orrible hack for DigiToRaw use)
static BlockIdToUnpackFnMap m_blockUnpackFn
Block ID to unpack function map.
GctFormatTranslateMCLegacy::~GctFormatTranslateMCLegacy ( )
virtual

Destructor.

Definition at line 98 of file GctFormatTranslateMCLegacy.cc.

99 {
100 }

Member Function Documentation

virtual BlockLengthMap& GctFormatTranslateMCLegacy::blockLengthMap ( )
inlineprotectedvirtual

get the static block ID to block-length map.

Implements GctFormatTranslateBase.

Definition at line 77 of file GctFormatTranslateMCLegacy.h.

References m_blockLength.

Referenced by generateBlockHeader(), and writeRctEmCandBlocks().

virtual const BlockLengthMap& GctFormatTranslateMCLegacy::blockLengthMap ( ) const
inlineprotectedvirtual

get the static block ID to block-length map.

Implements GctFormatTranslateBase.

Definition at line 78 of file GctFormatTranslateMCLegacy.h.

References m_blockLength.

virtual BlockNameMap& GctFormatTranslateMCLegacy::blockNameMap ( )
inlineprotectedvirtual

get the static block ID to block-name map.

Implements GctFormatTranslateBase.

Definition at line 80 of file GctFormatTranslateMCLegacy.h.

References m_blockName.

virtual const BlockNameMap& GctFormatTranslateMCLegacy::blockNameMap ( ) const
inlineprotectedvirtual

get the static block ID to blockname map.

Implements GctFormatTranslateBase.

Definition at line 81 of file GctFormatTranslateMCLegacy.h.

References m_blockName.

void GctFormatTranslateMCLegacy::blockToAllRctCaloRegions ( const unsigned char *  d,
const GctBlockHeader hdr 
)
private

Unpack All RCT Calo Regions ('orrible hack for DigiToRaw use)

Definition at line 652 of file GctFormatTranslateMCLegacy.cc.

References GctFormatTranslateBase::colls(), GctFormatTranslateBase::hltMode(), errorMatrix2Lands_multiChannel::id, LogDebug, GctBlockHeader::nSamples(), and GctUnpackCollections::rctCalo().

Referenced by GctFormatTranslateMCLegacy().

653 {
654  // Don't want to do this in HLT optimisation mode!
655  if(hltMode()) { LogDebug("GCT") << "HLT mode - skipping unpack of RCT Calo Regions"; return; }
656 
657  // This method is one giant "temporary" hack whilst waiting for proper
658  // pipeline formats for the RCT calo region data.
659 
660  const int nSamples = hdr.nSamples(); // Number of time-samples.
661 
662  // Re-interpret block payload pointer to 16 bits
663  const uint16_t * p16 = reinterpret_cast<const uint16_t *>(d);
664 
665  for(unsigned iCrate = 0 ; iCrate < 18 ; ++iCrate)
666  {
667  // Barrel and endcap regions
668  for(unsigned iCard = 0 ; iCard < 7 ; ++iCard)
669  {
670  // Samples
671  for(int16_t iSample = 0 ; iSample < nSamples ; ++iSample)
672  {
673  // Two regions per card (and per 32-bit word).
674  for(unsigned iRegion = 0 ; iRegion < 2 ; ++iRegion)
675  {
676  L1CaloRegionDetId id(iCrate, iCard, iRegion);
677  colls()->rctCalo()->push_back(L1CaloRegion(*p16, id.ieta(), id.iphi(), iSample));
678  ++p16; //advance pointer
679  }
680  }
681  }
682  // Forward regions (8 regions numbered 0 through 7, packed in 4 sets of pairs)
683  for(unsigned iRegionPairNum = 0 ; iRegionPairNum < 4 ; ++iRegionPairNum)
684  {
685  // Samples
686  for(int16_t iSample = 0 ; iSample < nSamples ; ++iSample)
687  {
688  // two regions in a pair
689  for(unsigned iPair = 0 ; iPair < 2 ; ++iPair)
690  {
691  // For forward regions, RCTCard=999
692  L1CaloRegionDetId id(iCrate, 999, iRegionPairNum*2 + iPair);
693  colls()->rctCalo()->push_back(L1CaloRegion(*p16, id.ieta(), id.iphi(), iSample));
694  ++p16; //advance pointer
695  }
696  }
697  }
698  }
699 }
#define LogDebug(id)
GctUnpackCollections *const colls() const
Protected access to the GCT Unpack Collections.
bool hltMode() const
Protected interface to get HLT optimisation mode flag.
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
uint32_t nSamples() const
Get the number of time samples.
L1CaloRegionCollection *const rctCalo() const
Input calo regions from the RCT to the GCT.
void GctFormatTranslateMCLegacy::blockToFibres ( const unsigned char *  d,
const GctBlockHeader hdr 
)
private

unpack Fibres

Definition at line 626 of file GctFormatTranslateMCLegacy.cc.

References GctBlockHeader::blockId(), GctBlockHeader::blockLength(), GctFormatTranslateBase::colls(), GctUnpackCollections::gctFibres(), GctFormatTranslateBase::hltMode(), i, LogDebug, GctBlockHeader::nSamples(), and AlCaHLTBitMon_ParallelJobs::p.

Referenced by blockToFibresAndToRctEmCand().

627 {
628  // Don't want to do this in HLT optimisation mode!
629  if(hltMode()) { LogDebug("GCT") << "HLT mode - skipping unpack of GCT Fibres"; return; }
630 
631  unsigned int id = hdr.blockId();
632  unsigned int nSamples = hdr.nSamples();
633  unsigned int length = hdr.blockLength();
634 
635  // re-interpret pointer
636  uint32_t * p = reinterpret_cast<uint32_t *>(const_cast<unsigned char *>(d));
637 
638  for (unsigned int i=0; i<length; ++i) {
639  for (unsigned int bx=0; bx<nSamples; ++bx) {
640  colls()->gctFibres()->push_back( L1GctFibreWord(*p, id, i, bx) );
641  ++p;
642  }
643  }
644 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
Global Calorimeter Trigger SC -&gt; CC fibre data word.
GctUnpackCollections *const colls() const
Protected access to the GCT Unpack Collections.
bool hltMode() const
Protected interface to get HLT optimisation mode flag.
uint32_t blockLength() const
Get the fundamental block length (for 1 time sample)
L1GctFibreCollection *const gctFibres() const
Raw fibre input to the GCT.
uint32_t blockId() const
Get the block ID.
uint32_t nSamples() const
Get the number of time samples.
void GctFormatTranslateMCLegacy::blockToFibresAndToRctEmCand ( const unsigned char *  d,
const GctBlockHeader hdr 
)
private

unpack Fibres and RCT EM Candidates

Definition at line 646 of file GctFormatTranslateMCLegacy.cc.

References blockToFibres(), and blockToRctEmCand().

Referenced by GctFormatTranslateMCLegacy().

647 {
648  this->blockToRctEmCand(d, hdr);
649  this->blockToFibres(d, hdr);
650 }
void blockToRctEmCand(const unsigned char *d, const GctBlockHeader &hdr)
unpack RCT EM Candidates
void blockToFibres(const unsigned char *d, const GctBlockHeader &hdr)
unpack Fibres
void GctFormatTranslateMCLegacy::blockToGctEmCandsAndEnergySums ( const unsigned char *  d,
const GctBlockHeader hdr 
)
private

unpack GCT EM Candidates and energy sums.

Definition at line 458 of file GctFormatTranslateMCLegacy.cc.

References GctBlockHeader::blockId(), GctFormatTranslateBase::colls(), GctUnpackCollections::gctEtHad(), GctUnpackCollections::gctEtMiss(), GctUnpackCollections::gctEtTot(), GctUnpackCollections::gctIsoEm(), GctUnpackCollections::gctNonIsoEm(), GctFormatTranslateBase::hltMode(), and GctBlockHeader::nSamples().

Referenced by GctFormatTranslateMCLegacy().

459 {
460  const unsigned int id = hdr.blockId();
461  const unsigned int nSamples = hdr.nSamples();
462 
463  // Re-interpret pointer. p16 will be pointing at the 16 bit word that
464  // contains the rank0 non-isolated electron of the zeroth time-sample.
465  const uint16_t * p16 = reinterpret_cast<const uint16_t *>(d);
466 
467  // UNPACK EM CANDS
468 
469  const unsigned int emCandCategoryOffset = nSamples * 4; // Offset to jump from the non-iso electrons to the isolated ones.
470  const unsigned int timeSampleOffset = nSamples * 2; // Offset to jump to next candidate pair in the same time-sample.
471 
472  unsigned int samplesToUnpack = 1;
473  if(!hltMode()) { samplesToUnpack = nSamples; } // Only if not running in HLT mode do we want more than 1 timesample.
474 
475  for (unsigned int iso=0; iso<2; ++iso) // loop over non-iso/iso candidate pairs
476  {
477  bool isoFlag = (iso==1);
478 
479  // Get the correct collection to put them in.
481  if (isoFlag) { em = colls()->gctIsoEm(); }
482  else { em = colls()->gctNonIsoEm(); }
483 
484  for (unsigned int bx=0; bx<samplesToUnpack; ++bx) // loop over time samples
485  {
486  // cand0Offset will give the offset on p16 to get the rank 0 candidate
487  // of the correct category and timesample.
488  const unsigned int cand0Offset = iso*emCandCategoryOffset + bx*2;
489 
490  em->push_back(L1GctEmCand(p16[cand0Offset], isoFlag, id, 0, bx)); // rank0 electron
491  em->push_back(L1GctEmCand(p16[cand0Offset + timeSampleOffset], isoFlag, id, 1, bx)); // rank1 electron
492  em->push_back(L1GctEmCand(p16[cand0Offset + 1], isoFlag, id, 2, bx)); // rank2 electron
493  em->push_back(L1GctEmCand(p16[cand0Offset + timeSampleOffset + 1], isoFlag, id, 3, bx)); // rank3 electron
494  }
495  }
496 
497  p16 += emCandCategoryOffset * 2; // Move the pointer over the data we've already unpacked.
498 
499  // UNPACK ENERGY SUMS
500  // NOTE: we are only unpacking one timesample of these currently!
501 
502  colls()->gctEtTot()->push_back(L1GctEtTotal(p16[0])); // Et total (timesample 0).
503  colls()->gctEtHad()->push_back(L1GctEtHad(p16[1])); // Et hadronic (timesample 0).
504 
505  // 32-bit pointer for getting Missing Et.
506  const uint32_t * p32 = reinterpret_cast<const uint32_t *>(p16);
507 
508  colls()->gctEtMiss()->push_back(L1GctEtMiss(p32[nSamples])); // Et Miss (timesample 0).
509 }
L1GctEmCandCollection *const gctNonIsoEm() const
GCT output: Non-isolated EM candidate collection.
Persistable copy of missing Et measured at Level-1.
Definition: L1GctEtMiss.h:18
Level-1 Trigger EM candidate at output of GCT.
Definition: L1GctEmCand.h:22
L1GctEtTotalCollection *const gctEtTot() const
GCT output: Total Et collection.
GctUnpackCollections *const colls() const
Protected access to the GCT Unpack Collections.
Persistable copy of total Et measured at Level-1.
Definition: L1GctEtTotal.h:18
L1GctEtMissCollection *const gctEtMiss() const
GCT output: Missing Et collection.
bool hltMode() const
Protected interface to get HLT optimisation mode flag.
Persistable copy of total Ht measured at Level-1.
Definition: L1GctEtHad.h:18
L1GctEmCandCollection *const gctIsoEm() const
GCT output: Isolated EM candidate collection.
L1GctEtHadCollection *const gctEtHad() const
GCT output: Hadronic transverse-energy (Ht) collection.
uint32_t blockId() const
Get the block ID.
uint32_t nSamples() const
Get the number of time samples.
std::vector< L1GctEmCand > L1GctEmCandCollection
void GctFormatTranslateMCLegacy::blockToGctJetCandsAndCounts ( const unsigned char *  d,
const GctBlockHeader hdr 
)
private

Unpack GCT Jet Candidates and jet counts.

Definition at line 511 of file GctFormatTranslateMCLegacy.cc.

References GctBlockHeader::blockId(), GctFormatTranslateBase::colls(), GctFormatTranslateBase::FORWARD_JETS, L1GctHFBitCounts::fromConcHFBitCounts(), L1GctHFRingEtSums::fromConcRingSums(), GctUnpackCollections::gctHfBitCounts(), GctUnpackCollections::gctHfRingEtSums(), GctUnpackCollections::gctHtMiss(), GctFormatTranslateBase::gctJets(), GctFormatTranslateBase::hltMode(), fwrapper::jets, GctBlockHeader::nSamples(), GctFormatTranslateBase::NUM_JET_CATEGORIES, and GctFormatTranslateBase::TAU_JETS.

Referenced by GctFormatTranslateMCLegacy().

512 {
513  const unsigned int id = hdr.blockId(); // Capture block ID.
514  const unsigned int nSamples = hdr.nSamples(); // Number of time-samples.
515 
516  // Re-interpret block payload pointer to 16 bits so it sees one candidate at a time.
517  // p16 points to the start of the block payload, at the rank0 tau jet candidate.
518  const uint16_t * p16 = reinterpret_cast<const uint16_t *>(d);
519 
520  // UNPACK JET CANDS
521 
522  const unsigned int jetCandCategoryOffset = nSamples * 4; // Offset to jump from one jet category to the next.
523  const unsigned int timeSampleOffset = nSamples * 2; // Offset to jump to next candidate pair in the same time-sample.
524 
525  unsigned int samplesToUnpack = 1;
526  if(!hltMode()) { samplesToUnpack = nSamples; } // Only if not running in HLT mode do we want more than 1 timesample.
527 
528  // Loop over the different catagories of jets
529  for(unsigned int iCat = 0 ; iCat < NUM_JET_CATEGORIES ; ++iCat)
530  {
531  L1GctJetCandCollection * const jets = gctJets(iCat);
532  assert(jets->empty()); // The supplied vector should be empty.
533 
534  bool tauflag = (iCat == TAU_JETS);
535  bool forwardFlag = (iCat == FORWARD_JETS);
536 
537  // Loop over the different timesamples (bunch crossings).
538  for(unsigned int bx = 0 ; bx < samplesToUnpack ; ++bx)
539  {
540  // cand0Offset will give the offset on p16 to get the rank 0 Jet Cand of the correct category and timesample.
541  const unsigned int cand0Offset = iCat*jetCandCategoryOffset + bx*2;
542 
543  // Rank 0 Jet.
544  jets->push_back(L1GctJetCand(p16[cand0Offset], tauflag, forwardFlag, id, 0, bx));
545  // Rank 1 Jet.
546  jets->push_back(L1GctJetCand(p16[cand0Offset + timeSampleOffset], tauflag, forwardFlag, id, 1, bx));
547  // Rank 2 Jet.
548  jets->push_back(L1GctJetCand(p16[cand0Offset + 1], tauflag, forwardFlag, id, 2, bx));
549  // Rank 3 Jet.
550  jets->push_back(L1GctJetCand(p16[cand0Offset + timeSampleOffset + 1], tauflag, forwardFlag, id, 3, bx));
551  }
552  }
553 
554  p16 += NUM_JET_CATEGORIES * jetCandCategoryOffset; // Move the pointer over the data we've already unpacked.
555 
556  // NOW UNPACK: HFBitCounts, HFRingEtSums and Missing Ht
557  // NOTE: we are only unpacking one timesample of these currently!
558 
559  // Re-interpret block payload pointer to 32 bits so it sees six jet counts at a time.
560  const uint32_t * p32 = reinterpret_cast<const uint32_t *>(p16);
561 
562  // Channel 0 carries both HF counts and sums
563  colls()->gctHfBitCounts()->push_back(L1GctHFBitCounts::fromConcHFBitCounts(id,6,0,p32[0]));
564  colls()->gctHfRingEtSums()->push_back(L1GctHFRingEtSums::fromConcRingSums(id,6,0,p32[0]));
565 
566  // Channel 1 carries Missing HT.
567  colls()->gctHtMiss()->push_back(L1GctHtMiss(p32[nSamples], 0));
568 }
L1GctHFBitCountsCollection *const gctHfBitCounts() const
GCT output: Hadronic-Forward bit-counts collection.
L1GctHtMissCollection *const gctHtMiss() const
GCT output: Missing Ht collection.
Level-1 Trigger jet candidate.
Definition: L1GctJetCand.h:18
std::vector< L1GctJetCand > L1GctJetCandCollection
GctUnpackCollections *const colls() const
Protected access to the GCT Unpack Collections.
vector< PseudoJet > jets
bool hltMode() const
Protected interface to get HLT optimisation mode flag.
static L1GctHFRingEtSums fromConcRingSums(const uint16_t capBlock, const uint16_t capIndex, const int16_t bx, const uint32_t data)
L1GctJetCandCollection *const gctJets(const unsigned cat) const
Get a specific jet candandiate collection using the JetCandCategory enumeration.
L1GctHFRingEtSumsCollection *const gctHfRingEtSums() const
GCT output: Hadronic-Forward ring-sums collection.
Persistable copy of missing Et measured at Level-1.
Definition: L1GctHtMiss.h:16
static L1GctHFBitCounts fromConcHFBitCounts(const uint16_t capBlock, const uint16_t capIndex, const int16_t bx, const uint32_t data)
uint32_t blockId() const
Get the block ID.
uint32_t nSamples() const
Get the number of time samples.
void GctFormatTranslateMCLegacy::blockToRctEmCand ( const unsigned char *  d,
const GctBlockHeader hdr 
)
private

unpack RCT EM Candidates

Definition at line 572 of file GctFormatTranslateMCLegacy.cc.

References GctBlockHeader::blockId(), GctBlockHeader::blockLength(), GctFormatTranslateBase::colls(), GctFormatTranslateBase::hltMode(), i, errorMatrix2Lands_multiChannel::id, LogDebug, GctBlockHeader::nSamples(), AlCaHLTBitMon_ParallelJobs::p, GctUnpackCollections::rctEm(), rctEmCrateMap(), SourceCardRouting::SFPtoEMU(), and GctFormatTranslateBase::srcCardRouting().

Referenced by blockToFibresAndToRctEmCand().

573 {
574  // Don't want to do this in HLT optimisation mode!
575  if(hltMode()) { LogDebug("GCT") << "HLT mode - skipping unpack of RCT EM Cands"; return; }
576 
577  unsigned int id = hdr.blockId();
578  unsigned int nSamples = hdr.nSamples();
579  unsigned int length = hdr.blockLength();
580 
581  // re-interpret pointer
582  uint16_t * p = reinterpret_cast<uint16_t *>(const_cast<unsigned char *>(d));
583 
584  // arrays of source card data
585  uint16_t sfp[2][4]; // [ cycle ] [ SFP ]
586  uint16_t eIsoRank[4];
587  uint16_t eIsoCard[4];
588  uint16_t eIsoRgn[4];
589  uint16_t eNonIsoRank[4];
590  uint16_t eNonIsoCard[4];
591  uint16_t eNonIsoRgn[4];
592  uint16_t MIPbits[7][2];
593  uint16_t QBits[7][2];
594 
595  unsigned int bx = 0;
596 
597  // loop over crates
598  for (unsigned int crate=rctEmCrateMap()[id]; crate<rctEmCrateMap()[id]+length/3; ++crate) {
599 
600  // read SC SFP words
601  for (unsigned short iSfp=0 ; iSfp<4 ; ++iSfp) {
602  for (unsigned short cyc=0 ; cyc<2 ; ++cyc) {
603  if (iSfp==0) { sfp[cyc][iSfp] = 0; } // muon bits
604  else { // EM candidate
605  sfp[cyc][iSfp] = *p;
606  ++p;
607  }
608  }
609  p = p + 2*(nSamples-1);
610  }
611 
612  // fill SC arrays
613  srcCardRouting().SFPtoEMU(eIsoRank, eIsoCard, eIsoRgn, eNonIsoRank, eNonIsoCard, eNonIsoRgn, MIPbits, QBits, sfp);
614 
615  // create EM cands
616  for (unsigned short int i=0; i<4; ++i) {
617  colls()->rctEm()->push_back( L1CaloEmCand( eIsoRank[i], eIsoRgn[i], eIsoCard[i], crate, true, i, bx) );
618  }
619  for (unsigned short int i=0; i<4; ++i) {
620  colls()->rctEm()->push_back( L1CaloEmCand( eNonIsoRank[i], eNonIsoRgn[i], eNonIsoCard[i], crate, false, i, bx) );
621  }
622  }
623 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
L1CaloEmCollection *const rctEm() const
Input electrons from the RCT to the GCT.
void SFPtoEMU(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned short(&SFP)[2][4]) const
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:18
const SourceCardRouting & srcCardRouting() const
Protected interface to the unpackSharedRegions commissioning option.
GctUnpackCollections *const colls() const
Protected access to the GCT Unpack Collections.
bool hltMode() const
Protected interface to get HLT optimisation mode flag.
uint32_t blockLength() const
Get the fundamental block length (for 1 time sample)
virtual BlkToRctCrateMap & rctEmCrateMap()
get the static block ID to RCT crate map for electrons.
uint32_t blockId() const
Get the block ID.
uint32_t nSamples() const
Get the number of time samples.
bool GctFormatTranslateMCLegacy::convertBlock ( const unsigned char *  d,
const GctBlockHeader hdr 
)
virtual

Get digis from the block - will return true if it succeeds, false otherwise.

Implements GctFormatTranslateBase.

Definition at line 130 of file GctFormatTranslateMCLegacy.cc.

References GctBlockHeader::blockId(), GctFormatTranslateBase::checkBlock(), data, m_blockUnpackFn, GctBlockHeader::nSamples(), and edm::second().

131 {
132  // if the block has no time samples, don't bother with it.
133  if ( hdr.nSamples() < 1 ) { return true; }
134 
135  if(!checkBlock(hdr)) { return false; } // Check the block to see if it's possible to unpack.
136 
137  // The header validity check above will protect against
138  // the map::find() method returning the end of the map,
139  // assuming the block header definitions are up-to-date.
140  (this->*m_blockUnpackFn.find(hdr.blockId())->second)(data, hdr); // Calls the correct unpack function, based on block ID.
141 
142  return true;
143 }
bool checkBlock(const GctBlockHeader &hdr) const
Performs checks on the block header to see if the block is possible to unpack or not.
U second(std::pair< T, U > const &p)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
uint32_t blockId() const
Get the block ID.
uint32_t nSamples() const
Get the number of time samples.
static BlockIdToUnpackFnMap m_blockUnpackFn
Block ID to unpack function map.
template<typename Collection >
bool GctFormatTranslateMCLegacy::findBx0OffsetInCollection ( unsigned &  bx0Offset,
const Collection *  coll 
)
private

Template function (used in packing) that will find the offset to first item in a collection vector where bx=0.

Returns false if fails to find any item in the collection with bx=0

Definition at line 702 of file GctFormatTranslateMCLegacy.cc.

References findQualityFiles::size.

Referenced by writeGctOutEmAndEnergyBlock(), and writeGctOutJetBlock().

703 {
704  bool foundBx0 = false;
705  unsigned size = coll->size();
706  for(bx0Offset = 0 ; bx0Offset < size ; ++bx0Offset)
707  {
708  if(coll->at(bx0Offset).bx() == 0) { foundBx0 = true; break; }
709  }
710  return foundBx0;
711 }
JetCorrectorParametersCollection coll
Definition: classes.h:14
tuple size
Write out results.
GctBlockHeader GctFormatTranslateMCLegacy::generateBlockHeader ( const unsigned char *  data) const
virtual

Generate a block header from four 8-bit values.

Implements GctFormatTranslateBase.

Definition at line 102 of file GctFormatTranslateMCLegacy.cc.

References blockLengthMap(), and TrackValidation_HighPurity_cff::valid.

103 {
104  // Turn the four 8-bit header words into the full 32-bit header.
105  uint32_t hdr = data[0] + (data[1]<<8) + (data[2]<<16) + (data[3]<<24);
106 
107  // Bit mapping of header:
108  // ----------------------
109  // 11:0 => block_id Unique pipeline identifier.
110  // - 3:0 =>> pipe_id There can be up to 16 different pipelines per FPGA.
111  // - 6:4 =>> reserved Do not use yet. Set to zero.
112  // - 11:7 =>> fpga geograpical add The VME geographical address of the FPGA.
113  // 15:12 => event_id Determined locally. Not reset by Resync.
114  // 19:16 => number_of_time_samples If time samples 15 or more then value = 15.
115  // 31:20 => event_bxId The bunch crossing the data was recorded.
116 
117  uint32_t blockId = hdr & 0xfff;
118  uint32_t blockLength = 0; // Set to zero until we know it's a valid block
119  uint32_t nSamples = (hdr>>16) & 0xf;
120  uint32_t bxId = (hdr>>20) & 0xfff;
121  uint32_t eventId = (hdr>>12) & 0xf;
122  bool valid = (blockLengthMap().find(blockId) != blockLengthMap().end());
123 
124  if(valid) { blockLength = blockLengthMap().find(blockId)->second; }
125 
126  return GctBlockHeader(blockId, blockLength, nSamples, bxId, eventId, valid);
127 }
virtual BlockLengthMap & blockLengthMap()
get the static block ID to block-length map.
Simple class for holding the basic attributes of an 32-bit block header.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
uint32_t GctFormatTranslateMCLegacy::generateRawHeader ( const uint32_t  blockId,
const uint32_t  nSamples,
const uint32_t  bxId,
const uint32_t  eventId 
) const
protectedvirtual

Returns a raw 32-bit header word generated from the blockId, number of time samples, bunch-crossing and event IDs.

Implements GctFormatTranslateBase.

Definition at line 436 of file GctFormatTranslateMCLegacy.cc.

440 {
441  // Bit mapping of header:
442  // ----------------------
443  // 11:0 => block_id Unique pipeline identifier.
444  // - 3:0 =>> pipe_id There can be up to 16 different pipelines per FPGA.
445  // - 6:4 =>> reserved Do not use yet. Set to zero.
446  // - 11:7 =>> fpga geograpical add The VME geographical address of the FPGA.
447  // 15:12 => event_id Determined locally. Not reset by Resync.
448  // 19:16 => number_of_time_samples If time samples 15 or more then value = 15.
449  // 31:20 => event_bxId The bunch crossing the data was recorded.
450 
451  return ((bxId & 0xfff) << 20) | ((nSamples & 0xf) << 16) | ((eventId & 0xf) << 12) | (blockId & 0xfff);
452 }
virtual BlockIdToEmCandIsoBoundMap& GctFormatTranslateMCLegacy::internEmIsoBounds ( )
inlineprotectedvirtual

get the static intern EM cand isolated boundary map.

Implements GctFormatTranslateBase.

Definition at line 89 of file GctFormatTranslateMCLegacy.h.

References m_internEmIsoBounds.

virtual const BlockIdToEmCandIsoBoundMap& GctFormatTranslateMCLegacy::internEmIsoBounds ( ) const
inlineprotectedvirtual

get the static intern EM cand isolated boundary map.

Implements GctFormatTranslateBase.

Definition at line 90 of file GctFormatTranslateMCLegacy.h.

References m_internEmIsoBounds.

virtual BlkToRctCrateMap& GctFormatTranslateMCLegacy::rctEmCrateMap ( )
inlineprotectedvirtual

get the static block ID to RCT crate map for electrons.

Implements GctFormatTranslateBase.

Definition at line 83 of file GctFormatTranslateMCLegacy.h.

References m_rctEmCrate.

Referenced by blockToRctEmCand(), and writeRctEmCandBlocks().

virtual const BlkToRctCrateMap& GctFormatTranslateMCLegacy::rctEmCrateMap ( ) const
inlineprotectedvirtual

get static the block ID to RCT crate map for electrons.

Implements GctFormatTranslateBase.

Definition at line 84 of file GctFormatTranslateMCLegacy.h.

References m_rctEmCrate.

virtual BlkToRctCrateMap& GctFormatTranslateMCLegacy::rctJetCrateMap ( )
inlineprotectedvirtual

get the static block ID to RCT crate map for jets

Implements GctFormatTranslateBase.

Definition at line 86 of file GctFormatTranslateMCLegacy.h.

References m_rctJetCrate.

virtual const BlkToRctCrateMap& GctFormatTranslateMCLegacy::rctJetCrateMap ( ) const
inlineprotectedvirtual

get the static block ID to RCT crate map for jets

Implements GctFormatTranslateBase.

Definition at line 87 of file GctFormatTranslateMCLegacy.h.

References m_rctJetCrate.

void GctFormatTranslateMCLegacy::writeAllRctCaloRegionBlock ( unsigned char *  d,
const L1CaloRegionCollection rctCalo 
)

Writes the giant hack that is the RCT Calo Regions block.

Definition at line 382 of file GctFormatTranslateMCLegacy.cc.

References L1CaloRegion::bx(), L1CaloRegion::et(), L1CaloRegion::fineGrain(), i, L1CaloRegion::isHbHe(), LogDebug, L1CaloRegion::mip(), evf::evtn::offset(), L1CaloRegion::overFlow(), L1CaloRegion::quiet(), L1CaloRegion::rctCard(), L1CaloRegion::rctCrate(), L1CaloRegion::rctRegionIndex(), findQualityFiles::size, and GctFormatTranslateBase::writeRawHeader().

Referenced by GctDigiToRaw::produce().

383 {
384  // This method is one giant "temporary" hack for CMSSW_1_8_X and CMSSW_2_0_0.
385 
386  if(rctCalo->size() == 0 || rctCalo->size()%396 != 0) // Should be 396 calo regions for 1 bx.
387  {
388  LogDebug("GCT") << "Block pack error: bad L1CaloRegionCollection size detected!\n"
389  << "Aborting packing of RCT Calo Region data!";
390  return;
391  }
392 
393  writeRawHeader(d, 0x0ff, 1);
394  d+=4; // move past header.
395 
396  // Want a 16 bit pointer to push the 16 bit data in.
397  uint16_t * p16 = reinterpret_cast<uint16_t *>(const_cast<unsigned char *>(d));
398 
399  for(unsigned i=0, size=rctCalo->size(); i < size ; ++i)
400  {
401  const L1CaloRegion &reg = rctCalo->at(i);
402  if(reg.bx() != 0) { continue; } // Only interested in bunch crossing zero for now!
403  const unsigned crateNum = reg.rctCrate();
404  const unsigned regionIndex = reg.rctRegionIndex();
405  assert(crateNum < 18); // Only 18 RCT crates!
406 
407  // Gotta make the raw data as there currently isn't a method of getting raw from L1CaloRegion
408  const uint16_t raw = reg.et() |
409  (reg.overFlow() ? 0x400 : 0x0) |
410  (reg.fineGrain() ? 0x800 : 0x0) |
411  (reg.mip() ? 0x1000 : 0x0) |
412  (reg.quiet() ? 0x2000 : 0x0);
413 
414  unsigned offset = 0; // for storing calculated raw data offset.
415  if(reg.isHbHe()) // Is a barrel/endcap region
416  {
417  const unsigned cardNum = reg.rctCard();
418  assert(cardNum < 7); // 7 RCT cards per crate for the barrel/endcap
419  assert(regionIndex < 2); // regionIndex less than 2 for barrel/endcap
420 
421  // Calculate position in the raw data from crateNum, cardNum, and regionIndex
422  offset = crateNum*22 + cardNum*2 + regionIndex;
423  }
424  else // Must be forward region
425  {
426  assert(regionIndex < 8); // regionIndex less than 8 for forward calorimeter.
427  offset = crateNum*22 + 14 + regionIndex;
428  }
429  p16[offset] = raw; // Write raw data in correct place!
430  }
431 }
#define LogDebug(id)
int16_t bx() const
get bunch-crossing index
Definition: L1CaloRegion.h:192
int i
Definition: DBlmapReader.cc:9
unsigned et() const
get Et
Definition: L1CaloRegion.h:116
bool overFlow() const
get overflow
Definition: L1CaloRegion.h:122
unsigned rctCrate() const
get RCT crate ID
Definition: L1CaloRegion.h:165
unsigned rctCard() const
get RCT reciever card ID (valid output for HB/HE)
Definition: L1CaloRegion.h:168
void writeRawHeader(unsigned char *data, uint32_t blockId, uint32_t nSamples) const
Writes a raw block header into the raw data array for a given block ID and number of time-samples...
unsigned rctRegionIndex() const
get RCT region index
Definition: L1CaloRegion.h:171
bool quiet() const
get quiet bit
Definition: L1CaloRegion.h:134
bool mip() const
get MIP bit
Definition: L1CaloRegion.h:131
bool isHbHe() const
Definition: L1CaloRegion.h:162
unsigned int offset(bool)
bool fineGrain() const
get fine grain bit
Definition: L1CaloRegion.h:128
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
tuple size
Write out results.
void GctFormatTranslateMCLegacy::writeGctOutEmAndEnergyBlock ( unsigned char *  d,
const L1GctEmCandCollection iso,
const L1GctEmCandCollection nonIso,
const L1GctEtTotalCollection etTotal,
const L1GctEtHadCollection etHad,
const L1GctEtMissCollection etMiss 
)

Writes GCT output EM and energy sums block into an unsigned char array, starting at the position pointed to by d.

Parameters
dmust be pointing at the position where the EM Output block header should be written!

Definition at line 146 of file GctFormatTranslateMCLegacy.cc.

References findBx0OffsetInCollection(), GctFormatTranslateBase::ISO_EM_CANDS, LogDebug, GctFormatTranslateBase::NON_ISO_EM_CANDS, GctFormatTranslateBase::NUM_EM_CAND_CATEGORIES, evf::evtn::offset(), and GctFormatTranslateBase::writeRawHeader().

Referenced by GctDigiToRaw::produce().

152 {
153  // Set up a vector of the collections for easy iteration.
154  vector<const L1GctEmCandCollection*> emCands(NUM_EM_CAND_CATEGORIES);
155  emCands.at(NON_ISO_EM_CANDS)=nonIso;
156  emCands.at(ISO_EM_CANDS)=iso;
157 
158  /* To hold the offsets within the EM candidate collections for the bx=0 candidates.
159  * The capture index doesn't seem to get set properly by the emulator, so take the
160  * first bx=0 cand as the highest energy EM cand, and the fourth as the lowest. */
161  vector<unsigned> bx0EmCandOffsets(NUM_EM_CAND_CATEGORIES);
162 
163  // Loop over the different catagories of EM cands to find the bx=0 offsets.
164  for(unsigned int iCat = 0 ; iCat < NUM_EM_CAND_CATEGORIES ; ++iCat)
165  {
166  const L1GctEmCandCollection * cands = emCands.at(iCat);
167  unsigned& offset = bx0EmCandOffsets.at(iCat);
168  if(!findBx0OffsetInCollection(offset, cands)) { LogDebug("GCT") << "No EM candidates with bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!"; return; }
169  if((cands->size()-offset) < 4) { LogDebug("GCT") << "Insufficient EM candidates with bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!"; return; }
170  }
171 
172  unsigned bx0EtTotalOffset, bx0EtHadOffset, bx0EtMissOffset;
173  if(!findBx0OffsetInCollection(bx0EtTotalOffset, etTotal)) { LogDebug("GCT") << "No Et Total value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!"; return; }
174  if(!findBx0OffsetInCollection(bx0EtHadOffset, etHad)) { LogDebug("GCT") << "No Et Hadronic value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!"; return; }
175  if(!findBx0OffsetInCollection(bx0EtMissOffset, etMiss)) { LogDebug("GCT") << "No Et Miss value for bx=0!\nAborting packing of GCT EM Cand and Energy Sum Output!"; return; }
176 
177  // We should now have all requisite data, so we can get on with packing
178 
179  unsigned nSamples = 1; // ** NOTE can only currenly do 1 timesample! **
180 
181  // write header
182  writeRawHeader(d, 0x683, nSamples);
183 
184  d=d+4; // move to the block payload.
185 
186  // FIRST DO EM CANDS
187 
188  // re-interpret payload pointer to 16 bit.
189  uint16_t * p16 = reinterpret_cast<uint16_t *>(d);
190 
191  for (unsigned iCat=0; iCat < NUM_EM_CAND_CATEGORIES; ++iCat) // loop over non-iso/iso candidates categories
192  {
193  const L1GctEmCandCollection * em = emCands.at(iCat); // The current category of EM cands.
194  const unsigned bx0Offset = bx0EmCandOffsets.at(iCat); // The offset in the EM cand collection to the bx=0 cands.
195 
196  uint16_t * cand = p16 + (iCat*4);
197 
198  *cand = em->at(bx0Offset).raw();
199  cand++;
200  *cand = em->at(bx0Offset + 2).raw();
201  cand += nSamples;
202  *cand = em->at(bx0Offset + 1).raw();
203  cand++;
204  *cand = em->at(bx0Offset + 3).raw();
205  }
206 
207  // NOW DO ENERGY SUMS
208  // assumes these are all 1-object collections, ie. central BX only
209  p16+=8; // Move past EM cands
210  *p16 = etTotal->at(bx0EtTotalOffset).raw(); // Et Total - 16 bits.
211  p16++;
212  *p16 = etHad->at(bx0EtHadOffset).raw(); // Et Hadronic - next 16 bits
213  p16++;
214  uint32_t * p32 = reinterpret_cast<uint32_t *>(p16); // For writing Missing Et (32-bit raw data)
215  *p32 = etMiss->at(bx0EtMissOffset).raw(); // Et Miss on final 32 bits of block payload.
216 }
#define LogDebug(id)
void writeRawHeader(unsigned char *data, uint32_t blockId, uint32_t nSamples) const
Writes a raw block header into the raw data array for a given block ID and number of time-samples...
unsigned int offset(bool)
bool findBx0OffsetInCollection(unsigned &bx0Offset, const Collection *coll)
Template function (used in packing) that will find the offset to first item in a collection vector wh...
std::vector< L1GctEmCand > L1GctEmCandCollection
void GctFormatTranslateMCLegacy::writeGctOutJetBlock ( unsigned char *  d,
const L1GctJetCandCollection cenJets,
const L1GctJetCandCollection forJets,
const L1GctJetCandCollection tauJets,
const L1GctHFRingEtSumsCollection hfRingSums,
const L1GctHFBitCountsCollection hfBitCounts,
const L1GctHtMissCollection htMiss 
)

Writes GCT output jet cands and counts into an unsigned char array, starting at the position pointed to by d.

Parameters
dmust be pointing at the position where the Jet Output block header should be written!

Definition at line 218 of file GctFormatTranslateMCLegacy.cc.

References GctFormatTranslateBase::CENTRAL_JETS, L1GctHtMiss::et(), findBx0OffsetInCollection(), GctFormatTranslateBase::FORWARD_JETS, fwrapper::jets, LogDebug, GctFormatTranslateBase::NUM_JET_CATEGORIES, evf::evtn::offset(), L1GctHtMiss::overFlow(), L1GctHtMiss::phi(), GctFormatTranslateBase::TAU_JETS, tmp, and GctFormatTranslateBase::writeRawHeader().

Referenced by GctDigiToRaw::produce().

225 {
226  // Set up a vector of the collections for easy iteration.
227  vector<const L1GctJetCandCollection*> jets(NUM_JET_CATEGORIES);
228  jets.at(CENTRAL_JETS)=cenJets;
229  jets.at(FORWARD_JETS)=forJets;
230  jets.at(TAU_JETS)=tauJets;
231 
232  /* To hold the offsets within the three jet cand collections for the bx=0 jets.
233  * The capture index doesn't seem to get set properly by the emulator, so take the
234  * first bx=0 jet as the highest energy jet, and the fourth as the lowest. */
235  vector<unsigned> bx0JetCandOffsets(NUM_JET_CATEGORIES);
236 
237  // Loop over the different catagories of jets to find the bx=0 offsets.
238  for(unsigned int iCat = 0 ; iCat < NUM_JET_CATEGORIES ; ++iCat)
239  {
240  const L1GctJetCandCollection * jetCands = jets.at(iCat);
241  unsigned& offset = bx0JetCandOffsets.at(iCat);
242  if(!findBx0OffsetInCollection(offset, jetCands)) { LogDebug("GCT") << "No jet candidates with bx=0!\nAborting packing of GCT Jet Output!"; return; }
243  if((jetCands->size()-offset) < 4) { LogDebug("GCT") << "Insufficient jet candidates with bx=0!\nAborting packing of GCT Jet Output!"; return; }
244  }
245 
246  // Now find the collection offsets for the HfRingSums, HfBitCounts, and HtMiss with bx=0
247  unsigned bx0HfRingSumsOffset, bx0HfBitCountsOffset, bx0HtMissOffset;
248  if(!findBx0OffsetInCollection(bx0HfRingSumsOffset, hfRingSums)) { LogDebug("GCT") << "No ring sums with bx=0!\nAborting packing of GCT Jet Output!"; return; }
249  if(!findBx0OffsetInCollection(bx0HfBitCountsOffset, hfBitCounts)) { LogDebug("GCT") << "No bit counts with bx=0!\nAborting packing of GCT Jet Output!"; return; }
250  if(!findBx0OffsetInCollection(bx0HtMissOffset, htMiss)) { LogDebug("GCT") << "No missing Ht with bx=0!\nAborting packing of GCT Jet Output!"; return; }
251 
252  // Now write the header, as we should now have all requisite data.
253  writeRawHeader(d, 0x583, 1); // ** NOTE can only currenly do 1 timesample! **
254 
255  d=d+4; // move forward past the block header to the block payload.
256 
257  // FIRST DO JET CANDS
258  // re-interpret pointer to 16 bits - the space allocated for each Jet candidate.
259  uint16_t * p16 = reinterpret_cast<uint16_t *>(d);
260 
261  const unsigned categoryOffset = 4; // Offset to jump from one jet category to the next.
262  const unsigned nextCandPairOffset = 2; // Offset to jump to next candidate pair.
263 
264  // Loop over the different catagories of jets
265  for(unsigned iCat = 0 ; iCat < NUM_JET_CATEGORIES ; ++iCat)
266  {
267  const L1GctJetCandCollection * jetCands = jets.at(iCat); // The current category of jet cands.
268  const unsigned cand0Offset = iCat*categoryOffset; // the offset on p16 to get the rank 0 Jet Cand of the correct category.
269  const unsigned bx0Offset = bx0JetCandOffsets.at(iCat); // The offset in the jet cand collection to the bx=0 jets.
270 
271  p16[cand0Offset] = jetCands->at(bx0Offset).raw(); // rank 0 jet in bx=0
272  p16[cand0Offset + nextCandPairOffset] = jetCands->at(bx0Offset + 1).raw(); // rank 1 jet in bx=0
273  p16[cand0Offset + 1] = jetCands->at(bx0Offset + 2).raw(); // rank 2 jet in bx=0
274  p16[cand0Offset + nextCandPairOffset + 1] = jetCands->at(bx0Offset + 3).raw(); // rank 3 jet in bx=0.
275  }
276 
277  // NOW DO JET COUNTS
278  d=d+24; // move forward past the jet cands to the jet counts section
279 
280  // re-interpret pointer to 32 bit.
281  uint32_t * p32 = reinterpret_cast<uint32_t *>(d);
282 
283  uint32_t tmp = hfBitCounts->at(bx0HfBitCountsOffset).raw() & 0xfff;
284  tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(0)<<12;
285  tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(1)<<16;
286  tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(2)<<19;
287  tmp |= hfRingSums->at(bx0HfRingSumsOffset).etSum(3)<<22;
288  p32[0] = tmp;
289 
290  const L1GctHtMiss& bx0HtMiss = htMiss->at(bx0HtMissOffset);
291  uint32_t htMissRaw = 0x5555c000 |
292  (bx0HtMiss.overFlow() ? 0x1000 : 0x0000) |
293  ((bx0HtMiss.et() & 0x7f) << 5) |
294  ((bx0HtMiss.phi() & 0x1f));
295 
296  p32[1] = htMissRaw;
297 }
#define LogDebug(id)
void writeRawHeader(unsigned char *data, uint32_t blockId, uint32_t nSamples) const
Writes a raw block header into the raw data array for a given block ID and number of time-samples...
std::vector< L1GctJetCand > L1GctJetCandCollection
bool overFlow() const
get the overflow
Definition: L1GctHtMiss.h:63
vector< PseudoJet > jets
unsigned et() const
get the magnitude
Definition: L1GctHtMiss.h:60
unsigned int offset(bool)
Persistable copy of missing Et measured at Level-1.
Definition: L1GctHtMiss.h:16
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
bool findBx0OffsetInCollection(unsigned &bx0Offset, const Collection *coll)
Template function (used in packing) that will find the offset to first item in a collection vector wh...
unsigned phi() const
get the Et
Definition: L1GctHtMiss.h:66
void GctFormatTranslateMCLegacy::writeRctEmCandBlocks ( unsigned char *  d,
const L1CaloEmCollection rctEm 
)

Writes the 4 RCT EM Candidate blocks.

Definition at line 299 of file GctFormatTranslateMCLegacy.cc.

References begin, blockLengthMap(), L1CaloEmCand::bx(), trackerHits::c, SourceCardRouting::EmuToSfpData::eIsoCardId, SourceCardRouting::EmuToSfpData::eIsoRank, SourceCardRouting::EmuToSfpData::eIsoRegionId, SourceCardRouting::EMUtoSFP(), end, SourceCardRouting::EmuToSfpData::eNonIsoCardId, SourceCardRouting::EmuToSfpData::eNonIsoRank, SourceCardRouting::EmuToSfpData::eNonIsoRegionId, i, L1CaloEmCand::index(), getHLTprescales::index, L1CaloEmCand::isolated(), LogDebug, L1CaloEmCand::rank(), L1CaloEmCand::rctCard(), L1CaloEmCand::rctCrate(), rctEmCrateMap(), L1CaloEmCand::rctRegion(), SourceCardRouting::EmuToSfpData::sfp, findQualityFiles::size, GctFormatTranslateBase::srcCardRouting(), and GctFormatTranslateBase::writeRawHeader().

Referenced by GctDigiToRaw::produce().

300 {
301  // This method is one giant "temporary" hack for CMSSW_1_8_X and CMSSW_2_0_0.
302 
303  if(rctEm->size() == 0 || rctEm->size()%144 != 0) // Should be 18 crates * 2 types (iso/noniso) * 4 electrons = 144 for 1 bx.
304  {
305  LogDebug("GCT") << "Block pack error: bad L1CaloEmCollection size detected!\n"
306  << "Aborting packing of RCT EM Cand data!";
307  return;
308  }
309 
310  // Need 18 sets of EM fibre data, since 18 RCT crates
311  SourceCardRouting::EmuToSfpData emuToSfpData[18];
312 
313  // Fill in the input arrays with the data from the digi
314  for(unsigned i=0, size=rctEm->size(); i < size ; ++i)
315  {
316  const L1CaloEmCand &cand = rctEm->at(i);
317  if(cand.bx() != 0) { continue; } // Only interested in bunch crossing zero for now!
318  unsigned crateNum = cand.rctCrate();
319  unsigned index = cand.index();
320 
321  // Some error checking.
322  assert(crateNum < 18); // Only 18 RCT crates!
323  assert(index < 4); // Should only be 4 cands of each type per crate!
324 
325  if(cand.isolated())
326  {
327  emuToSfpData[crateNum].eIsoRank[index] = cand.rank();
328  emuToSfpData[crateNum].eIsoCardId[index] = cand.rctCard();
329  emuToSfpData[crateNum].eIsoRegionId[index] = cand.rctRegion();
330  }
331  else
332  {
333  emuToSfpData[crateNum].eNonIsoRank[index] = cand.rank();
334  emuToSfpData[crateNum].eNonIsoCardId[index] = cand.rctCard();
335  emuToSfpData[crateNum].eNonIsoRegionId[index] = cand.rctRegion();
336  }
337  // Note doing nothing with the MIP bit and Q bit arrays as we are not
338  // interested in them; these arrays will contain uninitialised junk
339  // and so you will get out junk for sourcecard output 0 - I.e. don't
340  // trust sfp[0][0] or sfp[1][0] output!.
341  }
342 
343  // Now run the conversion
344  for(unsigned c = 0 ; c < 18 ; ++c)
345  {
346  srcCardRouting().EMUtoSFP(emuToSfpData[c].eIsoRank, emuToSfpData[c].eIsoCardId, emuToSfpData[c].eIsoRegionId,
347  emuToSfpData[c].eNonIsoRank, emuToSfpData[c].eNonIsoCardId, emuToSfpData[c].eNonIsoRegionId,
348  emuToSfpData[c].mipBits, emuToSfpData[c].qBits, emuToSfpData[c].sfp);
349  }
350 
351  // Now pack up the data into the RAW format.
352  BlkToRctCrateMap::iterator blockStartCrateIter;
353  for(blockStartCrateIter = rctEmCrateMap().begin() ; blockStartCrateIter != rctEmCrateMap().end() ; ++blockStartCrateIter)
354  {
355  unsigned blockId = blockStartCrateIter->first;
356  unsigned startCrate = blockStartCrateIter->second;
357  unsigned blockLength_32bit = blockLengthMap()[blockId];
358 
359  writeRawHeader(d, blockId, 1);
360  d+=4; // move past header.
361 
362  // Want a 16 bit pointer to push the 16 bit data in.
363  uint16_t * p16 = reinterpret_cast<uint16_t *>(const_cast<unsigned char *>(d));
364 
365  for(unsigned iCrate=startCrate, end=startCrate + blockLength_32bit/3 ; iCrate < end ; ++iCrate)
366  {
367  for(unsigned iOutput = 1 ; iOutput < 4 ; ++iOutput) // skipping output 0 as that is Q-bit/MIP-bit data.
368  {
369  for(unsigned iCycle = 0 ; iCycle < 2 ; ++iCycle)
370  {
371  *p16 = emuToSfpData[iCrate].sfp[iCycle][iOutput];
372  ++p16;
373  }
374  }
375  }
376 
377  // Now move d onto the location of the next block header
378  d+=(blockLength_32bit*4);
379  }
380 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
Struct of all data needed for running the emulator to SFP (sourcecard optical output) conversion...
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:18
void writeRawHeader(unsigned char *data, uint32_t blockId, uint32_t nSamples) const
Writes a raw block header into the raw data array for a given block ID and number of time-samples...
const SourceCardRouting & srcCardRouting() const
Protected interface to the unpackSharedRegions commissioning option.
void EMUtoSFP(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned short(&SFP)[2][4]) const
virtual BlockLengthMap & blockLengthMap()
get the static block ID to block-length map.
unsigned rctCrate() const
get RCT crate
Definition: L1CaloEmCand.h:53
bool isolated() const
which stream did this come from
Definition: L1CaloEmCand.h:56
int16_t bx() const
get bunch-crossing index
Definition: L1CaloEmCand.h:62
unsigned rank() const
get rank bits
Definition: L1CaloEmCand.h:44
unsigned rctCard() const
get RCT receiver card
Definition: L1CaloEmCand.h:47
#define end
Definition: vmac.h:38
unsigned index() const
get index on cable
Definition: L1CaloEmCand.h:59
#define begin
Definition: vmac.h:31
unsigned rctRegion() const
get RCT region ID
Definition: L1CaloEmCand.h:50
virtual BlkToRctCrateMap & rctEmCrateMap()
get the static block ID to RCT crate map for electrons.
tuple size
Write out results.

Member Data Documentation

GctFormatTranslateMCLegacy::BlockLengthMap GctFormatTranslateMCLegacy::m_blockLength = GctFormatTranslateMCLegacy::BlockLengthMap()
staticprivate

Map to translate block number to fundamental size of a block (i.e. for 1 time-sample).

Definition at line 114 of file GctFormatTranslateMCLegacy.h.

Referenced by blockLengthMap(), and GctFormatTranslateMCLegacy().

GctFormatTranslateMCLegacy::BlockNameMap GctFormatTranslateMCLegacy::m_blockName = GctFormatTranslateMCLegacy::BlockNameMap()
staticprivate

Map to hold a description for each block number.

Definition at line 117 of file GctFormatTranslateMCLegacy.h.

Referenced by blockNameMap(), and GctFormatTranslateMCLegacy().

GctFormatTranslateMCLegacy::BlockIdToUnpackFnMap GctFormatTranslateMCLegacy::m_blockUnpackFn = GctFormatTranslateMCLegacy::BlockIdToUnpackFnMap()
staticprivate

Block ID to unpack function map.

Definition at line 130 of file GctFormatTranslateMCLegacy.h.

Referenced by convertBlock(), and GctFormatTranslateMCLegacy().

A map of Block IDs to IsoBoundaryPairs for storing the location of the isolated Internal EM cands in the pipeline, as this differs with Block ID.

Definition at line 127 of file GctFormatTranslateMCLegacy.h.

Referenced by internEmIsoBounds().

GctFormatTranslateMCLegacy::BlkToRctCrateMap GctFormatTranslateMCLegacy::m_rctEmCrate = GctFormatTranslateMCLegacy::BlkToRctCrateMap()
staticprivate

Map to relate capture block ID to the RCT crate the data originated from (for electrons).

Definition at line 120 of file GctFormatTranslateMCLegacy.h.

Referenced by GctFormatTranslateMCLegacy(), and rctEmCrateMap().

GctFormatTranslateMCLegacy::BlkToRctCrateMap GctFormatTranslateMCLegacy::m_rctJetCrate = GctFormatTranslateMCLegacy::BlkToRctCrateMap()
staticprivate

Map to relate capture block ID to the RCT crate the data originated from (for jets).

Definition at line 123 of file GctFormatTranslateMCLegacy.h.

Referenced by rctJetCrateMap().