Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "Phase2OTBarrelRodBuilder.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 using namespace edm;
0005 using namespace std;
0006 
0007 Phase2OTBarrelRod* Phase2OTBarrelRodBuilder::build(const GeometricDet* thePhase2OTBarrelRod,
0008                                                    const TrackerGeometry* theGeomDetGeometry,
0009                                                    const bool useBrothers) {
0010   vector<const GeometricDet*> allGeometricDets = thePhase2OTBarrelRod->components();
0011   LogDebug("TkDetLayers") << "Phase2OTBarrelRodBuilder with #Modules: " << allGeometricDets.size() << std::endl;
0012   LogDebug("TkDetLayers") << "                           useBrothers: " << useBrothers << std::endl;
0013 
0014   vector<const GeomDet*> innerGeomDets;
0015   vector<const GeomDet*> outerGeomDets;
0016   vector<const GeomDet*> innerGeomDetBrothers;
0017   vector<const GeomDet*> outerGeomDetBrothers;
0018 
0019   double meanR = 0;
0020 
0021   if (!useBrothers) {
0022     for (auto const& compGeometricDets : allGeometricDets) {
0023       meanR = meanR + compGeometricDets->positionBounds().perp();
0024     }
0025     meanR = meanR / allGeometricDets.size();
0026     LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl;
0027     for (auto const& compGeometricDets : allGeometricDets) {
0028       const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets->geographicalId());
0029 
0030       if (compGeometricDets->positionBounds().perp() < meanR)
0031         innerGeomDets.push_back(theGeomDet);
0032 
0033       if (compGeometricDets->positionBounds().perp() > meanR)
0034         outerGeomDets.push_back(theGeomDet);
0035     }
0036 
0037     LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size();
0038     LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size();
0039 
0040   } else {
0041     vector<const GeometricDet*> compGeometricDets;
0042 
0043     double meanRBrothers = 0;
0044     for (auto& it : allGeometricDets) {
0045       compGeometricDets = it->components();
0046       if (compGeometricDets.size() != 2) {
0047         LogDebug("TkDetLayers") << " Stack not with two components but with " << compGeometricDets.size() << std::endl;
0048       } else {
0049         meanR = meanR + compGeometricDets[0]->positionBounds().perp();
0050         meanRBrothers = meanRBrothers + compGeometricDets[1]->positionBounds().perp();
0051       }
0052     }
0053     meanR = meanR / allGeometricDets.size();
0054     meanRBrothers = meanRBrothers / allGeometricDets.size();
0055     LogDebug("TkDetLayers") << " meanR Lower " << meanR << std::endl;
0056     LogDebug("TkDetLayers") << " meanR Upper " << meanRBrothers << std::endl;
0057 
0058     for (auto& it : allGeometricDets) {
0059       compGeometricDets = it->components();
0060       const GeomDet* theGeomDet = theGeomDetGeometry->idToDet(compGeometricDets[0]->geographicalId());
0061       LogTrace("TkDetLayers") << " inserting " << compGeometricDets[0]->geographicalId().rawId() << std::endl;
0062 
0063       if (compGeometricDets[0]->positionBounds().perp() < meanR)
0064         innerGeomDets.push_back(theGeomDet);
0065 
0066       else
0067         outerGeomDets.push_back(theGeomDet);
0068 
0069       const GeomDet* theGeomDetBrother = theGeomDetGeometry->idToDet(compGeometricDets[1]->geographicalId());
0070       LogTrace("TkDetLayers") << " inserting " << compGeometricDets[1]->geographicalId().rawId() << std::endl;
0071       if (compGeometricDets[1]->positionBounds().perp() < meanRBrothers)
0072         innerGeomDetBrothers.push_back(theGeomDetBrother);
0073 
0074       else
0075         outerGeomDetBrothers.push_back(theGeomDetBrother);
0076     }
0077 
0078     LogDebug("TkDetLayers") << "innerGeomDets.size(): " << innerGeomDets.size();
0079     LogDebug("TkDetLayers") << "outerGeomDets.size(): " << outerGeomDets.size();
0080     LogDebug("TkDetLayers") << "innerGeomDetsBro.size(): " << innerGeomDetBrothers.size();
0081     LogDebug("TkDetLayers") << "outerGeomDetsBro.size(): " << outerGeomDetBrothers.size();
0082   }
0083 
0084   return new Phase2OTBarrelRod(innerGeomDets, outerGeomDets, innerGeomDetBrothers, outerGeomDetBrothers);
0085 }