Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:12

0001 #include "CondDBCmsTrackerConstruction.h"
0002 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0003 #include "DetectorDescription/Core/interface/DDCompactView.h"
0004 #include "CondFormats/GeometryObjects/interface/PGeometricDet.h"
0005 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
0006 #include "Geometry/TrackerNumberingBuilder/plugins/ExtractStringFromDDD.h"
0007 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerBuilder.h"
0008 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerDetIdBuilder.h"
0009 
0010 using namespace cms;
0011 
0012 std::unique_ptr<GeometricDet> CondDBCmsTrackerConstruction::construct(const PGeometricDet& pgd) {
0013   //std::cout << "In CondDBCmsTrackerConstruction::construct with pgd.pgeomdets_.size() == " << pgd.pgeomdets_.size() << std::endl;
0014   auto tracker = std::make_unique<GeometricDet>(pgd.pgeomdets_[0], GeometricDet::Tracker);
0015 
0016   size_t detMax = pgd.pgeomdets_.size();
0017   size_t tri = 1;
0018   std::vector<GeometricDet*> hier;
0019   int lev = 1;
0020   GeometricDet* subdet = tracker.get();
0021   hier.emplace_back(subdet);
0022   while (tri < detMax && pgd.pgeomdets_[tri]._level == 1) {
0023     subdet = new GeometricDet(pgd.pgeomdets_[tri], GeometricDet::GDEnumType(pgd.pgeomdets_[tri]._type));
0024     //std::cout << lev << " type " << pgd.pgeomdets_[tri]._type << " " << subdet->geographicalId() << std::endl;
0025     ++tri;
0026     hier.back()->addComponent(subdet);
0027     hier.emplace_back(subdet);
0028     ++lev;
0029     while (tri < detMax && pgd.pgeomdets_[tri]._level == 2) {
0030       subdet = new GeometricDet(pgd.pgeomdets_[tri], GeometricDet::GDEnumType(pgd.pgeomdets_[tri]._type));
0031       //std::cout << lev << "\ttype " << pgd.pgeomdets_[tri]._type << " " << subdet->geographicalId() << std::endl;
0032       ++tri;
0033       hier.back()->addComponent(subdet);
0034       hier.emplace_back(subdet);
0035       ++lev;
0036       while (tri < detMax && pgd.pgeomdets_[tri]._level == 3) {
0037         subdet = new GeometricDet(pgd.pgeomdets_[tri], GeometricDet::GDEnumType(pgd.pgeomdets_[tri]._type));
0038         //std::cout << lev << "\t\ttype " << pgd.pgeomdets_[tri]._type << " " << subdet->geographicalId() << std::endl;
0039         ++tri;
0040         hier.back()->addComponent(subdet);
0041         hier.emplace_back(subdet);
0042         ++lev;
0043         while (tri < detMax && pgd.pgeomdets_[tri]._level == 4) {
0044           subdet = new GeometricDet(pgd.pgeomdets_[tri], GeometricDet::GDEnumType(pgd.pgeomdets_[tri]._type));
0045           //std::cout << lev << "\t\t\ttype " << pgd.pgeomdets_[tri]._type << " " << subdet->geographicalId() << std::endl;
0046           ++tri;
0047           hier.back()->addComponent(subdet);
0048           hier.emplace_back(subdet);
0049           ++lev;
0050           while (tri < detMax && pgd.pgeomdets_[tri]._level == 5) {
0051             subdet = new GeometricDet(pgd.pgeomdets_[tri], GeometricDet::GDEnumType(pgd.pgeomdets_[tri]._type));
0052             //std::cout << lev << "\t\t\t\ttype " << pgd.pgeomdets_[tri]._type << " " << subdet->geographicalId() << std::endl;
0053             ++tri;
0054             hier.back()->addComponent(subdet);
0055             hier.emplace_back(subdet);
0056             ++lev;
0057             while (tri < detMax && pgd.pgeomdets_[tri]._level == 6) {
0058               subdet = new GeometricDet(pgd.pgeomdets_[tri], GeometricDet::GDEnumType(pgd.pgeomdets_[tri]._type));
0059               //std::cout << lev << "\t\t\t\t\ttype " << pgd.pgeomdets_[tri]._type << " " << subdet->geographicalId() << std::endl;
0060               ++tri;
0061               hier.back()->addComponent(subdet);
0062             }
0063             --lev;
0064             hier.pop_back();
0065           }
0066           --lev;
0067           hier.pop_back();
0068         }
0069         --lev;
0070         hier.pop_back();
0071       }
0072       --lev;
0073       hier.pop_back();
0074     }
0075     --lev;
0076     hier.pop_back();
0077   }
0078   //     std::cout << "Before \"deep components\" test I want to see if I can iterate to 6 layers by myself..." << std::endl;
0079   //     std::vector<const GeometricDet*> l0 = tracker->components();
0080   //     std::vector<const GeometricDet*>::const_iterator i0 = l0.begin();
0081   //     std::vector<const GeometricDet*>::const_iterator e0 = l0.end();
0082   //     int count=0; // count only the leaves.
0083   //     for ( ; i0 != e0 ; ++i0) {
0084   //       std::cout << lev << " type " << (*i0)->type() << " " << int((*i0)->geographicalId()) << std::endl;
0085   //       std::vector<const GeometricDet*> l1 = (*i0)->components();
0086   //       if ( l1.size() == 0 )  ++count;
0087   //       std::vector<const GeometricDet*>::const_iterator i1 = l1.begin();
0088   //       std::vector<const GeometricDet*>::const_iterator e1 = l1.end();
0089   //       ++lev;
0090   //       for ( ; i1 != e1 ; ++i1) {
0091   //    std::cout << lev << "\ttype " << (*i1)->type() << " " << int((*i1)->geographicalId()) << std::endl;
0092   //    std::vector<const GeometricDet*> l2 = (*i1)->components();
0093   //    if ( l2.size() == 0 )  ++count;
0094   //    std::vector<const GeometricDet*>::const_iterator i2 = l1.begin();
0095   //    std::vector<const GeometricDet*>::const_iterator e2 = l1.end();
0096   //    ++lev;
0097   //    for ( ; i2 != e2 ; ++i2) {
0098   //      std::cout << lev << "\t\ttype " << (*i2)->type() << " " << int((*i2)->geographicalId()) << std::endl;
0099   //      std::vector<const GeometricDet*> l3 = (*i2)->components();
0100   //      if ( l3.size() == 0 )  ++count;
0101   //      std::vector<const GeometricDet*>::const_iterator i3 = l3.begin();
0102   //      std::vector<const GeometricDet*>::const_iterator e3 = l3.end();
0103   //      ++lev;
0104   //      for ( ; i3 != e3 ; ++i3) {
0105   //        std::cout << lev << "\t\t\ttype " << (*i3)->type() << " " << int((*i3)->geographicalId()) << std::endl;
0106   //        std::vector<const GeometricDet*> l4 = (*i3)->components();
0107   //        if ( l4.size() == 0 )  ++count;
0108   //        std::vector<const GeometricDet*>::const_iterator i4 = l4.begin();
0109   //        std::vector<const GeometricDet*>::const_iterator e4 = l4.end();
0110   //        ++lev;
0111   //        for ( ; i4 != e4 ; ++i4) {
0112   //          std::cout << lev << "\t\t\t\ttype " << (*i4)->type() << " " << int((*i4)->geographicalId()) << std::endl;
0113   //          std::vector<const GeometricDet*> l5 = (*i4)->components();
0114   //          if ( l5.size() == 0 )  ++count;
0115   //          std::vector<const GeometricDet*>::const_iterator i5 = l5.begin();
0116   //          std::vector<const GeometricDet*>::const_iterator e5 = l5.end();
0117   //          ++lev;
0118   //          for ( ; i5 != e5 ; ++i5) {
0119   //        std::cout << lev << "\t\t\t\t\ttype " << (*i5)->type() << " " << int((*i5)->geographicalId()) << std::endl;
0120   //        ++count;
0121   //        //       std::vector<const GeometricDet*> l6 = (*i0)->components();
0122   //        //       std::vector<const GeometricDet*>::const_iterator i6 = l6.begin();
0123   //        //       std::vector<const GeometricDet*>::const_iterator e6 = l6.end();
0124   //        //     for ( ; i6 != e6 ; ++i6) {
0125   //        //       std::cout << lev << " type " << (*i6)->type() << " " << int((*i6)->geographicalId()) << std::endl;
0126   //        //       std::vector<const GeometricDet*> l1 = (*i0)->components();
0127   //        //       std::vector<const GeometricDet*>::const_iterator i1 = l1.begin();
0128   //        //       std::vector<const GeometricDet*>::const_iterator e1 = l1.end();
0129   //        //     }
0130   //          }
0131   //          --lev;
0132   //        }
0133   //        --lev;
0134   //      }
0135   //      --lev;
0136   //    }
0137   //    --lev;
0138   //       }
0139   //       --lev;
0140   //     }
0141   //     std::cout << "done... count = " << count << std::endl;
0142   //     std::cout << "about to try to see what the \"deep components\" are" << std::endl;
0143   //    std::cout << "done with the \"deep components\" check, there are: " << tracker->deepComponents().size() << std::endl;
0144   return tracker;
0145 }