testCaloCluster

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/* Unit test for CaloCluster
   Stefano Argiro', Dec 2010

 */

#include <cppunit/extensions/HelperMacros.h>
#include "DataFormats/CaloRecHit/interface/CaloCluster.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/CaloRecHit/interface/CaloID.h"
#include "DataFormats/DetId/interface/DetId.h"

class testCaloCluster : public CppUnit::TestFixture {
  CPPUNIT_TEST_SUITE(testCaloCluster);
  CPPUNIT_TEST(FlagsTest);
  CPPUNIT_TEST_SUITE_END();

public:
  void setUp() {}
  void tearDown() {}

  void FlagsTest();
};

///registration of the test so that the runner can find it
CPPUNIT_TEST_SUITE_REGISTRATION(testCaloCluster);

void testCaloCluster::FlagsTest() {
  using namespace reco;
  using namespace math;

  CaloCluster c1(0., XYZPoint(), CaloID(), CaloCluster::island, CaloCluster::cleanOnly);
  CPPUNIT_ASSERT(c1.flags() == CaloCluster::cleanOnly);
  CPPUNIT_ASSERT(c1.isInClean() == true);
  CPPUNIT_ASSERT(c1.isInUnclean() == false);

  CaloCluster c2(0., XYZPoint(), CaloID(), CaloCluster::island, CaloCluster::uncleanOnly);
  CPPUNIT_ASSERT(c2.flags() == CaloCluster::uncleanOnly);
  CPPUNIT_ASSERT(c2.isInUnclean() == true);
  CPPUNIT_ASSERT(c2.isInClean() == false);

  CaloCluster c3(0., XYZPoint(), CaloID(), CaloCluster::island, CaloCluster::common);
  CPPUNIT_ASSERT(c3.flags() == CaloCluster::common);
  CPPUNIT_ASSERT(c3.isInUnclean() == true);
  CPPUNIT_ASSERT(c3.isInClean() == true);

  c3.setFlags(CaloCluster::common);
  CPPUNIT_ASSERT(c3.isInUnclean() == true);
  CPPUNIT_ASSERT(c3.isInClean() == true);
  CPPUNIT_ASSERT(c3.flags() == CaloCluster::common);

  c3.setFlags(CaloCluster::uncleanOnly);
  CPPUNIT_ASSERT(c3.isInUnclean() == true);
  CPPUNIT_ASSERT(c3.isInClean() == false);
  CPPUNIT_ASSERT(c3.flags() == CaloCluster::uncleanOnly);

  c3.setFlags(CaloCluster::cleanOnly);
  CPPUNIT_ASSERT(c3.isInUnclean() == false);
  CPPUNIT_ASSERT(c3.isInClean() == true);
  CPPUNIT_ASSERT(c3.flags() == CaloCluster::cleanOnly);
}