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
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 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)
 
virtual 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 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 14 of file PixelToFEDAssociateFromAscii.cc.

References init.

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

Member Function Documentation

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

Definition at line 174 of file PixelToFEDAssociateFromAscii.cc.

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

175 {
176  Bdu result;
177  string::size_type pos;
178 
179  result.b = readRange(line).first;
180 
181  pos = line.find("L:");
182  if (pos != string::npos) line = line.substr(pos+2);
183  result.l = readRange(line);
184 
185  pos = line.find("Z:");
186  if (pos != string::npos) line = line.substr(pos+2);
187  result.z = readRange(line);
188 
189  pos = line.find("F:");
190  if (pos != string::npos) line = line.substr(pos+2);
191  result.f = readRange(line);
192 
193  return result;
194 }
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 196 of file PixelToFEDAssociateFromAscii.cc.

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

197 {
198  Edu result;
199  string::size_type pos;
200 
201  result.e = readRange(line).first;
202 
203  pos = line.find("D:");
204  if (pos != string::npos) line = line.substr(pos+2);
205  result.d = readRange(line);
206 
207  pos = line.find("B:");
208  if (pos != string::npos) line = line.substr(pos+2);
209  result.b = readRange(line);
210 
211  return result;
212 }
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 63 of file PixelToFEDAssociateFromAscii.cc.

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

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

FED id for module.

Reimplemented from PixelToFEDAssociate.

Definition at line 22 of file PixelToFEDAssociateFromAscii.cc.

23 {
24  return id.isBarrel() ?
25  operator()(dynamic_cast<const PixelBarrelName & >(id)) :
26  operator()(dynamic_cast<const PixelEndcapName & >(id)) ;
27 }
string const
Definition: compareJSON.py:14
virtual int operator()(const PixelModuleName &) const override
FED id for module.
int PixelToFEDAssociateFromAscii::operator() ( const PixelBarrelName id) const

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

Definition at line 29 of file PixelToFEDAssociateFromAscii.cc.

References edm::moduleName().

30 {
31  for (BarrelConnections::const_iterator
32  ibc = theBarrel.begin(); ibc != theBarrel.end(); ibc++) {
33  for (vector<Bdu>::const_iterator
34  ibd = (*ibc).second.begin(); ibd != (*ibc).second.end(); ibd++) {
35  if ( ibd->b == id.shell()
36  && ibd->l.inside( id.layerName() )
37  && ibd->z.inside( id.moduleName() )
38  && ibd->f.inside( id.ladderName() ) ) return (*ibc).first;
39  }
40  }
41  edm::LogError("** PixelToFEDAssociateFromAscii WARNING, name: ")
42  << id.name()<<" not associated to FED";
43  return -1;
44 }
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
int PixelToFEDAssociateFromAscii::operator() ( const PixelEndcapName id) const

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

Definition at line 46 of file PixelToFEDAssociateFromAscii.cc.

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

Definition at line 215 of file PixelToFEDAssociateFromAscii.cc.

References Exception, plotBeamSpotDB::first, prof2calltree::l, geometryCSVtoXML::line, LogDebug, pileupDistInMC::num, and alignCSCRings::s.

216 {
217  bool first = true;
218  int num1 = -1;
219  int num2 = -1;
220  const char * line = l.c_str();
221  while (line) {
222  char * evp = 0;
223  int num = strtol(line, &evp, 10);
224  { stringstream s; s<<"raad from line: "; s<<num; LogDebug(s.str()); }
225  if (evp != line) {
226  line = evp +1;
227  if (first) { num1 = num; first = false; }
228  num2 = num;
229  } else line = 0;
230  }
231  if (first) {
232  string s = "** PixelToFEDAssociateFromAscii, read data, cant intrpret: " ;
233  edm::LogInfo(s) << endl
234  << l << endl
235  <<"=====> send exception " << endl;
236  s += l;
237  throw cms::Exception(s);
238  }
239  return Range(num1,num2);
240 }
#define LogDebug(id)
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 165 of file PixelToFEDAssociateFromAscii.cc.

References b, and alignCSCRings::e.

167 {
168  if (b.second.size() > 0) theBarrel.push_back(b);
169  if (e.second.size() > 0) theEndcap.push_back(e);
170  b.second.clear();
171  e.second.clear();
172 }
double b
Definition: hdecay.h:120
std::string PixelToFEDAssociateFromAscii::version ( ) const
overridevirtual

version

Implements PixelToFEDAssociate.

Definition at line 17 of file PixelToFEDAssociateFromAscii.cc.

Referenced by validation.Sample::datasetpattern(), and validation.Sample::filename().

18 {
19  return theVersion;
20 }

Member Data Documentation

BarrelConnections PixelToFEDAssociateFromAscii::theBarrel
private

Definition at line 56 of file PixelToFEDAssociateFromAscii.h.

EndcapConnections PixelToFEDAssociateFromAscii::theEndcap
private

Definition at line 57 of file PixelToFEDAssociateFromAscii.h.

std::string PixelToFEDAssociateFromAscii::theVersion
private

Definition at line 61 of file PixelToFEDAssociateFromAscii.h.