Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "TOBLayerBuilder.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "TOBRodBuilder.h"
0006 
0007 using namespace edm;
0008 using namespace std;
0009 
0010 TOBLayer* TOBLayerBuilder::build(const GeometricDet* aTOBLayer, const TrackerGeometry* theGeomDetGeometry) {
0011   vector<const GeometricDet*> theGeometricDetRods = aTOBLayer->components();
0012   vector<const GeometricDet*> negativeZrods;
0013   vector<const GeometricDet*> positiveZrods;
0014 
0015   for (vector<const GeometricDet*>::const_iterator it = theGeometricDetRods.begin(); it != theGeometricDetRods.end();
0016        it++) {
0017     if ((*it)->positionBounds().z() < 0)
0018       negativeZrods.push_back(*it);
0019     if ((*it)->positionBounds().z() >= 0)
0020       positiveZrods.push_back(*it);
0021   }
0022 
0023   TOBRodBuilder myTOBRodBuilder;
0024 
0025   vector<const TOBRod*> theInnerRods;
0026   vector<const TOBRod*> theOuterRods;
0027 
0028   //LogDebug("TkDetLayers") << "positiveZrods[0]->positionBounds().perp(): "
0029   //              << positiveZrods[0]->positionBounds().perp() ;
0030   //LogDebug("TkDetLayers") << "positiveZrods[1]->positionBounds().perp(): "
0031   //              << positiveZrods[1]->positionBounds().perp() ;
0032 
0033   double positiveMeanR = 0;
0034   if (!positiveZrods.empty()) {
0035     for (unsigned int index = 0; index != positiveZrods.size(); index++) {
0036       positiveMeanR += positiveZrods[index]->positionBounds().perp();
0037     }
0038     positiveMeanR = positiveMeanR / positiveZrods.size();
0039   }
0040 
0041   double negativeMeanR = 0;
0042   if (!negativeZrods.empty()) {
0043     for (unsigned int index = 0; index != negativeZrods.size(); index++) {
0044       negativeMeanR += negativeZrods[index]->positionBounds().perp();
0045     }
0046     negativeMeanR = negativeMeanR / negativeZrods.size();
0047   }
0048 
0049   if (!positiveZrods.empty() && !negativeZrods.empty()) {
0050     for (unsigned int index = 0; index != positiveZrods.size(); index++) {
0051       if (positiveZrods[index]->positionBounds().phi() != negativeZrods[index]->positionBounds().phi()) {
0052         edm::LogError("TkDetLayers") << "ERROR:rods don't have the same phi. exit!";
0053         break;
0054       }
0055 
0056       if (positiveZrods[index]->positionBounds().perp() < positiveMeanR)
0057         theInnerRods.push_back(myTOBRodBuilder.build(negativeZrods[index], positiveZrods[index], theGeomDetGeometry));
0058       if (positiveZrods[index]->positionBounds().perp() >= positiveMeanR)
0059         theOuterRods.push_back(myTOBRodBuilder.build(negativeZrods[index], positiveZrods[index], theGeomDetGeometry));
0060     }
0061   } else {
0062     if (!positiveZrods.empty()) {
0063       for (unsigned int index = 0; index != positiveZrods.size(); index++) {
0064         if (positiveZrods[index]->positionBounds().perp() < positiveMeanR)
0065           theInnerRods.push_back(myTOBRodBuilder.build(nullptr, positiveZrods[index], theGeomDetGeometry));
0066         if (positiveZrods[index]->positionBounds().perp() >= positiveMeanR)
0067           theOuterRods.push_back(myTOBRodBuilder.build(nullptr, positiveZrods[index], theGeomDetGeometry));
0068       }
0069     }
0070     if (!negativeZrods.empty()) {
0071       for (unsigned int index = 0; index != negativeZrods.size(); index++) {
0072         if (negativeZrods[index]->positionBounds().perp() < negativeMeanR)
0073           theInnerRods.push_back(myTOBRodBuilder.build(negativeZrods[index], nullptr, theGeomDetGeometry));
0074         if (negativeZrods[index]->positionBounds().perp() >= negativeMeanR)
0075           theOuterRods.push_back(myTOBRodBuilder.build(negativeZrods[index], nullptr, theGeomDetGeometry));
0076       }
0077     }
0078   }
0079 
0080   //LogDebug("TkDetLayers") << "theInnerRods.size(): " << theInnerRods.size() ;
0081   //LogDebug("TkDetLayers") << "theOuterRods.size(): " << theOuterRods.size() ;
0082 
0083   return new TOBLayer(theInnerRods, theOuterRods);
0084 }