Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:18

0001 /* Unit test for EcalUncalibratedRecHit
0002    Konstantinos Theofilatos', Oct 2011
0003 
0004  */
0005 
0006 #include <cppunit/extensions/HelperMacros.h>
0007 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
0008 #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
0009 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0010 
0011 class testEcalUncalibratedRecHit : public CppUnit::TestFixture {
0012   CPPUNIT_TEST_SUITE(testEcalUncalibratedRecHit);
0013   CPPUNIT_TEST(testOne);
0014   CPPUNIT_TEST_SUITE_END();
0015 
0016 public:
0017   void setUp() {}
0018   void tearDown() {}
0019   void print(uint32_t k) {
0020     for (int i = 31; i >= 0; i--) {
0021       std::cout << (((0x1 << i) & k) != 0);
0022     }
0023     std::cout << std::endl;
0024   }
0025 
0026   void testOne();
0027 };
0028 
0029 ///registration of the test so that the runner can find it
0030 CPPUNIT_TEST_SUITE_REGISTRATION(testEcalUncalibratedRecHit);
0031 
0032 void testEcalUncalibratedRecHit::testOne() {
0033   std::cout << std::endl;
0034   std::cout << "testing the EcalUncalibratedRecHit " << std::endl;
0035 
0036   EcalUncalibratedRecHit urh;
0037 
0038   std::cout << "initial status" << std::endl;
0039   print(urh.flags());
0040 
0041   urh.setAmplitude(17.3);
0042   CPPUNIT_ASSERT(urh.amplitude() == (float)17.3);
0043   urh.setAmplitudeError(1.3);
0044   CPPUNIT_ASSERT(urh.amplitudeError() == (float)1.3);
0045   urh.setPedestal(12.35);
0046   CPPUNIT_ASSERT(urh.pedestal() == (float)12.35);
0047   urh.setJitter(3.35);
0048   CPPUNIT_ASSERT(urh.jitter() == (float)3.35);
0049   urh.setChi2(12.35);
0050   CPPUNIT_ASSERT(urh.chi2() == (float)12.35);
0051   const unsigned int nsample = EcalDataFrame::MAXSAMPLES;
0052   for (unsigned int ibx = 0; ibx < nsample; ++ibx) {
0053     urh.setOutOfTimeAmplitude(ibx, 11.2 + ibx);
0054     CPPUNIT_ASSERT(urh.outOfTimeAmplitude(ibx) == (float)(11.2 + ibx));
0055   }
0056   print(urh.flags());
0057 
0058   std::cout << "start setting flagBits" << std::endl;
0059   print(urh.flags());
0060   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0061             << std::endl;
0062   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0063             << std::endl;
0064   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0065             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0066   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0067             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0068   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0069             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0070   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kGood));
0071   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0072   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0073   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0074   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0075 
0076   std::cout << "setting EcalUncalibratedRecHit::kHasSwitchToGain6" << std::endl;
0077   urh.setFlagBit(EcalUncalibratedRecHit::kHasSwitchToGain6);  //
0078   print(urh.flags());
0079   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0080             << std::endl;
0081   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kHasSwitchToGain6) = "
0082             << urh.checkFlag(EcalUncalibratedRecHit::kHasSwitchToGain6) << std::endl;
0083   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0084             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0085   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0086             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0087   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0088             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0089   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kGood));
0090   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kHasSwitchToGain6));
0091   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0092   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0093   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0094 
0095   std::cout << "setting EcalUncalibratedRecHit::kPoorReco" << std::endl;
0096   urh.setFlagBit(EcalUncalibratedRecHit::kPoorReco);  //
0097   print(urh.flags());
0098   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0099             << std::endl;
0100   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0101             << std::endl;
0102   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0103             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0104   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0105             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0106   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0107             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0108   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kGood));
0109   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0110   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0111   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0112   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0113 
0114   std::cout << "setting EcalUncalibratedRecHit::kHasSwitchToGain1" << std::endl;
0115   urh.setFlagBit(EcalUncalibratedRecHit::kHasSwitchToGain1);  //
0116   print(urh.flags());
0117   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0118             << std::endl;
0119   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kHasSwitchToGain1) = "
0120             << urh.checkFlag(EcalUncalibratedRecHit::kHasSwitchToGain1) << std::endl;
0121   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0122             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0123   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0124             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0125   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0126             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0127   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kGood));
0128   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kHasSwitchToGain1));
0129   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0130   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0131   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0132 
0133   std::cout << "setting EcalUncalibratedRecHit::kOutOfTime" << std::endl;
0134   urh.setFlagBit(EcalUncalibratedRecHit::kOutOfTime);  //
0135   print(urh.flags());
0136   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0137             << std::endl;
0138   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0139             << std::endl;
0140   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0141             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0142   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0143             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0144   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0145             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0146   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kGood));
0147   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0148   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0149   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0150   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0151 
0152   std::cout << "setting EcalUncalibratedRecHit::kGood" << std::endl;
0153   urh.setFlagBit(EcalUncalibratedRecHit::kGood);  //
0154   print(urh.flags());
0155   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0156             << std::endl;
0157   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0158             << std::endl;
0159   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0160             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0161   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0162             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0163   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0164             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0165   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kGood));
0166   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0167   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0168   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0169   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0170 
0171   std::cout << "setting EcalUncalibratedRecHit::kLeadingEdgeRecovered" << std::endl;
0172   urh.setFlagBit(EcalUncalibratedRecHit::kLeadingEdgeRecovered);  //
0173   print(urh.flags());
0174   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0175             << std::endl;
0176   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0177             << std::endl;
0178   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0179             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0180   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0181             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0182   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0183             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0184   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kGood));
0185   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0186   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0187   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0188   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0189   CPPUNIT_ASSERT(!urh.isSaturated());
0190 
0191   std::cout << "setting EcalUncalibratedRecHit::kSaturated" << std::endl;
0192   urh.setFlagBit(EcalUncalibratedRecHit::kSaturated);  //
0193   print(urh.flags());
0194   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0195             << std::endl;
0196   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0197             << std::endl;
0198   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0199             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0200   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0201             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0202   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0203             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0204   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kGood));
0205   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0206   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0207   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0208   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0209   CPPUNIT_ASSERT(urh.isSaturated());
0210 
0211   std::cout << "setting EcalUncalibratedRecHit::kOutOfTime" << std::endl;
0212   urh.setFlagBit(EcalUncalibratedRecHit::kOutOfTime);  //
0213   print(urh.flags());
0214   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0215             << std::endl;
0216   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0217             << std::endl;
0218   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0219             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0220   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0221             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0222   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0223             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0224   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kGood));
0225   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0226   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0227   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0228   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0229 
0230   std::cout << "setting EcalUncalibratedRecHit::kPoorReco" << std::endl;
0231   urh.setFlagBit(EcalUncalibratedRecHit::kPoorReco);  //
0232   print(urh.flags());
0233   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0234             << std::endl;
0235   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0236             << std::endl;
0237   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0238             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0239   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0240             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0241   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0242             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0243   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kGood));
0244   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0245   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0246   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0247   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0248 
0249   std::cout << "setting EcalUncalibratedRecHit::kGood" << std::endl;
0250   urh.setFlagBit(EcalUncalibratedRecHit::kGood);  //
0251   print(urh.flags());
0252   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kGood) = " << urh.checkFlag(EcalUncalibratedRecHit::kGood)
0253             << std::endl;
0254   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kPoorReco) = " << urh.checkFlag(EcalUncalibratedRecHit::kPoorReco)
0255             << std::endl;
0256   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kSaturated) = "
0257             << urh.checkFlag(EcalUncalibratedRecHit::kSaturated) << std::endl;
0258   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) = "
0259             << urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime) << std::endl;
0260   std::cout << "urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) = "
0261             << urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered) << std::endl;
0262   CPPUNIT_ASSERT(urh.checkFlag(EcalUncalibratedRecHit::kGood));
0263   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kPoorReco));
0264   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kSaturated));
0265   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kOutOfTime));
0266   CPPUNIT_ASSERT(!urh.checkFlag(EcalUncalibratedRecHit::kLeadingEdgeRecovered));
0267 }