CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/CalibCalorimetry/EcalTPGTools/plugins/testEcalTPGScale.cc

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   // geometry
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   vector<DetId>::const_iterator it ;
00039 
00040   // EB
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   for (unsigned int ADC=0 ; ADC<256 ; ADC++) {
00046     double gev = ecalScale.getTPGInGeV(ADC, towidEB) ;
00047     unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEB) ;
00048     if (tpgADC != ADC) {
00049       error = true ;
00050       cout<<" ERROR : with ADC = "<<ADC<<" getTPGInGeV = "<<gev<<" getTPGInADC = "<<tpgADC<<endl ;
00051     }
00052     ecalScale.getLinearizedTPG(ADC, towidEB) ;
00053   }
00054 
00055   // EE
00056   const std::vector<DetId>& eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
00057   it = eeCells.begin() ;
00058   const EEDetId idEE(*it);
00059   const EcalTrigTowerDetId towidEE = (*eTTmap_).towerOf(idEE) ;
00060   for (unsigned int ADC=0 ; ADC<256 ; ADC++) {
00061     double gev = ecalScale.getTPGInGeV(ADC, towidEE) ;
00062     unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEE) ;
00063     if (tpgADC != ADC) {
00064       error = true ;
00065       cout<<" ERROR : with ADC = "<<ADC<<" getTPGInGeV = "<<gev<<" getTPGInADC = "<<tpgADC<<endl ;
00066     }
00067     ecalScale.getLinearizedTPG(ADC, towidEE) ;
00068   }
00069 
00070 
00071   if (!error) cout<<" there is no error with EcalTPGScale internal consistancy "<<endl ;
00072 
00073 }
00074 
00075 void testEcalTPGScale::beginJob()
00076 {
00077   using namespace edm;
00078   using namespace std;
00079 
00080 }
00081