CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTPGScale.cc
Go to the documentation of this file.
2 
4 
11 
12 
14 { }
15 
17 { }
18 
20 {
21  setup_ = &evtSetup ;
22 }
23 
25 {
26  const EcalTrigTowerDetId & towerId = tpDigi.id() ;
27  int ADC = tpDigi.compressedEt() ;
28  return getTPGInGeV(ADC, towerId) ;
29 }
30 
32 {
33  // 1. get lsb
35  setup_->get<EcalTPGPhysicsConstRcd>().get( physHandle );
36  const EcalTPGPhysicsConstMap & physMap = physHandle.product()->getMap() ;
37 
38  uint32_t eb = DetId(DetId::Ecal,EcalBarrel).rawId() ;
39  uint32_t ee = DetId(DetId::Ecal,EcalEndcap).rawId() ;
40  EcalTPGPhysicsConstMapIterator it = physMap.end() ;
41  if (towerId.subDet() == EcalBarrel) it = physMap.find(eb) ;
42  else if (towerId.subDet() == EcalEndcap) it = physMap.find(ee) ;
43  double lsb10bits = 0. ;
44  if (it != physMap.end()) {
45  EcalTPGPhysicsConst::Item item = it->second ;
46  lsb10bits = item.EtSat/1024. ;
47  }
48 
49  // 2. linearized TPG
50  return lsb10bits * getLinearizedTPG(ADC, towerId) ;
51 
52 }
53 
54 unsigned int EcalTPGScale::getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId & towerId)
55 {
56  int tpg10bits = 0 ;
57 
58  // Get compressed look-up table
59  edm::ESHandle<EcalTPGLutGroup> lutGrpHandle;
60  setup_->get<EcalTPGLutGroupRcd>().get( lutGrpHandle );
61  const EcalTPGGroups::EcalTPGGroupsMap & lutGrpMap = lutGrpHandle.product()->getMap() ;
62  EcalTPGGroups::EcalTPGGroupsMapItr itgrp = lutGrpMap.find(towerId.rawId()) ;
63  uint32_t lutGrp = 999 ;
64  if (itgrp != lutGrpMap.end()) lutGrp = itgrp->second ;
65 
66  edm::ESHandle<EcalTPGLutIdMap> lutMapHandle;
67  setup_->get<EcalTPGLutIdMapRcd>().get( lutMapHandle );
68  const EcalTPGLutIdMap::EcalTPGLutMap & lutMap = lutMapHandle.product()->getMap() ;
69  EcalTPGLutIdMap::EcalTPGLutMapItr itLut = lutMap.find(lutGrp) ;
70  if (itLut != lutMap.end()) {
71  const unsigned int * lut = (itLut->second).getLut() ;
72  for (unsigned int i=0 ; i<1024 ; i++)
73  if (ADC == (0xff & lut[i])) {
74  tpg10bits = i ;
75  break ;
76  }
77  }
78 
79  return tpg10bits ;
80 }
81 
83 {
84  unsigned int tpgADC = 0 ;
85 
86  // 1. get lsb
88  setup_->get<EcalTPGPhysicsConstRcd>().get( physHandle );
89  const EcalTPGPhysicsConstMap & physMap = physHandle.product()->getMap() ;
90 
91  uint32_t eb = DetId(DetId::Ecal,EcalBarrel).rawId() ;
92  uint32_t ee = DetId(DetId::Ecal,EcalEndcap).rawId() ;
93  EcalTPGPhysicsConstMapIterator it = physMap.end() ;
94  if (towerId.subDet() == EcalBarrel) it = physMap.find(eb) ;
95  else if (towerId.subDet() == EcalEndcap) it = physMap.find(ee) ;
96  double lsb10bits = 0. ;
97  if (it != physMap.end()) {
98  EcalTPGPhysicsConst::Item item = it->second ;
99  lsb10bits = item.EtSat/1024. ;
100  }
101 
102  // 2. get compressed look-up table
103  edm::ESHandle<EcalTPGLutGroup> lutGrpHandle;
104  setup_->get<EcalTPGLutGroupRcd>().get( lutGrpHandle );
105  const EcalTPGGroups::EcalTPGGroupsMap & lutGrpMap = lutGrpHandle.product()->getMap() ;
106  EcalTPGGroups::EcalTPGGroupsMapItr itgrp = lutGrpMap.find(towerId) ;
107  uint32_t lutGrp = 0 ;
108  if (itgrp != lutGrpMap.end()) lutGrp = itgrp->second ;
109 
110  edm::ESHandle<EcalTPGLutIdMap> lutMapHandle;
111  setup_->get<EcalTPGLutIdMapRcd>().get( lutMapHandle );
112  const EcalTPGLutIdMap::EcalTPGLutMap & lutMap = lutMapHandle.product()->getMap() ;
113  EcalTPGLutIdMap::EcalTPGLutMapItr itLut = lutMap.find(lutGrp) ;
114  if (itLut != lutMap.end()) {
115  const unsigned int * lut = (itLut->second).getLut() ;
116  if (lsb10bits>0) {
117  int tpgADC10b = int(energy/lsb10bits+0.5) ;
118  if (tpgADC10b>=0 && tpgADC10b<1024) tpgADC = (0xff & lut[tpgADC10b]) ;
119  if (tpgADC10b>=1024) tpgADC = 0xff ;
120  }
121  }
122 
123  return tpgADC ;
124 }
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId)
Definition: EcalTPGScale.cc:54
int i
Definition: DBlmapReader.cc:9
const edm::EventSetup * setup_
Definition: EcalTPGScale.h:23
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:19
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:23
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:24
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int compressedEt() const
get the encoded/compressed Et of interesting sample
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId)
Definition: EcalTPGScale.cc:82
void get(HolderT &iHolder) const
tuple lut
Definition: lumiPlot.py:244
unsigned towerId(DetId const &)
Definition: DetId.h:18
const EcalTrigTowerDetId & id() const
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
std::map< uint32_t, EcalTPGPhysicsConst::Item > EcalTPGPhysicsConstMap
std::map< uint32_t, EcalTPGPhysicsConst::Item >::const_iterator EcalTPGPhysicsConstMapIterator
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:22
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr