CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RCTRegionUnpacker.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 RCTRegionUnpacker : 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 resRCTRegions_ = static_cast<CaloCollections*>(coll)->getCaloRegions();
49  resRCTRegions_->setBXRange(std::min(firstBX, resRCTRegions_->getFirstBX()), std::max(lastBX, resRCTRegions_->getLastBX()));
50 
51  // Initialise index
52  int unsigned i = 0;
53  std::vector <uint32_t> uint;
54  uint.reserve(6);
55 
56  for (int bx=firstBX; bx<lastBX; bx++){
57 
58  unsigned int crate;
59  bool even=0;
60 
61  PhysicsToBitConverter converter;
62  rctDataBase database;
63  int mp7link=(int)(block.header().getID()/2);
64  database.GetLinkRCT(mp7link,crate,even);
65 
66  uint.push_back(block.payload()[i++]);
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 
73  LogDebug("L1T")<<"--------------- mp7 link ="<<mp7link<<"RCT crate id="<<crate<<", RCT crate even="<<even<<std::endl;
74 
75  if(!even) {
76 
77  for(int i=0;i<6;i++) converter.Set32bitWordLinkOdd(i,uint[i]);
78  converter.Convert();
79 
80  for(int j = 0; j < 8; j++) {
81 
82  unsigned int hfet=(unsigned int)converter.GetHFEt(j);
83 
84  std::cout <<"region HF ="<<j<<"="<<hfet<<std::endl;
85  L1CaloRegion rgn = L1CaloRegion(hfet,0,crate,j);
86  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
87  CaloRegion region(*p4,0.,0.,(int) rgn.et(),(int) rgn.id().ieta(),(int) rgn.id().iphi(),0.,0.);
88  resRCTRegions_->push_back(bx,region);
89  }
90  }// end if odd
91 
92 
93  else{
94 
95  for(int i=0;i<6;i++) converter.Set32bitWordLinkEven(i,uint[i]);
96  converter.Convert();
97 
98  for(int j = 0; j < 7; j++) {
99  for(int k = 0; k < 2; k++) {
100 
101  unsigned int RCet=(unsigned int)converter.GetRCEt(j,k);
102  bool overflow=(bool)converter.GetRCOf(j,k);
103  bool tauveto=(bool)converter.GetRCTau(j,k);
104  bool hadveto=(bool)converter.GetRCHad(j,k);
105  bool quiet=false; //to be fixed
106 
107  LogDebug("L1T") <<"region="<<j<<", card="<<k<<", rgnEt="<<RCet<<", overflow="<<overflow<<", tauveto="<<tauveto<<", hadveto="<<hadveto<<std::endl;
108  L1CaloRegion rgn = L1CaloRegion(RCet,overflow,tauveto,hadveto,quiet,crate,j,k);
109  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > *p4 =new ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >();
110  CaloRegion region(*p4,0.,0.,(int) rgn.et(),(int) rgn.id().ieta(),(int) rgn.id().iphi(),0,0);
111  resRCTRegions_->push_back(bx,region);
112  }
113  }
114  }// end if even
115  }// end of loop over BX
116  return true;
117  }
118  }
119 }
120 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
int GetRCTau(int card, int region)
unsigned et() const
get Et
Definition: L1CaloRegion.h:116
unsigned int getID() const
Definition: Block.h:22
unsigned ieta() const
global eta index (0-21)
BlockHeader header() const
Definition: Block.h:52
L1CaloRegionDetId id() const
get global region ID
Definition: L1CaloRegion.h:158
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)
int GetRCHad(int card, int region)
double p4[4]
Definition: TauolaWrapper.h:92
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
int GetRCEt(int card, int region)
JetCorrectorParametersCollection coll
Definition: classes.h:10
virtual bool unpack(const Block &block, UnpackerCollections *coll) override
void Set32bitWordLinkOdd(int index, uint32_t value)
unsigned int getSize() const
Definition: Block.h:23
A calorimeter trigger region (sum of 4x4 trigger towers)
Definition: L1CaloRegion.h:22
unsigned iphi() const
global phi index (0-17)
tuple cout
Definition: gather_cfg.py:121
int GetRCOf(int card, int region)