ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_Cabling Namespace Reference

Namespaces

namespace  CoveritySafe

Enumerations

enum  DataSource { ROD_VALID , ROD_DB_ONLY , ROD_MC_ONLY , ROD_INVALID }

Functions

const std::string XmlHeader ("<?xml version=\"1.0\"?>")
const std::string OpenRootTag ("<SCT_textFile>")
const std::string OpenRodMappingTag ("<textList name=\"SCT Rod-Rob mapping\" headings=\"RodId RobId\">")
const std::string CloseRodMappingTag ("</textList>")
const std::string OpenModuleMappingTag ("<textList name=\"SCT cabling mapping\" headings=\"Rod Fibre Bec LayerDisk Eta Phi Side RobId Sn\">")
const std::string CloseModuleMappingTag ("</textList>")
const std::string CloseRootTag ("</SCT_textFile>")
std::string intToHex (const unsigned int i)
std::string formatRodOutput (const unsigned int rodNum)
std::string formatModuleOutput (const unsigned int rod, const unsigned int fibre, const int bec, const int layerDisk, const int eta, const int phi, const int side, const int robId, const std::string &fullsn)
std::string dateTime ()
std::string makeCablingFileName ()
DataSource onlineIdType (const unsigned int rodId)
Utility functions for this unit
int stringToInt (const std::string &hexOrDecString)
 Convert a string (decimal or hex) to an int; -1 indicates an error.
bool inRange (const int value, const int lowerBound, const int upperBound, const std::string &valueName)
 Check range and give error if out of range.
int calculateLink (const int MURorder, const int ModID, const int theSide, const bool isSwapped=false)
 calculate link, normal and swapped (from Kondo)

Enumeration Type Documentation

◆ DataSource

Enumerator
ROD_VALID 
ROD_DB_ONLY 
ROD_MC_ONLY 
ROD_INVALID 

Definition at line 18 of file SCT_OnlineIdType.h.

Function Documentation

◆ calculateLink()

int SCT_Cabling::calculateLink ( const int MURorder,
const int ModID,
const int theSide,
const bool isSwapped = false )

calculate link, normal and swapped (from Kondo)

Definition at line 55 of file SCT_CablingUtilities.cxx.

55 {
56 return isSwapped?(MURorder*12 + (5 - ModID) * 2 + (theSide)):(MURorder*12 + ModID * 2 + theSide);
57 }

◆ CloseModuleMappingTag()

const std::string SCT_Cabling::CloseModuleMappingTag ( "</textList>" )

◆ CloseRodMappingTag()

const std::string SCT_Cabling::CloseRodMappingTag ( "</textList>" )

◆ CloseRootTag()

const std::string SCT_Cabling::CloseRootTag ( "</SCT_textFile>" )

◆ dateTime()

std::string SCT_Cabling::dateTime ( )

Definition at line 54 of file SCT_CablingXmlTags.h.

54 {
55 std::stringstream ss;
56 std::time_t t = std::time(nullptr);
57 std::tm lt;
58 ss << std::put_time(localtime_r(&t, &lt), "%Y-%m-%d %X");
59 return ss.str();
60 }
static Double_t ss

◆ formatModuleOutput()

std::string SCT_Cabling::formatModuleOutput ( const unsigned int rod,
const unsigned int fibre,
const int bec,
const int layerDisk,
const int eta,
const int phi,
const int side,
const int robId,
const std::string & fullsn )

Definition at line 44 of file SCT_CablingXmlTags.h.

46 {
47 const std::string sep(" ");
48 using std::to_string;
49 std::string result= to_string(rod)+sep+to_string(fibre)+sep+to_string(bec)+sep+to_string(layerDisk)+sep;
50 result+=(to_string(eta)+sep+to_string(phi)+sep+to_string(side)+sep+SCT_Cabling::intToHex(robId)+sep+fullsn);
51 return result;
52 }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
static std::string to_string(const std::vector< T > &v)
std::string intToHex(const unsigned int i)

◆ formatRodOutput()

std::string SCT_Cabling::formatRodOutput ( const unsigned int rodNum)

Definition at line 38 of file SCT_CablingXmlTags.h.

38 {
39 const std::string rodString(SCT_Cabling::intToHex(rodNum));
40 const std::string sep(" ");
41 return rodString+sep+rodString;
42 }

◆ inRange()

bool SCT_Cabling::inRange ( const int value,
const int lowerBound,
const int upperBound,
const std::string & valueName )

Check range and give error if out of range.

Definition at line 45 of file SCT_CablingUtilities.cxx.

45 {
46 bool bad= ( (value > upperBound) or (value<lowerBound) );
47 if (bad){
48 std::string name = valueName.empty()?"The value":valueName;
49 std::cerr<<name<<" = "<<value<<" is out of the allowable range."<<std::endl;
50 }
51 return (not bad);
52 }

◆ intToHex()

std::string SCT_Cabling::intToHex ( const unsigned int i)

Definition at line 32 of file SCT_CablingXmlTags.h.

32 {
33 std::stringstream stream;
34 stream << "0x" << std::setfill ('0') << std::setw(6) << std::hex << i;
35 return stream.str();
36 }

◆ makeCablingFileName()

std::string SCT_Cabling::makeCablingFileName ( )

Definition at line 61 of file SCT_CablingXmlTags.h.

61 {
62 const std::string prefix("SCT_");
63 const std::string suffix("Cabling_svc.dat");
64 const std::string meat(SCT_Cabling::dateTime());
65 return prefix+meat+suffix;
66 }
std::string dateTime()

◆ onlineIdType()

DataSource SCT_Cabling::onlineIdType ( const unsigned int rodId)

Definition at line 12 of file SCT_OnlineIdType.cxx.

12 {
13 const unsigned int rod(rodId & 0xFFFFFF);
14 using UintSet = std::set<unsigned int>;
15 // set of rod ids used in data and in montecarlo
16 const UintSet commonSet={0x210000, 0x210001, 0x210002, 0x210003, 0x210004, 0x210005, 0x210006,
17 0x210007, 0x210008, 0x210009, 0x21000a, 0x220000, 0x220001, 0x220002, 0x220003, 0x220004,
18 0x220005, 0x220006, 0x220007, 0x220008, 0x220009, 0x22000a, 0x230000, 0x230001, 0x230002,
19 0x230003, 0x230004, 0x230005, 0x230006, 0x230007, 0x230008, 0x230009, 0x23000a, 0x240000,
20 0x240001, 0x240002, 0x240003, 0x240004, 0x240005, 0x240006, 0x240007, 0x240008, 0x240009,
21 0x24000a, 0x24000b};
22 const UintSet::const_iterator notFoundInCommon(commonSet.end());
23 //
24 // set of rods unique to usage in the database-derived cabling
25 const UintSet dbSet={0x210100, 0x210101, 0x210102, 0x210103, 0x210104, 0x210105, 0x210106,
26 0x210107, 0x210108, 0x210109, 0x21010a, 0x220100, 0x220101, 0x220102, 0x220103, 0x220104,
27 0x220105, 0x220106, 0x220107, 0x220108, 0x220109, 0x22010a, 0x230100, 0x230101, 0x230102,
28 0x230103, 0x230104, 0x230105, 0x230106, 0x230107, 0x230108, 0x230109, 0x23010a, 0x23010b,
29 0x240100, 0x240101, 0x240102, 0x240103, 0x240104, 0x240105, 0x240106, 0x240107, 0x240108,
30 0x240109, 0x24010a};
31 const UintSet::const_iterator notFoundInDb(dbSet.end());
32 //
33 // set of rod Ids which are unique to usage in old montecarlo files with cabling derived from text file
34 const UintSet mcSet={ 0x21000b, 0x21000c, 0x21000d, 0x21000e, 0x21000f, 0x210010, 0x210011, 0x210012, 0x210013,
35 0x210014, 0x210015, 0x22000b, 0x22000c, 0x22000d, 0x22000e, 0x22000f, 0x220010, 0x220011,
36 0x220012, 0x220013, 0x220014, 0x220015, 0x23000b, 0x23000c, 0x23000d, 0x23000e, 0x23000f,
37 0x230010, 0x230011, 0x230012, 0x230013, 0x230014, 0x24000c, 0x24000d, 0x24000e, 0x24000f,
38 0x240010, 0x240011, 0x240012, 0x240013, 0x240014};
39 const UintSet::const_iterator notFoundInMc(mcSet.end());
41 if (commonSet.find(rod) == notFoundInCommon){
42 //the rod is not among the rods which are common to db and mc, so look at those unique to db
43 if (dbSet.find(rod) == notFoundInDb){
44 //the rod is not in common or the db list, so look in mc list
45 if (mcSet.find(rod) == notFoundInMc){
46 //didnt find the rod anywhere
48 } else {
49 //found the rod in mc
51 }
52 } else {
53 //rod found in those unique to db
55 }
56 }else{
57 //rod was in the common list of rods
59 }
60 return result;
61 }//end of function definition

◆ OpenModuleMappingTag()

const std::string SCT_Cabling::OpenModuleMappingTag ( "<textList name=\"SCT cabling mapping\" headings=\"Rod Fibre Bec LayerDisk Eta Phi Side RobId Sn\">" )

◆ OpenRodMappingTag()

const std::string SCT_Cabling::OpenRodMappingTag ( "<textList name=\"SCT Rod-Rob mapping\" headings=\"RodId RobId\">" )

◆ OpenRootTag()

const std::string SCT_Cabling::OpenRootTag ( "<SCT_textFile>" )

◆ stringToInt()

int SCT_Cabling::stringToInt ( const std::string & hexOrDecString)

Convert a string (decimal or hex) to an int; -1 indicates an error.

Definition at line 20 of file SCT_CablingUtilities.cxx.

20 {
21 std::istringstream istrm(hexOrDecString);
22 int result(-1);
23 //enable exceptions for a badly formatted string
24 istrm.exceptions(std::ios_base::badbit|std::ios_base::failbit);
25 //do conversion if the string is not empty
26 if (not hexOrDecString.empty()){
27 try{
28 bool numberIsHex = (hexOrDecString.find('x') not_eq std::string::npos) or (hexOrDecString.find('X') not_eq std::string::npos);
29 if(numberIsHex){
30 istrm>>std::hex>>result;
31 } else {
32 istrm>>std::dec>>result;
33 }
34 } catch (const std::ios_base::failure&){ //bad conversion to int
35 result=-1;
36 //need to throw here
37 std::cerr<<"stringToInt failed to convert a string to an integer in InDetCabling/SCT_CablingUtilities"<<std::endl;
38 throw(std::ios_base::failure("stringToInt failure in SCT_CablingUtilities"));
39 }
40 }
41 return result;
42 }

◆ XmlHeader()

const std::string SCT_Cabling::XmlHeader ( "<?xml version=\"1.0\"?>" )