CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TrackerGeometricDetExtraESModule Class Reference

#include <TrackerGeometricDetExtraESModule.h>

Inheritance diagram for TrackerGeometricDetExtraESModule:
edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

List of all members.

Public Member Functions

boost::shared_ptr< std::vector
< GeometricDetExtra > > 
produce (const IdealGeometryRecord &)
 TrackerGeometricDetExtraESModule (const edm::ParameterSet &p)
virtual ~TrackerGeometricDetExtraESModule ()

Private Member Functions

void putOne (std::vector< GeometricDetExtra > &gde, const GeometricDet *gd, const DDExpandedView &ev, int lev)

Private Attributes

bool fromDDD_

Detailed Description

Definition at line 10 of file TrackerGeometricDetExtraESModule.h.


Constructor & Destructor Documentation

TrackerGeometricDetExtraESModule::TrackerGeometricDetExtraESModule ( const edm::ParameterSet p)

Definition at line 24 of file TrackerGeometricDetExtraESModule.cc.

References edm::ESProducer::setWhatProduced().

  : fromDDD_(p.getParameter<bool>("fromDDD")) 
{
  setWhatProduced(this);
}
TrackerGeometricDetExtraESModule::~TrackerGeometricDetExtraESModule ( ) [virtual]

Definition at line 30 of file TrackerGeometricDetExtraESModule.cc.

{}

Member Function Documentation

boost::shared_ptr< std::vector< GeometricDetExtra > > TrackerGeometricDetExtraESModule::produce ( const IdealGeometryRecord iRecord)

Definition at line 33 of file TrackerGeometricDetExtraESModule.cc.

References GeometricDet::components(), prof2calltree::count, GeometricDet::deepComponents(), fromDDD_, edm::eventsetup::EventSetupRecord::get(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), DDExpandedView::goTo(), i, GeometricDet::navType(), putOne(), and patCandidatesForDimuonsSequences_cff::tracker.

                                                                             {
  boost::shared_ptr<std::vector<GeometricDetExtra> > gde (new std::vector<GeometricDetExtra>);
  // get the GeometricDet which has a nav_type
  edm::ESHandle<GeometricDet> gd;
  iRecord.get ( gd );
  if (fromDDD_) {
  // traverse all components from the tracker down;
  // read the DD if from DD
    const GeometricDet* tracker = &(*gd);
    edm::ESTransientHandle<DDCompactView> cpv;
    iRecord.get( cpv );
    DDExpandedView ev(*cpv);
    ev.goTo(tracker->navType());
    putOne((*gde), tracker, ev, 0);
    std::vector<const GeometricDet*> tc = tracker->components();
    std::vector<const GeometricDet*>::const_iterator git = tc.begin();
    std::vector<const GeometricDet*>::const_iterator egit = tc.end();
    int count=0;
    int lev = 1;
    //  CmsTrackerStringToEnum ctst
    gde->reserve(tracker->deepComponents().size());
    for (; git!= egit; ++git) {  // one level below "tracker"
      ev.goTo((*git)->navType());
      putOne((*gde), *git, ev, lev);
      std::vector<const GeometricDet*> inone = (*git)->components();
      //    std::cout << lev << " type " << (*git)->type() << " " << int((*git)->geographicalId()) << std::endl; // << " has " << inone.size() << " components." << std::endl;
      if ( inone.size() == 0 )  ++count;
      std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
      std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
      ++lev;
      for (; git2 != egit2; ++git2) { // level 2
        ev.goTo((*git2)->navType());
        putOne((*gde), *git2, ev, lev);
        std::vector<const GeometricDet*> intwo= (*git2)->components();
        //      std::cout << lev << "\ttype " << (*git2)->type() << " " << int((*git2)->geographicalId()) << std::endl; // << " has " << intwo.size() << " components." << std::endl;
        if ( intwo.size() == 0 )  ++count;
        std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
        std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
        ++lev;
        for (; git3 != egit3; ++git3) { // level 3
          ev.goTo((*git3)->navType());
          putOne((*gde), *git3, ev, lev);
          std::vector<const GeometricDet*> inthree= (*git3)->components();
          //std::cout << lev << "\t\ttype " << (*git3)->type() << " " << int((*git3)->geographicalId()) << std::endl; // << " has " << inthree.size() << " components." << std::endl;
          if ( inthree.size() == 0 )  ++count;
          std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
          std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
          ++lev;
          for (; git4 != egit4; ++git4) { //level 4
            ev.goTo((*git4)->navType());
            putOne((*gde), *git4, ev, lev);
            std::vector<const GeometricDet*> infour= (*git4)->components();
            //  std::cout << lev << "\t\t\ttype " << (*git4)->type() << " " << int((*git4)->geographicalId()) << std::endl; // << " has " << infour.size() << " components." << std::endl;
            if ( infour.size() == 0 )  ++count;
            std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
            std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
            ++lev;
            for (; git5 != egit5; ++git5) { // level 5
              ev.goTo((*git5)->navType());
              putOne((*gde), *git5, ev, lev);
              std::vector<const GeometricDet*> infive= (*git5)->components();
              //    std::cout << lev << "\t\t\t\ttype " << (*git5)->type() << " " << int((*git5)->geographicalId()) << std::endl; // << " has " << infive.size() << " components." << std::endl;
              if ( infive.size() == 0 )  ++count;
              std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
              std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
              ++lev;
              for (; git6 != egit6; ++git6) { //level 6
                ev.goTo((*git6)->navType());
                putOne((*gde), *git6, ev, lev);
                std::vector<const GeometricDet*> insix= (*git6)->components();
                //      std::cout << lev << "\t\t\t\t\ttype " << (*git6)->type() << " " << int((*git6)->geographicalId()) << std::endl; // << " has " << insix.size() << " components." << std::endl;
                if ( insix.size() == 0 ){
                  ++count;
                } else {
                  edm::LogError("GeometricDetExtra") << "Hierarchy has exceeded hard-coded level 6 for Tracker " ;
                }
              } // level 6
              --lev;
            } // level 5
            --lev;
          } // level 4
          --lev;
        } //level 3
        --lev;
      } // level 2
      --lev;
    }
  }else{
    // if it is not from the DD, then just get the GDE from ES and match w/ GD.
    edm::ESHandle<PGeometricDetExtra> pgde;
    iRecord.getRecord<PGeometricDetExtraRcd>().get(pgde);
    std::map<uint32_t, const GeometricDet*> helperMap;
    const GeometricDet* tracker = &(*gd);
    helperMap[gd->geographicalID()] = tracker;
    std::vector<const GeometricDet*> tc = tracker->components();
    std::vector<const GeometricDet*>::const_iterator git = tc.begin();
    std::vector<const GeometricDet*>::const_iterator egit = tc.end();
    for (; git!= egit; ++git) {  // one level below "tracker"
      helperMap[(*git)->geographicalID()] = (*git);
      std::vector<const GeometricDet*> inone = (*git)->components();
      std::vector<const GeometricDet*>::const_iterator git2 = inone.begin();
      std::vector<const GeometricDet*>::const_iterator egit2 = inone.end();
      for (; git2 != egit2; ++git2) { // level 2
        helperMap[(*git2)->geographicalID()] = (*git2);
        std::vector<const GeometricDet*> intwo= (*git2)->components();
        std::vector<const GeometricDet*>::const_iterator git3 = intwo.begin();
        std::vector<const GeometricDet*>::const_iterator egit3 = intwo.end();
        for (; git3 != egit3; ++git3) { // level 3
          helperMap[(*git3)->geographicalID()] = (*git3);
          std::vector<const GeometricDet*> inthree= (*git3)->components();
          std::vector<const GeometricDet*>::const_iterator git4 = inthree.begin();
          std::vector<const GeometricDet*>::const_iterator egit4 = inthree.end();
          for (; git4 != egit4; ++git4) { //level 4
            helperMap[(*git4)->geographicalID()] = (*git4);
            std::vector<const GeometricDet*> infour= (*git4)->components();
            std::vector<const GeometricDet*>::const_iterator git5 = infour.begin();
            std::vector<const GeometricDet*>::const_iterator egit5 = infour.end();
            for (; git5 != egit5; ++git5) { // level 5
              helperMap[(*git5)->geographicalID()] = (*git5);
              std::vector<const GeometricDet*> infive= (*git5)->components();
              std::vector<const GeometricDet*>::const_iterator git6 = infive.begin();
              std::vector<const GeometricDet*>::const_iterator egit6 = infive.end();
              for (; git6 != egit6; ++git6) { //level 6
                helperMap[(*git6)->geographicalID()] = (*git6);
                if ( (*git6)->components().size() != 0 ){
                  edm::LogError("GeometricDetExtra") << "Hierarchy has exceeded hard-coded level of 6 for Tracker " ;
                }
              } // level 6
            } // level 5
          } // level 4
        } //level 3
      } // level 2
    }
  
    const std::vector<PGeometricDetExtra::Item>& pgdes = pgde->pgdes_;
    gde->reserve(pgdes.size());
    std::vector<DDExpandedNode> evs; //EMPTY
    std::string nm; //EMPTY
    for (unsigned int i = 0; i < pgdes.size(); ++i) {
        //   GeometricDetExtra( GeometricDet const *gd, DetId id, GeoHistory& gh,  double vol, double dens, double wgt, double cpy, const std::string& mat, const std::string& name, bool dd=false );
      gde->push_back( GeometricDetExtra(helperMap[pgdes[i]._geographicalId], pgdes[i]._geographicalId, evs
                                       , pgdes[i]._volume, pgdes[i]._density, pgdes[i]._weight, pgdes[i]._copy
                                       , pgdes[i]._material, nm));
    }
  }
  return boost::shared_ptr<std::vector<GeometricDetExtra> >(gde);
}
void TrackerGeometricDetExtraESModule::putOne ( std::vector< GeometricDetExtra > &  gde,
const GeometricDet gd,
const DDExpandedView ev,
int  lev 
) [private]

Definition at line 181 of file TrackerGeometricDetExtraESModule.cc.

References DDExpandedView::copyno(), GeometricDet::geographicalId(), DDExpandedView::geoHistory(), DDExpandedView::logicalPart(), AlCaRecoCosmics_cfg::name, and funct::true.

Referenced by produce().

                                                                                                                                            {
  std::string matname = ((ev.logicalPart()).material()).name().fullname();
  std::string lpname = ((ev.logicalPart()).name().fullname());
  std::vector<DDExpandedNode> evs = GeometricDetExtra::GeoHistory(ev.geoHistory().begin(),ev.geoHistory().end());
  gde.push_back(GeometricDetExtra( gd, gd->geographicalId(), evs,
                                   ((ev.logicalPart()).solid()).volume(), ((ev.logicalPart()).material()).density(),
                                   ((ev.logicalPart()).material()).density() * ( ((ev.logicalPart()).solid()).volume() / 1000.),                                                                       
                                   ev.copyno(), matname, lpname, true ));
}

Member Data Documentation

Definition at line 22 of file TrackerGeometricDetExtraESModule.h.

Referenced by produce().