CMS 3D CMS Logo

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

#include <PixelToLNKAssociateFromAscii.h>

Inheritance diagram for PixelToLNKAssociateFromAscii:
PixelToFEDAssociate

Public Types

typedef
PixelToFEDAssociate::CablingRocId 
CablingRocId
 
typedef
PixelToFEDAssociate::DetectorRocId 
DetectorRocId
 

Public Member Functions

virtual const CablingRocIdoperator() (const DetectorRocId &roc) const
 LNK id for module. More...
 
 PixelToLNKAssociateFromAscii (const std::string &fileName)
 
virtual std::string version () const
 version More...
 
- Public Member Functions inherited from PixelToFEDAssociate
virtual int operator() (const PixelModuleName &) const
 FED id for module. More...
 
virtual ~PixelToFEDAssociate ()
 

Private Types

typedef TRange< int > Range
 

Private Member Functions

void addConnections (int fedId, int linkId, std::string module, Range rocDetIds)
 
void init (const std::string &fileName)
 initialisatin (read file) More...
 
Range readRange (const std::string &) const
 

Private Attributes

std::vector< std::pair
< DetectorRocId, CablingRocId > > 
theConnection
 
std::string theVersion
 

Detailed Description

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

Definition at line 20 of file PixelToLNKAssociateFromAscii.h.

Member Typedef Documentation

Definition at line 23 of file PixelToLNKAssociateFromAscii.h.

Definition at line 24 of file PixelToLNKAssociateFromAscii.h.

Definition at line 34 of file PixelToLNKAssociateFromAscii.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file PixelToLNKAssociateFromAscii.cc.

References init.

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

Member Function Documentation

void PixelToLNKAssociateFromAscii::addConnections ( int  fedId,
int  linkId,
std::string  module,
Range  rocDetIds 
)
private

Definition at line 135 of file PixelToLNKAssociateFromAscii.cc.

References edm::hlt::Exception, PixelToFEDAssociate::CablingRocId::fedId, PixelBarrelName::isHalfModule(), PixelToFEDAssociate::CablingRocId::linkId, TRange< T >::max(), PixelBarrelName::mI, PixelEndcapName::mI, TRange< T >::min(), PixelBarrelName::mO, PixelEndcapName::mO, PixelToFEDAssociate::DetectorRocId::module, mergeVDriftHistosByStation::name, PixelPannelType::p3L, PixelPannelType::p3R, PixelPannelType::p4L, PixelPannelType::p4R, PixelBarrelName::pI, PixelEndcapName::pI, PixelBarrelName::pO, PixelEndcapName::pO, pos, PixelToFEDAssociate::DetectorRocId::rocDetId, PixelToFEDAssociate::CablingRocId::rocLinkId, and launcher::step.

137 {
139 
140  // check for Barrel modules
141  pos = module.find("BPix");
142  if (pos != string::npos) {
143 
144  // shell
145  string strP = module.substr(pos+6,2);
147  if (strP=="mO") part = PixelBarrelName::mO;
148  else if(strP=="mI") part = PixelBarrelName::mI;
149  else if(strP=="pO") part = PixelBarrelName::pO;
150  else part = PixelBarrelName::pI;
151  module = module.substr(pos+9);
152 
153  // sector
154  pos = module.find("_");
155  if (pos == string::npos) throw cms::Exception("problem with sector formatting");
156  // int sector = atoi( module.substr(3,pos-3).c_str());
157  module = module.substr(pos+1);
158 
159  // layer
160  pos = module.find("_");
161  if (pos == string::npos) throw cms::Exception("problem with layer formatting");
162  int layer = atoi( module.substr(3,pos-3).c_str());
163  module = module.substr(pos+1);
164 
165  // ladder
166  pos = module.find("_");
167  if (pos == string::npos) throw cms::Exception("problem with ladder formatting");
168  int ladder = atoi( module.substr(3,pos-3).c_str());
169  module = module.substr(pos+1);
170 
171  // z-module
172  int zmodule = atoi( module.substr(3,pos-3).c_str());
173 
174  // place modules in connections
175  int rocLnkId = 0;
176  for (int rocDetId=rocDetIds.min(); rocDetId <= rocDetIds.max(); rocDetId++) {
177  rocLnkId++;
178  DetectorRocId detectorRocId;
179  PixelBarrelName * name = new PixelBarrelName(part, layer, zmodule, ladder);
180  detectorRocId.module = name;
181  detectorRocId.rocDetId = rocDetId;
182  CablingRocId cablingRocId;
183  cablingRocId.fedId = fedId;
184  cablingRocId.linkId = linkId;
185  cablingRocId.rocLinkId = rocLnkId;
186  // fix for type-B modules in barrel
187  if (name->isHalfModule() && (rocDetIds.min()>7)
188  && (part==PixelBarrelName::mO || PixelBarrelName::mI) ) {
189  //cablingRocId.rocLinkId = 9-rocLnkId;
190  // rocDetId=8,...,15
191  cablingRocId.rocLinkId = rocLnkId; // 1...8 19/11/08 d.k.
192  detectorRocId.rocDetId = rocDetId-8; // 0...7
193  }
194  theConnection.push_back( make_pair(detectorRocId,cablingRocId));
195  }
196  }
197 
198  // check for endcap modules
199  // check for Barrel modules
200  pos = module.find("FPix");
201  if (pos != string::npos) {
202  string strH = module.substr(pos+6,2);
204  if (strH=="mO") part = PixelEndcapName::mO;
205  else if(strH=="mI") part = PixelEndcapName::mI;
206  else if(strH=="pO") part = PixelEndcapName::pO;
207  else part = PixelEndcapName::pI;
208  module = module.substr(pos+9);
209 
210  // disk
211  pos = module.find("_");
212  if (pos == string::npos) throw cms::Exception("problem with disk formatting");
213  int disk = atoi( module.substr(1,pos-1).c_str());
214  module = module.substr(pos+1);
215 
216  // blade
217  pos = module.find("_");
218  if (pos == string::npos) throw cms::Exception("problem with blade formatting");
219  int blade = atoi( module.substr(3,pos-3).c_str());
220  module = module.substr(pos+1);
221 
222  //pannel
223  pos = module.find("_");
224  if (pos == string::npos) throw cms::Exception("problem with pannel formatting");
225  int pannel = atoi( module.substr(3,pos-3).c_str());
226  module = module.substr(pos+1);
227 
228  // plaquete
229 // pos = module.find("_");
230 // if (pos == string::npos) throw cms::Exception("problem with plaquette formatting");
231 // int plaq = atoi( module.substr(3,pos-3).c_str());
232 
233  // pannel type
234  pos = module.find("TYP:");
235  if (pos == string::npos) throw cms::Exception("problem with pannel type formatting");
236  string strT = module.substr(pos+5,3);
237 
238  PixelPannelType::PannelType pannelType;
239  if (strT=="P3R") pannelType=PixelPannelType::p3R;
240  else if (strT=="P3L") pannelType=PixelPannelType::p3L;
241  else if (strT=="P4R") pannelType=PixelPannelType::p4R;
242  else if (strT=="P4L") pannelType=PixelPannelType::p4L;
243  else throw cms::Exception("problem with pannel type formatting (unrecoginzed word)");
244 
245  if ( pannelType==PixelPannelType::p4L) {
246 // cout <<"----------- p4L"<<endl;
247  int rocLnkId =0;
248  for (int plaq = 1; plaq <= 4; plaq++) {
249  Range rocs; int firstRoc=0; int step=0;
250  if (plaq==1) { rocs = Range(0,1); firstRoc=1; step=-1; }
251  if (plaq==2) { rocs = Range(0,5); firstRoc=0; step=+1; }
252  if (plaq==3) { rocs = Range(0,7); firstRoc=0; step=+1; }
253  if (plaq==4) { rocs = Range(0,4); firstRoc=0; step=+1; }
254  for (int iroc =rocs.min(); iroc<=rocs.max(); iroc++) {
255  rocLnkId++;
256  int rocDetId = firstRoc + step*iroc;
257 
258  DetectorRocId detectorRocId;
259  detectorRocId.module = new PixelEndcapName(part,disk,blade,pannel,plaq);
260  detectorRocId.rocDetId = rocDetId;
261 
262  CablingRocId cablingRocId;
263  cablingRocId.fedId = fedId;
264  cablingRocId.linkId = linkId;
265  cablingRocId.rocLinkId = rocLnkId;
266 
267  theConnection.push_back( make_pair(detectorRocId,cablingRocId));
268 // cout <<"PLAQ:"<<plaq<<" rocDetId: "<<rocDetId<<" rocLnkId:"<<rocLnkId<<endl;
269  }
270  }
271  }
272  else if ( pannelType==PixelPannelType::p4R) {
273 // cout <<"----------- p4R"<<endl;
274  int rocLnkId =0;
275  for (int plaq = 4; plaq >= 1; plaq--) {
276  Range rocs; int firstRoc=0; int step=0;
277  if (plaq==1) { rocs = Range(0,1); firstRoc=1; step=-1; }
278  if (plaq==2) { rocs = Range(0,5); firstRoc=3; step=+1; }
279  if (plaq==3) { rocs = Range(0,7); firstRoc=4; step=+1; }
280  if (plaq==4) { rocs = Range(0,4); firstRoc=0; step=+1; }
281  for (int iroc =rocs.min(); iroc-rocs.max() <= 0; iroc++) {
282  rocLnkId++;
283  int rocDetId = firstRoc + step*iroc;
284  if (rocDetId > rocs.max()) rocDetId = (rocDetId-1)%rocs.max();
285 
286  DetectorRocId detectorRocId;
287  detectorRocId.module = new PixelEndcapName(part,disk,blade,pannel,plaq);
288  detectorRocId.rocDetId = rocDetId;
289 
290  CablingRocId cablingRocId;
291  cablingRocId.fedId = fedId;
292  cablingRocId.linkId = linkId;
293  cablingRocId.rocLinkId = rocLnkId;
294 
295  theConnection.push_back( make_pair(detectorRocId,cablingRocId));
296 // cout <<"PLAQ:"<<plaq<<" rocDetId: "<<rocDetId<<" rocLnkId:"<<rocLnkId<<endl;
297  }
298  }
299  }
300  else if ( pannelType==PixelPannelType::p3L) {
301 // cout <<"----------- p3L"<<endl;
302  int rocLnkId =0;
303  for (int plaq = 1; plaq <= 3; plaq++) {
304  Range rocs; int firstRoc=0; int step=0;
305  if (plaq==1) { rocs = Range(0,5); firstRoc=0; step=1; }
306  if (plaq==2) { rocs = Range(0,7); firstRoc=0; step=1; }
307  if (plaq==3) { rocs = Range(0,9); firstRoc=0; step=1; }
308  for (int iroc =rocs.min(); iroc<=rocs.max(); iroc++) {
309  rocLnkId++;
310  int rocDetId = firstRoc + step*iroc;
311 
312  DetectorRocId detectorRocId;
313  detectorRocId.module = new PixelEndcapName(part,disk,blade,pannel,plaq);
314  detectorRocId.rocDetId = rocDetId;
315 
316  CablingRocId cablingRocId;
317  cablingRocId.fedId = fedId;
318  cablingRocId.linkId = linkId;
319  cablingRocId.rocLinkId = rocLnkId;
320 
321  theConnection.push_back( make_pair(detectorRocId,cablingRocId));
322 // cout <<"PLAQ:"<<plaq<<" rocDetId: "<<rocDetId<<" rocLnkId:"<<rocLnkId<<endl;
323  }
324  }
325  }
326  else if ( pannelType==PixelPannelType::p3R) {
327 // cout <<"----------- p3R"<<endl;
328  int rocLnkId =0;
329  for (int plaq = 3; plaq >= 1; plaq--) {
330  Range rocs; int firstRoc=0; int step=0;
331  if (plaq==1) { rocs = Range(0,5); firstRoc=3; step=1; }
332  if (plaq==2) { rocs = Range(0,7); firstRoc=4; step=1; }
333  if (plaq==3) { rocs = Range(0,9); firstRoc=5; step=1; }
334  for (int iroc =rocs.min(); iroc<=rocs.max(); iroc++) {
335  rocLnkId++;
336  int rocDetId = firstRoc + step*iroc;
337  if (rocDetId > rocs.max()) rocDetId = (rocDetId-1)%rocs.max();
338 
339  DetectorRocId detectorRocId;
340  detectorRocId.module = new PixelEndcapName(part,disk,blade,pannel,plaq);
341  detectorRocId.rocDetId = rocDetId;
342 
343  CablingRocId cablingRocId;
344  cablingRocId.fedId = fedId;
345  cablingRocId.linkId = linkId;
346  cablingRocId.rocLinkId = rocLnkId;
347 
348  theConnection.push_back( make_pair(detectorRocId,cablingRocId));
349 // cout <<"PLAQ:"<<plaq<<" rocDetId: "<<rocDetId<<" rocLnkId:"<<rocLnkId<<endl;
350  }
351  }
352  }
353 
354  }
355 }
list step
Definition: launcher.py:15
PixelToFEDAssociate::CablingRocId CablingRocId
uint16_t size_type
bool isHalfModule() const
full or half module
std::vector< std::pair< DetectorRocId, CablingRocId > > theConnection
part
Definition: HCALResponse.h:21
PixelToFEDAssociate::DetectorRocId DetectorRocId
Definition: vlib.h:209
void PixelToLNKAssociateFromAscii::init ( const std::string &  fileName)
private

initialisatin (read file)

Definition at line 37 of file PixelToLNKAssociateFromAscii.cc.

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

38 {
39  LogDebug("init, input file:") << cfg_name.c_str();
40 
41  std::ifstream file( cfg_name.c_str() );
42  if ( !file ) {
43  edm::LogError(" ** PixelToLNKAssociateFromAscii,init ** ")
44  << " cant open data file: " << cfg_name;
45  return;
46  } else {
47  edm::LogInfo("PixelToLNKAssociateFromAscii, read data from: ") <<cfg_name ;
48  }
49 
50  string line;
51  int fedId=-1;
52  int linkId=-1;
53 
54  try {
55  while (getline(file,line)) {
56  //
57  // treat # lines
58  //
59  string::size_type pos = line.find("#");
60  if (pos != string::npos) line = line.erase(pos);
61 
62  string::size_type posF = line.find("FED:");
63  string::size_type posL = line.find("LNK:");
64  string::size_type posM = line.find("MOD:");
65  string::size_type posR = line.find("ROC:");
66 
67  LogTrace("") <<" read line: "<< line;
68 
69 
70  //
71  // treat version lines, reset date
72  //
73  if ( line.compare(0,3,"VER") == 0 ) {
74  edm::LogInfo("version: ")<<line;
75  theVersion = line;
76  }
77 
78  //
79  // fed id line
80  //
81  else if ( posF != string::npos) {
82  line = line.substr(posF+4);
83  fedId = atoi(line.c_str());
84  }
85 
86  //
87  // link id linke
88  //
89  else if ( posL != string::npos) {
90  string srtL = line.substr(posL+4);
91  linkId = atoi(srtL.c_str());
92  }
93 
94  //
95  // module description
96  //
97  if ( posM != string::npos) {
98  if (posR != string::npos) {
99  string strM = line.substr(posM+4, posR-posM-5);
100  string::size_type pos = strM.find(" ");
101  if(pos != string::npos) strM = strM.substr(pos+1);
102  string strR = line.substr(posR+4);
103  Range range = readRange(strR);
104  addConnections( fedId, linkId, strM, range);
105  } else {
106  string strM= line.substr(posM+4);
107  string::size_type pos = strM.find(" ");
108  if(pos != string::npos) strM = strM.substr(pos+1);
109  addConnections( fedId, linkId, strM, Range(0,0));
110  }
111  }
112  }
113  }
114  catch(exception& err) {
115  edm::LogError("**PixelToLNKAssociateFromAscii** exception")<<err.what();
116  }
117 
118  //
119  // for debug
120  //
121  std::ostringstream str;
122  str <<" **PixelToLNKAssociateFromAscii ** CONNECTIONS: "<< endl;
123  typedef vector< pair<DetectorRocId,CablingRocId> >::const_iterator ICON;
124  for (ICON ic = theConnection.begin(); ic != theConnection.end(); ic++) {
125  str<< (*ic).first.module->name()
126  <<", rocDetId="<<(*ic).first.rocDetId
127  <<", fedId="<<ic->second.fedId
128  <<", linkId="<<ic->second.linkId
129  <<", rocLinkId="<<ic->second.rocLinkId
130  <<endl;
131  }
132  edm::LogInfo("PixelToLNKAssociateFromAscii")<<str.str();
133 }
#define LogDebug(id)
uint16_t size_type
void addConnections(int fedId, int linkId, std::string module, Range rocDetIds)
std::vector< std::pair< DetectorRocId, CablingRocId > > theConnection
#define LogTrace(id)
Range readRange(const std::string &) const
const PixelToLNKAssociateFromAscii::CablingRocId * PixelToLNKAssociateFromAscii::operator() ( const DetectorRocId roc) const
virtual

LNK id for module.

Reimplemented from PixelToFEDAssociate.

Definition at line 22 of file PixelToLNKAssociateFromAscii.cc.

References PixelToFEDAssociate::DetectorRocId::module, and PixelToFEDAssociate::DetectorRocId::rocDetId.

24 {
25 // bool deb = (roc.module->name()=="BPix_BpI_SEC1_LYR1_LDR1H_MOD1");
26 // if (deb) cout <<"KUKU"<<endl;
27 
28  typedef std::vector< std::pair<DetectorRocId,CablingRocId> >::const_iterator IM;
29  for (IM im = theConnection.begin(); im != theConnection.end(); im++) {
30  if( ( *(im->first.module) == *roc.module ) && (im->first.rocDetId == roc.rocDetId)) {
31  return &(im->second);
32  }
33  }
34  return 0;
35 }
std::vector< std::pair< DetectorRocId, CablingRocId > > theConnection
PixelToLNKAssociateFromAscii::Range PixelToLNKAssociateFromAscii::readRange ( const std::string &  ) const
private

Definition at line 358 of file PixelToLNKAssociateFromAscii.cc.

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

359 {
360  bool first = true;
361  int num1 = -1;
362  int num2 = -1;
363  const char * line = l.c_str();
364  while (line) {
365  char * evp = 0;
366  int num = strtol(line, &evp, 10);
367  { stringstream s; s<<"raad from line: "; s<<num; LogTrace("") << s.str(); }
368  if (evp != line) {
369  line = evp +1;
370  if (first) { num1 = num; first = false; }
371  num2 = num;
372  } else line = 0;
373  }
374  if (first) {
375  string s = "** PixelToLNKAssociateFromAscii, read data, cant intrpret: " ;
376  edm::LogInfo(s) << endl
377  << l << endl
378  <<"=====> send exception " << endl;
379  s += l;
380  throw cms::Exception(s);
381  }
382  return Range(num1,num2);
383 }
bool first
Definition: L1TdeRCT.cc:94
#define LogTrace(id)
long long int num
Definition: procUtils.cc:71
std::string PixelToLNKAssociateFromAscii::version ( ) const
virtual

version

Implements PixelToFEDAssociate.

Definition at line 17 of file PixelToLNKAssociateFromAscii.cc.

18 {
19  return theVersion;
20 }

Member Data Documentation

std::vector< std::pair<DetectorRocId,CablingRocId> > PixelToLNKAssociateFromAscii::theConnection
private

Definition at line 42 of file PixelToLNKAssociateFromAscii.h.

std::string PixelToLNKAssociateFromAscii::theVersion
private

Definition at line 41 of file PixelToLNKAssociateFromAscii.h.