CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PixelToFEDAssociateFromAscii Class Reference

#include <PixelToFEDAssociateFromAscii.h>

Inheritance diagram for PixelToFEDAssociateFromAscii:
PixelToFEDAssociate

Classes

struct  Bdu
 
struct  Edu
 

Public Member Functions

int operator() (const PixelModuleName &) const override
 FED id for module. More...
 
int operator() (const PixelBarrelName &) const
 FED id to which barrel modul (identified by name) should be assigned. More...
 
int operator() (const PixelEndcapName &) const
 FED id to which endcape modul (identified by name) should be assigned. More...
 
 PixelToFEDAssociateFromAscii (const std::string &fileName)
 
std::string version () const override
 version More...
 
- Public Member Functions inherited from PixelToFEDAssociate
virtual const CablingRocIdoperator() (const DetectorRocId &roc) const
 LNK id for module. More...
 
virtual ~PixelToFEDAssociate ()
 

Private Types

typedef std::vector< std::pair< int, std::vector< Bdu > > > BarrelConnections
 
typedef std::vector< std::pair< int, std::vector< Edu > > > EndcapConnections
 
typedef TRange< int > Range
 

Private Member Functions

Bdu getBdu (std::string) const
 
Edu getEdu (std::string) const
 
void init (const std::string &fileName)
 initialisatin (read file) More...
 
Range readRange (const std::string &) const
 
void send (std::pair< int, std::vector< Bdu > > &, std::pair< int, std::vector< Edu > > &)
 initialisation (read input file) More...
 

Private Attributes

BarrelConnections theBarrel
 
EndcapConnections theEndcap
 
std::string theVersion
 

Detailed Description

Check to which FED pixel module belongs to. The associacions are read from the datafile

Definition at line 19 of file PixelToFEDAssociateFromAscii.h.

Member Typedef Documentation

◆ BarrelConnections

typedef std::vector<std::pair<int, std::vector<Bdu> > > PixelToFEDAssociateFromAscii::BarrelConnections
private

Definition at line 57 of file PixelToFEDAssociateFromAscii.h.

◆ EndcapConnections

typedef std::vector<std::pair<int, std::vector<Edu> > > PixelToFEDAssociateFromAscii::EndcapConnections
private

Definition at line 58 of file PixelToFEDAssociateFromAscii.h.

◆ Range

Definition at line 39 of file PixelToFEDAssociateFromAscii.h.

Constructor & Destructor Documentation

◆ PixelToFEDAssociateFromAscii()

PixelToFEDAssociateFromAscii::PixelToFEDAssociateFromAscii ( const std::string &  fileName)

Definition at line 13 of file PixelToFEDAssociateFromAscii.cc.

References personalPlayback::fn, and init.

13 { init(fn); }
void init(const std::string &fileName)
initialisatin (read file)

Member Function Documentation

◆ getBdu()

PixelToFEDAssociateFromAscii::Bdu PixelToFEDAssociateFromAscii::getBdu ( std::string  ) const
private

Definition at line 149 of file PixelToFEDAssociateFromAscii.cc.

References mps_splice::line, and mps_fire::result.

149  {
150  Bdu result;
152 
153  result.b = readRange(line).first;
154 
155  pos = line.find("L:");
156  if (pos != string::npos)
157  line = line.substr(pos + 2);
158  result.l = readRange(line);
159 
160  pos = line.find("Z:");
161  if (pos != string::npos)
162  line = line.substr(pos + 2);
163  result.z = readRange(line);
164 
165  pos = line.find("F:");
166  if (pos != string::npos)
167  line = line.substr(pos + 2);
168  result.f = readRange(line);
169 
170  return result;
171 }
uint16_t size_type
Range readRange(const std::string &) const

◆ getEdu()

PixelToFEDAssociateFromAscii::Edu PixelToFEDAssociateFromAscii::getEdu ( std::string  ) const
private

Definition at line 173 of file PixelToFEDAssociateFromAscii.cc.

References mps_splice::line, and mps_fire::result.

173  {
174  Edu result;
176 
177  result.e = readRange(line).first;
178 
179  pos = line.find("D:");
180  if (pos != string::npos)
181  line = line.substr(pos + 2);
182  result.d = readRange(line);
183 
184  pos = line.find("B:");
185  if (pos != string::npos)
186  line = line.substr(pos + 2);
187  result.b = readRange(line);
188 
189  return result;
190 }
uint16_t size_type
Range readRange(const std::string &) const

◆ init()

void PixelToFEDAssociateFromAscii::init ( const std::string &  fileName)
private

initialisatin (read file)

Definition at line 44 of file PixelToFEDAssociateFromAscii.cc.

References submitPVResolutionJobs::err, cppFunctionSkipper::exception, geometryDiff::file, EcalPhiSymFlatTableProducers_cfi::id, mps_splice::line, LogDebug, and str.

44  {
45  LogDebug("init, input file:") << cfg_name.c_str();
46 
47  std::ifstream file(cfg_name.c_str());
48  if (!file) {
49  edm::LogError(" ** PixelToFEDAssociateFromAscii,init ** ") << " cant open data file: " << cfg_name;
50  return;
51  } else {
52  edm::LogInfo("PixelToFEDAssociateFromAscii, read data from: ") << cfg_name;
53  }
54 
55  string line;
56  pair<int, vector<Bdu> > barCon;
57  pair<int, vector<Edu> > endCon;
58 
59  try {
60  while (getline(file, line)) {
61  //
62  // treat # lines
63  //
64  string::size_type pos = line.find('#');
65  if (pos != string::npos)
66  line = line.erase(pos);
67 
68  string::size_type posF = line.find("FED:");
69  string::size_type posB = line.find("S:");
70  string::size_type posE = line.find("E:");
71 
72  LogDebug("line read") << line;
73 
74  //
75  // treat version lines, reset date
76  //
77  if (line.compare(0, 3, "VER") == 0) {
78  edm::LogInfo("version: ") << line;
79  theVersion = line;
80  send(barCon, endCon);
81  theBarrel.clear();
82  theEndcap.clear();
83  }
84 
85  //
86  // fed id line
87  //
88  else if (posF != string::npos) {
89  line = line.substr(posF + 4);
90  int id = atoi(line.c_str());
91  send(barCon, endCon);
92  barCon.first = id;
93  endCon.first = id;
94  }
95 
96  //
97  // barrel connections
98  //
99  else if (posB != string::npos) {
100  line = line.substr(posB + 2);
101  barCon.second.push_back(getBdu(line));
102  }
103 
104  //
105  // endcap connections
106  //
107  else if (posE != string::npos) {
108  line = line.substr(posE + 2);
109  endCon.second.push_back(getEdu(line));
110  }
111  }
112  send(barCon, endCon);
113  } catch (exception& err) {
114  edm::LogError("**PixelToFEDAssociateFromAscii** exception") << err.what();
115  theBarrel.clear();
116  theEndcap.clear();
117  }
118 
119  //
120  // for debug
121  //
122  std::ostringstream str;
123  str << " **PixelToFEDAssociateFromAscii ** BARREL FED CONNECTIONS: " << endl;
124  for (BarrelConnections::const_iterator ibc = theBarrel.begin(); ibc != theBarrel.end(); ibc++) {
125  str << "FED: " << ibc->first << endl;
126  for (vector<Bdu>::const_iterator ibd = (*ibc).second.begin(); ibd != (*ibc).second.end(); ibd++) {
127  str << "b: " << ibd->b << " l: " << ibd->l << " z: " << ibd->z << " f: " << ibd->f << endl;
128  }
129  }
130  str << " **PixelToFEDAssociateFromAscii ** ENDCAP FED CONNECTIONS: " << endl;
131  for (EndcapConnections::const_iterator iec = theEndcap.begin(); iec != theEndcap.end(); iec++) {
132  str << "FED: " << iec->first << endl;
133  for (vector<Edu>::const_iterator ied = (*iec).second.begin(); ied != (*iec).second.end(); ied++) {
134  str << " e: " << ied->e << " d: " << ied->d << " b: " << ied->b << endl;
135  }
136  }
137  edm::LogInfo("PixelToFEDAssociateFromAscii") << str.str();
138 }
Log< level::Error, false > LogError
uint16_t size_type
Log< level::Info, false > LogInfo
void send(std::pair< int, std::vector< Bdu > > &, std::pair< int, std::vector< Edu > > &)
initialisation (read input file)
#define str(s)
#define LogDebug(id)

◆ operator()() [1/3]

int PixelToFEDAssociateFromAscii::operator() ( const PixelModuleName id) const
overridevirtual

FED id for module.

Reimplemented from PixelToFEDAssociate.

Definition at line 16 of file PixelToFEDAssociateFromAscii.cc.

16  {
17  return id.isBarrel() ? operator()(dynamic_cast<const PixelBarrelName&>(id))
18  : operator()(dynamic_cast<const PixelEndcapName&>(id));
19 }
int operator()(const PixelModuleName &) const override
FED id for module.

◆ operator()() [2/3]

int PixelToFEDAssociateFromAscii::operator() ( const PixelBarrelName id) const

FED id to which barrel modul (identified by name) should be assigned.

Definition at line 21 of file PixelToFEDAssociateFromAscii.cc.

References EcalCalibMonitorClient_cfi::moduleName.

21  {
22  for (BarrelConnections::const_iterator ibc = theBarrel.begin(); ibc != theBarrel.end(); ibc++) {
23  for (vector<Bdu>::const_iterator ibd = (*ibc).second.begin(); ibd != (*ibc).second.end(); ibd++) {
24  if (ibd->b == id.shell() && ibd->l.inside(id.layerName()) && ibd->z.inside(id.moduleName()) &&
25  ibd->f.inside(id.ladderName()))
26  return (*ibc).first;
27  }
28  }
29  edm::LogError("** PixelToFEDAssociateFromAscii WARNING, name: ") << id.name() << " not associated to FED";
30  return -1;
31 }
Log< level::Error, false > LogError

◆ operator()() [3/3]

int PixelToFEDAssociateFromAscii::operator() ( const PixelEndcapName id) const

FED id to which endcape modul (identified by name) should be assigned.

Definition at line 33 of file PixelToFEDAssociateFromAscii.cc.

33  {
34  for (EndcapConnections::const_iterator iec = theEndcap.begin(); iec != theEndcap.end(); iec++) {
35  for (vector<Edu>::const_iterator ied = (*iec).second.begin(); ied != (*iec).second.end(); ied++) {
36  if (ied->e == id.halfCylinder() && ied->d.inside(id.diskName()) && ied->b.inside(id.bladeName()))
37  return iec->first;
38  }
39  }
40  edm::LogError("** PixelToFEDAssociateFromAscii WARNING, name: ") << id.name() << " not associated to FED";
41  return -1;
42 }
Log< level::Error, false > LogError

◆ readRange()

PixelToFEDAssociateFromAscii::Range PixelToFEDAssociateFromAscii::readRange ( const std::string &  ) const
private

Definition at line 192 of file PixelToFEDAssociateFromAscii.cc.

References Exception, dqmdumpme::first, MainPageGenerator::l, mps_splice::line, LogDebug, EgammaValidation_cff::num, and alignCSCRings::s.

192  {
193  bool first = true;
194  int num1 = -1;
195  int num2 = -1;
196  const char* line = l.c_str();
197  while (line) {
198  char* evp = nullptr;
199  int num = strtol(line, &evp, 10);
200  {
201  stringstream s;
202  s << "raad from line: ";
203  s << num;
204  LogDebug(s.str());
205  }
206  if (evp != line) {
207  line = evp + 1;
208  if (first) {
209  num1 = num;
210  first = false;
211  }
212  num2 = num;
213  } else
214  line = nullptr;
215  }
216  if (first) {
217  string s = "** PixelToFEDAssociateFromAscii, read data, cant intrpret: ";
218  edm::LogInfo(s) << endl << l << endl << "=====> send exception " << endl;
219  s += l;
220  throw cms::Exception(s);
221  }
222  return Range(num1, num2);
223 }
Log< level::Info, false > LogInfo
#define LogDebug(id)

◆ send()

void PixelToFEDAssociateFromAscii::send ( std::pair< int, std::vector< Bdu > > &  b,
std::pair< int, std::vector< Edu > > &  e 
)
private

initialisation (read input file)

Definition at line 140 of file PixelToFEDAssociateFromAscii.cc.

References b, and MillePedeFileConverter_cfg::e.

140  {
141  if (!b.second.empty())
142  theBarrel.push_back(b);
143  if (!e.second.empty())
144  theEndcap.push_back(e);
145  b.second.clear();
146  e.second.clear();
147 }
double b
Definition: hdecay.h:120

◆ version()

std::string PixelToFEDAssociateFromAscii::version ( ) const
overridevirtual

Member Data Documentation

◆ theBarrel

BarrelConnections PixelToFEDAssociateFromAscii::theBarrel
private

Definition at line 59 of file PixelToFEDAssociateFromAscii.h.

◆ theEndcap

EndcapConnections PixelToFEDAssociateFromAscii::theEndcap
private

Definition at line 60 of file PixelToFEDAssociateFromAscii.h.

◆ theVersion

std::string PixelToFEDAssociateFromAscii::theVersion
private

Definition at line 63 of file PixelToFEDAssociateFromAscii.h.