23 findingRecord<SiStripFedCablingRcd>();
26 <<
" Constructing object...";
29 string source =
pset.getUntrackedParameter<
string>(
"CablingSource",
"UNDEFINED");
33 <<
" CablingSource configurable set to \"" <<
source <<
"\"" 42 <<
" Destructing object...";
49 <<
" Constructing FED cabling...";
60 <<
" Pointer to SiStripConfigDb: 0x" << std::setw(8) << std::setfill(
'0') << std::hex
64 <<
" NULL pointer to SiStripConfigDb returned by DB \"service\"!" 65 <<
" Cannot build FED cabling object!";
90 <<
" NULL pointers to DeviceFactory and DatabaseCache returned by SiStripConfigDb!" 91 <<
" Cannot build FED cabling object!";
111 <<
"\" Querying DB in order to build cabling from one of connections, devices or DetIds...";
117 <<
" Cannot build SiStripFecCabling object!" 124 std::stringstream
ss;
125 ss <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 126 <<
" Built SiStripFecCabling object with following devices:" << endl
135 <<
" Building cabling object...";
137 if (!
db->getFedConnections().empty()) {
139 }
else if (!
db->getDeviceDescriptions().empty()) {
141 }
else if (!
db->getDcuDetIds().empty()) {
145 <<
" Cannot build SiStripFecCabling object!" 146 <<
" FedConnections, DeviceDescriptions and DcuDetIds vectors are all empty!";
152 std::stringstream
ss;
153 ss <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 154 <<
" Built SiStripFecCabling object with following devices:" << std::endl
198 <<
" Building FEC cabling from FED connections descriptions...";
209 <<
" Unable to build FEC cabling!" 210 <<
" No entries in FedConnections vector!";
217 <<
" Retrieving DCU-DetId vector from database...";
220 if (!dcu_detid_vector.empty()) {
222 <<
" Found " << dcu_detid_vector.size()
223 <<
" entries in DCU-DetId vector retrieved from database!";
226 <<
" No entries in DCU-DetId vector retrieved from database!";
231 SiStripConfigDb::FedConnectionsV::const_iterator ifed = conns.begin();
232 SiStripConfigDb::FedConnectionsV::const_iterator jfed = conns.end();
233 for (; ifed != jfed; ++ifed) {
236 <<
" NULL pointer to FedConnection!";
243 uint16_t fec_slot =
static_cast<uint16_t
>((*ifed)->getFecSlot());
246 uint16_t ccu_addr =
static_cast<uint16_t
>((*ifed)->getCcuAddress());
247 uint16_t ccu_chan =
static_cast<uint16_t
>((*ifed)->getI2cChannel());
248 uint16_t apv0 =
static_cast<uint16_t
>((*ifed)->getApvAddress());
249 uint16_t apv1 = apv0 + 1;
250 uint32_t dcu_id =
static_cast<uint32_t
>((*ifed)->getDcuHardId());
253 uint16_t fed_id =
static_cast<uint16_t
>((*ifed)->getFedId());
254 uint16_t fed_ch =
static_cast<uint16_t
>((*ifed)->getFedChannel());
258 fec_crate, fec_slot, fec_ring, ccu_addr, ccu_chan, apv0, apv1, dcu_id, det_id, npairs, fed_id, fed_ch, length);
262 fed_crate =
static_cast<uint16_t
>((*ifed)->getFedCrateId());
263 fed_slot =
static_cast<uint16_t
>((*ifed)->getFedSlot());
264 conn.fedCrate(fed_crate);
265 conn.fedSlot(fed_slot);
321 <<
" Building FEC cabling object from device descriptions...";
330 <<
" Retrieving APV descriptions from database...";
332 if (!apv_desc.empty()) {
334 <<
" Retrieved " << apv_desc.size() <<
" APV descriptions from database!";
337 <<
" Unable to build FEC cabling!" 338 <<
" No APV descriptions found!";
345 <<
" Retrieving DCU descriptions from database...";
348 if (!dcu_desc.empty()) {
351 SiStripConfigDb::DeviceDescriptionsV::const_iterator idcu;
352 for (idcu = dcu_desc.begin(); idcu != dcu_desc.end(); idcu++) {
353 dcuDescription* dcu =
dynamic_cast<dcuDescription*
>(*idcu);
357 if (dcu->getDcuType() ==
"FEH") {
365 <<
" Retrieved " << feh <<
" DCU-FEH descriptions from database!" 366 <<
" (and a further " << ccu <<
" DCUs for CCU modules, etc...)";
370 <<
" No DCU descriptions found!";
376 <<
" Retrieving DCU-DetId vector from database...";
379 if (!dcu_detid_vector.empty()) {
381 <<
" Found " << dcu_detid_vector.size()
382 <<
" entries in DCU-DetId vector retrieved from database!";
385 <<
" No entries in DCU-DetId vector retrieved from database!";
391 <<
" Retrieving FED ids from database...";
394 if (!fed_ids.empty()) {
396 <<
" Retrieved " << fed_ids.size() <<
" FED ids from database!";
399 <<
" No FED ids found!";
405 <<
" Building FEC cabling object from APV and DCU descriptions...";
407 SiStripConfigDb::DeviceDescriptionsV::const_iterator iapv;
408 for (iapv = apv_desc.begin(); iapv != apv_desc.end(); iapv++) {
411 <<
" NULL pointer to DeviceDescription (of type APV25)!";
425 SiStripConfigDb::DeviceDescriptionsV::const_iterator idcu;
426 for (idcu = dcu_desc.begin(); idcu != dcu_desc.end(); idcu++) {
429 <<
" NULL pointer to DeviceDescription (of type DCU)!";
434 dcuDescription* dcu =
dynamic_cast<dcuDescription*
>(*idcu);
438 if (dcu->getDcuType() !=
"FEH") {
448 dcu->getDcuHardId());
453 <<
" Finished building FEC cabling object from APV and DCU descriptions!";
456 std::stringstream ss1;
457 ss1 <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 458 <<
" Number of devices in FEC cabling object:" << std::endl;
464 std::vector<uint16_t>::const_iterator ifed = fed_ids.begin();
469 std::vector<uint32_t> used_keys;
472 <<
" Randomly assigning FED ids/channels to APV pairs in front-end modules...";
474 if (fed_ids.empty()) {
476 <<
" No FED ids retrieved from database! Unable to cable system!";
478 bool complete =
false;
479 std::vector<SiStripFecCrate>::const_iterator icrate = fec_cabling.
crates().begin();
480 std::vector<SiStripFecCrate>::const_iterator jcrate = fec_cabling.
crates().end();
481 while (!complete && icrate != jcrate) {
482 std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin();
483 std::vector<SiStripFec>::const_iterator jfec = icrate->fecs().end();
484 while (!complete && ifec != jfec) {
485 std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin();
486 std::vector<SiStripRing>::const_iterator jring = ifec->rings().end();
487 while (!complete && iring != jring) {
488 std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin();
489 std::vector<SiStripCcu>::const_iterator jccu = iring->ccus().end();
490 while (!complete && iccu != jccu) {
491 std::vector<SiStripModule>::const_iterator imod = iccu->modules().begin();
492 std::vector<SiStripModule>::const_iterator jmod = iccu->modules().end();
493 while (!complete && imod != jmod) {
498 SiStripFecKey(imod->fecCrate(), imod->fecSlot(), imod->fecRing(), imod->ccuAddr(), imod->ccuChan())
516 for (uint16_t ipair = 0; ipair < imod->nApvPairs(); ipair++) {
518 if (ifed == fed_ids.end()) {
520 ifed = fed_ids.begin();
524 <<
" Insufficient FED channels to cable all devices in control system!";
530 pair<uint16_t, uint16_t>
addr = imod->activeApvPair(imod->lldChannel(ipair));
551 std::sort(used_keys.begin(), used_keys.end());
554 std::stringstream ss2;
555 ss2 <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 556 <<
" Number of devices in FEC cabling object:" << std::endl;
561 <<
" Finished randomly assigning FED ids/channels to APV pairs in front-end modules...";
566 <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 567 <<
" Assigning APV pairs in dummy front-end modules to any remaining \"uncabled\" FED ids/channels...";
569 if (fed_ids.empty()) {
571 <<
" No FED ids retrieved from database! Unable to cable system!";
574 bool complete =
false;
578 if (ifed == fed_ids.end()) {
580 ifed = fed_ids.begin();
584 <<
" All FED channels are now cabled!";
610 uint16_t fed_crate = (*ifed) / 16 + 1;
611 uint16_t fed_slot = (*ifed) % 16 + 2;
612 temp.fedCrate(fed_crate);
613 temp.fedSlot(fed_slot);
622 <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 623 <<
" Finished assigning APV pairs in dummy front-end modules to any remaining \"uncabled\" FED ids/channels...";
626 std::stringstream ss3;
627 ss3 <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 628 <<
" Number of devices in FEC cabling object:" << std::endl;
678 <<
" Building FEC cabling object from DetIds...";
685 uint32_t chans_per_ccu = 10;
686 uint32_t ccus_per_ring = 10;
687 uint32_t rings_per_fec = 8;
688 uint32_t fecs_per_crate = 11;
693 <<
" Retrieving DCU-DetId vector from database...";
696 if (!dcu_detid_vector.empty()) {
698 <<
" Found " << dcu_detid_vector.size()
699 <<
" entries in DCU-DetId vector retrieved from database!";
702 <<
" No entries in DCU-DetId vector retrieved from database!" 703 <<
" Unable to build FEC cabling!";
709 uint32_t imodule = 0;
710 SiStripConfigDb::DcuDetIdsV::const_iterator iter;
711 for (iter = dcu_detid_vector.begin(); iter != dcu_detid_vector.end(); iter++) {
712 if (!(iter->second)) {
714 <<
" NULL pointer to TkDcuInfo!";
718 uint16_t fec_crate = (imodule / (chans_per_ccu * ccus_per_ring * rings_per_fec * fecs_per_crate)) + 1;
719 uint16_t fec_slot = (imodule / (chans_per_ccu * ccus_per_ring * rings_per_fec)) % fecs_per_crate + 2;
720 uint16_t fec_ring = (imodule / (chans_per_ccu * ccus_per_ring)) % rings_per_fec + 1;
721 uint16_t ccu_addr = (imodule / (chans_per_ccu)) % ccus_per_ring + 1;
722 uint16_t ccu_chan = (imodule) % chans_per_ccu + 16;
724 uint32_t dcu_id = iter->second->getDcuHardId();
725 uint32_t det_id = iter->second->getDetId();
726 uint16_t npairs = iter->second->getApvNumber() / 2;
727 uint16_t length = (uint16_t)iter->second->getFibreLength();
732 dcu_id =
SiStripFecKey(fec_crate, fec_slot, fec_ring, ccu_addr, ccu_chan).
key();
735 det_id = 0xFFFF + imodule;
738 npairs = rand() / 2 ? 2 : 3;
743 for (uint16_t ipair = 0; ipair < npairs; ipair++) {
744 uint16_t iapv = (ipair == 1 && npairs == 2 ? 36 : 32 + 2 * ipair);
770 uint32_t fed_id = 50;
772 for (vector<SiStripFecCrate>::const_iterator icrate = fec_cabling.
crates().begin();
773 icrate != fec_cabling.
crates().end();
775 for (vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++) {
776 for (vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++) {
777 for (vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++) {
778 for (vector<SiStripModule>::const_iterator imod = iccu->modules().begin(); imod != iccu->modules().end();
780 if (96 - fed_ch < imod->nApvPairs()) {
784 for (uint16_t ipair = 0; ipair < imod->nApvPairs(); ipair++) {
785 pair<uint16_t, uint16_t>
addr = imod->activeApvPair((*imod).lldChannel(ipair));
787 (fed_id - 50) / 16 + 1,
788 (fed_id - 50) % 16 + 2,
804 const std::vector<std::pair<uint32_t, TkDcuInfo*> >& _in) {
805 std::vector<std::pair<uint32_t, TkDcuInfo*> >
in = _in;
810 <<
" No entries in DCU-DetId vector!";
816 <<
" Assigning DCU ids and DetIds to constructed modules...";
824 for (vector<SiStripFecCrate>::const_iterator icrate = fec_cabling.
crates().begin();
825 icrate != fec_cabling.
crates().end();
827 for (vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++) {
828 for (vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++) {
829 for (vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++) {
830 for (vector<SiStripModule>::const_iterator imod = iccu->modules().begin(); imod != iccu->modules().end();
841 icrate->fecCrate(), ifec->fecSlot(), iring->fecRing(), iccu->ccuAddr(), imod->ccuChan());
842 uint32_t module_key =
path.key();
845 ss <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 846 <<
" Found NULL DcuId! Setting 'dummy' value based control key 0x" << hex << setw(8) << setfill(
'0')
847 << module_key <<
dec;
856 SiStripConfigDb::DcuDetIdsV::iterator iter =
in.end();
858 if (iter !=
in.end()) {
859 if (!(iter->second)) {
861 <<
" NULL pointer to TkDcuInfo!";
867 module.detId(iter->second->getDetId());
871 uint16_t pairs = iter->second->getApvNumber() / 2;
875 }
else if (pairs == 3) {
883 if (
module.nApvPairs() != 2 &&
module.nApvPairs() != 3) {
884 missing += (iter->second->getApvNumber() / 2 -
module.nApvPairs());
886 ss1 <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" << std::endl
887 <<
" Module with DCU id 0x" << hex << setw(8) << setfill(
'0') <<
module.dcuId() <<
dec 888 <<
" and DetId 0x" << hex << setw(8) << setfill(
'0') <<
module.detId() <<
dec 889 <<
" has unexpected number of APV pairs (" <<
module.nApvPairs() <<
")." << std::endl
890 <<
" Some APV pairs may have not been detected by the FEC scan." << std::endl
891 <<
" Setting to value found in static map (" << iter->second->getApvNumber() / 2 <<
")...";
893 module.nApvPairs(iter->second->getApvNumber() / 2);
895 }
else if (
module.nApvPairs() < iter->second->getApvNumber() / 2) {
896 missing += (iter->second->getApvNumber() / 2 -
module.nApvPairs());
898 ss2 <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" << std::endl
899 <<
" Module with DCU id 0x" << hex << setw(8) << setfill(
'0') <<
module.dcuId() <<
dec 900 <<
" and DetId 0x" << hex << setw(8) << setfill(
'0') <<
module.detId() <<
dec 901 <<
" has number of APV pairs (" <<
module.nApvPairs()
902 <<
") that does not match value found in DCU-DetId vector (" << iter->second->getApvNumber() / 2
904 <<
" Some APV pairs may have not been detected by" 905 <<
" the FEC scan or the DCU-DetId vector may be incorrect." << std::endl
906 <<
" Setting to value found in static map (" << iter->second->getApvNumber() / 2 <<
")...";
908 module.nApvPairs(iter->second->getApvNumber() / 2);
914 module.length(static_cast<uint16_t>(iter->second->getFibreLength()));
930 std::stringstream sss;
931 sss <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" << std::endl
932 <<
" Connections in DCU-DetId map : " <<
channels << std::endl
933 <<
" 4-APV modules : " << four << std::endl
934 <<
" 6-APV modules : " << six << std::endl
935 <<
" Unknown number of APV pairs : " <<
unknown << std::endl
937 <<
" Total missing APV pairs : " <<
missing << std::endl;
941 <<
" Finished assigning DCU ids and DetIds to constructed modules...";
946 <<
" Assigning \"random\" DetIds to modules with DCU ids not found in static table...";
948 uint32_t
detid = 0x10000;
949 for (vector<SiStripFecCrate>::const_iterator icrate = fec_cabling.
crates().begin();
950 icrate != fec_cabling.
crates().end();
952 for (vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++) {
953 for (vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++) {
954 for (vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++) {
955 for (vector<SiStripModule>::const_iterator imod = iccu->modules().begin(); imod != iccu->modules().end();
962 SiStripConfigDb::DcuDetIdsV::iterator iter =
in.end();
964 if (iter !=
in.end()) {
967 SiStripConfigDb::DcuDetIdsV::iterator idcu;
972 while (idcu !=
in.end()) {
974 if (static_cast<uint32_t>(idcu->second->getApvNumber()) ==
975 static_cast<uint32_t>(2 *
module.nApvPairs())) {
985 if (idcu !=
in.end()) {
986 if (!(idcu->second)) {
988 <<
" NULL pointer to TkDcuInfo!";
992 module.detId(idcu->second->getDetId());
996 ss <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 997 <<
" Did not find module with DCU id 0x" << hex << setw(8) << setfill(
'0') <<
module.dcuId() <<
dec 998 <<
" in DCU-DetId vector!" << endl
999 <<
" Assigned 'random' DetId 0x" << hex << setw(8) << setfill(
'0') <<
module.detId() <<
dec;
1010 ss <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 1011 <<
" Did not find module with DCU id 0x" << hex << setw(8) << setfill(
'0') <<
module.dcuId()
1012 <<
dec <<
" in DCU-DetId vector!" 1013 <<
" Could not assign 'random' DetId as DCU-DetID map is empty!" 1014 <<
" Assigned DetId based on incremented counter, with value 0x" << hex << setw(8)
1015 << setfill(
'0') <<
module.detId() <<
dec;
1017 ss <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 1018 <<
" Did not find module with DCU id 0x" << hex << setw(8) << setfill(
'0') <<
module.dcuId()
1019 <<
dec <<
" in DCU-DetId vector!" 1020 <<
" Could not assign 'random' DetId as no modules had appropriate number of APV pairs (" 1021 <<
module.nApvPairs() <<
"). Assigned DetId based on incremented counter, with value 0x" << hex
1022 << setw(8) << setfill(
'0') <<
module.detId() <<
dec;
1036 <<
" Finished assigning \"random\" DetIds to modules with DCU ids not found in static table...";
1039 <<
" Assigning \"random\" DetIds to modules with DCU ids not found in static table...";
1045 ss <<
"[SiStripFedCablingBuilderFromDb::" << __func__ <<
"]" 1046 <<
" Not all DetIds have been assigned to a DcuId! " <<
in.size() <<
" DetIds are unassigned!";
1055 vector<FedChannelConnection> conns;
Log< level::Info, true > LogVerbatim
Device and connection information at the level of a front-end module.
static uint16_t ccuAddr(const uint16_t &nth_module)
static uint16_t fecCrate(const uint16_t &nth_module)
DcuDetIds::range DcuDetIdsRange
static void buildFecCablingFromDetIds(SiStripConfigDb *const, SiStripFecCabling &)
static const uint32_t invalid32_
static const uint16_t LLD_CHAN_MIN
DbClient *const databaseCache(std::string method_name="") const
static const uint16_t LLD_CHAN_MAX
void addDevices(const FedChannelConnection &conn)
static const uint16_t FEC_RING_OFFSET
static void assignDcuAndDetIds(SiStripFecCabling &, const std::vector< std::pair< uint32_t, TkDcuInfo *> > &)
NumberOfDevices countDevices() const
static const IOVSyncValue & endOfTime()
~SiStripFedCablingBuilderFromDb() override
SiStripFedCablingBuilderFromDb(const edm::ParameterSet &)
const uint16_t & nApvPairs() const
static uint16_t fecSlot(const uint16_t &nth_module)
static uint16_t fecRing(const uint16_t &nth_module)
Log< level::Error, false > LogError
FedConnections::range FedConnectionsRange
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
static void getFecCabling(const SiStripFedCabling &in, SiStripFecCabling &out)
static const char mlCabling_[]
static DcuDetIdsV::const_iterator findDcuDetId(DcuDetIdsV::const_iterator begin, DcuDetIdsV::const_iterator end, uint32_t dcu_id)
const uint16_t & i2cAddr() const
static const IOVSyncValue & beginOfTime()
static void buildFecCabling(SiStripConfigDb *const, SiStripFecCabling &, const sistrip::CablingSource &)
Class containning control, module, detector and connection information, at the level of a FED channel...
DeviceDescriptions::range DeviceDescriptionsRange
void print(std::stringstream &) const
void dcuId(const FedChannelConnection &conn)
An interface class to the DeviceFactory.
const uint32_t & key() const
FedChannel fedCh(const uint16_t &apv_pair_num) const
virtual void writeFedCablingToCondDb(const SiStripFedCabling &)
key
prepare the HTCondor submission files and eventually submit them
Abstract base class for producer of SiStripFedCabling record.
void connections(std::vector< FedChannelConnection > &) const
const std::vector< SiStripFecCrate > & crates() const
void buildFecCabling(const SiStripFedCabling &)
void buildFedCabling(ConnsConstIterRange connections)
Simple container class for counting devices.
static uint16_t ccuChan(const uint16_t &nth_module)
static void getFedCabling(const SiStripFecCabling &in, SiStripFedCabling &out)
std::vector< DcuDetId > DcuDetIdsV
static const uint16_t invalid_
sistrip::CablingSource source_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
boost::iterator_range< FedIds::const_iterator > FedIdsRange
static std::string cablingSource(const sistrip::CablingSource &)
static const uint16_t FEC_CRATE_OFFSET
static void buildFecCablingFromFedConnections(SiStripConfigDb *const, SiStripFecCabling &)
Log< level::Warning, false > LogWarning
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
static std::string const source
DeviceFactory *const deviceFactory(std::string method_name="") const
static void buildFecCablingFromDevices(SiStripConfigDb *const, SiStripFecCabling &)
SiStripFedCabling * make(const SiStripFedCablingRcd &) override