Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:42

0001 #include "L1Trigger/TrackerDTC/interface/LayerEncoding.h"
0002 #include "L1Trigger/TrackTrigger/interface/SensorModule.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 
0005 #include <vector>
0006 #include <set>
0007 #include <algorithm>
0008 #include <iterator>
0009 
0010 using namespace std;
0011 using namespace edm;
0012 using namespace tt;
0013 
0014 namespace trackerDTC {
0015 
0016   LayerEncoding::LayerEncoding(const ParameterSet& iConfig, const Setup* setup)
0017       : setup_(setup), numDTCsPerRegion_(setup->numDTCsPerRegion()) {
0018     encodingsLayerId_.reserve(numDTCsPerRegion_);
0019     for (int dtcInRegion = 0; dtcInRegion < setup->numDTCsPerRegion(); dtcInRegion++) {
0020       set<int> encodingLayerId;
0021       for (int region = 0; region < setup->numRegions(); region++) {
0022         const int dtcId = dtcInRegion + region * setup->numDTCsPerRegion();
0023         const vector<SensorModule*>& modules = setup->dtcModules(dtcId);
0024         for (SensorModule* sm : modules)
0025           encodingLayerId.insert(sm->layerId());
0026       }
0027       // check configuration
0028       if ((int)encodingLayerId.size() > setup->hybridNumLayers()) {
0029         cms::Exception exception("overflow");
0030         exception << "Cabling map connects more than " << setup->hybridNumLayers() << " layers to a DTC.";
0031         exception.addContext("trackerDTC::LayerEncoding::LayerEncoding");
0032         throw exception;
0033       }
0034       encodingsLayerId_.emplace_back(encodingLayerId.begin(), encodingLayerId.end());
0035     }
0036   }
0037 
0038   // decode layer id for given sensor module
0039   int LayerEncoding::decode(SensorModule* sm) const {
0040     const vector<int>& encoding = encodingsLayerId_.at(sm->dtcId() % setup_->numDTCsPerRegion());
0041     const auto pos = find(encoding.begin(), encoding.end(), sm->layerId());
0042     return distance(encoding.begin(), pos);
0043   }
0044 
0045 }  // namespace trackerDTC