Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:04

0001 /**
0002    \file
0003    test file for EcalShowerContainmentCorrections 
0004 
0005    \author Stefano ARGIRO
0006    \version $Id: FEDRawData_t.cpp,v 1.2 2006/03/27 10:08:21 argiro Exp $
0007    \date 28 Jun 2005
0008 */
0009 
0010 #include <cppunit/extensions/HelperMacros.h>
0011 #include "CondFormats/EcalCorrections/interface/EcalShowerContainmentCorrections.h"
0012 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0013 class testEcalShowerContainmentCorrections : public CppUnit::TestFixture {
0014   CPPUNIT_TEST_SUITE(testEcalShowerContainmentCorrections);
0015 
0016   CPPUNIT_TEST(testFillandReadBack1);
0017   CPPUNIT_TEST(testFillandReadBack2);
0018 
0019   CPPUNIT_TEST_SUITE_END();
0020 
0021 public:
0022   void setUp();
0023   void tearDown();
0024   void testFillandReadBack1();
0025   void testFillandReadBack2();
0026 
0027   double* testdata_;
0028 };
0029 
0030 ///registration of the test so that the runner can find it
0031 CPPUNIT_TEST_SUITE_REGISTRATION(testEcalShowerContainmentCorrections);
0032 
0033 void testEcalShowerContainmentCorrections::setUp() {
0034   testdata_ = new double[EcalShowerContainmentCorrections::Coefficients::kSize];
0035 
0036   for (unsigned int i = 0; i < EcalShowerContainmentCorrections::Coefficients::kSize; ++i)
0037     testdata_[i] = i;
0038 }
0039 
0040 void testEcalShowerContainmentCorrections::tearDown() { delete[] testdata_; }
0041 
0042 void testEcalShowerContainmentCorrections::testFillandReadBack1() {
0043   EcalShowerContainmentCorrections::Coefficients coeff;
0044   std::copy(testdata_, testdata_ + EcalShowerContainmentCorrections::Coefficients::kSize, coeff.data);
0045 
0046   // fill a random xtal
0047   EBDetId xtal(5, 550, EBDetId::SMCRYSTALMODE);
0048 
0049   EcalShowerContainmentCorrections correction;
0050 
0051   correction.fillCorrectionCoefficients(xtal, 3, coeff);
0052 
0053   EcalShowerContainmentCorrections::Coefficients correction_readback = correction.correctionCoefficients(xtal);
0054 
0055   for (unsigned int i = 0; i < EcalShowerContainmentCorrections::Coefficients::kSize; ++i)
0056     CPPUNIT_ASSERT(testdata_[i] == correction_readback.data[i]);
0057 }
0058 
0059 void testEcalShowerContainmentCorrections::testFillandReadBack2() {
0060   EcalShowerContainmentCorrections::Coefficients coeff;
0061   std::copy(testdata_, testdata_ + EcalShowerContainmentCorrections::Coefficients::kSize, coeff.data);
0062 
0063   EcalShowerContainmentCorrections correction;
0064 
0065   // use filling by module
0066   correction.fillCorrectionCoefficients(3, 2, coeff);
0067 
0068   // this is a xtal in SM3 , module 2
0069   EBDetId xtal(3, 550, EBDetId::SMCRYSTALMODE);
0070 
0071   EcalShowerContainmentCorrections::Coefficients correction_readback = correction.correctionCoefficients(xtal);
0072 
0073   for (unsigned int i = 0; i < EcalShowerContainmentCorrections::Coefficients::kSize; ++i)
0074     CPPUNIT_ASSERT(testdata_[i] == correction_readback.data[i]);
0075 }
0076 
0077 #include <Utilities/Testing/interface/CppUnit_testdriver.icpp>