Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-27 23:38:18

0001 // system includes
0002 #include <iostream>
0003 #include <iomanip>
0004 #include <sstream>
0005 #include <string>
0006 #include <time.h>
0007 
0008 // user includes
0009 #include "DataFormats/SiStripCommon/interface/Constants.h"
0010 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0011 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 
0016 /**
0017    @class testSiStripFedKey 
0018    @author R.Bainbridge
0019    @brief Simple class that tests SiStripFedKey.
0020 */
0021 class testSiStripFedKey : public edm::one::EDAnalyzer<> {
0022 public:
0023   testSiStripFedKey(const edm::ParameterSet&);
0024   ~testSiStripFedKey();
0025 
0026   void beginJob();
0027   void analyze(const edm::Event&, const edm::EventSetup&);
0028 };
0029 
0030 using namespace sistrip;
0031 
0032 // -----------------------------------------------------------------------------
0033 //
0034 testSiStripFedKey::testSiStripFedKey(const edm::ParameterSet& pset) {
0035   LogTrace(mlDqmCommon_) << "[testSiStripFedKey::" << __func__ << "]"
0036                          << " Constructing object...";
0037 }
0038 
0039 // -----------------------------------------------------------------------------
0040 //
0041 testSiStripFedKey::~testSiStripFedKey() {
0042   LogTrace(mlDqmCommon_) << "[testSiStripFedKey::" << __func__ << "]"
0043                          << " Destructing object...";
0044 }
0045 
0046 // -----------------------------------------------------------------------------
0047 //
0048 void testSiStripFedKey::beginJob() {
0049   uint32_t cntr = 0;
0050   uint32_t start = time(NULL);
0051 
0052   edm::LogInfo(mlDqmCommon_) << "[SiStripFedKey::" << __func__ << "]"
0053                              << " Tests the generation of keys...";
0054 
0055   // FED ids
0056   for (uint16_t ifed = 0; ifed <= sistrip::CMS_FED_ID_MAX + 1; ifed++) {
0057     if (ifed > 1 && ifed != sistrip::FED_ID_MIN + 1 && ifed < sistrip::CMS_FED_ID_MAX - 1) {
0058       continue;
0059     }
0060 
0061     // FE units
0062     for (uint16_t ife = 0; ife <= sistrip::FEUNITS_PER_FED + 1; ife++) {
0063       if (ife > 1 && ife < sistrip::FEUNITS_PER_FED) {
0064         continue;
0065       }
0066 
0067       // FE channels
0068       for (uint16_t ichan = 0; ichan <= sistrip::FEDCH_PER_FEUNIT + 1; ichan++) {
0069         if (ichan > 1 && ichan < sistrip::FEDCH_PER_FEUNIT) {
0070           continue;
0071         }
0072 
0073         // APVs
0074         for (uint16_t iapv = 0; iapv <= sistrip::APVS_PER_FEDCH + 1; iapv++) {
0075           if (iapv > 1 && iapv < sistrip::APVS_PER_FEDCH) {
0076             continue;
0077           }
0078 
0079           // FED channel
0080           uint16_t channel = 12 * ife + ichan;
0081 
0082           // Some debug
0083           if (!(cntr % 1000)) {
0084             LogTrace(mlDqmCommon_) << "[SiStripFedKey::" << __func__ << "]"
0085                                    << " Cntr: " << cntr;
0086           }
0087           cntr++;
0088 
0089           // Print out FED id/channel
0090           std::stringstream ss;
0091           ss << std::endl
0092              << "[SiStripFedKey::" << __func__ << "]"
0093              << " FedId/FeUnit/FeChan/FedCh/APV: " << ifed << "/" << ife << "/" << ichan << "/" << channel << "/"
0094              << iapv << std::endl
0095              << std::endl;
0096 
0097           SiStripFedKey tmp1(ifed, ife, ichan, iapv);
0098           SiStripFedKey tmp2 = SiStripFedKey(tmp1.key());
0099           SiStripFedKey tmp3 = SiStripFedKey(tmp1.path());
0100           SiStripFedKey tmp4 = SiStripFedKey(tmp1);
0101           SiStripFedKey tmp5;
0102           tmp5 = tmp1;
0103 
0104           ss << ">>> original       : ";
0105           tmp1.terse(ss);
0106           ss << std::endl;
0107           ss << ">>> from FED key   : ";
0108           tmp2.terse(ss);
0109           ss << std::endl;
0110           ss << ">>> from directory : ";
0111           tmp3.terse(ss);
0112           ss << std::endl;
0113           ss << ">>> directory      : " << tmp1.path() << std::endl;
0114           ss << ">>> isValid        : " << tmp1.isValid() << " " << tmp1.isValid(tmp1.granularity()) << " "
0115              << tmp1.isValid(sistrip::FED_APV) << std::endl
0116              << ">>> isInvalid      : " << tmp1.isInvalid() << " " << tmp1.isInvalid(tmp1.granularity()) << " "
0117              << tmp1.isInvalid(sistrip::FED_APV);
0118           LogTrace(mlDqmCommon_) << ss.str();
0119         }
0120       }
0121     }
0122   }
0123 
0124   edm::LogVerbatim(mlDqmCommon_) << "[SiStripFedKey::" << __func__ << "]"
0125                                  << " Processed " << cntr << " FedKeys in " << (time(NULL) - start)
0126                                  << " seconds at an average rate of " << (cntr * 1.) / ((time(NULL) - start) * 1.)
0127                                  << " per second...";
0128 
0129   // Tests for utility methods
0130 
0131   SiStripFedKey invalid;
0132   SiStripFedKey inv(sistrip::invalid_, sistrip::invalid_, sistrip::invalid_, sistrip::invalid_);
0133   SiStripFedKey valid(51, 1, 1, 1);
0134   SiStripFedKey all(0, 0, 0, 0);
0135   SiStripFedKey same(valid);
0136   SiStripFedKey equal = valid;
0137   SiStripFedKey equals;
0138   equals = valid;
0139 
0140   std::stringstream ss;
0141 
0142   ss << "[SiStripFedKey::" << __func__ << "]"
0143      << " Tests for utility methods..." << std::endl;
0144 
0145   ss << ">>>> invalid.path: " << invalid << std::endl
0146      << ">>>> inv.path:     " << inv << std::endl
0147      << ">>>> valid.path:   " << valid << std::endl
0148      << ">>>> all.path:     " << all << std::endl
0149      << ">>>> same.path:    " << same << std::endl
0150      << ">>>> equal.path:   " << equal << std::endl
0151      << ">>>> equals.path:  " << equals << std::endl;
0152 
0153   ss << std::hex << ">>>> invalid.key:  " << invalid.key() << std::endl
0154      << ">>>> valid.key:    " << valid.key() << std::endl
0155      << ">>>> all.key:      " << all.key() << std::endl
0156      << std::dec;
0157 
0158   ss << ">>>> invalid.isInvalid: " << invalid.isInvalid() << std::endl
0159      << ">>>> invalid.isValid:   " << invalid.isValid() << std::endl
0160      << ">>>> valid.isInvalid:   " << valid.isInvalid() << std::endl
0161      << ">>>> valid.isValid:     " << valid.isValid() << std::endl
0162      << ">>>> all.isInvalid:     " << all.isInvalid() << std::endl
0163      << ">>>> all.isValid:       " << all.isValid() << std::endl;
0164 
0165   ss << ">>>> valid.isEqual(valid):        " << valid.isEqual(valid) << std::endl
0166      << ">>>> valid.isConsistent(valid):   " << valid.isConsistent(valid) << std::endl
0167      << ">>>> valid.isEqual(invalid):      " << valid.isEqual(invalid) << std::endl
0168      << ">>>> valid.isConsistent(invalid): " << valid.isConsistent(invalid) << std::endl
0169      << ">>>> valid.isEqual(all):          " << valid.isEqual(all) << std::endl
0170      << ">>>> valid.isConsistent(all):     " << valid.isConsistent(all) << std::endl
0171      << ">>>> valid.isEqual(same):         " << valid.isEqual(same) << std::endl
0172      << ">>>> valid.isEqual(equal):        " << valid.isEqual(equal) << std::endl
0173      << ">>>> valid.isEqual(equals):       " << valid.isEqual(equals) << std::endl;
0174 
0175   LogTrace(mlDqmCommon_) << ss.str();
0176 }
0177 
0178 // -----------------------------------------------------------------------------
0179 //
0180 void testSiStripFedKey::analyze(const edm::Event& event, const edm::EventSetup& setup) {
0181   LogTrace(mlDqmCommon_) << "[SiStripFedKey::" << __func__ << "]"
0182                          << " Analyzing run/event " << event.id().run() << "/" << event.id().event();
0183 }
0184 
0185 #include "FWCore/Framework/interface/MakerMacros.h"
0186 DEFINE_FWK_MODULE(testSiStripFedKey);