#include <CalibTracker/SiPixelConnectivity/interface/PixelToLNKAssociateFromAscii.h>
Public Types | |
typedef PixelToFEDAssociate::CablingRocId | CablingRocId |
typedef PixelToFEDAssociate::DetectorRocId | DetectorRocId |
Public Member Functions | |
virtual const CablingRocId * | operator() (const DetectorRocId &roc) const |
LNK id for module. | |
PixelToLNKAssociateFromAscii (const std::string &fileName) | |
virtual std::string | version () const |
version | |
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) | |
Range | readRange (const std::string &) const |
Private Attributes | |
std::vector< std::pair < DetectorRocId, CablingRocId > > | theConnection |
std::string | theVersion |
The associacions are read from the datafile
Definition at line 20 of file PixelToLNKAssociateFromAscii.h.
Definition at line 23 of file PixelToLNKAssociateFromAscii.h.
Definition at line 24 of file PixelToLNKAssociateFromAscii.h.
typedef TRange<int> PixelToLNKAssociateFromAscii::Range [private] |
Definition at line 34 of file PixelToLNKAssociateFromAscii.h.
PixelToLNKAssociateFromAscii::PixelToLNKAssociateFromAscii | ( | const std::string & | fileName | ) |
void PixelToLNKAssociateFromAscii::addConnections | ( | int | fedId, | |
int | linkId, | |||
std::string | module, | |||
Range | rocDetIds | |||
) | [private] |
Definition at line 135 of file PixelToLNKAssociateFromAscii.cc.
References muonGeometry::disk, 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, name, PixelPannelType::p3L, PixelPannelType::p3R, PixelPannelType::p4L, PixelPannelType::p4R, PixelEndcapName::pI, PixelBarrelName::pI, PixelBarrelName::pO, PixelEndcapName::pO, PixelToFEDAssociate::DetectorRocId::rocDetId, PixelToFEDAssociate::CablingRocId::rocLinkId, cmsRelvalreportInput::step, and theConnection.
00137 { 00138 string::size_type pos; 00139 00140 // check for Barrel modules 00141 pos = module.find("BPix"); 00142 if (pos != string::npos) { 00143 00144 // shell 00145 string strP = module.substr(pos+6,2); 00146 PixelBarrelName::Shell part; 00147 if (strP=="mO") part = PixelBarrelName::mO; 00148 else if(strP=="mI") part = PixelBarrelName::mI; 00149 else if(strP=="pO") part = PixelBarrelName::pO; 00150 else part = PixelBarrelName::pI; 00151 module = module.substr(pos+9); 00152 00153 // sector 00154 pos = module.find("_"); 00155 if (pos == string::npos) throw cms::Exception("problem with sector formatting"); 00156 // int sector = atoi( module.substr(3,pos-3).c_str()); 00157 module = module.substr(pos+1); 00158 00159 // layer 00160 pos = module.find("_"); 00161 if (pos == string::npos) throw cms::Exception("problem with layer formatting"); 00162 int layer = atoi( module.substr(3,pos-3).c_str()); 00163 module = module.substr(pos+1); 00164 00165 // ladder 00166 pos = module.find("_"); 00167 if (pos == string::npos) throw cms::Exception("problem with ladder formatting"); 00168 int ladder = atoi( module.substr(3,pos-3).c_str()); 00169 module = module.substr(pos+1); 00170 00171 // z-module 00172 int zmodule = atoi( module.substr(3,pos-3).c_str()); 00173 00174 // place modules in connections 00175 int rocLnkId = 0; 00176 for (int rocDetId=rocDetIds.min(); rocDetId <= rocDetIds.max(); rocDetId++) { 00177 rocLnkId++; 00178 DetectorRocId detectorRocId; 00179 PixelBarrelName * name = new PixelBarrelName(part, layer, zmodule, ladder); 00180 detectorRocId.module = name; 00181 detectorRocId.rocDetId = rocDetId; 00182 CablingRocId cablingRocId; 00183 cablingRocId.fedId = fedId; 00184 cablingRocId.linkId = linkId; 00185 cablingRocId.rocLinkId = rocLnkId; 00186 // fix for type-B modules in barrel 00187 if (name->isHalfModule() && (rocDetIds.min()>7) 00188 && (part==PixelBarrelName::mO || PixelBarrelName::mI) ) { 00189 cablingRocId.rocLinkId = 9-rocLnkId; 00190 detectorRocId.rocDetId = rocDetId-8; 00191 } 00192 theConnection.push_back( make_pair(detectorRocId,cablingRocId)); 00193 } 00194 } 00195 00196 // check for endcap modules 00197 // check for Barrel modules 00198 pos = module.find("FPix"); 00199 if (pos != string::npos) { 00200 string strH = module.substr(pos+6,2); 00201 PixelEndcapName::HalfCylinder part; 00202 if (strH=="mO") part = PixelEndcapName::mO; 00203 else if(strH=="mI") part = PixelEndcapName::mI; 00204 else if(strH=="pO") part = PixelEndcapName::pO; 00205 else part = PixelEndcapName::pI; 00206 module = module.substr(pos+9); 00207 00208 // disk 00209 pos = module.find("_"); 00210 if (pos == string::npos) throw cms::Exception("problem with disk formatting"); 00211 int disk = atoi( module.substr(1,pos-1).c_str()); 00212 module = module.substr(pos+1); 00213 00214 // blade 00215 pos = module.find("_"); 00216 if (pos == string::npos) throw cms::Exception("problem with blade formatting"); 00217 int blade = atoi( module.substr(3,pos-3).c_str()); 00218 module = module.substr(pos+1); 00219 00220 //pannel 00221 pos = module.find("_"); 00222 if (pos == string::npos) throw cms::Exception("problem with pannel formatting"); 00223 int pannel = atoi( module.substr(3,pos-3).c_str()); 00224 module = module.substr(pos+1); 00225 00226 // plaquete 00227 // pos = module.find("_"); 00228 // if (pos == string::npos) throw cms::Exception("problem with plaquette formatting"); 00229 // int plaq = atoi( module.substr(3,pos-3).c_str()); 00230 00231 // pannel type 00232 pos = module.find("TYP:"); 00233 if (pos == string::npos) throw cms::Exception("problem with pannel type formatting"); 00234 string strT = module.substr(pos+5,3); 00235 00236 PixelPannelType::PannelType pannelType; 00237 if (strT=="P3R") pannelType=PixelPannelType::p3R; 00238 else if (strT=="P3L") pannelType=PixelPannelType::p3L; 00239 else if (strT=="P4R") pannelType=PixelPannelType::p4R; 00240 else if (strT=="P4L") pannelType=PixelPannelType::p4L; 00241 else throw cms::Exception("problem with pannel type formatting (unrecoginzed word)"); 00242 00243 if ( pannelType==PixelPannelType::p4L) { 00244 // cout <<"----------- p4L"<<endl; 00245 int rocLnkId =0; 00246 for (int plaq = 1; plaq <= 4; plaq++) { 00247 Range rocs; int firstRoc=0; int step=0; 00248 if (plaq==1) { rocs = Range(0,1); firstRoc=1; step=-1; } 00249 if (plaq==2) { rocs = Range(0,5); firstRoc=0; step=+1; } 00250 if (plaq==3) { rocs = Range(0,7); firstRoc=0; step=+1; } 00251 if (plaq==4) { rocs = Range(0,4); firstRoc=0; step=+1; } 00252 for (int iroc =rocs.min(); iroc<=rocs.max(); iroc++) { 00253 rocLnkId++; 00254 int rocDetId = firstRoc + step*iroc; 00255 00256 DetectorRocId detectorRocId; 00257 detectorRocId.module = new PixelEndcapName(part,disk,blade,pannel,plaq); 00258 detectorRocId.rocDetId = rocDetId; 00259 00260 CablingRocId cablingRocId; 00261 cablingRocId.fedId = fedId; 00262 cablingRocId.linkId = linkId; 00263 cablingRocId.rocLinkId = rocLnkId; 00264 00265 theConnection.push_back( make_pair(detectorRocId,cablingRocId)); 00266 // cout <<"PLAQ:"<<plaq<<" rocDetId: "<<rocDetId<<" rocLnkId:"<<rocLnkId<<endl; 00267 } 00268 } 00269 } 00270 else if ( pannelType==PixelPannelType::p4R) { 00271 // cout <<"----------- p4R"<<endl; 00272 int rocLnkId =0; 00273 for (int plaq = 4; plaq >= 1; plaq--) { 00274 Range rocs; int firstRoc=0; int step=0; 00275 if (plaq==1) { rocs = Range(0,1); firstRoc=1; step=-1; } 00276 if (plaq==2) { rocs = Range(0,5); firstRoc=3; step=+1; } 00277 if (plaq==3) { rocs = Range(0,7); firstRoc=4; step=+1; } 00278 if (plaq==4) { rocs = Range(0,4); firstRoc=0; step=+1; } 00279 for (int iroc =rocs.min(); iroc<=rocs.max(); iroc++) { 00280 rocLnkId++; 00281 int rocDetId = firstRoc + step*iroc; 00282 if (rocDetId > rocs.max()) rocDetId = (rocDetId-1)%rocs.max(); 00283 00284 DetectorRocId detectorRocId; 00285 detectorRocId.module = new PixelEndcapName(part,disk,blade,pannel,plaq); 00286 detectorRocId.rocDetId = rocDetId; 00287 00288 CablingRocId cablingRocId; 00289 cablingRocId.fedId = fedId; 00290 cablingRocId.linkId = linkId; 00291 cablingRocId.rocLinkId = rocLnkId; 00292 00293 theConnection.push_back( make_pair(detectorRocId,cablingRocId)); 00294 // cout <<"PLAQ:"<<plaq<<" rocDetId: "<<rocDetId<<" rocLnkId:"<<rocLnkId<<endl; 00295 } 00296 } 00297 } 00298 else if ( pannelType==PixelPannelType::p3L) { 00299 // cout <<"----------- p3L"<<endl; 00300 int rocLnkId =0; 00301 for (int plaq = 1; plaq <= 3; plaq++) { 00302 Range rocs; int firstRoc=0; int step=0; 00303 if (plaq==1) { rocs = Range(0,5); firstRoc=0; step=1; } 00304 if (plaq==2) { rocs = Range(0,7); firstRoc=0; step=1; } 00305 if (plaq==3) { rocs = Range(0,9); firstRoc=0; step=1; } 00306 for (int iroc =rocs.min(); iroc<=rocs.max(); iroc++) { 00307 rocLnkId++; 00308 int rocDetId = firstRoc + step*iroc; 00309 00310 DetectorRocId detectorRocId; 00311 detectorRocId.module = new PixelEndcapName(part,disk,blade,pannel,plaq); 00312 detectorRocId.rocDetId = rocDetId; 00313 00314 CablingRocId cablingRocId; 00315 cablingRocId.fedId = fedId; 00316 cablingRocId.linkId = linkId; 00317 cablingRocId.rocLinkId = rocLnkId; 00318 00319 theConnection.push_back( make_pair(detectorRocId,cablingRocId)); 00320 // cout <<"PLAQ:"<<plaq<<" rocDetId: "<<rocDetId<<" rocLnkId:"<<rocLnkId<<endl; 00321 } 00322 } 00323 } 00324 else if ( pannelType==PixelPannelType::p3R) { 00325 // cout <<"----------- p3R"<<endl; 00326 int rocLnkId =0; 00327 for (int plaq = 3; plaq >= 1; plaq--) { 00328 Range rocs; int firstRoc=0; int step=0; 00329 if (plaq==1) { rocs = Range(0,5); firstRoc=3; step=1; } 00330 if (plaq==2) { rocs = Range(0,7); firstRoc=4; step=1; } 00331 if (plaq==3) { rocs = Range(0,9); firstRoc=5; step=1; } 00332 for (int iroc =rocs.min(); iroc<=rocs.max(); iroc++) { 00333 rocLnkId++; 00334 int rocDetId = firstRoc + step*iroc; 00335 if (rocDetId > rocs.max()) rocDetId = (rocDetId-1)%rocs.max(); 00336 00337 DetectorRocId detectorRocId; 00338 detectorRocId.module = new PixelEndcapName(part,disk,blade,pannel,plaq); 00339 detectorRocId.rocDetId = rocDetId; 00340 00341 CablingRocId cablingRocId; 00342 cablingRocId.fedId = fedId; 00343 cablingRocId.linkId = linkId; 00344 cablingRocId.rocLinkId = rocLnkId; 00345 00346 theConnection.push_back( make_pair(detectorRocId,cablingRocId)); 00347 // cout <<"PLAQ:"<<plaq<<" rocDetId: "<<rocDetId<<" rocLnkId:"<<rocLnkId<<endl; 00348 } 00349 } 00350 } 00351 00352 } 00353 }
void PixelToLNKAssociateFromAscii::init | ( | const std::string & | fileName | ) | [private] |
initialisatin (read file)
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, PixelToFEDAssociate::DetectorRocId::rocDetId, and theConnection.
00024 { 00025 // bool deb = (roc.module->name()=="BPix_BpI_SEC1_LYR1_LDR1H_MOD1"); 00026 // if (deb) cout <<"KUKU"<<endl; 00027 00028 typedef std::vector< std::pair<DetectorRocId,CablingRocId> >::const_iterator IM; 00029 for (IM im = theConnection.begin(); im != theConnection.end(); im++) { 00030 if( ( *(im->first.module) == *roc.module ) && (im->first.rocDetId == roc.rocDetId)) { 00031 return &(im->second); 00032 } 00033 } 00034 return 0; 00035 }
Range PixelToLNKAssociateFromAscii::readRange | ( | const std::string & | ) | const [private] |
std::string PixelToLNKAssociateFromAscii::version | ( | ) | const [virtual] |
version
Implements PixelToFEDAssociate.
Definition at line 17 of file PixelToLNKAssociateFromAscii.cc.
References theVersion.
00018 { 00019 return theVersion; 00020 }
std::vector< std::pair<DetectorRocId,CablingRocId> > PixelToLNKAssociateFromAscii::theConnection [private] |
Definition at line 42 of file PixelToLNKAssociateFromAscii.h.
Referenced by addConnections(), and operator()().
std::string PixelToLNKAssociateFromAscii::theVersion [private] |