CMS 3D CMS Logo

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