26 typedef std::vector< std::pair<DetectorRocId,CablingRocId> >::const_iterator IM;
27 for (IM im = theConnection.begin(); im != theConnection.end(); im++) {
28 if( ( *(im->first.module) == *roc.
module ) && (im->first.rocDetId == roc.
rocDetId)) {
40 std::ifstream
file( cfg_name.c_str() );
43 <<
" cant open data file: " << cfg_name;
46 edm::LogInfo(
"PixelToLNKAssociateFromAscii, read data from: ") <<cfg_name;
54 while (getline(
file,line)) {
59 if (pos != string::npos) line = line.erase(pos);
72 if ( line.compare(0,3,
"VER") == 0 ) {
80 else if ( posF != string::npos) {
81 line = line.substr(posF+4);
82 fedId = atoi(line.c_str());
88 else if ( posL != string::npos) {
89 string srtL = line.substr(posL+4);
90 linkId = atoi(srtL.c_str());
96 if ( posM != string::npos) {
97 if (posR != string::npos) {
98 string strM = line.substr(posM+4, posR-posM-5);
100 if(pos != string::npos) strM = strM.substr(pos+1);
101 string strR = line.substr(posR+4);
102 Range range = readRange(strR);
104 addConnections( fedId, linkId, strM, range);
106 string strM= line.substr(posM+4);
108 if(pos != string::npos) strM = strM.substr(pos+1);
109 addConnections( fedId, linkId, strM,
Range(0,0));
115 edm::LogError(
"**PixelToLNKAssociateFromAscii** exception")<<err.what();
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
132 edm::LogInfo(
"PixelToLNKAssociateFromAscii")<<str.str();
142 pos = module.find(
"BPix");
143 if (pos != string::npos) {
145 string module0=module;
151 if(p != string::npos) module0 = module0.substr(0,p);
155 string strP = module.substr(pos+6,2);
193 bool loopExecuted =
false;
194 for (
int rocDetId=rocDetIds.
min(); rocDetId <= rocDetIds.
max(); rocDetId++) {
204 cablingRocId.
linkId = linkId;
214 detectorRocId.
rocDetId = rocDetId-8;
216 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
218 if (!loopExecuted)
delete name;
223 pos = module.find(
"FPix");
224 if (pos != string::npos) {
226 string strH = module.substr(pos+6,2);
232 module = module.substr(pos+9);
235 pos = module.find(
"_");
236 if (pos == string::npos)
throw cms::Exception(
"problem with disk formatting");
237 int disk = atoi( module.substr(1,pos-1).c_str());
238 module = module.substr(pos+1);
241 pos = module.find(
"_");
242 if (pos == string::npos)
throw cms::Exception(
"problem with blade formatting");
243 int blade = atoi( module.substr(3,pos-3).c_str());
244 module = module.substr(pos+1);
247 pos = module.find(
"_");
248 if (pos == string::npos)
throw cms::Exception(
"problem with pannel formatting");
249 int pannel = atoi( module.substr(3,pos-3).c_str());
250 module = module.substr(pos+1);
265 pos = module.find(
"RNG");
266 if (pos == string::npos)
throw cms::Exception(
"problem with ring formatting");
267 ring = atoi( module.substr(pos+3,1).c_str());
271 pos = module.find(
"TYP:");
272 if (pos == string::npos)
throw cms::Exception(
"problem with pannel type formatting");
273 string strT = module.substr(pos+5,3);
274 string strT4 = module.substr(pos+5,4);
281 else throw cms::Exception(
"problem with pannel type formatting (unrecoginzed word)");
289 for (
int plaq = 1; plaq <= 4; plaq++) {
291 if (plaq==1) { rocs =
Range(0,1); firstRoc=1; step=-1; }
292 if (plaq==2) { rocs =
Range(0,5); firstRoc=0; step=+1; }
293 if (plaq==3) { rocs =
Range(0,7); firstRoc=0; step=+1; }
294 if (plaq==4) { rocs =
Range(0,4); firstRoc=0; step=+1; }
296 for (
int iroc =rocs.
min(); iroc<=rocs.
max(); iroc++) {
298 int rocDetId = firstRoc + step*iroc;
307 cablingRocId.
linkId = linkId;
310 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
318 for (
int plaq = 4; plaq >= 1; plaq--) {
320 if (plaq==1) { rocs =
Range(0,1); firstRoc=1; step=-1; }
321 if (plaq==2) { rocs =
Range(0,5); firstRoc=3; step=+1; }
322 if (plaq==3) { rocs =
Range(0,7); firstRoc=4; step=+1; }
323 if (plaq==4) { rocs =
Range(0,4); firstRoc=0; step=+1; }
325 for (
int iroc =rocs.
min(); iroc-rocs.
max() <= 0; iroc++) {
327 int rocDetId = firstRoc + step*iroc;
328 if (rocDetId > rocs.
max()) rocDetId = (rocDetId-1)%rocs.
max();
336 cablingRocId.
linkId = linkId;
339 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
347 for (
int plaq = 1; plaq <= 3; plaq++) {
349 if (plaq==1) { rocs =
Range(0,5); firstRoc=0; step=1; }
350 if (plaq==2) { rocs =
Range(0,7); firstRoc=0; step=1; }
351 if (plaq==3) { rocs =
Range(0,9); firstRoc=0; step=1; }
353 for (
int iroc =rocs.
min(); iroc<=rocs.
max(); iroc++) {
355 int rocDetId = firstRoc + step*iroc;
363 cablingRocId.
linkId = linkId;
366 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
374 for (
int plaq = 3; plaq >= 1; plaq--) {
376 if (plaq==1) { rocs =
Range(0,5); firstRoc=3; step=1; }
377 if (plaq==2) { rocs =
Range(0,7); firstRoc=4; step=1; }
378 if (plaq==3) { rocs =
Range(0,9); firstRoc=5; step=1; }
380 for (
int iroc =rocs.
min(); iroc<=rocs.
max(); iroc++) {
382 int rocDetId = firstRoc + step*iroc;
383 if (rocDetId > rocs.
max()) rocDetId = (rocDetId-1)%rocs.
max();
391 cablingRocId.
linkId = linkId;
394 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
405 bool loopExecuted =
false;
406 for (
int rocDetId=rocDetIds.
min(); rocDetId <= rocDetIds.
max(); rocDetId++) {
414 cablingRocId.
linkId = linkId;
416 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
418 <<
" rocDetId: " << rocDetId
419 <<
" rocLnkId:" << rocLnkId
420 <<
" fedId = " << fedId
421 <<
" linkId = " << linkId
422 <<
" name = " << name->
name();
449 if(p != string::npos) {
451 l1 = l.substr(0,p-1+1);
452 l2 = l.substr(p+1,len-1-p);
void init(const std::string &fileName)
initialisatin (read file)
PixelRecoRange< float > Range
std::string name() const override
from base class
const T & min() const
lower edge of range
void addConnections(int fedId, int linkId, std::string module, Range rocDetIds)
bool isHalfModule() const
full or half module
const CablingRocId * operator()(const DetectorRocId &roc) const override
LNK id for module.
const PixelModuleName * module
std::string version() const override
version
const T & max() const
upper edge of range
Range readRange(const std::string &) const
PixelToLNKAssociateFromAscii(const std::string &fileName, const bool phase1=false)