CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  std::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  int RCT_LUT_EB[256] ;
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  std::cout<<" ERROR : with ADC = "<<ADC<<" getTPGInGeV = "<<gev<<" getTPGInADC = "<<tpgADC<<std::endl ;
52  }
53  RCT_LUT_EB[ADC] = 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  int RCT_LUT_EE[256] ;
62  for (unsigned int ADC=0 ; ADC<256 ; ADC++) {
63  double gev = ecalScale.getTPGInGeV(ADC, towidEE) ;
64  unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEE) ;
65  if (tpgADC != ADC) {
66  error = true ;
67  std::cout<<" ERROR : with ADC = "<<ADC<<" getTPGInGeV = "<<gev<<" getTPGInADC = "<<tpgADC<<std::endl ;
68  }
69  RCT_LUT_EE[ADC] = ecalScale.getLinearizedTPG(ADC, towidEE) ;
70  }
71 
72 
73  if (!error) std::cout<<" there is no error with EcalTPGScale internal consistancy "<<std::endl ;
74 
75 }
76 
78 {
79  using namespace edm;
80  using namespace std;
81 
82 }
83 
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:19
const CaloSubdetectorGeometry * theEndcapGeometry_
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)
virtual void beginJob()
EcalTrigTowerDetId tower() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.h:52
virtual void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup)
const T & get() const
Definition: EventSetup.h:55
testEcalTPGScale(edm::ParameterSet const &pSet)
const CaloSubdetectorGeometry * theBarrelGeometry_
tuple cout
Definition: gather_cfg.py:41
struct ADC ADC
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_