CMS 3D CMS Logo

SiStripFedCablingFakeESSource.cc
Go to the documentation of this file.
11 #include <sstream>
12 #include <vector>
13 #include <map>
14 
15 using namespace sistrip;
16 
17 // -----------------------------------------------------------------------------
18 //
20  : SiStripFedCablingESProducer(pset), fedIds_(pset.getParameter<edm::FileInPath>("FedIdsFile")), pset_(pset) {
21  findingRecord<SiStripFedCablingRcd>();
22  m_detInfo = SiStripDetInfoFileReader::read(pset.getParameter<edm::FileInPath>("SiStripDetInfoFile").fullPath());
23  edm::LogVerbatim("FedCabling") << "[SiStripFedCablingFakeESSource::" << __func__ << "]"
24  << " Constructing object...";
25 }
26 
27 // -----------------------------------------------------------------------------
28 //
30  edm::LogVerbatim("FedCabling") << "[SiStripFedCablingFakeESSource::" << __func__ << "]"
31  << " Destructing object...";
32 }
33 
34 // -----------------------------------------------------------------------------
35 //
37  edm::LogVerbatim("FedCabling") << "[SiStripFedCablingFakeESSource::" << __func__ << "]"
38  << " Building \"fake\" FED cabling map"
39  << " from real DetIds and FedIds (read from ascii file)";
40 
41  // Create FEC cabling object
42  SiStripFecCabling* fec_cabling = new SiStripFecCabling();
43 
44  // Read DetId list from file
45  typedef std::vector<uint32_t> Dets;
46  Dets dets = m_detInfo.getAllDetIds();
47 
48  // Read FedId list from file
49  typedef std::vector<uint16_t> Feds;
51 
52  bool populateAllFeds = pset_.getParameter<bool>("PopulateAllFeds");
53 
54  // Iterator through DetInfo objects and populate FEC cabling object
55  uint32_t imodule = 0;
56  Dets::const_iterator idet = dets.begin();
57  Dets::const_iterator jdet = dets.end();
58  for (; idet != jdet; ++idet) {
59  uint16_t npairs = m_detInfo.getNumberOfApvsAndStripLength(*idet).first / 2;
60  for (uint16_t ipair = 0; ipair < npairs; ++ipair) {
61  uint16_t addr = 0;
62  if (npairs == 2 && ipair == 0) {
63  addr = 32;
64  } else if (npairs == 2 && ipair == 1) {
65  addr = 36;
66  } else if (npairs == 3 && ipair == 0) {
67  addr = 32;
68  } else if (npairs == 3 && ipair == 1) {
69  addr = 34;
70  } else if (npairs == 3 && ipair == 2) {
71  addr = 36;
72  } else {
73  edm::LogWarning("FedCabling") << "[SiStripFedCablingFakeESSource::" << __func__ << "]"
74  << " Inconsistent values for nPairs (" << npairs << ") and ipair (" << ipair
75  << ")!";
76  }
77  uint32_t module_key =
78  SiStripFecKey(fecCrate(imodule), fecSlot(imodule), fecRing(imodule), ccuAddr(imodule), ccuChan(imodule)).key();
80  fecSlot(imodule),
81  fecRing(imodule),
82  ccuAddr(imodule),
83  ccuChan(imodule),
84  addr,
85  addr + 1, // apv i2c addresses
86  module_key, // dcu id
87  *idet, // det id
88  npairs); // apv pairs
89  fec_cabling->addDevices(conn);
90  }
91  imodule++;
92  }
93 
94  // Assign "dummy" FED ids/chans
95  bool insufficient = false;
96  Feds::const_iterator ifed = feds.begin();
97  uint16_t fed_ch = 0;
98  for (std::vector<SiStripFecCrate>::iterator icrate = fec_cabling->crates().begin();
99  icrate != fec_cabling->crates().end();
100  icrate++) {
101  for (std::vector<SiStripFec>::iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++) {
102  for (std::vector<SiStripRing>::iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++) {
103  for (std::vector<SiStripCcu>::iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++) {
104  for (std::vector<SiStripModule>::iterator imod = iccu->modules().begin(); imod != iccu->modules().end();
105  imod++) {
106  if (populateAllFeds) {
107  for (uint16_t ipair = 0; ipair < imod->nApvPairs(); ipair++) {
108  if (ifed == feds.end()) {
109  fed_ch++;
110  ifed = feds.begin();
111  }
112  if (fed_ch == 96) {
113  insufficient = true;
114  break;
115  }
116 
117  std::pair<uint16_t, uint16_t> addr = imod->activeApvPair(imod->lldChannel(ipair));
118  SiStripModule::FedChannel fed_channel((*ifed) / 16 + 1, // 16 FEDs per crate, numbering starts from 1
119  (*ifed) % 16 + 2, // FED slot starts from 2
120  *ifed,
121  fed_ch);
122  imod->fedCh(addr.first, fed_channel);
123  ifed++;
124  }
125  } else {
126  // Patch introduced by D.Giordano 2/12/08
127  //to reproduce the fake cabling used in 2x
128  //that was designed to fill each fed iteratively
129  //filling all channels of a fed before going to the next one
130  if (96 - fed_ch < imod->nApvPairs()) {
131  ifed++;
132  fed_ch = 0;
133  } // move to next FED
134  for (uint16_t ipair = 0; ipair < imod->nApvPairs(); ipair++) {
135  std::pair<uint16_t, uint16_t> addr = imod->activeApvPair(imod->lldChannel(ipair));
136  SiStripModule::FedChannel fed_channel((*ifed) / 16 + 1, // 16 FEDs per crate, numbering starts from 1
137  (*ifed) % 16 + 2, // FED slot starts from 2
138  (*ifed),
139  fed_ch);
140  imod->fedCh(addr.first, fed_channel);
141  fed_ch++;
142  }
143  }
144  }
145  }
146  }
147  }
148  }
149 
150  if (insufficient) {
151  edm::LogWarning(mlCabling_) << "[SiStripFedCablingFakeESSource::" << __func__ << "]"
152  << " Insufficient FED channels to cable entire system!";
153  }
154 
155  // Some debug
156  std::stringstream ss;
157  ss << "[SiStripFedCablingFakeESSource::" << __func__ << "]"
158  << " First count devices of FEC cabling " << std::endl;
159  fec_cabling->countDevices().print(ss);
160  LogTrace(mlCabling_) << ss.str();
161 
162  // Build FED cabling using FedChannelConnections
163  std::vector<FedChannelConnection> conns;
164  fec_cabling->connections(conns);
165  SiStripFedCabling* cabling = new SiStripFedCabling(conns);
166 
167  return cabling;
168 }
169 
170 // -----------------------------------------------------------------------------
171 //
173  const edm::IOVSyncValue& iov_sync,
174  edm::ValidityInterval& iov_validity) {
175  edm::ValidityInterval infinity(iov_sync.beginOfTime(), iov_sync.endOfTime());
176  iov_validity = infinity;
177 }
Log< level::Info, true > LogVerbatim
static uint16_t ccuAddr(const uint16_t &nth_module)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static uint16_t fecCrate(const uint16_t &nth_module)
std::string fullPath() const
Definition: FileInPath.cc:161
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
void addDevices(const FedChannelConnection &conn)
NumberOfDevices countDevices() const
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
static uint16_t fecSlot(const uint16_t &nth_module)
static uint16_t fecRing(const uint16_t &nth_module)
sistrip classes
#define LogTrace(id)
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
static const char mlCabling_[]
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
Class containning control, module, detector and connection information, at the level of a FED channel...
void print(std::stringstream &) const
const uint32_t & key() const
Definition: SiStripKey.h:120
const double infinity
Abstract base class for producer of SiStripFedCabling record.
void connections(std::vector< FedChannelConnection > &) const
SiStripDetInfo read(std::string filePath)
const std::vector< SiStripFecCrate > & crates() const
SiStripFedCablingFakeESSource(const edm::ParameterSet &)
static uint16_t ccuChan(const uint16_t &nth_module)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
SiStripFedCabling * make(const SiStripFedCablingRcd &) override
HLT enums.
conn
Definition: getInfo.py:9
Log< level::Warning, false > LogWarning
const std::vector< uint32_t > & getAllDetIds() const noexcept
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override