Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:14

0001 // system includes
0002 #include <vector>
0003 #include <cstdint>
0004 #include <iostream>
0005 #include <iomanip>
0006 #include <sstream>
0007 #include <string>
0008 #include <time.h>
0009 #include <algorithm>
0010 
0011 // user includes
0012 #include "DataFormats/SiStripCommon/interface/Constants.h"
0013 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
0014 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
0015 #include "DataFormats/SiStripCommon/interface/SiStripKey.h"
0016 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 
0021 /**
0022    @class perfSiStripFecKey 
0023    @author R.Bainbridge
0024    @brief Simple class that tests SiStripFecKey.
0025 */
0026 class perfSiStripFecKey : public edm::one::EDAnalyzer<> {
0027 public:
0028   perfSiStripFecKey(const edm::ParameterSet&);
0029   ~perfSiStripFecKey();
0030 
0031   void beginJob();
0032   void analyze(const edm::Event&, const edm::EventSetup&);
0033 
0034 private:
0035   class Value {
0036   public:
0037     uint16_t crate_, slot_, ring_, ccu_, module_, lld_, i2c_;
0038     Value() : crate_(0), slot_(0), ring_(0), ccu_(0), module_(0), lld_(0), i2c_(0) { ; }
0039     Value(uint16_t crate, uint16_t slot, uint16_t ring, uint16_t ccu, uint16_t module, uint16_t lld, uint16_t i2c)
0040         : crate_(crate), slot_(slot), ring_(ring), ccu_(ccu), module_(module), lld_(lld), i2c_(i2c) {
0041       ;
0042     }
0043   };
0044 
0045   void build(std::vector<Value>&,
0046              std::vector<uint32_t>&,
0047              std::vector<std::string>&,
0048              std::vector<SiStripFecKey>&,
0049              std::vector<SiStripKey>&);
0050 
0051   void build(const std::vector<Value>&) const;
0052   void build(const std::vector<uint32_t>&) const;
0053   void build(const std::vector<std::string>&) const;
0054   void build(const std::vector<SiStripFecKey>&) const;
0055   void build(const std::vector<SiStripKey>&) const;
0056 
0057   void test(const std::vector<SiStripFecKey>&) const;
0058 
0059   uint32_t loops_;
0060 };
0061 
0062 using namespace sistrip;
0063 
0064 // -----------------------------------------------------------------------------
0065 //
0066 perfSiStripFecKey::perfSiStripFecKey(const edm::ParameterSet& pset)
0067     : loops_(pset.getUntrackedParameter<uint32_t>("Loops", 1)) {
0068   LogTrace(mlDqmCommon_) << "[perfSiStripFecKey::" << __func__ << "]"
0069                          << " Constructing object...";
0070 }
0071 
0072 // -----------------------------------------------------------------------------
0073 //
0074 perfSiStripFecKey::~perfSiStripFecKey() {
0075   LogTrace(mlDqmCommon_) << "[perfSiStripFecKey::" << __func__ << "]"
0076                          << " Destructing object...";
0077 }
0078 
0079 // -----------------------------------------------------------------------------
0080 //
0081 void perfSiStripFecKey::beginJob() {
0082   edm::LogInfo(mlDqmCommon_) << "[SiStripFecKey::" << __func__ << "]"
0083                              << " Tests the generation of keys...";
0084 
0085   std::vector<Value> values;
0086   std::vector<uint32_t> keys;
0087   std::vector<std::string> paths;
0088   std::vector<SiStripFecKey> derived;
0089   std::vector<SiStripKey> base;
0090 
0091   build(values, keys, paths, derived, base);
0092 
0093   build(values);
0094   build(keys);
0095   build(paths);
0096   build(derived);
0097   build(base);
0098 
0099   test(derived);
0100 }
0101 
0102 // -----------------------------------------------------------------------------
0103 //
0104 void perfSiStripFecKey::analyze(const edm::Event& event, const edm::EventSetup& setup) {
0105   LogTrace(mlDqmCommon_) << "[SiStripFecKey::" << __func__ << "]"
0106                          << " Analyzing run/event " << event.id().run() << "/" << event.id().event();
0107 }
0108 
0109 // -----------------------------------------------------------------------------
0110 //
0111 void perfSiStripFecKey::build(const std::vector<Value>& input) const {
0112   std::vector<Value>::const_iterator iter = input.begin();
0113   std::vector<Value>::const_iterator jter = input.end();
0114   for (; iter != jter; ++iter) {
0115     SiStripFecKey(iter->crate_, iter->slot_, iter->ring_, iter->ccu_, iter->module_, iter->lld_, iter->i2c_);
0116   }
0117 }
0118 
0119 // -----------------------------------------------------------------------------
0120 //
0121 void perfSiStripFecKey::build(const std::vector<uint32_t>& input) const {
0122   std::vector<uint32_t>::const_iterator iter = input.begin();
0123   std::vector<uint32_t>::const_iterator jter = input.end();
0124   for (; iter != jter; ++iter) {
0125     SiStripFecKey key(*iter);
0126   }
0127 }
0128 
0129 // -----------------------------------------------------------------------------
0130 //
0131 void perfSiStripFecKey::build(const std::vector<std::string>& input) const {
0132   std::vector<std::string>::const_iterator iter = input.begin();
0133   std::vector<std::string>::const_iterator jter = input.end();
0134   for (; iter != jter; ++iter) {
0135     SiStripFecKey key(*iter);
0136   }
0137 }
0138 
0139 // -----------------------------------------------------------------------------
0140 //
0141 void perfSiStripFecKey::build(const std::vector<SiStripFecKey>& input) const {
0142   std::vector<SiStripFecKey>::const_iterator iter = input.begin();
0143   std::vector<SiStripFecKey>::const_iterator jter = input.end();
0144   for (; iter != jter; ++iter) {
0145     SiStripFecKey key(*iter);
0146   }
0147 }
0148 
0149 // -----------------------------------------------------------------------------
0150 //
0151 void perfSiStripFecKey::build(const std::vector<SiStripKey>& input) const {
0152   std::vector<SiStripKey>::const_iterator iter = input.begin();
0153   std::vector<SiStripKey>::const_iterator jter = input.end();
0154   for (; iter != jter; ++iter) {
0155     SiStripFecKey key(*iter);
0156   }
0157 }
0158 
0159 // -----------------------------------------------------------------------------
0160 //
0161 void perfSiStripFecKey::test(const std::vector<SiStripFecKey>& input) const {
0162   std::vector<SiStripFecKey>::const_iterator iter = input.begin();
0163   std::vector<SiStripFecKey>::const_iterator jter = input.end();
0164   for (; iter != jter; ++iter) {
0165     iter->fecCrate();
0166     iter->fecSlot();
0167     iter->fecRing();
0168     iter->ccuAddr();
0169     iter->ccuChan();
0170     iter->lldChan();
0171     iter->i2cAddr();
0172   }
0173 }
0174 
0175 // -----------------------------------------------------------------------------
0176 //
0177 void perfSiStripFecKey::build(std::vector<Value>& values,
0178                               std::vector<uint32_t>& keys,
0179                               std::vector<std::string>& paths,
0180                               std::vector<SiStripFecKey>& derived,
0181                               std::vector<SiStripKey>& base) {
0182   values.clear();
0183   keys.clear();
0184   paths.clear();
0185   derived.clear();
0186   base.clear();
0187 
0188   for (uint16_t iloop = 0; iloop <= loops_; ++iloop) {
0189     if (!(iloop % 10)) {
0190       LogTrace("TEST") << "Nloop: " << iloop;
0191     }
0192 
0193     for (uint16_t icrate = 0; icrate <= sistrip::FEC_CRATE_MAX + 1; ++icrate) {
0194       if (icrate > 1 && icrate < sistrip::FEC_CRATE_MAX) {
0195         continue;
0196       }
0197 
0198       for (uint16_t ifec = 0; ifec <= sistrip::SLOTS_PER_CRATE + 1; ++ifec) {
0199         if (ifec > 1 && ifec < sistrip::SLOTS_PER_CRATE) {
0200           continue;
0201         }
0202 
0203         for (uint16_t iring = 0; iring <= sistrip::FEC_RING_MAX + 1; ++iring) {
0204           if (iring > 1 && iring < sistrip::FEC_RING_MAX) {
0205             continue;
0206           }
0207 
0208           for (uint16_t iccu = 0; iccu <= sistrip::CCU_ADDR_MAX + 1; ++iccu) {
0209             if (iccu > 1 && iccu < sistrip::CCU_ADDR_MAX) {
0210               continue;
0211             }
0212 
0213             for (uint16_t ichan = 0; ichan <= sistrip::CCU_CHAN_MAX + 1; ++ichan) {
0214               if (ichan > 1 && ichan != sistrip::CCU_CHAN_MIN && ichan < sistrip::CCU_CHAN_MAX - 1) {
0215                 continue;
0216               }
0217 
0218               for (uint16_t illd = 0; illd <= sistrip::LLD_CHAN_MAX + 1; ++illd) {
0219                 if (illd > 1 && illd < sistrip::LLD_CHAN_MAX) {
0220                   continue;
0221                 }
0222 
0223                 for (uint16_t iapv = 0; iapv <= sistrip::APV_I2C_MAX + 1; ++iapv) {
0224                   if (iapv > 1 && iapv != sistrip::APV_I2C_MIN && iapv < sistrip::APV_I2C_MAX) {
0225                     continue;
0226                   }
0227 
0228                   SiStripFecKey key(icrate, ifec, iring, iccu, ichan, illd, iapv);
0229                   values.push_back(Value(key.fecCrate(),
0230                                          key.fecSlot(),
0231                                          key.fecRing(),
0232                                          key.ccuAddr(),
0233                                          key.ccuChan(),
0234                                          key.lldChan(),
0235                                          key.i2cAddr()));
0236                   keys.push_back(key.key());
0237                   paths.push_back(key.path());
0238                   derived.push_back(key);
0239                   base.push_back(SiStripKey(key.key()));
0240                 }
0241               }
0242             }
0243           }
0244         }
0245       }
0246     }
0247   }
0248 
0249   //   std::sort( values.begin(), values.end() );
0250   //   std::sort( keys.begin(), keys.end() );
0251   //   std::sort( path.begin(), path.end() );
0252   //   std::sort( derived.begin(), derived.end() );
0253   //   std::sort( base.begin(), base.end() );
0254 }
0255 
0256 #include "FWCore/Framework/interface/MakerMacros.h"
0257 DEFINE_FWK_MODULE(perfSiStripFecKey);