Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002    \file
0003    Test suit for DTDigis
0004 
0005    \author Stefano ARGIRO
0006    \date 29 Jun 2005
0007 
0008    \note This test is not exaustive     
0009 */
0010 
0011 #include <cppunit/extensions/HelperMacros.h>
0012 #include <DataFormats/DTDigi/interface/DTDigi.h>
0013 #include <DataFormats/DTDigi/interface/DTDigiCollection.h>
0014 #include <DataFormats/MuonDetId/interface/DTLayerId.h>
0015 
0016 using namespace std;
0017 
0018 class testDTDigis : public CppUnit::TestFixture {
0019   CPPUNIT_TEST_SUITE(testDTDigis);
0020 
0021   CPPUNIT_TEST(testDigiCollectionInsert);
0022   CPPUNIT_TEST(testDigiCollectionPut);
0023   CPPUNIT_TEST(testTime2TDCConversion);
0024 
0025   CPPUNIT_TEST_SUITE_END();
0026 
0027 public:
0028   void setUp() {}
0029   void tearDown() {}
0030   void testDigiCollectionInsert();
0031   void testDigiCollectionPut();
0032   void testTime2TDCConversion();
0033 };
0034 
0035 ///registration of the test so that the runner can find it
0036 CPPUNIT_TEST_SUITE_REGISTRATION(testDTDigis);
0037 
0038 void testDTDigis::testDigiCollectionPut() {
0039   DTLayerId layer(2, 3, 8, 1, 4);
0040 
0041   DTDigiCollection digiCollection;
0042 
0043   std::vector<DTDigi> digivec;
0044   for (int i = 0; i < 10; ++i) {
0045     DTDigi digi(1 + i, 5 + i, 100 + i);
0046     digivec.push_back(digi);
0047   }
0048 
0049   digiCollection.put(std::make_pair(digivec.begin(), digivec.end()), layer);
0050 
0051   // Loop over the DetUnits with digis
0052   DTDigiCollection::DigiRangeIterator detUnitIt;
0053   for (detUnitIt = digiCollection.begin(); detUnitIt != digiCollection.end(); ++detUnitIt) {
0054     const DTLayerId& id = (*detUnitIt).first;
0055     const DTDigiCollection::Range& range = (*detUnitIt).second;
0056 
0057     //     // We have inserted digis for only one DetUnit...
0058     CPPUNIT_ASSERT(id == layer);
0059 
0060     // Loop over the digis of this DetUnit
0061     int i = 0;
0062     for (DTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second;
0063          //        detUnitIt->second.first;
0064          //      digiIt!=detUnitIt->second.second;
0065          ++digiIt) {
0066       CPPUNIT_ASSERT((*digiIt).wire() == 1 + i);
0067       CPPUNIT_ASSERT((*digiIt).countsTDC() == 5 + i);
0068       CPPUNIT_ASSERT((*digiIt).number() == 100 + i);
0069       i++;
0070 
0071       // Test the channel() functionality
0072       //       DTDigi digi2((*digiIt).channel(),(*digiIt).countsTDC());
0073       //       CPPUNIT_ASSERT((*digiIt)==digi2);
0074 
0075     }  // for digis in layer
0076   }    // for layers
0077 }
0078 
0079 void testDTDigis::testDigiCollectionInsert() {
0080   DTDigi digi(1, 5, 4);
0081 
0082   DTLayerId layer(2, 3, 8, 1, 4);
0083 
0084   DTDigiCollection digiCollection;
0085 
0086   digiCollection.insertDigi(layer, digi);
0087 
0088   unsigned int count = 0;
0089 
0090   // Loop over the DetUnits with digis
0091   DTDigiCollection::DigiRangeIterator detUnitIt;
0092   for (detUnitIt = digiCollection.begin(); detUnitIt != digiCollection.end(); ++detUnitIt) {
0093     const DTLayerId& id = (*detUnitIt).first;
0094     const DTDigiCollection::Range& range = (*detUnitIt).second;
0095 
0096     // We have inserted digis for only one DetUnit...
0097     CPPUNIT_ASSERT(id == layer);
0098 
0099     // Loop over the digis of this DetUnit
0100     for (DTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
0101       //std::cout << (*digiIt) << std::endl;
0102       CPPUNIT_ASSERT((*digiIt).wire() == 1);
0103       CPPUNIT_ASSERT((*digiIt).number() == 4);
0104       CPPUNIT_ASSERT((*digiIt).countsTDC() == 5);
0105 
0106       count++;
0107     }  // for digis in layer
0108   }    // for layers
0109 
0110   CPPUNIT_ASSERT(count != 0);
0111 }
0112 
0113 void testDTDigis::testTime2TDCConversion() {
0114   float time = 243;
0115   float reso = 25. / 32.;
0116   int tdc = int(time / reso);
0117   int pos = 2;
0118   int wire = 1;
0119 
0120   DTDigi digi(wire, time, pos);
0121   CPPUNIT_ASSERT(digi.countsTDC() == tdc);
0122 }
0123 
0124 #include <Utilities/Testing/interface/CppUnit_testdriver.icpp>