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 }
EcalTPGScale::getTPGInGeV
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:18
testEcalTPGScale::eTTmap_
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_
Definition: testEcalTPGScale.h:32
EcalTPGScale
Definition: EcalTPGScale.h:8
testEcalTPGScale::theEndcapGeometry_
const CaloSubdetectorGeometry * theEndcapGeometry_
Definition: testEcalTPGScale.h:30
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
EcalTPGScale::setEventSetup
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:16
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
relativeConstraints.error
error
Definition: relativeConstraints.py:53
testEcalTPGScale::beginJob
void beginJob() override
Definition: testEcalTPGScale.cc:71
EcalBarrelGeometryRecord
Definition: EcalBarrelGeometryRecord.h:23
EcalBarrel
Definition: EcalSubdetector.h:10
EBDetId::tower
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:57
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
EcalTPGScale::getLinearizedTPG
unsigned int getLinearizedTPG(unsigned int ADC, const EcalTrigTowerDetId &towerId)
Definition: EcalTPGScale.cc:47
edm::ESHandle< CaloGeometry >
ADC
Definition: ZdcTBAnalysis.h:46
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
EcalTPGScale::getTPGInADC
unsigned int getTPGInADC(double energy, const EcalTrigTowerDetId &towerId)
Definition: EcalTPGScale.cc:75
EEDetId
Definition: EEDetId.h:14
CaloGeometryRecord.h
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
CaloSubdetectorGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:36
testEcalTPGScale::testEcalTPGScale
testEcalTPGScale(edm::ParameterSet const &pSet)
Definition: testEcalTPGScale.cc:13
edm::EventSetup
Definition: EventSetup.h:57
DetId::Ecal
Definition: DetId.h:27
get
#define get
testEcalTPGScale.h
CaloCellGeometry.h
std
Definition: JetResolutionObject.h:76
testEcalTPGScale::theBarrelGeometry_
const CaloSubdetectorGeometry * theBarrelGeometry_
Definition: testEcalTPGScale.h:31
CaloGeometry.h
testEcalTPGScale::analyze
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Definition: testEcalTPGScale.cc:17
edm::Event
Definition: Event.h:73
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
EcalTPGScale.h