CMS 3D CMS Logo

testEcalTPGScale.cc
Go to the documentation of this file.
1 
2 #include "testEcalTPGScale.h"
8 
12 
14  std::cout << "I'm going to check the internal consistancy of EcalTPGScale transformation..." << std::endl;
15 }
16 
17 void testEcalTPGScale::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
18  using namespace edm;
19  using namespace std;
20 
21  // geometry
22  ESHandle<CaloGeometry> theGeometry;
23  ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
24  evtSetup.get<CaloGeometryRecord>().get(theGeometry);
25  evtSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap", theEndcapGeometry_handle);
26  evtSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel", theBarrelGeometry_handle);
27  evtSetup.get<IdealGeometryRecord>().get(eTTmap_);
28  theEndcapGeometry_ = &(*theEndcapGeometry_handle);
29  theBarrelGeometry_ = &(*theBarrelGeometry_handle);
30 
31  EcalTPGScale ecalScale;
32  ecalScale.setEventSetup(evtSetup);
33 
34  bool error(false);
35  vector<DetId>::const_iterator it;
36 
37  // EB
38  const std::vector<DetId>& ebCells = theBarrelGeometry_->getValidDetIds(DetId::Ecal, EcalBarrel);
39  it = ebCells.begin();
40  const EBDetId idEB(*it);
41  const EcalTrigTowerDetId towidEB = idEB.tower();
42  for (unsigned int ADC = 0; ADC < 256; ADC++) {
43  double gev = ecalScale.getTPGInGeV(ADC, towidEB);
44  unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEB);
45  if (tpgADC != ADC) {
46  error = true;
47  cout << " ERROR : with ADC = " << ADC << " getTPGInGeV = " << gev << " getTPGInADC = " << tpgADC << endl;
48  }
49  ecalScale.getLinearizedTPG(ADC, towidEB);
50  }
51 
52  // EE
53  const std::vector<DetId>& eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
54  it = eeCells.begin();
55  const EEDetId idEE(*it);
56  const EcalTrigTowerDetId towidEE = (*eTTmap_).towerOf(idEE);
57  for (unsigned int ADC = 0; ADC < 256; ADC++) {
58  double gev = ecalScale.getTPGInGeV(ADC, towidEE);
59  unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEE);
60  if (tpgADC != ADC) {
61  error = true;
62  cout << " ERROR : with ADC = " << ADC << " getTPGInGeV = " << gev << " getTPGInADC = " << tpgADC << endl;
63  }
64  ecalScale.getLinearizedTPG(ADC, towidEE);
65  }
66 
67  if (!error)
68  cout << " there is no error with EcalTPGScale internal consistancy " << endl;
69 }
70 
72  using namespace edm;
73  using namespace std;
74 }
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId)
Definition: EcalTPGScale.cc:47
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:16
const CaloSubdetectorGeometry * theEndcapGeometry_
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:18
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)
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId)
Definition: EcalTPGScale.cc:75
void beginJob() override
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
testEcalTPGScale(edm::ParameterSet const &pSet)
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
HLT enums.
T get() const
Definition: EventSetup.h:73
const CaloSubdetectorGeometry * theBarrelGeometry_
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_