CMS 3D CMS Logo

testEcalTPGScale.cc
Go to the documentation of this file.
1 
2 #include "testEcalTPGScale.h"
5 
7 
11 
13  : geomToken_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
14  endcapGeomToken_(
16  barrelGeomToken_(
17  esConsumes<CaloSubdetectorGeometry, EcalBarrelGeometryRecord>(edm::ESInputTag{"", "EcalBarrel"})),
18  eTTmapToken_(esConsumes<EcalTrigTowerConstituentsMap, IdealGeometryRecord>()),
19  tokens_(consumesCollector()) {
20  std::cout << "I'm going to check the internal consistancy of EcalTPGScale transformation..." << std::endl;
21 }
22 
23 void testEcalTPGScale::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
24  using namespace edm;
25  using namespace std;
26 
27  // geometry
28  ESHandle<CaloGeometry> theGeometry = evtSetup.getHandle(geomToken_);
29  ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle = evtSetup.getHandle(endcapGeomToken_);
30  ESHandle<CaloSubdetectorGeometry> theBarrelGeometry_handle = evtSetup.getHandle(barrelGeomToken_);
32 
33  theEndcapGeometry_ = &(*theEndcapGeometry_handle);
34  theBarrelGeometry_ = &(*theBarrelGeometry_handle);
35 
36  EcalTPGScale ecalScale(tokens_, evtSetup);
37 
38  bool error(false);
39  vector<DetId>::const_iterator it;
40 
41  // EB
42  const std::vector<DetId>& ebCells = theBarrelGeometry_->getValidDetIds(DetId::Ecal, EcalBarrel);
43  it = ebCells.begin();
44  const EBDetId idEB(*it);
45  const EcalTrigTowerDetId towidEB = idEB.tower();
46  for (unsigned int ADC = 0; ADC < 256; ADC++) {
47  double gev = ecalScale.getTPGInGeV(ADC, towidEB);
48  unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEB);
49  if (tpgADC != ADC) {
50  error = true;
51  cout << " ERROR : with ADC = " << ADC << " getTPGInGeV = " << gev << " getTPGInADC = " << tpgADC << endl;
52  }
53  ecalScale.getLinearizedTPG(ADC, towidEB);
54  }
55 
56  // EE
57  const std::vector<DetId>& eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
58  it = eeCells.begin();
59  const EEDetId idEE(*it);
60  const EcalTrigTowerDetId towidEE = (*eTTmap).towerOf(idEE);
61  for (unsigned int ADC = 0; ADC < 256; ADC++) {
62  double gev = ecalScale.getTPGInGeV(ADC, towidEE);
63  unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEE);
64  if (tpgADC != ADC) {
65  error = true;
66  cout << " ERROR : with ADC = " << ADC << " getTPGInGeV = " << gev << " getTPGInADC = " << tpgADC << endl;
67  }
68  ecalScale.getLinearizedTPG(ADC, towidEE);
69  }
70 
71  if (!error)
72  cout << " there is no error with EcalTPGScale internal consistancy " << endl;
73 }
74 
76  using namespace edm;
77  using namespace std;
78 }
edm::ESInputTag
Definition: ESInputTag.h:87
EcalTPGScale
Definition: EcalTPGScale.h:16
testEcalTPGScale::theEndcapGeometry_
const CaloSubdetectorGeometry * theEndcapGeometry_
Definition: testEcalTPGScale.h:38
ESInputTag
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EBDetId.h
EEDetId.h
EcalEndcapGeometryRecord
Definition: EcalEndcapGeometryRecord.h:23
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
relativeConstraints.error
error
Definition: relativeConstraints.py:53
testEcalTPGScale::beginJob
void beginJob() override
Definition: testEcalTPGScale.cc:75
EcalTPGScale::getLinearizedTPG
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:44
EcalBarrel
Definition: EcalSubdetector.h:10
testEcalTPGScale::endcapGeomToken_
edm::ESGetToken< CaloSubdetectorGeometry, EcalEndcapGeometryRecord > endcapGeomToken_
Definition: testEcalTPGScale.h:41
CaloGeometry
Definition: CaloGeometry.h:21
EBDetId::tower
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
edm::ESHandle< CaloGeometry >
ADC
Definition: ZdcTBAnalysis.h:46
tokens_
std::vector< edm::EDGetTokenT< int > > tokens_
Definition: TimeStudyModules.cc:75
CaloSubdetectorGeometry::getValidDetIds
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
Definition: CaloSubdetectorGeometry.cc:32
EEDetId
Definition: EEDetId.h:14
CaloGeometryRecord.h
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
edm::ParameterSet
Definition: ParameterSet.h:47
testEcalTPGScale::geomToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
Definition: testEcalTPGScale.h:40
EcalTPGScale::getTPGInGeV
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi) const
Definition: EcalTPGScale.cc:17
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
testEcalTPGScale::testEcalTPGScale
testEcalTPGScale(edm::ParameterSet const &pSet)
Definition: testEcalTPGScale.cc:12
edm::EventSetup
Definition: EventSetup.h:58
DetId::Ecal
Definition: DetId.h:27
testEcalTPGScale.h
CaloCellGeometry.h
std
Definition: JetResolutionObject.h:76
testEcalTPGScale::barrelGeomToken_
edm::ESGetToken< CaloSubdetectorGeometry, EcalBarrelGeometryRecord > barrelGeomToken_
Definition: testEcalTPGScale.h:42
testEcalTPGScale::tokens_
EcalTPGScale::Tokens tokens_
Definition: testEcalTPGScale.h:44
testEcalTPGScale::theBarrelGeometry_
const CaloSubdetectorGeometry * theBarrelGeometry_
Definition: testEcalTPGScale.h:39
EcalTPGScale::getTPGInADC
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:67
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
testEcalTPGScale::analyze
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Definition: testEcalTPGScale.cc:23
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
testEcalTPGScale::eTTmapToken_
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > eTTmapToken_
Definition: testEcalTPGScale.h:43
EcalTPGScale.h