CMS 3D CMS Logo

EcalTPGScale.cc
Go to the documentation of this file.
2 
4 
11 
13 
15 
16 void EcalTPGScale::setEventSetup(const edm::EventSetup& evtSetup) { setup_ = &evtSetup; }
17 
19  const EcalTrigTowerDetId& towerId = tpDigi.id();
20  int ADC = tpDigi.compressedEt();
21  return getTPGInGeV(ADC, towerId);
22 }
23 
25  // 1. get lsb
27  setup_->get<EcalTPGPhysicsConstRcd>().get(physHandle);
28  const EcalTPGPhysicsConstMap& physMap = physHandle.product()->getMap();
29 
30  uint32_t eb = DetId(DetId::Ecal, EcalBarrel).rawId();
31  uint32_t ee = DetId(DetId::Ecal, EcalEndcap).rawId();
32  EcalTPGPhysicsConstMapIterator it = physMap.end();
33  if (towerId.subDet() == EcalBarrel)
34  it = physMap.find(eb);
35  else if (towerId.subDet() == EcalEndcap)
36  it = physMap.find(ee);
37  double lsb10bits = 0.;
38  if (it != physMap.end()) {
39  EcalTPGPhysicsConst::Item item = it->second;
40  lsb10bits = item.EtSat / 1024.;
41  }
42 
43  // 2. linearized TPG
44  return lsb10bits * getLinearizedTPG(ADC, towerId);
45 }
46 
47 unsigned int EcalTPGScale::getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId& towerId) {
48  int tpg10bits = 0;
49 
50  // Get compressed look-up table
51  edm::ESHandle<EcalTPGLutGroup> lutGrpHandle;
52  setup_->get<EcalTPGLutGroupRcd>().get(lutGrpHandle);
53  const EcalTPGGroups::EcalTPGGroupsMap& lutGrpMap = lutGrpHandle.product()->getMap();
54  EcalTPGGroups::EcalTPGGroupsMapItr itgrp = lutGrpMap.find(towerId.rawId());
55  uint32_t lutGrp = 999;
56  if (itgrp != lutGrpMap.end())
57  lutGrp = itgrp->second;
58 
59  edm::ESHandle<EcalTPGLutIdMap> lutMapHandle;
60  setup_->get<EcalTPGLutIdMapRcd>().get(lutMapHandle);
61  const EcalTPGLutIdMap::EcalTPGLutMap& lutMap = lutMapHandle.product()->getMap();
62  EcalTPGLutIdMap::EcalTPGLutMapItr itLut = lutMap.find(lutGrp);
63  if (itLut != lutMap.end()) {
64  const unsigned int* lut = (itLut->second).getLut();
65  for (unsigned int i = 0; i < 1024; i++)
66  if (ADC == (0xff & lut[i])) {
67  tpg10bits = i;
68  break;
69  }
70  }
71 
72  return tpg10bits;
73 }
74 
76  unsigned int tpgADC = 0;
77 
78  // 1. get lsb
80  setup_->get<EcalTPGPhysicsConstRcd>().get(physHandle);
81  const EcalTPGPhysicsConstMap& physMap = physHandle.product()->getMap();
82 
83  uint32_t eb = DetId(DetId::Ecal, EcalBarrel).rawId();
84  uint32_t ee = DetId(DetId::Ecal, EcalEndcap).rawId();
85  EcalTPGPhysicsConstMapIterator it = physMap.end();
86  if (towerId.subDet() == EcalBarrel)
87  it = physMap.find(eb);
88  else if (towerId.subDet() == EcalEndcap)
89  it = physMap.find(ee);
90  double lsb10bits = 0.;
91  if (it != physMap.end()) {
92  EcalTPGPhysicsConst::Item item = it->second;
93  lsb10bits = item.EtSat / 1024.;
94  }
95 
96  // 2. get compressed look-up table
97  edm::ESHandle<EcalTPGLutGroup> lutGrpHandle;
98  setup_->get<EcalTPGLutGroupRcd>().get(lutGrpHandle);
99  const EcalTPGGroups::EcalTPGGroupsMap& lutGrpMap = lutGrpHandle.product()->getMap();
100  EcalTPGGroups::EcalTPGGroupsMapItr itgrp = lutGrpMap.find(towerId);
101  uint32_t lutGrp = 0;
102  if (itgrp != lutGrpMap.end())
103  lutGrp = itgrp->second;
104 
105  edm::ESHandle<EcalTPGLutIdMap> lutMapHandle;
106  setup_->get<EcalTPGLutIdMapRcd>().get(lutMapHandle);
107  const EcalTPGLutIdMap::EcalTPGLutMap& lutMap = lutMapHandle.product()->getMap();
108  EcalTPGLutIdMap::EcalTPGLutMapItr itLut = lutMap.find(lutGrp);
109  if (itLut != lutMap.end()) {
110  const unsigned int* lut = (itLut->second).getLut();
111  if (lsb10bits > 0) {
112  int tpgADC10b = int(energy / lsb10bits + 0.5);
113  if (tpgADC10b >= 0 && tpgADC10b < 1024)
114  tpgADC = (0xff & lut[tpgADC10b]);
115  if (tpgADC10b >= 1024)
116  tpgADC = 0xff;
117  }
118  }
119 
120  return tpgADC;
121 }
EcalTPGScale::getTPGInGeV
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:18
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalTPGLutGroupRcd.h
mps_fire.i
i
Definition: mps_fire.py:355
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::setEventSetup
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:16
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
EcalBarrel
Definition: EcalSubdetector.h:10
DetId
Definition: DetId.h:17
EcalTPGLutIdMap.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
EcalTPGScale::getLinearizedTPG
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId)
Definition: EcalTPGScale.cc:47
edm::ESHandle
Definition: DTSurvey.h:22
ADC
Definition: ZdcTBAnalysis.h:46
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
EcalTPGScale::getTPGInADC
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId)
Definition: EcalTPGScale.cc:75
EcalEndcap
Definition: EcalSubdetector.h:10
EcalTPGLutGroup.h
EcalTPGPhysicsConst::getMap
const std::map< uint32_t, Item > & getMap() const
Definition: EcalTPGPhysicsConst.h:27
EcalTPGPhysicsConst::Item
Definition: EcalTPGPhysicsConst.h:14
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
EcalTPGScale::setup_
const edm::EventSetup * setup_
Definition: EcalTPGScale.h:22
DetId::Ecal
Definition: DetId.h:27
get
#define get
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
EcalTriggerPrimitiveDigi
Definition: EcalTriggerPrimitiveDigi.h:16
EcalTPGLutIdMapRcd.h
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
EcalTPGScale::EcalTPGScale
EcalTPGScale()
Definition: EcalTPGScale.cc:12
EcalTPGPhysicsConst.h
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
EcalTPGScale::~EcalTPGScale
~EcalTPGScale()
Definition: EcalTPGScale.cc:14
EcalTPGLutGroupRcd
Definition: EcalTPGLutGroupRcd.h:5
EcalTPGPhysicsConstRcd.h
EcalTPGPhysicsConstMapIterator
std::map< uint32_t, EcalTPGPhysicsConst::Item >::const_iterator EcalTPGPhysicsConstMapIterator
Definition: EcalTPGPhysicsConst.h:37
EcalTPGPhysicsConstRcd
Definition: EcalTPGPhysicsConstRcd.h:5
EcalTPGScale.h
EcalTPGGroups::EcalTPGGroupsMap
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19