Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:47

0001 #include "Phase2OTBarrelLayerBuilder.h"
0002 #include "Phase2OTtiltedBarrelLayer.h"
0003 #include "Phase2OTBarrelRodBuilder.h"
0004 #include "Phase2EndcapRingBuilder.h"
0005 
0006 using namespace std;
0007 using namespace edm;
0008 
0009 Phase2OTBarrelLayer* Phase2OTBarrelLayerBuilder::build(const GeometricDet* aPhase2OTBarrelLayer,
0010                                                        const TrackerGeometry* theGeomDetGeometry,
0011                                                        const bool useBrothers) {
0012   // This builder is very similar to TOBLayer one. Most of the code should be put in a
0013   // common place.
0014 
0015   LogTrace("TkDetLayers") << "Phase2OTBarrelLayerBuilder::build";
0016   vector<const GeometricDet*> theGeometricDets = aPhase2OTBarrelLayer->components();
0017   LogDebug("TkDetLayers") << "Phase2OTBarrelLayerBuilder with #Components: " << theGeometricDets.size() << std::endl;
0018   vector<const GeometricDet*> theGeometricDetRods;
0019   vector<const GeometricDet*> theGeometricDetRings;
0020 
0021   for (vector<const GeometricDet*>::const_iterator it = theGeometricDets.begin(); it != theGeometricDets.end(); it++) {
0022     if ((*it)->type() == GeometricDet::ladder) {
0023       theGeometricDetRods.push_back(*it);
0024     } else if ((*it)->type() == GeometricDet::panel) {
0025       theGeometricDetRings.push_back(*it);
0026     } else {
0027       LogDebug("TkDetLayers") << "Phase2OTBarrelLayerBuilder with no Rods and no Rings! ";
0028     }
0029   }
0030 
0031   LogDebug("TkDetLayers") << "Phase2OTBarrelLayerBuilder with #Rods: " << theGeometricDetRods.size() << std::endl;
0032 
0033   Phase2OTBarrelRodBuilder myPhase2OTBarrelRodBuilder;
0034 
0035   vector<const Phase2OTBarrelRod*> theInnerRods;
0036   vector<const Phase2OTBarrelRod*> theOuterRods;
0037 
0038   // properly calculate the meanR value to separate rod in inner/outer.
0039 
0040   double meanR = 0;
0041   for (unsigned int index = 0; index != theGeometricDetRods.size(); index++)
0042     meanR += theGeometricDetRods[index]->positionBounds().perp();
0043   if (!theGeometricDetRods.empty())
0044 
0045     meanR /= (double)theGeometricDetRods.size();
0046 
0047   for (unsigned int index = 0; index != theGeometricDetRods.size(); index++) {
0048     if (theGeometricDetRods[index]->positionBounds().perp() < meanR)
0049       theInnerRods.push_back(
0050           myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], theGeomDetGeometry, useBrothers));
0051 
0052     if (theGeometricDetRods[index]->positionBounds().perp() > meanR)
0053       theOuterRods.push_back(
0054           myPhase2OTBarrelRodBuilder.build(theGeometricDetRods[index], theGeomDetGeometry, useBrothers));
0055   }
0056 
0057   if (theGeometricDetRings.empty())
0058     return new Phase2OTBarrelLayer(theInnerRods, theOuterRods);
0059 
0060   LogDebug("TkDetLayers") << "Phase2OTBarrelLayerBuilder with #Rings: " << theGeometricDetRings.size() << std::endl;
0061 
0062   Phase2EndcapRingBuilder myPhase2EndcapRingBuilder;
0063 
0064   vector<const Phase2EndcapRing*> theNegativeRings;
0065   vector<const Phase2EndcapRing*> thePositiveRings;
0066 
0067   // properly calculate the meanR value to separate rod in inner/outer.
0068   double centralZ = 0.0;
0069 
0070   for (vector<const GeometricDet*>::const_iterator it = theGeometricDetRings.begin(); it != theGeometricDetRings.end();
0071        it++) {
0072     if ((*it)->positionBounds().z() < centralZ)
0073       theNegativeRings.push_back(myPhase2EndcapRingBuilder.build(*it, theGeomDetGeometry, useBrothers));
0074     if ((*it)->positionBounds().z() > centralZ)
0075       thePositiveRings.push_back(myPhase2EndcapRingBuilder.build(*it, theGeomDetGeometry, useBrothers));
0076   }
0077 
0078   return new Phase2OTtiltedBarrelLayer(theInnerRods, theOuterRods, theNegativeRings, thePositiveRings);
0079 }