Go to the documentation of this file.00001
00002 #include "testEcalTPGScale.h"
00003 #include "CalibCalorimetry/EcalTPGTools/interface/EcalTPGScale.h"
00004 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00005 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00006 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00007 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00008
00009 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00010 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00011 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00012
00013
00014 testEcalTPGScale::testEcalTPGScale(edm::ParameterSet const& pSet)
00015 {
00016 std::cout<<"I'm going to check the internal consistancy of EcalTPGScale transformation..."<<std::endl ;
00017 }
00018
00019 void testEcalTPGScale::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup)
00020 {
00021 using namespace edm;
00022 using namespace std;
00023
00024
00025 ESHandle<CaloGeometry> theGeometry;
00026 ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
00027 evtSetup.get<CaloGeometryRecord>().get( theGeometry );
00028 evtSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap",theEndcapGeometry_handle);
00029 evtSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel",theBarrelGeometry_handle);
00030 evtSetup.get<IdealGeometryRecord>().get(eTTmap_);
00031 theEndcapGeometry_ = &(*theEndcapGeometry_handle);
00032 theBarrelGeometry_ = &(*theBarrelGeometry_handle);
00033
00034 EcalTPGScale ecalScale ;
00035 ecalScale.setEventSetup(evtSetup) ;
00036
00037 bool error(false) ;
00038 std::vector<DetId>::const_iterator it ;
00039
00040
00041 const std::vector<DetId>& ebCells = theBarrelGeometry_->getValidDetIds(DetId::Ecal, EcalBarrel);
00042 it = ebCells.begin() ;
00043 const EBDetId idEB(*it) ;
00044 const EcalTrigTowerDetId towidEB = idEB.tower();
00045 int RCT_LUT_EB[256] ;
00046 for (unsigned int ADC=0 ; ADC<256 ; ADC++) {
00047 double gev = ecalScale.getTPGInGeV(ADC, towidEB) ;
00048 unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEB) ;
00049 if (tpgADC != ADC) {
00050 error = true ;
00051 std::cout<<" ERROR : with ADC = "<<ADC<<" getTPGInGeV = "<<gev<<" getTPGInADC = "<<tpgADC<<std::endl ;
00052 }
00053 RCT_LUT_EB[ADC] = ecalScale.getLinearizedTPG(ADC, towidEB) ;
00054 }
00055
00056
00057 const std::vector<DetId>& eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
00058 it = eeCells.begin() ;
00059 const EEDetId idEE(*it);
00060 const EcalTrigTowerDetId towidEE = (*eTTmap_).towerOf(idEE) ;
00061 int RCT_LUT_EE[256] ;
00062 for (unsigned int ADC=0 ; ADC<256 ; ADC++) {
00063 double gev = ecalScale.getTPGInGeV(ADC, towidEE) ;
00064 unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEE) ;
00065 if (tpgADC != ADC) {
00066 error = true ;
00067 std::cout<<" ERROR : with ADC = "<<ADC<<" getTPGInGeV = "<<gev<<" getTPGInADC = "<<tpgADC<<std::endl ;
00068 }
00069 RCT_LUT_EE[ADC] = ecalScale.getLinearizedTPG(ADC, towidEE) ;
00070 }
00071
00072
00073 if (!error) std::cout<<" there is no error with EcalTPGScale internal consistancy "<<std::endl ;
00074
00075 }
00076
00077 void testEcalTPGScale::beginJob()
00078 {
00079 using namespace edm;
00080 using namespace std;
00081
00082 }
00083