CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RCTEMUnpacker.cc
Go to the documentation of this file.
4 #include "rctDataBase.h"
5 
6 
13 
14 
15 #include <iostream>
16 #include <fstream>
17 
18 #include "CaloCollections.h"
19 
20 namespace l1t {
21  namespace stage1 {
22  class RCTEmUnpacker : public Unpacker {
23  public:
24  virtual bool unpack(const Block& block, UnpackerCollections *coll) override;
25  private:
26  unsigned int counter_ = 0;
27  };
28  }
29 }
30 
31 // Implementation
32 
33 namespace l1t {
34  namespace stage1 {
36 
37  int nBX = int(ceil(block.header().getSize() / 6.));
38 
39  // Find the first and last BXs
40  int firstBX = -(ceil((double)nBX/2.)-1);
41  int lastBX;
42  if (nBX % 2 == 0) {
43  lastBX = ceil((double)nBX/2.)+1;
44  } else {
45  lastBX = ceil((double)nBX/2.);
46  }
47 
48  auto resRCTEMCands_ = static_cast<CaloCollections*>(coll)->getCaloEmCands();
49  resRCTEMCands_->setBXRange(std::min(firstBX, resRCTEMCands_->getFirstBX()), std::max(lastBX, resRCTEMCands_->getLastBX()));
50 
51  // Initialise index
52  int unsigned i = 0;
53 
54  for (int bx=firstBX; bx<lastBX; bx++){
55 
56  unsigned int crate;
57  bool even=0;
58 
59  std::vector <uint32_t> uint;
60  uint.reserve(6);
61 
62  PhysicsToBitConverter converter;
63  rctDataBase database;
64  int mp7link=(int)(block.header().getID()/2);
65  database.GetLinkRCT(mp7link,crate,even);
66 
67  uint.push_back(block.payload()[i++]);
68  uint.push_back(block.payload()[i++]);
69  uint.push_back(block.payload()[i++]);
70  uint.push_back(block.payload()[i++]);
71  uint.push_back(block.payload()[i++]);
72  uint.push_back(block.payload()[i++]);
73 
74  LogDebug("L1T")<<"--------------- mp7 link ="<<mp7link<<"RCT crate id="<<crate<<", RCT crate even="<<even<<std::endl;
75 
76  if(!even) {
77 
78  for(int j = 0; j < 4; j++) {
79 
80  for(int i=0;i<6;i++) converter.Set32bitWordLinkOdd(i,uint[i]);
81  converter.Convert();
82 
83  unsigned int rank=(unsigned int)converter.GetNEEt(j);
84  unsigned int reg=(unsigned int)converter.GetNEReg(j);
85  unsigned int card=(unsigned int)converter.GetNECard(j);
86 
87  LogDebug("L1T") <<"index="<<j<<", neRank="<<rank<<", neRegn="<<reg<<", neCard="<<card<<std::endl;
88  L1CaloEmCand em = L1CaloEmCand(rank,reg,card,crate,false);
89  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
90  CaloEmCand EmCand(*p4,(int) em.rank(),(int) em.regionId().ieta(),(int) em.regionId().iphi(),(int) j); //j was originally em.index, to be checked
91  EmCand.setHwIso((int) em.isolated());
92  resRCTEMCands_->push_back(bx,EmCand);
93  }
94 
95  for(int j = 0; j < 4; j++) {
96 
97  for(int i=0;i<6;i++) converter.Set32bitWordLinkEven(i,uint[i]);
98  converter.Convert();
99 
100  unsigned int rank=converter.GetIEEt(j);
101  unsigned int reg=converter.GetIEReg(j);
102  unsigned int card=converter.GetIECard(j);
103 
104  LogDebug("L1T") <<"index="<<j<<", neRank="<<rank<<", neRegn="<<reg<<", neCard="<<card<<std::endl;
105  L1CaloEmCand em = L1CaloEmCand(rank,reg,card,crate,true);
106  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
107  CaloEmCand EmCand(*p4,(int) em.rank(),(int) em.regionId().ieta(),(int) em.regionId().iphi(),(int) j); //j was originally em.index, to be checked
108  EmCand.setHwIso((int) em.isolated());
109  resRCTEMCands_->push_back(bx,EmCand);
110  }
111  }// end if odd
112  }// end of loop over BX
113  return true;
114  }
115  }
116 }
117 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
unsigned int getID() const
Definition: Block.h:22
unsigned ieta() const
global eta index (0-21)
BlockHeader header() const
Definition: Block.h:52
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:18
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
std::vector< uint32_t > payload() const
Definition: Block.h:53
#define DEFINE_L1T_UNPACKER(type)
Definition: Unpacker.h:29
void Set32bitWordLinkEven(int index, uint32_t value)
L1CaloRegionDetId regionId() const
get DetID object
Definition: L1CaloEmCand.h:65
double p4[4]
Definition: TauolaWrapper.h:92
bool isolated() const
which stream did this come from
Definition: L1CaloEmCand.h:56
unsigned rank() const
get rank bits
Definition: L1CaloEmCand.h:44
int j
Definition: DBlmapReader.cc:9
void GetLinkRCT(int linkMP7, unsigned int &RCTcrate, bool &RCTeven)
Definition: rctDataBase.h:61
T min(T a, T b)
Definition: MathUtil.h:58
JetCorrectorParametersCollection coll
Definition: classes.h:10
void Set32bitWordLinkOdd(int index, uint32_t value)
unsigned int getSize() const
Definition: Block.h:23
unsigned iphi() const
global phi index (0-17)