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)) {
39 LogDebug(
"init, input file:") << cfg_name.c_str();
41 std::ifstream
file( cfg_name.c_str() );
44 <<
" cant open data file: " << cfg_name;
47 edm::LogInfo(
"PixelToLNKAssociateFromAscii, read data from: ") <<cfg_name ;
55 while (getline(
file,line)) {
60 if (pos != string::npos) line = line.erase(pos);
73 if ( line.compare(0,3,
"VER") == 0 ) {
81 else if ( posF != string::npos) {
82 line = line.substr(posF+4);
83 fedId = atoi(line.c_str());
89 else if ( posL != string::npos) {
90 string srtL = line.substr(posL+4);
91 linkId = atoi(srtL.c_str());
97 if ( posM != string::npos) {
98 if (posR != string::npos) {
99 string strM = line.substr(posM+4, posR-posM-5);
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);
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();
136 int fedId,
int linkId, std::string
module,
Range rocDetIds)
141 pos = module.find(
"BPix");
142 if (pos != string::npos) {
145 string strP = module.substr(pos+6,2);
151 module = module.substr(pos+9);
154 pos = module.find(
"_");
155 if (pos == string::npos)
throw cms::Exception(
"problem with sector formatting");
157 module = module.substr(pos+1);
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);
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);
172 int zmodule = atoi( module.substr(3,pos-3).c_str());
176 for (
int rocDetId=rocDetIds.
min(); rocDetId <= rocDetIds.
max(); rocDetId++) {
183 cablingRocId.
fedId = fedId;
184 cablingRocId.
linkId = linkId;
192 detectorRocId.
rocDetId = rocDetId-8;
194 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
200 pos = module.find(
"FPix");
201 if (pos != string::npos) {
202 string strH = module.substr(pos+6,2);
208 module = module.substr(pos+9);
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);
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);
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);
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);
243 else throw cms::Exception(
"problem with pannel type formatting (unrecoginzed word)");
248 for (
int plaq = 1; plaq <= 4; plaq++) {
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++) {
256 int rocDetId = firstRoc + step*iroc;
263 cablingRocId.
fedId = fedId;
264 cablingRocId.
linkId = linkId;
267 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
275 for (
int plaq = 4; plaq >= 1; plaq--) {
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(); iroc++) {
283 int rocDetId = firstRoc + step*iroc;
284 if (rocDetId > rocs.
max()) rocDetId = (rocDetId-1)%rocs.
max();
291 cablingRocId.
fedId = fedId;
292 cablingRocId.
linkId = linkId;
295 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
303 for (
int plaq = 1; plaq <= 3; plaq++) {
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++) {
310 int rocDetId = firstRoc + step*iroc;
317 cablingRocId.
fedId = fedId;
318 cablingRocId.
linkId = linkId;
321 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
329 for (
int plaq = 3; plaq >= 1; plaq--) {
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++) {
336 int rocDetId = firstRoc + step*iroc;
337 if (rocDetId > rocs.
max()) rocDetId = (rocDetId-1)%rocs.
max();
344 cablingRocId.
fedId = fedId;
345 cablingRocId.
linkId = linkId;
348 theConnection.push_back( make_pair(detectorRocId,cablingRocId));
363 const char *
line = l.c_str();
366 int num = strtol(line, &evp, 10);
367 { stringstream
s; s<<
"raad from line: "; s<<
num;
LogTrace(
"") << s.str(); }
370 if (first) { num1 =
num; first =
false; }
375 string s =
"** PixelToLNKAssociateFromAscii, read data, cant intrpret: " ;
378 <<
"=====> send exception " << endl;
382 return Range(num1,num2);
void init(const std::string &fileName)
initialisatin (read file)
PixelToLNKAssociateFromAscii(const std::string &fileName)
const T & min() const
lower edge of range
void addConnections(int fedId, int linkId, std::string module, Range rocDetIds)
virtual const CablingRocId * operator()(const DetectorRocId &roc) const
LNK id for module.
bool isHalfModule() const
full or half module
virtual std::string version() const
version
const PixelModuleName * module
PixelRecoRange< float > Range
const T & max() const
upper edge of range
Range readRange(const std::string &) const