CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalTPGScale.cc
Go to the documentation of this file.
2 
4 
8  lutMapToken_(c.esConsumes<EcalTPGLutIdMap, EcalTPGLutIdMapRcd>()) {}
9 
10 EcalTPGScale::EcalTPGScale(Tokens const& tokens, const edm::EventSetup& evtSetup)
11  : phys_(evtSetup.getData(tokens.physConstToken_)),
12  lutGrp_(evtSetup.getData(tokens.lutGrpToken_)),
13  lut_(evtSetup.getData(tokens.lutMapToken_))
14 
15 {}
16 
18  const EcalTrigTowerDetId& towerId = tpDigi.id();
19  int ADC = tpDigi.compressedEt();
20  return getTPGInGeV(ADC, towerId);
21 }
22 
23 double EcalTPGScale::getTPGInGeV(unsigned int ADC, const EcalTrigTowerDetId& towerId) const {
24  // 1. get lsb
25 
26  const EcalTPGPhysicsConstMap& physMap = phys_.getMap();
27  uint32_t eb = DetId(DetId::Ecal, EcalBarrel).rawId();
28  uint32_t ee = DetId(DetId::Ecal, EcalEndcap).rawId();
29  EcalTPGPhysicsConstMapIterator it = physMap.end();
30  if (towerId.subDet() == EcalBarrel)
31  it = physMap.find(eb);
32  else if (towerId.subDet() == EcalEndcap)
33  it = physMap.find(ee);
34  double lsb10bits = 0.;
35  if (it != physMap.end()) {
36  EcalTPGPhysicsConst::Item item = it->second;
37  lsb10bits = item.EtSat / 1024.;
38  }
39 
40  // 2. linearized TPG
41  return lsb10bits * getLinearizedTPG(ADC, towerId);
42 }
43 
44 unsigned int EcalTPGScale::getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId& towerId) const {
45  int tpg10bits = 0;
46 
47  const EcalTPGGroups::EcalTPGGroupsMap& lutGrpMap = lutGrp_.getMap();
48  EcalTPGGroups::EcalTPGGroupsMapItr itgrp = lutGrpMap.find(towerId.rawId());
49  uint32_t lutGrp = 999;
50  if (itgrp != lutGrpMap.end())
51  lutGrp = itgrp->second;
52 
53  const EcalTPGLutIdMap::EcalTPGLutMap& lutMap = lut_.getMap();
54  EcalTPGLutIdMap::EcalTPGLutMapItr itLut = lutMap.find(lutGrp);
55  if (itLut != lutMap.end()) {
56  const unsigned int* lut = (itLut->second).getLut();
57  for (unsigned int i = 0; i < 1024; i++)
58  if (ADC == (0xff & lut[i])) {
59  tpg10bits = i;
60  break;
61  }
62  }
63 
64  return tpg10bits;
65 }
66 
67 unsigned int EcalTPGScale::getTPGInADC(double energy, const EcalTrigTowerDetId& towerId) const {
68  unsigned int tpgADC = 0;
69 
70  // 1. get lsb
71 
72  const EcalTPGPhysicsConstMap& physMap = phys_.getMap();
73 
74  uint32_t eb = DetId(DetId::Ecal, EcalBarrel).rawId();
75  uint32_t ee = DetId(DetId::Ecal, EcalEndcap).rawId();
76  EcalTPGPhysicsConstMapIterator it = physMap.end();
77  if (towerId.subDet() == EcalBarrel)
78  it = physMap.find(eb);
79  else if (towerId.subDet() == EcalEndcap)
80  it = physMap.find(ee);
81  double lsb10bits = 0.;
82  if (it != physMap.end()) {
83  EcalTPGPhysicsConst::Item item = it->second;
84  lsb10bits = item.EtSat / 1024.;
85  }
86 
87  // 2. get compressed look-up table
88 
89  const EcalTPGGroups::EcalTPGGroupsMap& lutGrpMap = lutGrp_.getMap();
90  EcalTPGGroups::EcalTPGGroupsMapItr itgrp = lutGrpMap.find(towerId);
91  uint32_t lutGrp = 0;
92  if (itgrp != lutGrpMap.end())
93  lutGrp = itgrp->second;
94 
95  const EcalTPGLutIdMap::EcalTPGLutMap& lutMap = lut_.getMap();
96  EcalTPGLutIdMap::EcalTPGLutMapItr itLut = lutMap.find(lutGrp);
97  if (itLut != lutMap.end()) {
98  const unsigned int* lut = (itLut->second).getLut();
99  if (lsb10bits > 0) {
100  int tpgADC10b = int(energy / lsb10bits + 0.5);
101  if (tpgADC10b >= 0 && tpgADC10b < 1024)
102  tpgADC = (0xff & lut[tpgADC10b]);
103  if (tpgADC10b >= 1024)
104  tpgADC = 0xff;
105  }
106  }
107 
108  return tpgADC;
109 }
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:25
const edm::EventSetup & c
EcalTPGScale(Tokens const &, const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:10
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
EcalTPGPhysicsConst const & phys_
Definition: EcalTPGScale.h:34
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
EcalTPGLutIdMap const & lut_
Definition: EcalTPGScale.h:36
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:67
int compressedEt() const
get the encoded/compressed Et of interesting sample
const EcalTPGLutMap & getMap() const
unsigned towerId(DetId const &, EcalElectronicsMapping const *)
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi) const
Definition: EcalTPGScale.cc:17
Definition: DetId.h:17
const std::map< uint32_t, Item > & getMap() const
const EcalTrigTowerDetId & id() const
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
EcalTPGLutGroup const & lutGrp_
Definition: EcalTPGScale.h:35
std::map< uint32_t, EcalTPGPhysicsConst::Item > EcalTPGPhysicsConstMap
std::map< uint32_t, EcalTPGPhysicsConst::Item >::const_iterator EcalTPGPhysicsConstMapIterator
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
Tokens(edm::ConsumesCollector)
Definition: EcalTPGScale.cc:5
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:44