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 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const CaloSubdetectorGeometry * theEndcapGeometry_
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:67
edm::ESGetToken< CaloSubdetectorGeometry, EcalEndcapGeometryRecord > endcapGeomToken_
void beginJob() override
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId) const
Definition: EcalTPGScale.cc:44
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)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
std::vector< edm::EDGetTokenT< int > > tokens_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
EcalTPGScale::Tokens tokens_
testEcalTPGScale(edm::ParameterSet const &pSet)
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi) const
Definition: EcalTPGScale.cc:17
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
HLT enums.
const CaloSubdetectorGeometry * theBarrelGeometry_
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > eTTmapToken_
edm::ESGetToken< CaloSubdetectorGeometry, EcalBarrelGeometryRecord > barrelGeomToken_