CMS 3D CMS Logo

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

#include <PixelToFEDAssociateFromAscii.h>

Inheritance diagram for PixelToFEDAssociateFromAscii:
PixelToFEDAssociate

Classes

struct  Bdu
 
struct  Edu
 

Public Member Functions

virtual int operator() (const PixelModuleName &) const
 FED id for module. More...
 
virtual int operator() (const PixelBarrelName &) const
 FED id to which barrel modul (identified by name) should be assigned. More...
 
virtual int operator() (const PixelEndcapName &) const
 FED id to which endcape modul (identified by name) should be assigned. More...
 
 PixelToFEDAssociateFromAscii (const std::string &fileName)
 
virtual std::string version () const
 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 > > &) const
 initialisation (read input file) More...
 

Private Attributes

std::string theVersion
 

Static Private Attributes

static BarrelConnections theBarrel = PixelToFEDAssociateFromAscii::BarrelConnections()
 
static EndcapConnections theEndcap = PixelToFEDAssociateFromAscii::EndcapConnections()
 

Detailed Description

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

Definition at line 21 of file PixelToFEDAssociateFromAscii.h.

Member Typedef Documentation

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

Definition at line 54 of file PixelToFEDAssociateFromAscii.h.

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

Definition at line 55 of file PixelToFEDAssociateFromAscii.h.

Definition at line 44 of file PixelToFEDAssociateFromAscii.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file PixelToFEDAssociateFromAscii.cc.

References init.

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

Member Function Documentation

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

Definition at line 180 of file PixelToFEDAssociateFromAscii.cc.

References PixelToFEDAssociateFromAscii::Bdu::b, PixelToFEDAssociateFromAscii::Bdu::f, PixelToFEDAssociateFromAscii::Bdu::l, pos, query::result, and PixelToFEDAssociateFromAscii::Bdu::z.

181 {
182  Bdu result;
184 
185  result.b = readRange(line).first;
186 
187  pos = line.find("L:");
188  if (pos != string::npos) line = line.substr(pos+2);
189  result.l = readRange(line);
190 
191  pos = line.find("Z:");
192  if (pos != string::npos) line = line.substr(pos+2);
193  result.z = readRange(line);
194 
195  pos = line.find("F:");
196  if (pos != string::npos) line = line.substr(pos+2);
197  result.f = readRange(line);
198 
199  return result;
200 }
Range readRange(const std::string &) const
uint16_t size_type
tuple result
Definition: query.py:137
PixelToFEDAssociateFromAscii::Edu PixelToFEDAssociateFromAscii::getEdu ( std::string  ) const
private

Definition at line 202 of file PixelToFEDAssociateFromAscii.cc.

References PixelToFEDAssociateFromAscii::Edu::b, PixelToFEDAssociateFromAscii::Edu::d, PixelToFEDAssociateFromAscii::Edu::e, pos, and query::result.

203 {
204  Edu result;
206 
207  result.e = readRange(line).first;
208 
209  pos = line.find("D:");
210  if (pos != string::npos) line = line.substr(pos+2);
211  result.d = readRange(line);
212 
213  pos = line.find("B:");
214  if (pos != string::npos) line = line.substr(pos+2);
215  result.b = readRange(line);
216 
217  return result;
218 }
Range readRange(const std::string &) const
uint16_t size_type
tuple result
Definition: query.py:137
void PixelToFEDAssociateFromAscii::init ( const std::string &  fileName)
private

initialisatin (read file)

Definition at line 69 of file PixelToFEDAssociateFromAscii.cc.

References cppFunctionSkipper::exception, mergeVDriftHistosByStation::file, geometryCSVtoXML::line, LogDebug, and pos.

70 {
71  LogDebug("init, input file:") << cfg_name.c_str();
72 
73  std::ifstream file( cfg_name.c_str() );
74  if ( !file ) {
75  edm::LogError(" ** PixelToFEDAssociateFromAscii,init ** ")
76  << " cant open data file: " << cfg_name;
77  return;
78  } else {
79  edm::LogInfo("PixelToFEDAssociateFromAscii, read data from: ") <<cfg_name ;
80  }
81 
82  string line;
83  pair< int, vector<Bdu> > barCon;
84  pair< int, vector<Edu> > endCon;
85 
86  try {
87  while (getline(file,line)) {
88  //
89  // treat # lines
90  //
91  string::size_type pos = line.find("#");
92  if (pos != string::npos) line = line.erase(pos);
93 
94  string::size_type posF = line.find("FED:");
95  string::size_type posB = line.find("S:");
96  string::size_type posE = line.find("E:");
97 
98  LogDebug ( "line read" ) << line;
99 
100  //
101  // treat version lines, reset date
102  //
103  if ( line.compare(0,3,"VER") == 0 ) {
104  edm::LogInfo("version: ")<<line;
105  theVersion = line;
106  send(barCon,endCon);
107  theBarrel.clear();
108  theEndcap.clear();
109  }
110 
111  //
112  // fed id line
113  //
114  else if ( posF != string::npos) {
115  line = line.substr(posF+4);
116  int id = atoi(line.c_str());
117  send(barCon,endCon);
118  barCon.first = id;
119  endCon.first = id;
120  }
121 
122  //
123  // barrel connections
124  //
125  else if ( posB != string::npos) {
126  line = line.substr(posB+2);
127  barCon.second.push_back( getBdu(line) );
128  }
129 
130  //
131  // endcap connections
132  //
133  else if ( posE != string::npos) {
134  line = line.substr(posE+2);
135  endCon.second.push_back( getEdu(line) );
136  }
137  }
138  send(barCon,endCon);
139  }
140  catch(exception& err) {
141  edm::LogError("**PixelToFEDAssociateFromAscii** exception")<<err.what();
142  theBarrel.clear();
143  theEndcap.clear();
144  }
145 
146  //
147  // for debug
148  //
149  std::ostringstream str;
150  str <<" **PixelToFEDAssociateFromAscii ** BARREL FED CONNECTIONS: "<< endl;
151  for (BarrelConnections::const_iterator
152  ibc = theBarrel.begin(); ibc != theBarrel.end(); ibc++) {
153  str << "FED: " << ibc->first << endl;
154  for (vector<Bdu>::const_iterator
155  ibd = (*ibc).second.begin(); ibd != (*ibc).second.end(); ibd++) {
156  str << "b: "<<ibd->b<<" l: "<<ibd->l<<" z: "<<ibd->z<<" f: "<<ibd->f<<endl;
157  }
158  }
159  str <<" **PixelToFEDAssociateFromAscii ** ENDCAP FED CONNECTIONS: " << endl;
160  for (EndcapConnections::const_iterator
161  iec = theEndcap.begin(); iec != theEndcap.end(); iec++) {
162  str << "FED: " << iec->first << endl;
163  for (vector<Edu>::const_iterator
164  ied = (*iec).second.begin(); ied != (*iec).second.end(); ied++) {
165  str << " e: "<<ied->e<<" d: "<<ied->d<<" b: "<<ied->b<<endl;
166  }
167  }
168  edm::LogInfo("PixelToFEDAssociateFromAscii")<<str.str();
169 }
#define LogDebug(id)
uint16_t size_type
void send(std::pair< int, std::vector< Bdu > > &, std::pair< int, std::vector< Edu > > &) const
initialisation (read input file)
int PixelToFEDAssociateFromAscii::operator() ( const PixelModuleName id) const
virtual

FED id for module.

Reimplemented from PixelToFEDAssociate.

Definition at line 28 of file PixelToFEDAssociateFromAscii.cc.

29 {
30  return id.isBarrel() ?
31  operator()(dynamic_cast<const PixelBarrelName & >(id)) :
32  operator()(dynamic_cast<const PixelEndcapName & >(id)) ;
33 }
string const
Definition: compareJSON.py:14
virtual int operator()(const PixelModuleName &) const
FED id for module.
int PixelToFEDAssociateFromAscii::operator() ( const PixelBarrelName id) const
virtual

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

Definition at line 35 of file PixelToFEDAssociateFromAscii.cc.

36 {
37  for (BarrelConnections::const_iterator
38  ibc = theBarrel.begin(); ibc != theBarrel.end(); ibc++) {
39  for (vector<Bdu>::const_iterator
40  ibd = (*ibc).second.begin(); ibd != (*ibc).second.end(); ibd++) {
41  if ( ibd->b == id.shell()
42  && ibd->l.inside( id.layerName() )
43  && ibd->z.inside( id.moduleName() )
44  && ibd->f.inside( id.ladderName() ) ) return (*ibc).first;
45  }
46  }
47  edm::LogError("** PixelToFEDAssociateFromAscii WARNING, name: ")
48  << id.name()<<" not associated to FED";
49  return -1;
50 }
int PixelToFEDAssociateFromAscii::operator() ( const PixelEndcapName id) const
virtual

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

Definition at line 52 of file PixelToFEDAssociateFromAscii.cc.

53 {
54  for (EndcapConnections::const_iterator
55  iec = theEndcap.begin(); iec != theEndcap.end(); iec++) {
56  for (vector<Edu>::const_iterator
57  ied = (*iec).second.begin(); ied != (*iec).second.end(); ied++) {
58  if ( ied->e == id.halfCylinder()
59  && ied->d.inside( id.diskName() )
60  && ied->b.inside( id.bladeName() ) ) return iec->first;
61  }
62  }
63  edm::LogError("** PixelToFEDAssociateFromAscii WARNING, name: ")
64  << id.name()<<" not associated to FED";
65  return -1;
66 }
PixelToFEDAssociateFromAscii::Range PixelToFEDAssociateFromAscii::readRange ( const std::string &  ) const
private

Definition at line 221 of file PixelToFEDAssociateFromAscii.cc.

References edm::hlt::Exception, first, prof2calltree::l, geometryCSVtoXML::line, LogDebug, and alignCSCRings::s.

222 {
223  bool first = true;
224  int num1 = -1;
225  int num2 = -1;
226  const char * line = l.c_str();
227  while (line) {
228  char * evp = 0;
229  int num = strtol(line, &evp, 10);
230  { stringstream s; s<<"raad from line: "; s<<num; LogDebug(s.str()); }
231  if (evp != line) {
232  line = evp +1;
233  if (first) { num1 = num; first = false; }
234  num2 = num;
235  } else line = 0;
236  }
237  if (first) {
238  string s = "** PixelToFEDAssociateFromAscii, read data, cant intrpret: " ;
239  edm::LogInfo(s) << endl
240  << l << endl
241  <<"=====> send exception " << endl;
242  s += l;
243  throw cms::Exception(s);
244  }
245  return Range(num1,num2);
246 }
#define LogDebug(id)
bool first
Definition: L1TdeRCT.cc:94
long long int num
Definition: procUtils.cc:71
void PixelToFEDAssociateFromAscii::send ( std::pair< int, std::vector< Bdu > > &  b,
std::pair< int, std::vector< Edu > > &  e 
) const
private

initialisation (read input file)

Definition at line 171 of file PixelToFEDAssociateFromAscii.cc.

References b, and alignCSCRings::e.

173 {
174  if (b.second.size() > 0) theBarrel.push_back(b);
175  if (e.second.size() > 0) theEndcap.push_back(e);
176  b.second.clear();
177  e.second.clear();
178 }
double b
Definition: hdecay.h:120
std::string PixelToFEDAssociateFromAscii::version ( ) const
virtual

version

Implements PixelToFEDAssociate.

Definition at line 23 of file PixelToFEDAssociateFromAscii.cc.

24 {
25  return theVersion;
26 }

Member Data Documentation

Definition at line 56 of file PixelToFEDAssociateFromAscii.h.

Definition at line 57 of file PixelToFEDAssociateFromAscii.h.

std::string PixelToFEDAssociateFromAscii::theVersion
private

Definition at line 61 of file PixelToFEDAssociateFromAscii.h.