CMS 3D CMS Logo

EcalTPGScale.cc
Go to the documentation of this file.
2 
4 
6  : physConstToken_(c.esConsumes<EcalTPGPhysicsConst, EcalTPGPhysicsConstRcd>()),
7  lutGrpToken_(c.esConsumes<EcalTPGLutGroup, EcalTPGLutGroupRcd>()),
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 }
mps_fire.i
i
Definition: mps_fire.py:428
EcalTPGLutIdMap::EcalTPGLutMap
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
Definition: EcalTPGLutIdMap.h:12
EcalTPGGroups::EcalTPGGroupsMapItr
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
ESHandle.h
EcalTPGScale::lutGrp_
EcalTPGLutGroup const & lutGrp_
Definition: EcalTPGScale.h:35
EcalTPGScale::Tokens
Definition: EcalTPGScale.h:18
printContent_cfi.getData
getData
Definition: printContent_cfi.py:16
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalTPGScale::getLinearizedTPG
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:44
EcalBarrel
Definition: EcalSubdetector.h:10
EcalTPGLutGroup
Definition: EcalTPGLutGroup.h:13
DetId
Definition: DetId.h:17
EcalTPGScale::EcalTPGScale
EcalTPGScale(Tokens const &, const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:10
ADC
Definition: ZdcTBAnalysis.h:46
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
EcalEndcap
Definition: EcalSubdetector.h:10
EcalTPGPhysicsConst::getMap
const std::map< uint32_t, Item > & getMap() const
Definition: EcalTPGPhysicsConst.h:27
EcalTPGPhysicsConst::Item
Definition: EcalTPGPhysicsConst.h:14
EcalTPGScale::getTPGInGeV
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi) const
Definition: EcalTPGScale.cc:17
createfilelist.int
int
Definition: createfilelist.py:10
EcalTPGGroups::getMap
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:25
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
DetId::Ecal
Definition: DetId.h:27
EcalTPGPhysicsConst
Definition: EcalTPGPhysicsConst.h:9
ecaldqm::towerId
unsigned towerId(DetId const &)
Definition: EcalDQMCommonUtils.cc:79
EcalTPGPhysicsConstMap
std::map< uint32_t, EcalTPGPhysicsConst::Item > EcalTPGPhysicsConstMap
Definition: EcalTPGPhysicsConst.h:36
EcalTPGLutIdMapRcd
Definition: EcalTPGLutIdMapRcd.h:5
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
EcalTriggerPrimitiveDigi::id
const EcalTrigTowerDetId & id() const
Definition: EcalTriggerPrimitiveDigi.h:29
EcalTPGScale::getTPGInADC
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:67
EcalTriggerPrimitiveDigi
Definition: EcalTriggerPrimitiveDigi.h:16
EcalTPGLutIdMap::EcalTPGLutMapItr
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
Definition: EcalTPGLutIdMap.h:13
EcalTriggerPrimitiveDigi::compressedEt
int compressedEt() const
get the encoded/compressed Et of interesting sample
Definition: EcalTriggerPrimitiveDigi.cc:19
EcalTPGLutGroupRcd
Definition: EcalTPGLutGroupRcd.h:5
EcalTPGScale::phys_
EcalTPGPhysicsConst const & phys_
Definition: EcalTPGScale.h:34
EcalTPGPhysicsConstMapIterator
std::map< uint32_t, EcalTPGPhysicsConst::Item >::const_iterator EcalTPGPhysicsConstMapIterator
Definition: EcalTPGPhysicsConst.h:37
EcalTPGScale::Tokens::Tokens
Tokens(edm::ConsumesCollector)
Definition: EcalTPGScale.cc:5
EcalTPGPhysicsConstRcd
Definition: EcalTPGPhysicsConstRcd.h:5
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
EcalTPGLutIdMap::getMap
const EcalTPGLutMap & getMap() const
Definition: EcalTPGLutIdMap.h:18
EcalTPGScale.h
EcalTPGGroups::EcalTPGGroupsMap
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19
EcalTPGScale::lut_
EcalTPGLutIdMap const & lut_
Definition: EcalTPGScale.h:36