CMS 3D CMS Logo

ZDCUnpacker.cc
Go to the documentation of this file.
3 
5 
6 #include "L1TObjectCollections.h"
7 
8 // #include "L1TStage2Layer2Constants.h"
9 #include "ZDCUnpacker.h"
10 #include "GTSetup.h"
11 
12 namespace l1t {
13  namespace stage2 {
14  ZDCUnpacker::ZDCUnpacker() : EtSumZDCCopy_(0) {}
15 
17  using namespace l1t::stage2;
18  uint32_t zdc_mask = 0x3FF;
19  LogDebug("L1T") << "Block ID = " << block.header().getID() << " size = " << block.header().getSize();
20 
21  int nBX = int(ceil(block.header().getSize() / zdc::nOutputFramePerBX));
22  // expect the first four frames to be the first 4 EtSum objects reported per event (see CMS IN-2013/005)
23 
24  // Find the central, first and last BXs
25  int firstBX = (nBX / 2) - nBX + 1;
26  int lastBX = nBX / 2;
27 
28  auto res_ = static_cast<L1TObjectCollections*>(coll)->getZDCSums(EtSumZDCCopy_);
29  res_->setBXRange(firstBX, lastBX);
30 
31  LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX;
32 
33  // Loop over multiple BX and fill EtSums collection
34  for (int bx = firstBX; bx <= lastBX; bx++) {
35  // ZDC -
36  int iFrame = (bx - firstBX) * zdc::nOutputFramePerBX;
37 
38  uint32_t raw_data = block.payload().at(iFrame + 1); // ZDC - info is found on frame 1 of each bx
39 
41  zdcm.setHwPt(raw_data & zdc_mask);
42  zdcm.setP4(l1t::CaloTools::p4Demux(&zdcm));
43 
44  LogDebug("L1T") << "ZDC -: pT " << zdcm.hwPt() << " bx " << bx;
45 
46  res_->push_back(bx, zdcm);
47 
48  // ZDC +
49  raw_data = block.payload().at(iFrame + 2); // ZDC + info is found on frame 2 of each bx
50 
52  zdcp.setHwPt(raw_data & zdc_mask);
53  zdcp.setP4(l1t::CaloTools::p4Demux(&zdcp));
54 
55  LogDebug("L1T") << "ZDC +: pT " << zdcp.hwPt() << " bx " << bx;
56 
57  res_->push_back(bx, zdcp);
58  }
59 
60  return true;
61  }
62  } // namespace stage2
63 } // namespace l1t
64 
constexpr int32_t ceil(float num)
bool unpack(const Block &block, UnpackerCollections *coll) override
Definition: ZDCUnpacker.cc:16
delete x;
Definition: CaloConfig.h:22
const unsigned int nOutputFramePerBX
Definition: GTSetup.cc:16
unsigned int EtSumZDCCopy_
Definition: ZDCUnpacker.h:15
#define DEFINE_L1T_UNPACKER(type)
static math::PtEtaPhiMLorentzVector p4Demux(l1t::L1Candidate *)
Definition: CaloTools.cc:317
#define LogDebug(id)