Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:01

0001 
0002 #include "testEcalTPGScale.h"
0003 #include "CalibCalorimetry/EcalTPGTools/interface/EcalTPGScale.h"
0004 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0005 
0006 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0007 
0008 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0009 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0010 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0011 
0012 testEcalTPGScale::testEcalTPGScale(edm::ParameterSet const& pSet)
0013     : geomToken_(esConsumes<CaloGeometry, CaloGeometryRecord>()),
0014       endcapGeomToken_(
0015           esConsumes<CaloSubdetectorGeometry, EcalEndcapGeometryRecord>(edm::ESInputTag{"", "EcalEndcap"})),
0016       barrelGeomToken_(
0017           esConsumes<CaloSubdetectorGeometry, EcalBarrelGeometryRecord>(edm::ESInputTag{"", "EcalBarrel"})),
0018       eTTmapToken_(esConsumes<EcalTrigTowerConstituentsMap, IdealGeometryRecord>()),
0019       tokens_(consumesCollector()) {
0020   std::cout << "I'm going to check the internal consistancy of EcalTPGScale transformation..." << std::endl;
0021 }
0022 
0023 void testEcalTPGScale::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
0024   using namespace edm;
0025   using namespace std;
0026 
0027   // geometry
0028   ESHandle<CaloGeometry> theGeometry = evtSetup.getHandle(geomToken_);
0029   ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle = evtSetup.getHandle(endcapGeomToken_);
0030   ESHandle<CaloSubdetectorGeometry> theBarrelGeometry_handle = evtSetup.getHandle(barrelGeomToken_);
0031   ESHandle<EcalTrigTowerConstituentsMap> eTTmap = evtSetup.getHandle(eTTmapToken_);
0032 
0033   theEndcapGeometry_ = &(*theEndcapGeometry_handle);
0034   theBarrelGeometry_ = &(*theBarrelGeometry_handle);
0035 
0036   EcalTPGScale ecalScale(tokens_, evtSetup);
0037 
0038   bool error(false);
0039   vector<DetId>::const_iterator it;
0040 
0041   // EB
0042   const std::vector<DetId>& ebCells = theBarrelGeometry_->getValidDetIds(DetId::Ecal, EcalBarrel);
0043   it = ebCells.begin();
0044   const EBDetId idEB(*it);
0045   const EcalTrigTowerDetId towidEB = idEB.tower();
0046   for (unsigned int ADC = 0; ADC < 256; ADC++) {
0047     double gev = ecalScale.getTPGInGeV(ADC, towidEB);
0048     unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEB);
0049     if (tpgADC != ADC) {
0050       error = true;
0051       cout << " ERROR : with ADC = " << ADC << " getTPGInGeV = " << gev << " getTPGInADC = " << tpgADC << endl;
0052     }
0053     ecalScale.getLinearizedTPG(ADC, towidEB);
0054   }
0055 
0056   // EE
0057   const std::vector<DetId>& eeCells = theEndcapGeometry_->getValidDetIds(DetId::Ecal, EcalEndcap);
0058   it = eeCells.begin();
0059   const EEDetId idEE(*it);
0060   const EcalTrigTowerDetId towidEE = (*eTTmap).towerOf(idEE);
0061   for (unsigned int ADC = 0; ADC < 256; ADC++) {
0062     double gev = ecalScale.getTPGInGeV(ADC, towidEE);
0063     unsigned int tpgADC = ecalScale.getTPGInADC(gev, towidEE);
0064     if (tpgADC != ADC) {
0065       error = true;
0066       cout << " ERROR : with ADC = " << ADC << " getTPGInGeV = " << gev << " getTPGInADC = " << tpgADC << endl;
0067     }
0068     ecalScale.getLinearizedTPG(ADC, towidEE);
0069   }
0070 
0071   if (!error)
0072     cout << " there is no error with EcalTPGScale internal consistancy " << endl;
0073 }
0074 
0075 void testEcalTPGScale::beginJob() {
0076   using namespace edm;
0077   using namespace std;
0078 }