CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
SiStripFedCablingBuilderFromDb Class Reference

#include <SiStripFedCablingBuilderFromDb.h>

Inheritance diagram for SiStripFedCablingBuilderFromDb:
SiStripFedCablingESProducer edm::EventSetupRecordIntervalFinder edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

Public Member Functions

virtual SiStripFedCablingmake (const SiStripFedCablingRcd &)
 
 SiStripFedCablingBuilderFromDb (const edm::ParameterSet &)
 
virtual ~SiStripFedCablingBuilderFromDb ()
 
- Public Member Functions inherited from SiStripFedCablingESProducer
virtual std::auto_ptr
< SiStripFedCabling
produce (const SiStripFedCablingRcd &)
 
 SiStripFedCablingESProducer (const edm::ParameterSet &)
 
virtual ~SiStripFedCablingESProducer ()
 
- Public Member Functions inherited from edm::ESProducer
 ESProducer ()
 
virtual ~ESProducer ()
 
- Public Member Functions inherited from edm::ESProxyFactoryProducer
 ESProxyFactoryProducer ()
 
virtual void newInterval (const eventsetup::EventSetupRecordKey &iRecordType, const ValidityInterval &iInterval)
 overrides DataProxyProvider method More...
 
virtual ~ESProxyFactoryProducer ()
 
- Public Member Functions inherited from edm::eventsetup::DataProxyProvider
 DataProxyProvider ()
 
const ComponentDescriptiondescription () const
 
bool isUsingRecord (const EventSetupRecordKey &) const
 
const KeyedProxieskeyedProxies (const EventSetupRecordKey &iRecordKey) const
 
void resetProxies (const EventSetupRecordKey &iRecordType)
 
void resetProxiesIfTransient (const EventSetupRecordKey &iRecordType)
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~DataProxyProvider ()
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const
eventsetup::ComponentDescription
descriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set
< eventsetup::EventSetupRecordKey
findingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder ()
 

Static Public Member Functions

static void buildFecCabling (SiStripConfigDb *const, SiStripFecCabling &, const sistrip::CablingSource &)
 
static void buildFecCabling (SiStripConfigDb *const, SiStripFecCabling &)
 
static void buildFecCablingFromDetIds (SiStripConfigDb *const, SiStripFecCabling &)
 
static void buildFecCablingFromDevices (SiStripConfigDb *const, SiStripFecCabling &)
 
static void buildFecCablingFromFedConnections (SiStripConfigDb *const, SiStripFecCabling &)
 
static void getFecCabling (const SiStripFedCabling &in, SiStripFecCabling &out)
 
static void getFedCabling (const SiStripFecCabling &in, SiStripFedCabling &out)
 
- Static Public Member Functions inherited from SiStripFedCablingESProducer
static uint16_t ccuAddr (const uint16_t &nth_module)
 
static uint16_t ccuChan (const uint16_t &nth_module)
 
static uint16_t fecCrate (const uint16_t &nth_module)
 
static uint16_t fecRing (const uint16_t &nth_module)
 
static uint16_t fecSlot (const uint16_t &nth_module)
 
- Static Public Member Functions inherited from edm::eventsetup::DataProxyProvider
static void prevalidate (ConfigurationDescriptions &)
 

Protected Member Functions

virtual void setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
 
virtual void writeFedCablingToCondDb (const SiStripFedCabling &)
 
- Protected Member Functions inherited from edm::ESProducer
template<typename T >
void setWhatProduced (T *iThis, const es::Label &iLabel=es::Label())
 
template<typename T >
void setWhatProduced (T *iThis, const char *iLabel)
 
template<typename T >
void setWhatProduced (T *iThis, const std::string &iLabel)
 
template<typename T , typename TDecorator >
void setWhatProduced (T *iThis, const TDecorator &iDec, const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const es::Label &iLabel=es::Label())
 
template<typename T , typename TReturn , typename TRecord , typename TArg >
void setWhatProduced (T *iThis, TReturn(T::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel=es::Label())
 
- Protected Member Functions inherited from edm::ESProxyFactoryProducer
template<class TFactory >
void registerFactory (std::auto_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
 
virtual void registerFactoryWithKey (const eventsetup::EventSetupRecordKey &iRecord, std::auto_ptr< eventsetup::ProxyFactoryBase > &iFactory, const std::string &iLabel=std::string())
 
virtual void registerProxies (const eventsetup::EventSetupRecordKey &iRecord, KeyedProxies &aProxyList)
 override DataProxyProvider method More...
 
- Protected Member Functions inherited from edm::eventsetup::DataProxyProvider
void eraseAll (const EventSetupRecordKey &iRecordKey)
 deletes all the Proxies in aStream More...
 
void invalidateProxies (const EventSetupRecordKey &iRecordKey)
 
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &)
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Static Protected Member Functions

static void assignDcuAndDetIds (SiStripFecCabling &, const std::vector< std::pair< uint32_t, TkDcuInfo * > > &)
 

Protected Attributes

SiStripConfigDbdb_
 
sistrip::CablingSource source_
 

Additional Inherited Members

- Public Types inherited from edm::eventsetup::DataProxyProvider
typedef std::vector< std::pair
< DataKey, boost::shared_ptr
< DataProxy > > > 
KeyedProxies
 
typedef std::vector
< EventSetupRecordKey
Keys
 
typedef std::map
< EventSetupRecordKey,
KeyedProxies
RecordProxies
 

Detailed Description

Definition at line 18 of file SiStripFedCablingBuilderFromDb.h.

Constructor & Destructor Documentation

SiStripFedCablingBuilderFromDb::SiStripFedCablingBuilderFromDb ( const edm::ParameterSet pset)

Definition at line 21 of file SiStripFedCablingBuilderFromDb.cc.

References SiStripEnumsAndStrings::cablingSource(), edm::ParameterSet::getUntrackedParameter(), LogTrace, sistrip::mlCabling_, source, and source_.

23  db_(0),
25 {
26  findingRecord<SiStripFedCablingRcd>();
27 
29  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
30  << " Constructing object...";
31 
32  // Defined cabling "source" (connections, devices, detids)
33  string source = pset.getUntrackedParameter<string>( "CablingSource", "UNDEFINED" );
35 
37  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
38  << " CablingSource configurable set to \"" << source << "\""
39  << ". CablingSource member data set to: \""
40  << SiStripEnumsAndStrings::cablingSource( source_ ) << "\"";
41 }
T getUntrackedParameter(std::string const &, T const &) const
static const char mlCabling_[]
SiStripFedCablingESProducer(const edm::ParameterSet &)
#define LogTrace(id)
static std::string cablingSource(const sistrip::CablingSource &)
static std::string const source
Definition: EdmProvDump.cc:42
SiStripFedCablingBuilderFromDb::~SiStripFedCablingBuilderFromDb ( )
virtual

Definition at line 45 of file SiStripFedCablingBuilderFromDb.cc.

References LogTrace, and sistrip::mlCabling_.

45  {
47  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
48  << " Destructing object...";
49 }
static const char mlCabling_[]
#define LogTrace(id)

Member Function Documentation

void SiStripFedCablingBuilderFromDb::assignDcuAndDetIds ( SiStripFecCabling fec_cabling,
const std::vector< std::pair< uint32_t, TkDcuInfo * > > &  _in 
)
staticprotected

Definition at line 858 of file SiStripFedCablingBuilderFromDb.cc.

References SiStripFecCabling::crates(), SiStripModule::dcuId(), TauDecayModes::dec, cond::rpcobgas::detid, SiStripModule::detId(), SiStripConfigDb::findDcuDetId(), recoMuon::in, SiStripModule::length(), LogTrace, combine::missing, sistrip::mlCabling_, SiStripModule::nApvPairs(), cmsHarvester::path, contentValuesCheck::ss, and susybsm::HSCParticleType::unknown.

Referenced by buildFecCablingFromDevices(), and buildFecCablingFromFedConnections().

859  {
860  std::vector< std::pair<uint32_t,TkDcuInfo*> > in = _in;
861  // ---------- Check if entries found in DCU-DetId vector ----------
862 
863  if ( in.empty() ) {
865  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
866  << " No entries in DCU-DetId vector!";
867  }
868 
869  // ---------- Assign DCU and DetId to Modules in FEC cabling object ----------
870 
872  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
873  << " Assigning DCU ids and DetIds to constructed modules...";
874 
875  uint16_t channels = 0;
876  uint16_t six = 0;
877  uint16_t four = 0;
878  uint16_t unknown = 0;
879  uint16_t missing = 0;
880 
881  for ( vector<SiStripFecCrate>::const_iterator icrate = fec_cabling.crates().begin(); icrate != fec_cabling.crates().end(); icrate++ ) {
882  for ( vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++ ) {
883  for ( vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++ ) {
884  for ( vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++ ) {
885  for ( vector<SiStripModule>::const_iterator imod = iccu->modules().begin(); imod != iccu->modules().end(); imod++ ) {
886  SiStripModule& module = const_cast<SiStripModule&>(*imod);
887 
888  //@@ TEMP FIX UNTIL LAURENT DEBUGS FedChannelConnectionDescription CLASS
889  module.nApvPairs(0);
890 
891  // --- Check for null DCU ---
892 
893  if ( !module.dcuId() ) {
894  SiStripFecKey path( icrate->fecCrate(),
895  ifec->fecSlot(),
896  iring->fecRing(),
897  iccu->ccuAddr(),
898  imod->ccuChan() );
899  uint32_t module_key = path.key();
900  module.dcuId( module_key ); // Assign DCU id equal to control key
901  stringstream ss;
902  ss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
903  << " Found NULL DcuId! Setting 'dummy' value based control key 0x"
904  << hex << setw(8) << setfill('0') << module_key << dec;
905  edm::LogWarning(mlCabling_) << ss.str();
906  }
907 
908  // --- Check for null DetId ---
909 
910  if ( !module.detId() ) {
911 
912  // --- Search for DcuId in map ---
913 
914  SiStripConfigDb::DcuDetIdsV::iterator iter = in.end();
915  iter = SiStripConfigDb::findDcuDetId( in.begin(), in.end(), module.dcuId() );
916  if ( iter != in.end() ) {
917 
918  if ( !(iter->second) ) {
920  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
921  << " NULL pointer to TkDcuInfo!";
922  continue;
923  }
924 
925  // --- Assign DetId and set nApvPairs based on APVs found in given Module ---
926 
927  module.detId( iter->second->getDetId() );
928  module.nApvPairs(0);
929 
930  // count expected channels
931  uint16_t pairs = iter->second->getApvNumber()/2;
932  channels += pairs;
933  if ( pairs == 2 ) { four++; }
934  else if ( pairs == 3 ) { six++; }
935  else { unknown++; }
936 
937  // --- Check number of APV pairs is valid and consistent with cached map ---
938 
939  if ( module.nApvPairs() != 2 && module.nApvPairs() != 3 ) {
940 
941  missing += ( iter->second->getApvNumber()/2 - module.nApvPairs() );
942  stringstream ss1;
943  ss1 << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]" << std::endl
944  << " Module with DCU id 0x"
945  << hex << setw(8) << setfill('0') << module.dcuId() << dec
946  << " and DetId 0x"
947  << hex << setw(8) << setfill('0') << module.detId() << dec
948  << " has unexpected number of APV pairs ("
949  << module.nApvPairs() << ")." << std::endl
950  << " Some APV pairs may have not been detected by the FEC scan." << std::endl
951  << " Setting to value found in static map ("
952  << iter->second->getApvNumber()/2 << ")...";
953  edm::LogWarning(mlCabling_) << ss1.str();
954  module.nApvPairs( iter->second->getApvNumber()/2 );
955 
956  } else if ( module.nApvPairs() < iter->second->getApvNumber()/2 ) {
957 
958  missing += ( iter->second->getApvNumber()/2 - module.nApvPairs() );
959  stringstream ss2;
960  ss2 << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]" << std::endl
961  << " Module with DCU id 0x"
962  << hex << setw(8) << setfill('0') << module.dcuId() << dec
963  << " and DetId 0x"
964  << hex << setw(8) << setfill('0') << module.detId() << dec
965  << " has number of APV pairs ("
966  << module.nApvPairs()
967  << ") that does not match value found in DCU-DetId vector ("
968  << iter->second->getApvNumber()/2 << ")." << std::endl
969  << " Some APV pairs may have not been detected by"
970  << " the FEC scan or the DCU-DetId vector may be incorrect." << std::endl
971  << " Setting to value found in static map ("
972  << iter->second->getApvNumber()/2 << ")...";
973  edm::LogWarning(mlCabling_) << ss2.str();
974  module.nApvPairs( iter->second->getApvNumber()/2 );
975 
976  }
977 
978  // --- Check for null fibre length ---
979 
980  if ( !module.length() ) {
981  module.length( static_cast<uint16_t>( iter->second->getFibreLength() ) );
982  }
983 
984  // --- Remove TkDcuInfo object from cached map ---
985 
986  in.erase( iter );
987 
988  } // Set for DCU in static table
989  } // Check for null DetId
990 
991  } // Module loop
992  } // CCU loop
993  } // FEC ring loop
994  } // FEC loop
995  } // FEC crate loop
996 
997  std::stringstream sss;
998  sss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]" << std::endl
999  << " Connections in DCU-DetId map : " << channels << std::endl
1000  << " 4-APV modules : " << four << std::endl
1001  << " 6-APV modules : " << six << std::endl
1002  << " Unknown number of APV pairs : " << unknown << std::endl
1003  << " Total found APV pairs : " << ( channels - missing ) << std::endl
1004  << " Total missing APV pairs : " << missing << std::endl;
1005  edm::LogVerbatim(mlCabling_) << sss.str();
1006 
1008  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1009  << " Finished assigning DCU ids and DetIds to constructed modules...";
1010 
1011  // ---------- "Randomly" assign DetIds to Modules with DCU ids not found in static table ----------
1012 
1014  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1015  << " Assigning \"random\" DetIds to modules with DCU ids not found in static table...";
1016 
1017  uint32_t detid = 0x10000; // Incremented "dummy" DetId
1018  for ( vector<SiStripFecCrate>::const_iterator icrate = fec_cabling.crates().begin(); icrate != fec_cabling.crates().end(); icrate++ ) {
1019  for ( vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++ ) {
1020  for ( vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++ ) {
1021  for ( vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++ ) {
1022  for ( vector<SiStripModule>::const_iterator imod = iccu->modules().begin(); imod != iccu->modules().end(); imod++ ) {
1023  SiStripModule& module = const_cast<SiStripModule&>(*imod);
1024 
1025  // --- Check for null DetId and search for DCU in cached map ---
1026 
1027  if ( !module.detId() ) {
1028 
1029  SiStripConfigDb::DcuDetIdsV::iterator iter = in.end();
1030  iter = SiStripConfigDb::findDcuDetId( in.begin(), in.end(), module.dcuId() );
1031  if ( iter != in.end() ) {
1032 
1033  // --- Search for "random" module with consistent number of APV pairs ---
1034 
1035  SiStripConfigDb::DcuDetIdsV::iterator idcu;
1036  if ( in.empty() ) { idcu = in.end(); }
1037  else {
1038  idcu = in.begin();
1039  while ( idcu != in.end() ) {
1040  if ( idcu->second ) {
1041  if ( static_cast<uint32_t>(idcu->second->getApvNumber()) ==
1042  static_cast<uint32_t>(2*module.nApvPairs()) ) { break; }
1043  }
1044  idcu++;
1045  }
1046  }
1047 
1048  // --- Assign "random" DetId if number of APV pairs is consistent ---
1049 
1050  if ( idcu != in.end() ) {
1051 
1052  if ( !(idcu->second) ) {
1054  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1055  << " NULL pointer to TkDcuInfo!";
1056  continue;
1057  }
1058 
1059  module.detId( idcu->second->getDetId() );
1060  in.erase( idcu );
1061 
1062  stringstream ss;
1063  ss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1064  << " Did not find module with DCU id 0x"
1065  << hex << setw(8) << setfill('0') << module.dcuId() << dec
1066  << " in DCU-DetId vector!" << endl
1067  << " Assigned 'random' DetId 0x"
1068  << hex << setw(8) << setfill('0') << module.detId() << dec;
1069  edm::LogWarning(mlCabling_) << ss.str();
1070 
1071  } else { // --- Else, assign "dummy" DetId based on counter ---
1072 
1073  // If no match found, then assign DetId using incremented counter
1074  module.detId( detid );
1075  detid++;
1076 
1077  stringstream ss;
1078  if ( in.empty() ) {
1079  ss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1080  << " Did not find module with DCU id 0x"
1081  << hex << setw(8) << setfill('0') << module.dcuId() << dec
1082  << " in DCU-DetId vector!"
1083  << " Could not assign 'random' DetId as DCU-DetID map is empty!"
1084  << " Assigned DetId based on incremented counter, with value 0x"
1085  << hex << setw(8) << setfill('0') << module.detId() << dec;
1086  } else {
1087  ss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1088  << " Did not find module with DCU id 0x"
1089  << hex << setw(8) << setfill('0') << module.dcuId() << dec
1090  << " in DCU-DetId vector!"
1091  << " Could not assign 'random' DetId as no modules had appropriate number of APV pairs ("
1092  << module.nApvPairs()
1093  << "). Assigned DetId based on incremented counter, with value 0x"
1094  << hex << setw(8) << setfill('0') << module.detId() << dec;
1095  }
1096  edm::LogWarning(mlCabling_) << ss.str();
1097 
1098  }
1099  }
1100 
1101  }
1102 
1103  } // Module loop
1104  } // CCU loop
1105  } // FEC ring loop
1106  } // FEC loop
1107  } // FEC crate loop
1108 
1110  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1111  << " Finished assigning \"random\" DetIds to modules with DCU ids not found in static table...";
1112 
1114  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1115  << " Assigning \"random\" DetIds to modules with DCU ids not found in static table...";
1116 
1117  // ---------- Check for unassigned DetIds ----------
1118 
1119  if ( !in.empty() ) {
1120  stringstream ss;
1121  ss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
1122  << " Not all DetIds have been assigned to a DcuId! "
1123  << in.size() << " DetIds are unassigned!";
1124  edm::LogWarning(mlCabling_) << ss.str();
1125  }
1126 
1127 }
Device and connection information at the level of a front-end module.
Definition: SiStripModule.h:24
dictionary missing
Definition: combine.py:4
const std::vector< SiStripFecCrate > & crates() const
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_[]
const uint16_t & length() const
static DcuDetIdsV::const_iterator findDcuDetId(DcuDetIdsV::const_iterator begin, DcuDetIdsV::const_iterator end, uint32_t dcu_id)
Definition: DcuDetIds.cc:395
tuple path
else: Piece not in the list, fine.
#define LogTrace(id)
const uint16_t & nApvPairs() const
const uint32_t & dcuId() const
const uint32_t & detId() const
Definition: vlib.h:208
void SiStripFedCablingBuilderFromDb::buildFecCabling ( SiStripConfigDb * const  db,
SiStripFecCabling fec_cabling,
const sistrip::CablingSource source 
)
static

Generic method which builds FEC cabling. Call ones of the three methods below depending on the cabling "source" parameter (connections, devices, detids).

Definition at line 113 of file SiStripFedCablingBuilderFromDb.cc.

References buildFecCablingFromDetIds(), buildFecCablingFromDevices(), buildFecCablingFromFedConnections(), sistrip::CABLING_FROM_CONNS, sistrip::CABLING_FROM_DETIDS, sistrip::CABLING_FROM_DEVICES, SiStripEnumsAndStrings::cablingSource(), SiStripFecCabling::countDevices(), LogTrace, sistrip::mlCabling_, contentValuesCheck::ss, and sistrip::UNDEFINED_CABLING_SOURCE.

Referenced by SiStripCondObjBuilderFromDb::buildCondObj(), CommissioningHistosUsingDb::CommissioningHistosUsingDb(), and make().

115  {
116 
118  else if ( source == sistrip::CABLING_FROM_DEVICES ) { buildFecCablingFromDevices( db, fec_cabling ); }
119  else if ( source == sistrip::CABLING_FROM_DETIDS ) { buildFecCablingFromDetIds( db, fec_cabling ); }
121 
123  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
124  << " Unexpected value for CablingSource: \""
126  << "\" Querying DB in order to build cabling from one of connections, devices or DetIds...";
127  buildFecCabling( db, fec_cabling );
128  return;
129 
130  } else {
131 
133  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
134  << " Cannot build SiStripFecCabling object!"
135  << " sistrip::CablingSource has value: "
137  return;
138 
139  }
140 
141  // Debug
142  const NumberOfDevices& devs = fec_cabling.countDevices();
143  std::stringstream ss;
144  ss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
145  << " Built SiStripFecCabling object with following devices:"
146  << endl << devs;
147  edm::LogVerbatim(mlCabling_) << ss.str() << endl;
148 
149 }
static void buildFecCablingFromDetIds(SiStripConfigDb *const, SiStripFecCabling &)
static const char mlCabling_[]
static void buildFecCabling(SiStripConfigDb *const, SiStripFecCabling &, const sistrip::CablingSource &)
#define LogTrace(id)
Simple container class for counting devices.
static std::string cablingSource(const sistrip::CablingSource &)
static void buildFecCablingFromFedConnections(SiStripConfigDb *const, SiStripFecCabling &)
static std::string const source
Definition: EdmProvDump.cc:42
NumberOfDevices countDevices() const
static void buildFecCablingFromDevices(SiStripConfigDb *const, SiStripFecCabling &)
void SiStripFedCablingBuilderFromDb::buildFecCabling ( SiStripConfigDb * const  db,
SiStripFecCabling fec_cabling 
)
static

Generic method which builds FEC cabling. Call ones of the three methods below depending on what descriptions are available within the database or which xml files are available.

Definition at line 153 of file SiStripFedCablingBuilderFromDb.cc.

References buildFecCablingFromDetIds(), buildFecCablingFromDevices(), buildFecCablingFromFedConnections(), SiStripFecCabling::countDevices(), SiStripConfigDb::getDcuDetIds(), SiStripConfigDb::getDeviceDescriptions(), SiStripConfigDb::getFedConnections(), LogTrace, sistrip::mlCabling_, and contentValuesCheck::ss.

154  {
156  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
157  << " Building cabling object...";
158 
159  if ( !db->getFedConnections().empty() ) { buildFecCablingFromFedConnections( db, fec_cabling ); }
160  else if ( !db->getDeviceDescriptions().empty() ) { buildFecCablingFromDevices( db, fec_cabling ); }
161  else if ( !db->getDcuDetIds().empty() ) { buildFecCablingFromDetIds( db, fec_cabling ); }
162  else {
163 
165  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
166  << " Cannot build SiStripFecCabling object!"
167  << " FedConnections, DeviceDescriptions and DcuDetIds vectors are all empty!";
168  return;
169 
170  }
171 
172  // Debug
173  const NumberOfDevices& devices = fec_cabling.countDevices();
174  std::stringstream ss;
175  ss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
176  << " Built SiStripFecCabling object with following devices:"
177  << std::endl << devices;
178  edm::LogVerbatim(mlCabling_) << ss.str() << endl;
179 
180 }
static void buildFecCablingFromDetIds(SiStripConfigDb *const, SiStripFecCabling &)
static const char mlCabling_[]
FedConnectionsRange getFedConnections(std::string partition="")
#define LogTrace(id)
Simple container class for counting devices.
static void buildFecCablingFromFedConnections(SiStripConfigDb *const, SiStripFecCabling &)
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
DcuDetIdsRange getDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:10
NumberOfDevices countDevices() const
static void buildFecCablingFromDevices(SiStripConfigDb *const, SiStripFecCabling &)
void SiStripFedCablingBuilderFromDb::buildFecCablingFromDetIds ( SiStripConfigDb * const  db,
SiStripFecCabling fec_cabling 
)
static

Builds the SiStripFecCabling conditions object using information found within the "dcuinfo.xml" file (ie, based on DetIds). "Dummy" values are provided when necessary.

Builds the SiStripFedCabling conditions object that is available via the EventSetup interface. The object contains the full FedChannel-Dcu-DetId mapping information.

This method is typically used when only the Dcu-DetId map (ie, from "dcuinfo.xml") exists and the FED connections (ie, "module.xml" file) and device descriptions (ie, from "fec.xml") are both missing.

The map is built using the Dcu-DetId map that is cached by the SiStripConfigDb object. As a minimum, the map should contain values within both the DetId and APpvPair fields, but if any information is missing, the method provides "dummy" values.

Methodology:

The FEC cabling object is built using the Dcu-DetId map (ie, from "dcuinfo.xml"). For each entry, the DcuId, DetId and ApvPairs values are retrieved. For each ApvPair, a FED channel connection object is created using "dummy" hardware addresses.

If the DcuId (provided by the hardware device descriptions) is null, a dummy value is provided, based on the control key.

If the DetId is null, a value is assigned using an incremented counter (starting from 0xFFFF).

If the number of APV pairs is null, a value of 2 or 3 is randomly assigned.

Given that the FED channel connections are not known, APV pairs are cabled to "random" FED ids and channels.

All Dcu-DetId mappings are accumulated in a new map, and this modified map is returned by the method.

Definition at line 736 of file SiStripFedCablingBuilderFromDb.cc.

References SiStripFecCabling::addDevices(), results_mgr::conn, SiStripFecCabling::crates(), SiStripModule::fedCh(), SiStripConfigDb::getDcuDetIds(), SiStripKey::key(), LogTrace, sistrip::mlCabling_, and rand().

Referenced by buildFecCabling().

737  {
739  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
740  << " Building FEC cabling object from DetIds...";
741 
742  // ---------- Some initialization ----------
743 
744  // fec_cabling.clear();
745 
746  // chans_per_ring = chans_per_ccu * ccus_per_ring = 100 (TOB gives lower limit of 60)
747  uint32_t chans_per_ccu = 10;
748  uint32_t ccus_per_ring = 10;
749  uint32_t rings_per_fec = 8;
750  uint32_t fecs_per_crate = 11;
751 
752  // ---------- Retrieve necessary descriptions from database ----------
753 
754 
756  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
757  << " Retrieving DCU-DetId vector from database...";
759  const SiStripConfigDb::DcuDetIdsV dcu_detid_vector( range.begin(), range.end() );
760  if ( !dcu_detid_vector.empty() ) {
762  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
763  << " Found " << dcu_detid_vector.size()
764  << " entries in DCU-DetId vector retrieved from database!";
765  } else {
767  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
768  << " No entries in DCU-DetId vector retrieved from database!"
769  << " Unable to build FEC cabling!";
770  return;
771  }
772 
773  // ---------- Populate FEC cabling object with DCU, DetId and "dummy" control info ----------
774 
775  uint32_t imodule = 0;
776  SiStripConfigDb::DcuDetIdsV::const_iterator iter;
777  for ( iter = dcu_detid_vector.begin(); iter != dcu_detid_vector.end(); iter++ ) {
778 
779  if ( !(iter->second) ) {
781  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
782  << " NULL pointer to TkDcuInfo!";
783  continue;
784  }
785 
786  uint16_t fec_crate = ( imodule / ( chans_per_ccu * ccus_per_ring * rings_per_fec * fecs_per_crate ) ) + 1;
787  uint16_t fec_slot = ( imodule / ( chans_per_ccu * ccus_per_ring * rings_per_fec ) ) % fecs_per_crate + 2;
788  uint16_t fec_ring = ( imodule / ( chans_per_ccu * ccus_per_ring ) ) % rings_per_fec + 1;
789  uint16_t ccu_addr = ( imodule / ( chans_per_ccu) ) % ccus_per_ring + 1;
790  uint16_t ccu_chan = ( imodule ) % chans_per_ccu + 16;
791 
792  uint32_t dcu_id = iter->second->getDcuHardId(); //
793  uint32_t det_id = iter->second->getDetId();
794  uint16_t npairs = iter->second->getApvNumber()/2;
795  uint16_t length = (uint16_t) iter->second->getFibreLength(); //@@ should be double!
796 
797  // --- Check if DCU, DetId and nApvPairs are null ---
798 
799  if ( !dcu_id ) {
800  dcu_id = SiStripFecKey( fec_crate,
801  fec_slot,
802  fec_ring,
803  ccu_addr,
804  ccu_chan ).key();
805  }
806  if ( !det_id ) { det_id = 0xFFFF + imodule; }
807  if ( !npairs ) { npairs = rand()/2 ? 2 : 3; }
808 
809  // --- Construct FedChannelConnection objects ---
810 
811  for ( uint16_t ipair = 0; ipair < npairs; ipair++ ) {
812  uint16_t iapv = ( ipair == 1 && npairs == 2 ? 36 : 32 + 2 * ipair ) ;
813  FedChannelConnection conn( fec_crate,
814  fec_slot,
815  fec_ring,
816  ccu_addr,
817  ccu_chan,
818  iapv, iapv+1,
819  dcu_id, det_id, npairs,
820  0, 0, // FED id and channel
821  length,
822  true, true, true, true );
823  fec_cabling.addDevices( conn );
824  }
825 
826  imodule++;
827  }
828 
829  // ---------- Assign "dummy" FED ids/chans to Modules of FEC cabling object ----------
830 
831  uint32_t fed_id = 50;
832  uint32_t fed_ch = 0;
833  for ( vector<SiStripFecCrate>::const_iterator icrate = fec_cabling.crates().begin(); icrate != fec_cabling.crates().end(); icrate++ ) {
834  for ( vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++ ) {
835  for ( vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++ ) {
836  for ( vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++ ) {
837  for ( vector<SiStripModule>::const_iterator imod = iccu->modules().begin(); imod != iccu->modules().end(); imod++ ) {
838  if ( 96-fed_ch < imod->nApvPairs() ) { fed_id++; fed_ch = 0; } // move to next FED
839  for ( uint16_t ipair = 0; ipair < imod->nApvPairs(); ipair++ ) {
840  pair<uint16_t,uint16_t> addr = imod->activeApvPair( (*imod).lldChannel(ipair) );
841  SiStripModule::FedChannel fed_channel( (fed_id-50)/16+1, // 16 FEDs per crate, numbering starts from 1
842  (fed_id-50)%16+2, // FED slot starts from 2
843  fed_id,
844  fed_ch );
845  const_cast<SiStripModule&>(*imod).fedCh( addr.first, fed_channel );
846  fed_ch++;
847  }
848  }
849  }
850  }
851  }
852  }
853 
854 }
Device and connection information at the level of a front-end module.
Definition: SiStripModule.h:24
DcuDetIds::range DcuDetIdsRange
void addDevices(const FedChannelConnection &conn)
const std::vector< SiStripFecCrate > & crates() const
const uint32_t & key() const
Definition: SiStripKey.h:125
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_[]
Class containning control, module, detector and connection information, at the level of a FED channel...
#define LogTrace(id)
std::vector< DcuDetId > DcuDetIdsV
Signal rand(Signal arg)
Definition: vlib.cc:442
FedChannel fedCh(const uint16_t &apv_pair_num) const
DcuDetIdsRange getDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:10
tuple conn
Definition: results_mgr.py:53
void SiStripFedCablingBuilderFromDb::buildFecCablingFromDevices ( SiStripConfigDb * const  db,
SiStripFecCabling fec_cabling 
)
static

Builds the SiStripFecCabling conditions object using information found within the "fec.xml" and "dcuinfo.xml" files. "Dummy" values are provided when necessary.

Builds the SiStripFedCabling conditions object that is available via the EventSetup interface. The object contains the full FedChannel-Dcu-DetId mapping information.

This method is typically used when the FED connections (ie, "module.xml" file) does not exist, such as prior to the FED cabling or "bare connection" procedure.

The map is built using information cached by the SiStripConfigDb object, comprising: 1) the hardware device descriptions, as found in the "fec.xml" file; 2) and Dcu-DetId mapping, as found in the "dcuinfo.xml" file. If any information is missing, the method provides "dummy" values.

Methodology:

The FEC cabling object is built using the hardware device descriptions (ie, from "fec.xml").

Given that the FED channel connections are not known, APV pairs are cabled to "random" FED ids and channels. FED ids are retrieved from any FED descriptions cached by the SiStripConfigDb object (ie, from "fed.xml"). A check is made to ensure sufficient FEDs exist to cable the entire control system. If not, the shortfall is met by generating FED ids using an incremented counter (starting from 50).

If the DcuId (provided by the hardware device descriptions) is null, a dummy value is provided, based on the control key.

The Dcu-DetId map (ie, from "dcuinfo.xml") is queried for a matching DcuId. If found, the DetId and ApvPairs are updated. If not, a "random" DetId within the Dcu-DetId map is assigned. Note that a check is made on the number of APV pairs before the DetId is assigned. If no appropriate match is found, the DetId is assigned a value using an incremented counter (starting from 0xFFFF).

All Dcu-DetId mappings are accumulated in a new map, and this modified map is returned by the method.

Definition at line 351 of file SiStripFedCablingBuilderFromDb.cc.

References SiStripFecCabling::addDevices(), assignDcuAndDetIds(), SiStripFedCablingESProducer::ccuAddr(), SiStripConfigDb::DeviceAddress::ccuAddr_, SiStripFedCablingESProducer::ccuChan(), SiStripConfigDb::DeviceAddress::ccuChan_, results_mgr::conn, SiStripFecCabling::countDevices(), SiStripFecCabling::crates(), SiStripFecCabling::dcuId(), SiStripConfigDb::deviceAddress(), sistrip::FEC_CRATE_OFFSET, sistrip::FEC_RING_OFFSET, SiStripFedCablingESProducer::fecCrate(), SiStripConfigDb::DeviceAddress::fecCrate_, SiStripFedCablingESProducer::fecRing(), SiStripConfigDb::DeviceAddress::fecRing_, SiStripFedCablingESProducer::fecSlot(), SiStripConfigDb::DeviceAddress::fecSlot_, SiStripModule::fedCh(), FedChannelConnection::fedCrate(), FedChannelConnection::fedSlot(), SiStripConfigDb::getDcuDetIds(), SiStripConfigDb::getDeviceDescriptions(), SiStripConfigDb::getFedIds(), SiStripFecKey::i2cAddr(), SiStripConfigDb::DeviceAddress::i2cAddr_, sistrip::invalid32_, relval_steps::key, sistrip::LLD_CHAN_MAX, sistrip::LLD_CHAN_MIN, LogTrace, sistrip::mlCabling_, SiStripModule::nApvPairs(), NumberOfDevices::print(), python.multivaluedict::sort(), and groupFilesInBlocks::temp.

Referenced by buildFecCabling(), and CommissioningHistosUsingDb::CommissioningHistosUsingDb().

352  {
354  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
355  << " Building FEC cabling object from device descriptions...";
356 
357  // ---------- Some initialization ----------
358 
359  // fec_cabling.clear(); //@@ Need to add method to "clear" FecCabling?
360 
361  // ---------- Retrieve APV descriptions from database ----------
362 
364  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
365  << " Retrieving APV descriptions from database...";
367  if ( !apv_desc.empty() ) {
369  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
370  << " Retrieved " << apv_desc.size()
371  << " APV descriptions from database!";
372  } else {
374  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
375  << " Unable to build FEC cabling!"
376  << " No APV descriptions found!";
377  return;
378  }
379 
380  // ---------- Retrieve DCU descriptions from database ----------
381 
383  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
384  << " Retrieving DCU descriptions from database...";
386 
387  if ( !dcu_desc.empty() ) {
388 
389  uint16_t feh = 0;
390  uint16_t ccu = 0;
391  SiStripConfigDb::DeviceDescriptionsV::const_iterator idcu;
392  for ( idcu = dcu_desc.begin(); idcu != dcu_desc.end(); idcu++ ) {
393  dcuDescription* dcu = dynamic_cast<dcuDescription*>( *idcu );
394  if ( !dcu ) { continue; }
395  if ( dcu->getDcuType() == "FEH" ) { feh++; }
396  else { ccu++; }
397  }
398 
400  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
401  << " Retrieved " << feh
402  << " DCU-FEH descriptions from database!"
403  << " (and a further " << ccu << " DCUs for CCU modules, etc...)";
404 
405  } else {
407  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
408  << " No DCU descriptions found!";
409  }
410 
411  // ---------- Retrieve DCU-DetId vector from database ----------
412 
413 
415  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
416  << " Retrieving DCU-DetId vector from database...";
418  const SiStripConfigDb::DcuDetIdsV dcu_detid_vector( range.begin(), range.end() );
419  if ( !dcu_detid_vector.empty() ) {
421  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
422  << " Found " << dcu_detid_vector.size()
423  << " entries in DCU-DetId vector retrieved from database!";
424  } else {
426  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
427  << " No entries in DCU-DetId vector retrieved from database!";
428  }
429 
430  // ---------- Retrieve FED ids from database ----------
431 
433  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
434  << " Retrieving FED ids from database...";
435  SiStripConfigDb::FedIdsRange fed_ids = db->getFedIds();
436 
437  if ( !fed_ids.empty() ) {
439  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
440  << " Retrieved " << fed_ids.size()
441  << " FED ids from database!";
442  } else {
444  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
445  << " No FED ids found!";
446  }
447 
448  // ---------- Populate FEC cabling object with retrieved info ----------
449 
451  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
452  << " Building FEC cabling object from APV and DCU descriptions...";
453 
454  SiStripConfigDb::DeviceDescriptionsV::const_iterator iapv;
455  for ( iapv = apv_desc.begin(); iapv != apv_desc.end(); iapv++ ) {
456 
457  if ( !(*iapv) ) {
459  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
460  << " NULL pointer to DeviceDescription (of type APV25)!";
461  continue;
462  }
463 
466  addr.fecSlot_,
467  addr.fecRing_ + sistrip::FEC_RING_OFFSET, //@@ temp
468  addr.ccuAddr_,
469  addr.ccuChan_,
470  addr.i2cAddr_ );
471  fec_cabling.addDevices( conn );
472 
473  }
474 
475  SiStripConfigDb::DeviceDescriptionsV::const_iterator idcu;
476  for ( idcu = dcu_desc.begin(); idcu != dcu_desc.end(); idcu++ ) {
477 
478  if ( !(*idcu) ) {
480  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
481  << " NULL pointer to DeviceDescription (of type DCU)!";
482  continue;
483  }
484 
486  dcuDescription* dcu = dynamic_cast<dcuDescription*>( *idcu );
487  if ( !dcu ) { continue; }
488  if ( dcu->getDcuType() != "FEH" ) { continue; }
490  addr.fecSlot_,
491  addr.fecRing_ + sistrip::FEC_RING_OFFSET, //@@ temp,
492  addr.ccuAddr_,
493  addr.ccuChan_,
494  0, 0, // APV I2C addresses not used
495  dcu->getDcuHardId() );
496  fec_cabling.dcuId( conn );
497 
498  }
499 
501  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
502  << " Finished building FEC cabling object from APV and DCU descriptions!";
503 
504  NumberOfDevices devs1 = fec_cabling.countDevices();
505  std::stringstream ss1;
506  ss1 << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
507  << " Number of devices in FEC cabling object:" << std::endl;
508  devs1.print(ss1);
509  LogTrace(mlCabling_) << ss1.str();
510 
511  // ---------- Counters used in assigning "dummy" FED ids and channels ----------
512 
513  std::vector<uint16_t>::const_iterator ifed = fed_ids.begin();
514  uint16_t fed_ch = 0;
515 
516  // ---------- Assign "dummy" FED crates/slots/ids/chans to constructed modules ----------
517 
518  std::vector<uint32_t> used_keys;
519 
521  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
522  << " Randomly assigning FED ids/channels to APV pairs in front-end modules...";
523 
524  if ( fed_ids.empty() ) {
526  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
527  << " No FED ids retrieved from database! Unable to cable system!";
528  } else {
529 
530  bool complete = false;
531  std::vector<SiStripFecCrate>::const_iterator icrate = fec_cabling.crates().begin();
532  std::vector<SiStripFecCrate>::const_iterator jcrate = fec_cabling.crates().end();
533  while ( !complete && icrate != jcrate ) {
534  std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin();
535  std::vector<SiStripFec>::const_iterator jfec = icrate->fecs().end();
536  while ( !complete && ifec != jfec ) {
537  std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin();
538  std::vector<SiStripRing>::const_iterator jring = ifec->rings().end();
539  while ( !complete && iring != jring ) {
540  std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin();
541  std::vector<SiStripCcu>::const_iterator jccu = iring->ccus().end();
542  while ( !complete && iccu != jccu ) {
543  std::vector<SiStripModule>::const_iterator imod = iccu->modules().begin();
544  std::vector<SiStripModule>::const_iterator jmod = iccu->modules().end();
545  while ( !complete && imod != jmod ) {
546 
547  // Set number of APV pairs based on devices found
548  const_cast<SiStripModule&>(*imod).nApvPairs(0);
549 
550  used_keys.push_back( SiStripFecKey( imod->fecCrate(),
551  imod->fecSlot(),
552  imod->fecRing(),
553  imod->ccuAddr(),
554  imod->ccuChan() ).key() );
555 
556 // // Add middle LLD channel if missing (to guarantee all FED channels are cabled!)
557 // if ( imod->nApvPairs() == 2 ) {
558 // const_cast<SiStripModule&>(*imod).nApvPairs(3);
559 // FedChannelConnection temp( imod->fecCrate(),
560 // imod->fecSlot(),
561 // imod->fecRing(),
562 // imod->ccuAddr(),
563 // imod->ccuChan(),
564 // SiStripFecKey::i2cAddr(2,true),
565 // SiStripFecKey::i2cAddr(2,false) );
566 // const_cast<SiStripModule&>(*imod).addDevices( temp );
567 // }
568 // const_cast<SiStripModule&>(*imod).nApvPairs(0);
569 
570  // Iterate through APV pairs
571  for ( uint16_t ipair = 0; ipair < imod->nApvPairs(); ipair++ ) {
572 
573  // Check FED id and channel
574  if ( ifed == fed_ids.end() ) { fed_ch++; ifed = fed_ids.begin(); }
575  if ( fed_ch == 96 ) {
577  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
578  << " Insufficient FED channels to cable all devices in control system!";
579  complete = true;
580  break;
581  }
582 
583  // Set "dummy" FED id and channel
584  pair<uint16_t,uint16_t> addr = imod->activeApvPair( imod->lldChannel(ipair) );
585  SiStripModule::FedChannel fed_channel( (*ifed)/16+1, // 16 FEDs per crate, numbering starts from 1
586  (*ifed)%16+2, // FED slot starts from 2
587  *ifed,
588  fed_ch );
589  const_cast<SiStripModule&>(*imod).fedCh( addr.first, fed_channel );
590  ifed++;
591 
592  }
593 
594  imod++;
595  }
596  iccu++;
597  }
598  iring++;
599  }
600  ifec++;
601  }
602  icrate++;
603  }
604 
605  }
606 
607  std::sort( used_keys.begin(), used_keys.end() );
608 
609  NumberOfDevices devs2 = fec_cabling.countDevices();
610  std::stringstream ss2;
611  ss2 << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
612  << " Number of devices in FEC cabling object:" << std::endl;
613  devs2.print(ss2);
614  LogTrace(mlCabling_) << ss2.str();
615 
617  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
618  << " Finished randomly assigning FED ids/channels to APV pairs in front-end modules...";
619 
620  // ---------- Assign "dummy" devices to remaining FED ids/chans ----------
621 
623  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
624  << " Assigning APV pairs in dummy front-end modules to any remaining \"uncabled\" FED ids/channels...";
625 
626  if ( fed_ids.empty() ) {
628  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
629  << " No FED ids retrieved from database! Unable to cable system!";
630  } else {
631 
632  uint16_t module = 0;
633  bool complete = false;
634  while ( !complete ) {
635  for ( uint16_t lld = sistrip::LLD_CHAN_MIN; lld < sistrip::LLD_CHAN_MAX+1; lld++ ) {
636 
637  // Check FED id and channel
638  if ( ifed == fed_ids.end() ) { fed_ch++; ifed = fed_ids.begin(); }
639  if ( fed_ch == 96 ) {
641  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
642  << " All FED channels are now cabled!";
643  complete = true;
644  break;
645  }
646 
647  // commented because key is not used
648  //uint32_t key = SiStripFecKey( fecCrate( module ),
649  // fecSlot( module ),
650  // fecRing( module ),
651  // ccuAddr( module ),
652  // ccuChan( module ) ).key();
653 
654  //if ( std::find( used_keys.begin(), used_keys.end(), key ) != used_keys.end() ) { break; }
655 
656  FedChannelConnection temp( fecCrate( module ),
657  fecSlot( module ),
658  fecRing( module ),
659  ccuAddr( module ),
660  ccuChan( module ),
661  SiStripFecKey::i2cAddr(lld,true),
662  SiStripFecKey::i2cAddr(lld,false),
665  3, // npairs
666  *ifed,
667  fed_ch );
668  uint16_t fed_crate = (*ifed)/16+1; // 16 FEDs per crate, numbering starts from 1
669  uint16_t fed_slot = (*ifed)%16+2; // FED slot starts from 2
670  temp.fedCrate( fed_crate );
671  temp.fedSlot( fed_slot );
672  fec_cabling.addDevices( temp );
673  ifed++;
674 
675  }
676  module++;
677  }
678 
679  }
680 
682  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
683  << " Finished assigning APV pairs in dummy front-end modules to any remaining \"uncabled\" FED ids/channels...";
684 
685  NumberOfDevices devs3 = fec_cabling.countDevices();
686  std::stringstream ss3;
687  ss3 << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
688  << " Number of devices in FEC cabling object:" << std::endl;
689  devs3.print(ss3);
690  LogTrace(mlCabling_) << ss3.str();
691 
692  // ---------- Assign DCU and DetIds and then FED cabling ----------
693 
694  assignDcuAndDetIds( fec_cabling, dcu_detid_vector );
695 
696 }
Device and connection information at the level of a front-end module.
Definition: SiStripModule.h:24
static uint16_t ccuAddr(const uint16_t &nth_module)
void print(std::stringstream &) const
static uint16_t fecCrate(const uint16_t &nth_module)
DcuDetIds::range DcuDetIdsRange
static const uint32_t invalid32_
Definition: Constants.h:15
static const uint16_t LLD_CHAN_MIN
static const uint16_t LLD_CHAN_MAX
void addDevices(const FedChannelConnection &conn)
static const uint16_t FEC_RING_OFFSET
const std::vector< SiStripFecCrate > & crates() const
static uint16_t fecSlot(const uint16_t &nth_module)
static uint16_t fecRing(const uint16_t &nth_module)
const uint16_t & i2cAddr() const
static void assignDcuAndDetIds(SiStripFecCabling &, const std::vector< std::pair< uint32_t, TkDcuInfo * > > &)
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_[]
Class containning control, module, detector and connection information, at the level of a FED channel...
DeviceDescriptions::range DeviceDescriptionsRange
void dcuId(const FedChannelConnection &conn)
FedIdsRange getFedIds(std::string partition="")
DeviceAddress deviceAddress(const deviceDescription &)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
#define LogTrace(id)
Simple container class for counting devices.
static uint16_t ccuChan(const uint16_t &nth_module)
const uint16_t & nApvPairs() const
std::vector< DcuDetId > DcuDetIdsV
boost::iterator_range< FedIds::const_iterator > FedIdsRange
static const uint16_t FEC_CRATE_OFFSET
FedChannel fedCh(const uint16_t &apv_pair_num) const
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
DcuDetIdsRange getDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:10
Definition: vlib.h:208
tuple conn
Definition: results_mgr.py:53
NumberOfDevices countDevices() const
void SiStripFedCablingBuilderFromDb::buildFecCablingFromFedConnections ( SiStripConfigDb * const  db,
SiStripFecCabling fec_cabling 
)
static

Builds the SiStripFecCabling conditions object using information found within the "module.xml" and "dcuinfo.xml" files. "Dummy" values are provided when necessary.

Populates the SiStripFecCabling conditions object that is available via the EventSetup interface. The object contains the full FedChannel-Dcu-DetId mapping information.

The map is built using information cached by the SiStripConfigDb object, comprising: 1) the FED channel connections, as found in the "module.xml" file or database; 2) and Dcu-DetId mapping, as found in the "dcuinfo.xml" file or DCU-DetId static table. If any information is missing, the method provides "dummy" values.

Methodology:

1) The FEC cabling object is built using FED channel connection objects.

2) If the DcuId for a module is null (as defined within the connection description), a "dummy" DCU id is provided, based on the control key.

3) The cached Dcu-DetId map is queried for a matching DcuId. If found, the DetId and ApvPairs are updated. The number of APV pairs is checked.

4) If the DCU is not found in the cached map, a "random" DetId is assigned (using the remaining "unassigned" DetIds within the cached map). The DetId is only assigned if the number of APV pairs is consistent with the entry in the cached map.

5) If no appropriate match is found, the DetId is assigned a "dummy" value using an incremented counter (starting from 0xFFFF).

6) All Dcu-DetId mappings are accumulated in a new map, and this modified map is returned by the method.

Definition at line 218 of file SiStripFedCablingBuilderFromDb.cc.

References SiStripFecCabling::addDevices(), assignDcuAndDetIds(), results_mgr::conn, sistrip::FEC_CRATE_OFFSET, sistrip::FEC_RING_OFFSET, FedChannelConnection::fedCrate(), FedChannelConnection::fedSlot(), SiStripConfigDb::getDcuDetIds(), SiStripConfigDb::getFedConnections(), sistrip::invalid_, LogTrace, and sistrip::mlCabling_.

Referenced by buildFecCabling().

219  {
221  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
222  << " Building FEC cabling from FED connections descriptions...";
223 
224  // ---------- Some initialization ----------
225 
226  //fec_cabling.clear(); //@@ Need to add method to "clear" FecCabling?
227 
228  // ---------- Retrieve connection descriptions from database ----------
229 
231  if ( conns.empty() ) {
233  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
234  << " Unable to build FEC cabling!"
235  << " No entries in FedConnections vector!";
236  return;
237  }
238 
239  // ---------- Retrieve DCU-DetId vector from database ----------
240 
242  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
243  << " Retrieving DCU-DetId vector from database...";
245  const SiStripConfigDb::DcuDetIdsV dcu_detid_vector( range.begin(), range.end() );
246  if ( !dcu_detid_vector.empty() ) {
248  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
249  << " Found " << dcu_detid_vector.size()
250  << " entries in DCU-DetId vector retrieved from database!";
251  } else {
253  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
254  << " No entries in DCU-DetId vector retrieved from database!";
255  }
256 
257  // ---------- Populate FEC cabling object with retrieved info ----------
258 
259  SiStripConfigDb::FedConnectionsV::const_iterator ifed = conns.begin();
260  SiStripConfigDb::FedConnectionsV::const_iterator jfed = conns.end();
261  for ( ; ifed != jfed; ++ifed ) {
262 
263  if ( !(*ifed) ) {
265  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
266  << " NULL pointer to FedConnection!";
267  continue;
268  }
269 
270  //uint16_t fec_id = static_cast<uint16_t>( (*ifed)->getFecHardwareId() );
271  uint16_t fec_crate = static_cast<uint16_t>( (*ifed)->getFecCrateId() + sistrip::FEC_CRATE_OFFSET ); //@@ temporary offset!
272  uint16_t fec_slot = static_cast<uint16_t>( (*ifed)->getFecSlot() );
273  uint16_t fec_ring = static_cast<uint16_t>( (*ifed)->getRingSlot() + sistrip::FEC_RING_OFFSET ); //@@ temporary offset!
274  uint16_t ccu_addr = static_cast<uint16_t>( (*ifed)->getCcuAddress() );
275  uint16_t ccu_chan = static_cast<uint16_t>( (*ifed)->getI2cChannel() );
276  uint16_t apv0 = static_cast<uint16_t>( (*ifed)->getApvAddress() );
277  uint16_t apv1 = apv0 + 1; //@@ needs implementing!
278  uint32_t dcu_id = static_cast<uint32_t>( (*ifed)->getDcuHardId() );
279  uint32_t det_id = 0; //@@ static_cast<uint32_t>( (*ifed)->getDetId() );
280  uint16_t npairs = 0; //@@ static_cast<uint16_t>( (*ifed)->getApvPairs() );
281  uint16_t fed_id = static_cast<uint16_t>( (*ifed)->getFedId() );
282  uint16_t fed_ch = static_cast<uint16_t>( (*ifed)->getFedChannel() );
283  uint16_t length = 0; //@@ static_cast<uint16_t>( (*ifed)->getFiberLength() );
284 
285  FedChannelConnection conn( fec_crate, fec_slot, fec_ring, ccu_addr, ccu_chan,
286  apv0, apv1,
287  dcu_id, det_id, npairs,
288  fed_id, fed_ch,
289  length );
290 
291  uint16_t fed_crate = sistrip::invalid_;
292  uint16_t fed_slot = sistrip::invalid_;
293  fed_crate = static_cast<uint16_t>( (*ifed)->getFedCrateId() );
294  fed_slot = static_cast<uint16_t>( (*ifed)->getFedSlot() );
295  conn.fedCrate( fed_crate );
296  conn.fedSlot( fed_slot );
297 
298  fec_cabling.addDevices( conn );
299 
300  }
301 
302  // ---------- Assign DCU and DetIds and then FED cabling ----------
303 
304  assignDcuAndDetIds( fec_cabling, dcu_detid_vector );
305 
306 }
DcuDetIds::range DcuDetIdsRange
void addDevices(const FedChannelConnection &conn)
static const uint16_t FEC_RING_OFFSET
FedConnections::range FedConnectionsRange
static void assignDcuAndDetIds(SiStripFecCabling &, const std::vector< std::pair< uint32_t, TkDcuInfo * > > &)
static const char mlCabling_[]
Class containning control, module, detector and connection information, at the level of a FED channel...
FedConnectionsRange getFedConnections(std::string partition="")
#define LogTrace(id)
std::vector< DcuDetId > DcuDetIdsV
static const uint16_t invalid_
Definition: Constants.h:16
static const uint16_t FEC_CRATE_OFFSET
DcuDetIdsRange getDcuDetIds(std::string partition="")
Definition: DcuDetIds.cc:10
tuple conn
Definition: results_mgr.py:53
void SiStripFedCablingBuilderFromDb::getFecCabling ( const SiStripFedCabling in,
SiStripFecCabling out 
)
static

Utility method that takes a FED cabling object as input and returns (as an arg) the corresponding FEC cabling object.

Definition at line 1140 of file SiStripFedCablingBuilderFromDb.cc.

References SiStripFecCabling::buildFecCabling().

1141  {
1142  fec_cabling.buildFecCabling( fed_cabling );
1143 }
void SiStripFedCablingBuilderFromDb::getFedCabling ( const SiStripFecCabling in,
SiStripFedCabling out 
)
static

Utility method that takes a FEC cabling object as input and returns (as an arg) the corresponding FED cabling object.

Definition at line 1131 of file SiStripFedCablingBuilderFromDb.cc.

References SiStripFedCabling::buildFedCabling(), and SiStripFecCabling::connections().

Referenced by SiStripCondObjBuilderFromDb::buildCondObj(), CommissioningHistosUsingDb::CommissioningHistosUsingDb(), and make().

1132  {
1133  vector<FedChannelConnection> conns;
1134  fec_cabling.connections( conns );
1135  fed_cabling.buildFedCabling( conns );
1136 }
SiStripFedCabling * SiStripFedCablingBuilderFromDb::make ( const SiStripFedCablingRcd )
virtual

Builds FED cabling using info from configuration database.

Implements SiStripFedCablingESProducer.

Definition at line 53 of file SiStripFedCablingBuilderFromDb.cc.

References buildFecCabling(), SiStripConfigDb::databaseCache(), db_, TauDecayModes::dec, SiStripConfigDb::deviceFactory(), getFedCabling(), LogTrace, sistrip::mlCabling_, cppFunctionSkipper::operator, source_, and writeFedCablingToCondDb().

53  {
55  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
56  << " Constructing FED cabling...";
57 
58  // Create FED cabling object
59  SiStripFedCabling* fed_cabling = new SiStripFedCabling();
60 
61  // Build and retrieve SiStripConfigDb object using service
63 
64  // Check pointer
65  if ( db_ ) {
67  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
68  << " Pointer to SiStripConfigDb: 0x"
69  << std::setw(8) << std::setfill('0')
70  << std::hex << db_ << std::dec;
71  } else {
73  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
74  << " NULL pointer to SiStripConfigDb returned by DB \"service\"!"
75  << " Cannot build FED cabling object!";
76  return fed_cabling;
77  }
78 
79  // Check if DB connection is made
80  if ( db_->deviceFactory() ||
81  db_->databaseCache() ) {
82 
83  // Build FEC cabling object
84  SiStripFecCabling fec_cabling;
85  buildFecCabling( db_, fec_cabling, source_ );
86 
87  // Populate FED cabling object
88  getFedCabling( fec_cabling, *fed_cabling );
89 
90  // Call virtual method that writes FED cabling object to conditions DB
91  writeFedCablingToCondDb( *fed_cabling );
92 
93  // Prints FED cabling
94  //stringstream ss;
95  //ss << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
96  //<< " Printing cabling map..." << endl
97  //<< *fed_cabling;
98  //LogTrace(mlCabling_) << ss.str();
99 
100  } else {
102  << "[SiStripFedCablingBuilderFromDb::" << __func__ << "]"
103  << " NULL pointers to DeviceFactory and DatabaseCache returned by SiStripConfigDb!"
104  << " Cannot build FED cabling object!";
105  }
106 
107  return fed_cabling;
108 
109 }
DeviceFactory *const deviceFactory(std::string method_name="") const
static const char mlCabling_[]
static void buildFecCabling(SiStripConfigDb *const, SiStripFecCabling &, const sistrip::CablingSource &)
virtual void writeFedCablingToCondDb(const SiStripFedCabling &)
#define LogTrace(id)
DbClient *const databaseCache(std::string method_name="") const
static void getFedCabling(const SiStripFecCabling &in, SiStripFedCabling &out)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void SiStripFedCablingBuilderFromDb::setIntervalFor ( const edm::eventsetup::EventSetupRecordKey key,
const edm::IOVSyncValue iov_sync,
edm::ValidityInterval iov_validity 
)
protectedvirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 1147 of file SiStripFedCablingBuilderFromDb.cc.

References edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime(), and infinity.

1149  {
1150  edm::ValidityInterval infinity( iov_sync.beginOfTime(), iov_sync.endOfTime() );
1151  iov_validity = infinity;
1152 }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:97
static const IOVSyncValue & beginOfTime()
const double infinity
virtual void SiStripFedCablingBuilderFromDb::writeFedCablingToCondDb ( const SiStripFedCabling )
inlineprotectedvirtual

Virtual method that is called by makeFedCabling() to allow FED cabling to be written to the conds DB (local or otherwise).

Definition at line 90 of file SiStripFedCablingBuilderFromDb.h.

Referenced by make().

90 {;}

Member Data Documentation

SiStripConfigDb* SiStripFedCablingBuilderFromDb::db_
protected

Access to the configuration DB interface class.

Definition at line 93 of file SiStripFedCablingBuilderFromDb.h.

Referenced by make().

sistrip::CablingSource SiStripFedCablingBuilderFromDb::source_
protected

Defines "source" (conns, devices, detids) of cabling info.

Definition at line 96 of file SiStripFedCablingBuilderFromDb.h.

Referenced by Config.Process::dumpConfig(), Config.Process::dumpPython(), make(), and SiStripFedCablingBuilderFromDb().