CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 }
const CaloSubdetectorGeometry * theEndcapGeometry_
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:67
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)
edm::ESGetToken< CaloSubdetectorGeometry, EcalEndcapGeometryRecord > endcapGeomToken_
void beginJob() override
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi) const
Definition: EcalTPGScale.cc:17
std::vector< edm::EDGetTokenT< int > > tokens_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
EcalTPGScale::Tokens tokens_
testEcalTPGScale(edm::ParameterSet const &pSet)
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
const CaloSubdetectorGeometry * theBarrelGeometry_
tuple cout
Definition: gather_cfg.py:144
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > eTTmapToken_
edm::ESGetToken< CaloSubdetectorGeometry, EcalBarrelGeometryRecord > barrelGeomToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:44