Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:46

0001 #include "TIBLayerBuilder.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "TIBRingBuilder.h"
0006 
0007 using namespace edm;
0008 using namespace std;
0009 
0010 TIBLayer* TIBLayerBuilder::build(const GeometricDet* aTIBLayer, const TrackerGeometry* theGeomDetGeometry) {
0011   vector<const GeometricDet*> theGeometricRods = aTIBLayer->components();
0012 
0013   vector<vector<const GeometricDet*> > innerGeometricDetRings;
0014   vector<vector<const GeometricDet*> > outerGeometricDetRings;
0015 
0016   constructRings(theGeometricRods, innerGeometricDetRings, outerGeometricDetRings);
0017 
0018   TIBRingBuilder myRingBuilder;
0019 
0020   vector<const TIBRing*> innerRings;
0021   vector<const TIBRing*> outerRings;
0022 
0023   for (unsigned int i = 0; i < innerGeometricDetRings.size(); i++) {
0024     innerRings.push_back(myRingBuilder.build(innerGeometricDetRings[i], theGeomDetGeometry));
0025     outerRings.push_back(myRingBuilder.build(outerGeometricDetRings[i], theGeomDetGeometry));
0026   }
0027 
0028   return new TIBLayer(innerRings, outerRings);
0029 }
0030 
0031 void TIBLayerBuilder::constructRings(vector<const GeometricDet*>& theGeometricRods,
0032                                      vector<vector<const GeometricDet*> >& innerGeometricDetRings,
0033                                      vector<vector<const GeometricDet*> >& outerGeometricDetRings) {
0034   double meanPerp = 0;
0035   for (vector<const GeometricDet*>::const_iterator it = theGeometricRods.begin(); it != theGeometricRods.end(); it++) {
0036     meanPerp = meanPerp + (*it)->positionBounds().perp();
0037   }
0038   meanPerp = meanPerp / theGeometricRods.size();
0039 
0040   vector<const GeometricDet*> theInnerGeometricRods;
0041   vector<const GeometricDet*> theOuterGeometricRods;
0042 
0043   for (vector<const GeometricDet*>::const_iterator it = theGeometricRods.begin(); it != theGeometricRods.end(); it++) {
0044     if ((*it)->positionBounds().perp() < meanPerp)
0045       theInnerGeometricRods.push_back(*it);
0046     if ((*it)->positionBounds().perp() > meanPerp)
0047       theOuterGeometricRods.push_back(*it);
0048   }
0049 
0050   size_t innerLeftRodMaxSize = 0;
0051   size_t innerRightRodMaxSize = 0;
0052   size_t outerLeftRodMaxSize = 0;
0053   size_t outerRightRodMaxSize = 0;
0054 
0055   for (vector<const GeometricDet*>::const_iterator it = theInnerGeometricRods.begin();
0056        it != theInnerGeometricRods.end();
0057        it++) {
0058     if ((*it)->positionBounds().z() < 0)
0059       innerLeftRodMaxSize = max(innerLeftRodMaxSize, (**it).components().size());
0060     if ((*it)->positionBounds().z() > 0)
0061       innerRightRodMaxSize = max(innerRightRodMaxSize, (**it).components().size());
0062   }
0063 
0064   for (vector<const GeometricDet*>::const_iterator it = theOuterGeometricRods.begin();
0065        it != theOuterGeometricRods.end();
0066        it++) {
0067     if ((*it)->positionBounds().z() < 0)
0068       outerLeftRodMaxSize = max(outerLeftRodMaxSize, (**it).components().size());
0069     if ((*it)->positionBounds().z() > 0)
0070       outerRightRodMaxSize = max(outerRightRodMaxSize, (**it).components().size());
0071   }
0072 
0073   LogDebug("TkDetLayers") << "innerLeftRodMaxSize: " << innerLeftRodMaxSize;
0074   LogDebug("TkDetLayers") << "innerRightRodMaxSize: " << innerRightRodMaxSize;
0075 
0076   LogDebug("TkDetLayers") << "outerLeftRodMaxSize: " << outerLeftRodMaxSize;
0077   LogDebug("TkDetLayers") << "outerRightRodMaxSize: " << outerRightRodMaxSize;
0078 
0079   for (unsigned int i = 0; i < (innerLeftRodMaxSize + innerRightRodMaxSize); i++) {
0080     innerGeometricDetRings.push_back(vector<const GeometricDet*>());
0081   }
0082 
0083   for (unsigned int i = 0; i < (outerLeftRodMaxSize + outerRightRodMaxSize); i++) {
0084     outerGeometricDetRings.push_back(vector<const GeometricDet*>());
0085   }
0086 
0087   for (unsigned int ringN = 0; ringN < innerLeftRodMaxSize; ringN++) {
0088     for (vector<const GeometricDet*>::const_iterator it = theInnerGeometricRods.begin();
0089          it != theInnerGeometricRods.end();
0090          it++) {
0091       if ((*it)->positionBounds().z() < 0) {
0092         if ((**it).components().size() > ringN)
0093           innerGeometricDetRings[ringN].push_back((**it).components()[ringN]);
0094       }
0095     }
0096   }
0097 
0098   for (unsigned int ringN = 0; ringN < innerRightRodMaxSize; ringN++) {
0099     for (vector<const GeometricDet*>::const_iterator it = theInnerGeometricRods.begin();
0100          it != theInnerGeometricRods.end();
0101          it++) {
0102       if ((*it)->positionBounds().z() > 0) {
0103         if ((**it).components().size() > ringN)
0104           innerGeometricDetRings[innerLeftRodMaxSize + ringN].push_back((**it).components()[ringN]);
0105       }
0106     }
0107   }
0108 
0109   for (unsigned int ringN = 0; ringN < outerLeftRodMaxSize; ringN++) {
0110     for (vector<const GeometricDet*>::const_iterator it = theOuterGeometricRods.begin();
0111          it != theOuterGeometricRods.end();
0112          it++) {
0113       if ((*it)->positionBounds().z() < 0) {
0114         if ((**it).components().size() > ringN)
0115           outerGeometricDetRings[ringN].push_back((**it).components()[ringN]);
0116       }
0117     }
0118   }
0119 
0120   for (unsigned int ringN = 0; ringN < outerRightRodMaxSize; ringN++) {
0121     for (vector<const GeometricDet*>::const_iterator it = theOuterGeometricRods.begin();
0122          it != theOuterGeometricRods.end();
0123          it++) {
0124       if ((*it)->positionBounds().z() > 0) {
0125         if ((**it).components().size() > ringN)
0126           outerGeometricDetRings[outerLeftRodMaxSize + ringN].push_back((**it).components()[ringN]);
0127       }
0128     }
0129   }
0130 }